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|drop-en)"
535 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
538 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
539 " Set the RSS mode.\n\n"
541 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
542 " Set the RSS redirection table.\n\n"
544 "port config (port_id) dcb vt (on|off) (traffic_class)"
546 " Set the DCB mode.\n\n"
548 "port config all burst (value)\n"
549 " Set the number of packets per burst.\n\n"
551 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
553 " Set the ring prefetch/host/writeback threshold"
554 " for tx/rx queue.\n\n"
556 "port config all (txfreet|txrst|rxfreet) (value)\n"
557 " Set free threshold for rx/tx, or set"
558 " tx rs bit threshold.\n\n"
559 "port config mtu X value\n"
560 " Set the MTU of port X to a given value\n\n"
562 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
563 " Start/stop a rx/tx queue of port X. Only take effect"
564 " when port X is started\n"
568 if (show_all || !strcmp(res->section, "registers")) {
576 "read reg (port_id) (address)\n"
577 " Display value of a port register.\n\n"
579 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
580 " Display a port register bit field.\n\n"
582 "read regbit (port_id) (address) (bit_x)\n"
583 " Display a single port register bit.\n\n"
585 "write reg (port_id) (address) (value)\n"
586 " Set value of a port register.\n\n"
588 "write regfield (port_id) (address) (bit_x) (bit_y)"
590 " Set bit field of a port register.\n\n"
592 "write regbit (port_id) (address) (bit_x) (value)\n"
593 " Set single bit value of a port register.\n\n"
596 if (show_all || !strcmp(res->section, "filters")) {
604 "ethertype_filter (port_id) (add|del)"
605 " (mac_addr|mac_ignr) (mac_address) ethertype"
606 " (ether_type) (drop|fwd) queue (queue_id)\n"
607 " Add/Del an ethertype filter.\n\n"
609 "2tuple_filter (port_id) (add|del)"
610 " dst_port (dst_port_value) protocol (protocol_value)"
611 " mask (mask_value) tcp_flags (tcp_flags_value)"
612 " priority (prio_value) queue (queue_id)\n"
613 " Add/Del a 2tuple filter.\n\n"
615 "5tuple_filter (port_id) (add|del)"
616 " dst_ip (dst_address) src_ip (src_address)"
617 " dst_port (dst_port_value) src_port (src_port_value)"
618 " protocol (protocol_value)"
619 " mask (mask_value) tcp_flags (tcp_flags_value)"
620 " priority (prio_value) queue (queue_id)\n"
621 " Add/Del a 5tuple filter.\n\n"
623 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
624 " Add/Del syn filter.\n\n"
626 "flex_filter (port_id) (add|del) len (len_value)"
627 " bytes (bytes_value) mask (mask_value)"
628 " priority (prio_value) queue (queue_id)\n"
629 " Add/Del a flex filter.\n\n"
631 "flow_director_filter (port_id) (add|del|update)"
632 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
633 " src (src_ip_address) dst (dst_ip_address)"
634 " vlan (vlan_value) flexbytes (flexbytes_value)"
635 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
636 " Add/Del an IP type flow director filter.\n\n"
638 "flow_director_filter (port_id) (add|del|update)"
639 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
640 " src (src_ip_address) (src_port)"
641 " dst (dst_ip_address) (dst_port)"
642 " vlan (vlan_value) flexbytes (flexbytes_value)"
643 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
644 " Add/Del an UDP/TCP type flow director filter.\n\n"
646 "flow_director_filter (port_id) (add|del|update)"
647 " flow (ipv4-sctp|ipv6-sctp)"
648 " src (src_ip_address) (src_port)"
649 " dst (dst_ip_address) (dst_port)"
650 " tag (verification_tag) vlan (vlan_value)"
651 " flexbytes (flexbytes_value) (drop|fwd)"
652 " queue (queue_id) fd_id (fd_id_value)\n"
653 " Add/Del a SCTP type flow director filter.\n\n"
655 "flush_flow_director (port_id)\n"
656 " Flush all flow director entries of a device.\n\n"
658 "flow_director_mask (port_id) vlan (vlan_value)"
659 " src_mask (ipv4_src) (ipv6_src) (src_port)"
660 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
661 " Set flow director mask.\n\n"
663 "flow_director_flex_mask (port_id)"
664 " flow (raw|ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
665 " flow (raw|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
666 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|all)"
668 " Configure mask of flex payload.\n\n"
670 "flow_director_flex_payload (port_id)"
671 " (raw|l2|l3|l4) (config)\n"
672 " Configure flex payload selection.\n\n"
674 "get_sym_hash_ena_per_port (port_id)\n"
675 " get symmetric hash enable configuration per port.\n\n"
677 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
678 " set symmetric hash enable configuration per port"
679 " to enable or disable.\n\n"
681 "get_hash_global_config (port_id)\n"
682 " Get the global configurations of hash filters.\n\n"
684 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
685 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
686 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
687 " (enable|disable)\n"
688 " Set the global configurations of hash filters.\n\n"
693 cmdline_parse_token_string_t cmd_help_long_help =
694 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
696 cmdline_parse_token_string_t cmd_help_long_section =
697 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
698 "all#control#display#config#"
699 "ports#registers#filters");
701 cmdline_parse_inst_t cmd_help_long = {
702 .f = cmd_help_long_parsed,
704 .help_str = "show help",
706 (void *)&cmd_help_long_help,
707 (void *)&cmd_help_long_section,
713 /* *** start/stop/close all ports *** */
714 struct cmd_operate_port_result {
715 cmdline_fixed_string_t keyword;
716 cmdline_fixed_string_t name;
717 cmdline_fixed_string_t value;
720 static void cmd_operate_port_parsed(void *parsed_result,
721 __attribute__((unused)) struct cmdline *cl,
722 __attribute__((unused)) void *data)
724 struct cmd_operate_port_result *res = parsed_result;
726 if (!strcmp(res->name, "start"))
727 start_port(RTE_PORT_ALL);
728 else if (!strcmp(res->name, "stop"))
729 stop_port(RTE_PORT_ALL);
730 else if (!strcmp(res->name, "close"))
731 close_port(RTE_PORT_ALL);
733 printf("Unknown parameter\n");
736 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
737 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
739 cmdline_parse_token_string_t cmd_operate_port_all_port =
740 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
742 cmdline_parse_token_string_t cmd_operate_port_all_all =
743 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
745 cmdline_parse_inst_t cmd_operate_port = {
746 .f = cmd_operate_port_parsed,
748 .help_str = "port start|stop|close all: start/stop/close all ports",
750 (void *)&cmd_operate_port_all_cmd,
751 (void *)&cmd_operate_port_all_port,
752 (void *)&cmd_operate_port_all_all,
757 /* *** start/stop/close specific port *** */
758 struct cmd_operate_specific_port_result {
759 cmdline_fixed_string_t keyword;
760 cmdline_fixed_string_t name;
764 static void cmd_operate_specific_port_parsed(void *parsed_result,
765 __attribute__((unused)) struct cmdline *cl,
766 __attribute__((unused)) void *data)
768 struct cmd_operate_specific_port_result *res = parsed_result;
770 if (!strcmp(res->name, "start"))
771 start_port(res->value);
772 else if (!strcmp(res->name, "stop"))
773 stop_port(res->value);
774 else if (!strcmp(res->name, "close"))
775 close_port(res->value);
777 printf("Unknown parameter\n");
780 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
781 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
783 cmdline_parse_token_string_t cmd_operate_specific_port_port =
784 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
785 name, "start#stop#close");
786 cmdline_parse_token_num_t cmd_operate_specific_port_id =
787 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
790 cmdline_parse_inst_t cmd_operate_specific_port = {
791 .f = cmd_operate_specific_port_parsed,
793 .help_str = "port start|stop|close X: start/stop/close port X",
795 (void *)&cmd_operate_specific_port_cmd,
796 (void *)&cmd_operate_specific_port_port,
797 (void *)&cmd_operate_specific_port_id,
802 /* *** attach a specified port *** */
803 struct cmd_operate_attach_port_result {
804 cmdline_fixed_string_t port;
805 cmdline_fixed_string_t keyword;
806 cmdline_fixed_string_t identifier;
809 static void cmd_operate_attach_port_parsed(void *parsed_result,
810 __attribute__((unused)) struct cmdline *cl,
811 __attribute__((unused)) void *data)
813 struct cmd_operate_attach_port_result *res = parsed_result;
815 if (!strcmp(res->keyword, "attach"))
816 attach_port(res->identifier);
818 printf("Unknown parameter\n");
821 cmdline_parse_token_string_t cmd_operate_attach_port_port =
822 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
824 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
825 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
827 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
828 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
831 cmdline_parse_inst_t cmd_operate_attach_port = {
832 .f = cmd_operate_attach_port_parsed,
834 .help_str = "port attach identifier, "
835 "identifier: pci address or virtual dev name",
837 (void *)&cmd_operate_attach_port_port,
838 (void *)&cmd_operate_attach_port_keyword,
839 (void *)&cmd_operate_attach_port_identifier,
844 /* *** detach a specified port *** */
845 struct cmd_operate_detach_port_result {
846 cmdline_fixed_string_t port;
847 cmdline_fixed_string_t keyword;
851 static void cmd_operate_detach_port_parsed(void *parsed_result,
852 __attribute__((unused)) struct cmdline *cl,
853 __attribute__((unused)) void *data)
855 struct cmd_operate_detach_port_result *res = parsed_result;
857 if (!strcmp(res->keyword, "detach"))
858 detach_port(res->port_id);
860 printf("Unknown parameter\n");
863 cmdline_parse_token_string_t cmd_operate_detach_port_port =
864 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
866 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
867 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
869 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
870 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
873 cmdline_parse_inst_t cmd_operate_detach_port = {
874 .f = cmd_operate_detach_port_parsed,
876 .help_str = "port detach port_id",
878 (void *)&cmd_operate_detach_port_port,
879 (void *)&cmd_operate_detach_port_keyword,
880 (void *)&cmd_operate_detach_port_port_id,
885 /* *** configure speed for all ports *** */
886 struct cmd_config_speed_all {
887 cmdline_fixed_string_t port;
888 cmdline_fixed_string_t keyword;
889 cmdline_fixed_string_t all;
890 cmdline_fixed_string_t item1;
891 cmdline_fixed_string_t item2;
892 cmdline_fixed_string_t value1;
893 cmdline_fixed_string_t value2;
897 cmd_config_speed_all_parsed(void *parsed_result,
898 __attribute__((unused)) struct cmdline *cl,
899 __attribute__((unused)) void *data)
901 struct cmd_config_speed_all *res = parsed_result;
902 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
903 uint16_t link_duplex = 0;
906 if (!all_ports_stopped()) {
907 printf("Please stop all ports first\n");
911 if (!strcmp(res->value1, "10"))
912 link_speed = ETH_LINK_SPEED_10;
913 else if (!strcmp(res->value1, "100"))
914 link_speed = ETH_LINK_SPEED_100;
915 else if (!strcmp(res->value1, "1000"))
916 link_speed = ETH_LINK_SPEED_1000;
917 else if (!strcmp(res->value1, "10000"))
918 link_speed = ETH_LINK_SPEED_10G;
919 else if (!strcmp(res->value1, "40000"))
920 link_speed = ETH_LINK_SPEED_40G;
921 else if (!strcmp(res->value1, "auto"))
922 link_speed = ETH_LINK_SPEED_AUTONEG;
924 printf("Unknown parameter\n");
928 if (!strcmp(res->value2, "half"))
929 link_duplex = ETH_LINK_HALF_DUPLEX;
930 else if (!strcmp(res->value2, "full"))
931 link_duplex = ETH_LINK_FULL_DUPLEX;
932 else if (!strcmp(res->value2, "auto"))
933 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
935 printf("Unknown parameter\n");
939 FOREACH_PORT(pid, ports) {
940 ports[pid].dev_conf.link_speed = link_speed;
941 ports[pid].dev_conf.link_duplex = link_duplex;
944 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
947 cmdline_parse_token_string_t cmd_config_speed_all_port =
948 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
949 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
950 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
952 cmdline_parse_token_string_t cmd_config_speed_all_all =
953 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
954 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
955 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
956 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
957 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
958 "10#100#1000#10000#40000#auto");
959 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
960 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
961 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
962 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
965 cmdline_parse_inst_t cmd_config_speed_all = {
966 .f = cmd_config_speed_all_parsed,
968 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
971 (void *)&cmd_config_speed_all_port,
972 (void *)&cmd_config_speed_all_keyword,
973 (void *)&cmd_config_speed_all_all,
974 (void *)&cmd_config_speed_all_item1,
975 (void *)&cmd_config_speed_all_value1,
976 (void *)&cmd_config_speed_all_item2,
977 (void *)&cmd_config_speed_all_value2,
982 /* *** configure speed for specific port *** */
983 struct cmd_config_speed_specific {
984 cmdline_fixed_string_t port;
985 cmdline_fixed_string_t keyword;
987 cmdline_fixed_string_t item1;
988 cmdline_fixed_string_t item2;
989 cmdline_fixed_string_t value1;
990 cmdline_fixed_string_t value2;
994 cmd_config_speed_specific_parsed(void *parsed_result,
995 __attribute__((unused)) struct cmdline *cl,
996 __attribute__((unused)) void *data)
998 struct cmd_config_speed_specific *res = parsed_result;
999 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1000 uint16_t link_duplex = 0;
1002 if (!all_ports_stopped()) {
1003 printf("Please stop all ports first\n");
1007 if (port_id_is_invalid(res->id, ENABLED_WARN))
1010 if (!strcmp(res->value1, "10"))
1011 link_speed = ETH_LINK_SPEED_10;
1012 else if (!strcmp(res->value1, "100"))
1013 link_speed = ETH_LINK_SPEED_100;
1014 else if (!strcmp(res->value1, "1000"))
1015 link_speed = ETH_LINK_SPEED_1000;
1016 else if (!strcmp(res->value1, "10000"))
1017 link_speed = ETH_LINK_SPEED_10000;
1018 else if (!strcmp(res->value1, "40000"))
1019 link_speed = ETH_LINK_SPEED_40G;
1020 else if (!strcmp(res->value1, "auto"))
1021 link_speed = ETH_LINK_SPEED_AUTONEG;
1023 printf("Unknown parameter\n");
1027 if (!strcmp(res->value2, "half"))
1028 link_duplex = ETH_LINK_HALF_DUPLEX;
1029 else if (!strcmp(res->value2, "full"))
1030 link_duplex = ETH_LINK_FULL_DUPLEX;
1031 else if (!strcmp(res->value2, "auto"))
1032 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1034 printf("Unknown parameter\n");
1038 ports[res->id].dev_conf.link_speed = link_speed;
1039 ports[res->id].dev_conf.link_duplex = link_duplex;
1041 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1045 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1046 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1048 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1049 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1051 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1052 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1053 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1054 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1056 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1057 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1058 "10#100#1000#10000#40000#auto");
1059 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1060 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1062 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1063 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1066 cmdline_parse_inst_t cmd_config_speed_specific = {
1067 .f = cmd_config_speed_specific_parsed,
1069 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1072 (void *)&cmd_config_speed_specific_port,
1073 (void *)&cmd_config_speed_specific_keyword,
1074 (void *)&cmd_config_speed_specific_id,
1075 (void *)&cmd_config_speed_specific_item1,
1076 (void *)&cmd_config_speed_specific_value1,
1077 (void *)&cmd_config_speed_specific_item2,
1078 (void *)&cmd_config_speed_specific_value2,
1083 /* *** configure txq/rxq, txd/rxd *** */
1084 struct cmd_config_rx_tx {
1085 cmdline_fixed_string_t port;
1086 cmdline_fixed_string_t keyword;
1087 cmdline_fixed_string_t all;
1088 cmdline_fixed_string_t name;
1093 cmd_config_rx_tx_parsed(void *parsed_result,
1094 __attribute__((unused)) struct cmdline *cl,
1095 __attribute__((unused)) void *data)
1097 struct cmd_config_rx_tx *res = parsed_result;
1099 if (!all_ports_stopped()) {
1100 printf("Please stop all ports first\n");
1104 if (!strcmp(res->name, "rxq")) {
1105 if (res->value <= 0) {
1106 printf("rxq %d invalid - must be > 0\n", res->value);
1109 nb_rxq = res->value;
1111 else if (!strcmp(res->name, "txq")) {
1112 if (res->value <= 0) {
1113 printf("txq %d invalid - must be > 0\n", res->value);
1116 nb_txq = res->value;
1118 else if (!strcmp(res->name, "rxd")) {
1119 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1120 printf("rxd %d invalid - must be > 0 && <= %d\n",
1121 res->value, RTE_TEST_RX_DESC_MAX);
1124 nb_rxd = res->value;
1125 } else if (!strcmp(res->name, "txd")) {
1126 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1127 printf("txd %d invalid - must be > 0 && <= %d\n",
1128 res->value, RTE_TEST_TX_DESC_MAX);
1131 nb_txd = res->value;
1133 printf("Unknown parameter\n");
1139 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1142 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1143 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1144 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1145 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1146 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1148 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1151 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1152 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1154 cmdline_parse_inst_t cmd_config_rx_tx = {
1155 .f = cmd_config_rx_tx_parsed,
1157 .help_str = "port config all rxq|txq|rxd|txd value",
1159 (void *)&cmd_config_rx_tx_port,
1160 (void *)&cmd_config_rx_tx_keyword,
1161 (void *)&cmd_config_rx_tx_all,
1162 (void *)&cmd_config_rx_tx_name,
1163 (void *)&cmd_config_rx_tx_value,
1168 /* *** config max packet length *** */
1169 struct cmd_config_max_pkt_len_result {
1170 cmdline_fixed_string_t port;
1171 cmdline_fixed_string_t keyword;
1172 cmdline_fixed_string_t all;
1173 cmdline_fixed_string_t name;
1178 cmd_config_max_pkt_len_parsed(void *parsed_result,
1179 __attribute__((unused)) struct cmdline *cl,
1180 __attribute__((unused)) void *data)
1182 struct cmd_config_max_pkt_len_result *res = parsed_result;
1184 if (!all_ports_stopped()) {
1185 printf("Please stop all ports first\n");
1189 if (!strcmp(res->name, "max-pkt-len")) {
1190 if (res->value < ETHER_MIN_LEN) {
1191 printf("max-pkt-len can not be less than %d\n",
1195 if (res->value == rx_mode.max_rx_pkt_len)
1198 rx_mode.max_rx_pkt_len = res->value;
1199 if (res->value > ETHER_MAX_LEN)
1200 rx_mode.jumbo_frame = 1;
1202 rx_mode.jumbo_frame = 0;
1204 printf("Unknown parameter\n");
1210 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1213 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1214 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1216 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1217 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1219 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1220 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1222 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1223 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1225 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1226 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1229 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1230 .f = cmd_config_max_pkt_len_parsed,
1232 .help_str = "port config all max-pkt-len value",
1234 (void *)&cmd_config_max_pkt_len_port,
1235 (void *)&cmd_config_max_pkt_len_keyword,
1236 (void *)&cmd_config_max_pkt_len_all,
1237 (void *)&cmd_config_max_pkt_len_name,
1238 (void *)&cmd_config_max_pkt_len_value,
1243 /* *** configure port MTU *** */
1244 struct cmd_config_mtu_result {
1245 cmdline_fixed_string_t port;
1246 cmdline_fixed_string_t keyword;
1247 cmdline_fixed_string_t mtu;
1253 cmd_config_mtu_parsed(void *parsed_result,
1254 __attribute__((unused)) struct cmdline *cl,
1255 __attribute__((unused)) void *data)
1257 struct cmd_config_mtu_result *res = parsed_result;
1259 if (res->value < ETHER_MIN_LEN) {
1260 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1263 port_mtu_set(res->port_id, res->value);
1266 cmdline_parse_token_string_t cmd_config_mtu_port =
1267 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1269 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1270 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1272 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1273 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1275 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1276 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1277 cmdline_parse_token_num_t cmd_config_mtu_value =
1278 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1280 cmdline_parse_inst_t cmd_config_mtu = {
1281 .f = cmd_config_mtu_parsed,
1283 .help_str = "port config mtu value",
1285 (void *)&cmd_config_mtu_port,
1286 (void *)&cmd_config_mtu_keyword,
1287 (void *)&cmd_config_mtu_mtu,
1288 (void *)&cmd_config_mtu_port_id,
1289 (void *)&cmd_config_mtu_value,
1294 /* *** configure rx mode *** */
1295 struct cmd_config_rx_mode_flag {
1296 cmdline_fixed_string_t port;
1297 cmdline_fixed_string_t keyword;
1298 cmdline_fixed_string_t all;
1299 cmdline_fixed_string_t name;
1300 cmdline_fixed_string_t value;
1304 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1305 __attribute__((unused)) struct cmdline *cl,
1306 __attribute__((unused)) void *data)
1308 struct cmd_config_rx_mode_flag *res = parsed_result;
1310 if (!all_ports_stopped()) {
1311 printf("Please stop all ports first\n");
1315 if (!strcmp(res->name, "crc-strip")) {
1316 if (!strcmp(res->value, "on"))
1317 rx_mode.hw_strip_crc = 1;
1318 else if (!strcmp(res->value, "off"))
1319 rx_mode.hw_strip_crc = 0;
1321 printf("Unknown parameter\n");
1324 } else if (!strcmp(res->name, "rx-cksum")) {
1325 if (!strcmp(res->value, "on"))
1326 rx_mode.hw_ip_checksum = 1;
1327 else if (!strcmp(res->value, "off"))
1328 rx_mode.hw_ip_checksum = 0;
1330 printf("Unknown parameter\n");
1333 } else if (!strcmp(res->name, "hw-vlan")) {
1334 if (!strcmp(res->value, "on")) {
1335 rx_mode.hw_vlan_filter = 1;
1336 rx_mode.hw_vlan_strip = 1;
1338 else if (!strcmp(res->value, "off")) {
1339 rx_mode.hw_vlan_filter = 0;
1340 rx_mode.hw_vlan_strip = 0;
1343 printf("Unknown parameter\n");
1346 } else if (!strcmp(res->name, "drop-en")) {
1347 if (!strcmp(res->value, "on"))
1349 else if (!strcmp(res->value, "off"))
1352 printf("Unknown parameter\n");
1356 printf("Unknown parameter\n");
1362 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1365 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1366 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1367 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1368 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1370 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1371 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1372 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1373 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1374 "crc-strip#rx-cksum#hw-vlan");
1375 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1376 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1379 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1380 .f = cmd_config_rx_mode_flag_parsed,
1382 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1384 (void *)&cmd_config_rx_mode_flag_port,
1385 (void *)&cmd_config_rx_mode_flag_keyword,
1386 (void *)&cmd_config_rx_mode_flag_all,
1387 (void *)&cmd_config_rx_mode_flag_name,
1388 (void *)&cmd_config_rx_mode_flag_value,
1393 /* *** configure rss *** */
1394 struct cmd_config_rss {
1395 cmdline_fixed_string_t port;
1396 cmdline_fixed_string_t keyword;
1397 cmdline_fixed_string_t all;
1398 cmdline_fixed_string_t name;
1399 cmdline_fixed_string_t value;
1403 cmd_config_rss_parsed(void *parsed_result,
1404 __attribute__((unused)) struct cmdline *cl,
1405 __attribute__((unused)) void *data)
1407 struct cmd_config_rss *res = parsed_result;
1408 struct rte_eth_rss_conf rss_conf;
1411 if (!strcmp(res->value, "all"))
1412 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1413 ETH_RSS_UDP | ETH_RSS_SCTP |
1415 else if (!strcmp(res->value, "ip"))
1416 rss_conf.rss_hf = ETH_RSS_IP;
1417 else if (!strcmp(res->value, "udp"))
1418 rss_conf.rss_hf = ETH_RSS_UDP;
1419 else if (!strcmp(res->value, "tcp"))
1420 rss_conf.rss_hf = ETH_RSS_TCP;
1421 else if (!strcmp(res->value, "sctp"))
1422 rss_conf.rss_hf = ETH_RSS_SCTP;
1423 else if (!strcmp(res->value, "ether"))
1424 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1425 else if (!strcmp(res->value, "none"))
1426 rss_conf.rss_hf = 0;
1428 printf("Unknown parameter\n");
1431 rss_conf.rss_key = NULL;
1432 for (i = 0; i < rte_eth_dev_count(); i++)
1433 rte_eth_dev_rss_hash_update(i, &rss_conf);
1436 cmdline_parse_token_string_t cmd_config_rss_port =
1437 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1438 cmdline_parse_token_string_t cmd_config_rss_keyword =
1439 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1440 cmdline_parse_token_string_t cmd_config_rss_all =
1441 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1442 cmdline_parse_token_string_t cmd_config_rss_name =
1443 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1444 cmdline_parse_token_string_t cmd_config_rss_value =
1445 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1446 "all#ip#tcp#udp#sctp#ether#none");
1448 cmdline_parse_inst_t cmd_config_rss = {
1449 .f = cmd_config_rss_parsed,
1451 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1453 (void *)&cmd_config_rss_port,
1454 (void *)&cmd_config_rss_keyword,
1455 (void *)&cmd_config_rss_all,
1456 (void *)&cmd_config_rss_name,
1457 (void *)&cmd_config_rss_value,
1462 /* *** configure rss hash key *** */
1463 struct cmd_config_rss_hash_key {
1464 cmdline_fixed_string_t port;
1465 cmdline_fixed_string_t config;
1467 cmdline_fixed_string_t rss_hash_key;
1468 cmdline_fixed_string_t key;
1471 #define RSS_HASH_KEY_LENGTH 40
1473 hexa_digit_to_value(char hexa_digit)
1475 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1476 return (uint8_t) (hexa_digit - '0');
1477 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1478 return (uint8_t) ((hexa_digit - 'a') + 10);
1479 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1480 return (uint8_t) ((hexa_digit - 'A') + 10);
1481 /* Invalid hexa digit */
1486 parse_and_check_key_hexa_digit(char *key, int idx)
1490 hexa_v = hexa_digit_to_value(key[idx]);
1492 printf("invalid key: character %c at position %d is not a "
1493 "valid hexa digit\n", key[idx], idx);
1498 cmd_config_rss_hash_key_parsed(void *parsed_result,
1499 __attribute__((unused)) struct cmdline *cl,
1500 __attribute__((unused)) void *data)
1502 struct cmd_config_rss_hash_key *res = parsed_result;
1503 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1508 /* Check the length of the RSS hash key */
1509 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1510 printf("key length: %d invalid - key must be a string of %d"
1511 "hexa-decimal numbers\n", (int) strlen(res->key),
1512 RSS_HASH_KEY_LENGTH * 2);
1515 /* Translate RSS hash key into binary representation */
1516 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1517 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1520 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1523 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1525 port_rss_hash_key_update(res->port_id, hash_key);
1528 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1529 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1530 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1531 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1533 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1534 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1535 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1536 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1537 rss_hash_key, "rss-hash-key");
1538 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1539 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1541 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1542 .f = cmd_config_rss_hash_key_parsed,
1544 .help_str = "port config X rss-hash-key 80 hexa digits",
1546 (void *)&cmd_config_rss_hash_key_port,
1547 (void *)&cmd_config_rss_hash_key_config,
1548 (void *)&cmd_config_rss_hash_key_port_id,
1549 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1550 (void *)&cmd_config_rss_hash_key_value,
1555 /* *** configure port rxq/txq start/stop *** */
1556 struct cmd_config_rxtx_queue {
1557 cmdline_fixed_string_t port;
1559 cmdline_fixed_string_t rxtxq;
1561 cmdline_fixed_string_t opname;
1565 cmd_config_rxtx_queue_parsed(void *parsed_result,
1566 __attribute__((unused)) struct cmdline *cl,
1567 __attribute__((unused)) void *data)
1569 struct cmd_config_rxtx_queue *res = parsed_result;
1574 if (test_done == 0) {
1575 printf("Please stop forwarding first\n");
1579 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1582 if (port_is_started(res->portid) != 1) {
1583 printf("Please start port %u first\n", res->portid);
1587 if (!strcmp(res->rxtxq, "rxq"))
1589 else if (!strcmp(res->rxtxq, "txq"))
1592 printf("Unknown parameter\n");
1596 if (isrx && rx_queue_id_is_invalid(res->qid))
1598 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1601 if (!strcmp(res->opname, "start"))
1603 else if (!strcmp(res->opname, "stop"))
1606 printf("Unknown parameter\n");
1610 if (isstart && isrx)
1611 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1612 else if (!isstart && isrx)
1613 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1614 else if (isstart && !isrx)
1615 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1617 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1619 if (ret == -ENOTSUP)
1620 printf("Function not supported in PMD driver\n");
1623 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1624 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1625 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1626 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1627 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1629 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1630 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1631 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1632 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1635 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1636 .f = cmd_config_rxtx_queue_parsed,
1638 .help_str = "port X rxq|txq ID start|stop",
1640 (void *)&cmd_config_speed_all_port,
1641 (void *)&cmd_config_rxtx_queue_portid,
1642 (void *)&cmd_config_rxtx_queue_rxtxq,
1643 (void *)&cmd_config_rxtx_queue_qid,
1644 (void *)&cmd_config_rxtx_queue_opname,
1649 /* *** Configure RSS RETA *** */
1650 struct cmd_config_rss_reta {
1651 cmdline_fixed_string_t port;
1652 cmdline_fixed_string_t keyword;
1654 cmdline_fixed_string_t name;
1655 cmdline_fixed_string_t list_name;
1656 cmdline_fixed_string_t list_of_items;
1660 parse_reta_config(const char *str,
1661 struct rte_eth_rss_reta_entry64 *reta_conf,
1662 uint16_t nb_entries)
1666 uint16_t hash_index, idx, shift;
1669 const char *p, *p0 = str;
1676 unsigned long int_fld[_NUM_FLD];
1677 char *str_fld[_NUM_FLD];
1679 while ((p = strchr(p0,'(')) != NULL) {
1681 if((p0 = strchr(p,')')) == NULL)
1685 if(size >= sizeof(s))
1688 snprintf(s, sizeof(s), "%.*s", size, p);
1689 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1691 for (i = 0; i < _NUM_FLD; i++) {
1693 int_fld[i] = strtoul(str_fld[i], &end, 0);
1694 if (errno != 0 || end == str_fld[i] ||
1699 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1700 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1702 if (hash_index >= nb_entries) {
1703 printf("Invalid RETA hash index=%d\n", hash_index);
1707 idx = hash_index / RTE_RETA_GROUP_SIZE;
1708 shift = hash_index % RTE_RETA_GROUP_SIZE;
1709 reta_conf[idx].mask |= (1ULL << shift);
1710 reta_conf[idx].reta[shift] = nb_queue;
1717 cmd_set_rss_reta_parsed(void *parsed_result,
1718 __attribute__((unused)) struct cmdline *cl,
1719 __attribute__((unused)) void *data)
1722 struct rte_eth_dev_info dev_info;
1723 struct rte_eth_rss_reta_entry64 reta_conf[8];
1724 struct cmd_config_rss_reta *res = parsed_result;
1726 memset(&dev_info, 0, sizeof(dev_info));
1727 rte_eth_dev_info_get(res->port_id, &dev_info);
1728 if (dev_info.reta_size == 0) {
1729 printf("Redirection table size is 0 which is "
1730 "invalid for RSS\n");
1733 printf("The reta size of port %d is %u\n",
1734 res->port_id, dev_info.reta_size);
1735 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1736 printf("Currently do not support more than %u entries of "
1737 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1741 memset(reta_conf, 0, sizeof(reta_conf));
1742 if (!strcmp(res->list_name, "reta")) {
1743 if (parse_reta_config(res->list_of_items, reta_conf,
1744 dev_info.reta_size)) {
1745 printf("Invalid RSS Redirection Table "
1746 "config entered\n");
1749 ret = rte_eth_dev_rss_reta_update(res->port_id,
1750 reta_conf, dev_info.reta_size);
1752 printf("Bad redirection table parameter, "
1753 "return code = %d \n", ret);
1757 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1759 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1761 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1762 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1763 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1765 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1767 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1768 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1770 cmdline_parse_inst_t cmd_config_rss_reta = {
1771 .f = cmd_set_rss_reta_parsed,
1773 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1775 (void *)&cmd_config_rss_reta_port,
1776 (void *)&cmd_config_rss_reta_keyword,
1777 (void *)&cmd_config_rss_reta_port_id,
1778 (void *)&cmd_config_rss_reta_name,
1779 (void *)&cmd_config_rss_reta_list_name,
1780 (void *)&cmd_config_rss_reta_list_of_items,
1785 /* *** SHOW PORT RETA INFO *** */
1786 struct cmd_showport_reta {
1787 cmdline_fixed_string_t show;
1788 cmdline_fixed_string_t port;
1790 cmdline_fixed_string_t rss;
1791 cmdline_fixed_string_t reta;
1793 cmdline_fixed_string_t list_of_items;
1797 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1798 uint16_t nb_entries,
1802 const char *p, *p0 = str;
1806 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1809 p = strchr(p0, '(');
1813 p0 = strchr(p, ')');
1817 if (size >= sizeof(s)) {
1818 printf("The string size exceeds the internal buffer size\n");
1821 snprintf(s, sizeof(s), "%.*s", size, p);
1822 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1823 if (ret <= 0 || ret != num) {
1824 printf("The bits of masks do not match the number of "
1825 "reta entries: %u\n", num);
1828 for (i = 0; i < ret; i++)
1829 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1835 cmd_showport_reta_parsed(void *parsed_result,
1836 __attribute__((unused)) struct cmdline *cl,
1837 __attribute__((unused)) void *data)
1839 struct cmd_showport_reta *res = parsed_result;
1840 struct rte_eth_rss_reta_entry64 reta_conf[8];
1841 struct rte_eth_dev_info dev_info;
1843 memset(&dev_info, 0, sizeof(dev_info));
1844 rte_eth_dev_info_get(res->port_id, &dev_info);
1845 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1846 res->size > ETH_RSS_RETA_SIZE_512) {
1847 printf("Invalid redirection table size: %u\n", res->size);
1851 memset(reta_conf, 0, sizeof(reta_conf));
1852 if (showport_parse_reta_config(reta_conf, res->size,
1853 res->list_of_items) < 0) {
1854 printf("Invalid string: %s for reta masks\n",
1855 res->list_of_items);
1858 port_rss_reta_info(res->port_id, reta_conf, res->size);
1861 cmdline_parse_token_string_t cmd_showport_reta_show =
1862 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1863 cmdline_parse_token_string_t cmd_showport_reta_port =
1864 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1865 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1866 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1867 cmdline_parse_token_string_t cmd_showport_reta_rss =
1868 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1869 cmdline_parse_token_string_t cmd_showport_reta_reta =
1870 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1871 cmdline_parse_token_num_t cmd_showport_reta_size =
1872 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1873 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1874 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1875 list_of_items, NULL);
1877 cmdline_parse_inst_t cmd_showport_reta = {
1878 .f = cmd_showport_reta_parsed,
1880 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1882 (void *)&cmd_showport_reta_show,
1883 (void *)&cmd_showport_reta_port,
1884 (void *)&cmd_showport_reta_port_id,
1885 (void *)&cmd_showport_reta_rss,
1886 (void *)&cmd_showport_reta_reta,
1887 (void *)&cmd_showport_reta_size,
1888 (void *)&cmd_showport_reta_list_of_items,
1893 /* *** Show RSS hash configuration *** */
1894 struct cmd_showport_rss_hash {
1895 cmdline_fixed_string_t show;
1896 cmdline_fixed_string_t port;
1898 cmdline_fixed_string_t rss_hash;
1899 cmdline_fixed_string_t key; /* optional argument */
1902 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1903 __attribute__((unused)) struct cmdline *cl,
1906 struct cmd_showport_rss_hash *res = parsed_result;
1908 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1911 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1912 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1913 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1914 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1915 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1916 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1917 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1918 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1920 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1921 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1923 cmdline_parse_inst_t cmd_showport_rss_hash = {
1924 .f = cmd_showport_rss_hash_parsed,
1926 .help_str = "show port X rss-hash (X = port number)\n",
1928 (void *)&cmd_showport_rss_hash_show,
1929 (void *)&cmd_showport_rss_hash_port,
1930 (void *)&cmd_showport_rss_hash_port_id,
1931 (void *)&cmd_showport_rss_hash_rss_hash,
1936 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1937 .f = cmd_showport_rss_hash_parsed,
1939 .help_str = "show port X rss-hash key (X = port number)\n",
1941 (void *)&cmd_showport_rss_hash_show,
1942 (void *)&cmd_showport_rss_hash_port,
1943 (void *)&cmd_showport_rss_hash_port_id,
1944 (void *)&cmd_showport_rss_hash_rss_hash,
1945 (void *)&cmd_showport_rss_hash_rss_key,
1950 /* *** Configure DCB *** */
1951 struct cmd_config_dcb {
1952 cmdline_fixed_string_t port;
1953 cmdline_fixed_string_t config;
1955 cmdline_fixed_string_t dcb;
1956 cmdline_fixed_string_t vt;
1957 cmdline_fixed_string_t vt_en;
1959 cmdline_fixed_string_t pfc;
1960 cmdline_fixed_string_t pfc_en;
1964 cmd_config_dcb_parsed(void *parsed_result,
1965 __attribute__((unused)) struct cmdline *cl,
1966 __attribute__((unused)) void *data)
1968 struct cmd_config_dcb *res = parsed_result;
1969 struct dcb_config dcb_conf;
1970 portid_t port_id = res->port_id;
1971 struct rte_port *port;
1973 port = &ports[port_id];
1974 /** Check if the port is not started **/
1975 if (port->port_status != RTE_PORT_STOPPED) {
1976 printf("Please stop port %d first\n",port_id);
1980 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1981 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1982 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1986 /* DCB in VT mode */
1987 if (!strncmp(res->vt_en, "on",2))
1988 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1990 dcb_conf.dcb_mode = DCB_ENABLED;
1992 if (!strncmp(res->pfc_en, "on",2)) {
1993 dcb_conf.pfc_en = 1;
1996 dcb_conf.pfc_en = 0;
1998 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1999 printf("Cannot initialize network ports\n");
2003 cmd_reconfig_device_queue(port_id, 1, 1);
2006 cmdline_parse_token_string_t cmd_config_dcb_port =
2007 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2008 cmdline_parse_token_string_t cmd_config_dcb_config =
2009 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2010 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2011 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2012 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2013 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2014 cmdline_parse_token_string_t cmd_config_dcb_vt =
2015 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2016 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2018 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2019 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2020 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2021 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2022 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2025 cmdline_parse_inst_t cmd_config_dcb = {
2026 .f = cmd_config_dcb_parsed,
2028 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2030 (void *)&cmd_config_dcb_port,
2031 (void *)&cmd_config_dcb_config,
2032 (void *)&cmd_config_dcb_port_id,
2033 (void *)&cmd_config_dcb_dcb,
2034 (void *)&cmd_config_dcb_vt,
2035 (void *)&cmd_config_dcb_vt_en,
2036 (void *)&cmd_config_dcb_num_tcs,
2037 (void *)&cmd_config_dcb_pfc,
2038 (void *)&cmd_config_dcb_pfc_en,
2043 /* *** configure number of packets per burst *** */
2044 struct cmd_config_burst {
2045 cmdline_fixed_string_t port;
2046 cmdline_fixed_string_t keyword;
2047 cmdline_fixed_string_t all;
2048 cmdline_fixed_string_t name;
2053 cmd_config_burst_parsed(void *parsed_result,
2054 __attribute__((unused)) struct cmdline *cl,
2055 __attribute__((unused)) void *data)
2057 struct cmd_config_burst *res = parsed_result;
2059 if (!all_ports_stopped()) {
2060 printf("Please stop all ports first\n");
2064 if (!strcmp(res->name, "burst")) {
2065 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2066 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2069 nb_pkt_per_burst = res->value;
2071 printf("Unknown parameter\n");
2077 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2080 cmdline_parse_token_string_t cmd_config_burst_port =
2081 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2082 cmdline_parse_token_string_t cmd_config_burst_keyword =
2083 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2084 cmdline_parse_token_string_t cmd_config_burst_all =
2085 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2086 cmdline_parse_token_string_t cmd_config_burst_name =
2087 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2088 cmdline_parse_token_num_t cmd_config_burst_value =
2089 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2091 cmdline_parse_inst_t cmd_config_burst = {
2092 .f = cmd_config_burst_parsed,
2094 .help_str = "port config all burst value",
2096 (void *)&cmd_config_burst_port,
2097 (void *)&cmd_config_burst_keyword,
2098 (void *)&cmd_config_burst_all,
2099 (void *)&cmd_config_burst_name,
2100 (void *)&cmd_config_burst_value,
2105 /* *** configure rx/tx queues *** */
2106 struct cmd_config_thresh {
2107 cmdline_fixed_string_t port;
2108 cmdline_fixed_string_t keyword;
2109 cmdline_fixed_string_t all;
2110 cmdline_fixed_string_t name;
2115 cmd_config_thresh_parsed(void *parsed_result,
2116 __attribute__((unused)) struct cmdline *cl,
2117 __attribute__((unused)) void *data)
2119 struct cmd_config_thresh *res = parsed_result;
2121 if (!all_ports_stopped()) {
2122 printf("Please stop all ports first\n");
2126 if (!strcmp(res->name, "txpt"))
2127 tx_pthresh = res->value;
2128 else if(!strcmp(res->name, "txht"))
2129 tx_hthresh = res->value;
2130 else if(!strcmp(res->name, "txwt"))
2131 tx_wthresh = res->value;
2132 else if(!strcmp(res->name, "rxpt"))
2133 rx_pthresh = res->value;
2134 else if(!strcmp(res->name, "rxht"))
2135 rx_hthresh = res->value;
2136 else if(!strcmp(res->name, "rxwt"))
2137 rx_wthresh = res->value;
2139 printf("Unknown parameter\n");
2145 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2148 cmdline_parse_token_string_t cmd_config_thresh_port =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2150 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2151 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2152 cmdline_parse_token_string_t cmd_config_thresh_all =
2153 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2154 cmdline_parse_token_string_t cmd_config_thresh_name =
2155 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2156 "txpt#txht#txwt#rxpt#rxht#rxwt");
2157 cmdline_parse_token_num_t cmd_config_thresh_value =
2158 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2160 cmdline_parse_inst_t cmd_config_thresh = {
2161 .f = cmd_config_thresh_parsed,
2163 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2165 (void *)&cmd_config_thresh_port,
2166 (void *)&cmd_config_thresh_keyword,
2167 (void *)&cmd_config_thresh_all,
2168 (void *)&cmd_config_thresh_name,
2169 (void *)&cmd_config_thresh_value,
2174 /* *** configure free/rs threshold *** */
2175 struct cmd_config_threshold {
2176 cmdline_fixed_string_t port;
2177 cmdline_fixed_string_t keyword;
2178 cmdline_fixed_string_t all;
2179 cmdline_fixed_string_t name;
2184 cmd_config_threshold_parsed(void *parsed_result,
2185 __attribute__((unused)) struct cmdline *cl,
2186 __attribute__((unused)) void *data)
2188 struct cmd_config_threshold *res = parsed_result;
2190 if (!all_ports_stopped()) {
2191 printf("Please stop all ports first\n");
2195 if (!strcmp(res->name, "txfreet"))
2196 tx_free_thresh = res->value;
2197 else if (!strcmp(res->name, "txrst"))
2198 tx_rs_thresh = res->value;
2199 else if (!strcmp(res->name, "rxfreet"))
2200 rx_free_thresh = res->value;
2202 printf("Unknown parameter\n");
2208 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2211 cmdline_parse_token_string_t cmd_config_threshold_port =
2212 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2213 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2214 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2216 cmdline_parse_token_string_t cmd_config_threshold_all =
2217 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2218 cmdline_parse_token_string_t cmd_config_threshold_name =
2219 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2220 "txfreet#txrst#rxfreet");
2221 cmdline_parse_token_num_t cmd_config_threshold_value =
2222 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2224 cmdline_parse_inst_t cmd_config_threshold = {
2225 .f = cmd_config_threshold_parsed,
2227 .help_str = "port config all txfreet|txrst|rxfreet value",
2229 (void *)&cmd_config_threshold_port,
2230 (void *)&cmd_config_threshold_keyword,
2231 (void *)&cmd_config_threshold_all,
2232 (void *)&cmd_config_threshold_name,
2233 (void *)&cmd_config_threshold_value,
2239 struct cmd_stop_result {
2240 cmdline_fixed_string_t stop;
2243 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2244 __attribute__((unused)) struct cmdline *cl,
2245 __attribute__((unused)) void *data)
2247 stop_packet_forwarding();
2250 cmdline_parse_token_string_t cmd_stop_stop =
2251 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2253 cmdline_parse_inst_t cmd_stop = {
2254 .f = cmd_stop_parsed,
2256 .help_str = "stop - stop packet forwarding",
2258 (void *)&cmd_stop_stop,
2263 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2266 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2267 unsigned int *parsed_items, int check_unique_values)
2269 unsigned int nb_item;
2277 * First parse all items in the list and store their value.
2282 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2284 if ((c >= '0') && (c <= '9')) {
2285 value = (unsigned int) (value * 10 + (c - '0'));
2290 printf("character %c is not a decimal digit\n", c);
2294 printf("No valid value before comma\n");
2297 if (nb_item < max_items) {
2298 parsed_items[nb_item] = value;
2304 if (nb_item >= max_items) {
2305 printf("Number of %s = %u > %u (maximum items)\n",
2306 item_name, nb_item + 1, max_items);
2309 parsed_items[nb_item++] = value;
2310 if (! check_unique_values)
2314 * Then, check that all values in the list are differents.
2315 * No optimization here...
2317 for (i = 0; i < nb_item; i++) {
2318 for (j = i + 1; j < nb_item; j++) {
2319 if (parsed_items[j] == parsed_items[i]) {
2320 printf("duplicated %s %u at index %u and %u\n",
2321 item_name, parsed_items[i], i, j);
2329 struct cmd_set_list_result {
2330 cmdline_fixed_string_t cmd_keyword;
2331 cmdline_fixed_string_t list_name;
2332 cmdline_fixed_string_t list_of_items;
2335 static void cmd_set_list_parsed(void *parsed_result,
2336 __attribute__((unused)) struct cmdline *cl,
2337 __attribute__((unused)) void *data)
2339 struct cmd_set_list_result *res;
2341 unsigned int lcorelist[RTE_MAX_LCORE];
2342 unsigned int portlist[RTE_MAX_ETHPORTS];
2344 unsigned int nb_item;
2346 if (test_done == 0) {
2347 printf("Please stop forwarding first\n");
2351 res = parsed_result;
2352 if (!strcmp(res->list_name, "corelist")) {
2353 nb_item = parse_item_list(res->list_of_items, "core",
2355 parsed_items.lcorelist, 1);
2357 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2360 if (!strcmp(res->list_name, "portlist")) {
2361 nb_item = parse_item_list(res->list_of_items, "port",
2363 parsed_items.portlist, 1);
2365 set_fwd_ports_list(parsed_items.portlist, nb_item);
2369 cmdline_parse_token_string_t cmd_set_list_keyword =
2370 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2372 cmdline_parse_token_string_t cmd_set_list_name =
2373 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2374 "corelist#portlist");
2375 cmdline_parse_token_string_t cmd_set_list_of_items =
2376 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2379 cmdline_parse_inst_t cmd_set_fwd_list = {
2380 .f = cmd_set_list_parsed,
2382 .help_str = "set corelist|portlist x[,y]*",
2384 (void *)&cmd_set_list_keyword,
2385 (void *)&cmd_set_list_name,
2386 (void *)&cmd_set_list_of_items,
2391 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2393 struct cmd_setmask_result {
2394 cmdline_fixed_string_t set;
2395 cmdline_fixed_string_t mask;
2399 static void cmd_set_mask_parsed(void *parsed_result,
2400 __attribute__((unused)) struct cmdline *cl,
2401 __attribute__((unused)) void *data)
2403 struct cmd_setmask_result *res = parsed_result;
2405 if (test_done == 0) {
2406 printf("Please stop forwarding first\n");
2409 if (!strcmp(res->mask, "coremask"))
2410 set_fwd_lcores_mask(res->hexavalue);
2411 else if (!strcmp(res->mask, "portmask"))
2412 set_fwd_ports_mask(res->hexavalue);
2415 cmdline_parse_token_string_t cmd_setmask_set =
2416 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2417 cmdline_parse_token_string_t cmd_setmask_mask =
2418 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2419 "coremask#portmask");
2420 cmdline_parse_token_num_t cmd_setmask_value =
2421 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2423 cmdline_parse_inst_t cmd_set_fwd_mask = {
2424 .f = cmd_set_mask_parsed,
2426 .help_str = "set coremask|portmask hexadecimal value",
2428 (void *)&cmd_setmask_set,
2429 (void *)&cmd_setmask_mask,
2430 (void *)&cmd_setmask_value,
2436 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2438 struct cmd_set_result {
2439 cmdline_fixed_string_t set;
2440 cmdline_fixed_string_t what;
2444 static void cmd_set_parsed(void *parsed_result,
2445 __attribute__((unused)) struct cmdline *cl,
2446 __attribute__((unused)) void *data)
2448 struct cmd_set_result *res = parsed_result;
2449 if (!strcmp(res->what, "nbport"))
2450 set_fwd_ports_number(res->value);
2451 else if (!strcmp(res->what, "nbcore"))
2452 set_fwd_lcores_number(res->value);
2453 else if (!strcmp(res->what, "burst"))
2454 set_nb_pkt_per_burst(res->value);
2455 else if (!strcmp(res->what, "verbose"))
2456 set_verbose_level(res->value);
2459 cmdline_parse_token_string_t cmd_set_set =
2460 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2461 cmdline_parse_token_string_t cmd_set_what =
2462 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2463 "nbport#nbcore#burst#verbose");
2464 cmdline_parse_token_num_t cmd_set_value =
2465 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2467 cmdline_parse_inst_t cmd_set_numbers = {
2468 .f = cmd_set_parsed,
2470 .help_str = "set nbport|nbcore|burst|verbose value",
2472 (void *)&cmd_set_set,
2473 (void *)&cmd_set_what,
2474 (void *)&cmd_set_value,
2479 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2481 struct cmd_set_txpkts_result {
2482 cmdline_fixed_string_t cmd_keyword;
2483 cmdline_fixed_string_t txpkts;
2484 cmdline_fixed_string_t seg_lengths;
2488 cmd_set_txpkts_parsed(void *parsed_result,
2489 __attribute__((unused)) struct cmdline *cl,
2490 __attribute__((unused)) void *data)
2492 struct cmd_set_txpkts_result *res;
2493 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2494 unsigned int nb_segs;
2496 res = parsed_result;
2497 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2498 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2500 set_tx_pkt_segments(seg_lengths, nb_segs);
2503 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2504 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2505 cmd_keyword, "set");
2506 cmdline_parse_token_string_t cmd_set_txpkts_name =
2507 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2509 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2510 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2513 cmdline_parse_inst_t cmd_set_txpkts = {
2514 .f = cmd_set_txpkts_parsed,
2516 .help_str = "set txpkts x[,y]*",
2518 (void *)&cmd_set_txpkts_keyword,
2519 (void *)&cmd_set_txpkts_name,
2520 (void *)&cmd_set_txpkts_lengths,
2525 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2526 struct cmd_rx_vlan_filter_all_result {
2527 cmdline_fixed_string_t rx_vlan;
2528 cmdline_fixed_string_t what;
2529 cmdline_fixed_string_t all;
2534 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2535 __attribute__((unused)) struct cmdline *cl,
2536 __attribute__((unused)) void *data)
2538 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2540 if (!strcmp(res->what, "add"))
2541 rx_vlan_all_filter_set(res->port_id, 1);
2543 rx_vlan_all_filter_set(res->port_id, 0);
2546 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2547 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2548 rx_vlan, "rx_vlan");
2549 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2550 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2552 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2553 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2555 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2556 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2559 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2560 .f = cmd_rx_vlan_filter_all_parsed,
2562 .help_str = "add/remove all identifiers to/from the set of VLAN "
2563 "Identifiers filtered by a port",
2565 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2566 (void *)&cmd_rx_vlan_filter_all_what,
2567 (void *)&cmd_rx_vlan_filter_all_all,
2568 (void *)&cmd_rx_vlan_filter_all_portid,
2573 /* *** VLAN OFFLOAD SET ON A PORT *** */
2574 struct cmd_vlan_offload_result {
2575 cmdline_fixed_string_t vlan;
2576 cmdline_fixed_string_t set;
2577 cmdline_fixed_string_t what;
2578 cmdline_fixed_string_t on;
2579 cmdline_fixed_string_t port_id;
2583 cmd_vlan_offload_parsed(void *parsed_result,
2584 __attribute__((unused)) struct cmdline *cl,
2585 __attribute__((unused)) void *data)
2588 struct cmd_vlan_offload_result *res = parsed_result;
2591 portid_t port_id = 0;
2595 len = strnlen(str, STR_TOKEN_SIZE);
2597 /* Get port_id first */
2605 tmp = strtoul(str, NULL, 0);
2606 /* If port_id greater that what portid_t can represent, return */
2607 if(tmp >= RTE_MAX_ETHPORTS)
2609 port_id = (portid_t)tmp;
2611 if (!strcmp(res->on, "on"))
2616 if (!strcmp(res->what, "strip"))
2617 rx_vlan_strip_set(port_id, on);
2618 else if(!strcmp(res->what, "stripq")){
2619 uint16_t queue_id = 0;
2621 /* No queue_id, return */
2623 printf("must specify (port,queue_id)\n");
2626 tmp = strtoul(str + i + 1, NULL, 0);
2627 /* If queue_id greater that what 16-bits can represent, return */
2631 queue_id = (uint16_t)tmp;
2632 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2634 else if (!strcmp(res->what, "filter"))
2635 rx_vlan_filter_set(port_id, on);
2637 vlan_extend_set(port_id, on);
2642 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2643 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2645 cmdline_parse_token_string_t cmd_vlan_offload_set =
2646 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2648 cmdline_parse_token_string_t cmd_vlan_offload_what =
2649 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2650 what, "strip#filter#qinq#stripq");
2651 cmdline_parse_token_string_t cmd_vlan_offload_on =
2652 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2654 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2655 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2658 cmdline_parse_inst_t cmd_vlan_offload = {
2659 .f = cmd_vlan_offload_parsed,
2661 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2662 " qinq(extended) for both rx/tx sides ",
2664 (void *)&cmd_vlan_offload_vlan,
2665 (void *)&cmd_vlan_offload_set,
2666 (void *)&cmd_vlan_offload_what,
2667 (void *)&cmd_vlan_offload_on,
2668 (void *)&cmd_vlan_offload_portid,
2673 /* *** VLAN TPID SET ON A PORT *** */
2674 struct cmd_vlan_tpid_result {
2675 cmdline_fixed_string_t vlan;
2676 cmdline_fixed_string_t set;
2677 cmdline_fixed_string_t what;
2683 cmd_vlan_tpid_parsed(void *parsed_result,
2684 __attribute__((unused)) struct cmdline *cl,
2685 __attribute__((unused)) void *data)
2687 struct cmd_vlan_tpid_result *res = parsed_result;
2688 vlan_tpid_set(res->port_id, res->tp_id);
2692 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2693 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2695 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2696 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2698 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2699 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2701 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2702 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2704 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2705 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2708 cmdline_parse_inst_t cmd_vlan_tpid = {
2709 .f = cmd_vlan_tpid_parsed,
2711 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2713 (void *)&cmd_vlan_tpid_vlan,
2714 (void *)&cmd_vlan_tpid_set,
2715 (void *)&cmd_vlan_tpid_what,
2716 (void *)&cmd_vlan_tpid_tpid,
2717 (void *)&cmd_vlan_tpid_portid,
2722 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2723 struct cmd_rx_vlan_filter_result {
2724 cmdline_fixed_string_t rx_vlan;
2725 cmdline_fixed_string_t what;
2731 cmd_rx_vlan_filter_parsed(void *parsed_result,
2732 __attribute__((unused)) struct cmdline *cl,
2733 __attribute__((unused)) void *data)
2735 struct cmd_rx_vlan_filter_result *res = parsed_result;
2737 if (!strcmp(res->what, "add"))
2738 rx_vft_set(res->port_id, res->vlan_id, 1);
2740 rx_vft_set(res->port_id, res->vlan_id, 0);
2743 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2744 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2745 rx_vlan, "rx_vlan");
2746 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2747 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2749 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2750 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2752 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2753 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2756 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2757 .f = cmd_rx_vlan_filter_parsed,
2759 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2760 "Identifiers filtered by a port",
2762 (void *)&cmd_rx_vlan_filter_rx_vlan,
2763 (void *)&cmd_rx_vlan_filter_what,
2764 (void *)&cmd_rx_vlan_filter_vlanid,
2765 (void *)&cmd_rx_vlan_filter_portid,
2770 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2771 struct cmd_tx_vlan_set_result {
2772 cmdline_fixed_string_t tx_vlan;
2773 cmdline_fixed_string_t set;
2779 cmd_tx_vlan_set_parsed(void *parsed_result,
2780 __attribute__((unused)) struct cmdline *cl,
2781 __attribute__((unused)) void *data)
2783 struct cmd_tx_vlan_set_result *res = parsed_result;
2784 tx_vlan_set(res->port_id, res->vlan_id);
2787 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2788 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2789 tx_vlan, "tx_vlan");
2790 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2791 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2793 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2794 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2796 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2797 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2800 cmdline_parse_inst_t cmd_tx_vlan_set = {
2801 .f = cmd_tx_vlan_set_parsed,
2803 .help_str = "enable hardware insertion of a VLAN header with a given "
2804 "TAG Identifier in packets sent on a port",
2806 (void *)&cmd_tx_vlan_set_tx_vlan,
2807 (void *)&cmd_tx_vlan_set_set,
2808 (void *)&cmd_tx_vlan_set_vlanid,
2809 (void *)&cmd_tx_vlan_set_portid,
2814 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2815 struct cmd_tx_vlan_set_pvid_result {
2816 cmdline_fixed_string_t tx_vlan;
2817 cmdline_fixed_string_t set;
2818 cmdline_fixed_string_t pvid;
2821 cmdline_fixed_string_t mode;
2825 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2826 __attribute__((unused)) struct cmdline *cl,
2827 __attribute__((unused)) void *data)
2829 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2831 if (strcmp(res->mode, "on") == 0)
2832 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2834 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2837 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2838 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2839 tx_vlan, "tx_vlan");
2840 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2841 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2843 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2844 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2846 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2847 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2849 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2850 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2852 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2853 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2856 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2857 .f = cmd_tx_vlan_set_pvid_parsed,
2859 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2861 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2862 (void *)&cmd_tx_vlan_set_pvid_set,
2863 (void *)&cmd_tx_vlan_set_pvid_pvid,
2864 (void *)&cmd_tx_vlan_set_pvid_port_id,
2865 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2866 (void *)&cmd_tx_vlan_set_pvid_mode,
2871 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2872 struct cmd_tx_vlan_reset_result {
2873 cmdline_fixed_string_t tx_vlan;
2874 cmdline_fixed_string_t reset;
2879 cmd_tx_vlan_reset_parsed(void *parsed_result,
2880 __attribute__((unused)) struct cmdline *cl,
2881 __attribute__((unused)) void *data)
2883 struct cmd_tx_vlan_reset_result *res = parsed_result;
2885 tx_vlan_reset(res->port_id);
2888 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2889 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2890 tx_vlan, "tx_vlan");
2891 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2892 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2894 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2895 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2898 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2899 .f = cmd_tx_vlan_reset_parsed,
2901 .help_str = "disable hardware insertion of a VLAN header in packets "
2904 (void *)&cmd_tx_vlan_reset_tx_vlan,
2905 (void *)&cmd_tx_vlan_reset_reset,
2906 (void *)&cmd_tx_vlan_reset_portid,
2912 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2913 struct cmd_csum_result {
2914 cmdline_fixed_string_t csum;
2915 cmdline_fixed_string_t mode;
2916 cmdline_fixed_string_t proto;
2917 cmdline_fixed_string_t hwsw;
2922 csum_show(int port_id)
2924 struct rte_eth_dev_info dev_info;
2927 ol_flags = ports[port_id].tx_ol_flags;
2928 printf("Parse tunnel is %s\n",
2929 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
2930 printf("IP checksum offload is %s\n",
2931 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2932 printf("UDP checksum offload is %s\n",
2933 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2934 printf("TCP checksum offload is %s\n",
2935 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2936 printf("SCTP checksum offload is %s\n",
2937 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2938 printf("Outer-Ip checksum offload is %s\n",
2939 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
2941 /* display warnings if configuration is not supported by the NIC */
2942 rte_eth_dev_info_get(port_id, &dev_info);
2943 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2944 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2945 printf("Warning: hardware IP checksum enabled but not "
2946 "supported by port %d\n", port_id);
2948 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2949 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2950 printf("Warning: hardware UDP checksum enabled but not "
2951 "supported by port %d\n", port_id);
2953 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2954 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2955 printf("Warning: hardware TCP checksum enabled but not "
2956 "supported by port %d\n", port_id);
2958 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2959 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2960 printf("Warning: hardware SCTP checksum enabled but not "
2961 "supported by port %d\n", port_id);
2963 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
2964 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
2965 printf("Warning: hardware outer IP checksum enabled but not "
2966 "supported by port %d\n", port_id);
2971 cmd_csum_parsed(void *parsed_result,
2972 __attribute__((unused)) struct cmdline *cl,
2973 __attribute__((unused)) void *data)
2975 struct cmd_csum_result *res = parsed_result;
2979 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
2980 printf("invalid port %d\n", res->port_id);
2984 if (!strcmp(res->mode, "set")) {
2986 if (!strcmp(res->hwsw, "hw"))
2989 if (!strcmp(res->proto, "ip")) {
2990 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2991 } else if (!strcmp(res->proto, "udp")) {
2992 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2993 } else if (!strcmp(res->proto, "tcp")) {
2994 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2995 } else if (!strcmp(res->proto, "sctp")) {
2996 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2997 } else if (!strcmp(res->proto, "outer-ip")) {
2998 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3002 ports[res->port_id].tx_ol_flags |= mask;
3004 ports[res->port_id].tx_ol_flags &= (~mask);
3006 csum_show(res->port_id);
3009 cmdline_parse_token_string_t cmd_csum_csum =
3010 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3012 cmdline_parse_token_string_t cmd_csum_mode =
3013 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3015 cmdline_parse_token_string_t cmd_csum_proto =
3016 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3017 proto, "ip#tcp#udp#sctp#outer-ip");
3018 cmdline_parse_token_string_t cmd_csum_hwsw =
3019 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3021 cmdline_parse_token_num_t cmd_csum_portid =
3022 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3025 cmdline_parse_inst_t cmd_csum_set = {
3026 .f = cmd_csum_parsed,
3028 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3029 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3031 (void *)&cmd_csum_csum,
3032 (void *)&cmd_csum_mode,
3033 (void *)&cmd_csum_proto,
3034 (void *)&cmd_csum_hwsw,
3035 (void *)&cmd_csum_portid,
3040 cmdline_parse_token_string_t cmd_csum_mode_show =
3041 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3044 cmdline_parse_inst_t cmd_csum_show = {
3045 .f = cmd_csum_parsed,
3047 .help_str = "show checksum offload configuration: csum show <port>",
3049 (void *)&cmd_csum_csum,
3050 (void *)&cmd_csum_mode_show,
3051 (void *)&cmd_csum_portid,
3056 /* Enable/disable tunnel parsing */
3057 struct cmd_csum_tunnel_result {
3058 cmdline_fixed_string_t csum;
3059 cmdline_fixed_string_t parse;
3060 cmdline_fixed_string_t onoff;
3065 cmd_csum_tunnel_parsed(void *parsed_result,
3066 __attribute__((unused)) struct cmdline *cl,
3067 __attribute__((unused)) void *data)
3069 struct cmd_csum_tunnel_result *res = parsed_result;
3071 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3074 if (!strcmp(res->onoff, "on"))
3075 ports[res->port_id].tx_ol_flags |=
3076 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3078 ports[res->port_id].tx_ol_flags &=
3079 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3081 csum_show(res->port_id);
3084 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3085 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3087 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3088 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3089 parse, "parse_tunnel");
3090 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3091 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3093 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3094 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3097 cmdline_parse_inst_t cmd_csum_tunnel = {
3098 .f = cmd_csum_tunnel_parsed,
3100 .help_str = "enable/disable parsing of tunnels for csum engine: "
3101 "csum parse_tunnel on|off <tx-port>",
3103 (void *)&cmd_csum_tunnel_csum,
3104 (void *)&cmd_csum_tunnel_parse,
3105 (void *)&cmd_csum_tunnel_onoff,
3106 (void *)&cmd_csum_tunnel_portid,
3111 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3112 struct cmd_tso_set_result {
3113 cmdline_fixed_string_t tso;
3114 cmdline_fixed_string_t mode;
3120 cmd_tso_set_parsed(void *parsed_result,
3121 __attribute__((unused)) struct cmdline *cl,
3122 __attribute__((unused)) void *data)
3124 struct cmd_tso_set_result *res = parsed_result;
3125 struct rte_eth_dev_info dev_info;
3127 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3130 if (!strcmp(res->mode, "set"))
3131 ports[res->port_id].tso_segsz = res->tso_segsz;
3133 if (ports[res->port_id].tso_segsz == 0)
3134 printf("TSO is disabled\n");
3136 printf("TSO segment size is %d\n",
3137 ports[res->port_id].tso_segsz);
3139 /* display warnings if configuration is not supported by the NIC */
3140 rte_eth_dev_info_get(res->port_id, &dev_info);
3141 if ((ports[res->port_id].tso_segsz != 0) &&
3142 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3143 printf("Warning: TSO enabled but not "
3144 "supported by port %d\n", res->port_id);
3148 cmdline_parse_token_string_t cmd_tso_set_tso =
3149 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3151 cmdline_parse_token_string_t cmd_tso_set_mode =
3152 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3154 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3155 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3157 cmdline_parse_token_num_t cmd_tso_set_portid =
3158 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3161 cmdline_parse_inst_t cmd_tso_set = {
3162 .f = cmd_tso_set_parsed,
3164 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3165 "tso set <tso_segsz> <port>",
3167 (void *)&cmd_tso_set_tso,
3168 (void *)&cmd_tso_set_mode,
3169 (void *)&cmd_tso_set_tso_segsz,
3170 (void *)&cmd_tso_set_portid,
3175 cmdline_parse_token_string_t cmd_tso_show_mode =
3176 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3180 cmdline_parse_inst_t cmd_tso_show = {
3181 .f = cmd_tso_set_parsed,
3183 .help_str = "Show TSO segment size for csum engine: "
3186 (void *)&cmd_tso_set_tso,
3187 (void *)&cmd_tso_show_mode,
3188 (void *)&cmd_tso_set_portid,
3193 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3194 struct cmd_set_flush_rx {
3195 cmdline_fixed_string_t set;
3196 cmdline_fixed_string_t flush_rx;
3197 cmdline_fixed_string_t mode;
3201 cmd_set_flush_rx_parsed(void *parsed_result,
3202 __attribute__((unused)) struct cmdline *cl,
3203 __attribute__((unused)) void *data)
3205 struct cmd_set_flush_rx *res = parsed_result;
3206 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3209 cmdline_parse_token_string_t cmd_setflushrx_set =
3210 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3212 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3213 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3214 flush_rx, "flush_rx");
3215 cmdline_parse_token_string_t cmd_setflushrx_mode =
3216 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3220 cmdline_parse_inst_t cmd_set_flush_rx = {
3221 .f = cmd_set_flush_rx_parsed,
3222 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3225 (void *)&cmd_setflushrx_set,
3226 (void *)&cmd_setflushrx_flush_rx,
3227 (void *)&cmd_setflushrx_mode,
3232 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3233 struct cmd_set_link_check {
3234 cmdline_fixed_string_t set;
3235 cmdline_fixed_string_t link_check;
3236 cmdline_fixed_string_t mode;
3240 cmd_set_link_check_parsed(void *parsed_result,
3241 __attribute__((unused)) struct cmdline *cl,
3242 __attribute__((unused)) void *data)
3244 struct cmd_set_link_check *res = parsed_result;
3245 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3248 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3249 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3251 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3252 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3253 link_check, "link_check");
3254 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3255 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3259 cmdline_parse_inst_t cmd_set_link_check = {
3260 .f = cmd_set_link_check_parsed,
3261 .help_str = "set link_check on|off: enable/disable link status check "
3262 "when starting/stopping a port",
3265 (void *)&cmd_setlinkcheck_set,
3266 (void *)&cmd_setlinkcheck_link_check,
3267 (void *)&cmd_setlinkcheck_mode,
3272 #ifdef RTE_NIC_BYPASS
3273 /* *** SET NIC BYPASS MODE *** */
3274 struct cmd_set_bypass_mode_result {
3275 cmdline_fixed_string_t set;
3276 cmdline_fixed_string_t bypass;
3277 cmdline_fixed_string_t mode;
3278 cmdline_fixed_string_t value;
3283 cmd_set_bypass_mode_parsed(void *parsed_result,
3284 __attribute__((unused)) struct cmdline *cl,
3285 __attribute__((unused)) void *data)
3287 struct cmd_set_bypass_mode_result *res = parsed_result;
3288 portid_t port_id = res->port_id;
3289 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3291 if (!bypass_is_supported(port_id))
3294 if (!strcmp(res->value, "bypass"))
3295 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3296 else if (!strcmp(res->value, "isolate"))
3297 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3299 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3301 /* Set the bypass mode for the relevant port. */
3302 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3303 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3307 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3308 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3310 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3311 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3313 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3314 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3316 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3317 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3318 value, "normal#bypass#isolate");
3319 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3320 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3323 cmdline_parse_inst_t cmd_set_bypass_mode = {
3324 .f = cmd_set_bypass_mode_parsed,
3325 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3326 "Set the NIC bypass mode for port_id",
3329 (void *)&cmd_setbypass_mode_set,
3330 (void *)&cmd_setbypass_mode_bypass,
3331 (void *)&cmd_setbypass_mode_mode,
3332 (void *)&cmd_setbypass_mode_value,
3333 (void *)&cmd_setbypass_mode_port,
3338 /* *** SET NIC BYPASS EVENT *** */
3339 struct cmd_set_bypass_event_result {
3340 cmdline_fixed_string_t set;
3341 cmdline_fixed_string_t bypass;
3342 cmdline_fixed_string_t event;
3343 cmdline_fixed_string_t event_value;
3344 cmdline_fixed_string_t mode;
3345 cmdline_fixed_string_t mode_value;
3350 cmd_set_bypass_event_parsed(void *parsed_result,
3351 __attribute__((unused)) struct cmdline *cl,
3352 __attribute__((unused)) void *data)
3355 struct cmd_set_bypass_event_result *res = parsed_result;
3356 portid_t port_id = res->port_id;
3357 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3358 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3360 if (!bypass_is_supported(port_id))
3363 if (!strcmp(res->event_value, "timeout"))
3364 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3365 else if (!strcmp(res->event_value, "os_on"))
3366 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3367 else if (!strcmp(res->event_value, "os_off"))
3368 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3369 else if (!strcmp(res->event_value, "power_on"))
3370 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3371 else if (!strcmp(res->event_value, "power_off"))
3372 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3374 bypass_event = RTE_BYPASS_EVENT_NONE;
3376 if (!strcmp(res->mode_value, "bypass"))
3377 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3378 else if (!strcmp(res->mode_value, "isolate"))
3379 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3381 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3383 /* Set the watchdog timeout. */
3384 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3387 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3388 (rc = rte_eth_dev_wd_timeout_store(port_id,
3389 bypass_timeout)) != 0) {
3390 printf("Failed to set timeout value %u "
3391 "for port %d, errto code: %d.\n",
3392 bypass_timeout, port_id, rc);
3396 /* Set the bypass event to transition to bypass mode. */
3397 if (0 != rte_eth_dev_bypass_event_store(port_id,
3398 bypass_event, bypass_mode)) {
3399 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3404 cmdline_parse_token_string_t cmd_setbypass_event_set =
3405 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3407 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3408 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3410 cmdline_parse_token_string_t cmd_setbypass_event_event =
3411 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3413 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3414 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3415 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3416 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3417 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3419 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3420 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3421 mode_value, "normal#bypass#isolate");
3422 cmdline_parse_token_num_t cmd_setbypass_event_port =
3423 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3426 cmdline_parse_inst_t cmd_set_bypass_event = {
3427 .f = cmd_set_bypass_event_parsed,
3428 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3429 "mode (normal|bypass|isolate) (port_id): "
3430 "Set the NIC bypass event mode for port_id",
3433 (void *)&cmd_setbypass_event_set,
3434 (void *)&cmd_setbypass_event_bypass,
3435 (void *)&cmd_setbypass_event_event,
3436 (void *)&cmd_setbypass_event_event_value,
3437 (void *)&cmd_setbypass_event_mode,
3438 (void *)&cmd_setbypass_event_mode_value,
3439 (void *)&cmd_setbypass_event_port,
3445 /* *** SET NIC BYPASS TIMEOUT *** */
3446 struct cmd_set_bypass_timeout_result {
3447 cmdline_fixed_string_t set;
3448 cmdline_fixed_string_t bypass;
3449 cmdline_fixed_string_t timeout;
3450 cmdline_fixed_string_t value;
3454 cmd_set_bypass_timeout_parsed(void *parsed_result,
3455 __attribute__((unused)) struct cmdline *cl,
3456 __attribute__((unused)) void *data)
3458 struct cmd_set_bypass_timeout_result *res = parsed_result;
3460 if (!strcmp(res->value, "1.5"))
3461 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3462 else if (!strcmp(res->value, "2"))
3463 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3464 else if (!strcmp(res->value, "3"))
3465 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3466 else if (!strcmp(res->value, "4"))
3467 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3468 else if (!strcmp(res->value, "8"))
3469 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3470 else if (!strcmp(res->value, "16"))
3471 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3472 else if (!strcmp(res->value, "32"))
3473 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3475 bypass_timeout = RTE_BYPASS_TMT_OFF;
3478 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3479 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3481 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3482 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3484 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3485 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3486 timeout, "timeout");
3487 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3488 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3489 value, "0#1.5#2#3#4#8#16#32");
3491 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3492 .f = cmd_set_bypass_timeout_parsed,
3493 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3494 "Set the NIC bypass watchdog timeout",
3497 (void *)&cmd_setbypass_timeout_set,
3498 (void *)&cmd_setbypass_timeout_bypass,
3499 (void *)&cmd_setbypass_timeout_timeout,
3500 (void *)&cmd_setbypass_timeout_value,
3505 /* *** SHOW NIC BYPASS MODE *** */
3506 struct cmd_show_bypass_config_result {
3507 cmdline_fixed_string_t show;
3508 cmdline_fixed_string_t bypass;
3509 cmdline_fixed_string_t config;
3514 cmd_show_bypass_config_parsed(void *parsed_result,
3515 __attribute__((unused)) struct cmdline *cl,
3516 __attribute__((unused)) void *data)
3518 struct cmd_show_bypass_config_result *res = parsed_result;
3519 uint32_t event_mode;
3520 uint32_t bypass_mode;
3521 portid_t port_id = res->port_id;
3522 uint32_t timeout = bypass_timeout;
3525 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3526 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3527 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3528 {"UNKNOWN", "normal", "bypass", "isolate"};
3529 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3536 int num_events = (sizeof events) / (sizeof events[0]);
3538 if (!bypass_is_supported(port_id))
3541 /* Display the bypass mode.*/
3542 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3543 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3547 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3548 bypass_mode = RTE_BYPASS_MODE_NONE;
3550 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3553 /* Display the bypass timeout.*/
3554 if (!RTE_BYPASS_TMT_VALID(timeout))
3555 timeout = RTE_BYPASS_TMT_OFF;
3557 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3559 /* Display the bypass events and associated modes. */
3560 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3562 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3563 printf("\tFailed to get bypass mode for event = %s\n",
3566 if (!RTE_BYPASS_MODE_VALID(event_mode))
3567 event_mode = RTE_BYPASS_MODE_NONE;
3569 printf("\tbypass event: %-16s = %s\n", events[i],
3575 cmdline_parse_token_string_t cmd_showbypass_config_show =
3576 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3578 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3579 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3581 cmdline_parse_token_string_t cmd_showbypass_config_config =
3582 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3584 cmdline_parse_token_num_t cmd_showbypass_config_port =
3585 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3588 cmdline_parse_inst_t cmd_show_bypass_config = {
3589 .f = cmd_show_bypass_config_parsed,
3590 .help_str = "show bypass config (port_id): "
3591 "Show the NIC bypass config for port_id",
3594 (void *)&cmd_showbypass_config_show,
3595 (void *)&cmd_showbypass_config_bypass,
3596 (void *)&cmd_showbypass_config_config,
3597 (void *)&cmd_showbypass_config_port,
3603 #ifdef RTE_LIBRTE_PMD_BOND
3604 /* *** SET BONDING MODE *** */
3605 struct cmd_set_bonding_mode_result {
3606 cmdline_fixed_string_t set;
3607 cmdline_fixed_string_t bonding;
3608 cmdline_fixed_string_t mode;
3613 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3614 __attribute__((unused)) struct cmdline *cl,
3615 __attribute__((unused)) void *data)
3617 struct cmd_set_bonding_mode_result *res = parsed_result;
3618 portid_t port_id = res->port_id;
3620 /* Set the bonding mode for the relevant port. */
3621 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3622 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3625 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3626 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3628 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3629 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3630 bonding, "bonding");
3631 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3632 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3634 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3635 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3637 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3638 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3641 cmdline_parse_inst_t cmd_set_bonding_mode = {
3642 .f = cmd_set_bonding_mode_parsed,
3643 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3646 (void *) &cmd_setbonding_mode_set,
3647 (void *) &cmd_setbonding_mode_bonding,
3648 (void *) &cmd_setbonding_mode_mode,
3649 (void *) &cmd_setbonding_mode_value,
3650 (void *) &cmd_setbonding_mode_port,
3655 /* *** SET BALANCE XMIT POLICY *** */
3656 struct cmd_set_bonding_balance_xmit_policy_result {
3657 cmdline_fixed_string_t set;
3658 cmdline_fixed_string_t bonding;
3659 cmdline_fixed_string_t balance_xmit_policy;
3661 cmdline_fixed_string_t policy;
3664 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3665 __attribute__((unused)) struct cmdline *cl,
3666 __attribute__((unused)) void *data)
3668 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3669 portid_t port_id = res->port_id;
3672 if (!strcmp(res->policy, "l2")) {
3673 policy = BALANCE_XMIT_POLICY_LAYER2;
3674 } else if (!strcmp(res->policy, "l23")) {
3675 policy = BALANCE_XMIT_POLICY_LAYER23;
3676 } else if (!strcmp(res->policy, "l34")) {
3677 policy = BALANCE_XMIT_POLICY_LAYER34;
3679 printf("\t Invalid xmit policy selection");
3683 /* Set the bonding mode for the relevant port. */
3684 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3685 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3690 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3691 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3693 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3694 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3695 bonding, "bonding");
3696 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3697 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3698 balance_xmit_policy, "balance_xmit_policy");
3699 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3700 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3702 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3703 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3704 policy, "l2#l23#l34");
3706 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3707 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3708 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3711 (void *)&cmd_setbonding_balance_xmit_policy_set,
3712 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3713 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3714 (void *)&cmd_setbonding_balance_xmit_policy_port,
3715 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3720 /* *** SHOW NIC BONDING CONFIGURATION *** */
3721 struct cmd_show_bonding_config_result {
3722 cmdline_fixed_string_t show;
3723 cmdline_fixed_string_t bonding;
3724 cmdline_fixed_string_t config;
3728 static void cmd_show_bonding_config_parsed(void *parsed_result,
3729 __attribute__((unused)) struct cmdline *cl,
3730 __attribute__((unused)) void *data)
3732 struct cmd_show_bonding_config_result *res = parsed_result;
3734 uint8_t slaves[RTE_MAX_ETHPORTS];
3735 int num_slaves, num_active_slaves;
3738 portid_t port_id = res->port_id;
3740 /* Display the bonding mode.*/
3741 bonding_mode = rte_eth_bond_mode_get(port_id);
3742 if (bonding_mode < 0) {
3743 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3746 printf("\tBonding mode: %d\n", bonding_mode);
3748 if (bonding_mode == BONDING_MODE_BALANCE) {
3749 int balance_xmit_policy;
3751 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3752 if (balance_xmit_policy < 0) {
3753 printf("\tFailed to get balance xmit policy for port = %d\n",
3757 printf("\tBalance Xmit Policy: ");
3759 switch (balance_xmit_policy) {
3760 case BALANCE_XMIT_POLICY_LAYER2:
3761 printf("BALANCE_XMIT_POLICY_LAYER2");
3763 case BALANCE_XMIT_POLICY_LAYER23:
3764 printf("BALANCE_XMIT_POLICY_LAYER23");
3766 case BALANCE_XMIT_POLICY_LAYER34:
3767 printf("BALANCE_XMIT_POLICY_LAYER34");
3774 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3776 if (num_slaves < 0) {
3777 printf("\tFailed to get slave list for port = %d\n", port_id);
3780 if (num_slaves > 0) {
3781 printf("\tSlaves (%d): [", num_slaves);
3782 for (i = 0; i < num_slaves - 1; i++)
3783 printf("%d ", slaves[i]);
3785 printf("%d]\n", slaves[num_slaves - 1]);
3787 printf("\tSlaves: []\n");
3791 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3794 if (num_active_slaves < 0) {
3795 printf("\tFailed to get active slave list for port = %d\n", port_id);
3798 if (num_active_slaves > 0) {
3799 printf("\tActive Slaves (%d): [", num_active_slaves);
3800 for (i = 0; i < num_active_slaves - 1; i++)
3801 printf("%d ", slaves[i]);
3803 printf("%d]\n", slaves[num_active_slaves - 1]);
3806 printf("\tActive Slaves: []\n");
3810 primary_id = rte_eth_bond_primary_get(port_id);
3811 if (primary_id < 0) {
3812 printf("\tFailed to get primary slave for port = %d\n", port_id);
3815 printf("\tPrimary: [%d]\n", primary_id);
3819 cmdline_parse_token_string_t cmd_showbonding_config_show =
3820 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3822 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3823 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3824 bonding, "bonding");
3825 cmdline_parse_token_string_t cmd_showbonding_config_config =
3826 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3828 cmdline_parse_token_num_t cmd_showbonding_config_port =
3829 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3832 cmdline_parse_inst_t cmd_show_bonding_config = {
3833 .f = cmd_show_bonding_config_parsed,
3834 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3837 (void *)&cmd_showbonding_config_show,
3838 (void *)&cmd_showbonding_config_bonding,
3839 (void *)&cmd_showbonding_config_config,
3840 (void *)&cmd_showbonding_config_port,
3845 /* *** SET BONDING PRIMARY *** */
3846 struct cmd_set_bonding_primary_result {
3847 cmdline_fixed_string_t set;
3848 cmdline_fixed_string_t bonding;
3849 cmdline_fixed_string_t primary;
3854 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3855 __attribute__((unused)) struct cmdline *cl,
3856 __attribute__((unused)) void *data)
3858 struct cmd_set_bonding_primary_result *res = parsed_result;
3859 portid_t master_port_id = res->port_id;
3860 portid_t slave_port_id = res->slave_id;
3862 /* Set the primary slave for a bonded device. */
3863 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3864 printf("\t Failed to set primary slave for port = %d.\n",
3871 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3874 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3875 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3876 bonding, "bonding");
3877 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3878 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3879 primary, "primary");
3880 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3881 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3883 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3884 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3887 cmdline_parse_inst_t cmd_set_bonding_primary = {
3888 .f = cmd_set_bonding_primary_parsed,
3889 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3892 (void *)&cmd_setbonding_primary_set,
3893 (void *)&cmd_setbonding_primary_bonding,
3894 (void *)&cmd_setbonding_primary_primary,
3895 (void *)&cmd_setbonding_primary_slave,
3896 (void *)&cmd_setbonding_primary_port,
3901 /* *** ADD SLAVE *** */
3902 struct cmd_add_bonding_slave_result {
3903 cmdline_fixed_string_t add;
3904 cmdline_fixed_string_t bonding;
3905 cmdline_fixed_string_t slave;
3910 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3911 __attribute__((unused)) struct cmdline *cl,
3912 __attribute__((unused)) void *data)
3914 struct cmd_add_bonding_slave_result *res = parsed_result;
3915 portid_t master_port_id = res->port_id;
3916 portid_t slave_port_id = res->slave_id;
3918 /* Set the primary slave for a bonded device. */
3919 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3920 printf("\t Failed to add slave %d to master port = %d.\n",
3921 slave_port_id, master_port_id);
3927 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3928 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3930 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3931 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3932 bonding, "bonding");
3933 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3934 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3936 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3937 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3939 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3940 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3943 cmdline_parse_inst_t cmd_add_bonding_slave = {
3944 .f = cmd_add_bonding_slave_parsed,
3945 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3948 (void *)&cmd_addbonding_slave_add,
3949 (void *)&cmd_addbonding_slave_bonding,
3950 (void *)&cmd_addbonding_slave_slave,
3951 (void *)&cmd_addbonding_slave_slaveid,
3952 (void *)&cmd_addbonding_slave_port,
3957 /* *** REMOVE SLAVE *** */
3958 struct cmd_remove_bonding_slave_result {
3959 cmdline_fixed_string_t remove;
3960 cmdline_fixed_string_t bonding;
3961 cmdline_fixed_string_t slave;
3966 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3967 __attribute__((unused)) struct cmdline *cl,
3968 __attribute__((unused)) void *data)
3970 struct cmd_remove_bonding_slave_result *res = parsed_result;
3971 portid_t master_port_id = res->port_id;
3972 portid_t slave_port_id = res->slave_id;
3974 /* Set the primary slave for a bonded device. */
3975 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3976 printf("\t Failed to remove slave %d from master port = %d.\n",
3977 slave_port_id, master_port_id);
3983 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3984 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3986 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3987 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3988 bonding, "bonding");
3989 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3990 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3992 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3993 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3995 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3996 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3999 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4000 .f = cmd_remove_bonding_slave_parsed,
4001 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4004 (void *)&cmd_removebonding_slave_remove,
4005 (void *)&cmd_removebonding_slave_bonding,
4006 (void *)&cmd_removebonding_slave_slave,
4007 (void *)&cmd_removebonding_slave_slaveid,
4008 (void *)&cmd_removebonding_slave_port,
4013 /* *** CREATE BONDED DEVICE *** */
4014 struct cmd_create_bonded_device_result {
4015 cmdline_fixed_string_t create;
4016 cmdline_fixed_string_t bonded;
4017 cmdline_fixed_string_t device;
4022 static int bond_dev_num = 0;
4024 static void cmd_create_bonded_device_parsed(void *parsed_result,
4025 __attribute__((unused)) struct cmdline *cl,
4026 __attribute__((unused)) void *data)
4028 struct cmd_create_bonded_device_result *res = parsed_result;
4029 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4032 if (test_done == 0) {
4033 printf("Please stop forwarding first\n");
4037 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4040 /* Create a new bonded device. */
4041 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4043 printf("\t Failed to create bonded device.\n");
4046 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4049 /* Update number of ports */
4050 nb_ports = rte_eth_dev_count();
4051 reconfig(port_id, res->socket);
4052 rte_eth_promiscuous_enable(port_id);
4057 cmdline_parse_token_string_t cmd_createbonded_device_create =
4058 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4060 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4061 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4063 cmdline_parse_token_string_t cmd_createbonded_device_device =
4064 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4066 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4067 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4069 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4070 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4073 cmdline_parse_inst_t cmd_create_bonded_device = {
4074 .f = cmd_create_bonded_device_parsed,
4075 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4078 (void *)&cmd_createbonded_device_create,
4079 (void *)&cmd_createbonded_device_bonded,
4080 (void *)&cmd_createbonded_device_device,
4081 (void *)&cmd_createbonded_device_mode,
4082 (void *)&cmd_createbonded_device_socket,
4087 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4088 struct cmd_set_bond_mac_addr_result {
4089 cmdline_fixed_string_t set;
4090 cmdline_fixed_string_t bonding;
4091 cmdline_fixed_string_t mac_addr;
4093 struct ether_addr address;
4096 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4097 __attribute__((unused)) struct cmdline *cl,
4098 __attribute__((unused)) void *data)
4100 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4103 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4106 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4108 /* check the return value and print it if is < 0 */
4110 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4113 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4114 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4115 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4116 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4118 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4119 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4121 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4122 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4123 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4124 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4126 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4127 .f = cmd_set_bond_mac_addr_parsed,
4129 .help_str = "set bonding mac_addr (port_id) (address): ",
4131 (void *)&cmd_set_bond_mac_addr_set,
4132 (void *)&cmd_set_bond_mac_addr_bonding,
4133 (void *)&cmd_set_bond_mac_addr_mac,
4134 (void *)&cmd_set_bond_mac_addr_portnum,
4135 (void *)&cmd_set_bond_mac_addr_addr,
4141 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4142 struct cmd_set_bond_mon_period_result {
4143 cmdline_fixed_string_t set;
4144 cmdline_fixed_string_t bonding;
4145 cmdline_fixed_string_t mon_period;
4150 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4151 __attribute__((unused)) struct cmdline *cl,
4152 __attribute__((unused)) void *data)
4154 struct cmd_set_bond_mon_period_result *res = parsed_result;
4157 if (res->port_num >= nb_ports) {
4158 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4162 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4164 /* check the return value and print it if is < 0 */
4166 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4169 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4170 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4172 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4173 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4174 bonding, "bonding");
4175 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4176 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4177 mon_period, "mon_period");
4178 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4179 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4181 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4182 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4185 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4186 .f = cmd_set_bond_mon_period_parsed,
4188 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4190 (void *)&cmd_set_bond_mon_period_set,
4191 (void *)&cmd_set_bond_mon_period_bonding,
4192 (void *)&cmd_set_bond_mon_period_mon_period,
4193 (void *)&cmd_set_bond_mon_period_portnum,
4194 (void *)&cmd_set_bond_mon_period_period_ms,
4199 #endif /* RTE_LIBRTE_PMD_BOND */
4201 /* *** SET FORWARDING MODE *** */
4202 struct cmd_set_fwd_mode_result {
4203 cmdline_fixed_string_t set;
4204 cmdline_fixed_string_t fwd;
4205 cmdline_fixed_string_t mode;
4208 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4209 __attribute__((unused)) struct cmdline *cl,
4210 __attribute__((unused)) void *data)
4212 struct cmd_set_fwd_mode_result *res = parsed_result;
4214 set_pkt_forwarding_mode(res->mode);
4217 cmdline_parse_token_string_t cmd_setfwd_set =
4218 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4219 cmdline_parse_token_string_t cmd_setfwd_fwd =
4220 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4221 cmdline_parse_token_string_t cmd_setfwd_mode =
4222 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4223 "" /* defined at init */);
4225 cmdline_parse_inst_t cmd_set_fwd_mode = {
4226 .f = cmd_set_fwd_mode_parsed,
4228 .help_str = NULL, /* defined at init */
4230 (void *)&cmd_setfwd_set,
4231 (void *)&cmd_setfwd_fwd,
4232 (void *)&cmd_setfwd_mode,
4237 static void cmd_set_fwd_mode_init(void)
4240 static char token[128];
4241 static char help[256];
4242 cmdline_parse_token_string_t *token_struct;
4244 modes = list_pkt_forwarding_modes();
4245 snprintf(help, sizeof help, "set fwd %s - "
4246 "set packet forwarding mode", modes);
4247 cmd_set_fwd_mode.help_str = help;
4249 /* string token separator is # */
4250 for (c = token; *modes != '\0'; modes++)
4255 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4256 token_struct->string_data.str = token;
4259 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4260 struct cmd_set_burst_tx_retry_result {
4261 cmdline_fixed_string_t set;
4262 cmdline_fixed_string_t burst;
4263 cmdline_fixed_string_t tx;
4264 cmdline_fixed_string_t delay;
4266 cmdline_fixed_string_t retry;
4270 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4271 __attribute__((unused)) struct cmdline *cl,
4272 __attribute__((unused)) void *data)
4274 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4276 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4277 && !strcmp(res->tx, "tx")) {
4278 if (!strcmp(res->delay, "delay"))
4279 burst_tx_delay_time = res->time;
4280 if (!strcmp(res->retry, "retry"))
4281 burst_tx_retry_num = res->retry_num;
4286 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4287 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4288 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4289 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4291 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4292 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4293 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4294 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4295 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4296 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4297 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4298 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4299 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4300 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4302 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4303 .f = cmd_set_burst_tx_retry_parsed,
4304 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4306 (void *)&cmd_set_burst_tx_retry_set,
4307 (void *)&cmd_set_burst_tx_retry_burst,
4308 (void *)&cmd_set_burst_tx_retry_tx,
4309 (void *)&cmd_set_burst_tx_retry_delay,
4310 (void *)&cmd_set_burst_tx_retry_time,
4311 (void *)&cmd_set_burst_tx_retry_retry,
4312 (void *)&cmd_set_burst_tx_retry_retry_num,
4317 /* *** SET PROMISC MODE *** */
4318 struct cmd_set_promisc_mode_result {
4319 cmdline_fixed_string_t set;
4320 cmdline_fixed_string_t promisc;
4321 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4322 uint8_t port_num; /* valid if "allports" argument == 0 */
4323 cmdline_fixed_string_t mode;
4326 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4327 __attribute__((unused)) struct cmdline *cl,
4330 struct cmd_set_promisc_mode_result *res = parsed_result;
4334 if (!strcmp(res->mode, "on"))
4341 FOREACH_PORT(i, ports) {
4343 rte_eth_promiscuous_enable(i);
4345 rte_eth_promiscuous_disable(i);
4350 rte_eth_promiscuous_enable(res->port_num);
4352 rte_eth_promiscuous_disable(res->port_num);
4356 cmdline_parse_token_string_t cmd_setpromisc_set =
4357 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4358 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4359 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4361 cmdline_parse_token_string_t cmd_setpromisc_portall =
4362 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4364 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4365 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4367 cmdline_parse_token_string_t cmd_setpromisc_mode =
4368 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4371 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4372 .f = cmd_set_promisc_mode_parsed,
4374 .help_str = "set promisc all on|off: set promisc mode for all ports",
4376 (void *)&cmd_setpromisc_set,
4377 (void *)&cmd_setpromisc_promisc,
4378 (void *)&cmd_setpromisc_portall,
4379 (void *)&cmd_setpromisc_mode,
4384 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4385 .f = cmd_set_promisc_mode_parsed,
4387 .help_str = "set promisc X on|off: set promisc mode on port X",
4389 (void *)&cmd_setpromisc_set,
4390 (void *)&cmd_setpromisc_promisc,
4391 (void *)&cmd_setpromisc_portnum,
4392 (void *)&cmd_setpromisc_mode,
4397 /* *** SET ALLMULTI MODE *** */
4398 struct cmd_set_allmulti_mode_result {
4399 cmdline_fixed_string_t set;
4400 cmdline_fixed_string_t allmulti;
4401 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4402 uint8_t port_num; /* valid if "allports" argument == 0 */
4403 cmdline_fixed_string_t mode;
4406 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4407 __attribute__((unused)) struct cmdline *cl,
4410 struct cmd_set_allmulti_mode_result *res = parsed_result;
4414 if (!strcmp(res->mode, "on"))
4421 FOREACH_PORT(i, ports) {
4423 rte_eth_allmulticast_enable(i);
4425 rte_eth_allmulticast_disable(i);
4430 rte_eth_allmulticast_enable(res->port_num);
4432 rte_eth_allmulticast_disable(res->port_num);
4436 cmdline_parse_token_string_t cmd_setallmulti_set =
4437 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4438 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4439 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4441 cmdline_parse_token_string_t cmd_setallmulti_portall =
4442 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4444 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4445 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4447 cmdline_parse_token_string_t cmd_setallmulti_mode =
4448 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4451 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4452 .f = cmd_set_allmulti_mode_parsed,
4454 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4456 (void *)&cmd_setallmulti_set,
4457 (void *)&cmd_setallmulti_allmulti,
4458 (void *)&cmd_setallmulti_portall,
4459 (void *)&cmd_setallmulti_mode,
4464 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4465 .f = cmd_set_allmulti_mode_parsed,
4467 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4469 (void *)&cmd_setallmulti_set,
4470 (void *)&cmd_setallmulti_allmulti,
4471 (void *)&cmd_setallmulti_portnum,
4472 (void *)&cmd_setallmulti_mode,
4477 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4478 struct cmd_link_flow_ctrl_set_result {
4479 cmdline_fixed_string_t set;
4480 cmdline_fixed_string_t flow_ctrl;
4481 cmdline_fixed_string_t rx;
4482 cmdline_fixed_string_t rx_lfc_mode;
4483 cmdline_fixed_string_t tx;
4484 cmdline_fixed_string_t tx_lfc_mode;
4485 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4486 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4487 cmdline_fixed_string_t autoneg_str;
4488 cmdline_fixed_string_t autoneg;
4489 cmdline_fixed_string_t hw_str;
4490 uint32_t high_water;
4491 cmdline_fixed_string_t lw_str;
4493 cmdline_fixed_string_t pt_str;
4494 uint16_t pause_time;
4495 cmdline_fixed_string_t xon_str;
4500 cmdline_parse_token_string_t cmd_lfc_set_set =
4501 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4503 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4504 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4505 flow_ctrl, "flow_ctrl");
4506 cmdline_parse_token_string_t cmd_lfc_set_rx =
4507 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4509 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4510 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4511 rx_lfc_mode, "on#off");
4512 cmdline_parse_token_string_t cmd_lfc_set_tx =
4513 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4515 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4516 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4517 tx_lfc_mode, "on#off");
4518 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4519 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4520 hw_str, "high_water");
4521 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4522 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4523 high_water, UINT32);
4524 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4525 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4526 lw_str, "low_water");
4527 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4528 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4530 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4531 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4532 pt_str, "pause_time");
4533 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4534 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4535 pause_time, UINT16);
4536 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4537 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4538 xon_str, "send_xon");
4539 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4540 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4542 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4543 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4544 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4545 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4546 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4547 mac_ctrl_frame_fwd_mode, "on#off");
4548 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4549 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4550 autoneg_str, "autoneg");
4551 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4552 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4554 cmdline_parse_token_num_t cmd_lfc_set_portid =
4555 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4558 /* forward declaration */
4560 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4563 cmdline_parse_inst_t cmd_link_flow_control_set = {
4564 .f = cmd_link_flow_ctrl_set_parsed,
4566 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4567 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4568 autoneg on|off port_id",
4570 (void *)&cmd_lfc_set_set,
4571 (void *)&cmd_lfc_set_flow_ctrl,
4572 (void *)&cmd_lfc_set_rx,
4573 (void *)&cmd_lfc_set_rx_mode,
4574 (void *)&cmd_lfc_set_tx,
4575 (void *)&cmd_lfc_set_tx_mode,
4576 (void *)&cmd_lfc_set_high_water,
4577 (void *)&cmd_lfc_set_low_water,
4578 (void *)&cmd_lfc_set_pause_time,
4579 (void *)&cmd_lfc_set_send_xon,
4580 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4581 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4582 (void *)&cmd_lfc_set_autoneg_str,
4583 (void *)&cmd_lfc_set_autoneg,
4584 (void *)&cmd_lfc_set_portid,
4589 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4590 .f = cmd_link_flow_ctrl_set_parsed,
4591 .data = (void *)&cmd_link_flow_control_set_rx,
4592 .help_str = "Change rx flow control parameter: set flow_ctrl "
4593 "rx on|off port_id",
4595 (void *)&cmd_lfc_set_set,
4596 (void *)&cmd_lfc_set_flow_ctrl,
4597 (void *)&cmd_lfc_set_rx,
4598 (void *)&cmd_lfc_set_rx_mode,
4599 (void *)&cmd_lfc_set_portid,
4604 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4605 .f = cmd_link_flow_ctrl_set_parsed,
4606 .data = (void *)&cmd_link_flow_control_set_tx,
4607 .help_str = "Change tx flow control parameter: set flow_ctrl "
4608 "tx on|off port_id",
4610 (void *)&cmd_lfc_set_set,
4611 (void *)&cmd_lfc_set_flow_ctrl,
4612 (void *)&cmd_lfc_set_tx,
4613 (void *)&cmd_lfc_set_tx_mode,
4614 (void *)&cmd_lfc_set_portid,
4619 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4620 .f = cmd_link_flow_ctrl_set_parsed,
4621 .data = (void *)&cmd_link_flow_control_set_hw,
4622 .help_str = "Change high water flow control parameter: set flow_ctrl "
4623 "high_water value port_id",
4625 (void *)&cmd_lfc_set_set,
4626 (void *)&cmd_lfc_set_flow_ctrl,
4627 (void *)&cmd_lfc_set_high_water_str,
4628 (void *)&cmd_lfc_set_high_water,
4629 (void *)&cmd_lfc_set_portid,
4634 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4635 .f = cmd_link_flow_ctrl_set_parsed,
4636 .data = (void *)&cmd_link_flow_control_set_lw,
4637 .help_str = "Change low water flow control parameter: set flow_ctrl "
4638 "low_water value port_id",
4640 (void *)&cmd_lfc_set_set,
4641 (void *)&cmd_lfc_set_flow_ctrl,
4642 (void *)&cmd_lfc_set_low_water_str,
4643 (void *)&cmd_lfc_set_low_water,
4644 (void *)&cmd_lfc_set_portid,
4649 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4650 .f = cmd_link_flow_ctrl_set_parsed,
4651 .data = (void *)&cmd_link_flow_control_set_pt,
4652 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4653 "pause_time value port_id",
4655 (void *)&cmd_lfc_set_set,
4656 (void *)&cmd_lfc_set_flow_ctrl,
4657 (void *)&cmd_lfc_set_pause_time_str,
4658 (void *)&cmd_lfc_set_pause_time,
4659 (void *)&cmd_lfc_set_portid,
4664 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4665 .f = cmd_link_flow_ctrl_set_parsed,
4666 .data = (void *)&cmd_link_flow_control_set_xon,
4667 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4668 "send_xon value port_id",
4670 (void *)&cmd_lfc_set_set,
4671 (void *)&cmd_lfc_set_flow_ctrl,
4672 (void *)&cmd_lfc_set_send_xon_str,
4673 (void *)&cmd_lfc_set_send_xon,
4674 (void *)&cmd_lfc_set_portid,
4679 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4680 .f = cmd_link_flow_ctrl_set_parsed,
4681 .data = (void *)&cmd_link_flow_control_set_macfwd,
4682 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4683 "mac_ctrl_frame_fwd on|off port_id",
4685 (void *)&cmd_lfc_set_set,
4686 (void *)&cmd_lfc_set_flow_ctrl,
4687 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4688 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4689 (void *)&cmd_lfc_set_portid,
4694 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4695 .f = cmd_link_flow_ctrl_set_parsed,
4696 .data = (void *)&cmd_link_flow_control_set_autoneg,
4697 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4698 "autoneg on|off port_id",
4700 (void *)&cmd_lfc_set_set,
4701 (void *)&cmd_lfc_set_flow_ctrl,
4702 (void *)&cmd_lfc_set_autoneg_str,
4703 (void *)&cmd_lfc_set_autoneg,
4704 (void *)&cmd_lfc_set_portid,
4710 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4711 __attribute__((unused)) struct cmdline *cl,
4714 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4715 cmdline_parse_inst_t *cmd = data;
4716 struct rte_eth_fc_conf fc_conf;
4717 int rx_fc_en, tx_fc_en = 0;
4721 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4722 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4723 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4724 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4726 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4727 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4730 /* Partial command line, retrieve current configuration */
4732 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4734 printf("cannot get current flow ctrl parameters, return"
4735 "code = %d\n", ret);
4739 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4740 (fc_conf.mode == RTE_FC_FULL))
4742 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4743 (fc_conf.mode == RTE_FC_FULL))
4747 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4748 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4750 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4751 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4753 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4755 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4756 fc_conf.high_water = res->high_water;
4758 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4759 fc_conf.low_water = res->low_water;
4761 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4762 fc_conf.pause_time = res->pause_time;
4764 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4765 fc_conf.send_xon = res->send_xon;
4767 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4768 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4769 fc_conf.mac_ctrl_frame_fwd = 1;
4771 fc_conf.mac_ctrl_frame_fwd = 0;
4774 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4775 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4777 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4779 printf("bad flow contrl parameter, return code = %d \n", ret);
4782 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4783 struct cmd_priority_flow_ctrl_set_result {
4784 cmdline_fixed_string_t set;
4785 cmdline_fixed_string_t pfc_ctrl;
4786 cmdline_fixed_string_t rx;
4787 cmdline_fixed_string_t rx_pfc_mode;
4788 cmdline_fixed_string_t tx;
4789 cmdline_fixed_string_t tx_pfc_mode;
4790 uint32_t high_water;
4792 uint16_t pause_time;
4798 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4799 __attribute__((unused)) struct cmdline *cl,
4800 __attribute__((unused)) void *data)
4802 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4803 struct rte_eth_pfc_conf pfc_conf;
4804 int rx_fc_enable, tx_fc_enable;
4808 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4809 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4810 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4811 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4813 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4814 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4817 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4818 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4819 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4820 pfc_conf.fc.high_water = res->high_water;
4821 pfc_conf.fc.low_water = res->low_water;
4822 pfc_conf.fc.pause_time = res->pause_time;
4823 pfc_conf.priority = res->priority;
4825 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4827 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4830 cmdline_parse_token_string_t cmd_pfc_set_set =
4831 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4833 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4834 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4835 pfc_ctrl, "pfc_ctrl");
4836 cmdline_parse_token_string_t cmd_pfc_set_rx =
4837 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4839 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4840 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4841 rx_pfc_mode, "on#off");
4842 cmdline_parse_token_string_t cmd_pfc_set_tx =
4843 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4845 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4846 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4847 tx_pfc_mode, "on#off");
4848 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4849 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4850 high_water, UINT32);
4851 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4852 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4854 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4855 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4856 pause_time, UINT16);
4857 cmdline_parse_token_num_t cmd_pfc_set_priority =
4858 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4860 cmdline_parse_token_num_t cmd_pfc_set_portid =
4861 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4864 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4865 .f = cmd_priority_flow_ctrl_set_parsed,
4867 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4868 tx on|off high_water low_water pause_time priority port_id",
4870 (void *)&cmd_pfc_set_set,
4871 (void *)&cmd_pfc_set_flow_ctrl,
4872 (void *)&cmd_pfc_set_rx,
4873 (void *)&cmd_pfc_set_rx_mode,
4874 (void *)&cmd_pfc_set_tx,
4875 (void *)&cmd_pfc_set_tx_mode,
4876 (void *)&cmd_pfc_set_high_water,
4877 (void *)&cmd_pfc_set_low_water,
4878 (void *)&cmd_pfc_set_pause_time,
4879 (void *)&cmd_pfc_set_priority,
4880 (void *)&cmd_pfc_set_portid,
4885 /* *** RESET CONFIGURATION *** */
4886 struct cmd_reset_result {
4887 cmdline_fixed_string_t reset;
4888 cmdline_fixed_string_t def;
4891 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4893 __attribute__((unused)) void *data)
4895 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4896 set_def_fwd_config();
4899 cmdline_parse_token_string_t cmd_reset_set =
4900 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4901 cmdline_parse_token_string_t cmd_reset_def =
4902 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4905 cmdline_parse_inst_t cmd_reset = {
4906 .f = cmd_reset_parsed,
4908 .help_str = "set default: reset default forwarding configuration",
4910 (void *)&cmd_reset_set,
4911 (void *)&cmd_reset_def,
4916 /* *** START FORWARDING *** */
4917 struct cmd_start_result {
4918 cmdline_fixed_string_t start;
4921 cmdline_parse_token_string_t cmd_start_start =
4922 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4924 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4925 __attribute__((unused)) struct cmdline *cl,
4926 __attribute__((unused)) void *data)
4928 start_packet_forwarding(0);
4931 cmdline_parse_inst_t cmd_start = {
4932 .f = cmd_start_parsed,
4934 .help_str = "start packet forwarding",
4936 (void *)&cmd_start_start,
4941 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4942 struct cmd_start_tx_first_result {
4943 cmdline_fixed_string_t start;
4944 cmdline_fixed_string_t tx_first;
4948 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4949 __attribute__((unused)) struct cmdline *cl,
4950 __attribute__((unused)) void *data)
4952 start_packet_forwarding(1);
4955 cmdline_parse_token_string_t cmd_start_tx_first_start =
4956 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4958 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4959 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4960 tx_first, "tx_first");
4962 cmdline_parse_inst_t cmd_start_tx_first = {
4963 .f = cmd_start_tx_first_parsed,
4965 .help_str = "start packet forwarding, after sending 1 burst of packets",
4967 (void *)&cmd_start_tx_first_start,
4968 (void *)&cmd_start_tx_first_tx_first,
4973 /* *** SET LINK UP *** */
4974 struct cmd_set_link_up_result {
4975 cmdline_fixed_string_t set;
4976 cmdline_fixed_string_t link_up;
4977 cmdline_fixed_string_t port;
4981 cmdline_parse_token_string_t cmd_set_link_up_set =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4983 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4984 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4986 cmdline_parse_token_string_t cmd_set_link_up_port =
4987 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4988 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4989 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4991 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4992 __attribute__((unused)) struct cmdline *cl,
4993 __attribute__((unused)) void *data)
4995 struct cmd_set_link_up_result *res = parsed_result;
4996 dev_set_link_up(res->port_id);
4999 cmdline_parse_inst_t cmd_set_link_up = {
5000 .f = cmd_set_link_up_parsed,
5002 .help_str = "set link-up port (port id)",
5004 (void *)&cmd_set_link_up_set,
5005 (void *)&cmd_set_link_up_link_up,
5006 (void *)&cmd_set_link_up_port,
5007 (void *)&cmd_set_link_up_port_id,
5012 /* *** SET LINK DOWN *** */
5013 struct cmd_set_link_down_result {
5014 cmdline_fixed_string_t set;
5015 cmdline_fixed_string_t link_down;
5016 cmdline_fixed_string_t port;
5020 cmdline_parse_token_string_t cmd_set_link_down_set =
5021 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5022 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5023 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5025 cmdline_parse_token_string_t cmd_set_link_down_port =
5026 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5027 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5028 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5030 static void cmd_set_link_down_parsed(
5031 __attribute__((unused)) void *parsed_result,
5032 __attribute__((unused)) struct cmdline *cl,
5033 __attribute__((unused)) void *data)
5035 struct cmd_set_link_down_result *res = parsed_result;
5036 dev_set_link_down(res->port_id);
5039 cmdline_parse_inst_t cmd_set_link_down = {
5040 .f = cmd_set_link_down_parsed,
5042 .help_str = "set link-down port (port id)",
5044 (void *)&cmd_set_link_down_set,
5045 (void *)&cmd_set_link_down_link_down,
5046 (void *)&cmd_set_link_down_port,
5047 (void *)&cmd_set_link_down_port_id,
5052 /* *** SHOW CFG *** */
5053 struct cmd_showcfg_result {
5054 cmdline_fixed_string_t show;
5055 cmdline_fixed_string_t cfg;
5056 cmdline_fixed_string_t what;
5059 static void cmd_showcfg_parsed(void *parsed_result,
5060 __attribute__((unused)) struct cmdline *cl,
5061 __attribute__((unused)) void *data)
5063 struct cmd_showcfg_result *res = parsed_result;
5064 if (!strcmp(res->what, "rxtx"))
5065 rxtx_config_display();
5066 else if (!strcmp(res->what, "cores"))
5067 fwd_lcores_config_display();
5068 else if (!strcmp(res->what, "fwd"))
5069 fwd_config_display();
5072 cmdline_parse_token_string_t cmd_showcfg_show =
5073 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5074 cmdline_parse_token_string_t cmd_showcfg_port =
5075 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5076 cmdline_parse_token_string_t cmd_showcfg_what =
5077 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5080 cmdline_parse_inst_t cmd_showcfg = {
5081 .f = cmd_showcfg_parsed,
5083 .help_str = "show config rxtx|cores|fwd",
5085 (void *)&cmd_showcfg_show,
5086 (void *)&cmd_showcfg_port,
5087 (void *)&cmd_showcfg_what,
5092 /* *** SHOW ALL PORT INFO *** */
5093 struct cmd_showportall_result {
5094 cmdline_fixed_string_t show;
5095 cmdline_fixed_string_t port;
5096 cmdline_fixed_string_t what;
5097 cmdline_fixed_string_t all;
5100 static void cmd_showportall_parsed(void *parsed_result,
5101 __attribute__((unused)) struct cmdline *cl,
5102 __attribute__((unused)) void *data)
5106 struct cmd_showportall_result *res = parsed_result;
5107 if (!strcmp(res->show, "clear")) {
5108 if (!strcmp(res->what, "stats"))
5109 FOREACH_PORT(i, ports)
5111 else if (!strcmp(res->what, "xstats"))
5112 FOREACH_PORT(i, ports)
5113 nic_xstats_clear(i);
5114 } else if (!strcmp(res->what, "info"))
5115 FOREACH_PORT(i, ports)
5116 port_infos_display(i);
5117 else if (!strcmp(res->what, "stats"))
5118 FOREACH_PORT(i, ports)
5119 nic_stats_display(i);
5120 else if (!strcmp(res->what, "xstats"))
5121 FOREACH_PORT(i, ports)
5122 nic_xstats_display(i);
5123 else if (!strcmp(res->what, "fdir"))
5124 FOREACH_PORT(i, ports)
5126 else if (!strcmp(res->what, "stat_qmap"))
5127 FOREACH_PORT(i, ports)
5128 nic_stats_mapping_display(i);
5131 cmdline_parse_token_string_t cmd_showportall_show =
5132 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5134 cmdline_parse_token_string_t cmd_showportall_port =
5135 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5136 cmdline_parse_token_string_t cmd_showportall_what =
5137 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5138 "info#stats#xstats#fdir#stat_qmap");
5139 cmdline_parse_token_string_t cmd_showportall_all =
5140 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5141 cmdline_parse_inst_t cmd_showportall = {
5142 .f = cmd_showportall_parsed,
5144 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5146 (void *)&cmd_showportall_show,
5147 (void *)&cmd_showportall_port,
5148 (void *)&cmd_showportall_what,
5149 (void *)&cmd_showportall_all,
5154 /* *** SHOW PORT INFO *** */
5155 struct cmd_showport_result {
5156 cmdline_fixed_string_t show;
5157 cmdline_fixed_string_t port;
5158 cmdline_fixed_string_t what;
5162 static void cmd_showport_parsed(void *parsed_result,
5163 __attribute__((unused)) struct cmdline *cl,
5164 __attribute__((unused)) void *data)
5166 struct cmd_showport_result *res = parsed_result;
5167 if (!strcmp(res->show, "clear")) {
5168 if (!strcmp(res->what, "stats"))
5169 nic_stats_clear(res->portnum);
5170 else if (!strcmp(res->what, "xstats"))
5171 nic_xstats_clear(res->portnum);
5172 } else if (!strcmp(res->what, "info"))
5173 port_infos_display(res->portnum);
5174 else if (!strcmp(res->what, "stats"))
5175 nic_stats_display(res->portnum);
5176 else if (!strcmp(res->what, "xstats"))
5177 nic_xstats_display(res->portnum);
5178 else if (!strcmp(res->what, "fdir"))
5179 fdir_get_infos(res->portnum);
5180 else if (!strcmp(res->what, "stat_qmap"))
5181 nic_stats_mapping_display(res->portnum);
5184 cmdline_parse_token_string_t cmd_showport_show =
5185 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5187 cmdline_parse_token_string_t cmd_showport_port =
5188 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5189 cmdline_parse_token_string_t cmd_showport_what =
5190 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5191 "info#stats#xstats#fdir#stat_qmap");
5192 cmdline_parse_token_num_t cmd_showport_portnum =
5193 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5195 cmdline_parse_inst_t cmd_showport = {
5196 .f = cmd_showport_parsed,
5198 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5200 (void *)&cmd_showport_show,
5201 (void *)&cmd_showport_port,
5202 (void *)&cmd_showport_what,
5203 (void *)&cmd_showport_portnum,
5208 /* *** READ PORT REGISTER *** */
5209 struct cmd_read_reg_result {
5210 cmdline_fixed_string_t read;
5211 cmdline_fixed_string_t reg;
5217 cmd_read_reg_parsed(void *parsed_result,
5218 __attribute__((unused)) struct cmdline *cl,
5219 __attribute__((unused)) void *data)
5221 struct cmd_read_reg_result *res = parsed_result;
5222 port_reg_display(res->port_id, res->reg_off);
5225 cmdline_parse_token_string_t cmd_read_reg_read =
5226 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5227 cmdline_parse_token_string_t cmd_read_reg_reg =
5228 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5229 cmdline_parse_token_num_t cmd_read_reg_port_id =
5230 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5231 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5232 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5234 cmdline_parse_inst_t cmd_read_reg = {
5235 .f = cmd_read_reg_parsed,
5237 .help_str = "read reg port_id reg_off",
5239 (void *)&cmd_read_reg_read,
5240 (void *)&cmd_read_reg_reg,
5241 (void *)&cmd_read_reg_port_id,
5242 (void *)&cmd_read_reg_reg_off,
5247 /* *** READ PORT REGISTER BIT FIELD *** */
5248 struct cmd_read_reg_bit_field_result {
5249 cmdline_fixed_string_t read;
5250 cmdline_fixed_string_t regfield;
5258 cmd_read_reg_bit_field_parsed(void *parsed_result,
5259 __attribute__((unused)) struct cmdline *cl,
5260 __attribute__((unused)) void *data)
5262 struct cmd_read_reg_bit_field_result *res = parsed_result;
5263 port_reg_bit_field_display(res->port_id, res->reg_off,
5264 res->bit1_pos, res->bit2_pos);
5267 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5268 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5270 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5271 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5272 regfield, "regfield");
5273 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5274 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5276 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5277 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5279 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5280 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5282 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5283 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5286 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5287 .f = cmd_read_reg_bit_field_parsed,
5289 .help_str = "read regfield port_id reg_off bit_x bit_y "
5290 "(read register bit field between bit_x and bit_y included)",
5292 (void *)&cmd_read_reg_bit_field_read,
5293 (void *)&cmd_read_reg_bit_field_regfield,
5294 (void *)&cmd_read_reg_bit_field_port_id,
5295 (void *)&cmd_read_reg_bit_field_reg_off,
5296 (void *)&cmd_read_reg_bit_field_bit1_pos,
5297 (void *)&cmd_read_reg_bit_field_bit2_pos,
5302 /* *** READ PORT REGISTER BIT *** */
5303 struct cmd_read_reg_bit_result {
5304 cmdline_fixed_string_t read;
5305 cmdline_fixed_string_t regbit;
5312 cmd_read_reg_bit_parsed(void *parsed_result,
5313 __attribute__((unused)) struct cmdline *cl,
5314 __attribute__((unused)) void *data)
5316 struct cmd_read_reg_bit_result *res = parsed_result;
5317 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5320 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5321 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5322 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5323 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5325 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5326 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5327 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5328 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5329 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5330 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5332 cmdline_parse_inst_t cmd_read_reg_bit = {
5333 .f = cmd_read_reg_bit_parsed,
5335 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5337 (void *)&cmd_read_reg_bit_read,
5338 (void *)&cmd_read_reg_bit_regbit,
5339 (void *)&cmd_read_reg_bit_port_id,
5340 (void *)&cmd_read_reg_bit_reg_off,
5341 (void *)&cmd_read_reg_bit_bit_pos,
5346 /* *** WRITE PORT REGISTER *** */
5347 struct cmd_write_reg_result {
5348 cmdline_fixed_string_t write;
5349 cmdline_fixed_string_t reg;
5356 cmd_write_reg_parsed(void *parsed_result,
5357 __attribute__((unused)) struct cmdline *cl,
5358 __attribute__((unused)) void *data)
5360 struct cmd_write_reg_result *res = parsed_result;
5361 port_reg_set(res->port_id, res->reg_off, res->value);
5364 cmdline_parse_token_string_t cmd_write_reg_write =
5365 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5366 cmdline_parse_token_string_t cmd_write_reg_reg =
5367 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5368 cmdline_parse_token_num_t cmd_write_reg_port_id =
5369 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5370 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5371 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5372 cmdline_parse_token_num_t cmd_write_reg_value =
5373 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5375 cmdline_parse_inst_t cmd_write_reg = {
5376 .f = cmd_write_reg_parsed,
5378 .help_str = "write reg port_id reg_off reg_value",
5380 (void *)&cmd_write_reg_write,
5381 (void *)&cmd_write_reg_reg,
5382 (void *)&cmd_write_reg_port_id,
5383 (void *)&cmd_write_reg_reg_off,
5384 (void *)&cmd_write_reg_value,
5389 /* *** WRITE PORT REGISTER BIT FIELD *** */
5390 struct cmd_write_reg_bit_field_result {
5391 cmdline_fixed_string_t write;
5392 cmdline_fixed_string_t regfield;
5401 cmd_write_reg_bit_field_parsed(void *parsed_result,
5402 __attribute__((unused)) struct cmdline *cl,
5403 __attribute__((unused)) void *data)
5405 struct cmd_write_reg_bit_field_result *res = parsed_result;
5406 port_reg_bit_field_set(res->port_id, res->reg_off,
5407 res->bit1_pos, res->bit2_pos, res->value);
5410 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5411 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5413 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5414 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5415 regfield, "regfield");
5416 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5417 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5419 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5420 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5422 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5423 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5425 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5426 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5428 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5429 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5432 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5433 .f = cmd_write_reg_bit_field_parsed,
5435 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5436 "(set register bit field between bit_x and bit_y included)",
5438 (void *)&cmd_write_reg_bit_field_write,
5439 (void *)&cmd_write_reg_bit_field_regfield,
5440 (void *)&cmd_write_reg_bit_field_port_id,
5441 (void *)&cmd_write_reg_bit_field_reg_off,
5442 (void *)&cmd_write_reg_bit_field_bit1_pos,
5443 (void *)&cmd_write_reg_bit_field_bit2_pos,
5444 (void *)&cmd_write_reg_bit_field_value,
5449 /* *** WRITE PORT REGISTER BIT *** */
5450 struct cmd_write_reg_bit_result {
5451 cmdline_fixed_string_t write;
5452 cmdline_fixed_string_t regbit;
5460 cmd_write_reg_bit_parsed(void *parsed_result,
5461 __attribute__((unused)) struct cmdline *cl,
5462 __attribute__((unused)) void *data)
5464 struct cmd_write_reg_bit_result *res = parsed_result;
5465 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5468 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5469 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5471 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5472 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5474 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5475 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5476 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5477 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5478 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5479 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5480 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5481 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5483 cmdline_parse_inst_t cmd_write_reg_bit = {
5484 .f = cmd_write_reg_bit_parsed,
5486 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5488 (void *)&cmd_write_reg_bit_write,
5489 (void *)&cmd_write_reg_bit_regbit,
5490 (void *)&cmd_write_reg_bit_port_id,
5491 (void *)&cmd_write_reg_bit_reg_off,
5492 (void *)&cmd_write_reg_bit_bit_pos,
5493 (void *)&cmd_write_reg_bit_value,
5498 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5499 struct cmd_read_rxd_txd_result {
5500 cmdline_fixed_string_t read;
5501 cmdline_fixed_string_t rxd_txd;
5508 cmd_read_rxd_txd_parsed(void *parsed_result,
5509 __attribute__((unused)) struct cmdline *cl,
5510 __attribute__((unused)) void *data)
5512 struct cmd_read_rxd_txd_result *res = parsed_result;
5514 if (!strcmp(res->rxd_txd, "rxd"))
5515 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5516 else if (!strcmp(res->rxd_txd, "txd"))
5517 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5520 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5521 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5522 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5523 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5525 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5526 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5527 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5528 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5529 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5530 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5532 cmdline_parse_inst_t cmd_read_rxd_txd = {
5533 .f = cmd_read_rxd_txd_parsed,
5535 .help_str = "read rxd|txd port_id queue_id rxd_id",
5537 (void *)&cmd_read_rxd_txd_read,
5538 (void *)&cmd_read_rxd_txd_rxd_txd,
5539 (void *)&cmd_read_rxd_txd_port_id,
5540 (void *)&cmd_read_rxd_txd_queue_id,
5541 (void *)&cmd_read_rxd_txd_desc_id,
5547 struct cmd_quit_result {
5548 cmdline_fixed_string_t quit;
5551 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5553 __attribute__((unused)) void *data)
5559 cmdline_parse_token_string_t cmd_quit_quit =
5560 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5562 cmdline_parse_inst_t cmd_quit = {
5563 .f = cmd_quit_parsed,
5565 .help_str = "exit application",
5567 (void *)&cmd_quit_quit,
5572 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5573 struct cmd_mac_addr_result {
5574 cmdline_fixed_string_t mac_addr_cmd;
5575 cmdline_fixed_string_t what;
5577 struct ether_addr address;
5580 static void cmd_mac_addr_parsed(void *parsed_result,
5581 __attribute__((unused)) struct cmdline *cl,
5582 __attribute__((unused)) void *data)
5584 struct cmd_mac_addr_result *res = parsed_result;
5587 if (strcmp(res->what, "add") == 0)
5588 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5590 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5592 /* check the return value and print it if is < 0 */
5594 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5598 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5599 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5601 cmdline_parse_token_string_t cmd_mac_addr_what =
5602 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5604 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5605 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5606 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5607 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5609 cmdline_parse_inst_t cmd_mac_addr = {
5610 .f = cmd_mac_addr_parsed,
5612 .help_str = "mac_addr add|remove X <address>: "
5613 "add/remove MAC address on port X",
5615 (void *)&cmd_mac_addr_cmd,
5616 (void *)&cmd_mac_addr_what,
5617 (void *)&cmd_mac_addr_portnum,
5618 (void *)&cmd_mac_addr_addr,
5624 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5625 struct cmd_set_qmap_result {
5626 cmdline_fixed_string_t set;
5627 cmdline_fixed_string_t qmap;
5628 cmdline_fixed_string_t what;
5635 cmd_set_qmap_parsed(void *parsed_result,
5636 __attribute__((unused)) struct cmdline *cl,
5637 __attribute__((unused)) void *data)
5639 struct cmd_set_qmap_result *res = parsed_result;
5640 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5642 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5645 cmdline_parse_token_string_t cmd_setqmap_set =
5646 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5648 cmdline_parse_token_string_t cmd_setqmap_qmap =
5649 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5651 cmdline_parse_token_string_t cmd_setqmap_what =
5652 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5654 cmdline_parse_token_num_t cmd_setqmap_portid =
5655 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5657 cmdline_parse_token_num_t cmd_setqmap_queueid =
5658 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5660 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5661 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5664 cmdline_parse_inst_t cmd_set_qmap = {
5665 .f = cmd_set_qmap_parsed,
5667 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5669 (void *)&cmd_setqmap_set,
5670 (void *)&cmd_setqmap_qmap,
5671 (void *)&cmd_setqmap_what,
5672 (void *)&cmd_setqmap_portid,
5673 (void *)&cmd_setqmap_queueid,
5674 (void *)&cmd_setqmap_mapvalue,
5679 /* *** CONFIGURE UNICAST HASH TABLE *** */
5680 struct cmd_set_uc_hash_table {
5681 cmdline_fixed_string_t set;
5682 cmdline_fixed_string_t port;
5684 cmdline_fixed_string_t what;
5685 struct ether_addr address;
5686 cmdline_fixed_string_t mode;
5690 cmd_set_uc_hash_parsed(void *parsed_result,
5691 __attribute__((unused)) struct cmdline *cl,
5692 __attribute__((unused)) void *data)
5695 struct cmd_set_uc_hash_table *res = parsed_result;
5697 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5699 if (strcmp(res->what, "uta") == 0)
5700 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5701 &res->address,(uint8_t)is_on);
5703 printf("bad unicast hash table parameter, return code = %d \n", ret);
5707 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5708 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5710 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5711 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5713 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5714 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5716 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5717 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5719 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5720 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5722 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5723 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5726 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5727 .f = cmd_set_uc_hash_parsed,
5729 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5731 (void *)&cmd_set_uc_hash_set,
5732 (void *)&cmd_set_uc_hash_port,
5733 (void *)&cmd_set_uc_hash_portid,
5734 (void *)&cmd_set_uc_hash_what,
5735 (void *)&cmd_set_uc_hash_mac,
5736 (void *)&cmd_set_uc_hash_mode,
5741 struct cmd_set_uc_all_hash_table {
5742 cmdline_fixed_string_t set;
5743 cmdline_fixed_string_t port;
5745 cmdline_fixed_string_t what;
5746 cmdline_fixed_string_t value;
5747 cmdline_fixed_string_t mode;
5751 cmd_set_uc_all_hash_parsed(void *parsed_result,
5752 __attribute__((unused)) struct cmdline *cl,
5753 __attribute__((unused)) void *data)
5756 struct cmd_set_uc_all_hash_table *res = parsed_result;
5758 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5760 if ((strcmp(res->what, "uta") == 0) &&
5761 (strcmp(res->value, "all") == 0))
5762 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5764 printf("bad unicast hash table parameter,"
5765 "return code = %d \n", ret);
5768 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5769 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5771 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5772 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5774 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5775 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5777 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5778 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5780 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5781 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5783 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5784 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5787 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5788 .f = cmd_set_uc_all_hash_parsed,
5790 .help_str = "set port X uta all on|off (X = port number)",
5792 (void *)&cmd_set_uc_all_hash_set,
5793 (void *)&cmd_set_uc_all_hash_port,
5794 (void *)&cmd_set_uc_all_hash_portid,
5795 (void *)&cmd_set_uc_all_hash_what,
5796 (void *)&cmd_set_uc_all_hash_value,
5797 (void *)&cmd_set_uc_all_hash_mode,
5802 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5803 struct cmd_set_vf_macvlan_filter {
5804 cmdline_fixed_string_t set;
5805 cmdline_fixed_string_t port;
5807 cmdline_fixed_string_t vf;
5809 struct ether_addr address;
5810 cmdline_fixed_string_t filter_type;
5811 cmdline_fixed_string_t mode;
5815 cmd_set_vf_macvlan_parsed(void *parsed_result,
5816 __attribute__((unused)) struct cmdline *cl,
5817 __attribute__((unused)) void *data)
5820 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5821 struct rte_eth_mac_filter filter;
5823 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5825 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5827 /* set VF MAC filter */
5831 filter.dst_id = res->vf_id;
5833 if (!strcmp(res->filter_type, "exact-mac"))
5834 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5835 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5836 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5837 else if (!strcmp(res->filter_type, "hashmac"))
5838 filter.filter_type = RTE_MAC_HASH_MATCH;
5839 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5840 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5842 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5845 ret = rte_eth_dev_filter_ctrl(res->port_id,
5846 RTE_ETH_FILTER_MACVLAN,
5850 ret = rte_eth_dev_filter_ctrl(res->port_id,
5851 RTE_ETH_FILTER_MACVLAN,
5852 RTE_ETH_FILTER_DELETE,
5856 printf("bad set MAC hash parameter, return code = %d\n", ret);
5860 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5861 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5863 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5864 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5866 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5867 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5869 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5870 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5872 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5873 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5875 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5876 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5878 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5879 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5880 filter_type, "exact-mac#exact-mac-vlan"
5881 "#hashmac#hashmac-vlan");
5882 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5883 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5886 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5887 .f = cmd_set_vf_macvlan_parsed,
5889 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5890 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5892 "exact match rule:exact match of MAC or MAC and VLAN; "
5893 "hash match rule: hash match of MAC and exact match "
5896 (void *)&cmd_set_vf_macvlan_set,
5897 (void *)&cmd_set_vf_macvlan_port,
5898 (void *)&cmd_set_vf_macvlan_portid,
5899 (void *)&cmd_set_vf_macvlan_vf,
5900 (void *)&cmd_set_vf_macvlan_vf_id,
5901 (void *)&cmd_set_vf_macvlan_mac,
5902 (void *)&cmd_set_vf_macvlan_filter_type,
5903 (void *)&cmd_set_vf_macvlan_mode,
5908 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5909 struct cmd_set_vf_traffic {
5910 cmdline_fixed_string_t set;
5911 cmdline_fixed_string_t port;
5913 cmdline_fixed_string_t vf;
5915 cmdline_fixed_string_t what;
5916 cmdline_fixed_string_t mode;
5920 cmd_set_vf_traffic_parsed(void *parsed_result,
5921 __attribute__((unused)) struct cmdline *cl,
5922 __attribute__((unused)) void *data)
5924 struct cmd_set_vf_traffic *res = parsed_result;
5925 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5926 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5928 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5931 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5932 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5934 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5935 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5937 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5938 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5940 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5941 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5943 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5944 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5946 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5947 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5949 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5950 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5953 cmdline_parse_inst_t cmd_set_vf_traffic = {
5954 .f = cmd_set_vf_traffic_parsed,
5956 .help_str = "set port X vf Y rx|tx on|off"
5957 "(X = port number,Y = vf id)",
5959 (void *)&cmd_setvf_traffic_set,
5960 (void *)&cmd_setvf_traffic_port,
5961 (void *)&cmd_setvf_traffic_portid,
5962 (void *)&cmd_setvf_traffic_vf,
5963 (void *)&cmd_setvf_traffic_vfid,
5964 (void *)&cmd_setvf_traffic_what,
5965 (void *)&cmd_setvf_traffic_mode,
5970 /* *** CONFIGURE VF RECEIVE MODE *** */
5971 struct cmd_set_vf_rxmode {
5972 cmdline_fixed_string_t set;
5973 cmdline_fixed_string_t port;
5975 cmdline_fixed_string_t vf;
5977 cmdline_fixed_string_t what;
5978 cmdline_fixed_string_t mode;
5979 cmdline_fixed_string_t on;
5983 cmd_set_vf_rxmode_parsed(void *parsed_result,
5984 __attribute__((unused)) struct cmdline *cl,
5985 __attribute__((unused)) void *data)
5988 uint16_t rx_mode = 0;
5989 struct cmd_set_vf_rxmode *res = parsed_result;
5991 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5992 if (!strcmp(res->what,"rxmode")) {
5993 if (!strcmp(res->mode, "AUPE"))
5994 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5995 else if (!strcmp(res->mode, "ROPE"))
5996 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5997 else if (!strcmp(res->mode, "BAM"))
5998 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5999 else if (!strncmp(res->mode, "MPE",3))
6000 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6003 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6005 printf("bad VF receive mode parameter, return code = %d \n",
6009 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6010 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6012 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6013 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6015 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6016 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6018 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6021 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6022 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6024 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6025 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6027 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6028 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6029 mode, "AUPE#ROPE#BAM#MPE");
6030 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6031 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6034 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6035 .f = cmd_set_vf_rxmode_parsed,
6037 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6039 (void *)&cmd_set_vf_rxmode_set,
6040 (void *)&cmd_set_vf_rxmode_port,
6041 (void *)&cmd_set_vf_rxmode_portid,
6042 (void *)&cmd_set_vf_rxmode_vf,
6043 (void *)&cmd_set_vf_rxmode_vfid,
6044 (void *)&cmd_set_vf_rxmode_what,
6045 (void *)&cmd_set_vf_rxmode_mode,
6046 (void *)&cmd_set_vf_rxmode_on,
6051 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6052 struct cmd_vf_mac_addr_result {
6053 cmdline_fixed_string_t mac_addr_cmd;
6054 cmdline_fixed_string_t what;
6055 cmdline_fixed_string_t port;
6057 cmdline_fixed_string_t vf;
6059 struct ether_addr address;
6062 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6063 __attribute__((unused)) struct cmdline *cl,
6064 __attribute__((unused)) void *data)
6066 struct cmd_vf_mac_addr_result *res = parsed_result;
6069 if (strcmp(res->what, "add") == 0)
6070 ret = rte_eth_dev_mac_addr_add(res->port_num,
6071 &res->address, res->vf_num);
6073 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6077 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6078 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6079 mac_addr_cmd,"mac_addr");
6080 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6081 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6083 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6084 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6086 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6087 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6089 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6090 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6092 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6093 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6095 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6096 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6099 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6100 .f = cmd_vf_mac_addr_parsed,
6102 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6103 "Y = VF number)add MAC address filtering for a VF on port X",
6105 (void *)&cmd_vf_mac_addr_cmd,
6106 (void *)&cmd_vf_mac_addr_what,
6107 (void *)&cmd_vf_mac_addr_port,
6108 (void *)&cmd_vf_mac_addr_portnum,
6109 (void *)&cmd_vf_mac_addr_vf,
6110 (void *)&cmd_vf_mac_addr_vfnum,
6111 (void *)&cmd_vf_mac_addr_addr,
6116 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6117 struct cmd_vf_rx_vlan_filter {
6118 cmdline_fixed_string_t rx_vlan;
6119 cmdline_fixed_string_t what;
6121 cmdline_fixed_string_t port;
6123 cmdline_fixed_string_t vf;
6128 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6129 __attribute__((unused)) struct cmdline *cl,
6130 __attribute__((unused)) void *data)
6132 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6134 if (!strcmp(res->what, "add"))
6135 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6137 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6140 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6141 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6142 rx_vlan, "rx_vlan");
6143 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6144 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6146 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6147 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6149 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6150 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6152 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6153 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6155 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6156 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6158 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6159 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6162 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6163 .f = cmd_vf_rx_vlan_filter_parsed,
6165 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6166 "Y = port number,Z = hexadecimal VF mask)",
6168 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6169 (void *)&cmd_vf_rx_vlan_filter_what,
6170 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6171 (void *)&cmd_vf_rx_vlan_filter_port,
6172 (void *)&cmd_vf_rx_vlan_filter_portid,
6173 (void *)&cmd_vf_rx_vlan_filter_vf,
6174 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6179 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6180 struct cmd_queue_rate_limit_result {
6181 cmdline_fixed_string_t set;
6182 cmdline_fixed_string_t port;
6184 cmdline_fixed_string_t queue;
6186 cmdline_fixed_string_t rate;
6190 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6191 __attribute__((unused)) struct cmdline *cl,
6192 __attribute__((unused)) void *data)
6194 struct cmd_queue_rate_limit_result *res = parsed_result;
6197 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6198 && (strcmp(res->queue, "queue") == 0)
6199 && (strcmp(res->rate, "rate") == 0))
6200 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6203 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6207 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6208 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6210 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6211 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6213 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6214 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6216 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6217 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6219 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6220 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6222 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6223 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6225 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6226 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6229 cmdline_parse_inst_t cmd_queue_rate_limit = {
6230 .f = cmd_queue_rate_limit_parsed,
6232 .help_str = "set port X queue Y rate Z:(X = port number,"
6233 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6235 (void *)&cmd_queue_rate_limit_set,
6236 (void *)&cmd_queue_rate_limit_port,
6237 (void *)&cmd_queue_rate_limit_portnum,
6238 (void *)&cmd_queue_rate_limit_queue,
6239 (void *)&cmd_queue_rate_limit_queuenum,
6240 (void *)&cmd_queue_rate_limit_rate,
6241 (void *)&cmd_queue_rate_limit_ratenum,
6246 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6247 struct cmd_vf_rate_limit_result {
6248 cmdline_fixed_string_t set;
6249 cmdline_fixed_string_t port;
6251 cmdline_fixed_string_t vf;
6253 cmdline_fixed_string_t rate;
6255 cmdline_fixed_string_t q_msk;
6259 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6260 __attribute__((unused)) struct cmdline *cl,
6261 __attribute__((unused)) void *data)
6263 struct cmd_vf_rate_limit_result *res = parsed_result;
6266 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6267 && (strcmp(res->vf, "vf") == 0)
6268 && (strcmp(res->rate, "rate") == 0)
6269 && (strcmp(res->q_msk, "queue_mask") == 0))
6270 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6271 res->rate_num, res->q_msk_val);
6273 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6277 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6278 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6280 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6281 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6283 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6284 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6286 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6287 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6289 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6290 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6292 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6293 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6295 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6296 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6298 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6299 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6300 q_msk, "queue_mask");
6301 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6302 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6305 cmdline_parse_inst_t cmd_vf_rate_limit = {
6306 .f = cmd_vf_rate_limit_parsed,
6308 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6309 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6310 "for queues of VF on port X",
6312 (void *)&cmd_vf_rate_limit_set,
6313 (void *)&cmd_vf_rate_limit_port,
6314 (void *)&cmd_vf_rate_limit_portnum,
6315 (void *)&cmd_vf_rate_limit_vf,
6316 (void *)&cmd_vf_rate_limit_vfnum,
6317 (void *)&cmd_vf_rate_limit_rate,
6318 (void *)&cmd_vf_rate_limit_ratenum,
6319 (void *)&cmd_vf_rate_limit_q_msk,
6320 (void *)&cmd_vf_rate_limit_q_msk_val,
6325 /* *** ADD TUNNEL FILTER OF A PORT *** */
6326 struct cmd_tunnel_filter_result {
6327 cmdline_fixed_string_t cmd;
6328 cmdline_fixed_string_t what;
6330 struct ether_addr outer_mac;
6331 struct ether_addr inner_mac;
6332 cmdline_ipaddr_t ip_value;
6333 uint16_t inner_vlan;
6334 cmdline_fixed_string_t tunnel_type;
6335 cmdline_fixed_string_t filter_type;
6341 cmd_tunnel_filter_parsed(void *parsed_result,
6342 __attribute__((unused)) struct cmdline *cl,
6343 __attribute__((unused)) void *data)
6345 struct cmd_tunnel_filter_result *res = parsed_result;
6346 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6349 tunnel_filter_conf.outer_mac = &res->outer_mac;
6350 tunnel_filter_conf.inner_mac = &res->inner_mac;
6351 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6353 if (res->ip_value.family == AF_INET) {
6354 tunnel_filter_conf.ip_addr.ipv4_addr =
6355 res->ip_value.addr.ipv4.s_addr;
6356 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6358 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6359 &(res->ip_value.addr.ipv6),
6360 sizeof(struct in6_addr));
6361 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6364 if (!strcmp(res->filter_type, "imac-ivlan"))
6365 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6366 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6367 tunnel_filter_conf.filter_type =
6368 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6369 else if (!strcmp(res->filter_type, "imac-tenid"))
6370 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6371 else if (!strcmp(res->filter_type, "imac"))
6372 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6373 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6374 tunnel_filter_conf.filter_type =
6375 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6377 printf("The filter type is not supported");
6381 if (!strcmp(res->tunnel_type, "vxlan"))
6382 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6383 else if (!strcmp(res->tunnel_type, "nvgre"))
6384 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6386 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6390 tunnel_filter_conf.tenant_id = res->tenant_id;
6391 tunnel_filter_conf.queue_id = res->queue_num;
6392 if (!strcmp(res->what, "add"))
6393 ret = rte_eth_dev_filter_ctrl(res->port_id,
6394 RTE_ETH_FILTER_TUNNEL,
6396 &tunnel_filter_conf);
6398 ret = rte_eth_dev_filter_ctrl(res->port_id,
6399 RTE_ETH_FILTER_TUNNEL,
6400 RTE_ETH_FILTER_DELETE,
6401 &tunnel_filter_conf);
6403 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6407 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6408 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6409 cmd, "tunnel_filter");
6410 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6411 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6413 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6414 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6416 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6417 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6419 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6420 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6422 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6423 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6424 inner_vlan, UINT16);
6425 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6426 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6428 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6429 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6430 tunnel_type, "vxlan#nvgre");
6432 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6433 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6434 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6435 "imac#omac-imac-tenid");
6436 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6437 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6439 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6440 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6443 cmdline_parse_inst_t cmd_tunnel_filter = {
6444 .f = cmd_tunnel_filter_parsed,
6446 .help_str = "add/rm tunnel filter of a port: "
6447 "tunnel_filter add port_id outer_mac inner_mac ip "
6448 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6449 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6450 "imac|omac-imac-tenid) "
6451 "tenant_id queue_num",
6453 (void *)&cmd_tunnel_filter_cmd,
6454 (void *)&cmd_tunnel_filter_what,
6455 (void *)&cmd_tunnel_filter_port_id,
6456 (void *)&cmd_tunnel_filter_outer_mac,
6457 (void *)&cmd_tunnel_filter_inner_mac,
6458 (void *)&cmd_tunnel_filter_ip_value,
6459 (void *)&cmd_tunnel_filter_innner_vlan,
6460 (void *)&cmd_tunnel_filter_tunnel_type,
6461 (void *)&cmd_tunnel_filter_filter_type,
6462 (void *)&cmd_tunnel_filter_tenant_id,
6463 (void *)&cmd_tunnel_filter_queue_num,
6468 /* *** CONFIGURE TUNNEL UDP PORT *** */
6469 struct cmd_tunnel_udp_config {
6470 cmdline_fixed_string_t cmd;
6471 cmdline_fixed_string_t what;
6477 cmd_tunnel_udp_config_parsed(void *parsed_result,
6478 __attribute__((unused)) struct cmdline *cl,
6479 __attribute__((unused)) void *data)
6481 struct cmd_tunnel_udp_config *res = parsed_result;
6482 struct rte_eth_udp_tunnel tunnel_udp;
6485 tunnel_udp.udp_port = res->udp_port;
6487 if (!strcmp(res->cmd, "rx_vxlan_port"))
6488 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6490 if (!strcmp(res->what, "add"))
6491 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6493 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6496 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6499 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6500 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6501 cmd, "rx_vxlan_port");
6502 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6503 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6505 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6506 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6508 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6509 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6512 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6513 .f = cmd_tunnel_udp_config_parsed,
6515 .help_str = "add/rm an tunneling UDP port filter: "
6516 "rx_vxlan_port add udp_port port_id",
6518 (void *)&cmd_tunnel_udp_config_cmd,
6519 (void *)&cmd_tunnel_udp_config_what,
6520 (void *)&cmd_tunnel_udp_config_udp_port,
6521 (void *)&cmd_tunnel_udp_config_port_id,
6526 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6527 struct cmd_set_mirror_mask_result {
6528 cmdline_fixed_string_t set;
6529 cmdline_fixed_string_t port;
6531 cmdline_fixed_string_t mirror;
6533 cmdline_fixed_string_t what;
6534 cmdline_fixed_string_t value;
6535 cmdline_fixed_string_t dstpool;
6537 cmdline_fixed_string_t on;
6540 cmdline_parse_token_string_t cmd_mirror_mask_set =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6543 cmdline_parse_token_string_t cmd_mirror_mask_port =
6544 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6546 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6547 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6549 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6550 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6551 mirror, "mirror-rule");
6552 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6553 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6555 cmdline_parse_token_string_t cmd_mirror_mask_what =
6556 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6557 what, "pool-mirror#vlan-mirror");
6558 cmdline_parse_token_string_t cmd_mirror_mask_value =
6559 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6561 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6562 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6563 dstpool, "dst-pool");
6564 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6565 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6567 cmdline_parse_token_string_t cmd_mirror_mask_on =
6568 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6572 cmd_set_mirror_mask_parsed(void *parsed_result,
6573 __attribute__((unused)) struct cmdline *cl,
6574 __attribute__((unused)) void *data)
6577 struct cmd_set_mirror_mask_result *res = parsed_result;
6578 struct rte_eth_vmdq_mirror_conf mr_conf;
6580 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6582 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6584 mr_conf.dst_pool = res->dstpool_id;
6586 if (!strcmp(res->what, "pool-mirror")) {
6587 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6588 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6589 } else if(!strcmp(res->what, "vlan-mirror")) {
6590 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6591 nb_item = parse_item_list(res->value, "core",
6592 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6596 for(i=0; i < nb_item; i++) {
6597 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6598 printf("Invalid vlan_id: must be < 4096\n");
6602 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6603 mr_conf.vlan.vlan_mask |= 1ULL << i;
6607 if(!strcmp(res->on, "on"))
6608 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6611 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6614 printf("mirror rule add error: (%s)\n", strerror(-ret));
6617 cmdline_parse_inst_t cmd_set_mirror_mask = {
6618 .f = cmd_set_mirror_mask_parsed,
6620 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6621 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6623 (void *)&cmd_mirror_mask_set,
6624 (void *)&cmd_mirror_mask_port,
6625 (void *)&cmd_mirror_mask_portid,
6626 (void *)&cmd_mirror_mask_mirror,
6627 (void *)&cmd_mirror_mask_ruleid,
6628 (void *)&cmd_mirror_mask_what,
6629 (void *)&cmd_mirror_mask_value,
6630 (void *)&cmd_mirror_mask_dstpool,
6631 (void *)&cmd_mirror_mask_poolid,
6632 (void *)&cmd_mirror_mask_on,
6637 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6638 struct cmd_set_mirror_link_result {
6639 cmdline_fixed_string_t set;
6640 cmdline_fixed_string_t port;
6642 cmdline_fixed_string_t mirror;
6644 cmdline_fixed_string_t what;
6645 cmdline_fixed_string_t dstpool;
6647 cmdline_fixed_string_t on;
6650 cmdline_parse_token_string_t cmd_mirror_link_set =
6651 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6653 cmdline_parse_token_string_t cmd_mirror_link_port =
6654 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6656 cmdline_parse_token_num_t cmd_mirror_link_portid =
6657 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6659 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6660 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6661 mirror, "mirror-rule");
6662 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6663 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6665 cmdline_parse_token_string_t cmd_mirror_link_what =
6666 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6667 what, "uplink-mirror#downlink-mirror");
6668 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6670 dstpool, "dst-pool");
6671 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6672 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6674 cmdline_parse_token_string_t cmd_mirror_link_on =
6675 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6679 cmd_set_mirror_link_parsed(void *parsed_result,
6680 __attribute__((unused)) struct cmdline *cl,
6681 __attribute__((unused)) void *data)
6684 struct cmd_set_mirror_link_result *res = parsed_result;
6685 struct rte_eth_vmdq_mirror_conf mr_conf;
6687 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6688 if(!strcmp(res->what, "uplink-mirror")) {
6689 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6690 }else if(!strcmp(res->what, "downlink-mirror"))
6691 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6693 mr_conf.dst_pool = res->dstpool_id;
6695 if(!strcmp(res->on, "on"))
6696 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6699 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6702 /* check the return value and print it if is < 0 */
6704 printf("mirror rule add error: (%s)\n", strerror(-ret));
6708 cmdline_parse_inst_t cmd_set_mirror_link = {
6709 .f = cmd_set_mirror_link_parsed,
6711 .help_str = "set port X mirror-rule Y uplink-mirror|"
6712 "downlink-mirror dst-pool Z on|off",
6714 (void *)&cmd_mirror_link_set,
6715 (void *)&cmd_mirror_link_port,
6716 (void *)&cmd_mirror_link_portid,
6717 (void *)&cmd_mirror_link_mirror,
6718 (void *)&cmd_mirror_link_ruleid,
6719 (void *)&cmd_mirror_link_what,
6720 (void *)&cmd_mirror_link_dstpool,
6721 (void *)&cmd_mirror_link_poolid,
6722 (void *)&cmd_mirror_link_on,
6727 /* *** RESET VM MIRROR RULE *** */
6728 struct cmd_rm_mirror_rule_result {
6729 cmdline_fixed_string_t reset;
6730 cmdline_fixed_string_t port;
6732 cmdline_fixed_string_t mirror;
6736 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6737 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6739 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6740 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6742 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6743 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6745 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6746 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6747 mirror, "mirror-rule");
6748 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6749 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6753 cmd_reset_mirror_rule_parsed(void *parsed_result,
6754 __attribute__((unused)) struct cmdline *cl,
6755 __attribute__((unused)) void *data)
6758 struct cmd_set_mirror_link_result *res = parsed_result;
6760 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6762 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6765 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6766 .f = cmd_reset_mirror_rule_parsed,
6768 .help_str = "reset port X mirror-rule Y",
6770 (void *)&cmd_rm_mirror_rule_reset,
6771 (void *)&cmd_rm_mirror_rule_port,
6772 (void *)&cmd_rm_mirror_rule_portid,
6773 (void *)&cmd_rm_mirror_rule_mirror,
6774 (void *)&cmd_rm_mirror_rule_ruleid,
6779 /* ******************************************************************************** */
6781 struct cmd_dump_result {
6782 cmdline_fixed_string_t dump;
6786 dump_struct_sizes(void)
6788 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6789 DUMP_SIZE(struct rte_mbuf);
6790 DUMP_SIZE(struct rte_mempool);
6791 DUMP_SIZE(struct rte_ring);
6795 static void cmd_dump_parsed(void *parsed_result,
6796 __attribute__((unused)) struct cmdline *cl,
6797 __attribute__((unused)) void *data)
6799 struct cmd_dump_result *res = parsed_result;
6801 if (!strcmp(res->dump, "dump_physmem"))
6802 rte_dump_physmem_layout(stdout);
6803 else if (!strcmp(res->dump, "dump_memzone"))
6804 rte_memzone_dump(stdout);
6805 else if (!strcmp(res->dump, "dump_log_history"))
6806 rte_log_dump_history(stdout);
6807 else if (!strcmp(res->dump, "dump_struct_sizes"))
6808 dump_struct_sizes();
6809 else if (!strcmp(res->dump, "dump_ring"))
6810 rte_ring_list_dump(stdout);
6811 else if (!strcmp(res->dump, "dump_mempool"))
6812 rte_mempool_list_dump(stdout);
6813 else if (!strcmp(res->dump, "dump_devargs"))
6814 rte_eal_devargs_dump(stdout);
6817 cmdline_parse_token_string_t cmd_dump_dump =
6818 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6822 "dump_struct_sizes#"
6827 cmdline_parse_inst_t cmd_dump = {
6828 .f = cmd_dump_parsed, /* function to call */
6829 .data = NULL, /* 2nd arg of func */
6830 .help_str = "dump status",
6831 .tokens = { /* token list, NULL terminated */
6832 (void *)&cmd_dump_dump,
6837 /* ******************************************************************************** */
6839 struct cmd_dump_one_result {
6840 cmdline_fixed_string_t dump;
6841 cmdline_fixed_string_t name;
6844 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6845 __attribute__((unused)) void *data)
6847 struct cmd_dump_one_result *res = parsed_result;
6849 if (!strcmp(res->dump, "dump_ring")) {
6851 r = rte_ring_lookup(res->name);
6853 cmdline_printf(cl, "Cannot find ring\n");
6856 rte_ring_dump(stdout, r);
6857 } else if (!strcmp(res->dump, "dump_mempool")) {
6858 struct rte_mempool *mp;
6859 mp = rte_mempool_lookup(res->name);
6861 cmdline_printf(cl, "Cannot find mempool\n");
6864 rte_mempool_dump(stdout, mp);
6868 cmdline_parse_token_string_t cmd_dump_one_dump =
6869 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6870 "dump_ring#dump_mempool");
6872 cmdline_parse_token_string_t cmd_dump_one_name =
6873 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6875 cmdline_parse_inst_t cmd_dump_one = {
6876 .f = cmd_dump_one_parsed, /* function to call */
6877 .data = NULL, /* 2nd arg of func */
6878 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6879 .tokens = { /* token list, NULL terminated */
6880 (void *)&cmd_dump_one_dump,
6881 (void *)&cmd_dump_one_name,
6886 /* *** Add/Del syn filter *** */
6887 struct cmd_syn_filter_result {
6888 cmdline_fixed_string_t filter;
6890 cmdline_fixed_string_t ops;
6891 cmdline_fixed_string_t priority;
6892 cmdline_fixed_string_t high;
6893 cmdline_fixed_string_t queue;
6898 cmd_syn_filter_parsed(void *parsed_result,
6899 __attribute__((unused)) struct cmdline *cl,
6900 __attribute__((unused)) void *data)
6902 struct cmd_syn_filter_result *res = parsed_result;
6903 struct rte_eth_syn_filter syn_filter;
6906 ret = rte_eth_dev_filter_supported(res->port_id,
6907 RTE_ETH_FILTER_SYN);
6909 printf("syn filter is not supported on port %u.\n",
6914 memset(&syn_filter, 0, sizeof(syn_filter));
6916 if (!strcmp(res->ops, "add")) {
6917 if (!strcmp(res->high, "high"))
6918 syn_filter.hig_pri = 1;
6920 syn_filter.hig_pri = 0;
6922 syn_filter.queue = res->queue_id;
6923 ret = rte_eth_dev_filter_ctrl(res->port_id,
6928 ret = rte_eth_dev_filter_ctrl(res->port_id,
6930 RTE_ETH_FILTER_DELETE,
6934 printf("syn filter programming error: (%s)\n",
6938 cmdline_parse_token_string_t cmd_syn_filter_filter =
6939 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6940 filter, "syn_filter");
6941 cmdline_parse_token_num_t cmd_syn_filter_port_id =
6942 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6944 cmdline_parse_token_string_t cmd_syn_filter_ops =
6945 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6947 cmdline_parse_token_string_t cmd_syn_filter_priority =
6948 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6949 priority, "priority");
6950 cmdline_parse_token_string_t cmd_syn_filter_high =
6951 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6953 cmdline_parse_token_string_t cmd_syn_filter_queue =
6954 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6956 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6957 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6960 cmdline_parse_inst_t cmd_syn_filter = {
6961 .f = cmd_syn_filter_parsed,
6963 .help_str = "add/delete syn filter",
6965 (void *)&cmd_syn_filter_filter,
6966 (void *)&cmd_syn_filter_port_id,
6967 (void *)&cmd_syn_filter_ops,
6968 (void *)&cmd_syn_filter_priority,
6969 (void *)&cmd_syn_filter_high,
6970 (void *)&cmd_syn_filter_queue,
6971 (void *)&cmd_syn_filter_queue_id,
6976 /* *** ADD/REMOVE A 2tuple FILTER *** */
6977 struct cmd_2tuple_filter_result {
6978 cmdline_fixed_string_t filter;
6980 cmdline_fixed_string_t ops;
6981 cmdline_fixed_string_t dst_port;
6982 uint16_t dst_port_value;
6983 cmdline_fixed_string_t protocol;
6984 uint8_t protocol_value;
6985 cmdline_fixed_string_t mask;
6987 cmdline_fixed_string_t tcp_flags;
6988 uint8_t tcp_flags_value;
6989 cmdline_fixed_string_t priority;
6990 uint8_t priority_value;
6991 cmdline_fixed_string_t queue;
6996 cmd_2tuple_filter_parsed(void *parsed_result,
6997 __attribute__((unused)) struct cmdline *cl,
6998 __attribute__((unused)) void *data)
7000 struct rte_eth_ntuple_filter filter;
7001 struct cmd_2tuple_filter_result *res = parsed_result;
7004 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7006 printf("ntuple filter is not supported on port %u.\n",
7011 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7013 filter.flags = RTE_2TUPLE_FLAGS;
7014 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7015 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7016 filter.proto = res->protocol_value;
7017 filter.priority = res->priority_value;
7018 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7019 printf("nonzero tcp_flags is only meaningful"
7020 " when protocol is TCP.\n");
7023 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7024 printf("invalid TCP flags.\n");
7028 if (res->tcp_flags_value != 0) {
7029 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7030 filter.tcp_flags = res->tcp_flags_value;
7033 /* need convert to big endian. */
7034 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7035 filter.queue = res->queue_id;
7037 if (!strcmp(res->ops, "add"))
7038 ret = rte_eth_dev_filter_ctrl(res->port_id,
7039 RTE_ETH_FILTER_NTUPLE,
7043 ret = rte_eth_dev_filter_ctrl(res->port_id,
7044 RTE_ETH_FILTER_NTUPLE,
7045 RTE_ETH_FILTER_DELETE,
7048 printf("2tuple filter programming error: (%s)\n",
7053 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7054 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7055 filter, "2tuple_filter");
7056 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7057 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7059 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7060 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7062 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7063 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7064 dst_port, "dst_port");
7065 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7066 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7067 dst_port_value, UINT16);
7068 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7069 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7070 protocol, "protocol");
7071 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7072 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7073 protocol_value, UINT8);
7074 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7075 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7077 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7078 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7080 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7081 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7082 tcp_flags, "tcp_flags");
7083 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7084 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7085 tcp_flags_value, UINT8);
7086 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7087 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7088 priority, "priority");
7089 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7090 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7091 priority_value, UINT8);
7092 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7093 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7095 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7096 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7099 cmdline_parse_inst_t cmd_2tuple_filter = {
7100 .f = cmd_2tuple_filter_parsed,
7102 .help_str = "add a 2tuple filter",
7104 (void *)&cmd_2tuple_filter_filter,
7105 (void *)&cmd_2tuple_filter_port_id,
7106 (void *)&cmd_2tuple_filter_ops,
7107 (void *)&cmd_2tuple_filter_dst_port,
7108 (void *)&cmd_2tuple_filter_dst_port_value,
7109 (void *)&cmd_2tuple_filter_protocol,
7110 (void *)&cmd_2tuple_filter_protocol_value,
7111 (void *)&cmd_2tuple_filter_mask,
7112 (void *)&cmd_2tuple_filter_mask_value,
7113 (void *)&cmd_2tuple_filter_tcp_flags,
7114 (void *)&cmd_2tuple_filter_tcp_flags_value,
7115 (void *)&cmd_2tuple_filter_priority,
7116 (void *)&cmd_2tuple_filter_priority_value,
7117 (void *)&cmd_2tuple_filter_queue,
7118 (void *)&cmd_2tuple_filter_queue_id,
7123 /* *** ADD/REMOVE A 5tuple FILTER *** */
7124 struct cmd_5tuple_filter_result {
7125 cmdline_fixed_string_t filter;
7127 cmdline_fixed_string_t ops;
7128 cmdline_fixed_string_t dst_ip;
7129 cmdline_ipaddr_t dst_ip_value;
7130 cmdline_fixed_string_t src_ip;
7131 cmdline_ipaddr_t src_ip_value;
7132 cmdline_fixed_string_t dst_port;
7133 uint16_t dst_port_value;
7134 cmdline_fixed_string_t src_port;
7135 uint16_t src_port_value;
7136 cmdline_fixed_string_t protocol;
7137 uint8_t protocol_value;
7138 cmdline_fixed_string_t mask;
7140 cmdline_fixed_string_t tcp_flags;
7141 uint8_t tcp_flags_value;
7142 cmdline_fixed_string_t priority;
7143 uint8_t priority_value;
7144 cmdline_fixed_string_t queue;
7149 cmd_5tuple_filter_parsed(void *parsed_result,
7150 __attribute__((unused)) struct cmdline *cl,
7151 __attribute__((unused)) void *data)
7153 struct rte_eth_ntuple_filter filter;
7154 struct cmd_5tuple_filter_result *res = parsed_result;
7157 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7159 printf("ntuple filter is not supported on port %u.\n",
7164 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7166 filter.flags = RTE_5TUPLE_FLAGS;
7167 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7168 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7169 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7170 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7171 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7172 filter.proto = res->protocol_value;
7173 filter.priority = res->priority_value;
7174 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7175 printf("nonzero tcp_flags is only meaningful"
7176 " when protocol is TCP.\n");
7179 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7180 printf("invalid TCP flags.\n");
7184 if (res->tcp_flags_value != 0) {
7185 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7186 filter.tcp_flags = res->tcp_flags_value;
7189 if (res->dst_ip_value.family == AF_INET)
7190 /* no need to convert, already big endian. */
7191 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7193 if (filter.dst_ip_mask == 0) {
7194 printf("can not support ipv6 involved compare.\n");
7200 if (res->src_ip_value.family == AF_INET)
7201 /* no need to convert, already big endian. */
7202 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7204 if (filter.src_ip_mask == 0) {
7205 printf("can not support ipv6 involved compare.\n");
7210 /* need convert to big endian. */
7211 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7212 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7213 filter.queue = res->queue_id;
7215 if (!strcmp(res->ops, "add"))
7216 ret = rte_eth_dev_filter_ctrl(res->port_id,
7217 RTE_ETH_FILTER_NTUPLE,
7221 ret = rte_eth_dev_filter_ctrl(res->port_id,
7222 RTE_ETH_FILTER_NTUPLE,
7223 RTE_ETH_FILTER_DELETE,
7226 printf("5tuple filter programming error: (%s)\n",
7230 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7231 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7232 filter, "5tuple_filter");
7233 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7234 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7236 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7237 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7239 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7240 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7242 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7243 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7245 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7246 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7248 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7249 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7251 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7252 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7253 dst_port, "dst_port");
7254 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7255 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7256 dst_port_value, UINT16);
7257 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7258 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7259 src_port, "src_port");
7260 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7261 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7262 src_port_value, UINT16);
7263 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7264 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7265 protocol, "protocol");
7266 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7267 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7268 protocol_value, UINT8);
7269 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7270 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7272 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7273 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7275 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7276 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7277 tcp_flags, "tcp_flags");
7278 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7279 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7280 tcp_flags_value, UINT8);
7281 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7282 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7283 priority, "priority");
7284 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7285 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7286 priority_value, UINT8);
7287 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7288 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7290 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7291 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7294 cmdline_parse_inst_t cmd_5tuple_filter = {
7295 .f = cmd_5tuple_filter_parsed,
7297 .help_str = "add/del a 5tuple filter",
7299 (void *)&cmd_5tuple_filter_filter,
7300 (void *)&cmd_5tuple_filter_port_id,
7301 (void *)&cmd_5tuple_filter_ops,
7302 (void *)&cmd_5tuple_filter_dst_ip,
7303 (void *)&cmd_5tuple_filter_dst_ip_value,
7304 (void *)&cmd_5tuple_filter_src_ip,
7305 (void *)&cmd_5tuple_filter_src_ip_value,
7306 (void *)&cmd_5tuple_filter_dst_port,
7307 (void *)&cmd_5tuple_filter_dst_port_value,
7308 (void *)&cmd_5tuple_filter_src_port,
7309 (void *)&cmd_5tuple_filter_src_port_value,
7310 (void *)&cmd_5tuple_filter_protocol,
7311 (void *)&cmd_5tuple_filter_protocol_value,
7312 (void *)&cmd_5tuple_filter_mask,
7313 (void *)&cmd_5tuple_filter_mask_value,
7314 (void *)&cmd_5tuple_filter_tcp_flags,
7315 (void *)&cmd_5tuple_filter_tcp_flags_value,
7316 (void *)&cmd_5tuple_filter_priority,
7317 (void *)&cmd_5tuple_filter_priority_value,
7318 (void *)&cmd_5tuple_filter_queue,
7319 (void *)&cmd_5tuple_filter_queue_id,
7324 /* *** ADD/REMOVE A flex FILTER *** */
7325 struct cmd_flex_filter_result {
7326 cmdline_fixed_string_t filter;
7327 cmdline_fixed_string_t ops;
7329 cmdline_fixed_string_t len;
7331 cmdline_fixed_string_t bytes;
7332 cmdline_fixed_string_t bytes_value;
7333 cmdline_fixed_string_t mask;
7334 cmdline_fixed_string_t mask_value;
7335 cmdline_fixed_string_t priority;
7336 uint8_t priority_value;
7337 cmdline_fixed_string_t queue;
7341 static int xdigit2val(unsigned char c)
7346 else if (isupper(c))
7354 cmd_flex_filter_parsed(void *parsed_result,
7355 __attribute__((unused)) struct cmdline *cl,
7356 __attribute__((unused)) void *data)
7359 struct rte_eth_flex_filter filter;
7360 struct cmd_flex_filter_result *res = parsed_result;
7361 char *bytes_ptr, *mask_ptr;
7362 uint16_t len, i, j = 0;
7367 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7368 printf("the len exceed the max length 128\n");
7371 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7372 filter.len = res->len_value;
7373 filter.priority = res->priority_value;
7374 filter.queue = res->queue_id;
7375 bytes_ptr = res->bytes_value;
7376 mask_ptr = res->mask_value;
7378 /* translate bytes string to array. */
7379 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7380 (bytes_ptr[1] == 'X')))
7382 len = strnlen(bytes_ptr, res->len_value * 2);
7383 if (len == 0 || (len % 8 != 0)) {
7384 printf("please check len and bytes input\n");
7387 for (i = 0; i < len; i++) {
7389 if (isxdigit(c) == 0) {
7390 /* invalid characters. */
7391 printf("invalid input\n");
7394 val = xdigit2val(c);
7397 filter.bytes[j] = byte;
7398 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7405 /* translate mask string to uint8_t array. */
7406 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7407 (mask_ptr[1] == 'X')))
7409 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7411 printf("invalid input\n");
7416 for (i = 0; i < len; i++) {
7418 if (isxdigit(c) == 0) {
7419 /* invalid characters. */
7420 printf("invalid input\n");
7423 val = xdigit2val(c);
7426 filter.mask[j] = byte;
7427 printf("mask[%d]:%02x ", j, filter.mask[j]);
7435 if (!strcmp(res->ops, "add"))
7436 ret = rte_eth_dev_filter_ctrl(res->port_id,
7437 RTE_ETH_FILTER_FLEXIBLE,
7441 ret = rte_eth_dev_filter_ctrl(res->port_id,
7442 RTE_ETH_FILTER_FLEXIBLE,
7443 RTE_ETH_FILTER_DELETE,
7447 printf("flex filter setting error: (%s)\n", strerror(-ret));
7450 cmdline_parse_token_string_t cmd_flex_filter_filter =
7451 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7452 filter, "flex_filter");
7453 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7454 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7456 cmdline_parse_token_string_t cmd_flex_filter_ops =
7457 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7459 cmdline_parse_token_string_t cmd_flex_filter_len =
7460 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7462 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7463 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7465 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7466 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7468 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7469 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7471 cmdline_parse_token_string_t cmd_flex_filter_mask =
7472 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7474 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7475 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7477 cmdline_parse_token_string_t cmd_flex_filter_priority =
7478 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7479 priority, "priority");
7480 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7481 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7482 priority_value, UINT8);
7483 cmdline_parse_token_string_t cmd_flex_filter_queue =
7484 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7486 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7487 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7489 cmdline_parse_inst_t cmd_flex_filter = {
7490 .f = cmd_flex_filter_parsed,
7492 .help_str = "add/del a flex filter",
7494 (void *)&cmd_flex_filter_filter,
7495 (void *)&cmd_flex_filter_port_id,
7496 (void *)&cmd_flex_filter_ops,
7497 (void *)&cmd_flex_filter_len,
7498 (void *)&cmd_flex_filter_len_value,
7499 (void *)&cmd_flex_filter_bytes,
7500 (void *)&cmd_flex_filter_bytes_value,
7501 (void *)&cmd_flex_filter_mask,
7502 (void *)&cmd_flex_filter_mask_value,
7503 (void *)&cmd_flex_filter_priority,
7504 (void *)&cmd_flex_filter_priority_value,
7505 (void *)&cmd_flex_filter_queue,
7506 (void *)&cmd_flex_filter_queue_id,
7511 /* *** Filters Control *** */
7513 /* *** deal with ethertype filter *** */
7514 struct cmd_ethertype_filter_result {
7515 cmdline_fixed_string_t filter;
7517 cmdline_fixed_string_t ops;
7518 cmdline_fixed_string_t mac;
7519 struct ether_addr mac_addr;
7520 cmdline_fixed_string_t ethertype;
7521 uint16_t ethertype_value;
7522 cmdline_fixed_string_t drop;
7523 cmdline_fixed_string_t queue;
7527 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7528 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7529 filter, "ethertype_filter");
7530 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7531 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7533 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7534 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7536 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7537 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7538 mac, "mac_addr#mac_ignr");
7539 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7540 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7542 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7543 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7544 ethertype, "ethertype");
7545 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7546 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7547 ethertype_value, UINT16);
7548 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7549 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7551 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7552 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7554 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7555 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7559 cmd_ethertype_filter_parsed(void *parsed_result,
7560 __attribute__((unused)) struct cmdline *cl,
7561 __attribute__((unused)) void *data)
7563 struct cmd_ethertype_filter_result *res = parsed_result;
7564 struct rte_eth_ethertype_filter filter;
7567 ret = rte_eth_dev_filter_supported(res->port_id,
7568 RTE_ETH_FILTER_ETHERTYPE);
7570 printf("ethertype filter is not supported on port %u.\n",
7575 memset(&filter, 0, sizeof(filter));
7576 if (!strcmp(res->mac, "mac_addr")) {
7577 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7578 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7579 sizeof(struct ether_addr));
7581 if (!strcmp(res->drop, "drop"))
7582 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7583 filter.ether_type = res->ethertype_value;
7584 filter.queue = res->queue_id;
7586 if (!strcmp(res->ops, "add"))
7587 ret = rte_eth_dev_filter_ctrl(res->port_id,
7588 RTE_ETH_FILTER_ETHERTYPE,
7592 ret = rte_eth_dev_filter_ctrl(res->port_id,
7593 RTE_ETH_FILTER_ETHERTYPE,
7594 RTE_ETH_FILTER_DELETE,
7597 printf("ethertype filter programming error: (%s)\n",
7601 cmdline_parse_inst_t cmd_ethertype_filter = {
7602 .f = cmd_ethertype_filter_parsed,
7604 .help_str = "add or delete an ethertype filter entry",
7606 (void *)&cmd_ethertype_filter_filter,
7607 (void *)&cmd_ethertype_filter_port_id,
7608 (void *)&cmd_ethertype_filter_ops,
7609 (void *)&cmd_ethertype_filter_mac,
7610 (void *)&cmd_ethertype_filter_mac_addr,
7611 (void *)&cmd_ethertype_filter_ethertype,
7612 (void *)&cmd_ethertype_filter_ethertype_value,
7613 (void *)&cmd_ethertype_filter_drop,
7614 (void *)&cmd_ethertype_filter_queue,
7615 (void *)&cmd_ethertype_filter_queue_id,
7620 /* *** deal with flow director filter *** */
7621 struct cmd_flow_director_result {
7622 cmdline_fixed_string_t flow_director_filter;
7624 cmdline_fixed_string_t ops;
7625 cmdline_fixed_string_t flow;
7626 cmdline_fixed_string_t flow_type;
7627 cmdline_fixed_string_t src;
7628 cmdline_ipaddr_t ip_src;
7630 cmdline_fixed_string_t dst;
7631 cmdline_ipaddr_t ip_dst;
7633 cmdline_fixed_string_t verify_tag;
7634 uint32_t verify_tag_value;
7635 cmdline_fixed_string_t vlan;
7636 uint16_t vlan_value;
7637 cmdline_fixed_string_t flexbytes;
7638 cmdline_fixed_string_t flexbytes_value;
7639 cmdline_fixed_string_t drop;
7640 cmdline_fixed_string_t queue;
7642 cmdline_fixed_string_t fd_id;
7643 uint32_t fd_id_value;
7647 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7650 const char *p, *p0 = q_arg;
7652 unsigned long int_fld;
7653 char *str_fld[max_num];
7658 p = strchr(p0, '(');
7662 p0 = strchr(p, ')');
7667 if (size >= sizeof(s))
7670 snprintf(s, sizeof(s), "%.*s", size, p);
7671 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7672 if (ret < 0 || ret > max_num)
7674 for (i = 0; i < ret; i++) {
7676 int_fld = strtoul(str_fld[i], &end, 0);
7677 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7679 flexbytes[i] = (uint8_t)int_fld;
7685 str2flowtype(char *string)
7688 static const struct {
7691 } flowtype_str[] = {
7692 {"raw", RTE_ETH_FLOW_RAW},
7693 {"ipv4", RTE_ETH_FLOW_IPV4},
7694 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
7695 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
7696 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
7697 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
7698 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
7699 {"ipv6", RTE_ETH_FLOW_IPV6},
7700 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
7701 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
7702 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
7703 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
7704 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
7705 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
7708 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7709 if (!strcmp(flowtype_str[i].str, string))
7710 return flowtype_str[i].type;
7712 return RTE_ETH_FLOW_UNKNOWN;
7715 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7717 if ((ip_addr).family == AF_INET) \
7718 (ip) = (ip_addr).addr.ipv4.s_addr; \
7720 printf("invalid parameter.\n"); \
7725 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7727 if ((ip_addr).family == AF_INET6) \
7728 (void)rte_memcpy(&(ip), \
7729 &((ip_addr).addr.ipv6), \
7730 sizeof(struct in6_addr)); \
7732 printf("invalid parameter.\n"); \
7738 cmd_flow_director_filter_parsed(void *parsed_result,
7739 __attribute__((unused)) struct cmdline *cl,
7740 __attribute__((unused)) void *data)
7742 struct cmd_flow_director_result *res = parsed_result;
7743 struct rte_eth_fdir_filter entry;
7744 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7747 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7749 printf("flow director is not supported on port %u.\n",
7753 memset(flexbytes, 0, sizeof(flexbytes));
7754 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7755 ret = parse_flexbytes(res->flexbytes_value,
7757 RTE_ETH_FDIR_MAX_FLEXLEN);
7759 printf("error: Cannot parse flexbytes input.\n");
7763 entry.input.flow_type = str2flowtype(res->flow_type);
7764 switch (entry.input.flow_type) {
7765 case RTE_ETH_FLOW_FRAG_IPV4:
7766 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
7767 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
7768 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
7769 IPV4_ADDR_TO_UINT(res->ip_dst,
7770 entry.input.flow.ip4_flow.dst_ip);
7771 IPV4_ADDR_TO_UINT(res->ip_src,
7772 entry.input.flow.ip4_flow.src_ip);
7773 /* need convert to big endian. */
7774 entry.input.flow.udp4_flow.dst_port =
7775 rte_cpu_to_be_16(res->port_dst);
7776 entry.input.flow.udp4_flow.src_port =
7777 rte_cpu_to_be_16(res->port_src);
7779 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
7780 IPV4_ADDR_TO_UINT(res->ip_dst,
7781 entry.input.flow.sctp4_flow.ip.dst_ip);
7782 IPV4_ADDR_TO_UINT(res->ip_src,
7783 entry.input.flow.sctp4_flow.ip.src_ip);
7784 /* need convert to big endian. */
7785 entry.input.flow.sctp4_flow.verify_tag =
7786 rte_cpu_to_be_32(res->verify_tag_value);
7788 case RTE_ETH_FLOW_FRAG_IPV6:
7789 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
7790 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
7791 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
7792 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7793 entry.input.flow.ipv6_flow.dst_ip);
7794 IPV6_ADDR_TO_ARRAY(res->ip_src,
7795 entry.input.flow.ipv6_flow.src_ip);
7796 /* need convert to big endian. */
7797 entry.input.flow.udp6_flow.dst_port =
7798 rte_cpu_to_be_16(res->port_dst);
7799 entry.input.flow.udp6_flow.src_port =
7800 rte_cpu_to_be_16(res->port_src);
7802 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
7803 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7804 entry.input.flow.sctp6_flow.ip.dst_ip);
7805 IPV6_ADDR_TO_ARRAY(res->ip_src,
7806 entry.input.flow.sctp6_flow.ip.src_ip);
7807 /* need convert to big endian. */
7808 entry.input.flow.sctp6_flow.verify_tag =
7809 rte_cpu_to_be_32(res->verify_tag_value);
7812 printf("invalid parameter.\n");
7815 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7817 RTE_ETH_FDIR_MAX_FLEXLEN);
7819 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7821 entry.action.flex_off = 0; /*use 0 by default */
7822 if (!strcmp(res->drop, "drop"))
7823 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7825 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7826 /* set to report FD ID by default */
7827 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7828 entry.action.rx_queue = res->queue_id;
7829 entry.soft_id = res->fd_id_value;
7830 if (!strcmp(res->ops, "add"))
7831 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7832 RTE_ETH_FILTER_ADD, &entry);
7833 else if (!strcmp(res->ops, "del"))
7834 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7835 RTE_ETH_FILTER_DELETE, &entry);
7837 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7838 RTE_ETH_FILTER_UPDATE, &entry);
7840 printf("flow director programming error: (%s)\n",
7844 cmdline_parse_token_string_t cmd_flow_director_filter =
7845 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7846 flow_director_filter, "flow_director_filter");
7847 cmdline_parse_token_num_t cmd_flow_director_port_id =
7848 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7850 cmdline_parse_token_string_t cmd_flow_director_ops =
7851 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7852 ops, "add#del#update");
7853 cmdline_parse_token_string_t cmd_flow_director_flow =
7854 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7856 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7858 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
7859 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp");
7860 cmdline_parse_token_string_t cmd_flow_director_src =
7861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7863 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7864 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7866 cmdline_parse_token_num_t cmd_flow_director_port_src =
7867 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7869 cmdline_parse_token_string_t cmd_flow_director_dst =
7870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7872 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
7873 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7875 cmdline_parse_token_num_t cmd_flow_director_port_dst =
7876 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7878 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
7879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7880 verify_tag, "verify_tag");
7881 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
7882 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7883 verify_tag_value, UINT32);
7884 cmdline_parse_token_string_t cmd_flow_director_vlan =
7885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7887 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
7888 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7889 vlan_value, UINT16);
7890 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
7891 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7892 flexbytes, "flexbytes");
7893 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
7894 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7895 flexbytes_value, NULL);
7896 cmdline_parse_token_string_t cmd_flow_director_drop =
7897 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7899 cmdline_parse_token_string_t cmd_flow_director_queue =
7900 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7902 cmdline_parse_token_num_t cmd_flow_director_queue_id =
7903 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7905 cmdline_parse_token_string_t cmd_flow_director_fd_id =
7906 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7908 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
7909 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7910 fd_id_value, UINT32);
7912 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
7913 .f = cmd_flow_director_filter_parsed,
7915 .help_str = "add or delete an ip flow director entry on NIC",
7917 (void *)&cmd_flow_director_filter,
7918 (void *)&cmd_flow_director_port_id,
7919 (void *)&cmd_flow_director_ops,
7920 (void *)&cmd_flow_director_flow,
7921 (void *)&cmd_flow_director_flow_type,
7922 (void *)&cmd_flow_director_src,
7923 (void *)&cmd_flow_director_ip_src,
7924 (void *)&cmd_flow_director_dst,
7925 (void *)&cmd_flow_director_ip_dst,
7926 (void *)&cmd_flow_director_vlan,
7927 (void *)&cmd_flow_director_vlan_value,
7928 (void *)&cmd_flow_director_flexbytes,
7929 (void *)&cmd_flow_director_flexbytes_value,
7930 (void *)&cmd_flow_director_drop,
7931 (void *)&cmd_flow_director_queue,
7932 (void *)&cmd_flow_director_queue_id,
7933 (void *)&cmd_flow_director_fd_id,
7934 (void *)&cmd_flow_director_fd_id_value,
7939 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
7940 .f = cmd_flow_director_filter_parsed,
7942 .help_str = "add or delete an udp/tcp flow director entry on NIC",
7944 (void *)&cmd_flow_director_filter,
7945 (void *)&cmd_flow_director_port_id,
7946 (void *)&cmd_flow_director_ops,
7947 (void *)&cmd_flow_director_flow,
7948 (void *)&cmd_flow_director_flow_type,
7949 (void *)&cmd_flow_director_src,
7950 (void *)&cmd_flow_director_ip_src,
7951 (void *)&cmd_flow_director_port_src,
7952 (void *)&cmd_flow_director_dst,
7953 (void *)&cmd_flow_director_ip_dst,
7954 (void *)&cmd_flow_director_port_dst,
7955 (void *)&cmd_flow_director_vlan,
7956 (void *)&cmd_flow_director_vlan_value,
7957 (void *)&cmd_flow_director_flexbytes,
7958 (void *)&cmd_flow_director_flexbytes_value,
7959 (void *)&cmd_flow_director_drop,
7960 (void *)&cmd_flow_director_queue,
7961 (void *)&cmd_flow_director_queue_id,
7962 (void *)&cmd_flow_director_fd_id,
7963 (void *)&cmd_flow_director_fd_id_value,
7968 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
7969 .f = cmd_flow_director_filter_parsed,
7971 .help_str = "add or delete a sctp flow director entry on NIC",
7973 (void *)&cmd_flow_director_filter,
7974 (void *)&cmd_flow_director_port_id,
7975 (void *)&cmd_flow_director_ops,
7976 (void *)&cmd_flow_director_flow,
7977 (void *)&cmd_flow_director_flow_type,
7978 (void *)&cmd_flow_director_src,
7979 (void *)&cmd_flow_director_ip_src,
7980 (void *)&cmd_flow_director_port_dst,
7981 (void *)&cmd_flow_director_dst,
7982 (void *)&cmd_flow_director_ip_dst,
7983 (void *)&cmd_flow_director_port_dst,
7984 (void *)&cmd_flow_director_verify_tag,
7985 (void *)&cmd_flow_director_verify_tag_value,
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 struct cmd_flush_flow_director_result {
8000 cmdline_fixed_string_t flush_flow_director;
8004 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8005 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8006 flush_flow_director, "flush_flow_director");
8007 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8008 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8012 cmd_flush_flow_director_parsed(void *parsed_result,
8013 __attribute__((unused)) struct cmdline *cl,
8014 __attribute__((unused)) void *data)
8016 struct cmd_flow_director_result *res = parsed_result;
8019 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8021 printf("flow director is not supported on port %u.\n",
8026 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8027 RTE_ETH_FILTER_FLUSH, NULL);
8029 printf("flow director table flushing error: (%s)\n",
8033 cmdline_parse_inst_t cmd_flush_flow_director = {
8034 .f = cmd_flush_flow_director_parsed,
8036 .help_str = "flush all flow director entries of a device on NIC",
8038 (void *)&cmd_flush_flow_director_flush,
8039 (void *)&cmd_flush_flow_director_port_id,
8044 /* *** deal with flow director mask *** */
8045 struct cmd_flow_director_mask_result {
8046 cmdline_fixed_string_t flow_director_mask;
8048 cmdline_fixed_string_t vlan;
8049 uint16_t vlan_value;
8050 cmdline_fixed_string_t src_mask;
8051 cmdline_ipaddr_t ipv4_src;
8052 cmdline_ipaddr_t ipv6_src;
8054 cmdline_fixed_string_t dst_mask;
8055 cmdline_ipaddr_t ipv4_dst;
8056 cmdline_ipaddr_t ipv6_dst;
8061 cmd_flow_director_mask_parsed(void *parsed_result,
8062 __attribute__((unused)) struct cmdline *cl,
8063 __attribute__((unused)) void *data)
8065 struct cmd_flow_director_mask_result *res = parsed_result;
8066 struct rte_eth_fdir_masks *mask;
8067 struct rte_port *port;
8069 if (res->port_id > nb_ports) {
8070 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8074 port = &ports[res->port_id];
8075 /** Check if the port is not started **/
8076 if (port->port_status != RTE_PORT_STOPPED) {
8077 printf("Please stop port %d first\n", res->port_id);
8080 mask = &port->dev_conf.fdir_conf.mask;
8082 mask->vlan_tci_mask = res->vlan_value;
8083 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8084 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8085 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8086 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8087 mask->src_port_mask = res->port_src;
8088 mask->dst_port_mask = res->port_dst;
8090 cmd_reconfig_device_queue(res->port_id, 1, 1);
8093 cmdline_parse_token_string_t cmd_flow_director_mask =
8094 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8095 flow_director_mask, "flow_director_mask");
8096 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8097 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8099 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8100 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8102 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8103 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8104 vlan_value, UINT16);
8105 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8106 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8107 src_mask, "src_mask");
8108 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8109 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8111 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8112 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8114 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8115 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8117 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8118 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8119 dst_mask, "dst_mask");
8120 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8121 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8123 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8124 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8126 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8127 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8129 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8130 .f = cmd_flow_director_mask_parsed,
8132 .help_str = "set flow director's mask on NIC",
8134 (void *)&cmd_flow_director_mask,
8135 (void *)&cmd_flow_director_mask_port_id,
8136 (void *)&cmd_flow_director_mask_vlan,
8137 (void *)&cmd_flow_director_mask_vlan_value,
8138 (void *)&cmd_flow_director_mask_src,
8139 (void *)&cmd_flow_director_mask_ipv4_src,
8140 (void *)&cmd_flow_director_mask_ipv6_src,
8141 (void *)&cmd_flow_director_mask_port_src,
8142 (void *)&cmd_flow_director_mask_dst,
8143 (void *)&cmd_flow_director_mask_ipv4_dst,
8144 (void *)&cmd_flow_director_mask_ipv6_dst,
8145 (void *)&cmd_flow_director_mask_port_dst,
8150 /* *** deal with flow director mask on flexible payload *** */
8151 struct cmd_flow_director_flex_mask_result {
8152 cmdline_fixed_string_t flow_director_flexmask;
8154 cmdline_fixed_string_t flow;
8155 cmdline_fixed_string_t flow_type;
8156 cmdline_fixed_string_t mask;
8160 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8161 __attribute__((unused)) struct cmdline *cl,
8162 __attribute__((unused)) void *data)
8164 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8165 struct rte_eth_fdir_info fdir_info;
8166 struct rte_eth_fdir_flex_mask flex_mask;
8167 struct rte_port *port;
8168 uint32_t flow_type_mask;
8172 if (res->port_id > nb_ports) {
8173 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8177 port = &ports[res->port_id];
8178 /** Check if the port is not started **/
8179 if (port->port_status != RTE_PORT_STOPPED) {
8180 printf("Please stop port %d first\n", res->port_id);
8184 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8185 ret = parse_flexbytes(res->mask,
8187 RTE_ETH_FDIR_MAX_FLEXLEN);
8189 printf("error: Cannot parse mask input.\n");
8193 memset(&fdir_info, 0, sizeof(fdir_info));
8194 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8195 RTE_ETH_FILTER_INFO, &fdir_info);
8197 printf("Cannot get FDir filter info\n");
8201 flow_type_mask = fdir_info.flow_types_mask[0];
8202 if (!strcmp(res->flow_type, "all")) {
8203 if (!flow_type_mask) {
8204 printf("No flow type supported\n");
8207 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8208 if (flow_type_mask & (1 << i)) {
8209 flex_mask.flow_type = i;
8210 fdir_set_flex_mask(res->port_id, &flex_mask);
8213 cmd_reconfig_device_queue(res->port_id, 1, 1);
8216 flex_mask.flow_type = str2flowtype(res->flow_type);
8217 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8218 printf("Flow type %s not supported on port %d\n",
8219 res->flow_type, res->port_id);
8222 fdir_set_flex_mask(res->port_id, &flex_mask);
8223 cmd_reconfig_device_queue(res->port_id, 1, 1);
8226 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8228 flow_director_flexmask,
8229 "flow_director_flex_mask");
8230 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8231 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8233 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8236 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8238 flow_type, "raw#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8239 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#all");
8240 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8241 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8244 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8245 .f = cmd_flow_director_flex_mask_parsed,
8247 .help_str = "set flow director's flex mask on NIC",
8249 (void *)&cmd_flow_director_flexmask,
8250 (void *)&cmd_flow_director_flexmask_port_id,
8251 (void *)&cmd_flow_director_flexmask_flow,
8252 (void *)&cmd_flow_director_flexmask_flow_type,
8253 (void *)&cmd_flow_director_flexmask_mask,
8258 /* *** deal with flow director flexible payload configuration *** */
8259 struct cmd_flow_director_flexpayload_result {
8260 cmdline_fixed_string_t flow_director_flexpayload;
8262 cmdline_fixed_string_t payload_layer;
8263 cmdline_fixed_string_t payload_cfg;
8267 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8270 const char *p, *p0 = q_arg;
8272 unsigned long int_fld;
8273 char *str_fld[max_num];
8278 p = strchr(p0, '(');
8282 p0 = strchr(p, ')');
8287 if (size >= sizeof(s))
8290 snprintf(s, sizeof(s), "%.*s", size, p);
8291 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8292 if (ret < 0 || ret > max_num)
8294 for (i = 0; i < ret; i++) {
8296 int_fld = strtoul(str_fld[i], &end, 0);
8297 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8299 offsets[i] = (uint16_t)int_fld;
8305 cmd_flow_director_flxpld_parsed(void *parsed_result,
8306 __attribute__((unused)) struct cmdline *cl,
8307 __attribute__((unused)) void *data)
8309 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8310 struct rte_eth_flex_payload_cfg flex_cfg;
8311 struct rte_port *port;
8314 if (res->port_id > nb_ports) {
8315 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8319 port = &ports[res->port_id];
8320 /** Check if the port is not started **/
8321 if (port->port_status != RTE_PORT_STOPPED) {
8322 printf("Please stop port %d first\n", res->port_id);
8326 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8328 if (!strcmp(res->payload_layer, "raw"))
8329 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8330 else if (!strcmp(res->payload_layer, "l2"))
8331 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8332 else if (!strcmp(res->payload_layer, "l3"))
8333 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8334 else if (!strcmp(res->payload_layer, "l4"))
8335 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8337 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8338 RTE_ETH_FDIR_MAX_FLEXLEN);
8340 printf("error: Cannot parse flex payload input.\n");
8344 fdir_set_flex_payload(res->port_id, &flex_cfg);
8345 cmd_reconfig_device_queue(res->port_id, 1, 1);
8348 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8350 flow_director_flexpayload,
8351 "flow_director_flex_payload");
8352 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8353 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8355 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8357 payload_layer, "raw#l2#l3#l4");
8358 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8362 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8363 .f = cmd_flow_director_flxpld_parsed,
8365 .help_str = "set flow director's flex payload on NIC",
8367 (void *)&cmd_flow_director_flexpayload,
8368 (void *)&cmd_flow_director_flexpayload_port_id,
8369 (void *)&cmd_flow_director_flexpayload_payload_layer,
8370 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8375 /* *** Classification Filters Control *** */
8376 /* *** Get symmetric hash enable per port *** */
8377 struct cmd_get_sym_hash_ena_per_port_result {
8378 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8383 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8384 __rte_unused struct cmdline *cl,
8385 __rte_unused void *data)
8387 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8388 struct rte_eth_hash_filter_info info;
8391 if (rte_eth_dev_filter_supported(res->port_id,
8392 RTE_ETH_FILTER_HASH) < 0) {
8393 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8398 memset(&info, 0, sizeof(info));
8399 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8400 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8401 RTE_ETH_FILTER_GET, &info);
8404 printf("Cannot get symmetric hash enable per port "
8405 "on port %u\n", res->port_id);
8409 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8410 "enabled" : "disabled", res->port_id);
8413 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8414 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8415 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8416 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8417 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8420 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8421 .f = cmd_get_sym_hash_per_port_parsed,
8423 .help_str = "get_sym_hash_ena_per_port port_id",
8425 (void *)&cmd_get_sym_hash_ena_per_port_all,
8426 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8431 /* *** Set symmetric hash enable per port *** */
8432 struct cmd_set_sym_hash_ena_per_port_result {
8433 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8434 cmdline_fixed_string_t enable;
8439 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8440 __rte_unused struct cmdline *cl,
8441 __rte_unused void *data)
8443 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8444 struct rte_eth_hash_filter_info info;
8447 if (rte_eth_dev_filter_supported(res->port_id,
8448 RTE_ETH_FILTER_HASH) < 0) {
8449 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8454 memset(&info, 0, sizeof(info));
8455 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8456 if (!strcmp(res->enable, "enable"))
8457 info.info.enable = 1;
8458 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8459 RTE_ETH_FILTER_SET, &info);
8461 printf("Cannot set symmetric hash enable per port on "
8462 "port %u\n", res->port_id);
8465 printf("Symmetric hash has been set to %s on port %u\n",
8466 res->enable, res->port_id);
8469 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8470 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8471 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8472 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8473 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8475 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8476 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8477 enable, "enable#disable");
8479 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8480 .f = cmd_set_sym_hash_per_port_parsed,
8482 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8484 (void *)&cmd_set_sym_hash_ena_per_port_all,
8485 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8486 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8491 /* Get global config of hash function */
8492 struct cmd_get_hash_global_config_result {
8493 cmdline_fixed_string_t get_hash_global_config;
8498 flowtype_to_str(uint16_t ftype)
8505 {"ipv4", RTE_ETH_FLOW_IPV4},
8506 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8507 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8508 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8509 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8510 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8511 {"ipv6", RTE_ETH_FLOW_IPV6},
8512 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8513 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8514 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8515 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8516 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8517 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8520 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8521 if (ftype_table[i].ftype == ftype)
8522 return ftype_table[i].str;
8529 cmd_get_hash_global_config_parsed(void *parsed_result,
8530 __rte_unused struct cmdline *cl,
8531 __rte_unused void *data)
8533 struct cmd_get_hash_global_config_result *res = parsed_result;
8534 struct rte_eth_hash_filter_info info;
8535 uint32_t idx, offset;
8540 if (rte_eth_dev_filter_supported(res->port_id,
8541 RTE_ETH_FILTER_HASH) < 0) {
8542 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8547 memset(&info, 0, sizeof(info));
8548 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8549 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8550 RTE_ETH_FILTER_GET, &info);
8552 printf("Cannot get hash global configurations by port %d\n",
8557 switch (info.info.global_conf.hash_func) {
8558 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8559 printf("Hash function is Toeplitz\n");
8561 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8562 printf("Hash function is Simple XOR\n");
8565 printf("Unknown hash function\n");
8569 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
8570 idx = i / UINT32_BIT;
8571 offset = i % UINT32_BIT;
8572 if (!(info.info.global_conf.valid_bit_mask[idx] &
8575 str = flowtype_to_str(i);
8578 printf("Symmetric hash is %s globally for flow type %s "
8580 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8581 (1UL << offset)) ? "enabled" : "disabled"), str,
8586 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8587 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8588 get_hash_global_config, "get_hash_global_config");
8589 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8590 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8593 cmdline_parse_inst_t cmd_get_hash_global_config = {
8594 .f = cmd_get_hash_global_config_parsed,
8596 .help_str = "get_hash_global_config port_id",
8598 (void *)&cmd_get_hash_global_config_all,
8599 (void *)&cmd_get_hash_global_config_port_id,
8604 /* Set global config of hash function */
8605 struct cmd_set_hash_global_config_result {
8606 cmdline_fixed_string_t set_hash_global_config;
8608 cmdline_fixed_string_t hash_func;
8609 cmdline_fixed_string_t flow_type;
8610 cmdline_fixed_string_t enable;
8614 cmd_set_hash_global_config_parsed(void *parsed_result,
8615 __rte_unused struct cmdline *cl,
8616 __rte_unused void *data)
8618 struct cmd_set_hash_global_config_result *res = parsed_result;
8619 struct rte_eth_hash_filter_info info;
8620 uint32_t ftype, idx, offset;
8623 if (rte_eth_dev_filter_supported(res->port_id,
8624 RTE_ETH_FILTER_HASH) < 0) {
8625 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8629 memset(&info, 0, sizeof(info));
8630 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8631 if (!strcmp(res->hash_func, "toeplitz"))
8632 info.info.global_conf.hash_func =
8633 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8634 else if (!strcmp(res->hash_func, "simple_xor"))
8635 info.info.global_conf.hash_func =
8636 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8637 else if (!strcmp(res->hash_func, "default"))
8638 info.info.global_conf.hash_func =
8639 RTE_ETH_HASH_FUNCTION_DEFAULT;
8641 ftype = str2flowtype(res->flow_type);
8642 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8643 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8644 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8645 if (!strcmp(res->enable, "enable"))
8646 info.info.global_conf.sym_hash_enable_mask[idx] |=
8648 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8649 RTE_ETH_FILTER_SET, &info);
8651 printf("Cannot set global hash configurations by port %d\n",
8654 printf("Global hash configurations have been set "
8655 "succcessfully by port %d\n", res->port_id);
8658 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8659 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8660 set_hash_global_config, "set_hash_global_config");
8661 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8662 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8664 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8665 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8666 hash_func, "toeplitz#simple_xor#default");
8667 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8668 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8670 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
8671 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
8672 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8673 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8674 enable, "enable#disable");
8676 cmdline_parse_inst_t cmd_set_hash_global_config = {
8677 .f = cmd_set_hash_global_config_parsed,
8679 .help_str = "set_hash_global_config port_id "
8680 "toeplitz|simple_xor|default "
8681 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
8682 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
8685 (void *)&cmd_set_hash_global_config_all,
8686 (void *)&cmd_set_hash_global_config_port_id,
8687 (void *)&cmd_set_hash_global_config_hash_func,
8688 (void *)&cmd_set_hash_global_config_flow_type,
8689 (void *)&cmd_set_hash_global_config_enable,
8694 /* ******************************************************************************** */
8696 /* list of instructions */
8697 cmdline_parse_ctx_t main_ctx[] = {
8698 (cmdline_parse_inst_t *)&cmd_help_brief,
8699 (cmdline_parse_inst_t *)&cmd_help_long,
8700 (cmdline_parse_inst_t *)&cmd_quit,
8701 (cmdline_parse_inst_t *)&cmd_showport,
8702 (cmdline_parse_inst_t *)&cmd_showportall,
8703 (cmdline_parse_inst_t *)&cmd_showcfg,
8704 (cmdline_parse_inst_t *)&cmd_start,
8705 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8706 (cmdline_parse_inst_t *)&cmd_set_link_up,
8707 (cmdline_parse_inst_t *)&cmd_set_link_down,
8708 (cmdline_parse_inst_t *)&cmd_reset,
8709 (cmdline_parse_inst_t *)&cmd_set_numbers,
8710 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8711 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8712 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8713 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8714 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8715 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8716 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8717 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8718 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8719 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8720 (cmdline_parse_inst_t *)&cmd_set_link_check,
8721 #ifdef RTE_NIC_BYPASS
8722 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8723 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8724 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8725 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8727 #ifdef RTE_LIBRTE_PMD_BOND
8728 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8729 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8730 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8731 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8732 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8733 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8734 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8735 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8736 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8738 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8739 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8740 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8741 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8742 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8743 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8744 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8745 (cmdline_parse_inst_t *)&cmd_csum_set,
8746 (cmdline_parse_inst_t *)&cmd_csum_show,
8747 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8748 (cmdline_parse_inst_t *)&cmd_tso_set,
8749 (cmdline_parse_inst_t *)&cmd_tso_show,
8750 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8751 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8752 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8753 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8754 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8755 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8756 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8757 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8758 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8759 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8760 (cmdline_parse_inst_t *)&cmd_config_dcb,
8761 (cmdline_parse_inst_t *)&cmd_read_reg,
8762 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8763 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8764 (cmdline_parse_inst_t *)&cmd_write_reg,
8765 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8766 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8767 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8768 (cmdline_parse_inst_t *)&cmd_stop,
8769 (cmdline_parse_inst_t *)&cmd_mac_addr,
8770 (cmdline_parse_inst_t *)&cmd_set_qmap,
8771 (cmdline_parse_inst_t *)&cmd_operate_port,
8772 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8773 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
8774 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
8775 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8776 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8777 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8778 (cmdline_parse_inst_t *)&cmd_config_mtu,
8779 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8780 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8781 (cmdline_parse_inst_t *)&cmd_config_rss,
8782 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8783 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8784 (cmdline_parse_inst_t *)&cmd_showport_reta,
8785 (cmdline_parse_inst_t *)&cmd_config_burst,
8786 (cmdline_parse_inst_t *)&cmd_config_thresh,
8787 (cmdline_parse_inst_t *)&cmd_config_threshold,
8788 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8789 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8790 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8791 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8792 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8793 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8794 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8795 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8796 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8797 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8798 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8799 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8800 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8801 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8802 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8803 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8804 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8805 (cmdline_parse_inst_t *)&cmd_dump,
8806 (cmdline_parse_inst_t *)&cmd_dump_one,
8807 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
8808 (cmdline_parse_inst_t *)&cmd_syn_filter,
8809 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
8810 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
8811 (cmdline_parse_inst_t *)&cmd_flex_filter,
8812 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8813 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8814 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8815 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8816 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
8817 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8818 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8819 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
8820 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
8821 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
8822 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
8826 /* prompt function, called from main on MASTER lcore */
8832 /* initialize non-constant commands */
8833 cmd_set_fwd_mode_init();
8835 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8839 cmdline_interact(cl);
8840 cmdline_stdin_exit(cl);
8844 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8846 if (!port_id_is_invalid(id, DISABLED_WARN)) {
8847 /* check if need_reconfig has been set to 1 */
8848 if (ports[id].need_reconfig == 0)
8849 ports[id].need_reconfig = dev;
8850 /* check if need_reconfig_queues has been set to 1 */
8851 if (ports[id].need_reconfig_queues == 0)
8852 ports[id].need_reconfig_queues = queue;
8856 FOREACH_PORT(pid, ports) {
8857 /* check if need_reconfig has been set to 1 */
8858 if (ports[pid].need_reconfig == 0)
8859 ports[pid].need_reconfig = dev;
8860 /* check if need_reconfig_queues has been set to 1 */
8861 if (ports[pid].need_reconfig_queues == 0)
8862 ports[pid].need_reconfig_queues = queue;
8867 #ifdef RTE_NIC_BYPASS
8869 bypass_is_supported(portid_t port_id)
8871 struct rte_port *port;
8872 struct rte_pci_id *pci_id;
8874 if (port_id_is_invalid(port_id, ENABLED_WARN))
8877 /* Get the device id. */
8878 port = &ports[port_id];
8879 pci_id = &port->dev_info.pci_dev->id;
8881 /* Check if NIC supports bypass. */
8882 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8886 printf("\tBypass not supported for port_id = %d.\n", port_id);