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) (vxlan|nvgre) (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) (vxlan|nvgre) (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 attach (ident)\n"
517 " Attach physical or virtual dev by pci address or virtual device name\n\n"
519 "port detach (port_id)\n"
520 " Detach physical or virtual dev by port_id\n\n"
522 "port config (port_id|all)"
523 " speed (10|100|1000|10000|40000|auto)"
524 " duplex (half|full|auto)\n"
525 " Set speed and duplex for all ports or port_id\n\n"
527 "port config all (rxq|txq|rxd|txd) (value)\n"
528 " Set number for rxq/txq/rxd/txd.\n\n"
530 "port config all max-pkt-len (value)\n"
531 " Set the max packet length.\n\n"
533 "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
534 "hw-vlan-strip|hw-vlan-extend|drop-en)"
536 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
539 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
540 " Set the RSS mode.\n\n"
542 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
543 " Set the RSS redirection table.\n\n"
545 "port config (port_id) dcb vt (on|off) (traffic_class)"
547 " Set the DCB mode.\n\n"
549 "port config all burst (value)\n"
550 " Set the number of packets per burst.\n\n"
552 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
554 " Set the ring prefetch/host/writeback threshold"
555 " for tx/rx queue.\n\n"
557 "port config all (txfreet|txrst|rxfreet) (value)\n"
558 " Set free threshold for rx/tx, or set"
559 " tx rs bit threshold.\n\n"
560 "port config mtu X value\n"
561 " Set the MTU of port X to a given value\n\n"
563 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
564 " Start/stop a rx/tx queue of port X. Only take effect"
565 " when port X is started\n"
569 if (show_all || !strcmp(res->section, "registers")) {
577 "read reg (port_id) (address)\n"
578 " Display value of a port register.\n\n"
580 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
581 " Display a port register bit field.\n\n"
583 "read regbit (port_id) (address) (bit_x)\n"
584 " Display a single port register bit.\n\n"
586 "write reg (port_id) (address) (value)\n"
587 " Set value of a port register.\n\n"
589 "write regfield (port_id) (address) (bit_x) (bit_y)"
591 " Set bit field of a port register.\n\n"
593 "write regbit (port_id) (address) (bit_x) (value)\n"
594 " Set single bit value of a port register.\n\n"
597 if (show_all || !strcmp(res->section, "filters")) {
605 "ethertype_filter (port_id) (add|del)"
606 " (mac_addr|mac_ignr) (mac_address) ethertype"
607 " (ether_type) (drop|fwd) queue (queue_id)\n"
608 " Add/Del an ethertype filter.\n\n"
610 "2tuple_filter (port_id) (add|del)"
611 " dst_port (dst_port_value) protocol (protocol_value)"
612 " mask (mask_value) tcp_flags (tcp_flags_value)"
613 " priority (prio_value) queue (queue_id)\n"
614 " Add/Del a 2tuple filter.\n\n"
616 "5tuple_filter (port_id) (add|del)"
617 " dst_ip (dst_address) src_ip (src_address)"
618 " dst_port (dst_port_value) src_port (src_port_value)"
619 " protocol (protocol_value)"
620 " mask (mask_value) tcp_flags (tcp_flags_value)"
621 " priority (prio_value) queue (queue_id)\n"
622 " Add/Del a 5tuple filter.\n\n"
624 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
625 " Add/Del syn filter.\n\n"
627 "flex_filter (port_id) (add|del) len (len_value)"
628 " bytes (bytes_value) mask (mask_value)"
629 " priority (prio_value) queue (queue_id)\n"
630 " Add/Del a flex filter.\n\n"
632 "flow_director_filter (port_id) (add|del|update)"
633 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
634 " src (src_ip_address) dst (dst_ip_address)"
635 " vlan (vlan_value) flexbytes (flexbytes_value)"
636 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
637 " Add/Del an IP type flow director filter.\n\n"
639 "flow_director_filter (port_id) (add|del|update)"
640 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
641 " src (src_ip_address) (src_port)"
642 " dst (dst_ip_address) (dst_port)"
643 " vlan (vlan_value) flexbytes (flexbytes_value)"
644 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
645 " Add/Del an UDP/TCP type flow director filter.\n\n"
647 "flow_director_filter (port_id) (add|del|update)"
648 " flow (ipv4-sctp|ipv6-sctp)"
649 " src (src_ip_address) (src_port)"
650 " dst (dst_ip_address) (dst_port)"
651 " tag (verification_tag) vlan (vlan_value)"
652 " flexbytes (flexbytes_value) (drop|fwd)"
653 " queue (queue_id) fd_id (fd_id_value)\n"
654 " Add/Del a SCTP type flow director filter.\n\n"
656 "flush_flow_director (port_id)\n"
657 " Flush all flow director entries of a device.\n\n"
659 "flow_director_mask (port_id) vlan (vlan_value)"
660 " src_mask (ipv4_src) (ipv6_src) (src_port)"
661 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
662 " Set flow director mask.\n\n"
664 "flow_director_flex_mask (port_id)"
665 " flow (raw|ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
666 " flow (raw|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
667 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|all)"
669 " Configure mask of flex payload.\n\n"
671 "flow_director_flex_payload (port_id)"
672 " (raw|l2|l3|l4) (config)\n"
673 " Configure flex payload selection.\n\n"
675 "get_sym_hash_ena_per_port (port_id)\n"
676 " get symmetric hash enable configuration per port.\n\n"
678 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
679 " set symmetric hash enable configuration per port"
680 " to enable or disable.\n\n"
682 "get_hash_global_config (port_id)\n"
683 " Get the global configurations of hash filters.\n\n"
685 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
686 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
687 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
688 " (enable|disable)\n"
689 " Set the global configurations of hash filters.\n\n"
694 cmdline_parse_token_string_t cmd_help_long_help =
695 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
697 cmdline_parse_token_string_t cmd_help_long_section =
698 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
699 "all#control#display#config#"
700 "ports#registers#filters");
702 cmdline_parse_inst_t cmd_help_long = {
703 .f = cmd_help_long_parsed,
705 .help_str = "show help",
707 (void *)&cmd_help_long_help,
708 (void *)&cmd_help_long_section,
714 /* *** start/stop/close all ports *** */
715 struct cmd_operate_port_result {
716 cmdline_fixed_string_t keyword;
717 cmdline_fixed_string_t name;
718 cmdline_fixed_string_t value;
721 static void cmd_operate_port_parsed(void *parsed_result,
722 __attribute__((unused)) struct cmdline *cl,
723 __attribute__((unused)) void *data)
725 struct cmd_operate_port_result *res = parsed_result;
727 if (!strcmp(res->name, "start"))
728 start_port(RTE_PORT_ALL);
729 else if (!strcmp(res->name, "stop"))
730 stop_port(RTE_PORT_ALL);
731 else if (!strcmp(res->name, "close"))
732 close_port(RTE_PORT_ALL);
734 printf("Unknown parameter\n");
737 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
738 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
740 cmdline_parse_token_string_t cmd_operate_port_all_port =
741 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
743 cmdline_parse_token_string_t cmd_operate_port_all_all =
744 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
746 cmdline_parse_inst_t cmd_operate_port = {
747 .f = cmd_operate_port_parsed,
749 .help_str = "port start|stop|close all: start/stop/close all ports",
751 (void *)&cmd_operate_port_all_cmd,
752 (void *)&cmd_operate_port_all_port,
753 (void *)&cmd_operate_port_all_all,
758 /* *** start/stop/close specific port *** */
759 struct cmd_operate_specific_port_result {
760 cmdline_fixed_string_t keyword;
761 cmdline_fixed_string_t name;
765 static void cmd_operate_specific_port_parsed(void *parsed_result,
766 __attribute__((unused)) struct cmdline *cl,
767 __attribute__((unused)) void *data)
769 struct cmd_operate_specific_port_result *res = parsed_result;
771 if (!strcmp(res->name, "start"))
772 start_port(res->value);
773 else if (!strcmp(res->name, "stop"))
774 stop_port(res->value);
775 else if (!strcmp(res->name, "close"))
776 close_port(res->value);
778 printf("Unknown parameter\n");
781 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
782 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
784 cmdline_parse_token_string_t cmd_operate_specific_port_port =
785 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
786 name, "start#stop#close");
787 cmdline_parse_token_num_t cmd_operate_specific_port_id =
788 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
791 cmdline_parse_inst_t cmd_operate_specific_port = {
792 .f = cmd_operate_specific_port_parsed,
794 .help_str = "port start|stop|close X: start/stop/close port X",
796 (void *)&cmd_operate_specific_port_cmd,
797 (void *)&cmd_operate_specific_port_port,
798 (void *)&cmd_operate_specific_port_id,
803 /* *** attach a specified port *** */
804 struct cmd_operate_attach_port_result {
805 cmdline_fixed_string_t port;
806 cmdline_fixed_string_t keyword;
807 cmdline_fixed_string_t identifier;
810 static void cmd_operate_attach_port_parsed(void *parsed_result,
811 __attribute__((unused)) struct cmdline *cl,
812 __attribute__((unused)) void *data)
814 struct cmd_operate_attach_port_result *res = parsed_result;
816 if (!strcmp(res->keyword, "attach"))
817 attach_port(res->identifier);
819 printf("Unknown parameter\n");
822 cmdline_parse_token_string_t cmd_operate_attach_port_port =
823 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
825 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
826 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
828 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
829 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
832 cmdline_parse_inst_t cmd_operate_attach_port = {
833 .f = cmd_operate_attach_port_parsed,
835 .help_str = "port attach identifier, "
836 "identifier: pci address or virtual dev name",
838 (void *)&cmd_operate_attach_port_port,
839 (void *)&cmd_operate_attach_port_keyword,
840 (void *)&cmd_operate_attach_port_identifier,
845 /* *** detach a specified port *** */
846 struct cmd_operate_detach_port_result {
847 cmdline_fixed_string_t port;
848 cmdline_fixed_string_t keyword;
852 static void cmd_operate_detach_port_parsed(void *parsed_result,
853 __attribute__((unused)) struct cmdline *cl,
854 __attribute__((unused)) void *data)
856 struct cmd_operate_detach_port_result *res = parsed_result;
858 if (!strcmp(res->keyword, "detach"))
859 detach_port(res->port_id);
861 printf("Unknown parameter\n");
864 cmdline_parse_token_string_t cmd_operate_detach_port_port =
865 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
867 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
868 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
870 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
871 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
874 cmdline_parse_inst_t cmd_operate_detach_port = {
875 .f = cmd_operate_detach_port_parsed,
877 .help_str = "port detach port_id",
879 (void *)&cmd_operate_detach_port_port,
880 (void *)&cmd_operate_detach_port_keyword,
881 (void *)&cmd_operate_detach_port_port_id,
886 /* *** configure speed for all ports *** */
887 struct cmd_config_speed_all {
888 cmdline_fixed_string_t port;
889 cmdline_fixed_string_t keyword;
890 cmdline_fixed_string_t all;
891 cmdline_fixed_string_t item1;
892 cmdline_fixed_string_t item2;
893 cmdline_fixed_string_t value1;
894 cmdline_fixed_string_t value2;
898 cmd_config_speed_all_parsed(void *parsed_result,
899 __attribute__((unused)) struct cmdline *cl,
900 __attribute__((unused)) void *data)
902 struct cmd_config_speed_all *res = parsed_result;
903 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
904 uint16_t link_duplex = 0;
907 if (!all_ports_stopped()) {
908 printf("Please stop all ports first\n");
912 if (!strcmp(res->value1, "10"))
913 link_speed = ETH_LINK_SPEED_10;
914 else if (!strcmp(res->value1, "100"))
915 link_speed = ETH_LINK_SPEED_100;
916 else if (!strcmp(res->value1, "1000"))
917 link_speed = ETH_LINK_SPEED_1000;
918 else if (!strcmp(res->value1, "10000"))
919 link_speed = ETH_LINK_SPEED_10G;
920 else if (!strcmp(res->value1, "40000"))
921 link_speed = ETH_LINK_SPEED_40G;
922 else if (!strcmp(res->value1, "auto"))
923 link_speed = ETH_LINK_SPEED_AUTONEG;
925 printf("Unknown parameter\n");
929 if (!strcmp(res->value2, "half"))
930 link_duplex = ETH_LINK_HALF_DUPLEX;
931 else if (!strcmp(res->value2, "full"))
932 link_duplex = ETH_LINK_FULL_DUPLEX;
933 else if (!strcmp(res->value2, "auto"))
934 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
936 printf("Unknown parameter\n");
940 FOREACH_PORT(pid, ports) {
941 ports[pid].dev_conf.link_speed = link_speed;
942 ports[pid].dev_conf.link_duplex = link_duplex;
945 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
948 cmdline_parse_token_string_t cmd_config_speed_all_port =
949 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
950 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
951 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
953 cmdline_parse_token_string_t cmd_config_speed_all_all =
954 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
955 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
956 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
957 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
958 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
959 "10#100#1000#10000#40000#auto");
960 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
961 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
962 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
963 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
966 cmdline_parse_inst_t cmd_config_speed_all = {
967 .f = cmd_config_speed_all_parsed,
969 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
972 (void *)&cmd_config_speed_all_port,
973 (void *)&cmd_config_speed_all_keyword,
974 (void *)&cmd_config_speed_all_all,
975 (void *)&cmd_config_speed_all_item1,
976 (void *)&cmd_config_speed_all_value1,
977 (void *)&cmd_config_speed_all_item2,
978 (void *)&cmd_config_speed_all_value2,
983 /* *** configure speed for specific port *** */
984 struct cmd_config_speed_specific {
985 cmdline_fixed_string_t port;
986 cmdline_fixed_string_t keyword;
988 cmdline_fixed_string_t item1;
989 cmdline_fixed_string_t item2;
990 cmdline_fixed_string_t value1;
991 cmdline_fixed_string_t value2;
995 cmd_config_speed_specific_parsed(void *parsed_result,
996 __attribute__((unused)) struct cmdline *cl,
997 __attribute__((unused)) void *data)
999 struct cmd_config_speed_specific *res = parsed_result;
1000 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1001 uint16_t link_duplex = 0;
1003 if (!all_ports_stopped()) {
1004 printf("Please stop all ports first\n");
1008 if (port_id_is_invalid(res->id, ENABLED_WARN))
1011 if (!strcmp(res->value1, "10"))
1012 link_speed = ETH_LINK_SPEED_10;
1013 else if (!strcmp(res->value1, "100"))
1014 link_speed = ETH_LINK_SPEED_100;
1015 else if (!strcmp(res->value1, "1000"))
1016 link_speed = ETH_LINK_SPEED_1000;
1017 else if (!strcmp(res->value1, "10000"))
1018 link_speed = ETH_LINK_SPEED_10000;
1019 else if (!strcmp(res->value1, "40000"))
1020 link_speed = ETH_LINK_SPEED_40G;
1021 else if (!strcmp(res->value1, "auto"))
1022 link_speed = ETH_LINK_SPEED_AUTONEG;
1024 printf("Unknown parameter\n");
1028 if (!strcmp(res->value2, "half"))
1029 link_duplex = ETH_LINK_HALF_DUPLEX;
1030 else if (!strcmp(res->value2, "full"))
1031 link_duplex = ETH_LINK_FULL_DUPLEX;
1032 else if (!strcmp(res->value2, "auto"))
1033 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1035 printf("Unknown parameter\n");
1039 ports[res->id].dev_conf.link_speed = link_speed;
1040 ports[res->id].dev_conf.link_duplex = link_duplex;
1042 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1046 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1047 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1049 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1050 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1052 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1053 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1054 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1055 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1057 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1058 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1059 "10#100#1000#10000#40000#auto");
1060 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1061 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1063 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1064 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1067 cmdline_parse_inst_t cmd_config_speed_specific = {
1068 .f = cmd_config_speed_specific_parsed,
1070 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1073 (void *)&cmd_config_speed_specific_port,
1074 (void *)&cmd_config_speed_specific_keyword,
1075 (void *)&cmd_config_speed_specific_id,
1076 (void *)&cmd_config_speed_specific_item1,
1077 (void *)&cmd_config_speed_specific_value1,
1078 (void *)&cmd_config_speed_specific_item2,
1079 (void *)&cmd_config_speed_specific_value2,
1084 /* *** configure txq/rxq, txd/rxd *** */
1085 struct cmd_config_rx_tx {
1086 cmdline_fixed_string_t port;
1087 cmdline_fixed_string_t keyword;
1088 cmdline_fixed_string_t all;
1089 cmdline_fixed_string_t name;
1094 cmd_config_rx_tx_parsed(void *parsed_result,
1095 __attribute__((unused)) struct cmdline *cl,
1096 __attribute__((unused)) void *data)
1098 struct cmd_config_rx_tx *res = parsed_result;
1100 if (!all_ports_stopped()) {
1101 printf("Please stop all ports first\n");
1105 if (!strcmp(res->name, "rxq")) {
1106 if (res->value <= 0) {
1107 printf("rxq %d invalid - must be > 0\n", res->value);
1110 nb_rxq = res->value;
1112 else if (!strcmp(res->name, "txq")) {
1113 if (res->value <= 0) {
1114 printf("txq %d invalid - must be > 0\n", res->value);
1117 nb_txq = res->value;
1119 else if (!strcmp(res->name, "rxd")) {
1120 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1121 printf("rxd %d invalid - must be > 0 && <= %d\n",
1122 res->value, RTE_TEST_RX_DESC_MAX);
1125 nb_rxd = res->value;
1126 } else if (!strcmp(res->name, "txd")) {
1127 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1128 printf("txd %d invalid - must be > 0 && <= %d\n",
1129 res->value, RTE_TEST_TX_DESC_MAX);
1132 nb_txd = res->value;
1134 printf("Unknown parameter\n");
1140 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1143 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1145 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1146 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1147 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1148 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1149 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1152 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1153 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1155 cmdline_parse_inst_t cmd_config_rx_tx = {
1156 .f = cmd_config_rx_tx_parsed,
1158 .help_str = "port config all rxq|txq|rxd|txd value",
1160 (void *)&cmd_config_rx_tx_port,
1161 (void *)&cmd_config_rx_tx_keyword,
1162 (void *)&cmd_config_rx_tx_all,
1163 (void *)&cmd_config_rx_tx_name,
1164 (void *)&cmd_config_rx_tx_value,
1169 /* *** config max packet length *** */
1170 struct cmd_config_max_pkt_len_result {
1171 cmdline_fixed_string_t port;
1172 cmdline_fixed_string_t keyword;
1173 cmdline_fixed_string_t all;
1174 cmdline_fixed_string_t name;
1179 cmd_config_max_pkt_len_parsed(void *parsed_result,
1180 __attribute__((unused)) struct cmdline *cl,
1181 __attribute__((unused)) void *data)
1183 struct cmd_config_max_pkt_len_result *res = parsed_result;
1185 if (!all_ports_stopped()) {
1186 printf("Please stop all ports first\n");
1190 if (!strcmp(res->name, "max-pkt-len")) {
1191 if (res->value < ETHER_MIN_LEN) {
1192 printf("max-pkt-len can not be less than %d\n",
1196 if (res->value == rx_mode.max_rx_pkt_len)
1199 rx_mode.max_rx_pkt_len = res->value;
1200 if (res->value > ETHER_MAX_LEN)
1201 rx_mode.jumbo_frame = 1;
1203 rx_mode.jumbo_frame = 0;
1205 printf("Unknown parameter\n");
1211 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1214 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1215 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1217 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1218 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1220 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1221 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1223 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1224 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1226 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1227 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1230 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1231 .f = cmd_config_max_pkt_len_parsed,
1233 .help_str = "port config all max-pkt-len value",
1235 (void *)&cmd_config_max_pkt_len_port,
1236 (void *)&cmd_config_max_pkt_len_keyword,
1237 (void *)&cmd_config_max_pkt_len_all,
1238 (void *)&cmd_config_max_pkt_len_name,
1239 (void *)&cmd_config_max_pkt_len_value,
1244 /* *** configure port MTU *** */
1245 struct cmd_config_mtu_result {
1246 cmdline_fixed_string_t port;
1247 cmdline_fixed_string_t keyword;
1248 cmdline_fixed_string_t mtu;
1254 cmd_config_mtu_parsed(void *parsed_result,
1255 __attribute__((unused)) struct cmdline *cl,
1256 __attribute__((unused)) void *data)
1258 struct cmd_config_mtu_result *res = parsed_result;
1260 if (res->value < ETHER_MIN_LEN) {
1261 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1264 port_mtu_set(res->port_id, res->value);
1267 cmdline_parse_token_string_t cmd_config_mtu_port =
1268 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1270 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1271 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1273 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1274 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1276 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1277 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1278 cmdline_parse_token_num_t cmd_config_mtu_value =
1279 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1281 cmdline_parse_inst_t cmd_config_mtu = {
1282 .f = cmd_config_mtu_parsed,
1284 .help_str = "port config mtu value",
1286 (void *)&cmd_config_mtu_port,
1287 (void *)&cmd_config_mtu_keyword,
1288 (void *)&cmd_config_mtu_mtu,
1289 (void *)&cmd_config_mtu_port_id,
1290 (void *)&cmd_config_mtu_value,
1295 /* *** configure rx mode *** */
1296 struct cmd_config_rx_mode_flag {
1297 cmdline_fixed_string_t port;
1298 cmdline_fixed_string_t keyword;
1299 cmdline_fixed_string_t all;
1300 cmdline_fixed_string_t name;
1301 cmdline_fixed_string_t value;
1305 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1306 __attribute__((unused)) struct cmdline *cl,
1307 __attribute__((unused)) void *data)
1309 struct cmd_config_rx_mode_flag *res = parsed_result;
1311 if (!all_ports_stopped()) {
1312 printf("Please stop all ports first\n");
1316 if (!strcmp(res->name, "crc-strip")) {
1317 if (!strcmp(res->value, "on"))
1318 rx_mode.hw_strip_crc = 1;
1319 else if (!strcmp(res->value, "off"))
1320 rx_mode.hw_strip_crc = 0;
1322 printf("Unknown parameter\n");
1325 } else if (!strcmp(res->name, "rx-cksum")) {
1326 if (!strcmp(res->value, "on"))
1327 rx_mode.hw_ip_checksum = 1;
1328 else if (!strcmp(res->value, "off"))
1329 rx_mode.hw_ip_checksum = 0;
1331 printf("Unknown parameter\n");
1334 } else if (!strcmp(res->name, "hw-vlan")) {
1335 if (!strcmp(res->value, "on")) {
1336 rx_mode.hw_vlan_filter = 1;
1337 rx_mode.hw_vlan_strip = 1;
1339 else if (!strcmp(res->value, "off")) {
1340 rx_mode.hw_vlan_filter = 0;
1341 rx_mode.hw_vlan_strip = 0;
1344 printf("Unknown parameter\n");
1347 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1348 if (!strcmp(res->value, "on"))
1349 rx_mode.hw_vlan_filter = 1;
1350 else if (!strcmp(res->value, "off"))
1351 rx_mode.hw_vlan_filter = 0;
1353 printf("Unknown parameter\n");
1356 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1357 if (!strcmp(res->value, "on"))
1358 rx_mode.hw_vlan_strip = 1;
1359 else if (!strcmp(res->value, "off"))
1360 rx_mode.hw_vlan_strip = 0;
1362 printf("Unknown parameter\n");
1365 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1366 if (!strcmp(res->value, "on"))
1367 rx_mode.hw_vlan_extend = 1;
1368 else if (!strcmp(res->value, "off"))
1369 rx_mode.hw_vlan_extend = 0;
1371 printf("Unknown parameter\n");
1374 } else if (!strcmp(res->name, "drop-en")) {
1375 if (!strcmp(res->value, "on"))
1377 else if (!strcmp(res->value, "off"))
1380 printf("Unknown parameter\n");
1384 printf("Unknown parameter\n");
1390 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1393 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1395 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1398 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1400 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1401 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1402 "crc-strip#rx-cksum#hw-vlan#"
1403 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1404 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1408 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1409 .f = cmd_config_rx_mode_flag_parsed,
1411 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1412 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1414 (void *)&cmd_config_rx_mode_flag_port,
1415 (void *)&cmd_config_rx_mode_flag_keyword,
1416 (void *)&cmd_config_rx_mode_flag_all,
1417 (void *)&cmd_config_rx_mode_flag_name,
1418 (void *)&cmd_config_rx_mode_flag_value,
1423 /* *** configure rss *** */
1424 struct cmd_config_rss {
1425 cmdline_fixed_string_t port;
1426 cmdline_fixed_string_t keyword;
1427 cmdline_fixed_string_t all;
1428 cmdline_fixed_string_t name;
1429 cmdline_fixed_string_t value;
1433 cmd_config_rss_parsed(void *parsed_result,
1434 __attribute__((unused)) struct cmdline *cl,
1435 __attribute__((unused)) void *data)
1437 struct cmd_config_rss *res = parsed_result;
1438 struct rte_eth_rss_conf rss_conf;
1441 if (!strcmp(res->value, "all"))
1442 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1443 ETH_RSS_UDP | ETH_RSS_SCTP |
1445 else if (!strcmp(res->value, "ip"))
1446 rss_conf.rss_hf = ETH_RSS_IP;
1447 else if (!strcmp(res->value, "udp"))
1448 rss_conf.rss_hf = ETH_RSS_UDP;
1449 else if (!strcmp(res->value, "tcp"))
1450 rss_conf.rss_hf = ETH_RSS_TCP;
1451 else if (!strcmp(res->value, "sctp"))
1452 rss_conf.rss_hf = ETH_RSS_SCTP;
1453 else if (!strcmp(res->value, "ether"))
1454 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1455 else if (!strcmp(res->value, "none"))
1456 rss_conf.rss_hf = 0;
1458 printf("Unknown parameter\n");
1461 rss_conf.rss_key = NULL;
1462 for (i = 0; i < rte_eth_dev_count(); i++)
1463 rte_eth_dev_rss_hash_update(i, &rss_conf);
1466 cmdline_parse_token_string_t cmd_config_rss_port =
1467 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1468 cmdline_parse_token_string_t cmd_config_rss_keyword =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1470 cmdline_parse_token_string_t cmd_config_rss_all =
1471 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1472 cmdline_parse_token_string_t cmd_config_rss_name =
1473 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1474 cmdline_parse_token_string_t cmd_config_rss_value =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1476 "all#ip#tcp#udp#sctp#ether#none");
1478 cmdline_parse_inst_t cmd_config_rss = {
1479 .f = cmd_config_rss_parsed,
1481 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1483 (void *)&cmd_config_rss_port,
1484 (void *)&cmd_config_rss_keyword,
1485 (void *)&cmd_config_rss_all,
1486 (void *)&cmd_config_rss_name,
1487 (void *)&cmd_config_rss_value,
1492 /* *** configure rss hash key *** */
1493 struct cmd_config_rss_hash_key {
1494 cmdline_fixed_string_t port;
1495 cmdline_fixed_string_t config;
1497 cmdline_fixed_string_t rss_hash_key;
1498 cmdline_fixed_string_t key;
1501 #define RSS_HASH_KEY_LENGTH 40
1503 hexa_digit_to_value(char hexa_digit)
1505 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1506 return (uint8_t) (hexa_digit - '0');
1507 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1508 return (uint8_t) ((hexa_digit - 'a') + 10);
1509 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1510 return (uint8_t) ((hexa_digit - 'A') + 10);
1511 /* Invalid hexa digit */
1516 parse_and_check_key_hexa_digit(char *key, int idx)
1520 hexa_v = hexa_digit_to_value(key[idx]);
1522 printf("invalid key: character %c at position %d is not a "
1523 "valid hexa digit\n", key[idx], idx);
1528 cmd_config_rss_hash_key_parsed(void *parsed_result,
1529 __attribute__((unused)) struct cmdline *cl,
1530 __attribute__((unused)) void *data)
1532 struct cmd_config_rss_hash_key *res = parsed_result;
1533 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1538 /* Check the length of the RSS hash key */
1539 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1540 printf("key length: %d invalid - key must be a string of %d"
1541 "hexa-decimal numbers\n", (int) strlen(res->key),
1542 RSS_HASH_KEY_LENGTH * 2);
1545 /* Translate RSS hash key into binary representation */
1546 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1547 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1550 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1553 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1555 port_rss_hash_key_update(res->port_id, hash_key);
1558 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1560 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1563 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1564 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1565 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1567 rss_hash_key, "rss-hash-key");
1568 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1571 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1572 .f = cmd_config_rss_hash_key_parsed,
1574 .help_str = "port config X rss-hash-key 80 hexa digits",
1576 (void *)&cmd_config_rss_hash_key_port,
1577 (void *)&cmd_config_rss_hash_key_config,
1578 (void *)&cmd_config_rss_hash_key_port_id,
1579 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1580 (void *)&cmd_config_rss_hash_key_value,
1585 /* *** configure port rxq/txq start/stop *** */
1586 struct cmd_config_rxtx_queue {
1587 cmdline_fixed_string_t port;
1589 cmdline_fixed_string_t rxtxq;
1591 cmdline_fixed_string_t opname;
1595 cmd_config_rxtx_queue_parsed(void *parsed_result,
1596 __attribute__((unused)) struct cmdline *cl,
1597 __attribute__((unused)) void *data)
1599 struct cmd_config_rxtx_queue *res = parsed_result;
1604 if (test_done == 0) {
1605 printf("Please stop forwarding first\n");
1609 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1612 if (port_is_started(res->portid) != 1) {
1613 printf("Please start port %u first\n", res->portid);
1617 if (!strcmp(res->rxtxq, "rxq"))
1619 else if (!strcmp(res->rxtxq, "txq"))
1622 printf("Unknown parameter\n");
1626 if (isrx && rx_queue_id_is_invalid(res->qid))
1628 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1631 if (!strcmp(res->opname, "start"))
1633 else if (!strcmp(res->opname, "stop"))
1636 printf("Unknown parameter\n");
1640 if (isstart && isrx)
1641 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1642 else if (!isstart && isrx)
1643 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1644 else if (isstart && !isrx)
1645 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1647 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1649 if (ret == -ENOTSUP)
1650 printf("Function not supported in PMD driver\n");
1653 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1654 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1655 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1656 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1657 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1659 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1660 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1661 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1665 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1666 .f = cmd_config_rxtx_queue_parsed,
1668 .help_str = "port X rxq|txq ID start|stop",
1670 (void *)&cmd_config_speed_all_port,
1671 (void *)&cmd_config_rxtx_queue_portid,
1672 (void *)&cmd_config_rxtx_queue_rxtxq,
1673 (void *)&cmd_config_rxtx_queue_qid,
1674 (void *)&cmd_config_rxtx_queue_opname,
1679 /* *** Configure RSS RETA *** */
1680 struct cmd_config_rss_reta {
1681 cmdline_fixed_string_t port;
1682 cmdline_fixed_string_t keyword;
1684 cmdline_fixed_string_t name;
1685 cmdline_fixed_string_t list_name;
1686 cmdline_fixed_string_t list_of_items;
1690 parse_reta_config(const char *str,
1691 struct rte_eth_rss_reta_entry64 *reta_conf,
1692 uint16_t nb_entries)
1696 uint16_t hash_index, idx, shift;
1699 const char *p, *p0 = str;
1706 unsigned long int_fld[_NUM_FLD];
1707 char *str_fld[_NUM_FLD];
1709 while ((p = strchr(p0,'(')) != NULL) {
1711 if((p0 = strchr(p,')')) == NULL)
1715 if(size >= sizeof(s))
1718 snprintf(s, sizeof(s), "%.*s", size, p);
1719 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1721 for (i = 0; i < _NUM_FLD; i++) {
1723 int_fld[i] = strtoul(str_fld[i], &end, 0);
1724 if (errno != 0 || end == str_fld[i] ||
1729 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1730 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1732 if (hash_index >= nb_entries) {
1733 printf("Invalid RETA hash index=%d\n", hash_index);
1737 idx = hash_index / RTE_RETA_GROUP_SIZE;
1738 shift = hash_index % RTE_RETA_GROUP_SIZE;
1739 reta_conf[idx].mask |= (1ULL << shift);
1740 reta_conf[idx].reta[shift] = nb_queue;
1747 cmd_set_rss_reta_parsed(void *parsed_result,
1748 __attribute__((unused)) struct cmdline *cl,
1749 __attribute__((unused)) void *data)
1752 struct rte_eth_dev_info dev_info;
1753 struct rte_eth_rss_reta_entry64 reta_conf[8];
1754 struct cmd_config_rss_reta *res = parsed_result;
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) {
1759 printf("Redirection table size is 0 which is "
1760 "invalid for RSS\n");
1763 printf("The reta size of port %d is %u\n",
1764 res->port_id, dev_info.reta_size);
1765 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1766 printf("Currently do not support more than %u entries of "
1767 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1771 memset(reta_conf, 0, sizeof(reta_conf));
1772 if (!strcmp(res->list_name, "reta")) {
1773 if (parse_reta_config(res->list_of_items, reta_conf,
1774 dev_info.reta_size)) {
1775 printf("Invalid RSS Redirection Table "
1776 "config entered\n");
1779 ret = rte_eth_dev_rss_reta_update(res->port_id,
1780 reta_conf, dev_info.reta_size);
1782 printf("Bad redirection table parameter, "
1783 "return code = %d \n", ret);
1787 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1789 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1790 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1791 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1792 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1793 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1795 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1796 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1797 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1800 cmdline_parse_inst_t cmd_config_rss_reta = {
1801 .f = cmd_set_rss_reta_parsed,
1803 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1805 (void *)&cmd_config_rss_reta_port,
1806 (void *)&cmd_config_rss_reta_keyword,
1807 (void *)&cmd_config_rss_reta_port_id,
1808 (void *)&cmd_config_rss_reta_name,
1809 (void *)&cmd_config_rss_reta_list_name,
1810 (void *)&cmd_config_rss_reta_list_of_items,
1815 /* *** SHOW PORT RETA INFO *** */
1816 struct cmd_showport_reta {
1817 cmdline_fixed_string_t show;
1818 cmdline_fixed_string_t port;
1820 cmdline_fixed_string_t rss;
1821 cmdline_fixed_string_t reta;
1823 cmdline_fixed_string_t list_of_items;
1827 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1828 uint16_t nb_entries,
1832 const char *p, *p0 = str;
1836 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1839 p = strchr(p0, '(');
1843 p0 = strchr(p, ')');
1847 if (size >= sizeof(s)) {
1848 printf("The string size exceeds the internal buffer size\n");
1851 snprintf(s, sizeof(s), "%.*s", size, p);
1852 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1853 if (ret <= 0 || ret != num) {
1854 printf("The bits of masks do not match the number of "
1855 "reta entries: %u\n", num);
1858 for (i = 0; i < ret; i++)
1859 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1865 cmd_showport_reta_parsed(void *parsed_result,
1866 __attribute__((unused)) struct cmdline *cl,
1867 __attribute__((unused)) void *data)
1869 struct cmd_showport_reta *res = parsed_result;
1870 struct rte_eth_rss_reta_entry64 reta_conf[8];
1871 struct rte_eth_dev_info dev_info;
1873 memset(&dev_info, 0, sizeof(dev_info));
1874 rte_eth_dev_info_get(res->port_id, &dev_info);
1875 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1876 res->size > ETH_RSS_RETA_SIZE_512) {
1877 printf("Invalid redirection table size: %u\n", res->size);
1881 memset(reta_conf, 0, sizeof(reta_conf));
1882 if (showport_parse_reta_config(reta_conf, res->size,
1883 res->list_of_items) < 0) {
1884 printf("Invalid string: %s for reta masks\n",
1885 res->list_of_items);
1888 port_rss_reta_info(res->port_id, reta_conf, res->size);
1891 cmdline_parse_token_string_t cmd_showport_reta_show =
1892 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1893 cmdline_parse_token_string_t cmd_showport_reta_port =
1894 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1895 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1896 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1897 cmdline_parse_token_string_t cmd_showport_reta_rss =
1898 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1899 cmdline_parse_token_string_t cmd_showport_reta_reta =
1900 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1901 cmdline_parse_token_num_t cmd_showport_reta_size =
1902 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1903 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1904 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1905 list_of_items, NULL);
1907 cmdline_parse_inst_t cmd_showport_reta = {
1908 .f = cmd_showport_reta_parsed,
1910 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1912 (void *)&cmd_showport_reta_show,
1913 (void *)&cmd_showport_reta_port,
1914 (void *)&cmd_showport_reta_port_id,
1915 (void *)&cmd_showport_reta_rss,
1916 (void *)&cmd_showport_reta_reta,
1917 (void *)&cmd_showport_reta_size,
1918 (void *)&cmd_showport_reta_list_of_items,
1923 /* *** Show RSS hash configuration *** */
1924 struct cmd_showport_rss_hash {
1925 cmdline_fixed_string_t show;
1926 cmdline_fixed_string_t port;
1928 cmdline_fixed_string_t rss_hash;
1929 cmdline_fixed_string_t key; /* optional argument */
1932 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1933 __attribute__((unused)) struct cmdline *cl,
1936 struct cmd_showport_rss_hash *res = parsed_result;
1938 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1941 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1942 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1943 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1944 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1945 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1946 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1947 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1948 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1950 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1951 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1953 cmdline_parse_inst_t cmd_showport_rss_hash = {
1954 .f = cmd_showport_rss_hash_parsed,
1956 .help_str = "show port X rss-hash (X = port number)\n",
1958 (void *)&cmd_showport_rss_hash_show,
1959 (void *)&cmd_showport_rss_hash_port,
1960 (void *)&cmd_showport_rss_hash_port_id,
1961 (void *)&cmd_showport_rss_hash_rss_hash,
1966 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1967 .f = cmd_showport_rss_hash_parsed,
1969 .help_str = "show port X rss-hash key (X = port number)\n",
1971 (void *)&cmd_showport_rss_hash_show,
1972 (void *)&cmd_showport_rss_hash_port,
1973 (void *)&cmd_showport_rss_hash_port_id,
1974 (void *)&cmd_showport_rss_hash_rss_hash,
1975 (void *)&cmd_showport_rss_hash_rss_key,
1980 /* *** Configure DCB *** */
1981 struct cmd_config_dcb {
1982 cmdline_fixed_string_t port;
1983 cmdline_fixed_string_t config;
1985 cmdline_fixed_string_t dcb;
1986 cmdline_fixed_string_t vt;
1987 cmdline_fixed_string_t vt_en;
1989 cmdline_fixed_string_t pfc;
1990 cmdline_fixed_string_t pfc_en;
1994 cmd_config_dcb_parsed(void *parsed_result,
1995 __attribute__((unused)) struct cmdline *cl,
1996 __attribute__((unused)) void *data)
1998 struct cmd_config_dcb *res = parsed_result;
1999 struct dcb_config dcb_conf;
2000 portid_t port_id = res->port_id;
2001 struct rte_port *port;
2003 port = &ports[port_id];
2004 /** Check if the port is not started **/
2005 if (port->port_status != RTE_PORT_STOPPED) {
2006 printf("Please stop port %d first\n",port_id);
2010 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
2011 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
2012 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
2016 /* DCB in VT mode */
2017 if (!strncmp(res->vt_en, "on",2))
2018 dcb_conf.dcb_mode = DCB_VT_ENABLED;
2020 dcb_conf.dcb_mode = DCB_ENABLED;
2022 if (!strncmp(res->pfc_en, "on",2)) {
2023 dcb_conf.pfc_en = 1;
2026 dcb_conf.pfc_en = 0;
2028 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
2029 printf("Cannot initialize network ports\n");
2033 cmd_reconfig_device_queue(port_id, 1, 1);
2036 cmdline_parse_token_string_t cmd_config_dcb_port =
2037 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2038 cmdline_parse_token_string_t cmd_config_dcb_config =
2039 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2040 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2041 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2042 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2043 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2044 cmdline_parse_token_string_t cmd_config_dcb_vt =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2046 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2047 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2048 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2049 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2050 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2052 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2053 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2055 cmdline_parse_inst_t cmd_config_dcb = {
2056 .f = cmd_config_dcb_parsed,
2058 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2060 (void *)&cmd_config_dcb_port,
2061 (void *)&cmd_config_dcb_config,
2062 (void *)&cmd_config_dcb_port_id,
2063 (void *)&cmd_config_dcb_dcb,
2064 (void *)&cmd_config_dcb_vt,
2065 (void *)&cmd_config_dcb_vt_en,
2066 (void *)&cmd_config_dcb_num_tcs,
2067 (void *)&cmd_config_dcb_pfc,
2068 (void *)&cmd_config_dcb_pfc_en,
2073 /* *** configure number of packets per burst *** */
2074 struct cmd_config_burst {
2075 cmdline_fixed_string_t port;
2076 cmdline_fixed_string_t keyword;
2077 cmdline_fixed_string_t all;
2078 cmdline_fixed_string_t name;
2083 cmd_config_burst_parsed(void *parsed_result,
2084 __attribute__((unused)) struct cmdline *cl,
2085 __attribute__((unused)) void *data)
2087 struct cmd_config_burst *res = parsed_result;
2089 if (!all_ports_stopped()) {
2090 printf("Please stop all ports first\n");
2094 if (!strcmp(res->name, "burst")) {
2095 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2096 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2099 nb_pkt_per_burst = res->value;
2101 printf("Unknown parameter\n");
2107 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2110 cmdline_parse_token_string_t cmd_config_burst_port =
2111 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2112 cmdline_parse_token_string_t cmd_config_burst_keyword =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2114 cmdline_parse_token_string_t cmd_config_burst_all =
2115 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2116 cmdline_parse_token_string_t cmd_config_burst_name =
2117 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2118 cmdline_parse_token_num_t cmd_config_burst_value =
2119 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2121 cmdline_parse_inst_t cmd_config_burst = {
2122 .f = cmd_config_burst_parsed,
2124 .help_str = "port config all burst value",
2126 (void *)&cmd_config_burst_port,
2127 (void *)&cmd_config_burst_keyword,
2128 (void *)&cmd_config_burst_all,
2129 (void *)&cmd_config_burst_name,
2130 (void *)&cmd_config_burst_value,
2135 /* *** configure rx/tx queues *** */
2136 struct cmd_config_thresh {
2137 cmdline_fixed_string_t port;
2138 cmdline_fixed_string_t keyword;
2139 cmdline_fixed_string_t all;
2140 cmdline_fixed_string_t name;
2145 cmd_config_thresh_parsed(void *parsed_result,
2146 __attribute__((unused)) struct cmdline *cl,
2147 __attribute__((unused)) void *data)
2149 struct cmd_config_thresh *res = parsed_result;
2151 if (!all_ports_stopped()) {
2152 printf("Please stop all ports first\n");
2156 if (!strcmp(res->name, "txpt"))
2157 tx_pthresh = res->value;
2158 else if(!strcmp(res->name, "txht"))
2159 tx_hthresh = res->value;
2160 else if(!strcmp(res->name, "txwt"))
2161 tx_wthresh = res->value;
2162 else if(!strcmp(res->name, "rxpt"))
2163 rx_pthresh = res->value;
2164 else if(!strcmp(res->name, "rxht"))
2165 rx_hthresh = res->value;
2166 else if(!strcmp(res->name, "rxwt"))
2167 rx_wthresh = res->value;
2169 printf("Unknown parameter\n");
2175 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2178 cmdline_parse_token_string_t cmd_config_thresh_port =
2179 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2180 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2181 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2182 cmdline_parse_token_string_t cmd_config_thresh_all =
2183 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2184 cmdline_parse_token_string_t cmd_config_thresh_name =
2185 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2186 "txpt#txht#txwt#rxpt#rxht#rxwt");
2187 cmdline_parse_token_num_t cmd_config_thresh_value =
2188 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2190 cmdline_parse_inst_t cmd_config_thresh = {
2191 .f = cmd_config_thresh_parsed,
2193 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2195 (void *)&cmd_config_thresh_port,
2196 (void *)&cmd_config_thresh_keyword,
2197 (void *)&cmd_config_thresh_all,
2198 (void *)&cmd_config_thresh_name,
2199 (void *)&cmd_config_thresh_value,
2204 /* *** configure free/rs threshold *** */
2205 struct cmd_config_threshold {
2206 cmdline_fixed_string_t port;
2207 cmdline_fixed_string_t keyword;
2208 cmdline_fixed_string_t all;
2209 cmdline_fixed_string_t name;
2214 cmd_config_threshold_parsed(void *parsed_result,
2215 __attribute__((unused)) struct cmdline *cl,
2216 __attribute__((unused)) void *data)
2218 struct cmd_config_threshold *res = parsed_result;
2220 if (!all_ports_stopped()) {
2221 printf("Please stop all ports first\n");
2225 if (!strcmp(res->name, "txfreet"))
2226 tx_free_thresh = res->value;
2227 else if (!strcmp(res->name, "txrst"))
2228 tx_rs_thresh = res->value;
2229 else if (!strcmp(res->name, "rxfreet"))
2230 rx_free_thresh = res->value;
2232 printf("Unknown parameter\n");
2238 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2241 cmdline_parse_token_string_t cmd_config_threshold_port =
2242 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2243 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2244 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2246 cmdline_parse_token_string_t cmd_config_threshold_all =
2247 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2248 cmdline_parse_token_string_t cmd_config_threshold_name =
2249 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2250 "txfreet#txrst#rxfreet");
2251 cmdline_parse_token_num_t cmd_config_threshold_value =
2252 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2254 cmdline_parse_inst_t cmd_config_threshold = {
2255 .f = cmd_config_threshold_parsed,
2257 .help_str = "port config all txfreet|txrst|rxfreet value",
2259 (void *)&cmd_config_threshold_port,
2260 (void *)&cmd_config_threshold_keyword,
2261 (void *)&cmd_config_threshold_all,
2262 (void *)&cmd_config_threshold_name,
2263 (void *)&cmd_config_threshold_value,
2269 struct cmd_stop_result {
2270 cmdline_fixed_string_t stop;
2273 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2274 __attribute__((unused)) struct cmdline *cl,
2275 __attribute__((unused)) void *data)
2277 stop_packet_forwarding();
2280 cmdline_parse_token_string_t cmd_stop_stop =
2281 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2283 cmdline_parse_inst_t cmd_stop = {
2284 .f = cmd_stop_parsed,
2286 .help_str = "stop - stop packet forwarding",
2288 (void *)&cmd_stop_stop,
2293 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2296 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2297 unsigned int *parsed_items, int check_unique_values)
2299 unsigned int nb_item;
2307 * First parse all items in the list and store their value.
2312 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2314 if ((c >= '0') && (c <= '9')) {
2315 value = (unsigned int) (value * 10 + (c - '0'));
2320 printf("character %c is not a decimal digit\n", c);
2324 printf("No valid value before comma\n");
2327 if (nb_item < max_items) {
2328 parsed_items[nb_item] = value;
2334 if (nb_item >= max_items) {
2335 printf("Number of %s = %u > %u (maximum items)\n",
2336 item_name, nb_item + 1, max_items);
2339 parsed_items[nb_item++] = value;
2340 if (! check_unique_values)
2344 * Then, check that all values in the list are differents.
2345 * No optimization here...
2347 for (i = 0; i < nb_item; i++) {
2348 for (j = i + 1; j < nb_item; j++) {
2349 if (parsed_items[j] == parsed_items[i]) {
2350 printf("duplicated %s %u at index %u and %u\n",
2351 item_name, parsed_items[i], i, j);
2359 struct cmd_set_list_result {
2360 cmdline_fixed_string_t cmd_keyword;
2361 cmdline_fixed_string_t list_name;
2362 cmdline_fixed_string_t list_of_items;
2365 static void cmd_set_list_parsed(void *parsed_result,
2366 __attribute__((unused)) struct cmdline *cl,
2367 __attribute__((unused)) void *data)
2369 struct cmd_set_list_result *res;
2371 unsigned int lcorelist[RTE_MAX_LCORE];
2372 unsigned int portlist[RTE_MAX_ETHPORTS];
2374 unsigned int nb_item;
2376 if (test_done == 0) {
2377 printf("Please stop forwarding first\n");
2381 res = parsed_result;
2382 if (!strcmp(res->list_name, "corelist")) {
2383 nb_item = parse_item_list(res->list_of_items, "core",
2385 parsed_items.lcorelist, 1);
2387 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2390 if (!strcmp(res->list_name, "portlist")) {
2391 nb_item = parse_item_list(res->list_of_items, "port",
2393 parsed_items.portlist, 1);
2395 set_fwd_ports_list(parsed_items.portlist, nb_item);
2399 cmdline_parse_token_string_t cmd_set_list_keyword =
2400 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2402 cmdline_parse_token_string_t cmd_set_list_name =
2403 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2404 "corelist#portlist");
2405 cmdline_parse_token_string_t cmd_set_list_of_items =
2406 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2409 cmdline_parse_inst_t cmd_set_fwd_list = {
2410 .f = cmd_set_list_parsed,
2412 .help_str = "set corelist|portlist x[,y]*",
2414 (void *)&cmd_set_list_keyword,
2415 (void *)&cmd_set_list_name,
2416 (void *)&cmd_set_list_of_items,
2421 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2423 struct cmd_setmask_result {
2424 cmdline_fixed_string_t set;
2425 cmdline_fixed_string_t mask;
2429 static void cmd_set_mask_parsed(void *parsed_result,
2430 __attribute__((unused)) struct cmdline *cl,
2431 __attribute__((unused)) void *data)
2433 struct cmd_setmask_result *res = parsed_result;
2435 if (test_done == 0) {
2436 printf("Please stop forwarding first\n");
2439 if (!strcmp(res->mask, "coremask"))
2440 set_fwd_lcores_mask(res->hexavalue);
2441 else if (!strcmp(res->mask, "portmask"))
2442 set_fwd_ports_mask(res->hexavalue);
2445 cmdline_parse_token_string_t cmd_setmask_set =
2446 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2447 cmdline_parse_token_string_t cmd_setmask_mask =
2448 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2449 "coremask#portmask");
2450 cmdline_parse_token_num_t cmd_setmask_value =
2451 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2453 cmdline_parse_inst_t cmd_set_fwd_mask = {
2454 .f = cmd_set_mask_parsed,
2456 .help_str = "set coremask|portmask hexadecimal value",
2458 (void *)&cmd_setmask_set,
2459 (void *)&cmd_setmask_mask,
2460 (void *)&cmd_setmask_value,
2466 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2468 struct cmd_set_result {
2469 cmdline_fixed_string_t set;
2470 cmdline_fixed_string_t what;
2474 static void cmd_set_parsed(void *parsed_result,
2475 __attribute__((unused)) struct cmdline *cl,
2476 __attribute__((unused)) void *data)
2478 struct cmd_set_result *res = parsed_result;
2479 if (!strcmp(res->what, "nbport"))
2480 set_fwd_ports_number(res->value);
2481 else if (!strcmp(res->what, "nbcore"))
2482 set_fwd_lcores_number(res->value);
2483 else if (!strcmp(res->what, "burst"))
2484 set_nb_pkt_per_burst(res->value);
2485 else if (!strcmp(res->what, "verbose"))
2486 set_verbose_level(res->value);
2489 cmdline_parse_token_string_t cmd_set_set =
2490 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2491 cmdline_parse_token_string_t cmd_set_what =
2492 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2493 "nbport#nbcore#burst#verbose");
2494 cmdline_parse_token_num_t cmd_set_value =
2495 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2497 cmdline_parse_inst_t cmd_set_numbers = {
2498 .f = cmd_set_parsed,
2500 .help_str = "set nbport|nbcore|burst|verbose value",
2502 (void *)&cmd_set_set,
2503 (void *)&cmd_set_what,
2504 (void *)&cmd_set_value,
2509 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2511 struct cmd_set_txpkts_result {
2512 cmdline_fixed_string_t cmd_keyword;
2513 cmdline_fixed_string_t txpkts;
2514 cmdline_fixed_string_t seg_lengths;
2518 cmd_set_txpkts_parsed(void *parsed_result,
2519 __attribute__((unused)) struct cmdline *cl,
2520 __attribute__((unused)) void *data)
2522 struct cmd_set_txpkts_result *res;
2523 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2524 unsigned int nb_segs;
2526 res = parsed_result;
2527 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2528 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2530 set_tx_pkt_segments(seg_lengths, nb_segs);
2533 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2534 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2535 cmd_keyword, "set");
2536 cmdline_parse_token_string_t cmd_set_txpkts_name =
2537 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2539 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2540 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2543 cmdline_parse_inst_t cmd_set_txpkts = {
2544 .f = cmd_set_txpkts_parsed,
2546 .help_str = "set txpkts x[,y]*",
2548 (void *)&cmd_set_txpkts_keyword,
2549 (void *)&cmd_set_txpkts_name,
2550 (void *)&cmd_set_txpkts_lengths,
2555 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2556 struct cmd_rx_vlan_filter_all_result {
2557 cmdline_fixed_string_t rx_vlan;
2558 cmdline_fixed_string_t what;
2559 cmdline_fixed_string_t all;
2564 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2565 __attribute__((unused)) struct cmdline *cl,
2566 __attribute__((unused)) void *data)
2568 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2570 if (!strcmp(res->what, "add"))
2571 rx_vlan_all_filter_set(res->port_id, 1);
2573 rx_vlan_all_filter_set(res->port_id, 0);
2576 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2577 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2578 rx_vlan, "rx_vlan");
2579 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2580 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2582 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2583 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2585 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2586 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2589 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2590 .f = cmd_rx_vlan_filter_all_parsed,
2592 .help_str = "add/remove all identifiers to/from the set of VLAN "
2593 "Identifiers filtered by a port",
2595 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2596 (void *)&cmd_rx_vlan_filter_all_what,
2597 (void *)&cmd_rx_vlan_filter_all_all,
2598 (void *)&cmd_rx_vlan_filter_all_portid,
2603 /* *** VLAN OFFLOAD SET ON A PORT *** */
2604 struct cmd_vlan_offload_result {
2605 cmdline_fixed_string_t vlan;
2606 cmdline_fixed_string_t set;
2607 cmdline_fixed_string_t what;
2608 cmdline_fixed_string_t on;
2609 cmdline_fixed_string_t port_id;
2613 cmd_vlan_offload_parsed(void *parsed_result,
2614 __attribute__((unused)) struct cmdline *cl,
2615 __attribute__((unused)) void *data)
2618 struct cmd_vlan_offload_result *res = parsed_result;
2621 portid_t port_id = 0;
2625 len = strnlen(str, STR_TOKEN_SIZE);
2627 /* Get port_id first */
2635 tmp = strtoul(str, NULL, 0);
2636 /* If port_id greater that what portid_t can represent, return */
2637 if(tmp >= RTE_MAX_ETHPORTS)
2639 port_id = (portid_t)tmp;
2641 if (!strcmp(res->on, "on"))
2646 if (!strcmp(res->what, "strip"))
2647 rx_vlan_strip_set(port_id, on);
2648 else if(!strcmp(res->what, "stripq")){
2649 uint16_t queue_id = 0;
2651 /* No queue_id, return */
2653 printf("must specify (port,queue_id)\n");
2656 tmp = strtoul(str + i + 1, NULL, 0);
2657 /* If queue_id greater that what 16-bits can represent, return */
2661 queue_id = (uint16_t)tmp;
2662 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2664 else if (!strcmp(res->what, "filter"))
2665 rx_vlan_filter_set(port_id, on);
2667 vlan_extend_set(port_id, on);
2672 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2673 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2675 cmdline_parse_token_string_t cmd_vlan_offload_set =
2676 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2678 cmdline_parse_token_string_t cmd_vlan_offload_what =
2679 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2680 what, "strip#filter#qinq#stripq");
2681 cmdline_parse_token_string_t cmd_vlan_offload_on =
2682 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2684 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2685 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2688 cmdline_parse_inst_t cmd_vlan_offload = {
2689 .f = cmd_vlan_offload_parsed,
2691 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2692 " qinq(extended) for both rx/tx sides ",
2694 (void *)&cmd_vlan_offload_vlan,
2695 (void *)&cmd_vlan_offload_set,
2696 (void *)&cmd_vlan_offload_what,
2697 (void *)&cmd_vlan_offload_on,
2698 (void *)&cmd_vlan_offload_portid,
2703 /* *** VLAN TPID SET ON A PORT *** */
2704 struct cmd_vlan_tpid_result {
2705 cmdline_fixed_string_t vlan;
2706 cmdline_fixed_string_t set;
2707 cmdline_fixed_string_t what;
2713 cmd_vlan_tpid_parsed(void *parsed_result,
2714 __attribute__((unused)) struct cmdline *cl,
2715 __attribute__((unused)) void *data)
2717 struct cmd_vlan_tpid_result *res = parsed_result;
2718 vlan_tpid_set(res->port_id, res->tp_id);
2722 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2723 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2725 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2726 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2728 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2729 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2731 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2732 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2734 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2735 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2738 cmdline_parse_inst_t cmd_vlan_tpid = {
2739 .f = cmd_vlan_tpid_parsed,
2741 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2743 (void *)&cmd_vlan_tpid_vlan,
2744 (void *)&cmd_vlan_tpid_set,
2745 (void *)&cmd_vlan_tpid_what,
2746 (void *)&cmd_vlan_tpid_tpid,
2747 (void *)&cmd_vlan_tpid_portid,
2752 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2753 struct cmd_rx_vlan_filter_result {
2754 cmdline_fixed_string_t rx_vlan;
2755 cmdline_fixed_string_t what;
2761 cmd_rx_vlan_filter_parsed(void *parsed_result,
2762 __attribute__((unused)) struct cmdline *cl,
2763 __attribute__((unused)) void *data)
2765 struct cmd_rx_vlan_filter_result *res = parsed_result;
2767 if (!strcmp(res->what, "add"))
2768 rx_vft_set(res->port_id, res->vlan_id, 1);
2770 rx_vft_set(res->port_id, res->vlan_id, 0);
2773 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2774 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2775 rx_vlan, "rx_vlan");
2776 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2777 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2779 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2780 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2782 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2783 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2786 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2787 .f = cmd_rx_vlan_filter_parsed,
2789 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2790 "Identifiers filtered by a port",
2792 (void *)&cmd_rx_vlan_filter_rx_vlan,
2793 (void *)&cmd_rx_vlan_filter_what,
2794 (void *)&cmd_rx_vlan_filter_vlanid,
2795 (void *)&cmd_rx_vlan_filter_portid,
2800 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2801 struct cmd_tx_vlan_set_result {
2802 cmdline_fixed_string_t tx_vlan;
2803 cmdline_fixed_string_t set;
2809 cmd_tx_vlan_set_parsed(void *parsed_result,
2810 __attribute__((unused)) struct cmdline *cl,
2811 __attribute__((unused)) void *data)
2813 struct cmd_tx_vlan_set_result *res = parsed_result;
2814 tx_vlan_set(res->port_id, res->vlan_id);
2817 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2818 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2819 tx_vlan, "tx_vlan");
2820 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2821 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2823 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2824 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2826 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2827 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2830 cmdline_parse_inst_t cmd_tx_vlan_set = {
2831 .f = cmd_tx_vlan_set_parsed,
2833 .help_str = "enable hardware insertion of a VLAN header with a given "
2834 "TAG Identifier in packets sent on a port",
2836 (void *)&cmd_tx_vlan_set_tx_vlan,
2837 (void *)&cmd_tx_vlan_set_set,
2838 (void *)&cmd_tx_vlan_set_vlanid,
2839 (void *)&cmd_tx_vlan_set_portid,
2844 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2845 struct cmd_tx_vlan_set_pvid_result {
2846 cmdline_fixed_string_t tx_vlan;
2847 cmdline_fixed_string_t set;
2848 cmdline_fixed_string_t pvid;
2851 cmdline_fixed_string_t mode;
2855 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2856 __attribute__((unused)) struct cmdline *cl,
2857 __attribute__((unused)) void *data)
2859 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2861 if (strcmp(res->mode, "on") == 0)
2862 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2864 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2867 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2868 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2869 tx_vlan, "tx_vlan");
2870 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2871 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2873 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2874 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2876 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2877 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2879 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2880 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2882 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2883 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2886 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2887 .f = cmd_tx_vlan_set_pvid_parsed,
2889 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2891 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2892 (void *)&cmd_tx_vlan_set_pvid_set,
2893 (void *)&cmd_tx_vlan_set_pvid_pvid,
2894 (void *)&cmd_tx_vlan_set_pvid_port_id,
2895 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2896 (void *)&cmd_tx_vlan_set_pvid_mode,
2901 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2902 struct cmd_tx_vlan_reset_result {
2903 cmdline_fixed_string_t tx_vlan;
2904 cmdline_fixed_string_t reset;
2909 cmd_tx_vlan_reset_parsed(void *parsed_result,
2910 __attribute__((unused)) struct cmdline *cl,
2911 __attribute__((unused)) void *data)
2913 struct cmd_tx_vlan_reset_result *res = parsed_result;
2915 tx_vlan_reset(res->port_id);
2918 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2919 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2920 tx_vlan, "tx_vlan");
2921 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2922 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2924 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2925 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2928 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2929 .f = cmd_tx_vlan_reset_parsed,
2931 .help_str = "disable hardware insertion of a VLAN header in packets "
2934 (void *)&cmd_tx_vlan_reset_tx_vlan,
2935 (void *)&cmd_tx_vlan_reset_reset,
2936 (void *)&cmd_tx_vlan_reset_portid,
2942 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2943 struct cmd_csum_result {
2944 cmdline_fixed_string_t csum;
2945 cmdline_fixed_string_t mode;
2946 cmdline_fixed_string_t proto;
2947 cmdline_fixed_string_t hwsw;
2952 csum_show(int port_id)
2954 struct rte_eth_dev_info dev_info;
2957 ol_flags = ports[port_id].tx_ol_flags;
2958 printf("Parse tunnel is %s\n",
2959 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
2960 printf("IP checksum offload is %s\n",
2961 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2962 printf("UDP checksum offload is %s\n",
2963 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2964 printf("TCP checksum offload is %s\n",
2965 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2966 printf("SCTP checksum offload is %s\n",
2967 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2968 printf("Outer-Ip checksum offload is %s\n",
2969 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
2971 /* display warnings if configuration is not supported by the NIC */
2972 rte_eth_dev_info_get(port_id, &dev_info);
2973 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2974 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2975 printf("Warning: hardware IP checksum enabled but not "
2976 "supported by port %d\n", port_id);
2978 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2979 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2980 printf("Warning: hardware UDP checksum enabled but not "
2981 "supported by port %d\n", port_id);
2983 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2984 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2985 printf("Warning: hardware TCP checksum enabled but not "
2986 "supported by port %d\n", port_id);
2988 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2989 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2990 printf("Warning: hardware SCTP checksum enabled but not "
2991 "supported by port %d\n", port_id);
2993 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
2994 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
2995 printf("Warning: hardware outer IP checksum enabled but not "
2996 "supported by port %d\n", port_id);
3001 cmd_csum_parsed(void *parsed_result,
3002 __attribute__((unused)) struct cmdline *cl,
3003 __attribute__((unused)) void *data)
3005 struct cmd_csum_result *res = parsed_result;
3009 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3010 printf("invalid port %d\n", res->port_id);
3014 if (!strcmp(res->mode, "set")) {
3016 if (!strcmp(res->hwsw, "hw"))
3019 if (!strcmp(res->proto, "ip")) {
3020 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3021 } else if (!strcmp(res->proto, "udp")) {
3022 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3023 } else if (!strcmp(res->proto, "tcp")) {
3024 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3025 } else if (!strcmp(res->proto, "sctp")) {
3026 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3027 } else if (!strcmp(res->proto, "outer-ip")) {
3028 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3032 ports[res->port_id].tx_ol_flags |= mask;
3034 ports[res->port_id].tx_ol_flags &= (~mask);
3036 csum_show(res->port_id);
3039 cmdline_parse_token_string_t cmd_csum_csum =
3040 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3042 cmdline_parse_token_string_t cmd_csum_mode =
3043 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3045 cmdline_parse_token_string_t cmd_csum_proto =
3046 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3047 proto, "ip#tcp#udp#sctp#outer-ip");
3048 cmdline_parse_token_string_t cmd_csum_hwsw =
3049 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3051 cmdline_parse_token_num_t cmd_csum_portid =
3052 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3055 cmdline_parse_inst_t cmd_csum_set = {
3056 .f = cmd_csum_parsed,
3058 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3059 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3061 (void *)&cmd_csum_csum,
3062 (void *)&cmd_csum_mode,
3063 (void *)&cmd_csum_proto,
3064 (void *)&cmd_csum_hwsw,
3065 (void *)&cmd_csum_portid,
3070 cmdline_parse_token_string_t cmd_csum_mode_show =
3071 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3074 cmdline_parse_inst_t cmd_csum_show = {
3075 .f = cmd_csum_parsed,
3077 .help_str = "show checksum offload configuration: csum show <port>",
3079 (void *)&cmd_csum_csum,
3080 (void *)&cmd_csum_mode_show,
3081 (void *)&cmd_csum_portid,
3086 /* Enable/disable tunnel parsing */
3087 struct cmd_csum_tunnel_result {
3088 cmdline_fixed_string_t csum;
3089 cmdline_fixed_string_t parse;
3090 cmdline_fixed_string_t onoff;
3095 cmd_csum_tunnel_parsed(void *parsed_result,
3096 __attribute__((unused)) struct cmdline *cl,
3097 __attribute__((unused)) void *data)
3099 struct cmd_csum_tunnel_result *res = parsed_result;
3101 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3104 if (!strcmp(res->onoff, "on"))
3105 ports[res->port_id].tx_ol_flags |=
3106 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3108 ports[res->port_id].tx_ol_flags &=
3109 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3111 csum_show(res->port_id);
3114 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3115 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3117 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3118 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3119 parse, "parse_tunnel");
3120 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3121 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3123 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3124 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3127 cmdline_parse_inst_t cmd_csum_tunnel = {
3128 .f = cmd_csum_tunnel_parsed,
3130 .help_str = "enable/disable parsing of tunnels for csum engine: "
3131 "csum parse_tunnel on|off <tx-port>",
3133 (void *)&cmd_csum_tunnel_csum,
3134 (void *)&cmd_csum_tunnel_parse,
3135 (void *)&cmd_csum_tunnel_onoff,
3136 (void *)&cmd_csum_tunnel_portid,
3141 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3142 struct cmd_tso_set_result {
3143 cmdline_fixed_string_t tso;
3144 cmdline_fixed_string_t mode;
3150 cmd_tso_set_parsed(void *parsed_result,
3151 __attribute__((unused)) struct cmdline *cl,
3152 __attribute__((unused)) void *data)
3154 struct cmd_tso_set_result *res = parsed_result;
3155 struct rte_eth_dev_info dev_info;
3157 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3160 if (!strcmp(res->mode, "set"))
3161 ports[res->port_id].tso_segsz = res->tso_segsz;
3163 if (ports[res->port_id].tso_segsz == 0)
3164 printf("TSO is disabled\n");
3166 printf("TSO segment size is %d\n",
3167 ports[res->port_id].tso_segsz);
3169 /* display warnings if configuration is not supported by the NIC */
3170 rte_eth_dev_info_get(res->port_id, &dev_info);
3171 if ((ports[res->port_id].tso_segsz != 0) &&
3172 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3173 printf("Warning: TSO enabled but not "
3174 "supported by port %d\n", res->port_id);
3178 cmdline_parse_token_string_t cmd_tso_set_tso =
3179 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3181 cmdline_parse_token_string_t cmd_tso_set_mode =
3182 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3184 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3185 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3187 cmdline_parse_token_num_t cmd_tso_set_portid =
3188 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3191 cmdline_parse_inst_t cmd_tso_set = {
3192 .f = cmd_tso_set_parsed,
3194 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3195 "tso set <tso_segsz> <port>",
3197 (void *)&cmd_tso_set_tso,
3198 (void *)&cmd_tso_set_mode,
3199 (void *)&cmd_tso_set_tso_segsz,
3200 (void *)&cmd_tso_set_portid,
3205 cmdline_parse_token_string_t cmd_tso_show_mode =
3206 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3210 cmdline_parse_inst_t cmd_tso_show = {
3211 .f = cmd_tso_set_parsed,
3213 .help_str = "Show TSO segment size for csum engine: "
3216 (void *)&cmd_tso_set_tso,
3217 (void *)&cmd_tso_show_mode,
3218 (void *)&cmd_tso_set_portid,
3223 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3224 struct cmd_set_flush_rx {
3225 cmdline_fixed_string_t set;
3226 cmdline_fixed_string_t flush_rx;
3227 cmdline_fixed_string_t mode;
3231 cmd_set_flush_rx_parsed(void *parsed_result,
3232 __attribute__((unused)) struct cmdline *cl,
3233 __attribute__((unused)) void *data)
3235 struct cmd_set_flush_rx *res = parsed_result;
3236 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3239 cmdline_parse_token_string_t cmd_setflushrx_set =
3240 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3242 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3243 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3244 flush_rx, "flush_rx");
3245 cmdline_parse_token_string_t cmd_setflushrx_mode =
3246 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3250 cmdline_parse_inst_t cmd_set_flush_rx = {
3251 .f = cmd_set_flush_rx_parsed,
3252 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3255 (void *)&cmd_setflushrx_set,
3256 (void *)&cmd_setflushrx_flush_rx,
3257 (void *)&cmd_setflushrx_mode,
3262 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3263 struct cmd_set_link_check {
3264 cmdline_fixed_string_t set;
3265 cmdline_fixed_string_t link_check;
3266 cmdline_fixed_string_t mode;
3270 cmd_set_link_check_parsed(void *parsed_result,
3271 __attribute__((unused)) struct cmdline *cl,
3272 __attribute__((unused)) void *data)
3274 struct cmd_set_link_check *res = parsed_result;
3275 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3278 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3279 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3281 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3282 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3283 link_check, "link_check");
3284 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3285 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3289 cmdline_parse_inst_t cmd_set_link_check = {
3290 .f = cmd_set_link_check_parsed,
3291 .help_str = "set link_check on|off: enable/disable link status check "
3292 "when starting/stopping a port",
3295 (void *)&cmd_setlinkcheck_set,
3296 (void *)&cmd_setlinkcheck_link_check,
3297 (void *)&cmd_setlinkcheck_mode,
3302 #ifdef RTE_NIC_BYPASS
3303 /* *** SET NIC BYPASS MODE *** */
3304 struct cmd_set_bypass_mode_result {
3305 cmdline_fixed_string_t set;
3306 cmdline_fixed_string_t bypass;
3307 cmdline_fixed_string_t mode;
3308 cmdline_fixed_string_t value;
3313 cmd_set_bypass_mode_parsed(void *parsed_result,
3314 __attribute__((unused)) struct cmdline *cl,
3315 __attribute__((unused)) void *data)
3317 struct cmd_set_bypass_mode_result *res = parsed_result;
3318 portid_t port_id = res->port_id;
3319 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3321 if (!bypass_is_supported(port_id))
3324 if (!strcmp(res->value, "bypass"))
3325 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3326 else if (!strcmp(res->value, "isolate"))
3327 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3329 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3331 /* Set the bypass mode for the relevant port. */
3332 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3333 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3337 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3338 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3340 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3341 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3343 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3344 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3346 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3347 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3348 value, "normal#bypass#isolate");
3349 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3350 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3353 cmdline_parse_inst_t cmd_set_bypass_mode = {
3354 .f = cmd_set_bypass_mode_parsed,
3355 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3356 "Set the NIC bypass mode for port_id",
3359 (void *)&cmd_setbypass_mode_set,
3360 (void *)&cmd_setbypass_mode_bypass,
3361 (void *)&cmd_setbypass_mode_mode,
3362 (void *)&cmd_setbypass_mode_value,
3363 (void *)&cmd_setbypass_mode_port,
3368 /* *** SET NIC BYPASS EVENT *** */
3369 struct cmd_set_bypass_event_result {
3370 cmdline_fixed_string_t set;
3371 cmdline_fixed_string_t bypass;
3372 cmdline_fixed_string_t event;
3373 cmdline_fixed_string_t event_value;
3374 cmdline_fixed_string_t mode;
3375 cmdline_fixed_string_t mode_value;
3380 cmd_set_bypass_event_parsed(void *parsed_result,
3381 __attribute__((unused)) struct cmdline *cl,
3382 __attribute__((unused)) void *data)
3385 struct cmd_set_bypass_event_result *res = parsed_result;
3386 portid_t port_id = res->port_id;
3387 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3388 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3390 if (!bypass_is_supported(port_id))
3393 if (!strcmp(res->event_value, "timeout"))
3394 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3395 else if (!strcmp(res->event_value, "os_on"))
3396 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3397 else if (!strcmp(res->event_value, "os_off"))
3398 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3399 else if (!strcmp(res->event_value, "power_on"))
3400 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3401 else if (!strcmp(res->event_value, "power_off"))
3402 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3404 bypass_event = RTE_BYPASS_EVENT_NONE;
3406 if (!strcmp(res->mode_value, "bypass"))
3407 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3408 else if (!strcmp(res->mode_value, "isolate"))
3409 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3411 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3413 /* Set the watchdog timeout. */
3414 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3417 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3418 (rc = rte_eth_dev_wd_timeout_store(port_id,
3419 bypass_timeout)) != 0) {
3420 printf("Failed to set timeout value %u "
3421 "for port %d, errto code: %d.\n",
3422 bypass_timeout, port_id, rc);
3426 /* Set the bypass event to transition to bypass mode. */
3427 if (0 != rte_eth_dev_bypass_event_store(port_id,
3428 bypass_event, bypass_mode)) {
3429 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3434 cmdline_parse_token_string_t cmd_setbypass_event_set =
3435 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3437 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3438 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3440 cmdline_parse_token_string_t cmd_setbypass_event_event =
3441 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3443 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3444 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3445 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3446 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3447 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3449 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3450 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3451 mode_value, "normal#bypass#isolate");
3452 cmdline_parse_token_num_t cmd_setbypass_event_port =
3453 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3456 cmdline_parse_inst_t cmd_set_bypass_event = {
3457 .f = cmd_set_bypass_event_parsed,
3458 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3459 "mode (normal|bypass|isolate) (port_id): "
3460 "Set the NIC bypass event mode for port_id",
3463 (void *)&cmd_setbypass_event_set,
3464 (void *)&cmd_setbypass_event_bypass,
3465 (void *)&cmd_setbypass_event_event,
3466 (void *)&cmd_setbypass_event_event_value,
3467 (void *)&cmd_setbypass_event_mode,
3468 (void *)&cmd_setbypass_event_mode_value,
3469 (void *)&cmd_setbypass_event_port,
3475 /* *** SET NIC BYPASS TIMEOUT *** */
3476 struct cmd_set_bypass_timeout_result {
3477 cmdline_fixed_string_t set;
3478 cmdline_fixed_string_t bypass;
3479 cmdline_fixed_string_t timeout;
3480 cmdline_fixed_string_t value;
3484 cmd_set_bypass_timeout_parsed(void *parsed_result,
3485 __attribute__((unused)) struct cmdline *cl,
3486 __attribute__((unused)) void *data)
3488 struct cmd_set_bypass_timeout_result *res = parsed_result;
3490 if (!strcmp(res->value, "1.5"))
3491 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3492 else if (!strcmp(res->value, "2"))
3493 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3494 else if (!strcmp(res->value, "3"))
3495 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3496 else if (!strcmp(res->value, "4"))
3497 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3498 else if (!strcmp(res->value, "8"))
3499 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3500 else if (!strcmp(res->value, "16"))
3501 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3502 else if (!strcmp(res->value, "32"))
3503 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3505 bypass_timeout = RTE_BYPASS_TMT_OFF;
3508 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3509 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3511 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3512 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3514 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3515 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3516 timeout, "timeout");
3517 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3518 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3519 value, "0#1.5#2#3#4#8#16#32");
3521 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3522 .f = cmd_set_bypass_timeout_parsed,
3523 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3524 "Set the NIC bypass watchdog timeout",
3527 (void *)&cmd_setbypass_timeout_set,
3528 (void *)&cmd_setbypass_timeout_bypass,
3529 (void *)&cmd_setbypass_timeout_timeout,
3530 (void *)&cmd_setbypass_timeout_value,
3535 /* *** SHOW NIC BYPASS MODE *** */
3536 struct cmd_show_bypass_config_result {
3537 cmdline_fixed_string_t show;
3538 cmdline_fixed_string_t bypass;
3539 cmdline_fixed_string_t config;
3544 cmd_show_bypass_config_parsed(void *parsed_result,
3545 __attribute__((unused)) struct cmdline *cl,
3546 __attribute__((unused)) void *data)
3548 struct cmd_show_bypass_config_result *res = parsed_result;
3549 uint32_t event_mode;
3550 uint32_t bypass_mode;
3551 portid_t port_id = res->port_id;
3552 uint32_t timeout = bypass_timeout;
3555 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3556 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3557 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3558 {"UNKNOWN", "normal", "bypass", "isolate"};
3559 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3566 int num_events = (sizeof events) / (sizeof events[0]);
3568 if (!bypass_is_supported(port_id))
3571 /* Display the bypass mode.*/
3572 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3573 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3577 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3578 bypass_mode = RTE_BYPASS_MODE_NONE;
3580 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3583 /* Display the bypass timeout.*/
3584 if (!RTE_BYPASS_TMT_VALID(timeout))
3585 timeout = RTE_BYPASS_TMT_OFF;
3587 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3589 /* Display the bypass events and associated modes. */
3590 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3592 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3593 printf("\tFailed to get bypass mode for event = %s\n",
3596 if (!RTE_BYPASS_MODE_VALID(event_mode))
3597 event_mode = RTE_BYPASS_MODE_NONE;
3599 printf("\tbypass event: %-16s = %s\n", events[i],
3605 cmdline_parse_token_string_t cmd_showbypass_config_show =
3606 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3608 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3609 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3611 cmdline_parse_token_string_t cmd_showbypass_config_config =
3612 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3614 cmdline_parse_token_num_t cmd_showbypass_config_port =
3615 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3618 cmdline_parse_inst_t cmd_show_bypass_config = {
3619 .f = cmd_show_bypass_config_parsed,
3620 .help_str = "show bypass config (port_id): "
3621 "Show the NIC bypass config for port_id",
3624 (void *)&cmd_showbypass_config_show,
3625 (void *)&cmd_showbypass_config_bypass,
3626 (void *)&cmd_showbypass_config_config,
3627 (void *)&cmd_showbypass_config_port,
3633 #ifdef RTE_LIBRTE_PMD_BOND
3634 /* *** SET BONDING MODE *** */
3635 struct cmd_set_bonding_mode_result {
3636 cmdline_fixed_string_t set;
3637 cmdline_fixed_string_t bonding;
3638 cmdline_fixed_string_t mode;
3643 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3644 __attribute__((unused)) struct cmdline *cl,
3645 __attribute__((unused)) void *data)
3647 struct cmd_set_bonding_mode_result *res = parsed_result;
3648 portid_t port_id = res->port_id;
3650 /* Set the bonding mode for the relevant port. */
3651 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3652 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3655 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3656 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3658 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3659 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3660 bonding, "bonding");
3661 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3662 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3664 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3665 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3667 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3668 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3671 cmdline_parse_inst_t cmd_set_bonding_mode = {
3672 .f = cmd_set_bonding_mode_parsed,
3673 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3676 (void *) &cmd_setbonding_mode_set,
3677 (void *) &cmd_setbonding_mode_bonding,
3678 (void *) &cmd_setbonding_mode_mode,
3679 (void *) &cmd_setbonding_mode_value,
3680 (void *) &cmd_setbonding_mode_port,
3685 /* *** SET BALANCE XMIT POLICY *** */
3686 struct cmd_set_bonding_balance_xmit_policy_result {
3687 cmdline_fixed_string_t set;
3688 cmdline_fixed_string_t bonding;
3689 cmdline_fixed_string_t balance_xmit_policy;
3691 cmdline_fixed_string_t policy;
3694 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3695 __attribute__((unused)) struct cmdline *cl,
3696 __attribute__((unused)) void *data)
3698 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3699 portid_t port_id = res->port_id;
3702 if (!strcmp(res->policy, "l2")) {
3703 policy = BALANCE_XMIT_POLICY_LAYER2;
3704 } else if (!strcmp(res->policy, "l23")) {
3705 policy = BALANCE_XMIT_POLICY_LAYER23;
3706 } else if (!strcmp(res->policy, "l34")) {
3707 policy = BALANCE_XMIT_POLICY_LAYER34;
3709 printf("\t Invalid xmit policy selection");
3713 /* Set the bonding mode for the relevant port. */
3714 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3715 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3720 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3721 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3723 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3724 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3725 bonding, "bonding");
3726 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3727 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3728 balance_xmit_policy, "balance_xmit_policy");
3729 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3730 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3732 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3733 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3734 policy, "l2#l23#l34");
3736 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3737 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3738 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3741 (void *)&cmd_setbonding_balance_xmit_policy_set,
3742 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3743 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3744 (void *)&cmd_setbonding_balance_xmit_policy_port,
3745 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3750 /* *** SHOW NIC BONDING CONFIGURATION *** */
3751 struct cmd_show_bonding_config_result {
3752 cmdline_fixed_string_t show;
3753 cmdline_fixed_string_t bonding;
3754 cmdline_fixed_string_t config;
3758 static void cmd_show_bonding_config_parsed(void *parsed_result,
3759 __attribute__((unused)) struct cmdline *cl,
3760 __attribute__((unused)) void *data)
3762 struct cmd_show_bonding_config_result *res = parsed_result;
3764 uint8_t slaves[RTE_MAX_ETHPORTS];
3765 int num_slaves, num_active_slaves;
3768 portid_t port_id = res->port_id;
3770 /* Display the bonding mode.*/
3771 bonding_mode = rte_eth_bond_mode_get(port_id);
3772 if (bonding_mode < 0) {
3773 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3776 printf("\tBonding mode: %d\n", bonding_mode);
3778 if (bonding_mode == BONDING_MODE_BALANCE) {
3779 int balance_xmit_policy;
3781 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3782 if (balance_xmit_policy < 0) {
3783 printf("\tFailed to get balance xmit policy for port = %d\n",
3787 printf("\tBalance Xmit Policy: ");
3789 switch (balance_xmit_policy) {
3790 case BALANCE_XMIT_POLICY_LAYER2:
3791 printf("BALANCE_XMIT_POLICY_LAYER2");
3793 case BALANCE_XMIT_POLICY_LAYER23:
3794 printf("BALANCE_XMIT_POLICY_LAYER23");
3796 case BALANCE_XMIT_POLICY_LAYER34:
3797 printf("BALANCE_XMIT_POLICY_LAYER34");
3804 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3806 if (num_slaves < 0) {
3807 printf("\tFailed to get slave list for port = %d\n", port_id);
3810 if (num_slaves > 0) {
3811 printf("\tSlaves (%d): [", num_slaves);
3812 for (i = 0; i < num_slaves - 1; i++)
3813 printf("%d ", slaves[i]);
3815 printf("%d]\n", slaves[num_slaves - 1]);
3817 printf("\tSlaves: []\n");
3821 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3824 if (num_active_slaves < 0) {
3825 printf("\tFailed to get active slave list for port = %d\n", port_id);
3828 if (num_active_slaves > 0) {
3829 printf("\tActive Slaves (%d): [", num_active_slaves);
3830 for (i = 0; i < num_active_slaves - 1; i++)
3831 printf("%d ", slaves[i]);
3833 printf("%d]\n", slaves[num_active_slaves - 1]);
3836 printf("\tActive Slaves: []\n");
3840 primary_id = rte_eth_bond_primary_get(port_id);
3841 if (primary_id < 0) {
3842 printf("\tFailed to get primary slave for port = %d\n", port_id);
3845 printf("\tPrimary: [%d]\n", primary_id);
3849 cmdline_parse_token_string_t cmd_showbonding_config_show =
3850 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3852 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3853 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3854 bonding, "bonding");
3855 cmdline_parse_token_string_t cmd_showbonding_config_config =
3856 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3858 cmdline_parse_token_num_t cmd_showbonding_config_port =
3859 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3862 cmdline_parse_inst_t cmd_show_bonding_config = {
3863 .f = cmd_show_bonding_config_parsed,
3864 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3867 (void *)&cmd_showbonding_config_show,
3868 (void *)&cmd_showbonding_config_bonding,
3869 (void *)&cmd_showbonding_config_config,
3870 (void *)&cmd_showbonding_config_port,
3875 /* *** SET BONDING PRIMARY *** */
3876 struct cmd_set_bonding_primary_result {
3877 cmdline_fixed_string_t set;
3878 cmdline_fixed_string_t bonding;
3879 cmdline_fixed_string_t primary;
3884 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3885 __attribute__((unused)) struct cmdline *cl,
3886 __attribute__((unused)) void *data)
3888 struct cmd_set_bonding_primary_result *res = parsed_result;
3889 portid_t master_port_id = res->port_id;
3890 portid_t slave_port_id = res->slave_id;
3892 /* Set the primary slave for a bonded device. */
3893 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3894 printf("\t Failed to set primary slave for port = %d.\n",
3901 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3902 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3904 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3906 bonding, "bonding");
3907 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3908 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3909 primary, "primary");
3910 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3911 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3913 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3914 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3917 cmdline_parse_inst_t cmd_set_bonding_primary = {
3918 .f = cmd_set_bonding_primary_parsed,
3919 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3922 (void *)&cmd_setbonding_primary_set,
3923 (void *)&cmd_setbonding_primary_bonding,
3924 (void *)&cmd_setbonding_primary_primary,
3925 (void *)&cmd_setbonding_primary_slave,
3926 (void *)&cmd_setbonding_primary_port,
3931 /* *** ADD SLAVE *** */
3932 struct cmd_add_bonding_slave_result {
3933 cmdline_fixed_string_t add;
3934 cmdline_fixed_string_t bonding;
3935 cmdline_fixed_string_t slave;
3940 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3941 __attribute__((unused)) struct cmdline *cl,
3942 __attribute__((unused)) void *data)
3944 struct cmd_add_bonding_slave_result *res = parsed_result;
3945 portid_t master_port_id = res->port_id;
3946 portid_t slave_port_id = res->slave_id;
3948 /* Set the primary slave for a bonded device. */
3949 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3950 printf("\t Failed to add slave %d to master port = %d.\n",
3951 slave_port_id, master_port_id);
3957 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3958 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3960 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3961 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3962 bonding, "bonding");
3963 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3964 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3966 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3967 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3969 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3970 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3973 cmdline_parse_inst_t cmd_add_bonding_slave = {
3974 .f = cmd_add_bonding_slave_parsed,
3975 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3978 (void *)&cmd_addbonding_slave_add,
3979 (void *)&cmd_addbonding_slave_bonding,
3980 (void *)&cmd_addbonding_slave_slave,
3981 (void *)&cmd_addbonding_slave_slaveid,
3982 (void *)&cmd_addbonding_slave_port,
3987 /* *** REMOVE SLAVE *** */
3988 struct cmd_remove_bonding_slave_result {
3989 cmdline_fixed_string_t remove;
3990 cmdline_fixed_string_t bonding;
3991 cmdline_fixed_string_t slave;
3996 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3997 __attribute__((unused)) struct cmdline *cl,
3998 __attribute__((unused)) void *data)
4000 struct cmd_remove_bonding_slave_result *res = parsed_result;
4001 portid_t master_port_id = res->port_id;
4002 portid_t slave_port_id = res->slave_id;
4004 /* Set the primary slave for a bonded device. */
4005 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4006 printf("\t Failed to remove slave %d from master port = %d.\n",
4007 slave_port_id, master_port_id);
4013 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4014 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4016 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4017 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4018 bonding, "bonding");
4019 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4020 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4022 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4023 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4025 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4026 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4029 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4030 .f = cmd_remove_bonding_slave_parsed,
4031 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4034 (void *)&cmd_removebonding_slave_remove,
4035 (void *)&cmd_removebonding_slave_bonding,
4036 (void *)&cmd_removebonding_slave_slave,
4037 (void *)&cmd_removebonding_slave_slaveid,
4038 (void *)&cmd_removebonding_slave_port,
4043 /* *** CREATE BONDED DEVICE *** */
4044 struct cmd_create_bonded_device_result {
4045 cmdline_fixed_string_t create;
4046 cmdline_fixed_string_t bonded;
4047 cmdline_fixed_string_t device;
4052 static int bond_dev_num = 0;
4054 static void cmd_create_bonded_device_parsed(void *parsed_result,
4055 __attribute__((unused)) struct cmdline *cl,
4056 __attribute__((unused)) void *data)
4058 struct cmd_create_bonded_device_result *res = parsed_result;
4059 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4062 if (test_done == 0) {
4063 printf("Please stop forwarding first\n");
4067 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4070 /* Create a new bonded device. */
4071 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4073 printf("\t Failed to create bonded device.\n");
4076 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4079 /* Update number of ports */
4080 nb_ports = rte_eth_dev_count();
4081 reconfig(port_id, res->socket);
4082 rte_eth_promiscuous_enable(port_id);
4083 ports[port_id].enabled = 1;
4088 cmdline_parse_token_string_t cmd_createbonded_device_create =
4089 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4091 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4092 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4094 cmdline_parse_token_string_t cmd_createbonded_device_device =
4095 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4097 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4098 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4100 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4101 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4104 cmdline_parse_inst_t cmd_create_bonded_device = {
4105 .f = cmd_create_bonded_device_parsed,
4106 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4109 (void *)&cmd_createbonded_device_create,
4110 (void *)&cmd_createbonded_device_bonded,
4111 (void *)&cmd_createbonded_device_device,
4112 (void *)&cmd_createbonded_device_mode,
4113 (void *)&cmd_createbonded_device_socket,
4118 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4119 struct cmd_set_bond_mac_addr_result {
4120 cmdline_fixed_string_t set;
4121 cmdline_fixed_string_t bonding;
4122 cmdline_fixed_string_t mac_addr;
4124 struct ether_addr address;
4127 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4128 __attribute__((unused)) struct cmdline *cl,
4129 __attribute__((unused)) void *data)
4131 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4134 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4137 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4139 /* check the return value and print it if is < 0 */
4141 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4144 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4145 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4146 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4147 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4149 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4150 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4152 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4153 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4154 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4155 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4157 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4158 .f = cmd_set_bond_mac_addr_parsed,
4160 .help_str = "set bonding mac_addr (port_id) (address): ",
4162 (void *)&cmd_set_bond_mac_addr_set,
4163 (void *)&cmd_set_bond_mac_addr_bonding,
4164 (void *)&cmd_set_bond_mac_addr_mac,
4165 (void *)&cmd_set_bond_mac_addr_portnum,
4166 (void *)&cmd_set_bond_mac_addr_addr,
4172 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4173 struct cmd_set_bond_mon_period_result {
4174 cmdline_fixed_string_t set;
4175 cmdline_fixed_string_t bonding;
4176 cmdline_fixed_string_t mon_period;
4181 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4182 __attribute__((unused)) struct cmdline *cl,
4183 __attribute__((unused)) void *data)
4185 struct cmd_set_bond_mon_period_result *res = parsed_result;
4188 if (res->port_num >= nb_ports) {
4189 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4193 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4195 /* check the return value and print it if is < 0 */
4197 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4200 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4201 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4203 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4204 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4205 bonding, "bonding");
4206 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4207 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4208 mon_period, "mon_period");
4209 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4210 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4212 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4213 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4216 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4217 .f = cmd_set_bond_mon_period_parsed,
4219 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4221 (void *)&cmd_set_bond_mon_period_set,
4222 (void *)&cmd_set_bond_mon_period_bonding,
4223 (void *)&cmd_set_bond_mon_period_mon_period,
4224 (void *)&cmd_set_bond_mon_period_portnum,
4225 (void *)&cmd_set_bond_mon_period_period_ms,
4230 #endif /* RTE_LIBRTE_PMD_BOND */
4232 /* *** SET FORWARDING MODE *** */
4233 struct cmd_set_fwd_mode_result {
4234 cmdline_fixed_string_t set;
4235 cmdline_fixed_string_t fwd;
4236 cmdline_fixed_string_t mode;
4239 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4240 __attribute__((unused)) struct cmdline *cl,
4241 __attribute__((unused)) void *data)
4243 struct cmd_set_fwd_mode_result *res = parsed_result;
4245 set_pkt_forwarding_mode(res->mode);
4248 cmdline_parse_token_string_t cmd_setfwd_set =
4249 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4250 cmdline_parse_token_string_t cmd_setfwd_fwd =
4251 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4252 cmdline_parse_token_string_t cmd_setfwd_mode =
4253 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4254 "" /* defined at init */);
4256 cmdline_parse_inst_t cmd_set_fwd_mode = {
4257 .f = cmd_set_fwd_mode_parsed,
4259 .help_str = NULL, /* defined at init */
4261 (void *)&cmd_setfwd_set,
4262 (void *)&cmd_setfwd_fwd,
4263 (void *)&cmd_setfwd_mode,
4268 static void cmd_set_fwd_mode_init(void)
4271 static char token[128];
4272 static char help[256];
4273 cmdline_parse_token_string_t *token_struct;
4275 modes = list_pkt_forwarding_modes();
4276 snprintf(help, sizeof help, "set fwd %s - "
4277 "set packet forwarding mode", modes);
4278 cmd_set_fwd_mode.help_str = help;
4280 /* string token separator is # */
4281 for (c = token; *modes != '\0'; modes++)
4286 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4287 token_struct->string_data.str = token;
4290 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4291 struct cmd_set_burst_tx_retry_result {
4292 cmdline_fixed_string_t set;
4293 cmdline_fixed_string_t burst;
4294 cmdline_fixed_string_t tx;
4295 cmdline_fixed_string_t delay;
4297 cmdline_fixed_string_t retry;
4301 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4302 __attribute__((unused)) struct cmdline *cl,
4303 __attribute__((unused)) void *data)
4305 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4307 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4308 && !strcmp(res->tx, "tx")) {
4309 if (!strcmp(res->delay, "delay"))
4310 burst_tx_delay_time = res->time;
4311 if (!strcmp(res->retry, "retry"))
4312 burst_tx_retry_num = res->retry_num;
4317 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4318 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4319 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4320 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4322 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4323 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4324 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4325 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4326 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4327 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4328 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4329 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4330 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4331 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4333 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4334 .f = cmd_set_burst_tx_retry_parsed,
4335 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4337 (void *)&cmd_set_burst_tx_retry_set,
4338 (void *)&cmd_set_burst_tx_retry_burst,
4339 (void *)&cmd_set_burst_tx_retry_tx,
4340 (void *)&cmd_set_burst_tx_retry_delay,
4341 (void *)&cmd_set_burst_tx_retry_time,
4342 (void *)&cmd_set_burst_tx_retry_retry,
4343 (void *)&cmd_set_burst_tx_retry_retry_num,
4348 /* *** SET PROMISC MODE *** */
4349 struct cmd_set_promisc_mode_result {
4350 cmdline_fixed_string_t set;
4351 cmdline_fixed_string_t promisc;
4352 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4353 uint8_t port_num; /* valid if "allports" argument == 0 */
4354 cmdline_fixed_string_t mode;
4357 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4358 __attribute__((unused)) struct cmdline *cl,
4361 struct cmd_set_promisc_mode_result *res = parsed_result;
4365 if (!strcmp(res->mode, "on"))
4372 FOREACH_PORT(i, ports) {
4374 rte_eth_promiscuous_enable(i);
4376 rte_eth_promiscuous_disable(i);
4381 rte_eth_promiscuous_enable(res->port_num);
4383 rte_eth_promiscuous_disable(res->port_num);
4387 cmdline_parse_token_string_t cmd_setpromisc_set =
4388 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4389 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4390 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4392 cmdline_parse_token_string_t cmd_setpromisc_portall =
4393 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4395 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4396 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4398 cmdline_parse_token_string_t cmd_setpromisc_mode =
4399 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4402 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4403 .f = cmd_set_promisc_mode_parsed,
4405 .help_str = "set promisc all on|off: set promisc mode for all ports",
4407 (void *)&cmd_setpromisc_set,
4408 (void *)&cmd_setpromisc_promisc,
4409 (void *)&cmd_setpromisc_portall,
4410 (void *)&cmd_setpromisc_mode,
4415 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4416 .f = cmd_set_promisc_mode_parsed,
4418 .help_str = "set promisc X on|off: set promisc mode on port X",
4420 (void *)&cmd_setpromisc_set,
4421 (void *)&cmd_setpromisc_promisc,
4422 (void *)&cmd_setpromisc_portnum,
4423 (void *)&cmd_setpromisc_mode,
4428 /* *** SET ALLMULTI MODE *** */
4429 struct cmd_set_allmulti_mode_result {
4430 cmdline_fixed_string_t set;
4431 cmdline_fixed_string_t allmulti;
4432 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4433 uint8_t port_num; /* valid if "allports" argument == 0 */
4434 cmdline_fixed_string_t mode;
4437 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4438 __attribute__((unused)) struct cmdline *cl,
4441 struct cmd_set_allmulti_mode_result *res = parsed_result;
4445 if (!strcmp(res->mode, "on"))
4452 FOREACH_PORT(i, ports) {
4454 rte_eth_allmulticast_enable(i);
4456 rte_eth_allmulticast_disable(i);
4461 rte_eth_allmulticast_enable(res->port_num);
4463 rte_eth_allmulticast_disable(res->port_num);
4467 cmdline_parse_token_string_t cmd_setallmulti_set =
4468 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4469 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4470 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4472 cmdline_parse_token_string_t cmd_setallmulti_portall =
4473 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4475 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4476 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4478 cmdline_parse_token_string_t cmd_setallmulti_mode =
4479 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4482 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4483 .f = cmd_set_allmulti_mode_parsed,
4485 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4487 (void *)&cmd_setallmulti_set,
4488 (void *)&cmd_setallmulti_allmulti,
4489 (void *)&cmd_setallmulti_portall,
4490 (void *)&cmd_setallmulti_mode,
4495 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4496 .f = cmd_set_allmulti_mode_parsed,
4498 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4500 (void *)&cmd_setallmulti_set,
4501 (void *)&cmd_setallmulti_allmulti,
4502 (void *)&cmd_setallmulti_portnum,
4503 (void *)&cmd_setallmulti_mode,
4508 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4509 struct cmd_link_flow_ctrl_set_result {
4510 cmdline_fixed_string_t set;
4511 cmdline_fixed_string_t flow_ctrl;
4512 cmdline_fixed_string_t rx;
4513 cmdline_fixed_string_t rx_lfc_mode;
4514 cmdline_fixed_string_t tx;
4515 cmdline_fixed_string_t tx_lfc_mode;
4516 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4517 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4518 cmdline_fixed_string_t autoneg_str;
4519 cmdline_fixed_string_t autoneg;
4520 cmdline_fixed_string_t hw_str;
4521 uint32_t high_water;
4522 cmdline_fixed_string_t lw_str;
4524 cmdline_fixed_string_t pt_str;
4525 uint16_t pause_time;
4526 cmdline_fixed_string_t xon_str;
4531 cmdline_parse_token_string_t cmd_lfc_set_set =
4532 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4534 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4535 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4536 flow_ctrl, "flow_ctrl");
4537 cmdline_parse_token_string_t cmd_lfc_set_rx =
4538 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4540 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4541 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4542 rx_lfc_mode, "on#off");
4543 cmdline_parse_token_string_t cmd_lfc_set_tx =
4544 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4546 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4547 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4548 tx_lfc_mode, "on#off");
4549 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4550 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4551 hw_str, "high_water");
4552 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4553 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4554 high_water, UINT32);
4555 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4556 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4557 lw_str, "low_water");
4558 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4559 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4561 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4562 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4563 pt_str, "pause_time");
4564 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4565 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4566 pause_time, UINT16);
4567 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4568 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4569 xon_str, "send_xon");
4570 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4571 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4573 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4574 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4575 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4576 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4577 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4578 mac_ctrl_frame_fwd_mode, "on#off");
4579 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4580 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4581 autoneg_str, "autoneg");
4582 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4583 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4585 cmdline_parse_token_num_t cmd_lfc_set_portid =
4586 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4589 /* forward declaration */
4591 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4594 cmdline_parse_inst_t cmd_link_flow_control_set = {
4595 .f = cmd_link_flow_ctrl_set_parsed,
4597 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4598 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4599 autoneg on|off port_id",
4601 (void *)&cmd_lfc_set_set,
4602 (void *)&cmd_lfc_set_flow_ctrl,
4603 (void *)&cmd_lfc_set_rx,
4604 (void *)&cmd_lfc_set_rx_mode,
4605 (void *)&cmd_lfc_set_tx,
4606 (void *)&cmd_lfc_set_tx_mode,
4607 (void *)&cmd_lfc_set_high_water,
4608 (void *)&cmd_lfc_set_low_water,
4609 (void *)&cmd_lfc_set_pause_time,
4610 (void *)&cmd_lfc_set_send_xon,
4611 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4612 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4613 (void *)&cmd_lfc_set_autoneg_str,
4614 (void *)&cmd_lfc_set_autoneg,
4615 (void *)&cmd_lfc_set_portid,
4620 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4621 .f = cmd_link_flow_ctrl_set_parsed,
4622 .data = (void *)&cmd_link_flow_control_set_rx,
4623 .help_str = "Change rx flow control parameter: set flow_ctrl "
4624 "rx on|off port_id",
4626 (void *)&cmd_lfc_set_set,
4627 (void *)&cmd_lfc_set_flow_ctrl,
4628 (void *)&cmd_lfc_set_rx,
4629 (void *)&cmd_lfc_set_rx_mode,
4630 (void *)&cmd_lfc_set_portid,
4635 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4636 .f = cmd_link_flow_ctrl_set_parsed,
4637 .data = (void *)&cmd_link_flow_control_set_tx,
4638 .help_str = "Change tx flow control parameter: set flow_ctrl "
4639 "tx on|off port_id",
4641 (void *)&cmd_lfc_set_set,
4642 (void *)&cmd_lfc_set_flow_ctrl,
4643 (void *)&cmd_lfc_set_tx,
4644 (void *)&cmd_lfc_set_tx_mode,
4645 (void *)&cmd_lfc_set_portid,
4650 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4651 .f = cmd_link_flow_ctrl_set_parsed,
4652 .data = (void *)&cmd_link_flow_control_set_hw,
4653 .help_str = "Change high water flow control parameter: set flow_ctrl "
4654 "high_water value port_id",
4656 (void *)&cmd_lfc_set_set,
4657 (void *)&cmd_lfc_set_flow_ctrl,
4658 (void *)&cmd_lfc_set_high_water_str,
4659 (void *)&cmd_lfc_set_high_water,
4660 (void *)&cmd_lfc_set_portid,
4665 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4666 .f = cmd_link_flow_ctrl_set_parsed,
4667 .data = (void *)&cmd_link_flow_control_set_lw,
4668 .help_str = "Change low water flow control parameter: set flow_ctrl "
4669 "low_water value port_id",
4671 (void *)&cmd_lfc_set_set,
4672 (void *)&cmd_lfc_set_flow_ctrl,
4673 (void *)&cmd_lfc_set_low_water_str,
4674 (void *)&cmd_lfc_set_low_water,
4675 (void *)&cmd_lfc_set_portid,
4680 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4681 .f = cmd_link_flow_ctrl_set_parsed,
4682 .data = (void *)&cmd_link_flow_control_set_pt,
4683 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4684 "pause_time value port_id",
4686 (void *)&cmd_lfc_set_set,
4687 (void *)&cmd_lfc_set_flow_ctrl,
4688 (void *)&cmd_lfc_set_pause_time_str,
4689 (void *)&cmd_lfc_set_pause_time,
4690 (void *)&cmd_lfc_set_portid,
4695 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4696 .f = cmd_link_flow_ctrl_set_parsed,
4697 .data = (void *)&cmd_link_flow_control_set_xon,
4698 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4699 "send_xon value port_id",
4701 (void *)&cmd_lfc_set_set,
4702 (void *)&cmd_lfc_set_flow_ctrl,
4703 (void *)&cmd_lfc_set_send_xon_str,
4704 (void *)&cmd_lfc_set_send_xon,
4705 (void *)&cmd_lfc_set_portid,
4710 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4711 .f = cmd_link_flow_ctrl_set_parsed,
4712 .data = (void *)&cmd_link_flow_control_set_macfwd,
4713 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4714 "mac_ctrl_frame_fwd on|off port_id",
4716 (void *)&cmd_lfc_set_set,
4717 (void *)&cmd_lfc_set_flow_ctrl,
4718 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4719 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4720 (void *)&cmd_lfc_set_portid,
4725 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4726 .f = cmd_link_flow_ctrl_set_parsed,
4727 .data = (void *)&cmd_link_flow_control_set_autoneg,
4728 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4729 "autoneg on|off port_id",
4731 (void *)&cmd_lfc_set_set,
4732 (void *)&cmd_lfc_set_flow_ctrl,
4733 (void *)&cmd_lfc_set_autoneg_str,
4734 (void *)&cmd_lfc_set_autoneg,
4735 (void *)&cmd_lfc_set_portid,
4741 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4742 __attribute__((unused)) struct cmdline *cl,
4745 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4746 cmdline_parse_inst_t *cmd = data;
4747 struct rte_eth_fc_conf fc_conf;
4748 int rx_fc_en, tx_fc_en = 0;
4752 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4753 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4754 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4755 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4757 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4758 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4761 /* Partial command line, retrieve current configuration */
4763 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4765 printf("cannot get current flow ctrl parameters, return"
4766 "code = %d\n", ret);
4770 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4771 (fc_conf.mode == RTE_FC_FULL))
4773 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4774 (fc_conf.mode == RTE_FC_FULL))
4778 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4779 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4781 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4782 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4784 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4786 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4787 fc_conf.high_water = res->high_water;
4789 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4790 fc_conf.low_water = res->low_water;
4792 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4793 fc_conf.pause_time = res->pause_time;
4795 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4796 fc_conf.send_xon = res->send_xon;
4798 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4799 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4800 fc_conf.mac_ctrl_frame_fwd = 1;
4802 fc_conf.mac_ctrl_frame_fwd = 0;
4805 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4806 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4808 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4810 printf("bad flow contrl parameter, return code = %d \n", ret);
4813 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4814 struct cmd_priority_flow_ctrl_set_result {
4815 cmdline_fixed_string_t set;
4816 cmdline_fixed_string_t pfc_ctrl;
4817 cmdline_fixed_string_t rx;
4818 cmdline_fixed_string_t rx_pfc_mode;
4819 cmdline_fixed_string_t tx;
4820 cmdline_fixed_string_t tx_pfc_mode;
4821 uint32_t high_water;
4823 uint16_t pause_time;
4829 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4830 __attribute__((unused)) struct cmdline *cl,
4831 __attribute__((unused)) void *data)
4833 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4834 struct rte_eth_pfc_conf pfc_conf;
4835 int rx_fc_enable, tx_fc_enable;
4839 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4840 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4841 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4842 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4844 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4845 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4848 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4849 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4850 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4851 pfc_conf.fc.high_water = res->high_water;
4852 pfc_conf.fc.low_water = res->low_water;
4853 pfc_conf.fc.pause_time = res->pause_time;
4854 pfc_conf.priority = res->priority;
4856 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4858 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4861 cmdline_parse_token_string_t cmd_pfc_set_set =
4862 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4864 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4865 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4866 pfc_ctrl, "pfc_ctrl");
4867 cmdline_parse_token_string_t cmd_pfc_set_rx =
4868 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4870 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4871 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4872 rx_pfc_mode, "on#off");
4873 cmdline_parse_token_string_t cmd_pfc_set_tx =
4874 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4876 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4877 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4878 tx_pfc_mode, "on#off");
4879 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4880 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4881 high_water, UINT32);
4882 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4883 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4885 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4886 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4887 pause_time, UINT16);
4888 cmdline_parse_token_num_t cmd_pfc_set_priority =
4889 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4891 cmdline_parse_token_num_t cmd_pfc_set_portid =
4892 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4895 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4896 .f = cmd_priority_flow_ctrl_set_parsed,
4898 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4899 tx on|off high_water low_water pause_time priority port_id",
4901 (void *)&cmd_pfc_set_set,
4902 (void *)&cmd_pfc_set_flow_ctrl,
4903 (void *)&cmd_pfc_set_rx,
4904 (void *)&cmd_pfc_set_rx_mode,
4905 (void *)&cmd_pfc_set_tx,
4906 (void *)&cmd_pfc_set_tx_mode,
4907 (void *)&cmd_pfc_set_high_water,
4908 (void *)&cmd_pfc_set_low_water,
4909 (void *)&cmd_pfc_set_pause_time,
4910 (void *)&cmd_pfc_set_priority,
4911 (void *)&cmd_pfc_set_portid,
4916 /* *** RESET CONFIGURATION *** */
4917 struct cmd_reset_result {
4918 cmdline_fixed_string_t reset;
4919 cmdline_fixed_string_t def;
4922 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4924 __attribute__((unused)) void *data)
4926 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4927 set_def_fwd_config();
4930 cmdline_parse_token_string_t cmd_reset_set =
4931 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4932 cmdline_parse_token_string_t cmd_reset_def =
4933 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4936 cmdline_parse_inst_t cmd_reset = {
4937 .f = cmd_reset_parsed,
4939 .help_str = "set default: reset default forwarding configuration",
4941 (void *)&cmd_reset_set,
4942 (void *)&cmd_reset_def,
4947 /* *** START FORWARDING *** */
4948 struct cmd_start_result {
4949 cmdline_fixed_string_t start;
4952 cmdline_parse_token_string_t cmd_start_start =
4953 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4955 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4956 __attribute__((unused)) struct cmdline *cl,
4957 __attribute__((unused)) void *data)
4959 start_packet_forwarding(0);
4962 cmdline_parse_inst_t cmd_start = {
4963 .f = cmd_start_parsed,
4965 .help_str = "start packet forwarding",
4967 (void *)&cmd_start_start,
4972 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4973 struct cmd_start_tx_first_result {
4974 cmdline_fixed_string_t start;
4975 cmdline_fixed_string_t tx_first;
4979 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4980 __attribute__((unused)) struct cmdline *cl,
4981 __attribute__((unused)) void *data)
4983 start_packet_forwarding(1);
4986 cmdline_parse_token_string_t cmd_start_tx_first_start =
4987 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4989 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4990 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4991 tx_first, "tx_first");
4993 cmdline_parse_inst_t cmd_start_tx_first = {
4994 .f = cmd_start_tx_first_parsed,
4996 .help_str = "start packet forwarding, after sending 1 burst of packets",
4998 (void *)&cmd_start_tx_first_start,
4999 (void *)&cmd_start_tx_first_tx_first,
5004 /* *** SET LINK UP *** */
5005 struct cmd_set_link_up_result {
5006 cmdline_fixed_string_t set;
5007 cmdline_fixed_string_t link_up;
5008 cmdline_fixed_string_t port;
5012 cmdline_parse_token_string_t cmd_set_link_up_set =
5013 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5014 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5015 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5017 cmdline_parse_token_string_t cmd_set_link_up_port =
5018 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5019 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5020 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5022 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5023 __attribute__((unused)) struct cmdline *cl,
5024 __attribute__((unused)) void *data)
5026 struct cmd_set_link_up_result *res = parsed_result;
5027 dev_set_link_up(res->port_id);
5030 cmdline_parse_inst_t cmd_set_link_up = {
5031 .f = cmd_set_link_up_parsed,
5033 .help_str = "set link-up port (port id)",
5035 (void *)&cmd_set_link_up_set,
5036 (void *)&cmd_set_link_up_link_up,
5037 (void *)&cmd_set_link_up_port,
5038 (void *)&cmd_set_link_up_port_id,
5043 /* *** SET LINK DOWN *** */
5044 struct cmd_set_link_down_result {
5045 cmdline_fixed_string_t set;
5046 cmdline_fixed_string_t link_down;
5047 cmdline_fixed_string_t port;
5051 cmdline_parse_token_string_t cmd_set_link_down_set =
5052 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5053 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5054 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5056 cmdline_parse_token_string_t cmd_set_link_down_port =
5057 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5058 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5059 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5061 static void cmd_set_link_down_parsed(
5062 __attribute__((unused)) void *parsed_result,
5063 __attribute__((unused)) struct cmdline *cl,
5064 __attribute__((unused)) void *data)
5066 struct cmd_set_link_down_result *res = parsed_result;
5067 dev_set_link_down(res->port_id);
5070 cmdline_parse_inst_t cmd_set_link_down = {
5071 .f = cmd_set_link_down_parsed,
5073 .help_str = "set link-down port (port id)",
5075 (void *)&cmd_set_link_down_set,
5076 (void *)&cmd_set_link_down_link_down,
5077 (void *)&cmd_set_link_down_port,
5078 (void *)&cmd_set_link_down_port_id,
5083 /* *** SHOW CFG *** */
5084 struct cmd_showcfg_result {
5085 cmdline_fixed_string_t show;
5086 cmdline_fixed_string_t cfg;
5087 cmdline_fixed_string_t what;
5090 static void cmd_showcfg_parsed(void *parsed_result,
5091 __attribute__((unused)) struct cmdline *cl,
5092 __attribute__((unused)) void *data)
5094 struct cmd_showcfg_result *res = parsed_result;
5095 if (!strcmp(res->what, "rxtx"))
5096 rxtx_config_display();
5097 else if (!strcmp(res->what, "cores"))
5098 fwd_lcores_config_display();
5099 else if (!strcmp(res->what, "fwd"))
5100 fwd_config_display();
5103 cmdline_parse_token_string_t cmd_showcfg_show =
5104 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5105 cmdline_parse_token_string_t cmd_showcfg_port =
5106 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5107 cmdline_parse_token_string_t cmd_showcfg_what =
5108 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5111 cmdline_parse_inst_t cmd_showcfg = {
5112 .f = cmd_showcfg_parsed,
5114 .help_str = "show config rxtx|cores|fwd",
5116 (void *)&cmd_showcfg_show,
5117 (void *)&cmd_showcfg_port,
5118 (void *)&cmd_showcfg_what,
5123 /* *** SHOW ALL PORT INFO *** */
5124 struct cmd_showportall_result {
5125 cmdline_fixed_string_t show;
5126 cmdline_fixed_string_t port;
5127 cmdline_fixed_string_t what;
5128 cmdline_fixed_string_t all;
5131 static void cmd_showportall_parsed(void *parsed_result,
5132 __attribute__((unused)) struct cmdline *cl,
5133 __attribute__((unused)) void *data)
5137 struct cmd_showportall_result *res = parsed_result;
5138 if (!strcmp(res->show, "clear")) {
5139 if (!strcmp(res->what, "stats"))
5140 FOREACH_PORT(i, ports)
5142 else if (!strcmp(res->what, "xstats"))
5143 FOREACH_PORT(i, ports)
5144 nic_xstats_clear(i);
5145 } else if (!strcmp(res->what, "info"))
5146 FOREACH_PORT(i, ports)
5147 port_infos_display(i);
5148 else if (!strcmp(res->what, "stats"))
5149 FOREACH_PORT(i, ports)
5150 nic_stats_display(i);
5151 else if (!strcmp(res->what, "xstats"))
5152 FOREACH_PORT(i, ports)
5153 nic_xstats_display(i);
5154 else if (!strcmp(res->what, "fdir"))
5155 FOREACH_PORT(i, ports)
5157 else if (!strcmp(res->what, "stat_qmap"))
5158 FOREACH_PORT(i, ports)
5159 nic_stats_mapping_display(i);
5162 cmdline_parse_token_string_t cmd_showportall_show =
5163 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5165 cmdline_parse_token_string_t cmd_showportall_port =
5166 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5167 cmdline_parse_token_string_t cmd_showportall_what =
5168 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5169 "info#stats#xstats#fdir#stat_qmap");
5170 cmdline_parse_token_string_t cmd_showportall_all =
5171 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5172 cmdline_parse_inst_t cmd_showportall = {
5173 .f = cmd_showportall_parsed,
5175 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5177 (void *)&cmd_showportall_show,
5178 (void *)&cmd_showportall_port,
5179 (void *)&cmd_showportall_what,
5180 (void *)&cmd_showportall_all,
5185 /* *** SHOW PORT INFO *** */
5186 struct cmd_showport_result {
5187 cmdline_fixed_string_t show;
5188 cmdline_fixed_string_t port;
5189 cmdline_fixed_string_t what;
5193 static void cmd_showport_parsed(void *parsed_result,
5194 __attribute__((unused)) struct cmdline *cl,
5195 __attribute__((unused)) void *data)
5197 struct cmd_showport_result *res = parsed_result;
5198 if (!strcmp(res->show, "clear")) {
5199 if (!strcmp(res->what, "stats"))
5200 nic_stats_clear(res->portnum);
5201 else if (!strcmp(res->what, "xstats"))
5202 nic_xstats_clear(res->portnum);
5203 } else if (!strcmp(res->what, "info"))
5204 port_infos_display(res->portnum);
5205 else if (!strcmp(res->what, "stats"))
5206 nic_stats_display(res->portnum);
5207 else if (!strcmp(res->what, "xstats"))
5208 nic_xstats_display(res->portnum);
5209 else if (!strcmp(res->what, "fdir"))
5210 fdir_get_infos(res->portnum);
5211 else if (!strcmp(res->what, "stat_qmap"))
5212 nic_stats_mapping_display(res->portnum);
5215 cmdline_parse_token_string_t cmd_showport_show =
5216 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5218 cmdline_parse_token_string_t cmd_showport_port =
5219 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5220 cmdline_parse_token_string_t cmd_showport_what =
5221 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5222 "info#stats#xstats#fdir#stat_qmap");
5223 cmdline_parse_token_num_t cmd_showport_portnum =
5224 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5226 cmdline_parse_inst_t cmd_showport = {
5227 .f = cmd_showport_parsed,
5229 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5231 (void *)&cmd_showport_show,
5232 (void *)&cmd_showport_port,
5233 (void *)&cmd_showport_what,
5234 (void *)&cmd_showport_portnum,
5239 /* *** READ PORT REGISTER *** */
5240 struct cmd_read_reg_result {
5241 cmdline_fixed_string_t read;
5242 cmdline_fixed_string_t reg;
5248 cmd_read_reg_parsed(void *parsed_result,
5249 __attribute__((unused)) struct cmdline *cl,
5250 __attribute__((unused)) void *data)
5252 struct cmd_read_reg_result *res = parsed_result;
5253 port_reg_display(res->port_id, res->reg_off);
5256 cmdline_parse_token_string_t cmd_read_reg_read =
5257 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5258 cmdline_parse_token_string_t cmd_read_reg_reg =
5259 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5260 cmdline_parse_token_num_t cmd_read_reg_port_id =
5261 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5262 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5263 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5265 cmdline_parse_inst_t cmd_read_reg = {
5266 .f = cmd_read_reg_parsed,
5268 .help_str = "read reg port_id reg_off",
5270 (void *)&cmd_read_reg_read,
5271 (void *)&cmd_read_reg_reg,
5272 (void *)&cmd_read_reg_port_id,
5273 (void *)&cmd_read_reg_reg_off,
5278 /* *** READ PORT REGISTER BIT FIELD *** */
5279 struct cmd_read_reg_bit_field_result {
5280 cmdline_fixed_string_t read;
5281 cmdline_fixed_string_t regfield;
5289 cmd_read_reg_bit_field_parsed(void *parsed_result,
5290 __attribute__((unused)) struct cmdline *cl,
5291 __attribute__((unused)) void *data)
5293 struct cmd_read_reg_bit_field_result *res = parsed_result;
5294 port_reg_bit_field_display(res->port_id, res->reg_off,
5295 res->bit1_pos, res->bit2_pos);
5298 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5299 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5301 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5302 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5303 regfield, "regfield");
5304 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5305 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5307 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5308 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5310 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5311 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5313 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5314 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5317 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5318 .f = cmd_read_reg_bit_field_parsed,
5320 .help_str = "read regfield port_id reg_off bit_x bit_y "
5321 "(read register bit field between bit_x and bit_y included)",
5323 (void *)&cmd_read_reg_bit_field_read,
5324 (void *)&cmd_read_reg_bit_field_regfield,
5325 (void *)&cmd_read_reg_bit_field_port_id,
5326 (void *)&cmd_read_reg_bit_field_reg_off,
5327 (void *)&cmd_read_reg_bit_field_bit1_pos,
5328 (void *)&cmd_read_reg_bit_field_bit2_pos,
5333 /* *** READ PORT REGISTER BIT *** */
5334 struct cmd_read_reg_bit_result {
5335 cmdline_fixed_string_t read;
5336 cmdline_fixed_string_t regbit;
5343 cmd_read_reg_bit_parsed(void *parsed_result,
5344 __attribute__((unused)) struct cmdline *cl,
5345 __attribute__((unused)) void *data)
5347 struct cmd_read_reg_bit_result *res = parsed_result;
5348 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5351 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5352 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5353 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5354 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5356 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5357 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5358 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5359 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5360 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5361 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5363 cmdline_parse_inst_t cmd_read_reg_bit = {
5364 .f = cmd_read_reg_bit_parsed,
5366 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5368 (void *)&cmd_read_reg_bit_read,
5369 (void *)&cmd_read_reg_bit_regbit,
5370 (void *)&cmd_read_reg_bit_port_id,
5371 (void *)&cmd_read_reg_bit_reg_off,
5372 (void *)&cmd_read_reg_bit_bit_pos,
5377 /* *** WRITE PORT REGISTER *** */
5378 struct cmd_write_reg_result {
5379 cmdline_fixed_string_t write;
5380 cmdline_fixed_string_t reg;
5387 cmd_write_reg_parsed(void *parsed_result,
5388 __attribute__((unused)) struct cmdline *cl,
5389 __attribute__((unused)) void *data)
5391 struct cmd_write_reg_result *res = parsed_result;
5392 port_reg_set(res->port_id, res->reg_off, res->value);
5395 cmdline_parse_token_string_t cmd_write_reg_write =
5396 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5397 cmdline_parse_token_string_t cmd_write_reg_reg =
5398 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5399 cmdline_parse_token_num_t cmd_write_reg_port_id =
5400 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5401 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5402 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5403 cmdline_parse_token_num_t cmd_write_reg_value =
5404 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5406 cmdline_parse_inst_t cmd_write_reg = {
5407 .f = cmd_write_reg_parsed,
5409 .help_str = "write reg port_id reg_off reg_value",
5411 (void *)&cmd_write_reg_write,
5412 (void *)&cmd_write_reg_reg,
5413 (void *)&cmd_write_reg_port_id,
5414 (void *)&cmd_write_reg_reg_off,
5415 (void *)&cmd_write_reg_value,
5420 /* *** WRITE PORT REGISTER BIT FIELD *** */
5421 struct cmd_write_reg_bit_field_result {
5422 cmdline_fixed_string_t write;
5423 cmdline_fixed_string_t regfield;
5432 cmd_write_reg_bit_field_parsed(void *parsed_result,
5433 __attribute__((unused)) struct cmdline *cl,
5434 __attribute__((unused)) void *data)
5436 struct cmd_write_reg_bit_field_result *res = parsed_result;
5437 port_reg_bit_field_set(res->port_id, res->reg_off,
5438 res->bit1_pos, res->bit2_pos, res->value);
5441 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5442 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5444 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5445 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5446 regfield, "regfield");
5447 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5448 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5450 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5451 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5453 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5454 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5456 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5457 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5459 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5460 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5463 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5464 .f = cmd_write_reg_bit_field_parsed,
5466 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5467 "(set register bit field between bit_x and bit_y included)",
5469 (void *)&cmd_write_reg_bit_field_write,
5470 (void *)&cmd_write_reg_bit_field_regfield,
5471 (void *)&cmd_write_reg_bit_field_port_id,
5472 (void *)&cmd_write_reg_bit_field_reg_off,
5473 (void *)&cmd_write_reg_bit_field_bit1_pos,
5474 (void *)&cmd_write_reg_bit_field_bit2_pos,
5475 (void *)&cmd_write_reg_bit_field_value,
5480 /* *** WRITE PORT REGISTER BIT *** */
5481 struct cmd_write_reg_bit_result {
5482 cmdline_fixed_string_t write;
5483 cmdline_fixed_string_t regbit;
5491 cmd_write_reg_bit_parsed(void *parsed_result,
5492 __attribute__((unused)) struct cmdline *cl,
5493 __attribute__((unused)) void *data)
5495 struct cmd_write_reg_bit_result *res = parsed_result;
5496 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5499 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5500 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5502 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5503 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5505 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5506 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5507 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5508 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5509 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5510 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5511 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5512 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5514 cmdline_parse_inst_t cmd_write_reg_bit = {
5515 .f = cmd_write_reg_bit_parsed,
5517 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5519 (void *)&cmd_write_reg_bit_write,
5520 (void *)&cmd_write_reg_bit_regbit,
5521 (void *)&cmd_write_reg_bit_port_id,
5522 (void *)&cmd_write_reg_bit_reg_off,
5523 (void *)&cmd_write_reg_bit_bit_pos,
5524 (void *)&cmd_write_reg_bit_value,
5529 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5530 struct cmd_read_rxd_txd_result {
5531 cmdline_fixed_string_t read;
5532 cmdline_fixed_string_t rxd_txd;
5539 cmd_read_rxd_txd_parsed(void *parsed_result,
5540 __attribute__((unused)) struct cmdline *cl,
5541 __attribute__((unused)) void *data)
5543 struct cmd_read_rxd_txd_result *res = parsed_result;
5545 if (!strcmp(res->rxd_txd, "rxd"))
5546 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5547 else if (!strcmp(res->rxd_txd, "txd"))
5548 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5551 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5552 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5553 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5554 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5556 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5557 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5558 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5559 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5560 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5561 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5563 cmdline_parse_inst_t cmd_read_rxd_txd = {
5564 .f = cmd_read_rxd_txd_parsed,
5566 .help_str = "read rxd|txd port_id queue_id rxd_id",
5568 (void *)&cmd_read_rxd_txd_read,
5569 (void *)&cmd_read_rxd_txd_rxd_txd,
5570 (void *)&cmd_read_rxd_txd_port_id,
5571 (void *)&cmd_read_rxd_txd_queue_id,
5572 (void *)&cmd_read_rxd_txd_desc_id,
5578 struct cmd_quit_result {
5579 cmdline_fixed_string_t quit;
5582 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5584 __attribute__((unused)) void *data)
5590 cmdline_parse_token_string_t cmd_quit_quit =
5591 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5593 cmdline_parse_inst_t cmd_quit = {
5594 .f = cmd_quit_parsed,
5596 .help_str = "exit application",
5598 (void *)&cmd_quit_quit,
5603 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5604 struct cmd_mac_addr_result {
5605 cmdline_fixed_string_t mac_addr_cmd;
5606 cmdline_fixed_string_t what;
5608 struct ether_addr address;
5611 static void cmd_mac_addr_parsed(void *parsed_result,
5612 __attribute__((unused)) struct cmdline *cl,
5613 __attribute__((unused)) void *data)
5615 struct cmd_mac_addr_result *res = parsed_result;
5618 if (strcmp(res->what, "add") == 0)
5619 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5621 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5623 /* check the return value and print it if is < 0 */
5625 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5629 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5630 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5632 cmdline_parse_token_string_t cmd_mac_addr_what =
5633 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5635 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5636 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5637 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5638 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5640 cmdline_parse_inst_t cmd_mac_addr = {
5641 .f = cmd_mac_addr_parsed,
5643 .help_str = "mac_addr add|remove X <address>: "
5644 "add/remove MAC address on port X",
5646 (void *)&cmd_mac_addr_cmd,
5647 (void *)&cmd_mac_addr_what,
5648 (void *)&cmd_mac_addr_portnum,
5649 (void *)&cmd_mac_addr_addr,
5655 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5656 struct cmd_set_qmap_result {
5657 cmdline_fixed_string_t set;
5658 cmdline_fixed_string_t qmap;
5659 cmdline_fixed_string_t what;
5666 cmd_set_qmap_parsed(void *parsed_result,
5667 __attribute__((unused)) struct cmdline *cl,
5668 __attribute__((unused)) void *data)
5670 struct cmd_set_qmap_result *res = parsed_result;
5671 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5673 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5676 cmdline_parse_token_string_t cmd_setqmap_set =
5677 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5679 cmdline_parse_token_string_t cmd_setqmap_qmap =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5682 cmdline_parse_token_string_t cmd_setqmap_what =
5683 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5685 cmdline_parse_token_num_t cmd_setqmap_portid =
5686 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5688 cmdline_parse_token_num_t cmd_setqmap_queueid =
5689 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5691 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5692 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5695 cmdline_parse_inst_t cmd_set_qmap = {
5696 .f = cmd_set_qmap_parsed,
5698 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5700 (void *)&cmd_setqmap_set,
5701 (void *)&cmd_setqmap_qmap,
5702 (void *)&cmd_setqmap_what,
5703 (void *)&cmd_setqmap_portid,
5704 (void *)&cmd_setqmap_queueid,
5705 (void *)&cmd_setqmap_mapvalue,
5710 /* *** CONFIGURE UNICAST HASH TABLE *** */
5711 struct cmd_set_uc_hash_table {
5712 cmdline_fixed_string_t set;
5713 cmdline_fixed_string_t port;
5715 cmdline_fixed_string_t what;
5716 struct ether_addr address;
5717 cmdline_fixed_string_t mode;
5721 cmd_set_uc_hash_parsed(void *parsed_result,
5722 __attribute__((unused)) struct cmdline *cl,
5723 __attribute__((unused)) void *data)
5726 struct cmd_set_uc_hash_table *res = parsed_result;
5728 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5730 if (strcmp(res->what, "uta") == 0)
5731 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5732 &res->address,(uint8_t)is_on);
5734 printf("bad unicast hash table parameter, return code = %d \n", ret);
5738 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5739 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5741 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5742 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5744 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5745 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5747 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5748 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5750 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5751 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5753 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5754 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5757 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5758 .f = cmd_set_uc_hash_parsed,
5760 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5762 (void *)&cmd_set_uc_hash_set,
5763 (void *)&cmd_set_uc_hash_port,
5764 (void *)&cmd_set_uc_hash_portid,
5765 (void *)&cmd_set_uc_hash_what,
5766 (void *)&cmd_set_uc_hash_mac,
5767 (void *)&cmd_set_uc_hash_mode,
5772 struct cmd_set_uc_all_hash_table {
5773 cmdline_fixed_string_t set;
5774 cmdline_fixed_string_t port;
5776 cmdline_fixed_string_t what;
5777 cmdline_fixed_string_t value;
5778 cmdline_fixed_string_t mode;
5782 cmd_set_uc_all_hash_parsed(void *parsed_result,
5783 __attribute__((unused)) struct cmdline *cl,
5784 __attribute__((unused)) void *data)
5787 struct cmd_set_uc_all_hash_table *res = parsed_result;
5789 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5791 if ((strcmp(res->what, "uta") == 0) &&
5792 (strcmp(res->value, "all") == 0))
5793 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5795 printf("bad unicast hash table parameter,"
5796 "return code = %d \n", ret);
5799 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5800 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5802 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5803 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5805 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5806 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5808 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5809 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5811 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5812 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5814 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5815 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5818 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5819 .f = cmd_set_uc_all_hash_parsed,
5821 .help_str = "set port X uta all on|off (X = port number)",
5823 (void *)&cmd_set_uc_all_hash_set,
5824 (void *)&cmd_set_uc_all_hash_port,
5825 (void *)&cmd_set_uc_all_hash_portid,
5826 (void *)&cmd_set_uc_all_hash_what,
5827 (void *)&cmd_set_uc_all_hash_value,
5828 (void *)&cmd_set_uc_all_hash_mode,
5833 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5834 struct cmd_set_vf_macvlan_filter {
5835 cmdline_fixed_string_t set;
5836 cmdline_fixed_string_t port;
5838 cmdline_fixed_string_t vf;
5840 struct ether_addr address;
5841 cmdline_fixed_string_t filter_type;
5842 cmdline_fixed_string_t mode;
5846 cmd_set_vf_macvlan_parsed(void *parsed_result,
5847 __attribute__((unused)) struct cmdline *cl,
5848 __attribute__((unused)) void *data)
5851 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5852 struct rte_eth_mac_filter filter;
5854 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5856 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5858 /* set VF MAC filter */
5862 filter.dst_id = res->vf_id;
5864 if (!strcmp(res->filter_type, "exact-mac"))
5865 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5866 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5867 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5868 else if (!strcmp(res->filter_type, "hashmac"))
5869 filter.filter_type = RTE_MAC_HASH_MATCH;
5870 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5871 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5873 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5876 ret = rte_eth_dev_filter_ctrl(res->port_id,
5877 RTE_ETH_FILTER_MACVLAN,
5881 ret = rte_eth_dev_filter_ctrl(res->port_id,
5882 RTE_ETH_FILTER_MACVLAN,
5883 RTE_ETH_FILTER_DELETE,
5887 printf("bad set MAC hash parameter, return code = %d\n", ret);
5891 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5892 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5894 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5895 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5897 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5898 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5900 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5901 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5903 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5904 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5906 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5907 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5909 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5910 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5911 filter_type, "exact-mac#exact-mac-vlan"
5912 "#hashmac#hashmac-vlan");
5913 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5917 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5918 .f = cmd_set_vf_macvlan_parsed,
5920 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5921 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5923 "exact match rule:exact match of MAC or MAC and VLAN; "
5924 "hash match rule: hash match of MAC and exact match "
5927 (void *)&cmd_set_vf_macvlan_set,
5928 (void *)&cmd_set_vf_macvlan_port,
5929 (void *)&cmd_set_vf_macvlan_portid,
5930 (void *)&cmd_set_vf_macvlan_vf,
5931 (void *)&cmd_set_vf_macvlan_vf_id,
5932 (void *)&cmd_set_vf_macvlan_mac,
5933 (void *)&cmd_set_vf_macvlan_filter_type,
5934 (void *)&cmd_set_vf_macvlan_mode,
5939 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5940 struct cmd_set_vf_traffic {
5941 cmdline_fixed_string_t set;
5942 cmdline_fixed_string_t port;
5944 cmdline_fixed_string_t vf;
5946 cmdline_fixed_string_t what;
5947 cmdline_fixed_string_t mode;
5951 cmd_set_vf_traffic_parsed(void *parsed_result,
5952 __attribute__((unused)) struct cmdline *cl,
5953 __attribute__((unused)) void *data)
5955 struct cmd_set_vf_traffic *res = parsed_result;
5956 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5957 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5959 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5962 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5963 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5965 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5966 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5968 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5969 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5971 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5972 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5974 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5975 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5977 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5978 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5980 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5981 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5984 cmdline_parse_inst_t cmd_set_vf_traffic = {
5985 .f = cmd_set_vf_traffic_parsed,
5987 .help_str = "set port X vf Y rx|tx on|off"
5988 "(X = port number,Y = vf id)",
5990 (void *)&cmd_setvf_traffic_set,
5991 (void *)&cmd_setvf_traffic_port,
5992 (void *)&cmd_setvf_traffic_portid,
5993 (void *)&cmd_setvf_traffic_vf,
5994 (void *)&cmd_setvf_traffic_vfid,
5995 (void *)&cmd_setvf_traffic_what,
5996 (void *)&cmd_setvf_traffic_mode,
6001 /* *** CONFIGURE VF RECEIVE MODE *** */
6002 struct cmd_set_vf_rxmode {
6003 cmdline_fixed_string_t set;
6004 cmdline_fixed_string_t port;
6006 cmdline_fixed_string_t vf;
6008 cmdline_fixed_string_t what;
6009 cmdline_fixed_string_t mode;
6010 cmdline_fixed_string_t on;
6014 cmd_set_vf_rxmode_parsed(void *parsed_result,
6015 __attribute__((unused)) struct cmdline *cl,
6016 __attribute__((unused)) void *data)
6019 uint16_t rx_mode = 0;
6020 struct cmd_set_vf_rxmode *res = parsed_result;
6022 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6023 if (!strcmp(res->what,"rxmode")) {
6024 if (!strcmp(res->mode, "AUPE"))
6025 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6026 else if (!strcmp(res->mode, "ROPE"))
6027 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6028 else if (!strcmp(res->mode, "BAM"))
6029 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6030 else if (!strncmp(res->mode, "MPE",3))
6031 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6034 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6036 printf("bad VF receive mode parameter, return code = %d \n",
6040 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6041 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6043 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6044 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6046 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6047 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6049 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6050 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6052 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6053 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6055 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6056 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6058 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6059 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6060 mode, "AUPE#ROPE#BAM#MPE");
6061 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6062 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6065 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6066 .f = cmd_set_vf_rxmode_parsed,
6068 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6070 (void *)&cmd_set_vf_rxmode_set,
6071 (void *)&cmd_set_vf_rxmode_port,
6072 (void *)&cmd_set_vf_rxmode_portid,
6073 (void *)&cmd_set_vf_rxmode_vf,
6074 (void *)&cmd_set_vf_rxmode_vfid,
6075 (void *)&cmd_set_vf_rxmode_what,
6076 (void *)&cmd_set_vf_rxmode_mode,
6077 (void *)&cmd_set_vf_rxmode_on,
6082 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6083 struct cmd_vf_mac_addr_result {
6084 cmdline_fixed_string_t mac_addr_cmd;
6085 cmdline_fixed_string_t what;
6086 cmdline_fixed_string_t port;
6088 cmdline_fixed_string_t vf;
6090 struct ether_addr address;
6093 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6094 __attribute__((unused)) struct cmdline *cl,
6095 __attribute__((unused)) void *data)
6097 struct cmd_vf_mac_addr_result *res = parsed_result;
6100 if (strcmp(res->what, "add") == 0)
6101 ret = rte_eth_dev_mac_addr_add(res->port_num,
6102 &res->address, res->vf_num);
6104 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6108 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6109 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6110 mac_addr_cmd,"mac_addr");
6111 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6112 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6114 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6115 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6117 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6118 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6120 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6121 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6123 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6124 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6126 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6127 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6130 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6131 .f = cmd_vf_mac_addr_parsed,
6133 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6134 "Y = VF number)add MAC address filtering for a VF on port X",
6136 (void *)&cmd_vf_mac_addr_cmd,
6137 (void *)&cmd_vf_mac_addr_what,
6138 (void *)&cmd_vf_mac_addr_port,
6139 (void *)&cmd_vf_mac_addr_portnum,
6140 (void *)&cmd_vf_mac_addr_vf,
6141 (void *)&cmd_vf_mac_addr_vfnum,
6142 (void *)&cmd_vf_mac_addr_addr,
6147 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6148 struct cmd_vf_rx_vlan_filter {
6149 cmdline_fixed_string_t rx_vlan;
6150 cmdline_fixed_string_t what;
6152 cmdline_fixed_string_t port;
6154 cmdline_fixed_string_t vf;
6159 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6160 __attribute__((unused)) struct cmdline *cl,
6161 __attribute__((unused)) void *data)
6163 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6165 if (!strcmp(res->what, "add"))
6166 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6168 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6171 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6172 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6173 rx_vlan, "rx_vlan");
6174 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6175 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6177 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6178 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6180 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6181 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6183 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6184 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6186 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6187 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6189 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6190 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6193 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6194 .f = cmd_vf_rx_vlan_filter_parsed,
6196 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6197 "Y = port number,Z = hexadecimal VF mask)",
6199 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6200 (void *)&cmd_vf_rx_vlan_filter_what,
6201 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6202 (void *)&cmd_vf_rx_vlan_filter_port,
6203 (void *)&cmd_vf_rx_vlan_filter_portid,
6204 (void *)&cmd_vf_rx_vlan_filter_vf,
6205 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6210 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6211 struct cmd_queue_rate_limit_result {
6212 cmdline_fixed_string_t set;
6213 cmdline_fixed_string_t port;
6215 cmdline_fixed_string_t queue;
6217 cmdline_fixed_string_t rate;
6221 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6222 __attribute__((unused)) struct cmdline *cl,
6223 __attribute__((unused)) void *data)
6225 struct cmd_queue_rate_limit_result *res = parsed_result;
6228 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6229 && (strcmp(res->queue, "queue") == 0)
6230 && (strcmp(res->rate, "rate") == 0))
6231 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6234 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6238 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6239 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6241 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6242 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6244 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6245 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6247 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6248 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6250 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6251 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6253 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6254 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6256 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6257 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6260 cmdline_parse_inst_t cmd_queue_rate_limit = {
6261 .f = cmd_queue_rate_limit_parsed,
6263 .help_str = "set port X queue Y rate Z:(X = port number,"
6264 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6266 (void *)&cmd_queue_rate_limit_set,
6267 (void *)&cmd_queue_rate_limit_port,
6268 (void *)&cmd_queue_rate_limit_portnum,
6269 (void *)&cmd_queue_rate_limit_queue,
6270 (void *)&cmd_queue_rate_limit_queuenum,
6271 (void *)&cmd_queue_rate_limit_rate,
6272 (void *)&cmd_queue_rate_limit_ratenum,
6277 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6278 struct cmd_vf_rate_limit_result {
6279 cmdline_fixed_string_t set;
6280 cmdline_fixed_string_t port;
6282 cmdline_fixed_string_t vf;
6284 cmdline_fixed_string_t rate;
6286 cmdline_fixed_string_t q_msk;
6290 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6291 __attribute__((unused)) struct cmdline *cl,
6292 __attribute__((unused)) void *data)
6294 struct cmd_vf_rate_limit_result *res = parsed_result;
6297 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6298 && (strcmp(res->vf, "vf") == 0)
6299 && (strcmp(res->rate, "rate") == 0)
6300 && (strcmp(res->q_msk, "queue_mask") == 0))
6301 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6302 res->rate_num, res->q_msk_val);
6304 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6308 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6309 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6311 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6312 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6314 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6315 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6317 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6318 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6320 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6321 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6323 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6324 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6326 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6327 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6329 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6330 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6331 q_msk, "queue_mask");
6332 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6333 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6336 cmdline_parse_inst_t cmd_vf_rate_limit = {
6337 .f = cmd_vf_rate_limit_parsed,
6339 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6340 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6341 "for queues of VF on port X",
6343 (void *)&cmd_vf_rate_limit_set,
6344 (void *)&cmd_vf_rate_limit_port,
6345 (void *)&cmd_vf_rate_limit_portnum,
6346 (void *)&cmd_vf_rate_limit_vf,
6347 (void *)&cmd_vf_rate_limit_vfnum,
6348 (void *)&cmd_vf_rate_limit_rate,
6349 (void *)&cmd_vf_rate_limit_ratenum,
6350 (void *)&cmd_vf_rate_limit_q_msk,
6351 (void *)&cmd_vf_rate_limit_q_msk_val,
6356 /* *** ADD TUNNEL FILTER OF A PORT *** */
6357 struct cmd_tunnel_filter_result {
6358 cmdline_fixed_string_t cmd;
6359 cmdline_fixed_string_t what;
6361 struct ether_addr outer_mac;
6362 struct ether_addr inner_mac;
6363 cmdline_ipaddr_t ip_value;
6364 uint16_t inner_vlan;
6365 cmdline_fixed_string_t tunnel_type;
6366 cmdline_fixed_string_t filter_type;
6372 cmd_tunnel_filter_parsed(void *parsed_result,
6373 __attribute__((unused)) struct cmdline *cl,
6374 __attribute__((unused)) void *data)
6376 struct cmd_tunnel_filter_result *res = parsed_result;
6377 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6380 tunnel_filter_conf.outer_mac = &res->outer_mac;
6381 tunnel_filter_conf.inner_mac = &res->inner_mac;
6382 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6384 if (res->ip_value.family == AF_INET) {
6385 tunnel_filter_conf.ip_addr.ipv4_addr =
6386 res->ip_value.addr.ipv4.s_addr;
6387 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6389 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6390 &(res->ip_value.addr.ipv6),
6391 sizeof(struct in6_addr));
6392 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6395 if (!strcmp(res->filter_type, "imac-ivlan"))
6396 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6397 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6398 tunnel_filter_conf.filter_type =
6399 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6400 else if (!strcmp(res->filter_type, "imac-tenid"))
6401 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6402 else if (!strcmp(res->filter_type, "imac"))
6403 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6404 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6405 tunnel_filter_conf.filter_type =
6406 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6408 printf("The filter type is not supported");
6412 if (!strcmp(res->tunnel_type, "vxlan"))
6413 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6414 else if (!strcmp(res->tunnel_type, "nvgre"))
6415 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6417 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6421 tunnel_filter_conf.tenant_id = res->tenant_id;
6422 tunnel_filter_conf.queue_id = res->queue_num;
6423 if (!strcmp(res->what, "add"))
6424 ret = rte_eth_dev_filter_ctrl(res->port_id,
6425 RTE_ETH_FILTER_TUNNEL,
6427 &tunnel_filter_conf);
6429 ret = rte_eth_dev_filter_ctrl(res->port_id,
6430 RTE_ETH_FILTER_TUNNEL,
6431 RTE_ETH_FILTER_DELETE,
6432 &tunnel_filter_conf);
6434 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6438 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6439 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6440 cmd, "tunnel_filter");
6441 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6442 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6444 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6445 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6447 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6448 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6450 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6451 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6453 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6454 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6455 inner_vlan, UINT16);
6456 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6457 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6459 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6460 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6461 tunnel_type, "vxlan#nvgre");
6463 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6464 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6465 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6466 "imac#omac-imac-tenid");
6467 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6468 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6470 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6471 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6474 cmdline_parse_inst_t cmd_tunnel_filter = {
6475 .f = cmd_tunnel_filter_parsed,
6477 .help_str = "add/rm tunnel filter of a port: "
6478 "tunnel_filter add port_id outer_mac inner_mac ip "
6479 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6480 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6481 "imac|omac-imac-tenid) "
6482 "tenant_id queue_num",
6484 (void *)&cmd_tunnel_filter_cmd,
6485 (void *)&cmd_tunnel_filter_what,
6486 (void *)&cmd_tunnel_filter_port_id,
6487 (void *)&cmd_tunnel_filter_outer_mac,
6488 (void *)&cmd_tunnel_filter_inner_mac,
6489 (void *)&cmd_tunnel_filter_ip_value,
6490 (void *)&cmd_tunnel_filter_innner_vlan,
6491 (void *)&cmd_tunnel_filter_tunnel_type,
6492 (void *)&cmd_tunnel_filter_filter_type,
6493 (void *)&cmd_tunnel_filter_tenant_id,
6494 (void *)&cmd_tunnel_filter_queue_num,
6499 /* *** CONFIGURE TUNNEL UDP PORT *** */
6500 struct cmd_tunnel_udp_config {
6501 cmdline_fixed_string_t cmd;
6502 cmdline_fixed_string_t what;
6508 cmd_tunnel_udp_config_parsed(void *parsed_result,
6509 __attribute__((unused)) struct cmdline *cl,
6510 __attribute__((unused)) void *data)
6512 struct cmd_tunnel_udp_config *res = parsed_result;
6513 struct rte_eth_udp_tunnel tunnel_udp;
6516 tunnel_udp.udp_port = res->udp_port;
6518 if (!strcmp(res->cmd, "rx_vxlan_port"))
6519 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6521 if (!strcmp(res->what, "add"))
6522 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6524 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6527 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6530 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6531 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6532 cmd, "rx_vxlan_port");
6533 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6534 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6536 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6537 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6539 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6540 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6543 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6544 .f = cmd_tunnel_udp_config_parsed,
6546 .help_str = "add/rm an tunneling UDP port filter: "
6547 "rx_vxlan_port add udp_port port_id",
6549 (void *)&cmd_tunnel_udp_config_cmd,
6550 (void *)&cmd_tunnel_udp_config_what,
6551 (void *)&cmd_tunnel_udp_config_udp_port,
6552 (void *)&cmd_tunnel_udp_config_port_id,
6557 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6558 struct cmd_set_mirror_mask_result {
6559 cmdline_fixed_string_t set;
6560 cmdline_fixed_string_t port;
6562 cmdline_fixed_string_t mirror;
6564 cmdline_fixed_string_t what;
6565 cmdline_fixed_string_t value;
6566 cmdline_fixed_string_t dstpool;
6568 cmdline_fixed_string_t on;
6571 cmdline_parse_token_string_t cmd_mirror_mask_set =
6572 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6574 cmdline_parse_token_string_t cmd_mirror_mask_port =
6575 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6577 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6578 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6580 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6581 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6582 mirror, "mirror-rule");
6583 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6584 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6586 cmdline_parse_token_string_t cmd_mirror_mask_what =
6587 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6588 what, "pool-mirror#vlan-mirror");
6589 cmdline_parse_token_string_t cmd_mirror_mask_value =
6590 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6592 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6593 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6594 dstpool, "dst-pool");
6595 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6596 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6598 cmdline_parse_token_string_t cmd_mirror_mask_on =
6599 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6603 cmd_set_mirror_mask_parsed(void *parsed_result,
6604 __attribute__((unused)) struct cmdline *cl,
6605 __attribute__((unused)) void *data)
6608 struct cmd_set_mirror_mask_result *res = parsed_result;
6609 struct rte_eth_vmdq_mirror_conf mr_conf;
6611 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6613 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6615 mr_conf.dst_pool = res->dstpool_id;
6617 if (!strcmp(res->what, "pool-mirror")) {
6618 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6619 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6620 } else if(!strcmp(res->what, "vlan-mirror")) {
6621 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6622 nb_item = parse_item_list(res->value, "core",
6623 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6627 for(i=0; i < nb_item; i++) {
6628 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6629 printf("Invalid vlan_id: must be < 4096\n");
6633 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6634 mr_conf.vlan.vlan_mask |= 1ULL << i;
6638 if(!strcmp(res->on, "on"))
6639 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6642 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6645 printf("mirror rule add error: (%s)\n", strerror(-ret));
6648 cmdline_parse_inst_t cmd_set_mirror_mask = {
6649 .f = cmd_set_mirror_mask_parsed,
6651 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6652 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6654 (void *)&cmd_mirror_mask_set,
6655 (void *)&cmd_mirror_mask_port,
6656 (void *)&cmd_mirror_mask_portid,
6657 (void *)&cmd_mirror_mask_mirror,
6658 (void *)&cmd_mirror_mask_ruleid,
6659 (void *)&cmd_mirror_mask_what,
6660 (void *)&cmd_mirror_mask_value,
6661 (void *)&cmd_mirror_mask_dstpool,
6662 (void *)&cmd_mirror_mask_poolid,
6663 (void *)&cmd_mirror_mask_on,
6668 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6669 struct cmd_set_mirror_link_result {
6670 cmdline_fixed_string_t set;
6671 cmdline_fixed_string_t port;
6673 cmdline_fixed_string_t mirror;
6675 cmdline_fixed_string_t what;
6676 cmdline_fixed_string_t dstpool;
6678 cmdline_fixed_string_t on;
6681 cmdline_parse_token_string_t cmd_mirror_link_set =
6682 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6684 cmdline_parse_token_string_t cmd_mirror_link_port =
6685 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6687 cmdline_parse_token_num_t cmd_mirror_link_portid =
6688 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6690 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6691 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6692 mirror, "mirror-rule");
6693 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6694 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6696 cmdline_parse_token_string_t cmd_mirror_link_what =
6697 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6698 what, "uplink-mirror#downlink-mirror");
6699 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6700 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6701 dstpool, "dst-pool");
6702 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6703 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6705 cmdline_parse_token_string_t cmd_mirror_link_on =
6706 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6710 cmd_set_mirror_link_parsed(void *parsed_result,
6711 __attribute__((unused)) struct cmdline *cl,
6712 __attribute__((unused)) void *data)
6715 struct cmd_set_mirror_link_result *res = parsed_result;
6716 struct rte_eth_vmdq_mirror_conf mr_conf;
6718 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6719 if(!strcmp(res->what, "uplink-mirror")) {
6720 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6721 }else if(!strcmp(res->what, "downlink-mirror"))
6722 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6724 mr_conf.dst_pool = res->dstpool_id;
6726 if(!strcmp(res->on, "on"))
6727 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6730 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6733 /* check the return value and print it if is < 0 */
6735 printf("mirror rule add error: (%s)\n", strerror(-ret));
6739 cmdline_parse_inst_t cmd_set_mirror_link = {
6740 .f = cmd_set_mirror_link_parsed,
6742 .help_str = "set port X mirror-rule Y uplink-mirror|"
6743 "downlink-mirror dst-pool Z on|off",
6745 (void *)&cmd_mirror_link_set,
6746 (void *)&cmd_mirror_link_port,
6747 (void *)&cmd_mirror_link_portid,
6748 (void *)&cmd_mirror_link_mirror,
6749 (void *)&cmd_mirror_link_ruleid,
6750 (void *)&cmd_mirror_link_what,
6751 (void *)&cmd_mirror_link_dstpool,
6752 (void *)&cmd_mirror_link_poolid,
6753 (void *)&cmd_mirror_link_on,
6758 /* *** RESET VM MIRROR RULE *** */
6759 struct cmd_rm_mirror_rule_result {
6760 cmdline_fixed_string_t reset;
6761 cmdline_fixed_string_t port;
6763 cmdline_fixed_string_t mirror;
6767 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6768 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6770 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6771 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6773 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6774 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6776 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6777 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6778 mirror, "mirror-rule");
6779 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6780 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6784 cmd_reset_mirror_rule_parsed(void *parsed_result,
6785 __attribute__((unused)) struct cmdline *cl,
6786 __attribute__((unused)) void *data)
6789 struct cmd_set_mirror_link_result *res = parsed_result;
6791 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6793 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6796 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6797 .f = cmd_reset_mirror_rule_parsed,
6799 .help_str = "reset port X mirror-rule Y",
6801 (void *)&cmd_rm_mirror_rule_reset,
6802 (void *)&cmd_rm_mirror_rule_port,
6803 (void *)&cmd_rm_mirror_rule_portid,
6804 (void *)&cmd_rm_mirror_rule_mirror,
6805 (void *)&cmd_rm_mirror_rule_ruleid,
6810 /* ******************************************************************************** */
6812 struct cmd_dump_result {
6813 cmdline_fixed_string_t dump;
6817 dump_struct_sizes(void)
6819 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6820 DUMP_SIZE(struct rte_mbuf);
6821 DUMP_SIZE(struct rte_mempool);
6822 DUMP_SIZE(struct rte_ring);
6826 static void cmd_dump_parsed(void *parsed_result,
6827 __attribute__((unused)) struct cmdline *cl,
6828 __attribute__((unused)) void *data)
6830 struct cmd_dump_result *res = parsed_result;
6832 if (!strcmp(res->dump, "dump_physmem"))
6833 rte_dump_physmem_layout(stdout);
6834 else if (!strcmp(res->dump, "dump_memzone"))
6835 rte_memzone_dump(stdout);
6836 else if (!strcmp(res->dump, "dump_log_history"))
6837 rte_log_dump_history(stdout);
6838 else if (!strcmp(res->dump, "dump_struct_sizes"))
6839 dump_struct_sizes();
6840 else if (!strcmp(res->dump, "dump_ring"))
6841 rte_ring_list_dump(stdout);
6842 else if (!strcmp(res->dump, "dump_mempool"))
6843 rte_mempool_list_dump(stdout);
6844 else if (!strcmp(res->dump, "dump_devargs"))
6845 rte_eal_devargs_dump(stdout);
6848 cmdline_parse_token_string_t cmd_dump_dump =
6849 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6853 "dump_struct_sizes#"
6858 cmdline_parse_inst_t cmd_dump = {
6859 .f = cmd_dump_parsed, /* function to call */
6860 .data = NULL, /* 2nd arg of func */
6861 .help_str = "dump status",
6862 .tokens = { /* token list, NULL terminated */
6863 (void *)&cmd_dump_dump,
6868 /* ******************************************************************************** */
6870 struct cmd_dump_one_result {
6871 cmdline_fixed_string_t dump;
6872 cmdline_fixed_string_t name;
6875 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6876 __attribute__((unused)) void *data)
6878 struct cmd_dump_one_result *res = parsed_result;
6880 if (!strcmp(res->dump, "dump_ring")) {
6882 r = rte_ring_lookup(res->name);
6884 cmdline_printf(cl, "Cannot find ring\n");
6887 rte_ring_dump(stdout, r);
6888 } else if (!strcmp(res->dump, "dump_mempool")) {
6889 struct rte_mempool *mp;
6890 mp = rte_mempool_lookup(res->name);
6892 cmdline_printf(cl, "Cannot find mempool\n");
6895 rte_mempool_dump(stdout, mp);
6899 cmdline_parse_token_string_t cmd_dump_one_dump =
6900 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6901 "dump_ring#dump_mempool");
6903 cmdline_parse_token_string_t cmd_dump_one_name =
6904 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6906 cmdline_parse_inst_t cmd_dump_one = {
6907 .f = cmd_dump_one_parsed, /* function to call */
6908 .data = NULL, /* 2nd arg of func */
6909 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6910 .tokens = { /* token list, NULL terminated */
6911 (void *)&cmd_dump_one_dump,
6912 (void *)&cmd_dump_one_name,
6917 /* *** Add/Del syn filter *** */
6918 struct cmd_syn_filter_result {
6919 cmdline_fixed_string_t filter;
6921 cmdline_fixed_string_t ops;
6922 cmdline_fixed_string_t priority;
6923 cmdline_fixed_string_t high;
6924 cmdline_fixed_string_t queue;
6929 cmd_syn_filter_parsed(void *parsed_result,
6930 __attribute__((unused)) struct cmdline *cl,
6931 __attribute__((unused)) void *data)
6933 struct cmd_syn_filter_result *res = parsed_result;
6934 struct rte_eth_syn_filter syn_filter;
6937 ret = rte_eth_dev_filter_supported(res->port_id,
6938 RTE_ETH_FILTER_SYN);
6940 printf("syn filter is not supported on port %u.\n",
6945 memset(&syn_filter, 0, sizeof(syn_filter));
6947 if (!strcmp(res->ops, "add")) {
6948 if (!strcmp(res->high, "high"))
6949 syn_filter.hig_pri = 1;
6951 syn_filter.hig_pri = 0;
6953 syn_filter.queue = res->queue_id;
6954 ret = rte_eth_dev_filter_ctrl(res->port_id,
6959 ret = rte_eth_dev_filter_ctrl(res->port_id,
6961 RTE_ETH_FILTER_DELETE,
6965 printf("syn filter programming error: (%s)\n",
6969 cmdline_parse_token_string_t cmd_syn_filter_filter =
6970 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6971 filter, "syn_filter");
6972 cmdline_parse_token_num_t cmd_syn_filter_port_id =
6973 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6975 cmdline_parse_token_string_t cmd_syn_filter_ops =
6976 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6978 cmdline_parse_token_string_t cmd_syn_filter_priority =
6979 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6980 priority, "priority");
6981 cmdline_parse_token_string_t cmd_syn_filter_high =
6982 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6984 cmdline_parse_token_string_t cmd_syn_filter_queue =
6985 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6987 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6988 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6991 cmdline_parse_inst_t cmd_syn_filter = {
6992 .f = cmd_syn_filter_parsed,
6994 .help_str = "add/delete syn filter",
6996 (void *)&cmd_syn_filter_filter,
6997 (void *)&cmd_syn_filter_port_id,
6998 (void *)&cmd_syn_filter_ops,
6999 (void *)&cmd_syn_filter_priority,
7000 (void *)&cmd_syn_filter_high,
7001 (void *)&cmd_syn_filter_queue,
7002 (void *)&cmd_syn_filter_queue_id,
7007 /* *** ADD/REMOVE A 2tuple FILTER *** */
7008 struct cmd_2tuple_filter_result {
7009 cmdline_fixed_string_t filter;
7011 cmdline_fixed_string_t ops;
7012 cmdline_fixed_string_t dst_port;
7013 uint16_t dst_port_value;
7014 cmdline_fixed_string_t protocol;
7015 uint8_t protocol_value;
7016 cmdline_fixed_string_t mask;
7018 cmdline_fixed_string_t tcp_flags;
7019 uint8_t tcp_flags_value;
7020 cmdline_fixed_string_t priority;
7021 uint8_t priority_value;
7022 cmdline_fixed_string_t queue;
7027 cmd_2tuple_filter_parsed(void *parsed_result,
7028 __attribute__((unused)) struct cmdline *cl,
7029 __attribute__((unused)) void *data)
7031 struct rte_eth_ntuple_filter filter;
7032 struct cmd_2tuple_filter_result *res = parsed_result;
7035 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7037 printf("ntuple filter is not supported on port %u.\n",
7042 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7044 filter.flags = RTE_2TUPLE_FLAGS;
7045 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7046 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7047 filter.proto = res->protocol_value;
7048 filter.priority = res->priority_value;
7049 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7050 printf("nonzero tcp_flags is only meaningful"
7051 " when protocol is TCP.\n");
7054 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7055 printf("invalid TCP flags.\n");
7059 if (res->tcp_flags_value != 0) {
7060 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7061 filter.tcp_flags = res->tcp_flags_value;
7064 /* need convert to big endian. */
7065 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7066 filter.queue = res->queue_id;
7068 if (!strcmp(res->ops, "add"))
7069 ret = rte_eth_dev_filter_ctrl(res->port_id,
7070 RTE_ETH_FILTER_NTUPLE,
7074 ret = rte_eth_dev_filter_ctrl(res->port_id,
7075 RTE_ETH_FILTER_NTUPLE,
7076 RTE_ETH_FILTER_DELETE,
7079 printf("2tuple filter programming error: (%s)\n",
7084 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7085 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7086 filter, "2tuple_filter");
7087 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7088 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7090 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7091 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7093 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7094 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7095 dst_port, "dst_port");
7096 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7097 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7098 dst_port_value, UINT16);
7099 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7100 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7101 protocol, "protocol");
7102 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7103 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7104 protocol_value, UINT8);
7105 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7106 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7108 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7109 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7111 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7112 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7113 tcp_flags, "tcp_flags");
7114 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7115 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7116 tcp_flags_value, UINT8);
7117 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7118 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7119 priority, "priority");
7120 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7121 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7122 priority_value, UINT8);
7123 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7124 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7126 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7127 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7130 cmdline_parse_inst_t cmd_2tuple_filter = {
7131 .f = cmd_2tuple_filter_parsed,
7133 .help_str = "add a 2tuple filter",
7135 (void *)&cmd_2tuple_filter_filter,
7136 (void *)&cmd_2tuple_filter_port_id,
7137 (void *)&cmd_2tuple_filter_ops,
7138 (void *)&cmd_2tuple_filter_dst_port,
7139 (void *)&cmd_2tuple_filter_dst_port_value,
7140 (void *)&cmd_2tuple_filter_protocol,
7141 (void *)&cmd_2tuple_filter_protocol_value,
7142 (void *)&cmd_2tuple_filter_mask,
7143 (void *)&cmd_2tuple_filter_mask_value,
7144 (void *)&cmd_2tuple_filter_tcp_flags,
7145 (void *)&cmd_2tuple_filter_tcp_flags_value,
7146 (void *)&cmd_2tuple_filter_priority,
7147 (void *)&cmd_2tuple_filter_priority_value,
7148 (void *)&cmd_2tuple_filter_queue,
7149 (void *)&cmd_2tuple_filter_queue_id,
7154 /* *** ADD/REMOVE A 5tuple FILTER *** */
7155 struct cmd_5tuple_filter_result {
7156 cmdline_fixed_string_t filter;
7158 cmdline_fixed_string_t ops;
7159 cmdline_fixed_string_t dst_ip;
7160 cmdline_ipaddr_t dst_ip_value;
7161 cmdline_fixed_string_t src_ip;
7162 cmdline_ipaddr_t src_ip_value;
7163 cmdline_fixed_string_t dst_port;
7164 uint16_t dst_port_value;
7165 cmdline_fixed_string_t src_port;
7166 uint16_t src_port_value;
7167 cmdline_fixed_string_t protocol;
7168 uint8_t protocol_value;
7169 cmdline_fixed_string_t mask;
7171 cmdline_fixed_string_t tcp_flags;
7172 uint8_t tcp_flags_value;
7173 cmdline_fixed_string_t priority;
7174 uint8_t priority_value;
7175 cmdline_fixed_string_t queue;
7180 cmd_5tuple_filter_parsed(void *parsed_result,
7181 __attribute__((unused)) struct cmdline *cl,
7182 __attribute__((unused)) void *data)
7184 struct rte_eth_ntuple_filter filter;
7185 struct cmd_5tuple_filter_result *res = parsed_result;
7188 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7190 printf("ntuple filter is not supported on port %u.\n",
7195 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7197 filter.flags = RTE_5TUPLE_FLAGS;
7198 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7199 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7200 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7201 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7202 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7203 filter.proto = res->protocol_value;
7204 filter.priority = res->priority_value;
7205 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7206 printf("nonzero tcp_flags is only meaningful"
7207 " when protocol is TCP.\n");
7210 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7211 printf("invalid TCP flags.\n");
7215 if (res->tcp_flags_value != 0) {
7216 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7217 filter.tcp_flags = res->tcp_flags_value;
7220 if (res->dst_ip_value.family == AF_INET)
7221 /* no need to convert, already big endian. */
7222 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7224 if (filter.dst_ip_mask == 0) {
7225 printf("can not support ipv6 involved compare.\n");
7231 if (res->src_ip_value.family == AF_INET)
7232 /* no need to convert, already big endian. */
7233 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7235 if (filter.src_ip_mask == 0) {
7236 printf("can not support ipv6 involved compare.\n");
7241 /* need convert to big endian. */
7242 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7243 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7244 filter.queue = res->queue_id;
7246 if (!strcmp(res->ops, "add"))
7247 ret = rte_eth_dev_filter_ctrl(res->port_id,
7248 RTE_ETH_FILTER_NTUPLE,
7252 ret = rte_eth_dev_filter_ctrl(res->port_id,
7253 RTE_ETH_FILTER_NTUPLE,
7254 RTE_ETH_FILTER_DELETE,
7257 printf("5tuple filter programming error: (%s)\n",
7261 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7262 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7263 filter, "5tuple_filter");
7264 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7265 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7267 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7268 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7270 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7271 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7273 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7274 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7276 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7277 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7279 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7280 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7282 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7283 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7284 dst_port, "dst_port");
7285 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7286 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7287 dst_port_value, UINT16);
7288 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7289 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7290 src_port, "src_port");
7291 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7292 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7293 src_port_value, UINT16);
7294 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7295 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7296 protocol, "protocol");
7297 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7298 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7299 protocol_value, UINT8);
7300 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7301 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7303 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7304 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7306 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7307 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7308 tcp_flags, "tcp_flags");
7309 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7310 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7311 tcp_flags_value, UINT8);
7312 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7313 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7314 priority, "priority");
7315 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7316 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7317 priority_value, UINT8);
7318 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7319 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7321 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7322 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7325 cmdline_parse_inst_t cmd_5tuple_filter = {
7326 .f = cmd_5tuple_filter_parsed,
7328 .help_str = "add/del a 5tuple filter",
7330 (void *)&cmd_5tuple_filter_filter,
7331 (void *)&cmd_5tuple_filter_port_id,
7332 (void *)&cmd_5tuple_filter_ops,
7333 (void *)&cmd_5tuple_filter_dst_ip,
7334 (void *)&cmd_5tuple_filter_dst_ip_value,
7335 (void *)&cmd_5tuple_filter_src_ip,
7336 (void *)&cmd_5tuple_filter_src_ip_value,
7337 (void *)&cmd_5tuple_filter_dst_port,
7338 (void *)&cmd_5tuple_filter_dst_port_value,
7339 (void *)&cmd_5tuple_filter_src_port,
7340 (void *)&cmd_5tuple_filter_src_port_value,
7341 (void *)&cmd_5tuple_filter_protocol,
7342 (void *)&cmd_5tuple_filter_protocol_value,
7343 (void *)&cmd_5tuple_filter_mask,
7344 (void *)&cmd_5tuple_filter_mask_value,
7345 (void *)&cmd_5tuple_filter_tcp_flags,
7346 (void *)&cmd_5tuple_filter_tcp_flags_value,
7347 (void *)&cmd_5tuple_filter_priority,
7348 (void *)&cmd_5tuple_filter_priority_value,
7349 (void *)&cmd_5tuple_filter_queue,
7350 (void *)&cmd_5tuple_filter_queue_id,
7355 /* *** ADD/REMOVE A flex FILTER *** */
7356 struct cmd_flex_filter_result {
7357 cmdline_fixed_string_t filter;
7358 cmdline_fixed_string_t ops;
7360 cmdline_fixed_string_t len;
7362 cmdline_fixed_string_t bytes;
7363 cmdline_fixed_string_t bytes_value;
7364 cmdline_fixed_string_t mask;
7365 cmdline_fixed_string_t mask_value;
7366 cmdline_fixed_string_t priority;
7367 uint8_t priority_value;
7368 cmdline_fixed_string_t queue;
7372 static int xdigit2val(unsigned char c)
7377 else if (isupper(c))
7385 cmd_flex_filter_parsed(void *parsed_result,
7386 __attribute__((unused)) struct cmdline *cl,
7387 __attribute__((unused)) void *data)
7390 struct rte_eth_flex_filter filter;
7391 struct cmd_flex_filter_result *res = parsed_result;
7392 char *bytes_ptr, *mask_ptr;
7393 uint16_t len, i, j = 0;
7398 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7399 printf("the len exceed the max length 128\n");
7402 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7403 filter.len = res->len_value;
7404 filter.priority = res->priority_value;
7405 filter.queue = res->queue_id;
7406 bytes_ptr = res->bytes_value;
7407 mask_ptr = res->mask_value;
7409 /* translate bytes string to array. */
7410 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7411 (bytes_ptr[1] == 'X')))
7413 len = strnlen(bytes_ptr, res->len_value * 2);
7414 if (len == 0 || (len % 8 != 0)) {
7415 printf("please check len and bytes input\n");
7418 for (i = 0; i < len; i++) {
7420 if (isxdigit(c) == 0) {
7421 /* invalid characters. */
7422 printf("invalid input\n");
7425 val = xdigit2val(c);
7428 filter.bytes[j] = byte;
7429 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7436 /* translate mask string to uint8_t array. */
7437 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7438 (mask_ptr[1] == 'X')))
7440 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7442 printf("invalid input\n");
7447 for (i = 0; i < len; i++) {
7449 if (isxdigit(c) == 0) {
7450 /* invalid characters. */
7451 printf("invalid input\n");
7454 val = xdigit2val(c);
7457 filter.mask[j] = byte;
7458 printf("mask[%d]:%02x ", j, filter.mask[j]);
7466 if (!strcmp(res->ops, "add"))
7467 ret = rte_eth_dev_filter_ctrl(res->port_id,
7468 RTE_ETH_FILTER_FLEXIBLE,
7472 ret = rte_eth_dev_filter_ctrl(res->port_id,
7473 RTE_ETH_FILTER_FLEXIBLE,
7474 RTE_ETH_FILTER_DELETE,
7478 printf("flex filter setting error: (%s)\n", strerror(-ret));
7481 cmdline_parse_token_string_t cmd_flex_filter_filter =
7482 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7483 filter, "flex_filter");
7484 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7485 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7487 cmdline_parse_token_string_t cmd_flex_filter_ops =
7488 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7490 cmdline_parse_token_string_t cmd_flex_filter_len =
7491 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7493 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7494 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7496 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7497 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7499 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7500 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7502 cmdline_parse_token_string_t cmd_flex_filter_mask =
7503 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7505 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7506 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7508 cmdline_parse_token_string_t cmd_flex_filter_priority =
7509 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7510 priority, "priority");
7511 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7512 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7513 priority_value, UINT8);
7514 cmdline_parse_token_string_t cmd_flex_filter_queue =
7515 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7517 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7518 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7520 cmdline_parse_inst_t cmd_flex_filter = {
7521 .f = cmd_flex_filter_parsed,
7523 .help_str = "add/del a flex filter",
7525 (void *)&cmd_flex_filter_filter,
7526 (void *)&cmd_flex_filter_port_id,
7527 (void *)&cmd_flex_filter_ops,
7528 (void *)&cmd_flex_filter_len,
7529 (void *)&cmd_flex_filter_len_value,
7530 (void *)&cmd_flex_filter_bytes,
7531 (void *)&cmd_flex_filter_bytes_value,
7532 (void *)&cmd_flex_filter_mask,
7533 (void *)&cmd_flex_filter_mask_value,
7534 (void *)&cmd_flex_filter_priority,
7535 (void *)&cmd_flex_filter_priority_value,
7536 (void *)&cmd_flex_filter_queue,
7537 (void *)&cmd_flex_filter_queue_id,
7542 /* *** Filters Control *** */
7544 /* *** deal with ethertype filter *** */
7545 struct cmd_ethertype_filter_result {
7546 cmdline_fixed_string_t filter;
7548 cmdline_fixed_string_t ops;
7549 cmdline_fixed_string_t mac;
7550 struct ether_addr mac_addr;
7551 cmdline_fixed_string_t ethertype;
7552 uint16_t ethertype_value;
7553 cmdline_fixed_string_t drop;
7554 cmdline_fixed_string_t queue;
7558 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7559 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7560 filter, "ethertype_filter");
7561 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7562 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7564 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7565 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7567 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7568 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7569 mac, "mac_addr#mac_ignr");
7570 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7571 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7573 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7574 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7575 ethertype, "ethertype");
7576 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7577 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7578 ethertype_value, UINT16);
7579 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7580 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7582 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7583 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7585 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7586 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7590 cmd_ethertype_filter_parsed(void *parsed_result,
7591 __attribute__((unused)) struct cmdline *cl,
7592 __attribute__((unused)) void *data)
7594 struct cmd_ethertype_filter_result *res = parsed_result;
7595 struct rte_eth_ethertype_filter filter;
7598 ret = rte_eth_dev_filter_supported(res->port_id,
7599 RTE_ETH_FILTER_ETHERTYPE);
7601 printf("ethertype filter is not supported on port %u.\n",
7606 memset(&filter, 0, sizeof(filter));
7607 if (!strcmp(res->mac, "mac_addr")) {
7608 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7609 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7610 sizeof(struct ether_addr));
7612 if (!strcmp(res->drop, "drop"))
7613 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7614 filter.ether_type = res->ethertype_value;
7615 filter.queue = res->queue_id;
7617 if (!strcmp(res->ops, "add"))
7618 ret = rte_eth_dev_filter_ctrl(res->port_id,
7619 RTE_ETH_FILTER_ETHERTYPE,
7623 ret = rte_eth_dev_filter_ctrl(res->port_id,
7624 RTE_ETH_FILTER_ETHERTYPE,
7625 RTE_ETH_FILTER_DELETE,
7628 printf("ethertype filter programming error: (%s)\n",
7632 cmdline_parse_inst_t cmd_ethertype_filter = {
7633 .f = cmd_ethertype_filter_parsed,
7635 .help_str = "add or delete an ethertype filter entry",
7637 (void *)&cmd_ethertype_filter_filter,
7638 (void *)&cmd_ethertype_filter_port_id,
7639 (void *)&cmd_ethertype_filter_ops,
7640 (void *)&cmd_ethertype_filter_mac,
7641 (void *)&cmd_ethertype_filter_mac_addr,
7642 (void *)&cmd_ethertype_filter_ethertype,
7643 (void *)&cmd_ethertype_filter_ethertype_value,
7644 (void *)&cmd_ethertype_filter_drop,
7645 (void *)&cmd_ethertype_filter_queue,
7646 (void *)&cmd_ethertype_filter_queue_id,
7651 /* *** deal with flow director filter *** */
7652 struct cmd_flow_director_result {
7653 cmdline_fixed_string_t flow_director_filter;
7655 cmdline_fixed_string_t ops;
7656 cmdline_fixed_string_t flow;
7657 cmdline_fixed_string_t flow_type;
7658 cmdline_fixed_string_t src;
7659 cmdline_ipaddr_t ip_src;
7661 cmdline_fixed_string_t dst;
7662 cmdline_ipaddr_t ip_dst;
7664 cmdline_fixed_string_t verify_tag;
7665 uint32_t verify_tag_value;
7666 cmdline_fixed_string_t vlan;
7667 uint16_t vlan_value;
7668 cmdline_fixed_string_t flexbytes;
7669 cmdline_fixed_string_t flexbytes_value;
7670 cmdline_fixed_string_t drop;
7671 cmdline_fixed_string_t queue;
7673 cmdline_fixed_string_t fd_id;
7674 uint32_t fd_id_value;
7678 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7681 const char *p, *p0 = q_arg;
7683 unsigned long int_fld;
7684 char *str_fld[max_num];
7689 p = strchr(p0, '(');
7693 p0 = strchr(p, ')');
7698 if (size >= sizeof(s))
7701 snprintf(s, sizeof(s), "%.*s", size, p);
7702 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7703 if (ret < 0 || ret > max_num)
7705 for (i = 0; i < ret; i++) {
7707 int_fld = strtoul(str_fld[i], &end, 0);
7708 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7710 flexbytes[i] = (uint8_t)int_fld;
7716 str2flowtype(char *string)
7719 static const struct {
7722 } flowtype_str[] = {
7723 {"raw", RTE_ETH_FLOW_RAW},
7724 {"ipv4", RTE_ETH_FLOW_IPV4},
7725 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
7726 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
7727 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
7728 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
7729 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
7730 {"ipv6", RTE_ETH_FLOW_IPV6},
7731 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
7732 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
7733 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
7734 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
7735 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
7736 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
7739 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7740 if (!strcmp(flowtype_str[i].str, string))
7741 return flowtype_str[i].type;
7743 return RTE_ETH_FLOW_UNKNOWN;
7746 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7748 if ((ip_addr).family == AF_INET) \
7749 (ip) = (ip_addr).addr.ipv4.s_addr; \
7751 printf("invalid parameter.\n"); \
7756 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7758 if ((ip_addr).family == AF_INET6) \
7759 (void)rte_memcpy(&(ip), \
7760 &((ip_addr).addr.ipv6), \
7761 sizeof(struct in6_addr)); \
7763 printf("invalid parameter.\n"); \
7769 cmd_flow_director_filter_parsed(void *parsed_result,
7770 __attribute__((unused)) struct cmdline *cl,
7771 __attribute__((unused)) void *data)
7773 struct cmd_flow_director_result *res = parsed_result;
7774 struct rte_eth_fdir_filter entry;
7775 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7778 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7780 printf("flow director is not supported on port %u.\n",
7784 memset(flexbytes, 0, sizeof(flexbytes));
7785 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7786 ret = parse_flexbytes(res->flexbytes_value,
7788 RTE_ETH_FDIR_MAX_FLEXLEN);
7790 printf("error: Cannot parse flexbytes input.\n");
7794 entry.input.flow_type = str2flowtype(res->flow_type);
7795 switch (entry.input.flow_type) {
7796 case RTE_ETH_FLOW_FRAG_IPV4:
7797 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
7798 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
7799 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
7800 IPV4_ADDR_TO_UINT(res->ip_dst,
7801 entry.input.flow.ip4_flow.dst_ip);
7802 IPV4_ADDR_TO_UINT(res->ip_src,
7803 entry.input.flow.ip4_flow.src_ip);
7804 /* need convert to big endian. */
7805 entry.input.flow.udp4_flow.dst_port =
7806 rte_cpu_to_be_16(res->port_dst);
7807 entry.input.flow.udp4_flow.src_port =
7808 rte_cpu_to_be_16(res->port_src);
7810 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
7811 IPV4_ADDR_TO_UINT(res->ip_dst,
7812 entry.input.flow.sctp4_flow.ip.dst_ip);
7813 IPV4_ADDR_TO_UINT(res->ip_src,
7814 entry.input.flow.sctp4_flow.ip.src_ip);
7815 /* need convert to big endian. */
7816 entry.input.flow.sctp4_flow.verify_tag =
7817 rte_cpu_to_be_32(res->verify_tag_value);
7819 case RTE_ETH_FLOW_FRAG_IPV6:
7820 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
7821 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
7822 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
7823 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7824 entry.input.flow.ipv6_flow.dst_ip);
7825 IPV6_ADDR_TO_ARRAY(res->ip_src,
7826 entry.input.flow.ipv6_flow.src_ip);
7827 /* need convert to big endian. */
7828 entry.input.flow.udp6_flow.dst_port =
7829 rte_cpu_to_be_16(res->port_dst);
7830 entry.input.flow.udp6_flow.src_port =
7831 rte_cpu_to_be_16(res->port_src);
7833 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
7834 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7835 entry.input.flow.sctp6_flow.ip.dst_ip);
7836 IPV6_ADDR_TO_ARRAY(res->ip_src,
7837 entry.input.flow.sctp6_flow.ip.src_ip);
7838 /* need convert to big endian. */
7839 entry.input.flow.sctp6_flow.verify_tag =
7840 rte_cpu_to_be_32(res->verify_tag_value);
7843 printf("invalid parameter.\n");
7846 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7848 RTE_ETH_FDIR_MAX_FLEXLEN);
7850 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7852 entry.action.flex_off = 0; /*use 0 by default */
7853 if (!strcmp(res->drop, "drop"))
7854 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7856 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7857 /* set to report FD ID by default */
7858 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7859 entry.action.rx_queue = res->queue_id;
7860 entry.soft_id = res->fd_id_value;
7861 if (!strcmp(res->ops, "add"))
7862 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7863 RTE_ETH_FILTER_ADD, &entry);
7864 else if (!strcmp(res->ops, "del"))
7865 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7866 RTE_ETH_FILTER_DELETE, &entry);
7868 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7869 RTE_ETH_FILTER_UPDATE, &entry);
7871 printf("flow director programming error: (%s)\n",
7875 cmdline_parse_token_string_t cmd_flow_director_filter =
7876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7877 flow_director_filter, "flow_director_filter");
7878 cmdline_parse_token_num_t cmd_flow_director_port_id =
7879 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7881 cmdline_parse_token_string_t cmd_flow_director_ops =
7882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7883 ops, "add#del#update");
7884 cmdline_parse_token_string_t cmd_flow_director_flow =
7885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7887 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7888 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7889 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
7890 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp");
7891 cmdline_parse_token_string_t cmd_flow_director_src =
7892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7894 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7895 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7897 cmdline_parse_token_num_t cmd_flow_director_port_src =
7898 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7900 cmdline_parse_token_string_t cmd_flow_director_dst =
7901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7903 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
7904 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7906 cmdline_parse_token_num_t cmd_flow_director_port_dst =
7907 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7909 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
7910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7911 verify_tag, "verify_tag");
7912 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
7913 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7914 verify_tag_value, UINT32);
7915 cmdline_parse_token_string_t cmd_flow_director_vlan =
7916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7918 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
7919 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7920 vlan_value, UINT16);
7921 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
7922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7923 flexbytes, "flexbytes");
7924 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
7925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7926 flexbytes_value, NULL);
7927 cmdline_parse_token_string_t cmd_flow_director_drop =
7928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7930 cmdline_parse_token_string_t cmd_flow_director_queue =
7931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7933 cmdline_parse_token_num_t cmd_flow_director_queue_id =
7934 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7936 cmdline_parse_token_string_t cmd_flow_director_fd_id =
7937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7939 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
7940 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7941 fd_id_value, UINT32);
7943 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
7944 .f = cmd_flow_director_filter_parsed,
7946 .help_str = "add or delete an ip flow director entry on NIC",
7948 (void *)&cmd_flow_director_filter,
7949 (void *)&cmd_flow_director_port_id,
7950 (void *)&cmd_flow_director_ops,
7951 (void *)&cmd_flow_director_flow,
7952 (void *)&cmd_flow_director_flow_type,
7953 (void *)&cmd_flow_director_src,
7954 (void *)&cmd_flow_director_ip_src,
7955 (void *)&cmd_flow_director_dst,
7956 (void *)&cmd_flow_director_ip_dst,
7957 (void *)&cmd_flow_director_vlan,
7958 (void *)&cmd_flow_director_vlan_value,
7959 (void *)&cmd_flow_director_flexbytes,
7960 (void *)&cmd_flow_director_flexbytes_value,
7961 (void *)&cmd_flow_director_drop,
7962 (void *)&cmd_flow_director_queue,
7963 (void *)&cmd_flow_director_queue_id,
7964 (void *)&cmd_flow_director_fd_id,
7965 (void *)&cmd_flow_director_fd_id_value,
7970 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
7971 .f = cmd_flow_director_filter_parsed,
7973 .help_str = "add or delete an udp/tcp flow director entry on NIC",
7975 (void *)&cmd_flow_director_filter,
7976 (void *)&cmd_flow_director_port_id,
7977 (void *)&cmd_flow_director_ops,
7978 (void *)&cmd_flow_director_flow,
7979 (void *)&cmd_flow_director_flow_type,
7980 (void *)&cmd_flow_director_src,
7981 (void *)&cmd_flow_director_ip_src,
7982 (void *)&cmd_flow_director_port_src,
7983 (void *)&cmd_flow_director_dst,
7984 (void *)&cmd_flow_director_ip_dst,
7985 (void *)&cmd_flow_director_port_dst,
7986 (void *)&cmd_flow_director_vlan,
7987 (void *)&cmd_flow_director_vlan_value,
7988 (void *)&cmd_flow_director_flexbytes,
7989 (void *)&cmd_flow_director_flexbytes_value,
7990 (void *)&cmd_flow_director_drop,
7991 (void *)&cmd_flow_director_queue,
7992 (void *)&cmd_flow_director_queue_id,
7993 (void *)&cmd_flow_director_fd_id,
7994 (void *)&cmd_flow_director_fd_id_value,
7999 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8000 .f = cmd_flow_director_filter_parsed,
8002 .help_str = "add or delete a sctp flow director entry on NIC",
8004 (void *)&cmd_flow_director_filter,
8005 (void *)&cmd_flow_director_port_id,
8006 (void *)&cmd_flow_director_ops,
8007 (void *)&cmd_flow_director_flow,
8008 (void *)&cmd_flow_director_flow_type,
8009 (void *)&cmd_flow_director_src,
8010 (void *)&cmd_flow_director_ip_src,
8011 (void *)&cmd_flow_director_port_dst,
8012 (void *)&cmd_flow_director_dst,
8013 (void *)&cmd_flow_director_ip_dst,
8014 (void *)&cmd_flow_director_port_dst,
8015 (void *)&cmd_flow_director_verify_tag,
8016 (void *)&cmd_flow_director_verify_tag_value,
8017 (void *)&cmd_flow_director_vlan,
8018 (void *)&cmd_flow_director_vlan_value,
8019 (void *)&cmd_flow_director_flexbytes,
8020 (void *)&cmd_flow_director_flexbytes_value,
8021 (void *)&cmd_flow_director_drop,
8022 (void *)&cmd_flow_director_queue,
8023 (void *)&cmd_flow_director_queue_id,
8024 (void *)&cmd_flow_director_fd_id,
8025 (void *)&cmd_flow_director_fd_id_value,
8030 struct cmd_flush_flow_director_result {
8031 cmdline_fixed_string_t flush_flow_director;
8035 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8036 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8037 flush_flow_director, "flush_flow_director");
8038 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8039 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8043 cmd_flush_flow_director_parsed(void *parsed_result,
8044 __attribute__((unused)) struct cmdline *cl,
8045 __attribute__((unused)) void *data)
8047 struct cmd_flow_director_result *res = parsed_result;
8050 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8052 printf("flow director is not supported on port %u.\n",
8057 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8058 RTE_ETH_FILTER_FLUSH, NULL);
8060 printf("flow director table flushing error: (%s)\n",
8064 cmdline_parse_inst_t cmd_flush_flow_director = {
8065 .f = cmd_flush_flow_director_parsed,
8067 .help_str = "flush all flow director entries of a device on NIC",
8069 (void *)&cmd_flush_flow_director_flush,
8070 (void *)&cmd_flush_flow_director_port_id,
8075 /* *** deal with flow director mask *** */
8076 struct cmd_flow_director_mask_result {
8077 cmdline_fixed_string_t flow_director_mask;
8079 cmdline_fixed_string_t vlan;
8080 uint16_t vlan_value;
8081 cmdline_fixed_string_t src_mask;
8082 cmdline_ipaddr_t ipv4_src;
8083 cmdline_ipaddr_t ipv6_src;
8085 cmdline_fixed_string_t dst_mask;
8086 cmdline_ipaddr_t ipv4_dst;
8087 cmdline_ipaddr_t ipv6_dst;
8092 cmd_flow_director_mask_parsed(void *parsed_result,
8093 __attribute__((unused)) struct cmdline *cl,
8094 __attribute__((unused)) void *data)
8096 struct cmd_flow_director_mask_result *res = parsed_result;
8097 struct rte_eth_fdir_masks *mask;
8098 struct rte_port *port;
8100 if (res->port_id > nb_ports) {
8101 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8105 port = &ports[res->port_id];
8106 /** Check if the port is not started **/
8107 if (port->port_status != RTE_PORT_STOPPED) {
8108 printf("Please stop port %d first\n", res->port_id);
8111 mask = &port->dev_conf.fdir_conf.mask;
8113 mask->vlan_tci_mask = res->vlan_value;
8114 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8115 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8116 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8117 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8118 mask->src_port_mask = res->port_src;
8119 mask->dst_port_mask = res->port_dst;
8121 cmd_reconfig_device_queue(res->port_id, 1, 1);
8124 cmdline_parse_token_string_t cmd_flow_director_mask =
8125 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8126 flow_director_mask, "flow_director_mask");
8127 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8128 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8130 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8131 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8133 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8134 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8135 vlan_value, UINT16);
8136 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8137 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8138 src_mask, "src_mask");
8139 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8140 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8142 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8143 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8145 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8148 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8150 dst_mask, "dst_mask");
8151 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8152 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8154 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8155 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8157 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8158 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8160 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8161 .f = cmd_flow_director_mask_parsed,
8163 .help_str = "set flow director's mask on NIC",
8165 (void *)&cmd_flow_director_mask,
8166 (void *)&cmd_flow_director_mask_port_id,
8167 (void *)&cmd_flow_director_mask_vlan,
8168 (void *)&cmd_flow_director_mask_vlan_value,
8169 (void *)&cmd_flow_director_mask_src,
8170 (void *)&cmd_flow_director_mask_ipv4_src,
8171 (void *)&cmd_flow_director_mask_ipv6_src,
8172 (void *)&cmd_flow_director_mask_port_src,
8173 (void *)&cmd_flow_director_mask_dst,
8174 (void *)&cmd_flow_director_mask_ipv4_dst,
8175 (void *)&cmd_flow_director_mask_ipv6_dst,
8176 (void *)&cmd_flow_director_mask_port_dst,
8181 /* *** deal with flow director mask on flexible payload *** */
8182 struct cmd_flow_director_flex_mask_result {
8183 cmdline_fixed_string_t flow_director_flexmask;
8185 cmdline_fixed_string_t flow;
8186 cmdline_fixed_string_t flow_type;
8187 cmdline_fixed_string_t mask;
8191 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8192 __attribute__((unused)) struct cmdline *cl,
8193 __attribute__((unused)) void *data)
8195 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8196 struct rte_eth_fdir_info fdir_info;
8197 struct rte_eth_fdir_flex_mask flex_mask;
8198 struct rte_port *port;
8199 uint32_t flow_type_mask;
8203 if (res->port_id > nb_ports) {
8204 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8208 port = &ports[res->port_id];
8209 /** Check if the port is not started **/
8210 if (port->port_status != RTE_PORT_STOPPED) {
8211 printf("Please stop port %d first\n", res->port_id);
8215 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8216 ret = parse_flexbytes(res->mask,
8218 RTE_ETH_FDIR_MAX_FLEXLEN);
8220 printf("error: Cannot parse mask input.\n");
8224 memset(&fdir_info, 0, sizeof(fdir_info));
8225 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8226 RTE_ETH_FILTER_INFO, &fdir_info);
8228 printf("Cannot get FDir filter info\n");
8232 flow_type_mask = fdir_info.flow_types_mask[0];
8233 if (!strcmp(res->flow_type, "all")) {
8234 if (!flow_type_mask) {
8235 printf("No flow type supported\n");
8238 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8239 if (flow_type_mask & (1 << i)) {
8240 flex_mask.flow_type = i;
8241 fdir_set_flex_mask(res->port_id, &flex_mask);
8244 cmd_reconfig_device_queue(res->port_id, 1, 1);
8247 flex_mask.flow_type = str2flowtype(res->flow_type);
8248 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8249 printf("Flow type %s not supported on port %d\n",
8250 res->flow_type, res->port_id);
8253 fdir_set_flex_mask(res->port_id, &flex_mask);
8254 cmd_reconfig_device_queue(res->port_id, 1, 1);
8257 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8259 flow_director_flexmask,
8260 "flow_director_flex_mask");
8261 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8262 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8264 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8267 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8269 flow_type, "raw#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8270 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#all");
8271 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8275 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8276 .f = cmd_flow_director_flex_mask_parsed,
8278 .help_str = "set flow director's flex mask on NIC",
8280 (void *)&cmd_flow_director_flexmask,
8281 (void *)&cmd_flow_director_flexmask_port_id,
8282 (void *)&cmd_flow_director_flexmask_flow,
8283 (void *)&cmd_flow_director_flexmask_flow_type,
8284 (void *)&cmd_flow_director_flexmask_mask,
8289 /* *** deal with flow director flexible payload configuration *** */
8290 struct cmd_flow_director_flexpayload_result {
8291 cmdline_fixed_string_t flow_director_flexpayload;
8293 cmdline_fixed_string_t payload_layer;
8294 cmdline_fixed_string_t payload_cfg;
8298 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8301 const char *p, *p0 = q_arg;
8303 unsigned long int_fld;
8304 char *str_fld[max_num];
8309 p = strchr(p0, '(');
8313 p0 = strchr(p, ')');
8318 if (size >= sizeof(s))
8321 snprintf(s, sizeof(s), "%.*s", size, p);
8322 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8323 if (ret < 0 || ret > max_num)
8325 for (i = 0; i < ret; i++) {
8327 int_fld = strtoul(str_fld[i], &end, 0);
8328 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8330 offsets[i] = (uint16_t)int_fld;
8336 cmd_flow_director_flxpld_parsed(void *parsed_result,
8337 __attribute__((unused)) struct cmdline *cl,
8338 __attribute__((unused)) void *data)
8340 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8341 struct rte_eth_flex_payload_cfg flex_cfg;
8342 struct rte_port *port;
8345 if (res->port_id > nb_ports) {
8346 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8350 port = &ports[res->port_id];
8351 /** Check if the port is not started **/
8352 if (port->port_status != RTE_PORT_STOPPED) {
8353 printf("Please stop port %d first\n", res->port_id);
8357 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8359 if (!strcmp(res->payload_layer, "raw"))
8360 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8361 else if (!strcmp(res->payload_layer, "l2"))
8362 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8363 else if (!strcmp(res->payload_layer, "l3"))
8364 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8365 else if (!strcmp(res->payload_layer, "l4"))
8366 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8368 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8369 RTE_ETH_FDIR_MAX_FLEXLEN);
8371 printf("error: Cannot parse flex payload input.\n");
8375 fdir_set_flex_payload(res->port_id, &flex_cfg);
8376 cmd_reconfig_device_queue(res->port_id, 1, 1);
8379 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8380 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8381 flow_director_flexpayload,
8382 "flow_director_flex_payload");
8383 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8384 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8386 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8388 payload_layer, "raw#l2#l3#l4");
8389 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8390 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8393 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8394 .f = cmd_flow_director_flxpld_parsed,
8396 .help_str = "set flow director's flex payload on NIC",
8398 (void *)&cmd_flow_director_flexpayload,
8399 (void *)&cmd_flow_director_flexpayload_port_id,
8400 (void *)&cmd_flow_director_flexpayload_payload_layer,
8401 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8406 /* *** Classification Filters Control *** */
8407 /* *** Get symmetric hash enable per port *** */
8408 struct cmd_get_sym_hash_ena_per_port_result {
8409 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8414 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8415 __rte_unused struct cmdline *cl,
8416 __rte_unused void *data)
8418 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8419 struct rte_eth_hash_filter_info info;
8422 if (rte_eth_dev_filter_supported(res->port_id,
8423 RTE_ETH_FILTER_HASH) < 0) {
8424 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8429 memset(&info, 0, sizeof(info));
8430 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8431 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8432 RTE_ETH_FILTER_GET, &info);
8435 printf("Cannot get symmetric hash enable per port "
8436 "on port %u\n", res->port_id);
8440 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8441 "enabled" : "disabled", res->port_id);
8444 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8445 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8446 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8447 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8448 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8451 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8452 .f = cmd_get_sym_hash_per_port_parsed,
8454 .help_str = "get_sym_hash_ena_per_port port_id",
8456 (void *)&cmd_get_sym_hash_ena_per_port_all,
8457 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8462 /* *** Set symmetric hash enable per port *** */
8463 struct cmd_set_sym_hash_ena_per_port_result {
8464 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8465 cmdline_fixed_string_t enable;
8470 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8471 __rte_unused struct cmdline *cl,
8472 __rte_unused void *data)
8474 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8475 struct rte_eth_hash_filter_info info;
8478 if (rte_eth_dev_filter_supported(res->port_id,
8479 RTE_ETH_FILTER_HASH) < 0) {
8480 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8485 memset(&info, 0, sizeof(info));
8486 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8487 if (!strcmp(res->enable, "enable"))
8488 info.info.enable = 1;
8489 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8490 RTE_ETH_FILTER_SET, &info);
8492 printf("Cannot set symmetric hash enable per port on "
8493 "port %u\n", res->port_id);
8496 printf("Symmetric hash has been set to %s on port %u\n",
8497 res->enable, res->port_id);
8500 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8501 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8502 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8503 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8504 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8506 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8507 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8508 enable, "enable#disable");
8510 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8511 .f = cmd_set_sym_hash_per_port_parsed,
8513 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8515 (void *)&cmd_set_sym_hash_ena_per_port_all,
8516 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8517 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8522 /* Get global config of hash function */
8523 struct cmd_get_hash_global_config_result {
8524 cmdline_fixed_string_t get_hash_global_config;
8529 flowtype_to_str(uint16_t ftype)
8536 {"ipv4", RTE_ETH_FLOW_IPV4},
8537 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8538 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8539 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8540 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8541 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8542 {"ipv6", RTE_ETH_FLOW_IPV6},
8543 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8544 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8545 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8546 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8547 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8548 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8551 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8552 if (ftype_table[i].ftype == ftype)
8553 return ftype_table[i].str;
8560 cmd_get_hash_global_config_parsed(void *parsed_result,
8561 __rte_unused struct cmdline *cl,
8562 __rte_unused void *data)
8564 struct cmd_get_hash_global_config_result *res = parsed_result;
8565 struct rte_eth_hash_filter_info info;
8566 uint32_t idx, offset;
8571 if (rte_eth_dev_filter_supported(res->port_id,
8572 RTE_ETH_FILTER_HASH) < 0) {
8573 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8578 memset(&info, 0, sizeof(info));
8579 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8580 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8581 RTE_ETH_FILTER_GET, &info);
8583 printf("Cannot get hash global configurations by port %d\n",
8588 switch (info.info.global_conf.hash_func) {
8589 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8590 printf("Hash function is Toeplitz\n");
8592 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8593 printf("Hash function is Simple XOR\n");
8596 printf("Unknown hash function\n");
8600 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
8601 idx = i / UINT32_BIT;
8602 offset = i % UINT32_BIT;
8603 if (!(info.info.global_conf.valid_bit_mask[idx] &
8606 str = flowtype_to_str(i);
8609 printf("Symmetric hash is %s globally for flow type %s "
8611 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8612 (1UL << offset)) ? "enabled" : "disabled"), str,
8617 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8618 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8619 get_hash_global_config, "get_hash_global_config");
8620 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8621 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8624 cmdline_parse_inst_t cmd_get_hash_global_config = {
8625 .f = cmd_get_hash_global_config_parsed,
8627 .help_str = "get_hash_global_config port_id",
8629 (void *)&cmd_get_hash_global_config_all,
8630 (void *)&cmd_get_hash_global_config_port_id,
8635 /* Set global config of hash function */
8636 struct cmd_set_hash_global_config_result {
8637 cmdline_fixed_string_t set_hash_global_config;
8639 cmdline_fixed_string_t hash_func;
8640 cmdline_fixed_string_t flow_type;
8641 cmdline_fixed_string_t enable;
8645 cmd_set_hash_global_config_parsed(void *parsed_result,
8646 __rte_unused struct cmdline *cl,
8647 __rte_unused void *data)
8649 struct cmd_set_hash_global_config_result *res = parsed_result;
8650 struct rte_eth_hash_filter_info info;
8651 uint32_t ftype, idx, offset;
8654 if (rte_eth_dev_filter_supported(res->port_id,
8655 RTE_ETH_FILTER_HASH) < 0) {
8656 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8660 memset(&info, 0, sizeof(info));
8661 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8662 if (!strcmp(res->hash_func, "toeplitz"))
8663 info.info.global_conf.hash_func =
8664 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8665 else if (!strcmp(res->hash_func, "simple_xor"))
8666 info.info.global_conf.hash_func =
8667 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8668 else if (!strcmp(res->hash_func, "default"))
8669 info.info.global_conf.hash_func =
8670 RTE_ETH_HASH_FUNCTION_DEFAULT;
8672 ftype = str2flowtype(res->flow_type);
8673 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8674 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8675 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8676 if (!strcmp(res->enable, "enable"))
8677 info.info.global_conf.sym_hash_enable_mask[idx] |=
8679 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8680 RTE_ETH_FILTER_SET, &info);
8682 printf("Cannot set global hash configurations by port %d\n",
8685 printf("Global hash configurations have been set "
8686 "succcessfully by port %d\n", res->port_id);
8689 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8690 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8691 set_hash_global_config, "set_hash_global_config");
8692 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8693 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8695 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8696 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8697 hash_func, "toeplitz#simple_xor#default");
8698 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8699 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8701 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
8702 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
8703 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8704 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8705 enable, "enable#disable");
8707 cmdline_parse_inst_t cmd_set_hash_global_config = {
8708 .f = cmd_set_hash_global_config_parsed,
8710 .help_str = "set_hash_global_config port_id "
8711 "toeplitz|simple_xor|default "
8712 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
8713 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
8716 (void *)&cmd_set_hash_global_config_all,
8717 (void *)&cmd_set_hash_global_config_port_id,
8718 (void *)&cmd_set_hash_global_config_hash_func,
8719 (void *)&cmd_set_hash_global_config_flow_type,
8720 (void *)&cmd_set_hash_global_config_enable,
8725 /* ******************************************************************************** */
8727 /* list of instructions */
8728 cmdline_parse_ctx_t main_ctx[] = {
8729 (cmdline_parse_inst_t *)&cmd_help_brief,
8730 (cmdline_parse_inst_t *)&cmd_help_long,
8731 (cmdline_parse_inst_t *)&cmd_quit,
8732 (cmdline_parse_inst_t *)&cmd_showport,
8733 (cmdline_parse_inst_t *)&cmd_showportall,
8734 (cmdline_parse_inst_t *)&cmd_showcfg,
8735 (cmdline_parse_inst_t *)&cmd_start,
8736 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8737 (cmdline_parse_inst_t *)&cmd_set_link_up,
8738 (cmdline_parse_inst_t *)&cmd_set_link_down,
8739 (cmdline_parse_inst_t *)&cmd_reset,
8740 (cmdline_parse_inst_t *)&cmd_set_numbers,
8741 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8742 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8743 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8744 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8745 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8746 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8747 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8748 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8749 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8750 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8751 (cmdline_parse_inst_t *)&cmd_set_link_check,
8752 #ifdef RTE_NIC_BYPASS
8753 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8754 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8755 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8756 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8758 #ifdef RTE_LIBRTE_PMD_BOND
8759 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8760 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8761 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8762 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8763 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8764 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8765 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8766 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8767 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8769 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8770 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8771 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8772 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8773 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8774 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8775 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8776 (cmdline_parse_inst_t *)&cmd_csum_set,
8777 (cmdline_parse_inst_t *)&cmd_csum_show,
8778 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8779 (cmdline_parse_inst_t *)&cmd_tso_set,
8780 (cmdline_parse_inst_t *)&cmd_tso_show,
8781 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8782 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8783 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8784 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8785 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8786 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8787 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8788 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8789 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8790 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8791 (cmdline_parse_inst_t *)&cmd_config_dcb,
8792 (cmdline_parse_inst_t *)&cmd_read_reg,
8793 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8794 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8795 (cmdline_parse_inst_t *)&cmd_write_reg,
8796 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8797 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8798 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8799 (cmdline_parse_inst_t *)&cmd_stop,
8800 (cmdline_parse_inst_t *)&cmd_mac_addr,
8801 (cmdline_parse_inst_t *)&cmd_set_qmap,
8802 (cmdline_parse_inst_t *)&cmd_operate_port,
8803 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8804 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
8805 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
8806 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8807 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8808 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8809 (cmdline_parse_inst_t *)&cmd_config_mtu,
8810 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8811 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8812 (cmdline_parse_inst_t *)&cmd_config_rss,
8813 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8814 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8815 (cmdline_parse_inst_t *)&cmd_showport_reta,
8816 (cmdline_parse_inst_t *)&cmd_config_burst,
8817 (cmdline_parse_inst_t *)&cmd_config_thresh,
8818 (cmdline_parse_inst_t *)&cmd_config_threshold,
8819 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8820 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8821 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8822 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8823 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8824 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8825 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8826 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8827 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8828 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8829 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8830 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8831 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8832 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8833 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8834 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8835 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8836 (cmdline_parse_inst_t *)&cmd_dump,
8837 (cmdline_parse_inst_t *)&cmd_dump_one,
8838 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
8839 (cmdline_parse_inst_t *)&cmd_syn_filter,
8840 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
8841 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
8842 (cmdline_parse_inst_t *)&cmd_flex_filter,
8843 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8844 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8845 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8846 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8847 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
8848 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8849 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8850 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
8851 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
8852 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
8853 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
8857 /* prompt function, called from main on MASTER lcore */
8863 /* initialize non-constant commands */
8864 cmd_set_fwd_mode_init();
8866 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8870 cmdline_interact(cl);
8871 cmdline_stdin_exit(cl);
8875 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8877 if (!port_id_is_invalid(id, DISABLED_WARN)) {
8878 /* check if need_reconfig has been set to 1 */
8879 if (ports[id].need_reconfig == 0)
8880 ports[id].need_reconfig = dev;
8881 /* check if need_reconfig_queues has been set to 1 */
8882 if (ports[id].need_reconfig_queues == 0)
8883 ports[id].need_reconfig_queues = queue;
8887 FOREACH_PORT(pid, ports) {
8888 /* check if need_reconfig has been set to 1 */
8889 if (ports[pid].need_reconfig == 0)
8890 ports[pid].need_reconfig = dev;
8891 /* check if need_reconfig_queues has been set to 1 */
8892 if (ports[pid].need_reconfig_queues == 0)
8893 ports[pid].need_reconfig_queues = queue;
8898 #ifdef RTE_NIC_BYPASS
8900 bypass_is_supported(portid_t port_id)
8902 struct rte_port *port;
8903 struct rte_pci_id *pci_id;
8905 if (port_id_is_invalid(port_id, ENABLED_WARN))
8908 /* Get the device id. */
8909 port = &ports[port_id];
8910 pci_id = &port->dev_info.pci_dev->id;
8912 /* Check if NIC supports bypass. */
8913 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8917 printf("\tBypass not supported for port_id = %d.\n", port_id);