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 (all|ip|tcp|udp|sctp|ether|none)\n"
533 " Set the RSS mode.\n\n"
535 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
536 " Set the RSS redirection table.\n\n"
538 "port config (port_id) dcb vt (on|off) (traffic_class)"
540 " Set the DCB mode.\n\n"
542 "port config all burst (value)\n"
543 " Set the number of packets per burst.\n\n"
545 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
547 " Set the ring prefetch/host/writeback threshold"
548 " for tx/rx queue.\n\n"
550 "port config all (txfreet|txrst|rxfreet) (value)\n"
551 " Set free threshold for rx/tx, or set"
552 " tx rs bit threshold.\n\n"
553 "port config mtu X value\n"
554 " Set the MTU of port X to a given value\n\n"
556 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
557 " Start/stop a rx/tx queue of port X. Only take effect"
558 " when port X is started\n"
562 if (show_all || !strcmp(res->section, "registers")) {
570 "read reg (port_id) (address)\n"
571 " Display value of a port register.\n\n"
573 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
574 " Display a port register bit field.\n\n"
576 "read regbit (port_id) (address) (bit_x)\n"
577 " Display a single port register bit.\n\n"
579 "write reg (port_id) (address) (value)\n"
580 " Set value of a port register.\n\n"
582 "write regfield (port_id) (address) (bit_x) (bit_y)"
584 " Set bit field of a port register.\n\n"
586 "write regbit (port_id) (address) (bit_x) (value)\n"
587 " Set single bit value of a port register.\n\n"
590 if (show_all || !strcmp(res->section, "filters")) {
598 "ethertype_filter (port_id) (add|del)"
599 " (mac_addr|mac_ignr) (mac_address) ethertype"
600 " (ether_type) (drop|fwd) queue (queue_id)\n"
601 " Add/Del an ethertype filter.\n\n"
603 "2tuple_filter (port_id) (add|del)"
604 " dst_port (dst_port_value) protocol (protocol_value)"
605 " mask (mask_value) tcp_flags (tcp_flags_value)"
606 " priority (prio_value) queue (queue_id)\n"
607 " Add/Del a 2tuple filter.\n\n"
609 "5tuple_filter (port_id) (add|del)"
610 " dst_ip (dst_address) src_ip (src_address)"
611 " dst_port (dst_port_value) src_port (src_port_value)"
612 " protocol (protocol_value)"
613 " mask (mask_value) tcp_flags (tcp_flags_value)"
614 " priority (prio_value) queue (queue_id)\n"
615 " Add/Del a 5tuple filter.\n\n"
617 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
618 " Add/Del syn filter.\n\n"
620 "flex_filter (port_id) (add|del) len (len_value)"
621 " bytes (bytes_value) mask (mask_value)"
622 " priority (prio_value) queue (queue_id)\n"
623 " Add/Del a flex filter.\n\n"
625 "flow_director_filter (port_id) (add|del|update)"
626 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
627 " src (src_ip_address) dst (dst_ip_address)"
628 " vlan (vlan_value) flexbytes (flexbytes_value)"
629 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
630 " Add/Del an IP type flow director filter.\n\n"
632 "flow_director_filter (port_id) (add|del|update)"
633 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
634 " src (src_ip_address) (src_port)"
635 " dst (dst_ip_address) (dst_port)"
636 " vlan (vlan_value) flexbytes (flexbytes_value)"
637 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
638 " Add/Del an UDP/TCP type flow director filter.\n\n"
640 "flow_director_filter (port_id) (add|del|update)"
641 " flow (ipv4-sctp|ipv6-sctp)"
642 " src (src_ip_address) (src_port)"
643 " dst (dst_ip_address) (dst_port)"
644 " tag (verification_tag) vlan (vlan_value)"
645 " flexbytes (flexbytes_value) (drop|fwd)"
646 " queue (queue_id) fd_id (fd_id_value)\n"
647 " Add/Del a SCTP type flow director filter.\n\n"
649 "flush_flow_director (port_id)\n"
650 " Flush all flow director entries of a device.\n\n"
652 "flow_director_mask (port_id) vlan (vlan_value)"
653 " src_mask (ipv4_src) (ipv6_src) (src_port)"
654 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
655 " Set flow director mask.\n\n"
657 "flow_director_flex_mask (port_id)"
658 " flow (raw|ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
659 " flow (raw|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
660 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|all)"
662 " Configure mask of flex payload.\n\n"
664 "flow_director_flex_payload (port_id)"
665 " (raw|l2|l3|l4) (config)\n"
666 " Configure flex payload selection.\n\n"
668 "get_sym_hash_ena_per_port (port_id)\n"
669 " get symmetric hash enable configuration per port.\n\n"
671 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
672 " set symmetric hash enable configuration per port"
673 " to enable or disable.\n\n"
675 "get_hash_global_config (port_id)\n"
676 " Get the global configurations of hash filters.\n\n"
678 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
679 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
680 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
681 " (enable|disable)\n"
682 " Set the global configurations of hash filters.\n\n"
687 cmdline_parse_token_string_t cmd_help_long_help =
688 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
690 cmdline_parse_token_string_t cmd_help_long_section =
691 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
692 "all#control#display#config#"
693 "ports#registers#filters");
695 cmdline_parse_inst_t cmd_help_long = {
696 .f = cmd_help_long_parsed,
698 .help_str = "show help",
700 (void *)&cmd_help_long_help,
701 (void *)&cmd_help_long_section,
707 /* *** start/stop/close all ports *** */
708 struct cmd_operate_port_result {
709 cmdline_fixed_string_t keyword;
710 cmdline_fixed_string_t name;
711 cmdline_fixed_string_t value;
714 static void cmd_operate_port_parsed(void *parsed_result,
715 __attribute__((unused)) struct cmdline *cl,
716 __attribute__((unused)) void *data)
718 struct cmd_operate_port_result *res = parsed_result;
720 if (!strcmp(res->name, "start"))
721 start_port(RTE_PORT_ALL);
722 else if (!strcmp(res->name, "stop"))
723 stop_port(RTE_PORT_ALL);
724 else if (!strcmp(res->name, "close"))
725 close_port(RTE_PORT_ALL);
727 printf("Unknown parameter\n");
730 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
731 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
733 cmdline_parse_token_string_t cmd_operate_port_all_port =
734 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
736 cmdline_parse_token_string_t cmd_operate_port_all_all =
737 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
739 cmdline_parse_inst_t cmd_operate_port = {
740 .f = cmd_operate_port_parsed,
742 .help_str = "port start|stop|close all: start/stop/close all ports",
744 (void *)&cmd_operate_port_all_cmd,
745 (void *)&cmd_operate_port_all_port,
746 (void *)&cmd_operate_port_all_all,
751 /* *** start/stop/close specific port *** */
752 struct cmd_operate_specific_port_result {
753 cmdline_fixed_string_t keyword;
754 cmdline_fixed_string_t name;
758 static void cmd_operate_specific_port_parsed(void *parsed_result,
759 __attribute__((unused)) struct cmdline *cl,
760 __attribute__((unused)) void *data)
762 struct cmd_operate_specific_port_result *res = parsed_result;
764 if (!strcmp(res->name, "start"))
765 start_port(res->value);
766 else if (!strcmp(res->name, "stop"))
767 stop_port(res->value);
768 else if (!strcmp(res->name, "close"))
769 close_port(res->value);
771 printf("Unknown parameter\n");
774 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
775 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
777 cmdline_parse_token_string_t cmd_operate_specific_port_port =
778 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
779 name, "start#stop#close");
780 cmdline_parse_token_num_t cmd_operate_specific_port_id =
781 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
784 cmdline_parse_inst_t cmd_operate_specific_port = {
785 .f = cmd_operate_specific_port_parsed,
787 .help_str = "port start|stop|close X: start/stop/close port X",
789 (void *)&cmd_operate_specific_port_cmd,
790 (void *)&cmd_operate_specific_port_port,
791 (void *)&cmd_operate_specific_port_id,
796 /* *** configure speed for all ports *** */
797 struct cmd_config_speed_all {
798 cmdline_fixed_string_t port;
799 cmdline_fixed_string_t keyword;
800 cmdline_fixed_string_t all;
801 cmdline_fixed_string_t item1;
802 cmdline_fixed_string_t item2;
803 cmdline_fixed_string_t value1;
804 cmdline_fixed_string_t value2;
808 cmd_config_speed_all_parsed(void *parsed_result,
809 __attribute__((unused)) struct cmdline *cl,
810 __attribute__((unused)) void *data)
812 struct cmd_config_speed_all *res = parsed_result;
813 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
814 uint16_t link_duplex = 0;
817 if (!all_ports_stopped()) {
818 printf("Please stop all ports first\n");
822 if (!strcmp(res->value1, "10"))
823 link_speed = ETH_LINK_SPEED_10;
824 else if (!strcmp(res->value1, "100"))
825 link_speed = ETH_LINK_SPEED_100;
826 else if (!strcmp(res->value1, "1000"))
827 link_speed = ETH_LINK_SPEED_1000;
828 else if (!strcmp(res->value1, "10000"))
829 link_speed = ETH_LINK_SPEED_10G;
830 else if (!strcmp(res->value1, "40000"))
831 link_speed = ETH_LINK_SPEED_40G;
832 else if (!strcmp(res->value1, "auto"))
833 link_speed = ETH_LINK_SPEED_AUTONEG;
835 printf("Unknown parameter\n");
839 if (!strcmp(res->value2, "half"))
840 link_duplex = ETH_LINK_HALF_DUPLEX;
841 else if (!strcmp(res->value2, "full"))
842 link_duplex = ETH_LINK_FULL_DUPLEX;
843 else if (!strcmp(res->value2, "auto"))
844 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
846 printf("Unknown parameter\n");
850 for (pid = 0; pid < nb_ports; pid++) {
851 ports[pid].dev_conf.link_speed = link_speed;
852 ports[pid].dev_conf.link_duplex = link_duplex;
855 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
858 cmdline_parse_token_string_t cmd_config_speed_all_port =
859 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
860 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
861 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
863 cmdline_parse_token_string_t cmd_config_speed_all_all =
864 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
865 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
866 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
867 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
868 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
869 "10#100#1000#10000#40000#auto");
870 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
871 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
872 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
873 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
876 cmdline_parse_inst_t cmd_config_speed_all = {
877 .f = cmd_config_speed_all_parsed,
879 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
882 (void *)&cmd_config_speed_all_port,
883 (void *)&cmd_config_speed_all_keyword,
884 (void *)&cmd_config_speed_all_all,
885 (void *)&cmd_config_speed_all_item1,
886 (void *)&cmd_config_speed_all_value1,
887 (void *)&cmd_config_speed_all_item2,
888 (void *)&cmd_config_speed_all_value2,
893 /* *** configure speed for specific port *** */
894 struct cmd_config_speed_specific {
895 cmdline_fixed_string_t port;
896 cmdline_fixed_string_t keyword;
898 cmdline_fixed_string_t item1;
899 cmdline_fixed_string_t item2;
900 cmdline_fixed_string_t value1;
901 cmdline_fixed_string_t value2;
905 cmd_config_speed_specific_parsed(void *parsed_result,
906 __attribute__((unused)) struct cmdline *cl,
907 __attribute__((unused)) void *data)
909 struct cmd_config_speed_specific *res = parsed_result;
910 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
911 uint16_t link_duplex = 0;
913 if (!all_ports_stopped()) {
914 printf("Please stop all ports first\n");
918 if (res->id >= nb_ports) {
919 printf("Port id %d must be less than %d\n", res->id, nb_ports);
923 if (!strcmp(res->value1, "10"))
924 link_speed = ETH_LINK_SPEED_10;
925 else if (!strcmp(res->value1, "100"))
926 link_speed = ETH_LINK_SPEED_100;
927 else if (!strcmp(res->value1, "1000"))
928 link_speed = ETH_LINK_SPEED_1000;
929 else if (!strcmp(res->value1, "10000"))
930 link_speed = ETH_LINK_SPEED_10000;
931 else if (!strcmp(res->value1, "40000"))
932 link_speed = ETH_LINK_SPEED_40G;
933 else if (!strcmp(res->value1, "auto"))
934 link_speed = ETH_LINK_SPEED_AUTONEG;
936 printf("Unknown parameter\n");
940 if (!strcmp(res->value2, "half"))
941 link_duplex = ETH_LINK_HALF_DUPLEX;
942 else if (!strcmp(res->value2, "full"))
943 link_duplex = ETH_LINK_FULL_DUPLEX;
944 else if (!strcmp(res->value2, "auto"))
945 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
947 printf("Unknown parameter\n");
951 ports[res->id].dev_conf.link_speed = link_speed;
952 ports[res->id].dev_conf.link_duplex = link_duplex;
954 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
958 cmdline_parse_token_string_t cmd_config_speed_specific_port =
959 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
961 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
962 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
964 cmdline_parse_token_num_t cmd_config_speed_specific_id =
965 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
966 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
967 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
969 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
970 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
971 "10#100#1000#10000#40000#auto");
972 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
973 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
975 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
976 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
979 cmdline_parse_inst_t cmd_config_speed_specific = {
980 .f = cmd_config_speed_specific_parsed,
982 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
985 (void *)&cmd_config_speed_specific_port,
986 (void *)&cmd_config_speed_specific_keyword,
987 (void *)&cmd_config_speed_specific_id,
988 (void *)&cmd_config_speed_specific_item1,
989 (void *)&cmd_config_speed_specific_value1,
990 (void *)&cmd_config_speed_specific_item2,
991 (void *)&cmd_config_speed_specific_value2,
996 /* *** configure txq/rxq, txd/rxd *** */
997 struct cmd_config_rx_tx {
998 cmdline_fixed_string_t port;
999 cmdline_fixed_string_t keyword;
1000 cmdline_fixed_string_t all;
1001 cmdline_fixed_string_t name;
1006 cmd_config_rx_tx_parsed(void *parsed_result,
1007 __attribute__((unused)) struct cmdline *cl,
1008 __attribute__((unused)) void *data)
1010 struct cmd_config_rx_tx *res = parsed_result;
1012 if (!all_ports_stopped()) {
1013 printf("Please stop all ports first\n");
1017 if (!strcmp(res->name, "rxq")) {
1018 if (res->value <= 0) {
1019 printf("rxq %d invalid - must be > 0\n", res->value);
1022 nb_rxq = res->value;
1024 else if (!strcmp(res->name, "txq")) {
1025 if (res->value <= 0) {
1026 printf("txq %d invalid - must be > 0\n", res->value);
1029 nb_txq = res->value;
1031 else if (!strcmp(res->name, "rxd")) {
1032 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1033 printf("rxd %d invalid - must be > 0 && <= %d\n",
1034 res->value, RTE_TEST_RX_DESC_MAX);
1037 nb_rxd = res->value;
1038 } else if (!strcmp(res->name, "txd")) {
1039 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1040 printf("txd %d invalid - must be > 0 && <= %d\n",
1041 res->value, RTE_TEST_TX_DESC_MAX);
1044 nb_txd = res->value;
1046 printf("Unknown parameter\n");
1052 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1055 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1056 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1057 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1058 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1059 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1060 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1061 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1062 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1064 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1065 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1067 cmdline_parse_inst_t cmd_config_rx_tx = {
1068 .f = cmd_config_rx_tx_parsed,
1070 .help_str = "port config all rxq|txq|rxd|txd value",
1072 (void *)&cmd_config_rx_tx_port,
1073 (void *)&cmd_config_rx_tx_keyword,
1074 (void *)&cmd_config_rx_tx_all,
1075 (void *)&cmd_config_rx_tx_name,
1076 (void *)&cmd_config_rx_tx_value,
1081 /* *** config max packet length *** */
1082 struct cmd_config_max_pkt_len_result {
1083 cmdline_fixed_string_t port;
1084 cmdline_fixed_string_t keyword;
1085 cmdline_fixed_string_t all;
1086 cmdline_fixed_string_t name;
1091 cmd_config_max_pkt_len_parsed(void *parsed_result,
1092 __attribute__((unused)) struct cmdline *cl,
1093 __attribute__((unused)) void *data)
1095 struct cmd_config_max_pkt_len_result *res = parsed_result;
1097 if (!all_ports_stopped()) {
1098 printf("Please stop all ports first\n");
1102 if (!strcmp(res->name, "max-pkt-len")) {
1103 if (res->value < ETHER_MIN_LEN) {
1104 printf("max-pkt-len can not be less than %d\n",
1108 if (res->value == rx_mode.max_rx_pkt_len)
1111 rx_mode.max_rx_pkt_len = res->value;
1112 if (res->value > ETHER_MAX_LEN)
1113 rx_mode.jumbo_frame = 1;
1115 rx_mode.jumbo_frame = 0;
1117 printf("Unknown parameter\n");
1123 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1126 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1127 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1129 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1130 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1132 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1133 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1135 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1136 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1138 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1139 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1142 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1143 .f = cmd_config_max_pkt_len_parsed,
1145 .help_str = "port config all max-pkt-len value",
1147 (void *)&cmd_config_max_pkt_len_port,
1148 (void *)&cmd_config_max_pkt_len_keyword,
1149 (void *)&cmd_config_max_pkt_len_all,
1150 (void *)&cmd_config_max_pkt_len_name,
1151 (void *)&cmd_config_max_pkt_len_value,
1156 /* *** configure port MTU *** */
1157 struct cmd_config_mtu_result {
1158 cmdline_fixed_string_t port;
1159 cmdline_fixed_string_t keyword;
1160 cmdline_fixed_string_t mtu;
1166 cmd_config_mtu_parsed(void *parsed_result,
1167 __attribute__((unused)) struct cmdline *cl,
1168 __attribute__((unused)) void *data)
1170 struct cmd_config_mtu_result *res = parsed_result;
1172 if (res->value < ETHER_MIN_LEN) {
1173 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1176 port_mtu_set(res->port_id, res->value);
1179 cmdline_parse_token_string_t cmd_config_mtu_port =
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1182 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1183 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1185 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1186 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1188 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1189 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1190 cmdline_parse_token_num_t cmd_config_mtu_value =
1191 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1193 cmdline_parse_inst_t cmd_config_mtu = {
1194 .f = cmd_config_mtu_parsed,
1196 .help_str = "port config mtu value",
1198 (void *)&cmd_config_mtu_port,
1199 (void *)&cmd_config_mtu_keyword,
1200 (void *)&cmd_config_mtu_mtu,
1201 (void *)&cmd_config_mtu_port_id,
1202 (void *)&cmd_config_mtu_value,
1207 /* *** configure rx mode *** */
1208 struct cmd_config_rx_mode_flag {
1209 cmdline_fixed_string_t port;
1210 cmdline_fixed_string_t keyword;
1211 cmdline_fixed_string_t all;
1212 cmdline_fixed_string_t name;
1213 cmdline_fixed_string_t value;
1217 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1218 __attribute__((unused)) struct cmdline *cl,
1219 __attribute__((unused)) void *data)
1221 struct cmd_config_rx_mode_flag *res = parsed_result;
1223 if (!all_ports_stopped()) {
1224 printf("Please stop all ports first\n");
1228 if (!strcmp(res->name, "crc-strip")) {
1229 if (!strcmp(res->value, "on"))
1230 rx_mode.hw_strip_crc = 1;
1231 else if (!strcmp(res->value, "off"))
1232 rx_mode.hw_strip_crc = 0;
1234 printf("Unknown parameter\n");
1237 } else if (!strcmp(res->name, "rx-cksum")) {
1238 if (!strcmp(res->value, "on"))
1239 rx_mode.hw_ip_checksum = 1;
1240 else if (!strcmp(res->value, "off"))
1241 rx_mode.hw_ip_checksum = 0;
1243 printf("Unknown parameter\n");
1246 } else if (!strcmp(res->name, "hw-vlan")) {
1247 if (!strcmp(res->value, "on")) {
1248 rx_mode.hw_vlan_filter = 1;
1249 rx_mode.hw_vlan_strip = 1;
1251 else if (!strcmp(res->value, "off")) {
1252 rx_mode.hw_vlan_filter = 0;
1253 rx_mode.hw_vlan_strip = 0;
1256 printf("Unknown parameter\n");
1259 } else if (!strcmp(res->name, "drop-en")) {
1260 if (!strcmp(res->value, "on"))
1262 else if (!strcmp(res->value, "off"))
1265 printf("Unknown parameter\n");
1269 printf("Unknown parameter\n");
1275 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1278 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1279 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1280 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1283 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1284 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1285 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1286 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1287 "crc-strip#rx-cksum#hw-vlan");
1288 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1289 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1292 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1293 .f = cmd_config_rx_mode_flag_parsed,
1295 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1297 (void *)&cmd_config_rx_mode_flag_port,
1298 (void *)&cmd_config_rx_mode_flag_keyword,
1299 (void *)&cmd_config_rx_mode_flag_all,
1300 (void *)&cmd_config_rx_mode_flag_name,
1301 (void *)&cmd_config_rx_mode_flag_value,
1306 /* *** configure rss *** */
1307 struct cmd_config_rss {
1308 cmdline_fixed_string_t port;
1309 cmdline_fixed_string_t keyword;
1310 cmdline_fixed_string_t all;
1311 cmdline_fixed_string_t name;
1312 cmdline_fixed_string_t value;
1316 cmd_config_rss_parsed(void *parsed_result,
1317 __attribute__((unused)) struct cmdline *cl,
1318 __attribute__((unused)) void *data)
1320 struct cmd_config_rss *res = parsed_result;
1321 struct rte_eth_rss_conf rss_conf;
1324 if (!strcmp(res->value, "all"))
1325 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1326 ETH_RSS_UDP | ETH_RSS_SCTP |
1328 else if (!strcmp(res->value, "ip"))
1329 rss_conf.rss_hf = ETH_RSS_IP;
1330 else if (!strcmp(res->value, "udp"))
1331 rss_conf.rss_hf = ETH_RSS_UDP;
1332 else if (!strcmp(res->value, "tcp"))
1333 rss_conf.rss_hf = ETH_RSS_TCP;
1334 else if (!strcmp(res->value, "sctp"))
1335 rss_conf.rss_hf = ETH_RSS_SCTP;
1336 else if (!strcmp(res->value, "ether"))
1337 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1338 else if (!strcmp(res->value, "none"))
1339 rss_conf.rss_hf = 0;
1341 printf("Unknown parameter\n");
1344 rss_conf.rss_key = NULL;
1345 for (i = 0; i < rte_eth_dev_count(); i++)
1346 rte_eth_dev_rss_hash_update(i, &rss_conf);
1349 cmdline_parse_token_string_t cmd_config_rss_port =
1350 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1351 cmdline_parse_token_string_t cmd_config_rss_keyword =
1352 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1353 cmdline_parse_token_string_t cmd_config_rss_all =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1355 cmdline_parse_token_string_t cmd_config_rss_name =
1356 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1357 cmdline_parse_token_string_t cmd_config_rss_value =
1358 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1359 "all#ip#tcp#udp#sctp#ether#none");
1361 cmdline_parse_inst_t cmd_config_rss = {
1362 .f = cmd_config_rss_parsed,
1364 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1366 (void *)&cmd_config_rss_port,
1367 (void *)&cmd_config_rss_keyword,
1368 (void *)&cmd_config_rss_all,
1369 (void *)&cmd_config_rss_name,
1370 (void *)&cmd_config_rss_value,
1375 /* *** configure rss hash key *** */
1376 struct cmd_config_rss_hash_key {
1377 cmdline_fixed_string_t port;
1378 cmdline_fixed_string_t config;
1380 cmdline_fixed_string_t rss_hash_key;
1381 cmdline_fixed_string_t key;
1384 #define RSS_HASH_KEY_LENGTH 40
1386 hexa_digit_to_value(char hexa_digit)
1388 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1389 return (uint8_t) (hexa_digit - '0');
1390 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1391 return (uint8_t) ((hexa_digit - 'a') + 10);
1392 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1393 return (uint8_t) ((hexa_digit - 'A') + 10);
1394 /* Invalid hexa digit */
1399 parse_and_check_key_hexa_digit(char *key, int idx)
1403 hexa_v = hexa_digit_to_value(key[idx]);
1405 printf("invalid key: character %c at position %d is not a "
1406 "valid hexa digit\n", key[idx], idx);
1411 cmd_config_rss_hash_key_parsed(void *parsed_result,
1412 __attribute__((unused)) struct cmdline *cl,
1413 __attribute__((unused)) void *data)
1415 struct cmd_config_rss_hash_key *res = parsed_result;
1416 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1421 /* Check the length of the RSS hash key */
1422 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1423 printf("key length: %d invalid - key must be a string of %d"
1424 "hexa-decimal numbers\n", (int) strlen(res->key),
1425 RSS_HASH_KEY_LENGTH * 2);
1428 /* Translate RSS hash key into binary representation */
1429 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1430 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1433 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1436 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1438 port_rss_hash_key_update(res->port_id, hash_key);
1441 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1442 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1443 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1444 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1446 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1447 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1448 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1449 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1450 rss_hash_key, "rss-hash-key");
1451 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1452 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1454 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1455 .f = cmd_config_rss_hash_key_parsed,
1457 .help_str = "port config X rss-hash-key 80 hexa digits",
1459 (void *)&cmd_config_rss_hash_key_port,
1460 (void *)&cmd_config_rss_hash_key_config,
1461 (void *)&cmd_config_rss_hash_key_port_id,
1462 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1463 (void *)&cmd_config_rss_hash_key_value,
1468 /* *** configure port rxq/txq start/stop *** */
1469 struct cmd_config_rxtx_queue {
1470 cmdline_fixed_string_t port;
1472 cmdline_fixed_string_t rxtxq;
1474 cmdline_fixed_string_t opname;
1478 cmd_config_rxtx_queue_parsed(void *parsed_result,
1479 __attribute__((unused)) struct cmdline *cl,
1480 __attribute__((unused)) void *data)
1482 struct cmd_config_rxtx_queue *res = parsed_result;
1487 if (test_done == 0) {
1488 printf("Please stop forwarding first\n");
1492 if (port_id_is_invalid(res->portid))
1495 if (port_is_started(res->portid) != 1) {
1496 printf("Please start port %u first\n", res->portid);
1500 if (!strcmp(res->rxtxq, "rxq"))
1502 else if (!strcmp(res->rxtxq, "txq"))
1505 printf("Unknown parameter\n");
1509 if (isrx && rx_queue_id_is_invalid(res->qid))
1511 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1514 if (!strcmp(res->opname, "start"))
1516 else if (!strcmp(res->opname, "stop"))
1519 printf("Unknown parameter\n");
1523 if (isstart && isrx)
1524 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1525 else if (!isstart && isrx)
1526 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1527 else if (isstart && !isrx)
1528 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1530 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1532 if (ret == -ENOTSUP)
1533 printf("Function not supported in PMD driver\n");
1536 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1537 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1538 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1539 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1540 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1541 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1542 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1543 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1544 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1545 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1548 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1549 .f = cmd_config_rxtx_queue_parsed,
1551 .help_str = "port X rxq|txq ID start|stop",
1553 (void *)&cmd_config_speed_all_port,
1554 (void *)&cmd_config_rxtx_queue_portid,
1555 (void *)&cmd_config_rxtx_queue_rxtxq,
1556 (void *)&cmd_config_rxtx_queue_qid,
1557 (void *)&cmd_config_rxtx_queue_opname,
1562 /* *** Configure RSS RETA *** */
1563 struct cmd_config_rss_reta {
1564 cmdline_fixed_string_t port;
1565 cmdline_fixed_string_t keyword;
1567 cmdline_fixed_string_t name;
1568 cmdline_fixed_string_t list_name;
1569 cmdline_fixed_string_t list_of_items;
1573 parse_reta_config(const char *str,
1574 struct rte_eth_rss_reta_entry64 *reta_conf,
1575 uint16_t nb_entries)
1579 uint16_t hash_index, idx, shift;
1582 const char *p, *p0 = str;
1589 unsigned long int_fld[_NUM_FLD];
1590 char *str_fld[_NUM_FLD];
1592 while ((p = strchr(p0,'(')) != NULL) {
1594 if((p0 = strchr(p,')')) == NULL)
1598 if(size >= sizeof(s))
1601 snprintf(s, sizeof(s), "%.*s", size, p);
1602 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1604 for (i = 0; i < _NUM_FLD; i++) {
1606 int_fld[i] = strtoul(str_fld[i], &end, 0);
1607 if (errno != 0 || end == str_fld[i] ||
1612 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1613 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1615 if (hash_index >= nb_entries) {
1616 printf("Invalid RETA hash index=%d\n", hash_index);
1620 idx = hash_index / RTE_RETA_GROUP_SIZE;
1621 shift = hash_index % RTE_RETA_GROUP_SIZE;
1622 reta_conf[idx].mask |= (1ULL << shift);
1623 reta_conf[idx].reta[shift] = nb_queue;
1630 cmd_set_rss_reta_parsed(void *parsed_result,
1631 __attribute__((unused)) struct cmdline *cl,
1632 __attribute__((unused)) void *data)
1635 struct rte_eth_dev_info dev_info;
1636 struct rte_eth_rss_reta_entry64 reta_conf[8];
1637 struct cmd_config_rss_reta *res = parsed_result;
1639 memset(&dev_info, 0, sizeof(dev_info));
1640 rte_eth_dev_info_get(res->port_id, &dev_info);
1641 if (dev_info.reta_size == 0) {
1642 printf("Redirection table size is 0 which is "
1643 "invalid for RSS\n");
1646 printf("The reta size of port %d is %u\n",
1647 res->port_id, dev_info.reta_size);
1648 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1649 printf("Currently do not support more than %u entries of "
1650 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1654 memset(reta_conf, 0, sizeof(reta_conf));
1655 if (!strcmp(res->list_name, "reta")) {
1656 if (parse_reta_config(res->list_of_items, reta_conf,
1657 dev_info.reta_size)) {
1658 printf("Invalid RSS Redirection Table "
1659 "config entered\n");
1662 ret = rte_eth_dev_rss_reta_update(res->port_id,
1663 reta_conf, dev_info.reta_size);
1665 printf("Bad redirection table parameter, "
1666 "return code = %d \n", ret);
1670 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1672 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1673 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1674 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1675 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1676 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1678 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1680 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1681 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1683 cmdline_parse_inst_t cmd_config_rss_reta = {
1684 .f = cmd_set_rss_reta_parsed,
1686 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1688 (void *)&cmd_config_rss_reta_port,
1689 (void *)&cmd_config_rss_reta_keyword,
1690 (void *)&cmd_config_rss_reta_port_id,
1691 (void *)&cmd_config_rss_reta_name,
1692 (void *)&cmd_config_rss_reta_list_name,
1693 (void *)&cmd_config_rss_reta_list_of_items,
1698 /* *** SHOW PORT RETA INFO *** */
1699 struct cmd_showport_reta {
1700 cmdline_fixed_string_t show;
1701 cmdline_fixed_string_t port;
1703 cmdline_fixed_string_t rss;
1704 cmdline_fixed_string_t reta;
1706 cmdline_fixed_string_t list_of_items;
1710 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1711 uint16_t nb_entries,
1715 const char *p, *p0 = str;
1719 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1722 p = strchr(p0, '(');
1726 p0 = strchr(p, ')');
1730 if (size >= sizeof(s)) {
1731 printf("The string size exceeds the internal buffer size\n");
1734 snprintf(s, sizeof(s), "%.*s", size, p);
1735 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1736 if (ret <= 0 || ret != num) {
1737 printf("The bits of masks do not match the number of "
1738 "reta entries: %u\n", num);
1741 for (i = 0; i < ret; i++)
1742 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1748 cmd_showport_reta_parsed(void *parsed_result,
1749 __attribute__((unused)) struct cmdline *cl,
1750 __attribute__((unused)) void *data)
1752 struct cmd_showport_reta *res = parsed_result;
1753 struct rte_eth_rss_reta_entry64 reta_conf[8];
1754 struct rte_eth_dev_info dev_info;
1756 memset(&dev_info, 0, sizeof(dev_info));
1757 rte_eth_dev_info_get(res->port_id, &dev_info);
1758 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1759 res->size > ETH_RSS_RETA_SIZE_512) {
1760 printf("Invalid redirection table size: %u\n", res->size);
1764 memset(reta_conf, 0, sizeof(reta_conf));
1765 if (showport_parse_reta_config(reta_conf, res->size,
1766 res->list_of_items) < 0) {
1767 printf("Invalid string: %s for reta masks\n",
1768 res->list_of_items);
1771 port_rss_reta_info(res->port_id, reta_conf, res->size);
1774 cmdline_parse_token_string_t cmd_showport_reta_show =
1775 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1776 cmdline_parse_token_string_t cmd_showport_reta_port =
1777 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1778 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1779 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1780 cmdline_parse_token_string_t cmd_showport_reta_rss =
1781 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1782 cmdline_parse_token_string_t cmd_showport_reta_reta =
1783 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1784 cmdline_parse_token_num_t cmd_showport_reta_size =
1785 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1786 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1787 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1788 list_of_items, NULL);
1790 cmdline_parse_inst_t cmd_showport_reta = {
1791 .f = cmd_showport_reta_parsed,
1793 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1795 (void *)&cmd_showport_reta_show,
1796 (void *)&cmd_showport_reta_port,
1797 (void *)&cmd_showport_reta_port_id,
1798 (void *)&cmd_showport_reta_rss,
1799 (void *)&cmd_showport_reta_reta,
1800 (void *)&cmd_showport_reta_size,
1801 (void *)&cmd_showport_reta_list_of_items,
1806 /* *** Show RSS hash configuration *** */
1807 struct cmd_showport_rss_hash {
1808 cmdline_fixed_string_t show;
1809 cmdline_fixed_string_t port;
1811 cmdline_fixed_string_t rss_hash;
1812 cmdline_fixed_string_t key; /* optional argument */
1815 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1816 __attribute__((unused)) struct cmdline *cl,
1819 struct cmd_showport_rss_hash *res = parsed_result;
1821 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1824 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1825 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1826 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1827 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1828 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1829 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1830 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1831 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1833 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1834 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1836 cmdline_parse_inst_t cmd_showport_rss_hash = {
1837 .f = cmd_showport_rss_hash_parsed,
1839 .help_str = "show port X rss-hash (X = port number)\n",
1841 (void *)&cmd_showport_rss_hash_show,
1842 (void *)&cmd_showport_rss_hash_port,
1843 (void *)&cmd_showport_rss_hash_port_id,
1844 (void *)&cmd_showport_rss_hash_rss_hash,
1849 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1850 .f = cmd_showport_rss_hash_parsed,
1852 .help_str = "show port X rss-hash key (X = port number)\n",
1854 (void *)&cmd_showport_rss_hash_show,
1855 (void *)&cmd_showport_rss_hash_port,
1856 (void *)&cmd_showport_rss_hash_port_id,
1857 (void *)&cmd_showport_rss_hash_rss_hash,
1858 (void *)&cmd_showport_rss_hash_rss_key,
1863 /* *** Configure DCB *** */
1864 struct cmd_config_dcb {
1865 cmdline_fixed_string_t port;
1866 cmdline_fixed_string_t config;
1868 cmdline_fixed_string_t dcb;
1869 cmdline_fixed_string_t vt;
1870 cmdline_fixed_string_t vt_en;
1872 cmdline_fixed_string_t pfc;
1873 cmdline_fixed_string_t pfc_en;
1877 cmd_config_dcb_parsed(void *parsed_result,
1878 __attribute__((unused)) struct cmdline *cl,
1879 __attribute__((unused)) void *data)
1881 struct cmd_config_dcb *res = parsed_result;
1882 struct dcb_config dcb_conf;
1883 portid_t port_id = res->port_id;
1884 struct rte_port *port;
1886 port = &ports[port_id];
1887 /** Check if the port is not started **/
1888 if (port->port_status != RTE_PORT_STOPPED) {
1889 printf("Please stop port %d first\n",port_id);
1893 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1894 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1895 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1899 /* DCB in VT mode */
1900 if (!strncmp(res->vt_en, "on",2))
1901 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1903 dcb_conf.dcb_mode = DCB_ENABLED;
1905 if (!strncmp(res->pfc_en, "on",2)) {
1906 dcb_conf.pfc_en = 1;
1909 dcb_conf.pfc_en = 0;
1911 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1912 printf("Cannot initialize network ports\n");
1916 cmd_reconfig_device_queue(port_id, 1, 1);
1919 cmdline_parse_token_string_t cmd_config_dcb_port =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1921 cmdline_parse_token_string_t cmd_config_dcb_config =
1922 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1923 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1924 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1925 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1927 cmdline_parse_token_string_t cmd_config_dcb_vt =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1929 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1930 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1931 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1932 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1933 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1934 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1935 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1938 cmdline_parse_inst_t cmd_config_dcb = {
1939 .f = cmd_config_dcb_parsed,
1941 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1943 (void *)&cmd_config_dcb_port,
1944 (void *)&cmd_config_dcb_config,
1945 (void *)&cmd_config_dcb_port_id,
1946 (void *)&cmd_config_dcb_dcb,
1947 (void *)&cmd_config_dcb_vt,
1948 (void *)&cmd_config_dcb_vt_en,
1949 (void *)&cmd_config_dcb_num_tcs,
1950 (void *)&cmd_config_dcb_pfc,
1951 (void *)&cmd_config_dcb_pfc_en,
1956 /* *** configure number of packets per burst *** */
1957 struct cmd_config_burst {
1958 cmdline_fixed_string_t port;
1959 cmdline_fixed_string_t keyword;
1960 cmdline_fixed_string_t all;
1961 cmdline_fixed_string_t name;
1966 cmd_config_burst_parsed(void *parsed_result,
1967 __attribute__((unused)) struct cmdline *cl,
1968 __attribute__((unused)) void *data)
1970 struct cmd_config_burst *res = parsed_result;
1972 if (!all_ports_stopped()) {
1973 printf("Please stop all ports first\n");
1977 if (!strcmp(res->name, "burst")) {
1978 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1979 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1982 nb_pkt_per_burst = res->value;
1984 printf("Unknown parameter\n");
1990 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1993 cmdline_parse_token_string_t cmd_config_burst_port =
1994 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1995 cmdline_parse_token_string_t cmd_config_burst_keyword =
1996 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1997 cmdline_parse_token_string_t cmd_config_burst_all =
1998 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1999 cmdline_parse_token_string_t cmd_config_burst_name =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2001 cmdline_parse_token_num_t cmd_config_burst_value =
2002 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2004 cmdline_parse_inst_t cmd_config_burst = {
2005 .f = cmd_config_burst_parsed,
2007 .help_str = "port config all burst value",
2009 (void *)&cmd_config_burst_port,
2010 (void *)&cmd_config_burst_keyword,
2011 (void *)&cmd_config_burst_all,
2012 (void *)&cmd_config_burst_name,
2013 (void *)&cmd_config_burst_value,
2018 /* *** configure rx/tx queues *** */
2019 struct cmd_config_thresh {
2020 cmdline_fixed_string_t port;
2021 cmdline_fixed_string_t keyword;
2022 cmdline_fixed_string_t all;
2023 cmdline_fixed_string_t name;
2028 cmd_config_thresh_parsed(void *parsed_result,
2029 __attribute__((unused)) struct cmdline *cl,
2030 __attribute__((unused)) void *data)
2032 struct cmd_config_thresh *res = parsed_result;
2034 if (!all_ports_stopped()) {
2035 printf("Please stop all ports first\n");
2039 if (!strcmp(res->name, "txpt"))
2040 tx_pthresh = res->value;
2041 else if(!strcmp(res->name, "txht"))
2042 tx_hthresh = res->value;
2043 else if(!strcmp(res->name, "txwt"))
2044 tx_wthresh = res->value;
2045 else if(!strcmp(res->name, "rxpt"))
2046 rx_pthresh = res->value;
2047 else if(!strcmp(res->name, "rxht"))
2048 rx_hthresh = res->value;
2049 else if(!strcmp(res->name, "rxwt"))
2050 rx_wthresh = res->value;
2052 printf("Unknown parameter\n");
2058 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2061 cmdline_parse_token_string_t cmd_config_thresh_port =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2063 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2065 cmdline_parse_token_string_t cmd_config_thresh_all =
2066 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2067 cmdline_parse_token_string_t cmd_config_thresh_name =
2068 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2069 "txpt#txht#txwt#rxpt#rxht#rxwt");
2070 cmdline_parse_token_num_t cmd_config_thresh_value =
2071 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2073 cmdline_parse_inst_t cmd_config_thresh = {
2074 .f = cmd_config_thresh_parsed,
2076 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2078 (void *)&cmd_config_thresh_port,
2079 (void *)&cmd_config_thresh_keyword,
2080 (void *)&cmd_config_thresh_all,
2081 (void *)&cmd_config_thresh_name,
2082 (void *)&cmd_config_thresh_value,
2087 /* *** configure free/rs threshold *** */
2088 struct cmd_config_threshold {
2089 cmdline_fixed_string_t port;
2090 cmdline_fixed_string_t keyword;
2091 cmdline_fixed_string_t all;
2092 cmdline_fixed_string_t name;
2097 cmd_config_threshold_parsed(void *parsed_result,
2098 __attribute__((unused)) struct cmdline *cl,
2099 __attribute__((unused)) void *data)
2101 struct cmd_config_threshold *res = parsed_result;
2103 if (!all_ports_stopped()) {
2104 printf("Please stop all ports first\n");
2108 if (!strcmp(res->name, "txfreet"))
2109 tx_free_thresh = res->value;
2110 else if (!strcmp(res->name, "txrst"))
2111 tx_rs_thresh = res->value;
2112 else if (!strcmp(res->name, "rxfreet"))
2113 rx_free_thresh = res->value;
2115 printf("Unknown parameter\n");
2121 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2124 cmdline_parse_token_string_t cmd_config_threshold_port =
2125 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2126 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2129 cmdline_parse_token_string_t cmd_config_threshold_all =
2130 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2131 cmdline_parse_token_string_t cmd_config_threshold_name =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2133 "txfreet#txrst#rxfreet");
2134 cmdline_parse_token_num_t cmd_config_threshold_value =
2135 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2137 cmdline_parse_inst_t cmd_config_threshold = {
2138 .f = cmd_config_threshold_parsed,
2140 .help_str = "port config all txfreet|txrst|rxfreet value",
2142 (void *)&cmd_config_threshold_port,
2143 (void *)&cmd_config_threshold_keyword,
2144 (void *)&cmd_config_threshold_all,
2145 (void *)&cmd_config_threshold_name,
2146 (void *)&cmd_config_threshold_value,
2152 struct cmd_stop_result {
2153 cmdline_fixed_string_t stop;
2156 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2157 __attribute__((unused)) struct cmdline *cl,
2158 __attribute__((unused)) void *data)
2160 stop_packet_forwarding();
2163 cmdline_parse_token_string_t cmd_stop_stop =
2164 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2166 cmdline_parse_inst_t cmd_stop = {
2167 .f = cmd_stop_parsed,
2169 .help_str = "stop - stop packet forwarding",
2171 (void *)&cmd_stop_stop,
2176 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2179 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2180 unsigned int *parsed_items, int check_unique_values)
2182 unsigned int nb_item;
2190 * First parse all items in the list and store their value.
2195 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2197 if ((c >= '0') && (c <= '9')) {
2198 value = (unsigned int) (value * 10 + (c - '0'));
2203 printf("character %c is not a decimal digit\n", c);
2207 printf("No valid value before comma\n");
2210 if (nb_item < max_items) {
2211 parsed_items[nb_item] = value;
2217 if (nb_item >= max_items) {
2218 printf("Number of %s = %u > %u (maximum items)\n",
2219 item_name, nb_item + 1, max_items);
2222 parsed_items[nb_item++] = value;
2223 if (! check_unique_values)
2227 * Then, check that all values in the list are differents.
2228 * No optimization here...
2230 for (i = 0; i < nb_item; i++) {
2231 for (j = i + 1; j < nb_item; j++) {
2232 if (parsed_items[j] == parsed_items[i]) {
2233 printf("duplicated %s %u at index %u and %u\n",
2234 item_name, parsed_items[i], i, j);
2242 struct cmd_set_list_result {
2243 cmdline_fixed_string_t cmd_keyword;
2244 cmdline_fixed_string_t list_name;
2245 cmdline_fixed_string_t list_of_items;
2248 static void cmd_set_list_parsed(void *parsed_result,
2249 __attribute__((unused)) struct cmdline *cl,
2250 __attribute__((unused)) void *data)
2252 struct cmd_set_list_result *res;
2254 unsigned int lcorelist[RTE_MAX_LCORE];
2255 unsigned int portlist[RTE_MAX_ETHPORTS];
2257 unsigned int nb_item;
2259 if (test_done == 0) {
2260 printf("Please stop forwarding first\n");
2264 res = parsed_result;
2265 if (!strcmp(res->list_name, "corelist")) {
2266 nb_item = parse_item_list(res->list_of_items, "core",
2268 parsed_items.lcorelist, 1);
2270 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2273 if (!strcmp(res->list_name, "portlist")) {
2274 nb_item = parse_item_list(res->list_of_items, "port",
2276 parsed_items.portlist, 1);
2278 set_fwd_ports_list(parsed_items.portlist, nb_item);
2282 cmdline_parse_token_string_t cmd_set_list_keyword =
2283 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2285 cmdline_parse_token_string_t cmd_set_list_name =
2286 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2287 "corelist#portlist");
2288 cmdline_parse_token_string_t cmd_set_list_of_items =
2289 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2292 cmdline_parse_inst_t cmd_set_fwd_list = {
2293 .f = cmd_set_list_parsed,
2295 .help_str = "set corelist|portlist x[,y]*",
2297 (void *)&cmd_set_list_keyword,
2298 (void *)&cmd_set_list_name,
2299 (void *)&cmd_set_list_of_items,
2304 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2306 struct cmd_setmask_result {
2307 cmdline_fixed_string_t set;
2308 cmdline_fixed_string_t mask;
2312 static void cmd_set_mask_parsed(void *parsed_result,
2313 __attribute__((unused)) struct cmdline *cl,
2314 __attribute__((unused)) void *data)
2316 struct cmd_setmask_result *res = parsed_result;
2318 if (test_done == 0) {
2319 printf("Please stop forwarding first\n");
2322 if (!strcmp(res->mask, "coremask"))
2323 set_fwd_lcores_mask(res->hexavalue);
2324 else if (!strcmp(res->mask, "portmask"))
2325 set_fwd_ports_mask(res->hexavalue);
2328 cmdline_parse_token_string_t cmd_setmask_set =
2329 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2330 cmdline_parse_token_string_t cmd_setmask_mask =
2331 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2332 "coremask#portmask");
2333 cmdline_parse_token_num_t cmd_setmask_value =
2334 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2336 cmdline_parse_inst_t cmd_set_fwd_mask = {
2337 .f = cmd_set_mask_parsed,
2339 .help_str = "set coremask|portmask hexadecimal value",
2341 (void *)&cmd_setmask_set,
2342 (void *)&cmd_setmask_mask,
2343 (void *)&cmd_setmask_value,
2349 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2351 struct cmd_set_result {
2352 cmdline_fixed_string_t set;
2353 cmdline_fixed_string_t what;
2357 static void cmd_set_parsed(void *parsed_result,
2358 __attribute__((unused)) struct cmdline *cl,
2359 __attribute__((unused)) void *data)
2361 struct cmd_set_result *res = parsed_result;
2362 if (!strcmp(res->what, "nbport"))
2363 set_fwd_ports_number(res->value);
2364 else if (!strcmp(res->what, "nbcore"))
2365 set_fwd_lcores_number(res->value);
2366 else if (!strcmp(res->what, "burst"))
2367 set_nb_pkt_per_burst(res->value);
2368 else if (!strcmp(res->what, "verbose"))
2369 set_verbose_level(res->value);
2372 cmdline_parse_token_string_t cmd_set_set =
2373 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2374 cmdline_parse_token_string_t cmd_set_what =
2375 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2376 "nbport#nbcore#burst#verbose");
2377 cmdline_parse_token_num_t cmd_set_value =
2378 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2380 cmdline_parse_inst_t cmd_set_numbers = {
2381 .f = cmd_set_parsed,
2383 .help_str = "set nbport|nbcore|burst|verbose value",
2385 (void *)&cmd_set_set,
2386 (void *)&cmd_set_what,
2387 (void *)&cmd_set_value,
2392 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2394 struct cmd_set_txpkts_result {
2395 cmdline_fixed_string_t cmd_keyword;
2396 cmdline_fixed_string_t txpkts;
2397 cmdline_fixed_string_t seg_lengths;
2401 cmd_set_txpkts_parsed(void *parsed_result,
2402 __attribute__((unused)) struct cmdline *cl,
2403 __attribute__((unused)) void *data)
2405 struct cmd_set_txpkts_result *res;
2406 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2407 unsigned int nb_segs;
2409 res = parsed_result;
2410 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2411 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2413 set_tx_pkt_segments(seg_lengths, nb_segs);
2416 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2417 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2418 cmd_keyword, "set");
2419 cmdline_parse_token_string_t cmd_set_txpkts_name =
2420 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2422 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2423 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2426 cmdline_parse_inst_t cmd_set_txpkts = {
2427 .f = cmd_set_txpkts_parsed,
2429 .help_str = "set txpkts x[,y]*",
2431 (void *)&cmd_set_txpkts_keyword,
2432 (void *)&cmd_set_txpkts_name,
2433 (void *)&cmd_set_txpkts_lengths,
2438 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2439 struct cmd_rx_vlan_filter_all_result {
2440 cmdline_fixed_string_t rx_vlan;
2441 cmdline_fixed_string_t what;
2442 cmdline_fixed_string_t all;
2447 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2448 __attribute__((unused)) struct cmdline *cl,
2449 __attribute__((unused)) void *data)
2451 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2453 if (!strcmp(res->what, "add"))
2454 rx_vlan_all_filter_set(res->port_id, 1);
2456 rx_vlan_all_filter_set(res->port_id, 0);
2459 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2460 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2461 rx_vlan, "rx_vlan");
2462 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2463 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2465 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2466 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2468 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2469 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2472 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2473 .f = cmd_rx_vlan_filter_all_parsed,
2475 .help_str = "add/remove all identifiers to/from the set of VLAN "
2476 "Identifiers filtered by a port",
2478 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2479 (void *)&cmd_rx_vlan_filter_all_what,
2480 (void *)&cmd_rx_vlan_filter_all_all,
2481 (void *)&cmd_rx_vlan_filter_all_portid,
2486 /* *** VLAN OFFLOAD SET ON A PORT *** */
2487 struct cmd_vlan_offload_result {
2488 cmdline_fixed_string_t vlan;
2489 cmdline_fixed_string_t set;
2490 cmdline_fixed_string_t what;
2491 cmdline_fixed_string_t on;
2492 cmdline_fixed_string_t port_id;
2496 cmd_vlan_offload_parsed(void *parsed_result,
2497 __attribute__((unused)) struct cmdline *cl,
2498 __attribute__((unused)) void *data)
2501 struct cmd_vlan_offload_result *res = parsed_result;
2504 portid_t port_id = 0;
2508 len = strnlen(str, STR_TOKEN_SIZE);
2510 /* Get port_id first */
2518 tmp = strtoul(str, NULL, 0);
2519 /* If port_id greater that what portid_t can represent, return */
2520 if(tmp >= RTE_MAX_ETHPORTS)
2522 port_id = (portid_t)tmp;
2524 if (!strcmp(res->on, "on"))
2529 if (!strcmp(res->what, "strip"))
2530 rx_vlan_strip_set(port_id, on);
2531 else if(!strcmp(res->what, "stripq")){
2532 uint16_t queue_id = 0;
2534 /* No queue_id, return */
2536 printf("must specify (port,queue_id)\n");
2539 tmp = strtoul(str + i + 1, NULL, 0);
2540 /* If queue_id greater that what 16-bits can represent, return */
2544 queue_id = (uint16_t)tmp;
2545 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2547 else if (!strcmp(res->what, "filter"))
2548 rx_vlan_filter_set(port_id, on);
2550 vlan_extend_set(port_id, on);
2555 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2556 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2558 cmdline_parse_token_string_t cmd_vlan_offload_set =
2559 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2561 cmdline_parse_token_string_t cmd_vlan_offload_what =
2562 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2563 what, "strip#filter#qinq#stripq");
2564 cmdline_parse_token_string_t cmd_vlan_offload_on =
2565 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2567 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2568 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2571 cmdline_parse_inst_t cmd_vlan_offload = {
2572 .f = cmd_vlan_offload_parsed,
2574 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2575 " qinq(extended) for both rx/tx sides ",
2577 (void *)&cmd_vlan_offload_vlan,
2578 (void *)&cmd_vlan_offload_set,
2579 (void *)&cmd_vlan_offload_what,
2580 (void *)&cmd_vlan_offload_on,
2581 (void *)&cmd_vlan_offload_portid,
2586 /* *** VLAN TPID SET ON A PORT *** */
2587 struct cmd_vlan_tpid_result {
2588 cmdline_fixed_string_t vlan;
2589 cmdline_fixed_string_t set;
2590 cmdline_fixed_string_t what;
2596 cmd_vlan_tpid_parsed(void *parsed_result,
2597 __attribute__((unused)) struct cmdline *cl,
2598 __attribute__((unused)) void *data)
2600 struct cmd_vlan_tpid_result *res = parsed_result;
2601 vlan_tpid_set(res->port_id, res->tp_id);
2605 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2606 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2608 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2609 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2611 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2612 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2614 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2615 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2617 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2618 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2621 cmdline_parse_inst_t cmd_vlan_tpid = {
2622 .f = cmd_vlan_tpid_parsed,
2624 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2626 (void *)&cmd_vlan_tpid_vlan,
2627 (void *)&cmd_vlan_tpid_set,
2628 (void *)&cmd_vlan_tpid_what,
2629 (void *)&cmd_vlan_tpid_tpid,
2630 (void *)&cmd_vlan_tpid_portid,
2635 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2636 struct cmd_rx_vlan_filter_result {
2637 cmdline_fixed_string_t rx_vlan;
2638 cmdline_fixed_string_t what;
2644 cmd_rx_vlan_filter_parsed(void *parsed_result,
2645 __attribute__((unused)) struct cmdline *cl,
2646 __attribute__((unused)) void *data)
2648 struct cmd_rx_vlan_filter_result *res = parsed_result;
2650 if (!strcmp(res->what, "add"))
2651 rx_vft_set(res->port_id, res->vlan_id, 1);
2653 rx_vft_set(res->port_id, res->vlan_id, 0);
2656 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2657 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2658 rx_vlan, "rx_vlan");
2659 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2660 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2662 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2663 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2665 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2666 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2669 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2670 .f = cmd_rx_vlan_filter_parsed,
2672 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2673 "Identifiers filtered by a port",
2675 (void *)&cmd_rx_vlan_filter_rx_vlan,
2676 (void *)&cmd_rx_vlan_filter_what,
2677 (void *)&cmd_rx_vlan_filter_vlanid,
2678 (void *)&cmd_rx_vlan_filter_portid,
2683 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2684 struct cmd_tx_vlan_set_result {
2685 cmdline_fixed_string_t tx_vlan;
2686 cmdline_fixed_string_t set;
2692 cmd_tx_vlan_set_parsed(void *parsed_result,
2693 __attribute__((unused)) struct cmdline *cl,
2694 __attribute__((unused)) void *data)
2696 struct cmd_tx_vlan_set_result *res = parsed_result;
2697 tx_vlan_set(res->port_id, res->vlan_id);
2700 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2701 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2702 tx_vlan, "tx_vlan");
2703 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2704 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2706 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2707 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2709 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2710 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2713 cmdline_parse_inst_t cmd_tx_vlan_set = {
2714 .f = cmd_tx_vlan_set_parsed,
2716 .help_str = "enable hardware insertion of a VLAN header with a given "
2717 "TAG Identifier in packets sent on a port",
2719 (void *)&cmd_tx_vlan_set_tx_vlan,
2720 (void *)&cmd_tx_vlan_set_set,
2721 (void *)&cmd_tx_vlan_set_vlanid,
2722 (void *)&cmd_tx_vlan_set_portid,
2727 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2728 struct cmd_tx_vlan_set_pvid_result {
2729 cmdline_fixed_string_t tx_vlan;
2730 cmdline_fixed_string_t set;
2731 cmdline_fixed_string_t pvid;
2734 cmdline_fixed_string_t mode;
2738 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2739 __attribute__((unused)) struct cmdline *cl,
2740 __attribute__((unused)) void *data)
2742 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2744 if (strcmp(res->mode, "on") == 0)
2745 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2747 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2750 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2751 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2752 tx_vlan, "tx_vlan");
2753 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2754 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2756 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2757 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2759 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2760 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2762 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2763 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2765 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2766 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2769 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2770 .f = cmd_tx_vlan_set_pvid_parsed,
2772 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2774 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2775 (void *)&cmd_tx_vlan_set_pvid_set,
2776 (void *)&cmd_tx_vlan_set_pvid_pvid,
2777 (void *)&cmd_tx_vlan_set_pvid_port_id,
2778 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2779 (void *)&cmd_tx_vlan_set_pvid_mode,
2784 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2785 struct cmd_tx_vlan_reset_result {
2786 cmdline_fixed_string_t tx_vlan;
2787 cmdline_fixed_string_t reset;
2792 cmd_tx_vlan_reset_parsed(void *parsed_result,
2793 __attribute__((unused)) struct cmdline *cl,
2794 __attribute__((unused)) void *data)
2796 struct cmd_tx_vlan_reset_result *res = parsed_result;
2798 tx_vlan_reset(res->port_id);
2801 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2802 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2803 tx_vlan, "tx_vlan");
2804 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2805 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2807 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2808 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2811 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2812 .f = cmd_tx_vlan_reset_parsed,
2814 .help_str = "disable hardware insertion of a VLAN header in packets "
2817 (void *)&cmd_tx_vlan_reset_tx_vlan,
2818 (void *)&cmd_tx_vlan_reset_reset,
2819 (void *)&cmd_tx_vlan_reset_portid,
2825 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2826 struct cmd_csum_result {
2827 cmdline_fixed_string_t csum;
2828 cmdline_fixed_string_t mode;
2829 cmdline_fixed_string_t proto;
2830 cmdline_fixed_string_t hwsw;
2835 csum_show(int port_id)
2837 struct rte_eth_dev_info dev_info;
2840 ol_flags = ports[port_id].tx_ol_flags;
2841 printf("Parse tunnel is %s\n",
2842 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
2843 printf("IP checksum offload is %s\n",
2844 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2845 printf("UDP checksum offload is %s\n",
2846 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2847 printf("TCP checksum offload is %s\n",
2848 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2849 printf("SCTP checksum offload is %s\n",
2850 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2851 printf("Outer-Ip checksum offload is %s\n",
2852 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
2854 /* display warnings if configuration is not supported by the NIC */
2855 rte_eth_dev_info_get(port_id, &dev_info);
2856 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2857 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2858 printf("Warning: hardware IP checksum enabled but not "
2859 "supported by port %d\n", port_id);
2861 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2862 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2863 printf("Warning: hardware UDP checksum enabled but not "
2864 "supported by port %d\n", port_id);
2866 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2867 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2868 printf("Warning: hardware TCP checksum enabled but not "
2869 "supported by port %d\n", port_id);
2871 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2872 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2873 printf("Warning: hardware SCTP checksum enabled but not "
2874 "supported by port %d\n", port_id);
2876 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
2877 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
2878 printf("Warning: hardware outer IP checksum enabled but not "
2879 "supported by port %d\n", port_id);
2884 cmd_csum_parsed(void *parsed_result,
2885 __attribute__((unused)) struct cmdline *cl,
2886 __attribute__((unused)) void *data)
2888 struct cmd_csum_result *res = parsed_result;
2892 if (port_id_is_invalid(res->port_id)) {
2893 printf("invalid port %d\n", res->port_id);
2897 if (!strcmp(res->mode, "set")) {
2899 if (!strcmp(res->hwsw, "hw"))
2902 if (!strcmp(res->proto, "ip")) {
2903 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2904 } else if (!strcmp(res->proto, "udp")) {
2905 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2906 } else if (!strcmp(res->proto, "tcp")) {
2907 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2908 } else if (!strcmp(res->proto, "sctp")) {
2909 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2910 } else if (!strcmp(res->proto, "outer-ip")) {
2911 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
2915 ports[res->port_id].tx_ol_flags |= mask;
2917 ports[res->port_id].tx_ol_flags &= (~mask);
2919 csum_show(res->port_id);
2922 cmdline_parse_token_string_t cmd_csum_csum =
2923 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2925 cmdline_parse_token_string_t cmd_csum_mode =
2926 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2928 cmdline_parse_token_string_t cmd_csum_proto =
2929 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2930 proto, "ip#tcp#udp#sctp#outer-ip");
2931 cmdline_parse_token_string_t cmd_csum_hwsw =
2932 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2934 cmdline_parse_token_num_t cmd_csum_portid =
2935 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
2938 cmdline_parse_inst_t cmd_csum_set = {
2939 .f = cmd_csum_parsed,
2941 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2942 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
2944 (void *)&cmd_csum_csum,
2945 (void *)&cmd_csum_mode,
2946 (void *)&cmd_csum_proto,
2947 (void *)&cmd_csum_hwsw,
2948 (void *)&cmd_csum_portid,
2953 cmdline_parse_token_string_t cmd_csum_mode_show =
2954 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2957 cmdline_parse_inst_t cmd_csum_show = {
2958 .f = cmd_csum_parsed,
2960 .help_str = "show checksum offload configuration: csum show <port>",
2962 (void *)&cmd_csum_csum,
2963 (void *)&cmd_csum_mode_show,
2964 (void *)&cmd_csum_portid,
2969 /* Enable/disable tunnel parsing */
2970 struct cmd_csum_tunnel_result {
2971 cmdline_fixed_string_t csum;
2972 cmdline_fixed_string_t parse;
2973 cmdline_fixed_string_t onoff;
2978 cmd_csum_tunnel_parsed(void *parsed_result,
2979 __attribute__((unused)) struct cmdline *cl,
2980 __attribute__((unused)) void *data)
2982 struct cmd_csum_tunnel_result *res = parsed_result;
2984 if (port_id_is_invalid(res->port_id)) {
2985 printf("invalid port %d\n", res->port_id);
2989 if (!strcmp(res->onoff, "on"))
2990 ports[res->port_id].tx_ol_flags |=
2991 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
2993 ports[res->port_id].tx_ol_flags &=
2994 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
2996 csum_show(res->port_id);
2999 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3000 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3002 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3003 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3004 parse, "parse_tunnel");
3005 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3006 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3008 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3009 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3012 cmdline_parse_inst_t cmd_csum_tunnel = {
3013 .f = cmd_csum_tunnel_parsed,
3015 .help_str = "enable/disable parsing of tunnels for csum engine: "
3016 "csum parse_tunnel on|off <tx-port>",
3018 (void *)&cmd_csum_tunnel_csum,
3019 (void *)&cmd_csum_tunnel_parse,
3020 (void *)&cmd_csum_tunnel_onoff,
3021 (void *)&cmd_csum_tunnel_portid,
3026 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3027 struct cmd_tso_set_result {
3028 cmdline_fixed_string_t tso;
3029 cmdline_fixed_string_t mode;
3035 cmd_tso_set_parsed(void *parsed_result,
3036 __attribute__((unused)) struct cmdline *cl,
3037 __attribute__((unused)) void *data)
3039 struct cmd_tso_set_result *res = parsed_result;
3040 struct rte_eth_dev_info dev_info;
3042 if (port_id_is_invalid(res->port_id))
3045 if (!strcmp(res->mode, "set"))
3046 ports[res->port_id].tso_segsz = res->tso_segsz;
3048 if (ports[res->port_id].tso_segsz == 0)
3049 printf("TSO is disabled\n");
3051 printf("TSO segment size is %d\n",
3052 ports[res->port_id].tso_segsz);
3054 /* display warnings if configuration is not supported by the NIC */
3055 rte_eth_dev_info_get(res->port_id, &dev_info);
3056 if ((ports[res->port_id].tso_segsz != 0) &&
3057 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3058 printf("Warning: TSO enabled but not "
3059 "supported by port %d\n", res->port_id);
3063 cmdline_parse_token_string_t cmd_tso_set_tso =
3064 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3066 cmdline_parse_token_string_t cmd_tso_set_mode =
3067 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3069 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3070 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3072 cmdline_parse_token_num_t cmd_tso_set_portid =
3073 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3076 cmdline_parse_inst_t cmd_tso_set = {
3077 .f = cmd_tso_set_parsed,
3079 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3080 "tso set <tso_segsz> <port>",
3082 (void *)&cmd_tso_set_tso,
3083 (void *)&cmd_tso_set_mode,
3084 (void *)&cmd_tso_set_tso_segsz,
3085 (void *)&cmd_tso_set_portid,
3090 cmdline_parse_token_string_t cmd_tso_show_mode =
3091 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3095 cmdline_parse_inst_t cmd_tso_show = {
3096 .f = cmd_tso_set_parsed,
3098 .help_str = "Show TSO segment size for csum engine: "
3101 (void *)&cmd_tso_set_tso,
3102 (void *)&cmd_tso_show_mode,
3103 (void *)&cmd_tso_set_portid,
3108 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3109 struct cmd_set_flush_rx {
3110 cmdline_fixed_string_t set;
3111 cmdline_fixed_string_t flush_rx;
3112 cmdline_fixed_string_t mode;
3116 cmd_set_flush_rx_parsed(void *parsed_result,
3117 __attribute__((unused)) struct cmdline *cl,
3118 __attribute__((unused)) void *data)
3120 struct cmd_set_flush_rx *res = parsed_result;
3121 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3124 cmdline_parse_token_string_t cmd_setflushrx_set =
3125 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3127 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3128 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3129 flush_rx, "flush_rx");
3130 cmdline_parse_token_string_t cmd_setflushrx_mode =
3131 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3135 cmdline_parse_inst_t cmd_set_flush_rx = {
3136 .f = cmd_set_flush_rx_parsed,
3137 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3140 (void *)&cmd_setflushrx_set,
3141 (void *)&cmd_setflushrx_flush_rx,
3142 (void *)&cmd_setflushrx_mode,
3147 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3148 struct cmd_set_link_check {
3149 cmdline_fixed_string_t set;
3150 cmdline_fixed_string_t link_check;
3151 cmdline_fixed_string_t mode;
3155 cmd_set_link_check_parsed(void *parsed_result,
3156 __attribute__((unused)) struct cmdline *cl,
3157 __attribute__((unused)) void *data)
3159 struct cmd_set_link_check *res = parsed_result;
3160 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3163 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3164 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3166 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3167 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3168 link_check, "link_check");
3169 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3170 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3174 cmdline_parse_inst_t cmd_set_link_check = {
3175 .f = cmd_set_link_check_parsed,
3176 .help_str = "set link_check on|off: enable/disable link status check "
3177 "when starting/stopping a port",
3180 (void *)&cmd_setlinkcheck_set,
3181 (void *)&cmd_setlinkcheck_link_check,
3182 (void *)&cmd_setlinkcheck_mode,
3187 #ifdef RTE_NIC_BYPASS
3188 /* *** SET NIC BYPASS MODE *** */
3189 struct cmd_set_bypass_mode_result {
3190 cmdline_fixed_string_t set;
3191 cmdline_fixed_string_t bypass;
3192 cmdline_fixed_string_t mode;
3193 cmdline_fixed_string_t value;
3198 cmd_set_bypass_mode_parsed(void *parsed_result,
3199 __attribute__((unused)) struct cmdline *cl,
3200 __attribute__((unused)) void *data)
3202 struct cmd_set_bypass_mode_result *res = parsed_result;
3203 portid_t port_id = res->port_id;
3204 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3206 if (!bypass_is_supported(port_id))
3209 if (!strcmp(res->value, "bypass"))
3210 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3211 else if (!strcmp(res->value, "isolate"))
3212 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3214 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3216 /* Set the bypass mode for the relevant port. */
3217 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3218 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3222 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3223 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3225 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3226 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3228 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3229 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3231 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3232 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3233 value, "normal#bypass#isolate");
3234 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3235 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3238 cmdline_parse_inst_t cmd_set_bypass_mode = {
3239 .f = cmd_set_bypass_mode_parsed,
3240 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3241 "Set the NIC bypass mode for port_id",
3244 (void *)&cmd_setbypass_mode_set,
3245 (void *)&cmd_setbypass_mode_bypass,
3246 (void *)&cmd_setbypass_mode_mode,
3247 (void *)&cmd_setbypass_mode_value,
3248 (void *)&cmd_setbypass_mode_port,
3253 /* *** SET NIC BYPASS EVENT *** */
3254 struct cmd_set_bypass_event_result {
3255 cmdline_fixed_string_t set;
3256 cmdline_fixed_string_t bypass;
3257 cmdline_fixed_string_t event;
3258 cmdline_fixed_string_t event_value;
3259 cmdline_fixed_string_t mode;
3260 cmdline_fixed_string_t mode_value;
3265 cmd_set_bypass_event_parsed(void *parsed_result,
3266 __attribute__((unused)) struct cmdline *cl,
3267 __attribute__((unused)) void *data)
3270 struct cmd_set_bypass_event_result *res = parsed_result;
3271 portid_t port_id = res->port_id;
3272 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3273 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3275 if (!bypass_is_supported(port_id))
3278 if (!strcmp(res->event_value, "timeout"))
3279 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3280 else if (!strcmp(res->event_value, "os_on"))
3281 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3282 else if (!strcmp(res->event_value, "os_off"))
3283 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3284 else if (!strcmp(res->event_value, "power_on"))
3285 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3286 else if (!strcmp(res->event_value, "power_off"))
3287 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3289 bypass_event = RTE_BYPASS_EVENT_NONE;
3291 if (!strcmp(res->mode_value, "bypass"))
3292 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3293 else if (!strcmp(res->mode_value, "isolate"))
3294 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3296 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3298 /* Set the watchdog timeout. */
3299 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3302 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3303 (rc = rte_eth_dev_wd_timeout_store(port_id,
3304 bypass_timeout)) != 0) {
3305 printf("Failed to set timeout value %u "
3306 "for port %d, errto code: %d.\n",
3307 bypass_timeout, port_id, rc);
3311 /* Set the bypass event to transition to bypass mode. */
3312 if (0 != rte_eth_dev_bypass_event_store(port_id,
3313 bypass_event, bypass_mode)) {
3314 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3319 cmdline_parse_token_string_t cmd_setbypass_event_set =
3320 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3322 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3323 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3325 cmdline_parse_token_string_t cmd_setbypass_event_event =
3326 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3328 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3329 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3330 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3331 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3332 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3334 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3335 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3336 mode_value, "normal#bypass#isolate");
3337 cmdline_parse_token_num_t cmd_setbypass_event_port =
3338 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3341 cmdline_parse_inst_t cmd_set_bypass_event = {
3342 .f = cmd_set_bypass_event_parsed,
3343 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3344 "mode (normal|bypass|isolate) (port_id): "
3345 "Set the NIC bypass event mode for port_id",
3348 (void *)&cmd_setbypass_event_set,
3349 (void *)&cmd_setbypass_event_bypass,
3350 (void *)&cmd_setbypass_event_event,
3351 (void *)&cmd_setbypass_event_event_value,
3352 (void *)&cmd_setbypass_event_mode,
3353 (void *)&cmd_setbypass_event_mode_value,
3354 (void *)&cmd_setbypass_event_port,
3360 /* *** SET NIC BYPASS TIMEOUT *** */
3361 struct cmd_set_bypass_timeout_result {
3362 cmdline_fixed_string_t set;
3363 cmdline_fixed_string_t bypass;
3364 cmdline_fixed_string_t timeout;
3365 cmdline_fixed_string_t value;
3369 cmd_set_bypass_timeout_parsed(void *parsed_result,
3370 __attribute__((unused)) struct cmdline *cl,
3371 __attribute__((unused)) void *data)
3373 struct cmd_set_bypass_timeout_result *res = parsed_result;
3375 if (!strcmp(res->value, "1.5"))
3376 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3377 else if (!strcmp(res->value, "2"))
3378 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3379 else if (!strcmp(res->value, "3"))
3380 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3381 else if (!strcmp(res->value, "4"))
3382 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3383 else if (!strcmp(res->value, "8"))
3384 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3385 else if (!strcmp(res->value, "16"))
3386 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3387 else if (!strcmp(res->value, "32"))
3388 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3390 bypass_timeout = RTE_BYPASS_TMT_OFF;
3393 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3394 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3396 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3397 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3399 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3400 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3401 timeout, "timeout");
3402 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3403 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3404 value, "0#1.5#2#3#4#8#16#32");
3406 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3407 .f = cmd_set_bypass_timeout_parsed,
3408 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3409 "Set the NIC bypass watchdog timeout",
3412 (void *)&cmd_setbypass_timeout_set,
3413 (void *)&cmd_setbypass_timeout_bypass,
3414 (void *)&cmd_setbypass_timeout_timeout,
3415 (void *)&cmd_setbypass_timeout_value,
3420 /* *** SHOW NIC BYPASS MODE *** */
3421 struct cmd_show_bypass_config_result {
3422 cmdline_fixed_string_t show;
3423 cmdline_fixed_string_t bypass;
3424 cmdline_fixed_string_t config;
3429 cmd_show_bypass_config_parsed(void *parsed_result,
3430 __attribute__((unused)) struct cmdline *cl,
3431 __attribute__((unused)) void *data)
3433 struct cmd_show_bypass_config_result *res = parsed_result;
3434 uint32_t event_mode;
3435 uint32_t bypass_mode;
3436 portid_t port_id = res->port_id;
3437 uint32_t timeout = bypass_timeout;
3440 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3441 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3442 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3443 {"UNKNOWN", "normal", "bypass", "isolate"};
3444 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3451 int num_events = (sizeof events) / (sizeof events[0]);
3453 if (!bypass_is_supported(port_id))
3456 /* Display the bypass mode.*/
3457 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3458 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3462 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3463 bypass_mode = RTE_BYPASS_MODE_NONE;
3465 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3468 /* Display the bypass timeout.*/
3469 if (!RTE_BYPASS_TMT_VALID(timeout))
3470 timeout = RTE_BYPASS_TMT_OFF;
3472 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3474 /* Display the bypass events and associated modes. */
3475 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3477 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3478 printf("\tFailed to get bypass mode for event = %s\n",
3481 if (!RTE_BYPASS_MODE_VALID(event_mode))
3482 event_mode = RTE_BYPASS_MODE_NONE;
3484 printf("\tbypass event: %-16s = %s\n", events[i],
3490 cmdline_parse_token_string_t cmd_showbypass_config_show =
3491 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3493 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3494 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3496 cmdline_parse_token_string_t cmd_showbypass_config_config =
3497 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3499 cmdline_parse_token_num_t cmd_showbypass_config_port =
3500 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3503 cmdline_parse_inst_t cmd_show_bypass_config = {
3504 .f = cmd_show_bypass_config_parsed,
3505 .help_str = "show bypass config (port_id): "
3506 "Show the NIC bypass config for port_id",
3509 (void *)&cmd_showbypass_config_show,
3510 (void *)&cmd_showbypass_config_bypass,
3511 (void *)&cmd_showbypass_config_config,
3512 (void *)&cmd_showbypass_config_port,
3518 #ifdef RTE_LIBRTE_PMD_BOND
3519 /* *** SET BONDING MODE *** */
3520 struct cmd_set_bonding_mode_result {
3521 cmdline_fixed_string_t set;
3522 cmdline_fixed_string_t bonding;
3523 cmdline_fixed_string_t mode;
3528 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3529 __attribute__((unused)) struct cmdline *cl,
3530 __attribute__((unused)) void *data)
3532 struct cmd_set_bonding_mode_result *res = parsed_result;
3533 portid_t port_id = res->port_id;
3535 /* Set the bonding mode for the relevant port. */
3536 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3537 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3540 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3541 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3543 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3544 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3545 bonding, "bonding");
3546 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3547 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3549 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3550 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3552 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3553 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3556 cmdline_parse_inst_t cmd_set_bonding_mode = {
3557 .f = cmd_set_bonding_mode_parsed,
3558 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3561 (void *) &cmd_setbonding_mode_set,
3562 (void *) &cmd_setbonding_mode_bonding,
3563 (void *) &cmd_setbonding_mode_mode,
3564 (void *) &cmd_setbonding_mode_value,
3565 (void *) &cmd_setbonding_mode_port,
3570 /* *** SET BALANCE XMIT POLICY *** */
3571 struct cmd_set_bonding_balance_xmit_policy_result {
3572 cmdline_fixed_string_t set;
3573 cmdline_fixed_string_t bonding;
3574 cmdline_fixed_string_t balance_xmit_policy;
3576 cmdline_fixed_string_t policy;
3579 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3580 __attribute__((unused)) struct cmdline *cl,
3581 __attribute__((unused)) void *data)
3583 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3584 portid_t port_id = res->port_id;
3587 if (!strcmp(res->policy, "l2")) {
3588 policy = BALANCE_XMIT_POLICY_LAYER2;
3589 } else if (!strcmp(res->policy, "l23")) {
3590 policy = BALANCE_XMIT_POLICY_LAYER23;
3591 } else if (!strcmp(res->policy, "l34")) {
3592 policy = BALANCE_XMIT_POLICY_LAYER34;
3594 printf("\t Invalid xmit policy selection");
3598 /* Set the bonding mode for the relevant port. */
3599 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3600 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3605 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3606 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3608 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3609 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3610 bonding, "bonding");
3611 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3612 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3613 balance_xmit_policy, "balance_xmit_policy");
3614 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3615 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3617 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3618 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3619 policy, "l2#l23#l34");
3621 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3622 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3623 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3626 (void *)&cmd_setbonding_balance_xmit_policy_set,
3627 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3628 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3629 (void *)&cmd_setbonding_balance_xmit_policy_port,
3630 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3635 /* *** SHOW NIC BONDING CONFIGURATION *** */
3636 struct cmd_show_bonding_config_result {
3637 cmdline_fixed_string_t show;
3638 cmdline_fixed_string_t bonding;
3639 cmdline_fixed_string_t config;
3643 static void cmd_show_bonding_config_parsed(void *parsed_result,
3644 __attribute__((unused)) struct cmdline *cl,
3645 __attribute__((unused)) void *data)
3647 struct cmd_show_bonding_config_result *res = parsed_result;
3649 uint8_t slaves[RTE_MAX_ETHPORTS];
3650 int num_slaves, num_active_slaves;
3653 portid_t port_id = res->port_id;
3655 /* Display the bonding mode.*/
3656 bonding_mode = rte_eth_bond_mode_get(port_id);
3657 if (bonding_mode < 0) {
3658 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3661 printf("\tBonding mode: %d\n", bonding_mode);
3663 if (bonding_mode == BONDING_MODE_BALANCE) {
3664 int balance_xmit_policy;
3666 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3667 if (balance_xmit_policy < 0) {
3668 printf("\tFailed to get balance xmit policy for port = %d\n",
3672 printf("\tBalance Xmit Policy: ");
3674 switch (balance_xmit_policy) {
3675 case BALANCE_XMIT_POLICY_LAYER2:
3676 printf("BALANCE_XMIT_POLICY_LAYER2");
3678 case BALANCE_XMIT_POLICY_LAYER23:
3679 printf("BALANCE_XMIT_POLICY_LAYER23");
3681 case BALANCE_XMIT_POLICY_LAYER34:
3682 printf("BALANCE_XMIT_POLICY_LAYER34");
3689 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3691 if (num_slaves < 0) {
3692 printf("\tFailed to get slave list for port = %d\n", port_id);
3695 if (num_slaves > 0) {
3696 printf("\tSlaves (%d): [", num_slaves);
3697 for (i = 0; i < num_slaves - 1; i++)
3698 printf("%d ", slaves[i]);
3700 printf("%d]\n", slaves[num_slaves - 1]);
3702 printf("\tSlaves: []\n");
3706 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3709 if (num_active_slaves < 0) {
3710 printf("\tFailed to get active slave list for port = %d\n", port_id);
3713 if (num_active_slaves > 0) {
3714 printf("\tActive Slaves (%d): [", num_active_slaves);
3715 for (i = 0; i < num_active_slaves - 1; i++)
3716 printf("%d ", slaves[i]);
3718 printf("%d]\n", slaves[num_active_slaves - 1]);
3721 printf("\tActive Slaves: []\n");
3725 primary_id = rte_eth_bond_primary_get(port_id);
3726 if (primary_id < 0) {
3727 printf("\tFailed to get primary slave for port = %d\n", port_id);
3730 printf("\tPrimary: [%d]\n", primary_id);
3734 cmdline_parse_token_string_t cmd_showbonding_config_show =
3735 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3737 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3738 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3739 bonding, "bonding");
3740 cmdline_parse_token_string_t cmd_showbonding_config_config =
3741 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3743 cmdline_parse_token_num_t cmd_showbonding_config_port =
3744 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3747 cmdline_parse_inst_t cmd_show_bonding_config = {
3748 .f = cmd_show_bonding_config_parsed,
3749 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3752 (void *)&cmd_showbonding_config_show,
3753 (void *)&cmd_showbonding_config_bonding,
3754 (void *)&cmd_showbonding_config_config,
3755 (void *)&cmd_showbonding_config_port,
3760 /* *** SET BONDING PRIMARY *** */
3761 struct cmd_set_bonding_primary_result {
3762 cmdline_fixed_string_t set;
3763 cmdline_fixed_string_t bonding;
3764 cmdline_fixed_string_t primary;
3769 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3770 __attribute__((unused)) struct cmdline *cl,
3771 __attribute__((unused)) void *data)
3773 struct cmd_set_bonding_primary_result *res = parsed_result;
3774 portid_t master_port_id = res->port_id;
3775 portid_t slave_port_id = res->slave_id;
3777 /* Set the primary slave for a bonded device. */
3778 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3779 printf("\t Failed to set primary slave for port = %d.\n",
3786 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3789 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3790 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3791 bonding, "bonding");
3792 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3793 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3794 primary, "primary");
3795 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3796 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3798 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3799 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3802 cmdline_parse_inst_t cmd_set_bonding_primary = {
3803 .f = cmd_set_bonding_primary_parsed,
3804 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3807 (void *)&cmd_setbonding_primary_set,
3808 (void *)&cmd_setbonding_primary_bonding,
3809 (void *)&cmd_setbonding_primary_primary,
3810 (void *)&cmd_setbonding_primary_slave,
3811 (void *)&cmd_setbonding_primary_port,
3816 /* *** ADD SLAVE *** */
3817 struct cmd_add_bonding_slave_result {
3818 cmdline_fixed_string_t add;
3819 cmdline_fixed_string_t bonding;
3820 cmdline_fixed_string_t slave;
3825 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3826 __attribute__((unused)) struct cmdline *cl,
3827 __attribute__((unused)) void *data)
3829 struct cmd_add_bonding_slave_result *res = parsed_result;
3830 portid_t master_port_id = res->port_id;
3831 portid_t slave_port_id = res->slave_id;
3833 /* Set the primary slave for a bonded device. */
3834 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3835 printf("\t Failed to add slave %d to master port = %d.\n",
3836 slave_port_id, master_port_id);
3842 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3843 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3845 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3846 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3847 bonding, "bonding");
3848 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3849 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3851 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3852 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3854 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3855 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3858 cmdline_parse_inst_t cmd_add_bonding_slave = {
3859 .f = cmd_add_bonding_slave_parsed,
3860 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3863 (void *)&cmd_addbonding_slave_add,
3864 (void *)&cmd_addbonding_slave_bonding,
3865 (void *)&cmd_addbonding_slave_slave,
3866 (void *)&cmd_addbonding_slave_slaveid,
3867 (void *)&cmd_addbonding_slave_port,
3872 /* *** REMOVE SLAVE *** */
3873 struct cmd_remove_bonding_slave_result {
3874 cmdline_fixed_string_t remove;
3875 cmdline_fixed_string_t bonding;
3876 cmdline_fixed_string_t slave;
3881 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3882 __attribute__((unused)) struct cmdline *cl,
3883 __attribute__((unused)) void *data)
3885 struct cmd_remove_bonding_slave_result *res = parsed_result;
3886 portid_t master_port_id = res->port_id;
3887 portid_t slave_port_id = res->slave_id;
3889 /* Set the primary slave for a bonded device. */
3890 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3891 printf("\t Failed to remove slave %d from master port = %d.\n",
3892 slave_port_id, master_port_id);
3898 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3899 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3901 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3902 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3903 bonding, "bonding");
3904 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3905 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3907 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3908 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3910 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3911 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3914 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3915 .f = cmd_remove_bonding_slave_parsed,
3916 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3919 (void *)&cmd_removebonding_slave_remove,
3920 (void *)&cmd_removebonding_slave_bonding,
3921 (void *)&cmd_removebonding_slave_slave,
3922 (void *)&cmd_removebonding_slave_slaveid,
3923 (void *)&cmd_removebonding_slave_port,
3928 /* *** CREATE BONDED DEVICE *** */
3929 struct cmd_create_bonded_device_result {
3930 cmdline_fixed_string_t create;
3931 cmdline_fixed_string_t bonded;
3932 cmdline_fixed_string_t device;
3937 static int bond_dev_num = 0;
3939 static void cmd_create_bonded_device_parsed(void *parsed_result,
3940 __attribute__((unused)) struct cmdline *cl,
3941 __attribute__((unused)) void *data)
3943 struct cmd_create_bonded_device_result *res = parsed_result;
3944 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3947 if (test_done == 0) {
3948 printf("Please stop forwarding first\n");
3952 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3955 /* Create a new bonded device. */
3956 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3958 printf("\t Failed to create bonded device.\n");
3961 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3964 /* Update number of ports */
3965 nb_ports = rte_eth_dev_count();
3966 reconfig(port_id, res->socket);
3967 rte_eth_promiscuous_enable(port_id);
3972 cmdline_parse_token_string_t cmd_createbonded_device_create =
3973 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3975 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3976 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3978 cmdline_parse_token_string_t cmd_createbonded_device_device =
3979 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3981 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3982 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3984 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3985 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3988 cmdline_parse_inst_t cmd_create_bonded_device = {
3989 .f = cmd_create_bonded_device_parsed,
3990 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3993 (void *)&cmd_createbonded_device_create,
3994 (void *)&cmd_createbonded_device_bonded,
3995 (void *)&cmd_createbonded_device_device,
3996 (void *)&cmd_createbonded_device_mode,
3997 (void *)&cmd_createbonded_device_socket,
4002 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4003 struct cmd_set_bond_mac_addr_result {
4004 cmdline_fixed_string_t set;
4005 cmdline_fixed_string_t bonding;
4006 cmdline_fixed_string_t mac_addr;
4008 struct ether_addr address;
4011 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4012 __attribute__((unused)) struct cmdline *cl,
4013 __attribute__((unused)) void *data)
4015 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4018 if (res->port_num >= nb_ports) {
4019 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4023 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4025 /* check the return value and print it if is < 0 */
4027 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4030 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4031 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4032 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4033 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4035 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4036 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4038 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4039 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4040 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4041 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4043 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4044 .f = cmd_set_bond_mac_addr_parsed,
4046 .help_str = "set bonding mac_addr (port_id) (address): ",
4048 (void *)&cmd_set_bond_mac_addr_set,
4049 (void *)&cmd_set_bond_mac_addr_bonding,
4050 (void *)&cmd_set_bond_mac_addr_mac,
4051 (void *)&cmd_set_bond_mac_addr_portnum,
4052 (void *)&cmd_set_bond_mac_addr_addr,
4058 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4059 struct cmd_set_bond_mon_period_result {
4060 cmdline_fixed_string_t set;
4061 cmdline_fixed_string_t bonding;
4062 cmdline_fixed_string_t mon_period;
4067 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4068 __attribute__((unused)) struct cmdline *cl,
4069 __attribute__((unused)) void *data)
4071 struct cmd_set_bond_mon_period_result *res = parsed_result;
4074 if (res->port_num >= nb_ports) {
4075 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4079 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4081 /* check the return value and print it if is < 0 */
4083 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4086 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4087 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4089 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4090 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4091 bonding, "bonding");
4092 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4093 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4094 mon_period, "mon_period");
4095 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4096 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4098 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4099 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4102 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4103 .f = cmd_set_bond_mon_period_parsed,
4105 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4107 (void *)&cmd_set_bond_mon_period_set,
4108 (void *)&cmd_set_bond_mon_period_bonding,
4109 (void *)&cmd_set_bond_mon_period_mon_period,
4110 (void *)&cmd_set_bond_mon_period_portnum,
4111 (void *)&cmd_set_bond_mon_period_period_ms,
4116 #endif /* RTE_LIBRTE_PMD_BOND */
4118 /* *** SET FORWARDING MODE *** */
4119 struct cmd_set_fwd_mode_result {
4120 cmdline_fixed_string_t set;
4121 cmdline_fixed_string_t fwd;
4122 cmdline_fixed_string_t mode;
4125 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4126 __attribute__((unused)) struct cmdline *cl,
4127 __attribute__((unused)) void *data)
4129 struct cmd_set_fwd_mode_result *res = parsed_result;
4131 set_pkt_forwarding_mode(res->mode);
4134 cmdline_parse_token_string_t cmd_setfwd_set =
4135 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4136 cmdline_parse_token_string_t cmd_setfwd_fwd =
4137 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4138 cmdline_parse_token_string_t cmd_setfwd_mode =
4139 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4140 "" /* defined at init */);
4142 cmdline_parse_inst_t cmd_set_fwd_mode = {
4143 .f = cmd_set_fwd_mode_parsed,
4145 .help_str = NULL, /* defined at init */
4147 (void *)&cmd_setfwd_set,
4148 (void *)&cmd_setfwd_fwd,
4149 (void *)&cmd_setfwd_mode,
4154 static void cmd_set_fwd_mode_init(void)
4157 static char token[128];
4158 static char help[256];
4159 cmdline_parse_token_string_t *token_struct;
4161 modes = list_pkt_forwarding_modes();
4162 snprintf(help, sizeof help, "set fwd %s - "
4163 "set packet forwarding mode", modes);
4164 cmd_set_fwd_mode.help_str = help;
4166 /* string token separator is # */
4167 for (c = token; *modes != '\0'; modes++)
4172 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4173 token_struct->string_data.str = token;
4176 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4177 struct cmd_set_burst_tx_retry_result {
4178 cmdline_fixed_string_t set;
4179 cmdline_fixed_string_t burst;
4180 cmdline_fixed_string_t tx;
4181 cmdline_fixed_string_t delay;
4183 cmdline_fixed_string_t retry;
4187 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4188 __attribute__((unused)) struct cmdline *cl,
4189 __attribute__((unused)) void *data)
4191 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4193 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4194 && !strcmp(res->tx, "tx")) {
4195 if (!strcmp(res->delay, "delay"))
4196 burst_tx_delay_time = res->time;
4197 if (!strcmp(res->retry, "retry"))
4198 burst_tx_retry_num = res->retry_num;
4203 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4204 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4205 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4206 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4208 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4209 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4210 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4211 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4212 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4213 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4214 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4215 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4216 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4217 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4219 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4220 .f = cmd_set_burst_tx_retry_parsed,
4221 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4223 (void *)&cmd_set_burst_tx_retry_set,
4224 (void *)&cmd_set_burst_tx_retry_burst,
4225 (void *)&cmd_set_burst_tx_retry_tx,
4226 (void *)&cmd_set_burst_tx_retry_delay,
4227 (void *)&cmd_set_burst_tx_retry_time,
4228 (void *)&cmd_set_burst_tx_retry_retry,
4229 (void *)&cmd_set_burst_tx_retry_retry_num,
4234 /* *** SET PROMISC MODE *** */
4235 struct cmd_set_promisc_mode_result {
4236 cmdline_fixed_string_t set;
4237 cmdline_fixed_string_t promisc;
4238 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4239 uint8_t port_num; /* valid if "allports" argument == 0 */
4240 cmdline_fixed_string_t mode;
4243 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4244 __attribute__((unused)) struct cmdline *cl,
4247 struct cmd_set_promisc_mode_result *res = parsed_result;
4251 if (!strcmp(res->mode, "on"))
4258 for (i = 0; i < nb_ports; i++) {
4260 rte_eth_promiscuous_enable(i);
4262 rte_eth_promiscuous_disable(i);
4267 rte_eth_promiscuous_enable(res->port_num);
4269 rte_eth_promiscuous_disable(res->port_num);
4273 cmdline_parse_token_string_t cmd_setpromisc_set =
4274 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4275 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4276 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4278 cmdline_parse_token_string_t cmd_setpromisc_portall =
4279 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4281 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4282 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4284 cmdline_parse_token_string_t cmd_setpromisc_mode =
4285 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4288 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4289 .f = cmd_set_promisc_mode_parsed,
4291 .help_str = "set promisc all on|off: set promisc mode for all ports",
4293 (void *)&cmd_setpromisc_set,
4294 (void *)&cmd_setpromisc_promisc,
4295 (void *)&cmd_setpromisc_portall,
4296 (void *)&cmd_setpromisc_mode,
4301 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4302 .f = cmd_set_promisc_mode_parsed,
4304 .help_str = "set promisc X on|off: set promisc mode on port X",
4306 (void *)&cmd_setpromisc_set,
4307 (void *)&cmd_setpromisc_promisc,
4308 (void *)&cmd_setpromisc_portnum,
4309 (void *)&cmd_setpromisc_mode,
4314 /* *** SET ALLMULTI MODE *** */
4315 struct cmd_set_allmulti_mode_result {
4316 cmdline_fixed_string_t set;
4317 cmdline_fixed_string_t allmulti;
4318 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4319 uint8_t port_num; /* valid if "allports" argument == 0 */
4320 cmdline_fixed_string_t mode;
4323 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4324 __attribute__((unused)) struct cmdline *cl,
4327 struct cmd_set_allmulti_mode_result *res = parsed_result;
4331 if (!strcmp(res->mode, "on"))
4338 for (i = 0; i < nb_ports; i++) {
4340 rte_eth_allmulticast_enable(i);
4342 rte_eth_allmulticast_disable(i);
4347 rte_eth_allmulticast_enable(res->port_num);
4349 rte_eth_allmulticast_disable(res->port_num);
4353 cmdline_parse_token_string_t cmd_setallmulti_set =
4354 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4355 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4356 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4358 cmdline_parse_token_string_t cmd_setallmulti_portall =
4359 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4361 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4362 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4364 cmdline_parse_token_string_t cmd_setallmulti_mode =
4365 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4368 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4369 .f = cmd_set_allmulti_mode_parsed,
4371 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4373 (void *)&cmd_setallmulti_set,
4374 (void *)&cmd_setallmulti_allmulti,
4375 (void *)&cmd_setallmulti_portall,
4376 (void *)&cmd_setallmulti_mode,
4381 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4382 .f = cmd_set_allmulti_mode_parsed,
4384 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4386 (void *)&cmd_setallmulti_set,
4387 (void *)&cmd_setallmulti_allmulti,
4388 (void *)&cmd_setallmulti_portnum,
4389 (void *)&cmd_setallmulti_mode,
4394 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4395 struct cmd_link_flow_ctrl_set_result {
4396 cmdline_fixed_string_t set;
4397 cmdline_fixed_string_t flow_ctrl;
4398 cmdline_fixed_string_t rx;
4399 cmdline_fixed_string_t rx_lfc_mode;
4400 cmdline_fixed_string_t tx;
4401 cmdline_fixed_string_t tx_lfc_mode;
4402 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4403 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4404 cmdline_fixed_string_t autoneg_str;
4405 cmdline_fixed_string_t autoneg;
4406 cmdline_fixed_string_t hw_str;
4407 uint32_t high_water;
4408 cmdline_fixed_string_t lw_str;
4410 cmdline_fixed_string_t pt_str;
4411 uint16_t pause_time;
4412 cmdline_fixed_string_t xon_str;
4417 cmdline_parse_token_string_t cmd_lfc_set_set =
4418 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4420 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4421 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4422 flow_ctrl, "flow_ctrl");
4423 cmdline_parse_token_string_t cmd_lfc_set_rx =
4424 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4426 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4427 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4428 rx_lfc_mode, "on#off");
4429 cmdline_parse_token_string_t cmd_lfc_set_tx =
4430 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4432 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4433 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4434 tx_lfc_mode, "on#off");
4435 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4436 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4437 hw_str, "high_water");
4438 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4439 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4440 high_water, UINT32);
4441 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4442 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4443 lw_str, "low_water");
4444 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4445 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4447 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4448 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4449 pt_str, "pause_time");
4450 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4451 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4452 pause_time, UINT16);
4453 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4454 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4455 xon_str, "send_xon");
4456 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4457 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4459 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4460 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4461 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4462 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4463 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4464 mac_ctrl_frame_fwd_mode, "on#off");
4465 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4466 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4467 autoneg_str, "autoneg");
4468 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4469 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4471 cmdline_parse_token_num_t cmd_lfc_set_portid =
4472 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4475 /* forward declaration */
4477 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4480 cmdline_parse_inst_t cmd_link_flow_control_set = {
4481 .f = cmd_link_flow_ctrl_set_parsed,
4483 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4484 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4485 autoneg on|off port_id",
4487 (void *)&cmd_lfc_set_set,
4488 (void *)&cmd_lfc_set_flow_ctrl,
4489 (void *)&cmd_lfc_set_rx,
4490 (void *)&cmd_lfc_set_rx_mode,
4491 (void *)&cmd_lfc_set_tx,
4492 (void *)&cmd_lfc_set_tx_mode,
4493 (void *)&cmd_lfc_set_high_water,
4494 (void *)&cmd_lfc_set_low_water,
4495 (void *)&cmd_lfc_set_pause_time,
4496 (void *)&cmd_lfc_set_send_xon,
4497 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4498 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4499 (void *)&cmd_lfc_set_autoneg_str,
4500 (void *)&cmd_lfc_set_autoneg,
4501 (void *)&cmd_lfc_set_portid,
4506 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4507 .f = cmd_link_flow_ctrl_set_parsed,
4508 .data = (void *)&cmd_link_flow_control_set_rx,
4509 .help_str = "Change rx flow control parameter: set flow_ctrl "
4510 "rx on|off port_id",
4512 (void *)&cmd_lfc_set_set,
4513 (void *)&cmd_lfc_set_flow_ctrl,
4514 (void *)&cmd_lfc_set_rx,
4515 (void *)&cmd_lfc_set_rx_mode,
4516 (void *)&cmd_lfc_set_portid,
4521 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4522 .f = cmd_link_flow_ctrl_set_parsed,
4523 .data = (void *)&cmd_link_flow_control_set_tx,
4524 .help_str = "Change tx flow control parameter: set flow_ctrl "
4525 "tx on|off port_id",
4527 (void *)&cmd_lfc_set_set,
4528 (void *)&cmd_lfc_set_flow_ctrl,
4529 (void *)&cmd_lfc_set_tx,
4530 (void *)&cmd_lfc_set_tx_mode,
4531 (void *)&cmd_lfc_set_portid,
4536 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4537 .f = cmd_link_flow_ctrl_set_parsed,
4538 .data = (void *)&cmd_link_flow_control_set_hw,
4539 .help_str = "Change high water flow control parameter: set flow_ctrl "
4540 "high_water value port_id",
4542 (void *)&cmd_lfc_set_set,
4543 (void *)&cmd_lfc_set_flow_ctrl,
4544 (void *)&cmd_lfc_set_high_water_str,
4545 (void *)&cmd_lfc_set_high_water,
4546 (void *)&cmd_lfc_set_portid,
4551 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4552 .f = cmd_link_flow_ctrl_set_parsed,
4553 .data = (void *)&cmd_link_flow_control_set_lw,
4554 .help_str = "Change low water flow control parameter: set flow_ctrl "
4555 "low_water value port_id",
4557 (void *)&cmd_lfc_set_set,
4558 (void *)&cmd_lfc_set_flow_ctrl,
4559 (void *)&cmd_lfc_set_low_water_str,
4560 (void *)&cmd_lfc_set_low_water,
4561 (void *)&cmd_lfc_set_portid,
4566 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4567 .f = cmd_link_flow_ctrl_set_parsed,
4568 .data = (void *)&cmd_link_flow_control_set_pt,
4569 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4570 "pause_time value port_id",
4572 (void *)&cmd_lfc_set_set,
4573 (void *)&cmd_lfc_set_flow_ctrl,
4574 (void *)&cmd_lfc_set_pause_time_str,
4575 (void *)&cmd_lfc_set_pause_time,
4576 (void *)&cmd_lfc_set_portid,
4581 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4582 .f = cmd_link_flow_ctrl_set_parsed,
4583 .data = (void *)&cmd_link_flow_control_set_xon,
4584 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4585 "send_xon value port_id",
4587 (void *)&cmd_lfc_set_set,
4588 (void *)&cmd_lfc_set_flow_ctrl,
4589 (void *)&cmd_lfc_set_send_xon_str,
4590 (void *)&cmd_lfc_set_send_xon,
4591 (void *)&cmd_lfc_set_portid,
4596 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4597 .f = cmd_link_flow_ctrl_set_parsed,
4598 .data = (void *)&cmd_link_flow_control_set_macfwd,
4599 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4600 "mac_ctrl_frame_fwd on|off port_id",
4602 (void *)&cmd_lfc_set_set,
4603 (void *)&cmd_lfc_set_flow_ctrl,
4604 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4605 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4606 (void *)&cmd_lfc_set_portid,
4611 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4612 .f = cmd_link_flow_ctrl_set_parsed,
4613 .data = (void *)&cmd_link_flow_control_set_autoneg,
4614 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4615 "autoneg on|off port_id",
4617 (void *)&cmd_lfc_set_set,
4618 (void *)&cmd_lfc_set_flow_ctrl,
4619 (void *)&cmd_lfc_set_autoneg_str,
4620 (void *)&cmd_lfc_set_autoneg,
4621 (void *)&cmd_lfc_set_portid,
4627 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4628 __attribute__((unused)) struct cmdline *cl,
4631 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4632 cmdline_parse_inst_t *cmd = data;
4633 struct rte_eth_fc_conf fc_conf;
4634 int rx_fc_en, tx_fc_en = 0;
4638 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4639 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4640 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4641 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4643 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4644 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4647 /* Partial command line, retrieve current configuration */
4649 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4651 printf("cannot get current flow ctrl parameters, return"
4652 "code = %d\n", ret);
4656 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4657 (fc_conf.mode == RTE_FC_FULL))
4659 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4660 (fc_conf.mode == RTE_FC_FULL))
4664 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4665 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4667 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4668 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4670 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4672 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4673 fc_conf.high_water = res->high_water;
4675 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4676 fc_conf.low_water = res->low_water;
4678 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4679 fc_conf.pause_time = res->pause_time;
4681 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4682 fc_conf.send_xon = res->send_xon;
4684 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4685 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4686 fc_conf.mac_ctrl_frame_fwd = 1;
4688 fc_conf.mac_ctrl_frame_fwd = 0;
4691 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4692 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4694 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4696 printf("bad flow contrl parameter, return code = %d \n", ret);
4699 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4700 struct cmd_priority_flow_ctrl_set_result {
4701 cmdline_fixed_string_t set;
4702 cmdline_fixed_string_t pfc_ctrl;
4703 cmdline_fixed_string_t rx;
4704 cmdline_fixed_string_t rx_pfc_mode;
4705 cmdline_fixed_string_t tx;
4706 cmdline_fixed_string_t tx_pfc_mode;
4707 uint32_t high_water;
4709 uint16_t pause_time;
4715 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4716 __attribute__((unused)) struct cmdline *cl,
4717 __attribute__((unused)) void *data)
4719 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4720 struct rte_eth_pfc_conf pfc_conf;
4721 int rx_fc_enable, tx_fc_enable;
4725 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4726 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4727 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4728 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4730 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4731 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4734 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4735 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4736 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4737 pfc_conf.fc.high_water = res->high_water;
4738 pfc_conf.fc.low_water = res->low_water;
4739 pfc_conf.fc.pause_time = res->pause_time;
4740 pfc_conf.priority = res->priority;
4742 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4744 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4747 cmdline_parse_token_string_t cmd_pfc_set_set =
4748 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4750 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4751 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4752 pfc_ctrl, "pfc_ctrl");
4753 cmdline_parse_token_string_t cmd_pfc_set_rx =
4754 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4756 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4757 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4758 rx_pfc_mode, "on#off");
4759 cmdline_parse_token_string_t cmd_pfc_set_tx =
4760 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4762 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4763 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4764 tx_pfc_mode, "on#off");
4765 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4766 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4767 high_water, UINT32);
4768 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4769 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4771 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4772 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4773 pause_time, UINT16);
4774 cmdline_parse_token_num_t cmd_pfc_set_priority =
4775 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4777 cmdline_parse_token_num_t cmd_pfc_set_portid =
4778 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4781 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4782 .f = cmd_priority_flow_ctrl_set_parsed,
4784 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4785 tx on|off high_water low_water pause_time priority port_id",
4787 (void *)&cmd_pfc_set_set,
4788 (void *)&cmd_pfc_set_flow_ctrl,
4789 (void *)&cmd_pfc_set_rx,
4790 (void *)&cmd_pfc_set_rx_mode,
4791 (void *)&cmd_pfc_set_tx,
4792 (void *)&cmd_pfc_set_tx_mode,
4793 (void *)&cmd_pfc_set_high_water,
4794 (void *)&cmd_pfc_set_low_water,
4795 (void *)&cmd_pfc_set_pause_time,
4796 (void *)&cmd_pfc_set_priority,
4797 (void *)&cmd_pfc_set_portid,
4802 /* *** RESET CONFIGURATION *** */
4803 struct cmd_reset_result {
4804 cmdline_fixed_string_t reset;
4805 cmdline_fixed_string_t def;
4808 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4810 __attribute__((unused)) void *data)
4812 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4813 set_def_fwd_config();
4816 cmdline_parse_token_string_t cmd_reset_set =
4817 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4818 cmdline_parse_token_string_t cmd_reset_def =
4819 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4822 cmdline_parse_inst_t cmd_reset = {
4823 .f = cmd_reset_parsed,
4825 .help_str = "set default: reset default forwarding configuration",
4827 (void *)&cmd_reset_set,
4828 (void *)&cmd_reset_def,
4833 /* *** START FORWARDING *** */
4834 struct cmd_start_result {
4835 cmdline_fixed_string_t start;
4838 cmdline_parse_token_string_t cmd_start_start =
4839 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4841 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4842 __attribute__((unused)) struct cmdline *cl,
4843 __attribute__((unused)) void *data)
4845 start_packet_forwarding(0);
4848 cmdline_parse_inst_t cmd_start = {
4849 .f = cmd_start_parsed,
4851 .help_str = "start packet forwarding",
4853 (void *)&cmd_start_start,
4858 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4859 struct cmd_start_tx_first_result {
4860 cmdline_fixed_string_t start;
4861 cmdline_fixed_string_t tx_first;
4865 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4866 __attribute__((unused)) struct cmdline *cl,
4867 __attribute__((unused)) void *data)
4869 start_packet_forwarding(1);
4872 cmdline_parse_token_string_t cmd_start_tx_first_start =
4873 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4875 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4876 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4877 tx_first, "tx_first");
4879 cmdline_parse_inst_t cmd_start_tx_first = {
4880 .f = cmd_start_tx_first_parsed,
4882 .help_str = "start packet forwarding, after sending 1 burst of packets",
4884 (void *)&cmd_start_tx_first_start,
4885 (void *)&cmd_start_tx_first_tx_first,
4890 /* *** SET LINK UP *** */
4891 struct cmd_set_link_up_result {
4892 cmdline_fixed_string_t set;
4893 cmdline_fixed_string_t link_up;
4894 cmdline_fixed_string_t port;
4898 cmdline_parse_token_string_t cmd_set_link_up_set =
4899 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4900 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4901 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4903 cmdline_parse_token_string_t cmd_set_link_up_port =
4904 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4905 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4906 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4908 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4909 __attribute__((unused)) struct cmdline *cl,
4910 __attribute__((unused)) void *data)
4912 struct cmd_set_link_up_result *res = parsed_result;
4913 dev_set_link_up(res->port_id);
4916 cmdline_parse_inst_t cmd_set_link_up = {
4917 .f = cmd_set_link_up_parsed,
4919 .help_str = "set link-up port (port id)",
4921 (void *)&cmd_set_link_up_set,
4922 (void *)&cmd_set_link_up_link_up,
4923 (void *)&cmd_set_link_up_port,
4924 (void *)&cmd_set_link_up_port_id,
4929 /* *** SET LINK DOWN *** */
4930 struct cmd_set_link_down_result {
4931 cmdline_fixed_string_t set;
4932 cmdline_fixed_string_t link_down;
4933 cmdline_fixed_string_t port;
4937 cmdline_parse_token_string_t cmd_set_link_down_set =
4938 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4939 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4940 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4942 cmdline_parse_token_string_t cmd_set_link_down_port =
4943 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4944 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4945 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4947 static void cmd_set_link_down_parsed(
4948 __attribute__((unused)) void *parsed_result,
4949 __attribute__((unused)) struct cmdline *cl,
4950 __attribute__((unused)) void *data)
4952 struct cmd_set_link_down_result *res = parsed_result;
4953 dev_set_link_down(res->port_id);
4956 cmdline_parse_inst_t cmd_set_link_down = {
4957 .f = cmd_set_link_down_parsed,
4959 .help_str = "set link-down port (port id)",
4961 (void *)&cmd_set_link_down_set,
4962 (void *)&cmd_set_link_down_link_down,
4963 (void *)&cmd_set_link_down_port,
4964 (void *)&cmd_set_link_down_port_id,
4969 /* *** SHOW CFG *** */
4970 struct cmd_showcfg_result {
4971 cmdline_fixed_string_t show;
4972 cmdline_fixed_string_t cfg;
4973 cmdline_fixed_string_t what;
4976 static void cmd_showcfg_parsed(void *parsed_result,
4977 __attribute__((unused)) struct cmdline *cl,
4978 __attribute__((unused)) void *data)
4980 struct cmd_showcfg_result *res = parsed_result;
4981 if (!strcmp(res->what, "rxtx"))
4982 rxtx_config_display();
4983 else if (!strcmp(res->what, "cores"))
4984 fwd_lcores_config_display();
4985 else if (!strcmp(res->what, "fwd"))
4986 fwd_config_display();
4989 cmdline_parse_token_string_t cmd_showcfg_show =
4990 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4991 cmdline_parse_token_string_t cmd_showcfg_port =
4992 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4993 cmdline_parse_token_string_t cmd_showcfg_what =
4994 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4997 cmdline_parse_inst_t cmd_showcfg = {
4998 .f = cmd_showcfg_parsed,
5000 .help_str = "show config rxtx|cores|fwd",
5002 (void *)&cmd_showcfg_show,
5003 (void *)&cmd_showcfg_port,
5004 (void *)&cmd_showcfg_what,
5009 /* *** SHOW ALL PORT INFO *** */
5010 struct cmd_showportall_result {
5011 cmdline_fixed_string_t show;
5012 cmdline_fixed_string_t port;
5013 cmdline_fixed_string_t what;
5014 cmdline_fixed_string_t all;
5017 static void cmd_showportall_parsed(void *parsed_result,
5018 __attribute__((unused)) struct cmdline *cl,
5019 __attribute__((unused)) void *data)
5023 struct cmd_showportall_result *res = parsed_result;
5024 if (!strcmp(res->show, "clear")) {
5025 if (!strcmp(res->what, "stats"))
5026 for (i = 0; i < nb_ports; i++)
5028 else if (!strcmp(res->what, "xstats"))
5029 for (i = 0; i < nb_ports; i++)
5030 nic_xstats_clear(i);
5031 } else if (!strcmp(res->what, "info"))
5032 for (i = 0; i < nb_ports; i++)
5033 port_infos_display(i);
5034 else if (!strcmp(res->what, "stats"))
5035 for (i = 0; i < nb_ports; i++)
5036 nic_stats_display(i);
5037 else if (!strcmp(res->what, "xstats"))
5038 for (i = 0; i < nb_ports; i++)
5039 nic_xstats_display(i);
5040 else if (!strcmp(res->what, "fdir"))
5041 for (i = 0; i < nb_ports; i++)
5043 else if (!strcmp(res->what, "stat_qmap"))
5044 for (i = 0; i < nb_ports; i++)
5045 nic_stats_mapping_display(i);
5048 cmdline_parse_token_string_t cmd_showportall_show =
5049 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5051 cmdline_parse_token_string_t cmd_showportall_port =
5052 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5053 cmdline_parse_token_string_t cmd_showportall_what =
5054 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5055 "info#stats#xstats#fdir#stat_qmap");
5056 cmdline_parse_token_string_t cmd_showportall_all =
5057 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5058 cmdline_parse_inst_t cmd_showportall = {
5059 .f = cmd_showportall_parsed,
5061 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5063 (void *)&cmd_showportall_show,
5064 (void *)&cmd_showportall_port,
5065 (void *)&cmd_showportall_what,
5066 (void *)&cmd_showportall_all,
5071 /* *** SHOW PORT INFO *** */
5072 struct cmd_showport_result {
5073 cmdline_fixed_string_t show;
5074 cmdline_fixed_string_t port;
5075 cmdline_fixed_string_t what;
5079 static void cmd_showport_parsed(void *parsed_result,
5080 __attribute__((unused)) struct cmdline *cl,
5081 __attribute__((unused)) void *data)
5083 struct cmd_showport_result *res = parsed_result;
5084 if (!strcmp(res->show, "clear")) {
5085 if (!strcmp(res->what, "stats"))
5086 nic_stats_clear(res->portnum);
5087 else if (!strcmp(res->what, "xstats"))
5088 nic_xstats_clear(res->portnum);
5089 } else if (!strcmp(res->what, "info"))
5090 port_infos_display(res->portnum);
5091 else if (!strcmp(res->what, "stats"))
5092 nic_stats_display(res->portnum);
5093 else if (!strcmp(res->what, "xstats"))
5094 nic_xstats_display(res->portnum);
5095 else if (!strcmp(res->what, "fdir"))
5096 fdir_get_infos(res->portnum);
5097 else if (!strcmp(res->what, "stat_qmap"))
5098 nic_stats_mapping_display(res->portnum);
5101 cmdline_parse_token_string_t cmd_showport_show =
5102 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5104 cmdline_parse_token_string_t cmd_showport_port =
5105 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5106 cmdline_parse_token_string_t cmd_showport_what =
5107 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5108 "info#stats#xstats#fdir#stat_qmap");
5109 cmdline_parse_token_num_t cmd_showport_portnum =
5110 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5112 cmdline_parse_inst_t cmd_showport = {
5113 .f = cmd_showport_parsed,
5115 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5117 (void *)&cmd_showport_show,
5118 (void *)&cmd_showport_port,
5119 (void *)&cmd_showport_what,
5120 (void *)&cmd_showport_portnum,
5125 /* *** READ PORT REGISTER *** */
5126 struct cmd_read_reg_result {
5127 cmdline_fixed_string_t read;
5128 cmdline_fixed_string_t reg;
5134 cmd_read_reg_parsed(void *parsed_result,
5135 __attribute__((unused)) struct cmdline *cl,
5136 __attribute__((unused)) void *data)
5138 struct cmd_read_reg_result *res = parsed_result;
5139 port_reg_display(res->port_id, res->reg_off);
5142 cmdline_parse_token_string_t cmd_read_reg_read =
5143 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5144 cmdline_parse_token_string_t cmd_read_reg_reg =
5145 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5146 cmdline_parse_token_num_t cmd_read_reg_port_id =
5147 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5148 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5149 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5151 cmdline_parse_inst_t cmd_read_reg = {
5152 .f = cmd_read_reg_parsed,
5154 .help_str = "read reg port_id reg_off",
5156 (void *)&cmd_read_reg_read,
5157 (void *)&cmd_read_reg_reg,
5158 (void *)&cmd_read_reg_port_id,
5159 (void *)&cmd_read_reg_reg_off,
5164 /* *** READ PORT REGISTER BIT FIELD *** */
5165 struct cmd_read_reg_bit_field_result {
5166 cmdline_fixed_string_t read;
5167 cmdline_fixed_string_t regfield;
5175 cmd_read_reg_bit_field_parsed(void *parsed_result,
5176 __attribute__((unused)) struct cmdline *cl,
5177 __attribute__((unused)) void *data)
5179 struct cmd_read_reg_bit_field_result *res = parsed_result;
5180 port_reg_bit_field_display(res->port_id, res->reg_off,
5181 res->bit1_pos, res->bit2_pos);
5184 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5185 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5187 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5188 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5189 regfield, "regfield");
5190 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5191 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5193 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5194 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5196 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5197 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5199 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5200 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5203 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5204 .f = cmd_read_reg_bit_field_parsed,
5206 .help_str = "read regfield port_id reg_off bit_x bit_y "
5207 "(read register bit field between bit_x and bit_y included)",
5209 (void *)&cmd_read_reg_bit_field_read,
5210 (void *)&cmd_read_reg_bit_field_regfield,
5211 (void *)&cmd_read_reg_bit_field_port_id,
5212 (void *)&cmd_read_reg_bit_field_reg_off,
5213 (void *)&cmd_read_reg_bit_field_bit1_pos,
5214 (void *)&cmd_read_reg_bit_field_bit2_pos,
5219 /* *** READ PORT REGISTER BIT *** */
5220 struct cmd_read_reg_bit_result {
5221 cmdline_fixed_string_t read;
5222 cmdline_fixed_string_t regbit;
5229 cmd_read_reg_bit_parsed(void *parsed_result,
5230 __attribute__((unused)) struct cmdline *cl,
5231 __attribute__((unused)) void *data)
5233 struct cmd_read_reg_bit_result *res = parsed_result;
5234 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5237 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5238 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5239 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5240 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5242 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5243 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5244 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5245 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5246 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5247 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5249 cmdline_parse_inst_t cmd_read_reg_bit = {
5250 .f = cmd_read_reg_bit_parsed,
5252 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5254 (void *)&cmd_read_reg_bit_read,
5255 (void *)&cmd_read_reg_bit_regbit,
5256 (void *)&cmd_read_reg_bit_port_id,
5257 (void *)&cmd_read_reg_bit_reg_off,
5258 (void *)&cmd_read_reg_bit_bit_pos,
5263 /* *** WRITE PORT REGISTER *** */
5264 struct cmd_write_reg_result {
5265 cmdline_fixed_string_t write;
5266 cmdline_fixed_string_t reg;
5273 cmd_write_reg_parsed(void *parsed_result,
5274 __attribute__((unused)) struct cmdline *cl,
5275 __attribute__((unused)) void *data)
5277 struct cmd_write_reg_result *res = parsed_result;
5278 port_reg_set(res->port_id, res->reg_off, res->value);
5281 cmdline_parse_token_string_t cmd_write_reg_write =
5282 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5283 cmdline_parse_token_string_t cmd_write_reg_reg =
5284 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5285 cmdline_parse_token_num_t cmd_write_reg_port_id =
5286 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5287 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5288 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5289 cmdline_parse_token_num_t cmd_write_reg_value =
5290 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5292 cmdline_parse_inst_t cmd_write_reg = {
5293 .f = cmd_write_reg_parsed,
5295 .help_str = "write reg port_id reg_off reg_value",
5297 (void *)&cmd_write_reg_write,
5298 (void *)&cmd_write_reg_reg,
5299 (void *)&cmd_write_reg_port_id,
5300 (void *)&cmd_write_reg_reg_off,
5301 (void *)&cmd_write_reg_value,
5306 /* *** WRITE PORT REGISTER BIT FIELD *** */
5307 struct cmd_write_reg_bit_field_result {
5308 cmdline_fixed_string_t write;
5309 cmdline_fixed_string_t regfield;
5318 cmd_write_reg_bit_field_parsed(void *parsed_result,
5319 __attribute__((unused)) struct cmdline *cl,
5320 __attribute__((unused)) void *data)
5322 struct cmd_write_reg_bit_field_result *res = parsed_result;
5323 port_reg_bit_field_set(res->port_id, res->reg_off,
5324 res->bit1_pos, res->bit2_pos, res->value);
5327 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5328 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5330 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5331 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5332 regfield, "regfield");
5333 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5334 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5336 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5337 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5339 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5340 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5342 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5343 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5345 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5346 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5349 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5350 .f = cmd_write_reg_bit_field_parsed,
5352 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5353 "(set register bit field between bit_x and bit_y included)",
5355 (void *)&cmd_write_reg_bit_field_write,
5356 (void *)&cmd_write_reg_bit_field_regfield,
5357 (void *)&cmd_write_reg_bit_field_port_id,
5358 (void *)&cmd_write_reg_bit_field_reg_off,
5359 (void *)&cmd_write_reg_bit_field_bit1_pos,
5360 (void *)&cmd_write_reg_bit_field_bit2_pos,
5361 (void *)&cmd_write_reg_bit_field_value,
5366 /* *** WRITE PORT REGISTER BIT *** */
5367 struct cmd_write_reg_bit_result {
5368 cmdline_fixed_string_t write;
5369 cmdline_fixed_string_t regbit;
5377 cmd_write_reg_bit_parsed(void *parsed_result,
5378 __attribute__((unused)) struct cmdline *cl,
5379 __attribute__((unused)) void *data)
5381 struct cmd_write_reg_bit_result *res = parsed_result;
5382 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5385 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5386 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5388 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5389 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5391 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5392 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5393 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5394 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5395 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5396 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5397 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5398 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5400 cmdline_parse_inst_t cmd_write_reg_bit = {
5401 .f = cmd_write_reg_bit_parsed,
5403 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5405 (void *)&cmd_write_reg_bit_write,
5406 (void *)&cmd_write_reg_bit_regbit,
5407 (void *)&cmd_write_reg_bit_port_id,
5408 (void *)&cmd_write_reg_bit_reg_off,
5409 (void *)&cmd_write_reg_bit_bit_pos,
5410 (void *)&cmd_write_reg_bit_value,
5415 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5416 struct cmd_read_rxd_txd_result {
5417 cmdline_fixed_string_t read;
5418 cmdline_fixed_string_t rxd_txd;
5425 cmd_read_rxd_txd_parsed(void *parsed_result,
5426 __attribute__((unused)) struct cmdline *cl,
5427 __attribute__((unused)) void *data)
5429 struct cmd_read_rxd_txd_result *res = parsed_result;
5431 if (!strcmp(res->rxd_txd, "rxd"))
5432 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5433 else if (!strcmp(res->rxd_txd, "txd"))
5434 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5437 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5438 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5439 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5440 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5442 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5443 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5444 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5445 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5446 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5447 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5449 cmdline_parse_inst_t cmd_read_rxd_txd = {
5450 .f = cmd_read_rxd_txd_parsed,
5452 .help_str = "read rxd|txd port_id queue_id rxd_id",
5454 (void *)&cmd_read_rxd_txd_read,
5455 (void *)&cmd_read_rxd_txd_rxd_txd,
5456 (void *)&cmd_read_rxd_txd_port_id,
5457 (void *)&cmd_read_rxd_txd_queue_id,
5458 (void *)&cmd_read_rxd_txd_desc_id,
5464 struct cmd_quit_result {
5465 cmdline_fixed_string_t quit;
5468 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5470 __attribute__((unused)) void *data)
5476 cmdline_parse_token_string_t cmd_quit_quit =
5477 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5479 cmdline_parse_inst_t cmd_quit = {
5480 .f = cmd_quit_parsed,
5482 .help_str = "exit application",
5484 (void *)&cmd_quit_quit,
5489 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5490 struct cmd_mac_addr_result {
5491 cmdline_fixed_string_t mac_addr_cmd;
5492 cmdline_fixed_string_t what;
5494 struct ether_addr address;
5497 static void cmd_mac_addr_parsed(void *parsed_result,
5498 __attribute__((unused)) struct cmdline *cl,
5499 __attribute__((unused)) void *data)
5501 struct cmd_mac_addr_result *res = parsed_result;
5504 if (strcmp(res->what, "add") == 0)
5505 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5507 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5509 /* check the return value and print it if is < 0 */
5511 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5515 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5516 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5518 cmdline_parse_token_string_t cmd_mac_addr_what =
5519 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5521 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5522 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5523 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5524 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5526 cmdline_parse_inst_t cmd_mac_addr = {
5527 .f = cmd_mac_addr_parsed,
5529 .help_str = "mac_addr add|remove X <address>: "
5530 "add/remove MAC address on port X",
5532 (void *)&cmd_mac_addr_cmd,
5533 (void *)&cmd_mac_addr_what,
5534 (void *)&cmd_mac_addr_portnum,
5535 (void *)&cmd_mac_addr_addr,
5541 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5542 struct cmd_set_qmap_result {
5543 cmdline_fixed_string_t set;
5544 cmdline_fixed_string_t qmap;
5545 cmdline_fixed_string_t what;
5552 cmd_set_qmap_parsed(void *parsed_result,
5553 __attribute__((unused)) struct cmdline *cl,
5554 __attribute__((unused)) void *data)
5556 struct cmd_set_qmap_result *res = parsed_result;
5557 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5559 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5562 cmdline_parse_token_string_t cmd_setqmap_set =
5563 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5565 cmdline_parse_token_string_t cmd_setqmap_qmap =
5566 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5568 cmdline_parse_token_string_t cmd_setqmap_what =
5569 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5571 cmdline_parse_token_num_t cmd_setqmap_portid =
5572 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5574 cmdline_parse_token_num_t cmd_setqmap_queueid =
5575 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5577 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5578 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5581 cmdline_parse_inst_t cmd_set_qmap = {
5582 .f = cmd_set_qmap_parsed,
5584 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5586 (void *)&cmd_setqmap_set,
5587 (void *)&cmd_setqmap_qmap,
5588 (void *)&cmd_setqmap_what,
5589 (void *)&cmd_setqmap_portid,
5590 (void *)&cmd_setqmap_queueid,
5591 (void *)&cmd_setqmap_mapvalue,
5596 /* *** CONFIGURE UNICAST HASH TABLE *** */
5597 struct cmd_set_uc_hash_table {
5598 cmdline_fixed_string_t set;
5599 cmdline_fixed_string_t port;
5601 cmdline_fixed_string_t what;
5602 struct ether_addr address;
5603 cmdline_fixed_string_t mode;
5607 cmd_set_uc_hash_parsed(void *parsed_result,
5608 __attribute__((unused)) struct cmdline *cl,
5609 __attribute__((unused)) void *data)
5612 struct cmd_set_uc_hash_table *res = parsed_result;
5614 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5616 if (strcmp(res->what, "uta") == 0)
5617 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5618 &res->address,(uint8_t)is_on);
5620 printf("bad unicast hash table parameter, return code = %d \n", ret);
5624 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5625 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5627 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5628 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5630 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5631 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5633 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5634 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5636 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5637 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5639 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5640 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5643 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5644 .f = cmd_set_uc_hash_parsed,
5646 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5648 (void *)&cmd_set_uc_hash_set,
5649 (void *)&cmd_set_uc_hash_port,
5650 (void *)&cmd_set_uc_hash_portid,
5651 (void *)&cmd_set_uc_hash_what,
5652 (void *)&cmd_set_uc_hash_mac,
5653 (void *)&cmd_set_uc_hash_mode,
5658 struct cmd_set_uc_all_hash_table {
5659 cmdline_fixed_string_t set;
5660 cmdline_fixed_string_t port;
5662 cmdline_fixed_string_t what;
5663 cmdline_fixed_string_t value;
5664 cmdline_fixed_string_t mode;
5668 cmd_set_uc_all_hash_parsed(void *parsed_result,
5669 __attribute__((unused)) struct cmdline *cl,
5670 __attribute__((unused)) void *data)
5673 struct cmd_set_uc_all_hash_table *res = parsed_result;
5675 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5677 if ((strcmp(res->what, "uta") == 0) &&
5678 (strcmp(res->value, "all") == 0))
5679 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5681 printf("bad unicast hash table parameter,"
5682 "return code = %d \n", ret);
5685 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5686 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5688 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5689 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5691 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5692 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5694 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5695 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5697 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5698 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5700 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5701 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5704 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5705 .f = cmd_set_uc_all_hash_parsed,
5707 .help_str = "set port X uta all on|off (X = port number)",
5709 (void *)&cmd_set_uc_all_hash_set,
5710 (void *)&cmd_set_uc_all_hash_port,
5711 (void *)&cmd_set_uc_all_hash_portid,
5712 (void *)&cmd_set_uc_all_hash_what,
5713 (void *)&cmd_set_uc_all_hash_value,
5714 (void *)&cmd_set_uc_all_hash_mode,
5719 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5720 struct cmd_set_vf_macvlan_filter {
5721 cmdline_fixed_string_t set;
5722 cmdline_fixed_string_t port;
5724 cmdline_fixed_string_t vf;
5726 struct ether_addr address;
5727 cmdline_fixed_string_t filter_type;
5728 cmdline_fixed_string_t mode;
5732 cmd_set_vf_macvlan_parsed(void *parsed_result,
5733 __attribute__((unused)) struct cmdline *cl,
5734 __attribute__((unused)) void *data)
5737 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5738 struct rte_eth_mac_filter filter;
5740 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5742 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5744 /* set VF MAC filter */
5748 filter.dst_id = res->vf_id;
5750 if (!strcmp(res->filter_type, "exact-mac"))
5751 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5752 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5753 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5754 else if (!strcmp(res->filter_type, "hashmac"))
5755 filter.filter_type = RTE_MAC_HASH_MATCH;
5756 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5757 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5759 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5762 ret = rte_eth_dev_filter_ctrl(res->port_id,
5763 RTE_ETH_FILTER_MACVLAN,
5767 ret = rte_eth_dev_filter_ctrl(res->port_id,
5768 RTE_ETH_FILTER_MACVLAN,
5769 RTE_ETH_FILTER_DELETE,
5773 printf("bad set MAC hash parameter, return code = %d\n", ret);
5777 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5778 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5780 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5781 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5783 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5784 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5786 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5787 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5789 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5790 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5792 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5793 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5795 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5796 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5797 filter_type, "exact-mac#exact-mac-vlan"
5798 "#hashmac#hashmac-vlan");
5799 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5800 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5803 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5804 .f = cmd_set_vf_macvlan_parsed,
5806 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5807 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5809 "exact match rule:exact match of MAC or MAC and VLAN; "
5810 "hash match rule: hash match of MAC and exact match "
5813 (void *)&cmd_set_vf_macvlan_set,
5814 (void *)&cmd_set_vf_macvlan_port,
5815 (void *)&cmd_set_vf_macvlan_portid,
5816 (void *)&cmd_set_vf_macvlan_vf,
5817 (void *)&cmd_set_vf_macvlan_vf_id,
5818 (void *)&cmd_set_vf_macvlan_mac,
5819 (void *)&cmd_set_vf_macvlan_filter_type,
5820 (void *)&cmd_set_vf_macvlan_mode,
5825 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5826 struct cmd_set_vf_traffic {
5827 cmdline_fixed_string_t set;
5828 cmdline_fixed_string_t port;
5830 cmdline_fixed_string_t vf;
5832 cmdline_fixed_string_t what;
5833 cmdline_fixed_string_t mode;
5837 cmd_set_vf_traffic_parsed(void *parsed_result,
5838 __attribute__((unused)) struct cmdline *cl,
5839 __attribute__((unused)) void *data)
5841 struct cmd_set_vf_traffic *res = parsed_result;
5842 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5843 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5845 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5848 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5849 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5851 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5852 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5854 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5855 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5857 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5858 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5860 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5861 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5863 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5864 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5866 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5867 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5870 cmdline_parse_inst_t cmd_set_vf_traffic = {
5871 .f = cmd_set_vf_traffic_parsed,
5873 .help_str = "set port X vf Y rx|tx on|off"
5874 "(X = port number,Y = vf id)",
5876 (void *)&cmd_setvf_traffic_set,
5877 (void *)&cmd_setvf_traffic_port,
5878 (void *)&cmd_setvf_traffic_portid,
5879 (void *)&cmd_setvf_traffic_vf,
5880 (void *)&cmd_setvf_traffic_vfid,
5881 (void *)&cmd_setvf_traffic_what,
5882 (void *)&cmd_setvf_traffic_mode,
5887 /* *** CONFIGURE VF RECEIVE MODE *** */
5888 struct cmd_set_vf_rxmode {
5889 cmdline_fixed_string_t set;
5890 cmdline_fixed_string_t port;
5892 cmdline_fixed_string_t vf;
5894 cmdline_fixed_string_t what;
5895 cmdline_fixed_string_t mode;
5896 cmdline_fixed_string_t on;
5900 cmd_set_vf_rxmode_parsed(void *parsed_result,
5901 __attribute__((unused)) struct cmdline *cl,
5902 __attribute__((unused)) void *data)
5905 uint16_t rx_mode = 0;
5906 struct cmd_set_vf_rxmode *res = parsed_result;
5908 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5909 if (!strcmp(res->what,"rxmode")) {
5910 if (!strcmp(res->mode, "AUPE"))
5911 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5912 else if (!strcmp(res->mode, "ROPE"))
5913 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5914 else if (!strcmp(res->mode, "BAM"))
5915 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5916 else if (!strncmp(res->mode, "MPE",3))
5917 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5920 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5922 printf("bad VF receive mode parameter, return code = %d \n",
5926 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5929 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5930 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5932 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5933 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5935 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5936 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5938 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5939 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5941 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5942 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5944 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5945 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5946 mode, "AUPE#ROPE#BAM#MPE");
5947 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5948 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5951 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5952 .f = cmd_set_vf_rxmode_parsed,
5954 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5956 (void *)&cmd_set_vf_rxmode_set,
5957 (void *)&cmd_set_vf_rxmode_port,
5958 (void *)&cmd_set_vf_rxmode_portid,
5959 (void *)&cmd_set_vf_rxmode_vf,
5960 (void *)&cmd_set_vf_rxmode_vfid,
5961 (void *)&cmd_set_vf_rxmode_what,
5962 (void *)&cmd_set_vf_rxmode_mode,
5963 (void *)&cmd_set_vf_rxmode_on,
5968 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5969 struct cmd_vf_mac_addr_result {
5970 cmdline_fixed_string_t mac_addr_cmd;
5971 cmdline_fixed_string_t what;
5972 cmdline_fixed_string_t port;
5974 cmdline_fixed_string_t vf;
5976 struct ether_addr address;
5979 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5980 __attribute__((unused)) struct cmdline *cl,
5981 __attribute__((unused)) void *data)
5983 struct cmd_vf_mac_addr_result *res = parsed_result;
5986 if (strcmp(res->what, "add") == 0)
5987 ret = rte_eth_dev_mac_addr_add(res->port_num,
5988 &res->address, res->vf_num);
5990 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5994 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5995 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5996 mac_addr_cmd,"mac_addr");
5997 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5998 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6000 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6001 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6003 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6004 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6006 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6007 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6009 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6010 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6012 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6013 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6016 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6017 .f = cmd_vf_mac_addr_parsed,
6019 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6020 "Y = VF number)add MAC address filtering for a VF on port X",
6022 (void *)&cmd_vf_mac_addr_cmd,
6023 (void *)&cmd_vf_mac_addr_what,
6024 (void *)&cmd_vf_mac_addr_port,
6025 (void *)&cmd_vf_mac_addr_portnum,
6026 (void *)&cmd_vf_mac_addr_vf,
6027 (void *)&cmd_vf_mac_addr_vfnum,
6028 (void *)&cmd_vf_mac_addr_addr,
6033 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6034 struct cmd_vf_rx_vlan_filter {
6035 cmdline_fixed_string_t rx_vlan;
6036 cmdline_fixed_string_t what;
6038 cmdline_fixed_string_t port;
6040 cmdline_fixed_string_t vf;
6045 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6046 __attribute__((unused)) struct cmdline *cl,
6047 __attribute__((unused)) void *data)
6049 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6051 if (!strcmp(res->what, "add"))
6052 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6054 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6057 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6058 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6059 rx_vlan, "rx_vlan");
6060 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6061 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6063 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6064 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6066 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6067 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6069 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6070 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6072 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6073 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6075 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6076 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6079 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6080 .f = cmd_vf_rx_vlan_filter_parsed,
6082 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6083 "Y = port number,Z = hexadecimal VF mask)",
6085 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6086 (void *)&cmd_vf_rx_vlan_filter_what,
6087 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6088 (void *)&cmd_vf_rx_vlan_filter_port,
6089 (void *)&cmd_vf_rx_vlan_filter_portid,
6090 (void *)&cmd_vf_rx_vlan_filter_vf,
6091 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6096 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6097 struct cmd_queue_rate_limit_result {
6098 cmdline_fixed_string_t set;
6099 cmdline_fixed_string_t port;
6101 cmdline_fixed_string_t queue;
6103 cmdline_fixed_string_t rate;
6107 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6108 __attribute__((unused)) struct cmdline *cl,
6109 __attribute__((unused)) void *data)
6111 struct cmd_queue_rate_limit_result *res = parsed_result;
6114 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6115 && (strcmp(res->queue, "queue") == 0)
6116 && (strcmp(res->rate, "rate") == 0))
6117 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6120 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6124 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6125 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6127 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6128 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6130 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6131 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6133 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6134 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6136 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6137 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6139 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6140 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6142 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6143 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6146 cmdline_parse_inst_t cmd_queue_rate_limit = {
6147 .f = cmd_queue_rate_limit_parsed,
6149 .help_str = "set port X queue Y rate Z:(X = port number,"
6150 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6152 (void *)&cmd_queue_rate_limit_set,
6153 (void *)&cmd_queue_rate_limit_port,
6154 (void *)&cmd_queue_rate_limit_portnum,
6155 (void *)&cmd_queue_rate_limit_queue,
6156 (void *)&cmd_queue_rate_limit_queuenum,
6157 (void *)&cmd_queue_rate_limit_rate,
6158 (void *)&cmd_queue_rate_limit_ratenum,
6163 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6164 struct cmd_vf_rate_limit_result {
6165 cmdline_fixed_string_t set;
6166 cmdline_fixed_string_t port;
6168 cmdline_fixed_string_t vf;
6170 cmdline_fixed_string_t rate;
6172 cmdline_fixed_string_t q_msk;
6176 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6177 __attribute__((unused)) struct cmdline *cl,
6178 __attribute__((unused)) void *data)
6180 struct cmd_vf_rate_limit_result *res = parsed_result;
6183 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6184 && (strcmp(res->vf, "vf") == 0)
6185 && (strcmp(res->rate, "rate") == 0)
6186 && (strcmp(res->q_msk, "queue_mask") == 0))
6187 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6188 res->rate_num, res->q_msk_val);
6190 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6194 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6195 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6197 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6198 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6200 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6201 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6203 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6204 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6206 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6207 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6209 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6210 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6212 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6213 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6215 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6216 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6217 q_msk, "queue_mask");
6218 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6219 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6222 cmdline_parse_inst_t cmd_vf_rate_limit = {
6223 .f = cmd_vf_rate_limit_parsed,
6225 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6226 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6227 "for queues of VF on port X",
6229 (void *)&cmd_vf_rate_limit_set,
6230 (void *)&cmd_vf_rate_limit_port,
6231 (void *)&cmd_vf_rate_limit_portnum,
6232 (void *)&cmd_vf_rate_limit_vf,
6233 (void *)&cmd_vf_rate_limit_vfnum,
6234 (void *)&cmd_vf_rate_limit_rate,
6235 (void *)&cmd_vf_rate_limit_ratenum,
6236 (void *)&cmd_vf_rate_limit_q_msk,
6237 (void *)&cmd_vf_rate_limit_q_msk_val,
6242 /* *** ADD TUNNEL FILTER OF A PORT *** */
6243 struct cmd_tunnel_filter_result {
6244 cmdline_fixed_string_t cmd;
6245 cmdline_fixed_string_t what;
6247 struct ether_addr outer_mac;
6248 struct ether_addr inner_mac;
6249 cmdline_ipaddr_t ip_value;
6250 uint16_t inner_vlan;
6251 cmdline_fixed_string_t tunnel_type;
6252 cmdline_fixed_string_t filter_type;
6258 cmd_tunnel_filter_parsed(void *parsed_result,
6259 __attribute__((unused)) struct cmdline *cl,
6260 __attribute__((unused)) void *data)
6262 struct cmd_tunnel_filter_result *res = parsed_result;
6263 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6266 tunnel_filter_conf.outer_mac = &res->outer_mac;
6267 tunnel_filter_conf.inner_mac = &res->inner_mac;
6268 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6270 if (res->ip_value.family == AF_INET) {
6271 tunnel_filter_conf.ip_addr.ipv4_addr =
6272 res->ip_value.addr.ipv4.s_addr;
6273 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6275 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6276 &(res->ip_value.addr.ipv6),
6277 sizeof(struct in6_addr));
6278 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6281 if (!strcmp(res->filter_type, "imac-ivlan"))
6282 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6283 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6284 tunnel_filter_conf.filter_type =
6285 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6286 else if (!strcmp(res->filter_type, "imac-tenid"))
6287 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6288 else if (!strcmp(res->filter_type, "imac"))
6289 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6290 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6291 tunnel_filter_conf.filter_type =
6292 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6294 printf("The filter type is not supported");
6298 if (!strcmp(res->tunnel_type, "vxlan"))
6299 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6301 printf("Only VXLAN is supported now.\n");
6305 tunnel_filter_conf.tenant_id = res->tenant_id;
6306 tunnel_filter_conf.queue_id = res->queue_num;
6307 if (!strcmp(res->what, "add"))
6308 ret = rte_eth_dev_filter_ctrl(res->port_id,
6309 RTE_ETH_FILTER_TUNNEL,
6311 &tunnel_filter_conf);
6313 ret = rte_eth_dev_filter_ctrl(res->port_id,
6314 RTE_ETH_FILTER_TUNNEL,
6315 RTE_ETH_FILTER_DELETE,
6316 &tunnel_filter_conf);
6318 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6322 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6323 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6324 cmd, "tunnel_filter");
6325 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6326 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6328 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6329 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6331 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6332 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6334 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6335 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6337 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6338 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6339 inner_vlan, UINT16);
6340 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6341 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6343 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6344 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6345 tunnel_type, "vxlan");
6347 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6348 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6349 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6350 "imac#omac-imac-tenid");
6351 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6352 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6354 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6355 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6358 cmdline_parse_inst_t cmd_tunnel_filter = {
6359 .f = cmd_tunnel_filter_parsed,
6361 .help_str = "add/rm tunnel filter of a port: "
6362 "tunnel_filter add port_id outer_mac inner_mac ip "
6363 "inner_vlan tunnel_type(vxlan) filter_type "
6364 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6365 "imac|omac-imac-tenid) "
6366 "tenant_id queue_num",
6368 (void *)&cmd_tunnel_filter_cmd,
6369 (void *)&cmd_tunnel_filter_what,
6370 (void *)&cmd_tunnel_filter_port_id,
6371 (void *)&cmd_tunnel_filter_outer_mac,
6372 (void *)&cmd_tunnel_filter_inner_mac,
6373 (void *)&cmd_tunnel_filter_ip_value,
6374 (void *)&cmd_tunnel_filter_innner_vlan,
6375 (void *)&cmd_tunnel_filter_tunnel_type,
6376 (void *)&cmd_tunnel_filter_filter_type,
6377 (void *)&cmd_tunnel_filter_tenant_id,
6378 (void *)&cmd_tunnel_filter_queue_num,
6383 /* *** CONFIGURE TUNNEL UDP PORT *** */
6384 struct cmd_tunnel_udp_config {
6385 cmdline_fixed_string_t cmd;
6386 cmdline_fixed_string_t what;
6392 cmd_tunnel_udp_config_parsed(void *parsed_result,
6393 __attribute__((unused)) struct cmdline *cl,
6394 __attribute__((unused)) void *data)
6396 struct cmd_tunnel_udp_config *res = parsed_result;
6397 struct rte_eth_udp_tunnel tunnel_udp;
6400 tunnel_udp.udp_port = res->udp_port;
6402 if (!strcmp(res->cmd, "rx_vxlan_port"))
6403 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6405 if (!strcmp(res->what, "add"))
6406 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6408 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6411 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6414 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6415 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6416 cmd, "rx_vxlan_port");
6417 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6418 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6420 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6421 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6423 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6424 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6427 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6428 .f = cmd_tunnel_udp_config_parsed,
6430 .help_str = "add/rm an tunneling UDP port filter: "
6431 "rx_vxlan_port add udp_port port_id",
6433 (void *)&cmd_tunnel_udp_config_cmd,
6434 (void *)&cmd_tunnel_udp_config_what,
6435 (void *)&cmd_tunnel_udp_config_udp_port,
6436 (void *)&cmd_tunnel_udp_config_port_id,
6441 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6442 struct cmd_set_mirror_mask_result {
6443 cmdline_fixed_string_t set;
6444 cmdline_fixed_string_t port;
6446 cmdline_fixed_string_t mirror;
6448 cmdline_fixed_string_t what;
6449 cmdline_fixed_string_t value;
6450 cmdline_fixed_string_t dstpool;
6452 cmdline_fixed_string_t on;
6455 cmdline_parse_token_string_t cmd_mirror_mask_set =
6456 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6458 cmdline_parse_token_string_t cmd_mirror_mask_port =
6459 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6461 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6462 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6464 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6465 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6466 mirror, "mirror-rule");
6467 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6468 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6470 cmdline_parse_token_string_t cmd_mirror_mask_what =
6471 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6472 what, "pool-mirror#vlan-mirror");
6473 cmdline_parse_token_string_t cmd_mirror_mask_value =
6474 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6476 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6478 dstpool, "dst-pool");
6479 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6480 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6482 cmdline_parse_token_string_t cmd_mirror_mask_on =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6487 cmd_set_mirror_mask_parsed(void *parsed_result,
6488 __attribute__((unused)) struct cmdline *cl,
6489 __attribute__((unused)) void *data)
6492 struct cmd_set_mirror_mask_result *res = parsed_result;
6493 struct rte_eth_vmdq_mirror_conf mr_conf;
6495 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6497 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6499 mr_conf.dst_pool = res->dstpool_id;
6501 if (!strcmp(res->what, "pool-mirror")) {
6502 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6503 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6504 } else if(!strcmp(res->what, "vlan-mirror")) {
6505 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6506 nb_item = parse_item_list(res->value, "core",
6507 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6511 for(i=0; i < nb_item; i++) {
6512 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6513 printf("Invalid vlan_id: must be < 4096\n");
6517 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6518 mr_conf.vlan.vlan_mask |= 1ULL << i;
6522 if(!strcmp(res->on, "on"))
6523 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6526 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6529 printf("mirror rule add error: (%s)\n", strerror(-ret));
6532 cmdline_parse_inst_t cmd_set_mirror_mask = {
6533 .f = cmd_set_mirror_mask_parsed,
6535 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6536 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6538 (void *)&cmd_mirror_mask_set,
6539 (void *)&cmd_mirror_mask_port,
6540 (void *)&cmd_mirror_mask_portid,
6541 (void *)&cmd_mirror_mask_mirror,
6542 (void *)&cmd_mirror_mask_ruleid,
6543 (void *)&cmd_mirror_mask_what,
6544 (void *)&cmd_mirror_mask_value,
6545 (void *)&cmd_mirror_mask_dstpool,
6546 (void *)&cmd_mirror_mask_poolid,
6547 (void *)&cmd_mirror_mask_on,
6552 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6553 struct cmd_set_mirror_link_result {
6554 cmdline_fixed_string_t set;
6555 cmdline_fixed_string_t port;
6557 cmdline_fixed_string_t mirror;
6559 cmdline_fixed_string_t what;
6560 cmdline_fixed_string_t dstpool;
6562 cmdline_fixed_string_t on;
6565 cmdline_parse_token_string_t cmd_mirror_link_set =
6566 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6568 cmdline_parse_token_string_t cmd_mirror_link_port =
6569 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6571 cmdline_parse_token_num_t cmd_mirror_link_portid =
6572 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6574 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6575 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6576 mirror, "mirror-rule");
6577 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6578 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6580 cmdline_parse_token_string_t cmd_mirror_link_what =
6581 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6582 what, "uplink-mirror#downlink-mirror");
6583 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6584 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6585 dstpool, "dst-pool");
6586 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6587 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6589 cmdline_parse_token_string_t cmd_mirror_link_on =
6590 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6594 cmd_set_mirror_link_parsed(void *parsed_result,
6595 __attribute__((unused)) struct cmdline *cl,
6596 __attribute__((unused)) void *data)
6599 struct cmd_set_mirror_link_result *res = parsed_result;
6600 struct rte_eth_vmdq_mirror_conf mr_conf;
6602 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6603 if(!strcmp(res->what, "uplink-mirror")) {
6604 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6605 }else if(!strcmp(res->what, "downlink-mirror"))
6606 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6608 mr_conf.dst_pool = res->dstpool_id;
6610 if(!strcmp(res->on, "on"))
6611 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6614 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6617 /* check the return value and print it if is < 0 */
6619 printf("mirror rule add error: (%s)\n", strerror(-ret));
6623 cmdline_parse_inst_t cmd_set_mirror_link = {
6624 .f = cmd_set_mirror_link_parsed,
6626 .help_str = "set port X mirror-rule Y uplink-mirror|"
6627 "downlink-mirror dst-pool Z on|off",
6629 (void *)&cmd_mirror_link_set,
6630 (void *)&cmd_mirror_link_port,
6631 (void *)&cmd_mirror_link_portid,
6632 (void *)&cmd_mirror_link_mirror,
6633 (void *)&cmd_mirror_link_ruleid,
6634 (void *)&cmd_mirror_link_what,
6635 (void *)&cmd_mirror_link_dstpool,
6636 (void *)&cmd_mirror_link_poolid,
6637 (void *)&cmd_mirror_link_on,
6642 /* *** RESET VM MIRROR RULE *** */
6643 struct cmd_rm_mirror_rule_result {
6644 cmdline_fixed_string_t reset;
6645 cmdline_fixed_string_t port;
6647 cmdline_fixed_string_t mirror;
6651 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6652 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6654 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6655 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6657 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6658 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6660 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6661 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6662 mirror, "mirror-rule");
6663 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6664 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6668 cmd_reset_mirror_rule_parsed(void *parsed_result,
6669 __attribute__((unused)) struct cmdline *cl,
6670 __attribute__((unused)) void *data)
6673 struct cmd_set_mirror_link_result *res = parsed_result;
6675 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6677 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6680 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6681 .f = cmd_reset_mirror_rule_parsed,
6683 .help_str = "reset port X mirror-rule Y",
6685 (void *)&cmd_rm_mirror_rule_reset,
6686 (void *)&cmd_rm_mirror_rule_port,
6687 (void *)&cmd_rm_mirror_rule_portid,
6688 (void *)&cmd_rm_mirror_rule_mirror,
6689 (void *)&cmd_rm_mirror_rule_ruleid,
6694 /* ******************************************************************************** */
6696 struct cmd_dump_result {
6697 cmdline_fixed_string_t dump;
6701 dump_struct_sizes(void)
6703 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6704 DUMP_SIZE(struct rte_mbuf);
6705 DUMP_SIZE(struct rte_mempool);
6706 DUMP_SIZE(struct rte_ring);
6710 static void cmd_dump_parsed(void *parsed_result,
6711 __attribute__((unused)) struct cmdline *cl,
6712 __attribute__((unused)) void *data)
6714 struct cmd_dump_result *res = parsed_result;
6716 if (!strcmp(res->dump, "dump_physmem"))
6717 rte_dump_physmem_layout(stdout);
6718 else if (!strcmp(res->dump, "dump_memzone"))
6719 rte_memzone_dump(stdout);
6720 else if (!strcmp(res->dump, "dump_log_history"))
6721 rte_log_dump_history(stdout);
6722 else if (!strcmp(res->dump, "dump_struct_sizes"))
6723 dump_struct_sizes();
6724 else if (!strcmp(res->dump, "dump_ring"))
6725 rte_ring_list_dump(stdout);
6726 else if (!strcmp(res->dump, "dump_mempool"))
6727 rte_mempool_list_dump(stdout);
6728 else if (!strcmp(res->dump, "dump_devargs"))
6729 rte_eal_devargs_dump(stdout);
6732 cmdline_parse_token_string_t cmd_dump_dump =
6733 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6737 "dump_struct_sizes#"
6742 cmdline_parse_inst_t cmd_dump = {
6743 .f = cmd_dump_parsed, /* function to call */
6744 .data = NULL, /* 2nd arg of func */
6745 .help_str = "dump status",
6746 .tokens = { /* token list, NULL terminated */
6747 (void *)&cmd_dump_dump,
6752 /* ******************************************************************************** */
6754 struct cmd_dump_one_result {
6755 cmdline_fixed_string_t dump;
6756 cmdline_fixed_string_t name;
6759 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6760 __attribute__((unused)) void *data)
6762 struct cmd_dump_one_result *res = parsed_result;
6764 if (!strcmp(res->dump, "dump_ring")) {
6766 r = rte_ring_lookup(res->name);
6768 cmdline_printf(cl, "Cannot find ring\n");
6771 rte_ring_dump(stdout, r);
6772 } else if (!strcmp(res->dump, "dump_mempool")) {
6773 struct rte_mempool *mp;
6774 mp = rte_mempool_lookup(res->name);
6776 cmdline_printf(cl, "Cannot find mempool\n");
6779 rte_mempool_dump(stdout, mp);
6783 cmdline_parse_token_string_t cmd_dump_one_dump =
6784 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6785 "dump_ring#dump_mempool");
6787 cmdline_parse_token_string_t cmd_dump_one_name =
6788 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6790 cmdline_parse_inst_t cmd_dump_one = {
6791 .f = cmd_dump_one_parsed, /* function to call */
6792 .data = NULL, /* 2nd arg of func */
6793 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6794 .tokens = { /* token list, NULL terminated */
6795 (void *)&cmd_dump_one_dump,
6796 (void *)&cmd_dump_one_name,
6801 /* *** Add/Del syn filter *** */
6802 struct cmd_syn_filter_result {
6803 cmdline_fixed_string_t filter;
6805 cmdline_fixed_string_t ops;
6806 cmdline_fixed_string_t priority;
6807 cmdline_fixed_string_t high;
6808 cmdline_fixed_string_t queue;
6813 cmd_syn_filter_parsed(void *parsed_result,
6814 __attribute__((unused)) struct cmdline *cl,
6815 __attribute__((unused)) void *data)
6817 struct cmd_syn_filter_result *res = parsed_result;
6818 struct rte_eth_syn_filter syn_filter;
6821 ret = rte_eth_dev_filter_supported(res->port_id,
6822 RTE_ETH_FILTER_SYN);
6824 printf("syn filter is not supported on port %u.\n",
6829 memset(&syn_filter, 0, sizeof(syn_filter));
6831 if (!strcmp(res->ops, "add")) {
6832 if (!strcmp(res->high, "high"))
6833 syn_filter.hig_pri = 1;
6835 syn_filter.hig_pri = 0;
6837 syn_filter.queue = res->queue_id;
6838 ret = rte_eth_dev_filter_ctrl(res->port_id,
6843 ret = rte_eth_dev_filter_ctrl(res->port_id,
6845 RTE_ETH_FILTER_DELETE,
6849 printf("syn filter programming error: (%s)\n",
6853 cmdline_parse_token_string_t cmd_syn_filter_filter =
6854 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6855 filter, "syn_filter");
6856 cmdline_parse_token_num_t cmd_syn_filter_port_id =
6857 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6859 cmdline_parse_token_string_t cmd_syn_filter_ops =
6860 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6862 cmdline_parse_token_string_t cmd_syn_filter_priority =
6863 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6864 priority, "priority");
6865 cmdline_parse_token_string_t cmd_syn_filter_high =
6866 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6868 cmdline_parse_token_string_t cmd_syn_filter_queue =
6869 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6871 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6872 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6875 cmdline_parse_inst_t cmd_syn_filter = {
6876 .f = cmd_syn_filter_parsed,
6878 .help_str = "add/delete syn filter",
6880 (void *)&cmd_syn_filter_filter,
6881 (void *)&cmd_syn_filter_port_id,
6882 (void *)&cmd_syn_filter_ops,
6883 (void *)&cmd_syn_filter_priority,
6884 (void *)&cmd_syn_filter_high,
6885 (void *)&cmd_syn_filter_queue,
6886 (void *)&cmd_syn_filter_queue_id,
6891 /* *** ADD/REMOVE A 2tuple FILTER *** */
6892 struct cmd_2tuple_filter_result {
6893 cmdline_fixed_string_t filter;
6895 cmdline_fixed_string_t ops;
6896 cmdline_fixed_string_t dst_port;
6897 uint16_t dst_port_value;
6898 cmdline_fixed_string_t protocol;
6899 uint8_t protocol_value;
6900 cmdline_fixed_string_t mask;
6902 cmdline_fixed_string_t tcp_flags;
6903 uint8_t tcp_flags_value;
6904 cmdline_fixed_string_t priority;
6905 uint8_t priority_value;
6906 cmdline_fixed_string_t queue;
6911 cmd_2tuple_filter_parsed(void *parsed_result,
6912 __attribute__((unused)) struct cmdline *cl,
6913 __attribute__((unused)) void *data)
6915 struct rte_eth_ntuple_filter filter;
6916 struct cmd_2tuple_filter_result *res = parsed_result;
6919 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
6921 printf("ntuple filter is not supported on port %u.\n",
6926 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
6928 filter.flags = RTE_2TUPLE_FLAGS;
6929 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
6930 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
6931 filter.proto = res->protocol_value;
6932 filter.priority = res->priority_value;
6933 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
6934 printf("nonzero tcp_flags is only meaningful"
6935 " when protocol is TCP.\n");
6938 if (res->tcp_flags_value > TCP_FLAG_ALL) {
6939 printf("invalid TCP flags.\n");
6943 if (res->tcp_flags_value != 0) {
6944 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
6945 filter.tcp_flags = res->tcp_flags_value;
6948 /* need convert to big endian. */
6949 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6950 filter.queue = res->queue_id;
6952 if (!strcmp(res->ops, "add"))
6953 ret = rte_eth_dev_filter_ctrl(res->port_id,
6954 RTE_ETH_FILTER_NTUPLE,
6958 ret = rte_eth_dev_filter_ctrl(res->port_id,
6959 RTE_ETH_FILTER_NTUPLE,
6960 RTE_ETH_FILTER_DELETE,
6963 printf("2tuple filter programming error: (%s)\n",
6968 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
6969 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6970 filter, "2tuple_filter");
6971 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6972 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6974 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
6975 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6977 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6978 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6979 dst_port, "dst_port");
6980 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6981 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6982 dst_port_value, UINT16);
6983 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6984 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6985 protocol, "protocol");
6986 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6987 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6988 protocol_value, UINT8);
6989 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
6990 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6992 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
6993 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6995 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
6996 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6997 tcp_flags, "tcp_flags");
6998 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
6999 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7000 tcp_flags_value, UINT8);
7001 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7002 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7003 priority, "priority");
7004 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7005 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7006 priority_value, UINT8);
7007 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7008 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7010 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7011 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7014 cmdline_parse_inst_t cmd_2tuple_filter = {
7015 .f = cmd_2tuple_filter_parsed,
7017 .help_str = "add a 2tuple filter",
7019 (void *)&cmd_2tuple_filter_filter,
7020 (void *)&cmd_2tuple_filter_port_id,
7021 (void *)&cmd_2tuple_filter_ops,
7022 (void *)&cmd_2tuple_filter_dst_port,
7023 (void *)&cmd_2tuple_filter_dst_port_value,
7024 (void *)&cmd_2tuple_filter_protocol,
7025 (void *)&cmd_2tuple_filter_protocol_value,
7026 (void *)&cmd_2tuple_filter_mask,
7027 (void *)&cmd_2tuple_filter_mask_value,
7028 (void *)&cmd_2tuple_filter_tcp_flags,
7029 (void *)&cmd_2tuple_filter_tcp_flags_value,
7030 (void *)&cmd_2tuple_filter_priority,
7031 (void *)&cmd_2tuple_filter_priority_value,
7032 (void *)&cmd_2tuple_filter_queue,
7033 (void *)&cmd_2tuple_filter_queue_id,
7038 /* *** ADD/REMOVE A 5tuple FILTER *** */
7039 struct cmd_5tuple_filter_result {
7040 cmdline_fixed_string_t filter;
7042 cmdline_fixed_string_t ops;
7043 cmdline_fixed_string_t dst_ip;
7044 cmdline_ipaddr_t dst_ip_value;
7045 cmdline_fixed_string_t src_ip;
7046 cmdline_ipaddr_t src_ip_value;
7047 cmdline_fixed_string_t dst_port;
7048 uint16_t dst_port_value;
7049 cmdline_fixed_string_t src_port;
7050 uint16_t src_port_value;
7051 cmdline_fixed_string_t protocol;
7052 uint8_t protocol_value;
7053 cmdline_fixed_string_t mask;
7055 cmdline_fixed_string_t tcp_flags;
7056 uint8_t tcp_flags_value;
7057 cmdline_fixed_string_t priority;
7058 uint8_t priority_value;
7059 cmdline_fixed_string_t queue;
7064 cmd_5tuple_filter_parsed(void *parsed_result,
7065 __attribute__((unused)) struct cmdline *cl,
7066 __attribute__((unused)) void *data)
7068 struct rte_eth_ntuple_filter filter;
7069 struct cmd_5tuple_filter_result *res = parsed_result;
7072 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7074 printf("ntuple filter is not supported on port %u.\n",
7079 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7081 filter.flags = RTE_5TUPLE_FLAGS;
7082 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7083 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7084 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7085 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7086 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7087 filter.proto = res->protocol_value;
7088 filter.priority = res->priority_value;
7089 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7090 printf("nonzero tcp_flags is only meaningful"
7091 " when protocol is TCP.\n");
7094 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7095 printf("invalid TCP flags.\n");
7099 if (res->tcp_flags_value != 0) {
7100 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7101 filter.tcp_flags = res->tcp_flags_value;
7104 if (res->dst_ip_value.family == AF_INET)
7105 /* no need to convert, already big endian. */
7106 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7108 if (filter.dst_ip_mask == 0) {
7109 printf("can not support ipv6 involved compare.\n");
7115 if (res->src_ip_value.family == AF_INET)
7116 /* no need to convert, already big endian. */
7117 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7119 if (filter.src_ip_mask == 0) {
7120 printf("can not support ipv6 involved compare.\n");
7125 /* need convert to big endian. */
7126 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7127 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7128 filter.queue = res->queue_id;
7130 if (!strcmp(res->ops, "add"))
7131 ret = rte_eth_dev_filter_ctrl(res->port_id,
7132 RTE_ETH_FILTER_NTUPLE,
7136 ret = rte_eth_dev_filter_ctrl(res->port_id,
7137 RTE_ETH_FILTER_NTUPLE,
7138 RTE_ETH_FILTER_DELETE,
7141 printf("5tuple filter programming error: (%s)\n",
7145 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7146 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7147 filter, "5tuple_filter");
7148 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7149 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7151 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7152 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7154 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7155 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7157 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7158 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7160 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7161 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7163 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7164 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7166 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7167 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7168 dst_port, "dst_port");
7169 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7170 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7171 dst_port_value, UINT16);
7172 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7173 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7174 src_port, "src_port");
7175 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7176 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7177 src_port_value, UINT16);
7178 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7179 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7180 protocol, "protocol");
7181 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7182 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7183 protocol_value, UINT8);
7184 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7185 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7187 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7188 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7190 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7191 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7192 tcp_flags, "tcp_flags");
7193 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7194 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7195 tcp_flags_value, UINT8);
7196 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7197 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7198 priority, "priority");
7199 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7200 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7201 priority_value, UINT8);
7202 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7203 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7205 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7206 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7209 cmdline_parse_inst_t cmd_5tuple_filter = {
7210 .f = cmd_5tuple_filter_parsed,
7212 .help_str = "add/del a 5tuple filter",
7214 (void *)&cmd_5tuple_filter_filter,
7215 (void *)&cmd_5tuple_filter_port_id,
7216 (void *)&cmd_5tuple_filter_ops,
7217 (void *)&cmd_5tuple_filter_dst_ip,
7218 (void *)&cmd_5tuple_filter_dst_ip_value,
7219 (void *)&cmd_5tuple_filter_src_ip,
7220 (void *)&cmd_5tuple_filter_src_ip_value,
7221 (void *)&cmd_5tuple_filter_dst_port,
7222 (void *)&cmd_5tuple_filter_dst_port_value,
7223 (void *)&cmd_5tuple_filter_src_port,
7224 (void *)&cmd_5tuple_filter_src_port_value,
7225 (void *)&cmd_5tuple_filter_protocol,
7226 (void *)&cmd_5tuple_filter_protocol_value,
7227 (void *)&cmd_5tuple_filter_mask,
7228 (void *)&cmd_5tuple_filter_mask_value,
7229 (void *)&cmd_5tuple_filter_tcp_flags,
7230 (void *)&cmd_5tuple_filter_tcp_flags_value,
7231 (void *)&cmd_5tuple_filter_priority,
7232 (void *)&cmd_5tuple_filter_priority_value,
7233 (void *)&cmd_5tuple_filter_queue,
7234 (void *)&cmd_5tuple_filter_queue_id,
7239 /* *** ADD/REMOVE A flex FILTER *** */
7240 struct cmd_flex_filter_result {
7241 cmdline_fixed_string_t filter;
7242 cmdline_fixed_string_t ops;
7244 cmdline_fixed_string_t len;
7246 cmdline_fixed_string_t bytes;
7247 cmdline_fixed_string_t bytes_value;
7248 cmdline_fixed_string_t mask;
7249 cmdline_fixed_string_t mask_value;
7250 cmdline_fixed_string_t priority;
7251 uint8_t priority_value;
7252 cmdline_fixed_string_t queue;
7256 static int xdigit2val(unsigned char c)
7261 else if (isupper(c))
7269 cmd_flex_filter_parsed(void *parsed_result,
7270 __attribute__((unused)) struct cmdline *cl,
7271 __attribute__((unused)) void *data)
7274 struct rte_eth_flex_filter filter;
7275 struct cmd_flex_filter_result *res = parsed_result;
7276 char *bytes_ptr, *mask_ptr;
7277 uint16_t len, i, j = 0;
7282 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7283 printf("the len exceed the max length 128\n");
7286 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7287 filter.len = res->len_value;
7288 filter.priority = res->priority_value;
7289 filter.queue = res->queue_id;
7290 bytes_ptr = res->bytes_value;
7291 mask_ptr = res->mask_value;
7293 /* translate bytes string to array. */
7294 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7295 (bytes_ptr[1] == 'X')))
7297 len = strnlen(bytes_ptr, res->len_value * 2);
7298 if (len == 0 || (len % 8 != 0)) {
7299 printf("please check len and bytes input\n");
7302 for (i = 0; i < len; i++) {
7304 if (isxdigit(c) == 0) {
7305 /* invalid characters. */
7306 printf("invalid input\n");
7309 val = xdigit2val(c);
7312 filter.bytes[j] = byte;
7313 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7320 /* translate mask string to uint8_t array. */
7321 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7322 (mask_ptr[1] == 'X')))
7324 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7326 printf("invalid input\n");
7331 for (i = 0; i < len; i++) {
7333 if (isxdigit(c) == 0) {
7334 /* invalid characters. */
7335 printf("invalid input\n");
7338 val = xdigit2val(c);
7341 filter.mask[j] = byte;
7342 printf("mask[%d]:%02x ", j, filter.mask[j]);
7350 if (!strcmp(res->ops, "add"))
7351 ret = rte_eth_dev_filter_ctrl(res->port_id,
7352 RTE_ETH_FILTER_FLEXIBLE,
7356 ret = rte_eth_dev_filter_ctrl(res->port_id,
7357 RTE_ETH_FILTER_FLEXIBLE,
7358 RTE_ETH_FILTER_DELETE,
7362 printf("flex filter setting error: (%s)\n", strerror(-ret));
7365 cmdline_parse_token_string_t cmd_flex_filter_filter =
7366 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7367 filter, "flex_filter");
7368 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7369 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7371 cmdline_parse_token_string_t cmd_flex_filter_ops =
7372 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7374 cmdline_parse_token_string_t cmd_flex_filter_len =
7375 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7377 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7378 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7380 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7381 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7383 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7384 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7386 cmdline_parse_token_string_t cmd_flex_filter_mask =
7387 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7389 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7390 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7392 cmdline_parse_token_string_t cmd_flex_filter_priority =
7393 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7394 priority, "priority");
7395 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7396 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7397 priority_value, UINT8);
7398 cmdline_parse_token_string_t cmd_flex_filter_queue =
7399 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7401 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7402 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7404 cmdline_parse_inst_t cmd_flex_filter = {
7405 .f = cmd_flex_filter_parsed,
7407 .help_str = "add/del a flex filter",
7409 (void *)&cmd_flex_filter_filter,
7410 (void *)&cmd_flex_filter_port_id,
7411 (void *)&cmd_flex_filter_ops,
7412 (void *)&cmd_flex_filter_len,
7413 (void *)&cmd_flex_filter_len_value,
7414 (void *)&cmd_flex_filter_bytes,
7415 (void *)&cmd_flex_filter_bytes_value,
7416 (void *)&cmd_flex_filter_mask,
7417 (void *)&cmd_flex_filter_mask_value,
7418 (void *)&cmd_flex_filter_priority,
7419 (void *)&cmd_flex_filter_priority_value,
7420 (void *)&cmd_flex_filter_queue,
7421 (void *)&cmd_flex_filter_queue_id,
7426 /* *** Filters Control *** */
7428 /* *** deal with ethertype filter *** */
7429 struct cmd_ethertype_filter_result {
7430 cmdline_fixed_string_t filter;
7432 cmdline_fixed_string_t ops;
7433 cmdline_fixed_string_t mac;
7434 struct ether_addr mac_addr;
7435 cmdline_fixed_string_t ethertype;
7436 uint16_t ethertype_value;
7437 cmdline_fixed_string_t drop;
7438 cmdline_fixed_string_t queue;
7442 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7443 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7444 filter, "ethertype_filter");
7445 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7446 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7448 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7449 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7451 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7452 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7453 mac, "mac_addr#mac_ignr");
7454 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7455 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7457 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7458 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7459 ethertype, "ethertype");
7460 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7461 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7462 ethertype_value, UINT16);
7463 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7464 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7466 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7467 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7469 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7470 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7474 cmd_ethertype_filter_parsed(void *parsed_result,
7475 __attribute__((unused)) struct cmdline *cl,
7476 __attribute__((unused)) void *data)
7478 struct cmd_ethertype_filter_result *res = parsed_result;
7479 struct rte_eth_ethertype_filter filter;
7482 ret = rte_eth_dev_filter_supported(res->port_id,
7483 RTE_ETH_FILTER_ETHERTYPE);
7485 printf("ethertype filter is not supported on port %u.\n",
7490 memset(&filter, 0, sizeof(filter));
7491 if (!strcmp(res->mac, "mac_addr")) {
7492 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7493 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7494 sizeof(struct ether_addr));
7496 if (!strcmp(res->drop, "drop"))
7497 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7498 filter.ether_type = res->ethertype_value;
7499 filter.queue = res->queue_id;
7501 if (!strcmp(res->ops, "add"))
7502 ret = rte_eth_dev_filter_ctrl(res->port_id,
7503 RTE_ETH_FILTER_ETHERTYPE,
7507 ret = rte_eth_dev_filter_ctrl(res->port_id,
7508 RTE_ETH_FILTER_ETHERTYPE,
7509 RTE_ETH_FILTER_DELETE,
7512 printf("ethertype filter programming error: (%s)\n",
7516 cmdline_parse_inst_t cmd_ethertype_filter = {
7517 .f = cmd_ethertype_filter_parsed,
7519 .help_str = "add or delete an ethertype filter entry",
7521 (void *)&cmd_ethertype_filter_filter,
7522 (void *)&cmd_ethertype_filter_port_id,
7523 (void *)&cmd_ethertype_filter_ops,
7524 (void *)&cmd_ethertype_filter_mac,
7525 (void *)&cmd_ethertype_filter_mac_addr,
7526 (void *)&cmd_ethertype_filter_ethertype,
7527 (void *)&cmd_ethertype_filter_ethertype_value,
7528 (void *)&cmd_ethertype_filter_drop,
7529 (void *)&cmd_ethertype_filter_queue,
7530 (void *)&cmd_ethertype_filter_queue_id,
7535 /* *** deal with flow director filter *** */
7536 struct cmd_flow_director_result {
7537 cmdline_fixed_string_t flow_director_filter;
7539 cmdline_fixed_string_t ops;
7540 cmdline_fixed_string_t flow;
7541 cmdline_fixed_string_t flow_type;
7542 cmdline_fixed_string_t src;
7543 cmdline_ipaddr_t ip_src;
7545 cmdline_fixed_string_t dst;
7546 cmdline_ipaddr_t ip_dst;
7548 cmdline_fixed_string_t verify_tag;
7549 uint32_t verify_tag_value;
7550 cmdline_fixed_string_t vlan;
7551 uint16_t vlan_value;
7552 cmdline_fixed_string_t flexbytes;
7553 cmdline_fixed_string_t flexbytes_value;
7554 cmdline_fixed_string_t drop;
7555 cmdline_fixed_string_t queue;
7557 cmdline_fixed_string_t fd_id;
7558 uint32_t fd_id_value;
7562 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7565 const char *p, *p0 = q_arg;
7567 unsigned long int_fld;
7568 char *str_fld[max_num];
7573 p = strchr(p0, '(');
7577 p0 = strchr(p, ')');
7582 if (size >= sizeof(s))
7585 snprintf(s, sizeof(s), "%.*s", size, p);
7586 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7587 if (ret < 0 || ret > max_num)
7589 for (i = 0; i < ret; i++) {
7591 int_fld = strtoul(str_fld[i], &end, 0);
7592 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7594 flexbytes[i] = (uint8_t)int_fld;
7600 str2flowtype(char *string)
7603 static const struct {
7606 } flowtype_str[] = {
7607 {"raw", RTE_ETH_FLOW_RAW},
7608 {"ipv4", RTE_ETH_FLOW_IPV4},
7609 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
7610 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
7611 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
7612 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
7613 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
7614 {"ipv6", RTE_ETH_FLOW_IPV6},
7615 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
7616 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
7617 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
7618 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
7619 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
7620 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
7623 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7624 if (!strcmp(flowtype_str[i].str, string))
7625 return flowtype_str[i].type;
7627 return RTE_ETH_FLOW_UNKNOWN;
7630 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7632 if ((ip_addr).family == AF_INET) \
7633 (ip) = (ip_addr).addr.ipv4.s_addr; \
7635 printf("invalid parameter.\n"); \
7640 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7642 if ((ip_addr).family == AF_INET6) \
7643 (void)rte_memcpy(&(ip), \
7644 &((ip_addr).addr.ipv6), \
7645 sizeof(struct in6_addr)); \
7647 printf("invalid parameter.\n"); \
7653 cmd_flow_director_filter_parsed(void *parsed_result,
7654 __attribute__((unused)) struct cmdline *cl,
7655 __attribute__((unused)) void *data)
7657 struct cmd_flow_director_result *res = parsed_result;
7658 struct rte_eth_fdir_filter entry;
7659 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7662 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7664 printf("flow director is not supported on port %u.\n",
7668 memset(flexbytes, 0, sizeof(flexbytes));
7669 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7670 ret = parse_flexbytes(res->flexbytes_value,
7672 RTE_ETH_FDIR_MAX_FLEXLEN);
7674 printf("error: Cannot parse flexbytes input.\n");
7678 entry.input.flow_type = str2flowtype(res->flow_type);
7679 switch (entry.input.flow_type) {
7680 case RTE_ETH_FLOW_FRAG_IPV4:
7681 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
7682 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
7683 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
7684 IPV4_ADDR_TO_UINT(res->ip_dst,
7685 entry.input.flow.ip4_flow.dst_ip);
7686 IPV4_ADDR_TO_UINT(res->ip_src,
7687 entry.input.flow.ip4_flow.src_ip);
7688 /* need convert to big endian. */
7689 entry.input.flow.udp4_flow.dst_port =
7690 rte_cpu_to_be_16(res->port_dst);
7691 entry.input.flow.udp4_flow.src_port =
7692 rte_cpu_to_be_16(res->port_src);
7694 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
7695 IPV4_ADDR_TO_UINT(res->ip_dst,
7696 entry.input.flow.sctp4_flow.ip.dst_ip);
7697 IPV4_ADDR_TO_UINT(res->ip_src,
7698 entry.input.flow.sctp4_flow.ip.src_ip);
7699 /* need convert to big endian. */
7700 entry.input.flow.sctp4_flow.verify_tag =
7701 rte_cpu_to_be_32(res->verify_tag_value);
7703 case RTE_ETH_FLOW_FRAG_IPV6:
7704 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
7705 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
7706 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
7707 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7708 entry.input.flow.ipv6_flow.dst_ip);
7709 IPV6_ADDR_TO_ARRAY(res->ip_src,
7710 entry.input.flow.ipv6_flow.src_ip);
7711 /* need convert to big endian. */
7712 entry.input.flow.udp6_flow.dst_port =
7713 rte_cpu_to_be_16(res->port_dst);
7714 entry.input.flow.udp6_flow.src_port =
7715 rte_cpu_to_be_16(res->port_src);
7717 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
7718 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7719 entry.input.flow.sctp6_flow.ip.dst_ip);
7720 IPV6_ADDR_TO_ARRAY(res->ip_src,
7721 entry.input.flow.sctp6_flow.ip.src_ip);
7722 /* need convert to big endian. */
7723 entry.input.flow.sctp6_flow.verify_tag =
7724 rte_cpu_to_be_32(res->verify_tag_value);
7727 printf("invalid parameter.\n");
7730 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7732 RTE_ETH_FDIR_MAX_FLEXLEN);
7734 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7736 entry.action.flex_off = 0; /*use 0 by default */
7737 if (!strcmp(res->drop, "drop"))
7738 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7740 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7741 /* set to report FD ID by default */
7742 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7743 entry.action.rx_queue = res->queue_id;
7744 entry.soft_id = res->fd_id_value;
7745 if (!strcmp(res->ops, "add"))
7746 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7747 RTE_ETH_FILTER_ADD, &entry);
7748 else if (!strcmp(res->ops, "del"))
7749 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7750 RTE_ETH_FILTER_DELETE, &entry);
7752 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7753 RTE_ETH_FILTER_UPDATE, &entry);
7755 printf("flow director programming error: (%s)\n",
7759 cmdline_parse_token_string_t cmd_flow_director_filter =
7760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7761 flow_director_filter, "flow_director_filter");
7762 cmdline_parse_token_num_t cmd_flow_director_port_id =
7763 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7765 cmdline_parse_token_string_t cmd_flow_director_ops =
7766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7767 ops, "add#del#update");
7768 cmdline_parse_token_string_t cmd_flow_director_flow =
7769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7771 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7772 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7773 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
7774 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp");
7775 cmdline_parse_token_string_t cmd_flow_director_src =
7776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7778 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7779 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7781 cmdline_parse_token_num_t cmd_flow_director_port_src =
7782 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7784 cmdline_parse_token_string_t cmd_flow_director_dst =
7785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7787 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
7788 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7790 cmdline_parse_token_num_t cmd_flow_director_port_dst =
7791 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7793 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
7794 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7795 verify_tag, "verify_tag");
7796 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
7797 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7798 verify_tag_value, UINT32);
7799 cmdline_parse_token_string_t cmd_flow_director_vlan =
7800 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7802 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
7803 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7804 vlan_value, UINT16);
7805 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
7806 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7807 flexbytes, "flexbytes");
7808 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
7809 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7810 flexbytes_value, NULL);
7811 cmdline_parse_token_string_t cmd_flow_director_drop =
7812 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7814 cmdline_parse_token_string_t cmd_flow_director_queue =
7815 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7817 cmdline_parse_token_num_t cmd_flow_director_queue_id =
7818 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7820 cmdline_parse_token_string_t cmd_flow_director_fd_id =
7821 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7823 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
7824 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7825 fd_id_value, UINT32);
7827 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
7828 .f = cmd_flow_director_filter_parsed,
7830 .help_str = "add or delete an ip flow director entry on NIC",
7832 (void *)&cmd_flow_director_filter,
7833 (void *)&cmd_flow_director_port_id,
7834 (void *)&cmd_flow_director_ops,
7835 (void *)&cmd_flow_director_flow,
7836 (void *)&cmd_flow_director_flow_type,
7837 (void *)&cmd_flow_director_src,
7838 (void *)&cmd_flow_director_ip_src,
7839 (void *)&cmd_flow_director_dst,
7840 (void *)&cmd_flow_director_ip_dst,
7841 (void *)&cmd_flow_director_vlan,
7842 (void *)&cmd_flow_director_vlan_value,
7843 (void *)&cmd_flow_director_flexbytes,
7844 (void *)&cmd_flow_director_flexbytes_value,
7845 (void *)&cmd_flow_director_drop,
7846 (void *)&cmd_flow_director_queue,
7847 (void *)&cmd_flow_director_queue_id,
7848 (void *)&cmd_flow_director_fd_id,
7849 (void *)&cmd_flow_director_fd_id_value,
7854 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
7855 .f = cmd_flow_director_filter_parsed,
7857 .help_str = "add or delete an udp/tcp flow director entry on NIC",
7859 (void *)&cmd_flow_director_filter,
7860 (void *)&cmd_flow_director_port_id,
7861 (void *)&cmd_flow_director_ops,
7862 (void *)&cmd_flow_director_flow,
7863 (void *)&cmd_flow_director_flow_type,
7864 (void *)&cmd_flow_director_src,
7865 (void *)&cmd_flow_director_ip_src,
7866 (void *)&cmd_flow_director_port_src,
7867 (void *)&cmd_flow_director_dst,
7868 (void *)&cmd_flow_director_ip_dst,
7869 (void *)&cmd_flow_director_port_dst,
7870 (void *)&cmd_flow_director_vlan,
7871 (void *)&cmd_flow_director_vlan_value,
7872 (void *)&cmd_flow_director_flexbytes,
7873 (void *)&cmd_flow_director_flexbytes_value,
7874 (void *)&cmd_flow_director_drop,
7875 (void *)&cmd_flow_director_queue,
7876 (void *)&cmd_flow_director_queue_id,
7877 (void *)&cmd_flow_director_fd_id,
7878 (void *)&cmd_flow_director_fd_id_value,
7883 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
7884 .f = cmd_flow_director_filter_parsed,
7886 .help_str = "add or delete a sctp flow director entry on NIC",
7888 (void *)&cmd_flow_director_filter,
7889 (void *)&cmd_flow_director_port_id,
7890 (void *)&cmd_flow_director_ops,
7891 (void *)&cmd_flow_director_flow,
7892 (void *)&cmd_flow_director_flow_type,
7893 (void *)&cmd_flow_director_src,
7894 (void *)&cmd_flow_director_ip_src,
7895 (void *)&cmd_flow_director_port_dst,
7896 (void *)&cmd_flow_director_dst,
7897 (void *)&cmd_flow_director_ip_dst,
7898 (void *)&cmd_flow_director_port_dst,
7899 (void *)&cmd_flow_director_verify_tag,
7900 (void *)&cmd_flow_director_verify_tag_value,
7901 (void *)&cmd_flow_director_vlan,
7902 (void *)&cmd_flow_director_vlan_value,
7903 (void *)&cmd_flow_director_flexbytes,
7904 (void *)&cmd_flow_director_flexbytes_value,
7905 (void *)&cmd_flow_director_drop,
7906 (void *)&cmd_flow_director_queue,
7907 (void *)&cmd_flow_director_queue_id,
7908 (void *)&cmd_flow_director_fd_id,
7909 (void *)&cmd_flow_director_fd_id_value,
7914 struct cmd_flush_flow_director_result {
7915 cmdline_fixed_string_t flush_flow_director;
7919 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
7920 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
7921 flush_flow_director, "flush_flow_director");
7922 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
7923 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
7927 cmd_flush_flow_director_parsed(void *parsed_result,
7928 __attribute__((unused)) struct cmdline *cl,
7929 __attribute__((unused)) void *data)
7931 struct cmd_flow_director_result *res = parsed_result;
7934 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7936 printf("flow director is not supported on port %u.\n",
7941 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7942 RTE_ETH_FILTER_FLUSH, NULL);
7944 printf("flow director table flushing error: (%s)\n",
7948 cmdline_parse_inst_t cmd_flush_flow_director = {
7949 .f = cmd_flush_flow_director_parsed,
7951 .help_str = "flush all flow director entries of a device on NIC",
7953 (void *)&cmd_flush_flow_director_flush,
7954 (void *)&cmd_flush_flow_director_port_id,
7959 /* *** deal with flow director mask *** */
7960 struct cmd_flow_director_mask_result {
7961 cmdline_fixed_string_t flow_director_mask;
7963 cmdline_fixed_string_t vlan;
7964 uint16_t vlan_value;
7965 cmdline_fixed_string_t src_mask;
7966 cmdline_ipaddr_t ipv4_src;
7967 cmdline_ipaddr_t ipv6_src;
7969 cmdline_fixed_string_t dst_mask;
7970 cmdline_ipaddr_t ipv4_dst;
7971 cmdline_ipaddr_t ipv6_dst;
7976 cmd_flow_director_mask_parsed(void *parsed_result,
7977 __attribute__((unused)) struct cmdline *cl,
7978 __attribute__((unused)) void *data)
7980 struct cmd_flow_director_mask_result *res = parsed_result;
7981 struct rte_eth_fdir_masks *mask;
7982 struct rte_port *port;
7984 if (res->port_id > nb_ports) {
7985 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
7989 port = &ports[res->port_id];
7990 /** Check if the port is not started **/
7991 if (port->port_status != RTE_PORT_STOPPED) {
7992 printf("Please stop port %d first\n", res->port_id);
7995 mask = &port->dev_conf.fdir_conf.mask;
7997 mask->vlan_tci_mask = res->vlan_value;
7998 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
7999 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8000 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8001 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8002 mask->src_port_mask = res->port_src;
8003 mask->dst_port_mask = res->port_dst;
8005 cmd_reconfig_device_queue(res->port_id, 1, 1);
8008 cmdline_parse_token_string_t cmd_flow_director_mask =
8009 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8010 flow_director_mask, "flow_director_mask");
8011 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8012 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8014 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8015 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8017 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8018 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8019 vlan_value, UINT16);
8020 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8021 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8022 src_mask, "src_mask");
8023 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8024 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8026 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8027 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8029 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8030 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8032 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8033 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8034 dst_mask, "dst_mask");
8035 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8036 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8038 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8039 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8041 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8042 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8044 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8045 .f = cmd_flow_director_mask_parsed,
8047 .help_str = "set flow director's mask on NIC",
8049 (void *)&cmd_flow_director_mask,
8050 (void *)&cmd_flow_director_mask_port_id,
8051 (void *)&cmd_flow_director_mask_vlan,
8052 (void *)&cmd_flow_director_mask_vlan_value,
8053 (void *)&cmd_flow_director_mask_src,
8054 (void *)&cmd_flow_director_mask_ipv4_src,
8055 (void *)&cmd_flow_director_mask_ipv6_src,
8056 (void *)&cmd_flow_director_mask_port_src,
8057 (void *)&cmd_flow_director_mask_dst,
8058 (void *)&cmd_flow_director_mask_ipv4_dst,
8059 (void *)&cmd_flow_director_mask_ipv6_dst,
8060 (void *)&cmd_flow_director_mask_port_dst,
8065 /* *** deal with flow director mask on flexible payload *** */
8066 struct cmd_flow_director_flex_mask_result {
8067 cmdline_fixed_string_t flow_director_flexmask;
8069 cmdline_fixed_string_t flow;
8070 cmdline_fixed_string_t flow_type;
8071 cmdline_fixed_string_t mask;
8075 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8076 __attribute__((unused)) struct cmdline *cl,
8077 __attribute__((unused)) void *data)
8079 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8080 struct rte_eth_fdir_info fdir_info;
8081 struct rte_eth_fdir_flex_mask flex_mask;
8082 struct rte_port *port;
8083 uint32_t flow_type_mask;
8087 if (res->port_id > nb_ports) {
8088 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8092 port = &ports[res->port_id];
8093 /** Check if the port is not started **/
8094 if (port->port_status != RTE_PORT_STOPPED) {
8095 printf("Please stop port %d first\n", res->port_id);
8099 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8100 ret = parse_flexbytes(res->mask,
8102 RTE_ETH_FDIR_MAX_FLEXLEN);
8104 printf("error: Cannot parse mask input.\n");
8108 memset(&fdir_info, 0, sizeof(fdir_info));
8109 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8110 RTE_ETH_FILTER_INFO, &fdir_info);
8112 printf("Cannot get FDir filter info\n");
8116 flow_type_mask = fdir_info.flow_types_mask[0];
8117 if (!strcmp(res->flow_type, "all")) {
8118 if (!flow_type_mask) {
8119 printf("No flow type supported\n");
8122 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8123 if (flow_type_mask & (1 << i)) {
8124 flex_mask.flow_type = i;
8125 fdir_set_flex_mask(res->port_id, &flex_mask);
8128 cmd_reconfig_device_queue(res->port_id, 1, 1);
8131 flex_mask.flow_type = str2flowtype(res->flow_type);
8132 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8133 printf("Flow type %s not supported on port %d\n",
8134 res->flow_type, res->port_id);
8137 fdir_set_flex_mask(res->port_id, &flex_mask);
8138 cmd_reconfig_device_queue(res->port_id, 1, 1);
8141 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8142 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8143 flow_director_flexmask,
8144 "flow_director_flex_mask");
8145 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8148 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8151 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8153 flow_type, "raw#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8154 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#all");
8155 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8156 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8159 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8160 .f = cmd_flow_director_flex_mask_parsed,
8162 .help_str = "set flow director's flex mask on NIC",
8164 (void *)&cmd_flow_director_flexmask,
8165 (void *)&cmd_flow_director_flexmask_port_id,
8166 (void *)&cmd_flow_director_flexmask_flow,
8167 (void *)&cmd_flow_director_flexmask_flow_type,
8168 (void *)&cmd_flow_director_flexmask_mask,
8173 /* *** deal with flow director flexible payload configuration *** */
8174 struct cmd_flow_director_flexpayload_result {
8175 cmdline_fixed_string_t flow_director_flexpayload;
8177 cmdline_fixed_string_t payload_layer;
8178 cmdline_fixed_string_t payload_cfg;
8182 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8185 const char *p, *p0 = q_arg;
8187 unsigned long int_fld;
8188 char *str_fld[max_num];
8193 p = strchr(p0, '(');
8197 p0 = strchr(p, ')');
8202 if (size >= sizeof(s))
8205 snprintf(s, sizeof(s), "%.*s", size, p);
8206 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8207 if (ret < 0 || ret > max_num)
8209 for (i = 0; i < ret; i++) {
8211 int_fld = strtoul(str_fld[i], &end, 0);
8212 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8214 offsets[i] = (uint16_t)int_fld;
8220 cmd_flow_director_flxpld_parsed(void *parsed_result,
8221 __attribute__((unused)) struct cmdline *cl,
8222 __attribute__((unused)) void *data)
8224 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8225 struct rte_eth_flex_payload_cfg flex_cfg;
8226 struct rte_port *port;
8229 if (res->port_id > nb_ports) {
8230 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8234 port = &ports[res->port_id];
8235 /** Check if the port is not started **/
8236 if (port->port_status != RTE_PORT_STOPPED) {
8237 printf("Please stop port %d first\n", res->port_id);
8241 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8243 if (!strcmp(res->payload_layer, "raw"))
8244 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8245 else if (!strcmp(res->payload_layer, "l2"))
8246 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8247 else if (!strcmp(res->payload_layer, "l3"))
8248 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8249 else if (!strcmp(res->payload_layer, "l4"))
8250 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8252 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8253 RTE_ETH_FDIR_MAX_FLEXLEN);
8255 printf("error: Cannot parse flex payload input.\n");
8259 fdir_set_flex_payload(res->port_id, &flex_cfg);
8260 cmd_reconfig_device_queue(res->port_id, 1, 1);
8263 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8265 flow_director_flexpayload,
8266 "flow_director_flex_payload");
8267 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8268 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8270 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8272 payload_layer, "raw#l2#l3#l4");
8273 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8277 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8278 .f = cmd_flow_director_flxpld_parsed,
8280 .help_str = "set flow director's flex payload on NIC",
8282 (void *)&cmd_flow_director_flexpayload,
8283 (void *)&cmd_flow_director_flexpayload_port_id,
8284 (void *)&cmd_flow_director_flexpayload_payload_layer,
8285 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8290 /* *** Classification Filters Control *** */
8291 /* *** Get symmetric hash enable per port *** */
8292 struct cmd_get_sym_hash_ena_per_port_result {
8293 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8298 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8299 __rte_unused struct cmdline *cl,
8300 __rte_unused void *data)
8302 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8303 struct rte_eth_hash_filter_info info;
8306 if (rte_eth_dev_filter_supported(res->port_id,
8307 RTE_ETH_FILTER_HASH) < 0) {
8308 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8313 memset(&info, 0, sizeof(info));
8314 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8315 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8316 RTE_ETH_FILTER_GET, &info);
8319 printf("Cannot get symmetric hash enable per port "
8320 "on port %u\n", res->port_id);
8324 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8325 "enabled" : "disabled", res->port_id);
8328 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8329 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8330 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8331 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8332 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8335 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8336 .f = cmd_get_sym_hash_per_port_parsed,
8338 .help_str = "get_sym_hash_ena_per_port port_id",
8340 (void *)&cmd_get_sym_hash_ena_per_port_all,
8341 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8346 /* *** Set symmetric hash enable per port *** */
8347 struct cmd_set_sym_hash_ena_per_port_result {
8348 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8349 cmdline_fixed_string_t enable;
8354 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8355 __rte_unused struct cmdline *cl,
8356 __rte_unused void *data)
8358 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8359 struct rte_eth_hash_filter_info info;
8362 if (rte_eth_dev_filter_supported(res->port_id,
8363 RTE_ETH_FILTER_HASH) < 0) {
8364 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8369 memset(&info, 0, sizeof(info));
8370 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8371 if (!strcmp(res->enable, "enable"))
8372 info.info.enable = 1;
8373 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8374 RTE_ETH_FILTER_SET, &info);
8376 printf("Cannot set symmetric hash enable per port on "
8377 "port %u\n", res->port_id);
8380 printf("Symmetric hash has been set to %s on port %u\n",
8381 res->enable, res->port_id);
8384 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8385 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8386 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8387 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8388 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8390 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8391 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8392 enable, "enable#disable");
8394 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8395 .f = cmd_set_sym_hash_per_port_parsed,
8397 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8399 (void *)&cmd_set_sym_hash_ena_per_port_all,
8400 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8401 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8406 /* Get global config of hash function */
8407 struct cmd_get_hash_global_config_result {
8408 cmdline_fixed_string_t get_hash_global_config;
8413 flowtype_to_str(uint16_t ftype)
8420 {"ipv4", RTE_ETH_FLOW_IPV4},
8421 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8422 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8423 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8424 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8425 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8426 {"ipv6", RTE_ETH_FLOW_IPV6},
8427 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8428 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8429 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8430 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8431 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8432 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8435 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8436 if (ftype_table[i].ftype == ftype)
8437 return ftype_table[i].str;
8444 cmd_get_hash_global_config_parsed(void *parsed_result,
8445 __rte_unused struct cmdline *cl,
8446 __rte_unused void *data)
8448 struct cmd_get_hash_global_config_result *res = parsed_result;
8449 struct rte_eth_hash_filter_info info;
8450 uint32_t idx, offset;
8455 if (rte_eth_dev_filter_supported(res->port_id,
8456 RTE_ETH_FILTER_HASH) < 0) {
8457 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8462 memset(&info, 0, sizeof(info));
8463 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8464 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8465 RTE_ETH_FILTER_GET, &info);
8467 printf("Cannot get hash global configurations by port %d\n",
8472 switch (info.info.global_conf.hash_func) {
8473 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8474 printf("Hash function is Toeplitz\n");
8476 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8477 printf("Hash function is Simple XOR\n");
8480 printf("Unknown hash function\n");
8484 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
8485 idx = i / UINT32_BIT;
8486 offset = i % UINT32_BIT;
8487 if (!(info.info.global_conf.valid_bit_mask[idx] &
8490 str = flowtype_to_str(i);
8493 printf("Symmetric hash is %s globally for flow type %s "
8495 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8496 (1UL << offset)) ? "enabled" : "disabled"), str,
8501 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8502 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8503 get_hash_global_config, "get_hash_global_config");
8504 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8505 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8508 cmdline_parse_inst_t cmd_get_hash_global_config = {
8509 .f = cmd_get_hash_global_config_parsed,
8511 .help_str = "get_hash_global_config port_id",
8513 (void *)&cmd_get_hash_global_config_all,
8514 (void *)&cmd_get_hash_global_config_port_id,
8519 /* Set global config of hash function */
8520 struct cmd_set_hash_global_config_result {
8521 cmdline_fixed_string_t set_hash_global_config;
8523 cmdline_fixed_string_t hash_func;
8524 cmdline_fixed_string_t flow_type;
8525 cmdline_fixed_string_t enable;
8529 cmd_set_hash_global_config_parsed(void *parsed_result,
8530 __rte_unused struct cmdline *cl,
8531 __rte_unused void *data)
8533 struct cmd_set_hash_global_config_result *res = parsed_result;
8534 struct rte_eth_hash_filter_info info;
8535 uint32_t ftype, idx, offset;
8538 if (rte_eth_dev_filter_supported(res->port_id,
8539 RTE_ETH_FILTER_HASH) < 0) {
8540 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8544 memset(&info, 0, sizeof(info));
8545 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8546 if (!strcmp(res->hash_func, "toeplitz"))
8547 info.info.global_conf.hash_func =
8548 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8549 else if (!strcmp(res->hash_func, "simple_xor"))
8550 info.info.global_conf.hash_func =
8551 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8552 else if (!strcmp(res->hash_func, "default"))
8553 info.info.global_conf.hash_func =
8554 RTE_ETH_HASH_FUNCTION_DEFAULT;
8556 ftype = str2flowtype(res->flow_type);
8557 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8558 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8559 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8560 if (!strcmp(res->enable, "enable"))
8561 info.info.global_conf.sym_hash_enable_mask[idx] |=
8563 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8564 RTE_ETH_FILTER_SET, &info);
8566 printf("Cannot set global hash configurations by port %d\n",
8569 printf("Global hash configurations have been set "
8570 "succcessfully by port %d\n", res->port_id);
8573 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8574 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8575 set_hash_global_config, "set_hash_global_config");
8576 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8577 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8579 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8580 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8581 hash_func, "toeplitz#simple_xor#default");
8582 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8583 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8585 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
8586 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
8587 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8588 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8589 enable, "enable#disable");
8591 cmdline_parse_inst_t cmd_set_hash_global_config = {
8592 .f = cmd_set_hash_global_config_parsed,
8594 .help_str = "set_hash_global_config port_id "
8595 "toeplitz|simple_xor|default "
8596 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
8597 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
8600 (void *)&cmd_set_hash_global_config_all,
8601 (void *)&cmd_set_hash_global_config_port_id,
8602 (void *)&cmd_set_hash_global_config_hash_func,
8603 (void *)&cmd_set_hash_global_config_flow_type,
8604 (void *)&cmd_set_hash_global_config_enable,
8609 /* ******************************************************************************** */
8611 /* list of instructions */
8612 cmdline_parse_ctx_t main_ctx[] = {
8613 (cmdline_parse_inst_t *)&cmd_help_brief,
8614 (cmdline_parse_inst_t *)&cmd_help_long,
8615 (cmdline_parse_inst_t *)&cmd_quit,
8616 (cmdline_parse_inst_t *)&cmd_showport,
8617 (cmdline_parse_inst_t *)&cmd_showportall,
8618 (cmdline_parse_inst_t *)&cmd_showcfg,
8619 (cmdline_parse_inst_t *)&cmd_start,
8620 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8621 (cmdline_parse_inst_t *)&cmd_set_link_up,
8622 (cmdline_parse_inst_t *)&cmd_set_link_down,
8623 (cmdline_parse_inst_t *)&cmd_reset,
8624 (cmdline_parse_inst_t *)&cmd_set_numbers,
8625 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8626 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8627 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8628 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8629 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8630 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8631 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8632 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8633 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8634 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8635 (cmdline_parse_inst_t *)&cmd_set_link_check,
8636 #ifdef RTE_NIC_BYPASS
8637 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8638 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8639 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8640 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8642 #ifdef RTE_LIBRTE_PMD_BOND
8643 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8644 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8645 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8646 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8647 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8648 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8649 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8650 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8651 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8653 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8654 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8655 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8656 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8657 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8658 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8659 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8660 (cmdline_parse_inst_t *)&cmd_csum_set,
8661 (cmdline_parse_inst_t *)&cmd_csum_show,
8662 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8663 (cmdline_parse_inst_t *)&cmd_tso_set,
8664 (cmdline_parse_inst_t *)&cmd_tso_show,
8665 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8666 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8667 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8668 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8669 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8670 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8671 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8672 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8673 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8674 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8675 (cmdline_parse_inst_t *)&cmd_config_dcb,
8676 (cmdline_parse_inst_t *)&cmd_read_reg,
8677 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8678 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8679 (cmdline_parse_inst_t *)&cmd_write_reg,
8680 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8681 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8682 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8683 (cmdline_parse_inst_t *)&cmd_stop,
8684 (cmdline_parse_inst_t *)&cmd_mac_addr,
8685 (cmdline_parse_inst_t *)&cmd_set_qmap,
8686 (cmdline_parse_inst_t *)&cmd_operate_port,
8687 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8688 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8689 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8690 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8691 (cmdline_parse_inst_t *)&cmd_config_mtu,
8692 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8693 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8694 (cmdline_parse_inst_t *)&cmd_config_rss,
8695 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8696 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8697 (cmdline_parse_inst_t *)&cmd_showport_reta,
8698 (cmdline_parse_inst_t *)&cmd_config_burst,
8699 (cmdline_parse_inst_t *)&cmd_config_thresh,
8700 (cmdline_parse_inst_t *)&cmd_config_threshold,
8701 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8702 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8703 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8704 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8705 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8706 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8707 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8708 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8709 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8710 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8711 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8712 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8713 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8714 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8715 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8716 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8717 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8718 (cmdline_parse_inst_t *)&cmd_dump,
8719 (cmdline_parse_inst_t *)&cmd_dump_one,
8720 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
8721 (cmdline_parse_inst_t *)&cmd_syn_filter,
8722 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
8723 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
8724 (cmdline_parse_inst_t *)&cmd_flex_filter,
8725 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8726 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8727 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8728 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8729 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
8730 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8731 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8732 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
8733 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
8734 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
8735 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
8739 /* prompt function, called from main on MASTER lcore */
8745 /* initialize non-constant commands */
8746 cmd_set_fwd_mode_init();
8748 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8752 cmdline_interact(cl);
8753 cmdline_stdin_exit(cl);
8757 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8759 if (id < nb_ports) {
8760 /* check if need_reconfig has been set to 1 */
8761 if (ports[id].need_reconfig == 0)
8762 ports[id].need_reconfig = dev;
8763 /* check if need_reconfig_queues has been set to 1 */
8764 if (ports[id].need_reconfig_queues == 0)
8765 ports[id].need_reconfig_queues = queue;
8769 for (pid = 0; pid < nb_ports; pid++) {
8770 /* check if need_reconfig has been set to 1 */
8771 if (ports[pid].need_reconfig == 0)
8772 ports[pid].need_reconfig = dev;
8773 /* check if need_reconfig_queues has been set to 1 */
8774 if (ports[pid].need_reconfig_queues == 0)
8775 ports[pid].need_reconfig_queues = queue;
8780 #ifdef RTE_NIC_BYPASS
8782 bypass_is_supported(portid_t port_id)
8784 struct rte_port *port;
8785 struct rte_pci_id *pci_id;
8787 if (port_id >= nb_ports) {
8788 printf("\tPort id must be less than %d.\n", nb_ports);
8792 /* Get the device id. */
8793 port = &ports[port_id];
8794 pci_id = &port->dev_info.pci_dev->id;
8796 /* Check if NIC supports bypass. */
8797 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8801 printf("\tBypass not supported for port_id = %d.\n", port_id);