4 * Copyright(c) 2010-2015 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>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
77 #include <rte_eth_ctrl.h>
79 #include <cmdline_rdline.h>
80 #include <cmdline_parse.h>
81 #include <cmdline_parse_num.h>
82 #include <cmdline_parse_string.h>
83 #include <cmdline_parse_ipaddr.h>
84 #include <cmdline_parse_etheraddr.h>
85 #include <cmdline_socket.h>
87 #ifdef RTE_LIBRTE_PMD_BOND
88 #include <rte_eth_bond.h>
93 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
96 uint8_t bypass_is_supported(portid_t port_id);
99 /* *** Help command with introduction. *** */
100 struct cmd_help_brief_result {
101 cmdline_fixed_string_t help;
104 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
106 __attribute__((unused)) void *data)
111 "Help is available for the following sections:\n\n"
112 " help control : Start and stop forwarding.\n"
113 " help display : Displaying port, stats and config "
115 " help config : Configuration information.\n"
116 " help ports : Configuring ports.\n"
117 " help registers : Reading and setting port registers.\n"
118 " help filters : Filters configuration help.\n"
119 " help all : All of the above sections.\n\n"
124 cmdline_parse_token_string_t cmd_help_brief_help =
125 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
127 cmdline_parse_inst_t cmd_help_brief = {
128 .f = cmd_help_brief_parsed,
130 .help_str = "show help",
132 (void *)&cmd_help_brief_help,
137 /* *** Help command with help sections. *** */
138 struct cmd_help_long_result {
139 cmdline_fixed_string_t help;
140 cmdline_fixed_string_t section;
143 static void cmd_help_long_parsed(void *parsed_result,
145 __attribute__((unused)) void *data)
148 struct cmd_help_long_result *res = parsed_result;
150 if (!strcmp(res->section, "all"))
153 if (show_all || !strcmp(res->section, "control")) {
158 "Control forwarding:\n"
159 "-------------------\n\n"
162 " Start packet forwarding with current configuration.\n\n"
165 " Start packet forwarding with current config"
166 " after sending one burst of packets.\n\n"
169 " Stop packet forwarding, and display accumulated"
173 " Quit to prompt.\n\n"
177 if (show_all || !strcmp(res->section, "display")) {
185 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
186 " Display information for port_id, or all.\n\n"
188 "show port X rss reta (size) (mask0,mask1,...)\n"
189 " Display the rss redirection table entry indicated"
190 " by masks on port X. size is used to indicate the"
191 " hardware supported reta size\n\n"
193 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
194 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
195 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [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 (port_id) vlan_id[, vlan_id_outer]\n"
309 " Set hardware insertion of VLAN IDs (single or double VLAN "
310 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
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 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-up|pool-mirror-down|vlan-mirror)"
417 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
418 " Set pool or vlan type mirror rule on a port.\n"
419 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
420 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
423 "set port (port_id) mirror-rule (rule_id)"
424 " (uplink-mirror|downlink-mirror) dst-pool"
425 " (pool_id) (on|off)\n"
426 " Set uplink or downlink type mirror rule on a port.\n"
427 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
428 " 0 on' enable mirror income traffic to pool 0.\n\n"
430 "reset port (port_id) mirror-rule (rule_id)\n"
431 " Reset a mirror rule.\n\n"
433 "set flush_rx (on|off)\n"
434 " Flush (default) or don't flush RX streams before"
435 " forwarding. Mainly used with PCAP drivers.\n\n"
437 #ifdef RTE_NIC_BYPASS
438 "set bypass mode (normal|bypass|isolate) (port_id)\n"
439 " Set the bypass mode for the lowest port on bypass enabled"
442 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
443 "mode (normal|bypass|isolate) (port_id)\n"
444 " Set the event required to initiate specified bypass mode for"
445 " the lowest port on a bypass enabled NIC where:\n"
446 " timeout = enable bypass after watchdog timeout.\n"
447 " os_on = enable bypass when OS/board is powered on.\n"
448 " os_off = enable bypass when OS/board is powered off.\n"
449 " power_on = enable bypass when power supply is turned on.\n"
450 " power_off = enable bypass when power supply is turned off."
453 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
454 " Set the bypass watchdog timeout to 'n' seconds"
455 " where 0 = instant.\n\n"
457 "show bypass config (port_id)\n"
458 " Show the bypass configuration for a bypass enabled NIC"
459 " using the lowest port on the NIC.\n\n"
461 #ifdef RTE_LIBRTE_PMD_BOND
462 "create bonded device (mode) (socket)\n"
463 " Create a new bonded device with specific bonding mode and socket.\n\n"
465 "add bonding slave (slave_id) (port_id)\n"
466 " Add a slave device to a bonded device.\n\n"
468 "remove bonding slave (slave_id) (port_id)\n"
469 " Remove a slave device from a bonded device.\n\n"
471 "set bonding mode (value) (port_id)\n"
472 " Set the bonding mode on a bonded device.\n\n"
474 "set bonding primary (slave_id) (port_id)\n"
475 " Set the primary slave for a bonded device.\n\n"
477 "show bonding config (port_id)\n"
478 " Show the bonding config for port_id.\n\n"
480 "set bonding mac_addr (port_id) (address)\n"
481 " Set the MAC address of a bonded device.\n\n"
483 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
484 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
486 "set bonding mon_period (port_id) (value)\n"
487 " Set the bonding link status monitoring polling period in ms.\n\n"
489 "set link-up port (port_id)\n"
490 " Set link up for a port.\n\n"
492 "set link-down port (port_id)\n"
493 " Set link down for a port.\n\n"
495 , list_pkt_forwarding_modes()
499 if (show_all || !strcmp(res->section, "ports")) {
505 "----------------\n\n"
507 "port start (port_id|all)\n"
508 " Start all ports or port_id.\n\n"
510 "port stop (port_id|all)\n"
511 " Stop all ports or port_id.\n\n"
513 "port close (port_id|all)\n"
514 " Close all ports or port_id.\n\n"
516 "port attach (ident)\n"
517 " Attach physical or virtual dev by pci address or virtual device name\n\n"
519 "port detach (port_id)\n"
520 " Detach physical or virtual dev by port_id\n\n"
522 "port config (port_id|all)"
523 " speed (10|100|1000|10000|40000|auto)"
524 " duplex (half|full|auto)\n"
525 " Set speed and duplex for all ports or port_id\n\n"
527 "port config all (rxq|txq|rxd|txd) (value)\n"
528 " Set number for rxq/txq/rxd/txd.\n\n"
530 "port config all max-pkt-len (value)\n"
531 " Set the max packet length.\n\n"
533 "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
534 "hw-vlan-strip|hw-vlan-extend|drop-en)"
536 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
539 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
540 " Set the RSS mode.\n\n"
542 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
543 " Set the RSS redirection table.\n\n"
545 "port config (port_id) dcb vt (on|off) (traffic_class)"
547 " Set the DCB mode.\n\n"
549 "port config all burst (value)\n"
550 " Set the number of packets per burst.\n\n"
552 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
554 " Set the ring prefetch/host/writeback threshold"
555 " for tx/rx queue.\n\n"
557 "port config all (txfreet|txrst|rxfreet) (value)\n"
558 " Set free threshold for rx/tx, or set"
559 " tx rs bit threshold.\n\n"
560 "port config mtu X value\n"
561 " Set the MTU of port X to a given value\n\n"
563 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
564 " Start/stop a rx/tx queue of port X. Only take effect"
565 " when port X is started\n"
569 if (show_all || !strcmp(res->section, "registers")) {
577 "read reg (port_id) (address)\n"
578 " Display value of a port register.\n\n"
580 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
581 " Display a port register bit field.\n\n"
583 "read regbit (port_id) (address) (bit_x)\n"
584 " Display a single port register bit.\n\n"
586 "write reg (port_id) (address) (value)\n"
587 " Set value of a port register.\n\n"
589 "write regfield (port_id) (address) (bit_x) (bit_y)"
591 " Set bit field of a port register.\n\n"
593 "write regbit (port_id) (address) (bit_x) (value)\n"
594 " Set single bit value of a port register.\n\n"
597 if (show_all || !strcmp(res->section, "filters")) {
605 "ethertype_filter (port_id) (add|del)"
606 " (mac_addr|mac_ignr) (mac_address) ethertype"
607 " (ether_type) (drop|fwd) queue (queue_id)\n"
608 " Add/Del an ethertype filter.\n\n"
610 "2tuple_filter (port_id) (add|del)"
611 " dst_port (dst_port_value) protocol (protocol_value)"
612 " mask (mask_value) tcp_flags (tcp_flags_value)"
613 " priority (prio_value) queue (queue_id)\n"
614 " Add/Del a 2tuple filter.\n\n"
616 "5tuple_filter (port_id) (add|del)"
617 " dst_ip (dst_address) src_ip (src_address)"
618 " dst_port (dst_port_value) src_port (src_port_value)"
619 " protocol (protocol_value)"
620 " mask (mask_value) tcp_flags (tcp_flags_value)"
621 " priority (prio_value) queue (queue_id)\n"
622 " Add/Del a 5tuple filter.\n\n"
624 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
625 " Add/Del syn filter.\n\n"
627 "flex_filter (port_id) (add|del) len (len_value)"
628 " bytes (bytes_value) mask (mask_value)"
629 " priority (prio_value) queue (queue_id)\n"
630 " Add/Del a flex filter.\n\n"
632 "flow_director_filter (port_id) (add|del|update)"
633 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
634 " src (src_ip_address) dst (dst_ip_address)"
635 " vlan (vlan_value) flexbytes (flexbytes_value)"
636 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
637 " Add/Del an IP type flow director filter.\n\n"
639 "flow_director_filter (port_id) (add|del|update)"
640 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
641 " src (src_ip_address) (src_port)"
642 " dst (dst_ip_address) (dst_port)"
643 " vlan (vlan_value) flexbytes (flexbytes_value)"
644 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
645 " Add/Del an UDP/TCP type flow director filter.\n\n"
647 "flow_director_filter (port_id) (add|del|update)"
648 " flow (ipv4-sctp|ipv6-sctp)"
649 " src (src_ip_address) (src_port)"
650 " dst (dst_ip_address) (dst_port)"
651 " tag (verification_tag) vlan (vlan_value)"
652 " flexbytes (flexbytes_value) (drop|fwd)"
653 " queue (queue_id) fd_id (fd_id_value)\n"
654 " Add/Del a SCTP type flow director filter.\n\n"
656 "flow_director_filter (port_id) (add|del|update)"
657 " flow l2_payload ether (ethertype)"
658 " flexbytes (flexbytes_value) (drop|fwd)"
659 " queue (queue_id) fd_id (fd_id_value)\n"
660 " Add/Del a l2 payload type flow director filter.\n\n"
662 "flush_flow_director (port_id)\n"
663 " Flush all flow director entries of a device.\n\n"
665 "flow_director_mask (port_id) vlan (vlan_value)"
666 " src_mask (ipv4_src) (ipv6_src) (src_port)"
667 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
668 " Set flow director mask.\n\n"
670 "flow_director_flex_mask (port_id)"
671 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
672 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
674 " Configure mask of flex payload.\n\n"
676 "flow_director_flex_payload (port_id)"
677 " (raw|l2|l3|l4) (config)\n"
678 " Configure flex payload selection.\n\n"
680 "get_sym_hash_ena_per_port (port_id)\n"
681 " get symmetric hash enable configuration per port.\n\n"
683 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
684 " set symmetric hash enable configuration per port"
685 " to enable or disable.\n\n"
687 "get_hash_global_config (port_id)\n"
688 " Get the global configurations of hash filters.\n\n"
690 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
691 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
692 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
693 " (enable|disable)\n"
694 " Set the global configurations of hash filters.\n\n"
696 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
697 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
698 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
699 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
700 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
701 "ipv6-next-header|udp-src-port|udp-dst-port|"
702 "tcp-src-port|tcp-dst-port|sctp-src-port|"
703 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
704 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
705 "fld-8th|none) (select|add)\n"
706 " Set the input set for hash.\n\n"
708 "set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
709 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
710 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
711 "l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
712 "udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
713 "sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
714 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
715 "fld-8th|none) (select|add)\n"
716 " Set the input set for FDir.\n\n"
721 cmdline_parse_token_string_t cmd_help_long_help =
722 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
724 cmdline_parse_token_string_t cmd_help_long_section =
725 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
726 "all#control#display#config#"
727 "ports#registers#filters");
729 cmdline_parse_inst_t cmd_help_long = {
730 .f = cmd_help_long_parsed,
732 .help_str = "show help",
734 (void *)&cmd_help_long_help,
735 (void *)&cmd_help_long_section,
741 /* *** start/stop/close all ports *** */
742 struct cmd_operate_port_result {
743 cmdline_fixed_string_t keyword;
744 cmdline_fixed_string_t name;
745 cmdline_fixed_string_t value;
748 static void cmd_operate_port_parsed(void *parsed_result,
749 __attribute__((unused)) struct cmdline *cl,
750 __attribute__((unused)) void *data)
752 struct cmd_operate_port_result *res = parsed_result;
754 if (!strcmp(res->name, "start"))
755 start_port(RTE_PORT_ALL);
756 else if (!strcmp(res->name, "stop"))
757 stop_port(RTE_PORT_ALL);
758 else if (!strcmp(res->name, "close"))
759 close_port(RTE_PORT_ALL);
761 printf("Unknown parameter\n");
764 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
765 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
767 cmdline_parse_token_string_t cmd_operate_port_all_port =
768 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
770 cmdline_parse_token_string_t cmd_operate_port_all_all =
771 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
773 cmdline_parse_inst_t cmd_operate_port = {
774 .f = cmd_operate_port_parsed,
776 .help_str = "port start|stop|close all: start/stop/close all ports",
778 (void *)&cmd_operate_port_all_cmd,
779 (void *)&cmd_operate_port_all_port,
780 (void *)&cmd_operate_port_all_all,
785 /* *** start/stop/close specific port *** */
786 struct cmd_operate_specific_port_result {
787 cmdline_fixed_string_t keyword;
788 cmdline_fixed_string_t name;
792 static void cmd_operate_specific_port_parsed(void *parsed_result,
793 __attribute__((unused)) struct cmdline *cl,
794 __attribute__((unused)) void *data)
796 struct cmd_operate_specific_port_result *res = parsed_result;
798 if (!strcmp(res->name, "start"))
799 start_port(res->value);
800 else if (!strcmp(res->name, "stop"))
801 stop_port(res->value);
802 else if (!strcmp(res->name, "close"))
803 close_port(res->value);
805 printf("Unknown parameter\n");
808 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
809 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
811 cmdline_parse_token_string_t cmd_operate_specific_port_port =
812 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
813 name, "start#stop#close");
814 cmdline_parse_token_num_t cmd_operate_specific_port_id =
815 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
818 cmdline_parse_inst_t cmd_operate_specific_port = {
819 .f = cmd_operate_specific_port_parsed,
821 .help_str = "port start|stop|close X: start/stop/close port X",
823 (void *)&cmd_operate_specific_port_cmd,
824 (void *)&cmd_operate_specific_port_port,
825 (void *)&cmd_operate_specific_port_id,
830 /* *** attach a specified port *** */
831 struct cmd_operate_attach_port_result {
832 cmdline_fixed_string_t port;
833 cmdline_fixed_string_t keyword;
834 cmdline_fixed_string_t identifier;
837 static void cmd_operate_attach_port_parsed(void *parsed_result,
838 __attribute__((unused)) struct cmdline *cl,
839 __attribute__((unused)) void *data)
841 struct cmd_operate_attach_port_result *res = parsed_result;
843 if (!strcmp(res->keyword, "attach"))
844 attach_port(res->identifier);
846 printf("Unknown parameter\n");
849 cmdline_parse_token_string_t cmd_operate_attach_port_port =
850 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
852 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
853 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
855 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
856 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
859 cmdline_parse_inst_t cmd_operate_attach_port = {
860 .f = cmd_operate_attach_port_parsed,
862 .help_str = "port attach identifier, "
863 "identifier: pci address or virtual dev name",
865 (void *)&cmd_operate_attach_port_port,
866 (void *)&cmd_operate_attach_port_keyword,
867 (void *)&cmd_operate_attach_port_identifier,
872 /* *** detach a specified port *** */
873 struct cmd_operate_detach_port_result {
874 cmdline_fixed_string_t port;
875 cmdline_fixed_string_t keyword;
879 static void cmd_operate_detach_port_parsed(void *parsed_result,
880 __attribute__((unused)) struct cmdline *cl,
881 __attribute__((unused)) void *data)
883 struct cmd_operate_detach_port_result *res = parsed_result;
885 if (!strcmp(res->keyword, "detach"))
886 detach_port(res->port_id);
888 printf("Unknown parameter\n");
891 cmdline_parse_token_string_t cmd_operate_detach_port_port =
892 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
894 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
895 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
897 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
898 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
901 cmdline_parse_inst_t cmd_operate_detach_port = {
902 .f = cmd_operate_detach_port_parsed,
904 .help_str = "port detach port_id",
906 (void *)&cmd_operate_detach_port_port,
907 (void *)&cmd_operate_detach_port_keyword,
908 (void *)&cmd_operate_detach_port_port_id,
913 /* *** configure speed for all ports *** */
914 struct cmd_config_speed_all {
915 cmdline_fixed_string_t port;
916 cmdline_fixed_string_t keyword;
917 cmdline_fixed_string_t all;
918 cmdline_fixed_string_t item1;
919 cmdline_fixed_string_t item2;
920 cmdline_fixed_string_t value1;
921 cmdline_fixed_string_t value2;
925 cmd_config_speed_all_parsed(void *parsed_result,
926 __attribute__((unused)) struct cmdline *cl,
927 __attribute__((unused)) void *data)
929 struct cmd_config_speed_all *res = parsed_result;
930 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
931 uint16_t link_duplex = 0;
934 if (!all_ports_stopped()) {
935 printf("Please stop all ports first\n");
939 if (!strcmp(res->value1, "10"))
940 link_speed = ETH_LINK_SPEED_10;
941 else if (!strcmp(res->value1, "100"))
942 link_speed = ETH_LINK_SPEED_100;
943 else if (!strcmp(res->value1, "1000"))
944 link_speed = ETH_LINK_SPEED_1000;
945 else if (!strcmp(res->value1, "10000"))
946 link_speed = ETH_LINK_SPEED_10G;
947 else if (!strcmp(res->value1, "40000"))
948 link_speed = ETH_LINK_SPEED_40G;
949 else if (!strcmp(res->value1, "auto"))
950 link_speed = ETH_LINK_SPEED_AUTONEG;
952 printf("Unknown parameter\n");
956 if (!strcmp(res->value2, "half"))
957 link_duplex = ETH_LINK_HALF_DUPLEX;
958 else if (!strcmp(res->value2, "full"))
959 link_duplex = ETH_LINK_FULL_DUPLEX;
960 else if (!strcmp(res->value2, "auto"))
961 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
963 printf("Unknown parameter\n");
967 FOREACH_PORT(pid, ports) {
968 ports[pid].dev_conf.link_speed = link_speed;
969 ports[pid].dev_conf.link_duplex = link_duplex;
972 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
975 cmdline_parse_token_string_t cmd_config_speed_all_port =
976 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
977 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
978 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
980 cmdline_parse_token_string_t cmd_config_speed_all_all =
981 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
982 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
983 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
984 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
985 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
986 "10#100#1000#10000#40000#auto");
987 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
988 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
989 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
990 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
993 cmdline_parse_inst_t cmd_config_speed_all = {
994 .f = cmd_config_speed_all_parsed,
996 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
999 (void *)&cmd_config_speed_all_port,
1000 (void *)&cmd_config_speed_all_keyword,
1001 (void *)&cmd_config_speed_all_all,
1002 (void *)&cmd_config_speed_all_item1,
1003 (void *)&cmd_config_speed_all_value1,
1004 (void *)&cmd_config_speed_all_item2,
1005 (void *)&cmd_config_speed_all_value2,
1010 /* *** configure speed for specific port *** */
1011 struct cmd_config_speed_specific {
1012 cmdline_fixed_string_t port;
1013 cmdline_fixed_string_t keyword;
1015 cmdline_fixed_string_t item1;
1016 cmdline_fixed_string_t item2;
1017 cmdline_fixed_string_t value1;
1018 cmdline_fixed_string_t value2;
1022 cmd_config_speed_specific_parsed(void *parsed_result,
1023 __attribute__((unused)) struct cmdline *cl,
1024 __attribute__((unused)) void *data)
1026 struct cmd_config_speed_specific *res = parsed_result;
1027 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1028 uint16_t link_duplex = 0;
1030 if (!all_ports_stopped()) {
1031 printf("Please stop all ports first\n");
1035 if (port_id_is_invalid(res->id, ENABLED_WARN))
1038 if (!strcmp(res->value1, "10"))
1039 link_speed = ETH_LINK_SPEED_10;
1040 else if (!strcmp(res->value1, "100"))
1041 link_speed = ETH_LINK_SPEED_100;
1042 else if (!strcmp(res->value1, "1000"))
1043 link_speed = ETH_LINK_SPEED_1000;
1044 else if (!strcmp(res->value1, "10000"))
1045 link_speed = ETH_LINK_SPEED_10000;
1046 else if (!strcmp(res->value1, "40000"))
1047 link_speed = ETH_LINK_SPEED_40G;
1048 else if (!strcmp(res->value1, "auto"))
1049 link_speed = ETH_LINK_SPEED_AUTONEG;
1051 printf("Unknown parameter\n");
1055 if (!strcmp(res->value2, "half"))
1056 link_duplex = ETH_LINK_HALF_DUPLEX;
1057 else if (!strcmp(res->value2, "full"))
1058 link_duplex = ETH_LINK_FULL_DUPLEX;
1059 else if (!strcmp(res->value2, "auto"))
1060 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1062 printf("Unknown parameter\n");
1066 ports[res->id].dev_conf.link_speed = link_speed;
1067 ports[res->id].dev_conf.link_duplex = link_duplex;
1069 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1073 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1074 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1076 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1077 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1079 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1080 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1081 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1082 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1084 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1085 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1086 "10#100#1000#10000#40000#auto");
1087 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1088 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1090 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1091 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1094 cmdline_parse_inst_t cmd_config_speed_specific = {
1095 .f = cmd_config_speed_specific_parsed,
1097 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1100 (void *)&cmd_config_speed_specific_port,
1101 (void *)&cmd_config_speed_specific_keyword,
1102 (void *)&cmd_config_speed_specific_id,
1103 (void *)&cmd_config_speed_specific_item1,
1104 (void *)&cmd_config_speed_specific_value1,
1105 (void *)&cmd_config_speed_specific_item2,
1106 (void *)&cmd_config_speed_specific_value2,
1111 /* *** configure txq/rxq, txd/rxd *** */
1112 struct cmd_config_rx_tx {
1113 cmdline_fixed_string_t port;
1114 cmdline_fixed_string_t keyword;
1115 cmdline_fixed_string_t all;
1116 cmdline_fixed_string_t name;
1121 cmd_config_rx_tx_parsed(void *parsed_result,
1122 __attribute__((unused)) struct cmdline *cl,
1123 __attribute__((unused)) void *data)
1125 struct cmd_config_rx_tx *res = parsed_result;
1127 if (!all_ports_stopped()) {
1128 printf("Please stop all ports first\n");
1132 if (!strcmp(res->name, "rxq")) {
1133 if (res->value <= 0) {
1134 printf("rxq %d invalid - must be > 0\n", res->value);
1137 nb_rxq = res->value;
1139 else if (!strcmp(res->name, "txq")) {
1140 if (res->value <= 0) {
1141 printf("txq %d invalid - must be > 0\n", res->value);
1144 nb_txq = res->value;
1146 else if (!strcmp(res->name, "rxd")) {
1147 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1148 printf("rxd %d invalid - must be > 0 && <= %d\n",
1149 res->value, RTE_TEST_RX_DESC_MAX);
1152 nb_rxd = res->value;
1153 } else if (!strcmp(res->name, "txd")) {
1154 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1155 printf("txd %d invalid - must be > 0 && <= %d\n",
1156 res->value, RTE_TEST_TX_DESC_MAX);
1159 nb_txd = res->value;
1161 printf("Unknown parameter\n");
1167 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1170 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1171 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1172 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1173 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1174 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1175 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1176 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1177 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1179 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1180 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1182 cmdline_parse_inst_t cmd_config_rx_tx = {
1183 .f = cmd_config_rx_tx_parsed,
1185 .help_str = "port config all rxq|txq|rxd|txd value",
1187 (void *)&cmd_config_rx_tx_port,
1188 (void *)&cmd_config_rx_tx_keyword,
1189 (void *)&cmd_config_rx_tx_all,
1190 (void *)&cmd_config_rx_tx_name,
1191 (void *)&cmd_config_rx_tx_value,
1196 /* *** config max packet length *** */
1197 struct cmd_config_max_pkt_len_result {
1198 cmdline_fixed_string_t port;
1199 cmdline_fixed_string_t keyword;
1200 cmdline_fixed_string_t all;
1201 cmdline_fixed_string_t name;
1206 cmd_config_max_pkt_len_parsed(void *parsed_result,
1207 __attribute__((unused)) struct cmdline *cl,
1208 __attribute__((unused)) void *data)
1210 struct cmd_config_max_pkt_len_result *res = parsed_result;
1212 if (!all_ports_stopped()) {
1213 printf("Please stop all ports first\n");
1217 if (!strcmp(res->name, "max-pkt-len")) {
1218 if (res->value < ETHER_MIN_LEN) {
1219 printf("max-pkt-len can not be less than %d\n",
1223 if (res->value == rx_mode.max_rx_pkt_len)
1226 rx_mode.max_rx_pkt_len = res->value;
1227 if (res->value > ETHER_MAX_LEN)
1228 rx_mode.jumbo_frame = 1;
1230 rx_mode.jumbo_frame = 0;
1232 printf("Unknown parameter\n");
1238 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1241 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1242 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1244 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1245 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1247 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1248 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1250 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1251 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1253 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1254 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1257 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1258 .f = cmd_config_max_pkt_len_parsed,
1260 .help_str = "port config all max-pkt-len value",
1262 (void *)&cmd_config_max_pkt_len_port,
1263 (void *)&cmd_config_max_pkt_len_keyword,
1264 (void *)&cmd_config_max_pkt_len_all,
1265 (void *)&cmd_config_max_pkt_len_name,
1266 (void *)&cmd_config_max_pkt_len_value,
1271 /* *** configure port MTU *** */
1272 struct cmd_config_mtu_result {
1273 cmdline_fixed_string_t port;
1274 cmdline_fixed_string_t keyword;
1275 cmdline_fixed_string_t mtu;
1281 cmd_config_mtu_parsed(void *parsed_result,
1282 __attribute__((unused)) struct cmdline *cl,
1283 __attribute__((unused)) void *data)
1285 struct cmd_config_mtu_result *res = parsed_result;
1287 if (res->value < ETHER_MIN_LEN) {
1288 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1291 port_mtu_set(res->port_id, res->value);
1294 cmdline_parse_token_string_t cmd_config_mtu_port =
1295 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1297 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1298 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1300 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1301 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1303 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1304 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1305 cmdline_parse_token_num_t cmd_config_mtu_value =
1306 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1308 cmdline_parse_inst_t cmd_config_mtu = {
1309 .f = cmd_config_mtu_parsed,
1311 .help_str = "port config mtu value",
1313 (void *)&cmd_config_mtu_port,
1314 (void *)&cmd_config_mtu_keyword,
1315 (void *)&cmd_config_mtu_mtu,
1316 (void *)&cmd_config_mtu_port_id,
1317 (void *)&cmd_config_mtu_value,
1322 /* *** configure rx mode *** */
1323 struct cmd_config_rx_mode_flag {
1324 cmdline_fixed_string_t port;
1325 cmdline_fixed_string_t keyword;
1326 cmdline_fixed_string_t all;
1327 cmdline_fixed_string_t name;
1328 cmdline_fixed_string_t value;
1332 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1333 __attribute__((unused)) struct cmdline *cl,
1334 __attribute__((unused)) void *data)
1336 struct cmd_config_rx_mode_flag *res = parsed_result;
1338 if (!all_ports_stopped()) {
1339 printf("Please stop all ports first\n");
1343 if (!strcmp(res->name, "crc-strip")) {
1344 if (!strcmp(res->value, "on"))
1345 rx_mode.hw_strip_crc = 1;
1346 else if (!strcmp(res->value, "off"))
1347 rx_mode.hw_strip_crc = 0;
1349 printf("Unknown parameter\n");
1352 } else if (!strcmp(res->name, "rx-cksum")) {
1353 if (!strcmp(res->value, "on"))
1354 rx_mode.hw_ip_checksum = 1;
1355 else if (!strcmp(res->value, "off"))
1356 rx_mode.hw_ip_checksum = 0;
1358 printf("Unknown parameter\n");
1361 } else if (!strcmp(res->name, "hw-vlan")) {
1362 if (!strcmp(res->value, "on")) {
1363 rx_mode.hw_vlan_filter = 1;
1364 rx_mode.hw_vlan_strip = 1;
1366 else if (!strcmp(res->value, "off")) {
1367 rx_mode.hw_vlan_filter = 0;
1368 rx_mode.hw_vlan_strip = 0;
1371 printf("Unknown parameter\n");
1374 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1375 if (!strcmp(res->value, "on"))
1376 rx_mode.hw_vlan_filter = 1;
1377 else if (!strcmp(res->value, "off"))
1378 rx_mode.hw_vlan_filter = 0;
1380 printf("Unknown parameter\n");
1383 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1384 if (!strcmp(res->value, "on"))
1385 rx_mode.hw_vlan_strip = 1;
1386 else if (!strcmp(res->value, "off"))
1387 rx_mode.hw_vlan_strip = 0;
1389 printf("Unknown parameter\n");
1392 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1393 if (!strcmp(res->value, "on"))
1394 rx_mode.hw_vlan_extend = 1;
1395 else if (!strcmp(res->value, "off"))
1396 rx_mode.hw_vlan_extend = 0;
1398 printf("Unknown parameter\n");
1401 } else if (!strcmp(res->name, "drop-en")) {
1402 if (!strcmp(res->value, "on"))
1404 else if (!strcmp(res->value, "off"))
1407 printf("Unknown parameter\n");
1411 printf("Unknown parameter\n");
1417 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1420 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1421 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1422 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1425 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1427 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1428 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1429 "crc-strip#rx-cksum#hw-vlan#"
1430 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1431 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1432 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1435 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1436 .f = cmd_config_rx_mode_flag_parsed,
1438 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1439 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1441 (void *)&cmd_config_rx_mode_flag_port,
1442 (void *)&cmd_config_rx_mode_flag_keyword,
1443 (void *)&cmd_config_rx_mode_flag_all,
1444 (void *)&cmd_config_rx_mode_flag_name,
1445 (void *)&cmd_config_rx_mode_flag_value,
1450 /* *** configure rss *** */
1451 struct cmd_config_rss {
1452 cmdline_fixed_string_t port;
1453 cmdline_fixed_string_t keyword;
1454 cmdline_fixed_string_t all;
1455 cmdline_fixed_string_t name;
1456 cmdline_fixed_string_t value;
1460 cmd_config_rss_parsed(void *parsed_result,
1461 __attribute__((unused)) struct cmdline *cl,
1462 __attribute__((unused)) void *data)
1464 struct cmd_config_rss *res = parsed_result;
1465 struct rte_eth_rss_conf rss_conf;
1468 if (!strcmp(res->value, "all"))
1469 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1470 ETH_RSS_UDP | ETH_RSS_SCTP |
1472 else if (!strcmp(res->value, "ip"))
1473 rss_conf.rss_hf = ETH_RSS_IP;
1474 else if (!strcmp(res->value, "udp"))
1475 rss_conf.rss_hf = ETH_RSS_UDP;
1476 else if (!strcmp(res->value, "tcp"))
1477 rss_conf.rss_hf = ETH_RSS_TCP;
1478 else if (!strcmp(res->value, "sctp"))
1479 rss_conf.rss_hf = ETH_RSS_SCTP;
1480 else if (!strcmp(res->value, "ether"))
1481 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1482 else if (!strcmp(res->value, "none"))
1483 rss_conf.rss_hf = 0;
1485 printf("Unknown parameter\n");
1488 rss_conf.rss_key = NULL;
1489 for (i = 0; i < rte_eth_dev_count(); i++)
1490 rte_eth_dev_rss_hash_update(i, &rss_conf);
1493 cmdline_parse_token_string_t cmd_config_rss_port =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1495 cmdline_parse_token_string_t cmd_config_rss_keyword =
1496 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1497 cmdline_parse_token_string_t cmd_config_rss_all =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1499 cmdline_parse_token_string_t cmd_config_rss_name =
1500 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1501 cmdline_parse_token_string_t cmd_config_rss_value =
1502 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1503 "all#ip#tcp#udp#sctp#ether#none");
1505 cmdline_parse_inst_t cmd_config_rss = {
1506 .f = cmd_config_rss_parsed,
1508 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1510 (void *)&cmd_config_rss_port,
1511 (void *)&cmd_config_rss_keyword,
1512 (void *)&cmd_config_rss_all,
1513 (void *)&cmd_config_rss_name,
1514 (void *)&cmd_config_rss_value,
1519 /* *** configure rss hash key *** */
1520 struct cmd_config_rss_hash_key {
1521 cmdline_fixed_string_t port;
1522 cmdline_fixed_string_t config;
1524 cmdline_fixed_string_t rss_hash_key;
1525 cmdline_fixed_string_t rss_type;
1526 cmdline_fixed_string_t key;
1529 #define RSS_HASH_KEY_LENGTH 40
1531 hexa_digit_to_value(char hexa_digit)
1533 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1534 return (uint8_t) (hexa_digit - '0');
1535 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1536 return (uint8_t) ((hexa_digit - 'a') + 10);
1537 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1538 return (uint8_t) ((hexa_digit - 'A') + 10);
1539 /* Invalid hexa digit */
1544 parse_and_check_key_hexa_digit(char *key, int idx)
1548 hexa_v = hexa_digit_to_value(key[idx]);
1550 printf("invalid key: character %c at position %d is not a "
1551 "valid hexa digit\n", key[idx], idx);
1556 cmd_config_rss_hash_key_parsed(void *parsed_result,
1557 __attribute__((unused)) struct cmdline *cl,
1558 __attribute__((unused)) void *data)
1560 struct cmd_config_rss_hash_key *res = parsed_result;
1561 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1566 /* Check the length of the RSS hash key */
1567 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1568 printf("key length: %d invalid - key must be a string of %d"
1569 "hexa-decimal numbers\n", (int) strlen(res->key),
1570 RSS_HASH_KEY_LENGTH * 2);
1573 /* Translate RSS hash key into binary representation */
1574 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1575 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1578 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1581 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1583 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1584 RSS_HASH_KEY_LENGTH);
1587 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1588 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1589 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1590 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1592 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1593 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1594 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1595 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1596 rss_hash_key, "rss-hash-key");
1597 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1598 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1599 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1600 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1601 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1602 "ipv6-tcp-ex#ipv6-udp-ex");
1603 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1604 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1606 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1607 .f = cmd_config_rss_hash_key_parsed,
1610 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1611 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1612 "ipv6-sctp|ipv6-other|l2-payload|"
1613 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1615 (void *)&cmd_config_rss_hash_key_port,
1616 (void *)&cmd_config_rss_hash_key_config,
1617 (void *)&cmd_config_rss_hash_key_port_id,
1618 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1619 (void *)&cmd_config_rss_hash_key_rss_type,
1620 (void *)&cmd_config_rss_hash_key_value,
1625 /* *** configure port rxq/txq start/stop *** */
1626 struct cmd_config_rxtx_queue {
1627 cmdline_fixed_string_t port;
1629 cmdline_fixed_string_t rxtxq;
1631 cmdline_fixed_string_t opname;
1635 cmd_config_rxtx_queue_parsed(void *parsed_result,
1636 __attribute__((unused)) struct cmdline *cl,
1637 __attribute__((unused)) void *data)
1639 struct cmd_config_rxtx_queue *res = parsed_result;
1644 if (test_done == 0) {
1645 printf("Please stop forwarding first\n");
1649 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1652 if (port_is_started(res->portid) != 1) {
1653 printf("Please start port %u first\n", res->portid);
1657 if (!strcmp(res->rxtxq, "rxq"))
1659 else if (!strcmp(res->rxtxq, "txq"))
1662 printf("Unknown parameter\n");
1666 if (isrx && rx_queue_id_is_invalid(res->qid))
1668 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1671 if (!strcmp(res->opname, "start"))
1673 else if (!strcmp(res->opname, "stop"))
1676 printf("Unknown parameter\n");
1680 if (isstart && isrx)
1681 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1682 else if (!isstart && isrx)
1683 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1684 else if (isstart && !isrx)
1685 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1687 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1689 if (ret == -ENOTSUP)
1690 printf("Function not supported in PMD driver\n");
1693 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1695 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1696 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1697 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1699 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1700 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1701 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1705 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1706 .f = cmd_config_rxtx_queue_parsed,
1708 .help_str = "port X rxq|txq ID start|stop",
1710 (void *)&cmd_config_speed_all_port,
1711 (void *)&cmd_config_rxtx_queue_portid,
1712 (void *)&cmd_config_rxtx_queue_rxtxq,
1713 (void *)&cmd_config_rxtx_queue_qid,
1714 (void *)&cmd_config_rxtx_queue_opname,
1719 /* *** Configure RSS RETA *** */
1720 struct cmd_config_rss_reta {
1721 cmdline_fixed_string_t port;
1722 cmdline_fixed_string_t keyword;
1724 cmdline_fixed_string_t name;
1725 cmdline_fixed_string_t list_name;
1726 cmdline_fixed_string_t list_of_items;
1730 parse_reta_config(const char *str,
1731 struct rte_eth_rss_reta_entry64 *reta_conf,
1732 uint16_t nb_entries)
1736 uint16_t hash_index, idx, shift;
1739 const char *p, *p0 = str;
1746 unsigned long int_fld[_NUM_FLD];
1747 char *str_fld[_NUM_FLD];
1749 while ((p = strchr(p0,'(')) != NULL) {
1751 if((p0 = strchr(p,')')) == NULL)
1755 if(size >= sizeof(s))
1758 snprintf(s, sizeof(s), "%.*s", size, p);
1759 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1761 for (i = 0; i < _NUM_FLD; i++) {
1763 int_fld[i] = strtoul(str_fld[i], &end, 0);
1764 if (errno != 0 || end == str_fld[i] ||
1769 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1770 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1772 if (hash_index >= nb_entries) {
1773 printf("Invalid RETA hash index=%d\n", hash_index);
1777 idx = hash_index / RTE_RETA_GROUP_SIZE;
1778 shift = hash_index % RTE_RETA_GROUP_SIZE;
1779 reta_conf[idx].mask |= (1ULL << shift);
1780 reta_conf[idx].reta[shift] = nb_queue;
1787 cmd_set_rss_reta_parsed(void *parsed_result,
1788 __attribute__((unused)) struct cmdline *cl,
1789 __attribute__((unused)) void *data)
1792 struct rte_eth_dev_info dev_info;
1793 struct rte_eth_rss_reta_entry64 reta_conf[8];
1794 struct cmd_config_rss_reta *res = parsed_result;
1796 memset(&dev_info, 0, sizeof(dev_info));
1797 rte_eth_dev_info_get(res->port_id, &dev_info);
1798 if (dev_info.reta_size == 0) {
1799 printf("Redirection table size is 0 which is "
1800 "invalid for RSS\n");
1803 printf("The reta size of port %d is %u\n",
1804 res->port_id, dev_info.reta_size);
1805 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1806 printf("Currently do not support more than %u entries of "
1807 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1811 memset(reta_conf, 0, sizeof(reta_conf));
1812 if (!strcmp(res->list_name, "reta")) {
1813 if (parse_reta_config(res->list_of_items, reta_conf,
1814 dev_info.reta_size)) {
1815 printf("Invalid RSS Redirection Table "
1816 "config entered\n");
1819 ret = rte_eth_dev_rss_reta_update(res->port_id,
1820 reta_conf, dev_info.reta_size);
1822 printf("Bad redirection table parameter, "
1823 "return code = %d \n", ret);
1827 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1828 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1829 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1831 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1832 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1833 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1834 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1835 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1836 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1837 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1838 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1840 cmdline_parse_inst_t cmd_config_rss_reta = {
1841 .f = cmd_set_rss_reta_parsed,
1843 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1845 (void *)&cmd_config_rss_reta_port,
1846 (void *)&cmd_config_rss_reta_keyword,
1847 (void *)&cmd_config_rss_reta_port_id,
1848 (void *)&cmd_config_rss_reta_name,
1849 (void *)&cmd_config_rss_reta_list_name,
1850 (void *)&cmd_config_rss_reta_list_of_items,
1855 /* *** SHOW PORT RETA INFO *** */
1856 struct cmd_showport_reta {
1857 cmdline_fixed_string_t show;
1858 cmdline_fixed_string_t port;
1860 cmdline_fixed_string_t rss;
1861 cmdline_fixed_string_t reta;
1863 cmdline_fixed_string_t list_of_items;
1867 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1868 uint16_t nb_entries,
1872 const char *p, *p0 = str;
1876 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1879 p = strchr(p0, '(');
1883 p0 = strchr(p, ')');
1887 if (size >= sizeof(s)) {
1888 printf("The string size exceeds the internal buffer size\n");
1891 snprintf(s, sizeof(s), "%.*s", size, p);
1892 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1893 if (ret <= 0 || ret != num) {
1894 printf("The bits of masks do not match the number of "
1895 "reta entries: %u\n", num);
1898 for (i = 0; i < ret; i++)
1899 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1905 cmd_showport_reta_parsed(void *parsed_result,
1906 __attribute__((unused)) struct cmdline *cl,
1907 __attribute__((unused)) void *data)
1909 struct cmd_showport_reta *res = parsed_result;
1910 struct rte_eth_rss_reta_entry64 reta_conf[8];
1911 struct rte_eth_dev_info dev_info;
1913 memset(&dev_info, 0, sizeof(dev_info));
1914 rte_eth_dev_info_get(res->port_id, &dev_info);
1915 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1916 res->size > ETH_RSS_RETA_SIZE_512) {
1917 printf("Invalid redirection table size: %u\n", res->size);
1921 memset(reta_conf, 0, sizeof(reta_conf));
1922 if (showport_parse_reta_config(reta_conf, res->size,
1923 res->list_of_items) < 0) {
1924 printf("Invalid string: %s for reta masks\n",
1925 res->list_of_items);
1928 port_rss_reta_info(res->port_id, reta_conf, res->size);
1931 cmdline_parse_token_string_t cmd_showport_reta_show =
1932 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1933 cmdline_parse_token_string_t cmd_showport_reta_port =
1934 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1935 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1936 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1937 cmdline_parse_token_string_t cmd_showport_reta_rss =
1938 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1939 cmdline_parse_token_string_t cmd_showport_reta_reta =
1940 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1941 cmdline_parse_token_num_t cmd_showport_reta_size =
1942 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1943 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1944 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1945 list_of_items, NULL);
1947 cmdline_parse_inst_t cmd_showport_reta = {
1948 .f = cmd_showport_reta_parsed,
1950 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1952 (void *)&cmd_showport_reta_show,
1953 (void *)&cmd_showport_reta_port,
1954 (void *)&cmd_showport_reta_port_id,
1955 (void *)&cmd_showport_reta_rss,
1956 (void *)&cmd_showport_reta_reta,
1957 (void *)&cmd_showport_reta_size,
1958 (void *)&cmd_showport_reta_list_of_items,
1963 /* *** Show RSS hash configuration *** */
1964 struct cmd_showport_rss_hash {
1965 cmdline_fixed_string_t show;
1966 cmdline_fixed_string_t port;
1968 cmdline_fixed_string_t rss_hash;
1969 cmdline_fixed_string_t rss_type;
1970 cmdline_fixed_string_t key; /* optional argument */
1973 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1974 __attribute__((unused)) struct cmdline *cl,
1977 struct cmd_showport_rss_hash *res = parsed_result;
1979 port_rss_hash_conf_show(res->port_id, res->rss_type,
1980 show_rss_key != NULL);
1983 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1984 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1985 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1986 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1987 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1988 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1989 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1990 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1992 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
1993 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
1994 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1995 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1996 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1997 "ipv6-tcp-ex#ipv6-udp-ex");
1998 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1999 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2001 cmdline_parse_inst_t cmd_showport_rss_hash = {
2002 .f = cmd_showport_rss_hash_parsed,
2005 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2006 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2007 "ipv6-sctp|ipv6-other|l2-payload|"
2008 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2010 (void *)&cmd_showport_rss_hash_show,
2011 (void *)&cmd_showport_rss_hash_port,
2012 (void *)&cmd_showport_rss_hash_port_id,
2013 (void *)&cmd_showport_rss_hash_rss_hash,
2014 (void *)&cmd_showport_rss_hash_rss_hash_info,
2019 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2020 .f = cmd_showport_rss_hash_parsed,
2023 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2024 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2025 "ipv6-sctp|ipv6-other|l2-payload|"
2026 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2028 (void *)&cmd_showport_rss_hash_show,
2029 (void *)&cmd_showport_rss_hash_port,
2030 (void *)&cmd_showport_rss_hash_port_id,
2031 (void *)&cmd_showport_rss_hash_rss_hash,
2032 (void *)&cmd_showport_rss_hash_rss_hash_info,
2033 (void *)&cmd_showport_rss_hash_rss_key,
2038 /* *** Configure DCB *** */
2039 struct cmd_config_dcb {
2040 cmdline_fixed_string_t port;
2041 cmdline_fixed_string_t config;
2043 cmdline_fixed_string_t dcb;
2044 cmdline_fixed_string_t vt;
2045 cmdline_fixed_string_t vt_en;
2047 cmdline_fixed_string_t pfc;
2048 cmdline_fixed_string_t pfc_en;
2052 cmd_config_dcb_parsed(void *parsed_result,
2053 __attribute__((unused)) struct cmdline *cl,
2054 __attribute__((unused)) void *data)
2056 struct cmd_config_dcb *res = parsed_result;
2057 portid_t port_id = res->port_id;
2058 struct rte_port *port;
2062 port = &ports[port_id];
2063 /** Check if the port is not started **/
2064 if (port->port_status != RTE_PORT_STOPPED) {
2065 printf("Please stop port %d first\n", port_id);
2069 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2070 printf("The invalid number of traffic class,"
2071 " only 4 or 8 allowed.\n");
2075 if (nb_fwd_lcores < res->num_tcs) {
2076 printf("nb_cores shouldn't be less than number of TCs.\n");
2079 if (!strncmp(res->pfc_en, "on", 2))
2084 /* DCB in VT mode */
2085 if (!strncmp(res->vt_en, "on", 2))
2086 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2087 (enum rte_eth_nb_tcs)res->num_tcs,
2090 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2091 (enum rte_eth_nb_tcs)res->num_tcs,
2096 printf("Cannot initialize network ports.\n");
2100 cmd_reconfig_device_queue(port_id, 1, 1);
2103 cmdline_parse_token_string_t cmd_config_dcb_port =
2104 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2105 cmdline_parse_token_string_t cmd_config_dcb_config =
2106 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2107 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2108 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2109 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2111 cmdline_parse_token_string_t cmd_config_dcb_vt =
2112 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2113 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2115 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2116 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2117 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2119 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2122 cmdline_parse_inst_t cmd_config_dcb = {
2123 .f = cmd_config_dcb_parsed,
2125 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2127 (void *)&cmd_config_dcb_port,
2128 (void *)&cmd_config_dcb_config,
2129 (void *)&cmd_config_dcb_port_id,
2130 (void *)&cmd_config_dcb_dcb,
2131 (void *)&cmd_config_dcb_vt,
2132 (void *)&cmd_config_dcb_vt_en,
2133 (void *)&cmd_config_dcb_num_tcs,
2134 (void *)&cmd_config_dcb_pfc,
2135 (void *)&cmd_config_dcb_pfc_en,
2140 /* *** configure number of packets per burst *** */
2141 struct cmd_config_burst {
2142 cmdline_fixed_string_t port;
2143 cmdline_fixed_string_t keyword;
2144 cmdline_fixed_string_t all;
2145 cmdline_fixed_string_t name;
2150 cmd_config_burst_parsed(void *parsed_result,
2151 __attribute__((unused)) struct cmdline *cl,
2152 __attribute__((unused)) void *data)
2154 struct cmd_config_burst *res = parsed_result;
2156 if (!all_ports_stopped()) {
2157 printf("Please stop all ports first\n");
2161 if (!strcmp(res->name, "burst")) {
2162 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2163 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2166 nb_pkt_per_burst = res->value;
2168 printf("Unknown parameter\n");
2174 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2177 cmdline_parse_token_string_t cmd_config_burst_port =
2178 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2179 cmdline_parse_token_string_t cmd_config_burst_keyword =
2180 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2181 cmdline_parse_token_string_t cmd_config_burst_all =
2182 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2183 cmdline_parse_token_string_t cmd_config_burst_name =
2184 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2185 cmdline_parse_token_num_t cmd_config_burst_value =
2186 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2188 cmdline_parse_inst_t cmd_config_burst = {
2189 .f = cmd_config_burst_parsed,
2191 .help_str = "port config all burst value",
2193 (void *)&cmd_config_burst_port,
2194 (void *)&cmd_config_burst_keyword,
2195 (void *)&cmd_config_burst_all,
2196 (void *)&cmd_config_burst_name,
2197 (void *)&cmd_config_burst_value,
2202 /* *** configure rx/tx queues *** */
2203 struct cmd_config_thresh {
2204 cmdline_fixed_string_t port;
2205 cmdline_fixed_string_t keyword;
2206 cmdline_fixed_string_t all;
2207 cmdline_fixed_string_t name;
2212 cmd_config_thresh_parsed(void *parsed_result,
2213 __attribute__((unused)) struct cmdline *cl,
2214 __attribute__((unused)) void *data)
2216 struct cmd_config_thresh *res = parsed_result;
2218 if (!all_ports_stopped()) {
2219 printf("Please stop all ports first\n");
2223 if (!strcmp(res->name, "txpt"))
2224 tx_pthresh = res->value;
2225 else if(!strcmp(res->name, "txht"))
2226 tx_hthresh = res->value;
2227 else if(!strcmp(res->name, "txwt"))
2228 tx_wthresh = res->value;
2229 else if(!strcmp(res->name, "rxpt"))
2230 rx_pthresh = res->value;
2231 else if(!strcmp(res->name, "rxht"))
2232 rx_hthresh = res->value;
2233 else if(!strcmp(res->name, "rxwt"))
2234 rx_wthresh = res->value;
2236 printf("Unknown parameter\n");
2242 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2245 cmdline_parse_token_string_t cmd_config_thresh_port =
2246 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2247 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2248 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2249 cmdline_parse_token_string_t cmd_config_thresh_all =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2251 cmdline_parse_token_string_t cmd_config_thresh_name =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2253 "txpt#txht#txwt#rxpt#rxht#rxwt");
2254 cmdline_parse_token_num_t cmd_config_thresh_value =
2255 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2257 cmdline_parse_inst_t cmd_config_thresh = {
2258 .f = cmd_config_thresh_parsed,
2260 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2262 (void *)&cmd_config_thresh_port,
2263 (void *)&cmd_config_thresh_keyword,
2264 (void *)&cmd_config_thresh_all,
2265 (void *)&cmd_config_thresh_name,
2266 (void *)&cmd_config_thresh_value,
2271 /* *** configure free/rs threshold *** */
2272 struct cmd_config_threshold {
2273 cmdline_fixed_string_t port;
2274 cmdline_fixed_string_t keyword;
2275 cmdline_fixed_string_t all;
2276 cmdline_fixed_string_t name;
2281 cmd_config_threshold_parsed(void *parsed_result,
2282 __attribute__((unused)) struct cmdline *cl,
2283 __attribute__((unused)) void *data)
2285 struct cmd_config_threshold *res = parsed_result;
2287 if (!all_ports_stopped()) {
2288 printf("Please stop all ports first\n");
2292 if (!strcmp(res->name, "txfreet"))
2293 tx_free_thresh = res->value;
2294 else if (!strcmp(res->name, "txrst"))
2295 tx_rs_thresh = res->value;
2296 else if (!strcmp(res->name, "rxfreet"))
2297 rx_free_thresh = res->value;
2299 printf("Unknown parameter\n");
2305 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2308 cmdline_parse_token_string_t cmd_config_threshold_port =
2309 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2310 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2311 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2313 cmdline_parse_token_string_t cmd_config_threshold_all =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2315 cmdline_parse_token_string_t cmd_config_threshold_name =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2317 "txfreet#txrst#rxfreet");
2318 cmdline_parse_token_num_t cmd_config_threshold_value =
2319 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2321 cmdline_parse_inst_t cmd_config_threshold = {
2322 .f = cmd_config_threshold_parsed,
2324 .help_str = "port config all txfreet|txrst|rxfreet value",
2326 (void *)&cmd_config_threshold_port,
2327 (void *)&cmd_config_threshold_keyword,
2328 (void *)&cmd_config_threshold_all,
2329 (void *)&cmd_config_threshold_name,
2330 (void *)&cmd_config_threshold_value,
2336 struct cmd_stop_result {
2337 cmdline_fixed_string_t stop;
2340 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2341 __attribute__((unused)) struct cmdline *cl,
2342 __attribute__((unused)) void *data)
2344 stop_packet_forwarding();
2347 cmdline_parse_token_string_t cmd_stop_stop =
2348 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2350 cmdline_parse_inst_t cmd_stop = {
2351 .f = cmd_stop_parsed,
2353 .help_str = "stop - stop packet forwarding",
2355 (void *)&cmd_stop_stop,
2360 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2363 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2364 unsigned int *parsed_items, int check_unique_values)
2366 unsigned int nb_item;
2374 * First parse all items in the list and store their value.
2379 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2381 if ((c >= '0') && (c <= '9')) {
2382 value = (unsigned int) (value * 10 + (c - '0'));
2387 printf("character %c is not a decimal digit\n", c);
2391 printf("No valid value before comma\n");
2394 if (nb_item < max_items) {
2395 parsed_items[nb_item] = value;
2401 if (nb_item >= max_items) {
2402 printf("Number of %s = %u > %u (maximum items)\n",
2403 item_name, nb_item + 1, max_items);
2406 parsed_items[nb_item++] = value;
2407 if (! check_unique_values)
2411 * Then, check that all values in the list are differents.
2412 * No optimization here...
2414 for (i = 0; i < nb_item; i++) {
2415 for (j = i + 1; j < nb_item; j++) {
2416 if (parsed_items[j] == parsed_items[i]) {
2417 printf("duplicated %s %u at index %u and %u\n",
2418 item_name, parsed_items[i], i, j);
2426 struct cmd_set_list_result {
2427 cmdline_fixed_string_t cmd_keyword;
2428 cmdline_fixed_string_t list_name;
2429 cmdline_fixed_string_t list_of_items;
2432 static void cmd_set_list_parsed(void *parsed_result,
2433 __attribute__((unused)) struct cmdline *cl,
2434 __attribute__((unused)) void *data)
2436 struct cmd_set_list_result *res;
2438 unsigned int lcorelist[RTE_MAX_LCORE];
2439 unsigned int portlist[RTE_MAX_ETHPORTS];
2441 unsigned int nb_item;
2443 if (test_done == 0) {
2444 printf("Please stop forwarding first\n");
2448 res = parsed_result;
2449 if (!strcmp(res->list_name, "corelist")) {
2450 nb_item = parse_item_list(res->list_of_items, "core",
2452 parsed_items.lcorelist, 1);
2454 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2457 if (!strcmp(res->list_name, "portlist")) {
2458 nb_item = parse_item_list(res->list_of_items, "port",
2460 parsed_items.portlist, 1);
2462 set_fwd_ports_list(parsed_items.portlist, nb_item);
2466 cmdline_parse_token_string_t cmd_set_list_keyword =
2467 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2469 cmdline_parse_token_string_t cmd_set_list_name =
2470 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2471 "corelist#portlist");
2472 cmdline_parse_token_string_t cmd_set_list_of_items =
2473 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2476 cmdline_parse_inst_t cmd_set_fwd_list = {
2477 .f = cmd_set_list_parsed,
2479 .help_str = "set corelist|portlist x[,y]*",
2481 (void *)&cmd_set_list_keyword,
2482 (void *)&cmd_set_list_name,
2483 (void *)&cmd_set_list_of_items,
2488 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2490 struct cmd_setmask_result {
2491 cmdline_fixed_string_t set;
2492 cmdline_fixed_string_t mask;
2496 static void cmd_set_mask_parsed(void *parsed_result,
2497 __attribute__((unused)) struct cmdline *cl,
2498 __attribute__((unused)) void *data)
2500 struct cmd_setmask_result *res = parsed_result;
2502 if (test_done == 0) {
2503 printf("Please stop forwarding first\n");
2506 if (!strcmp(res->mask, "coremask"))
2507 set_fwd_lcores_mask(res->hexavalue);
2508 else if (!strcmp(res->mask, "portmask"))
2509 set_fwd_ports_mask(res->hexavalue);
2512 cmdline_parse_token_string_t cmd_setmask_set =
2513 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2514 cmdline_parse_token_string_t cmd_setmask_mask =
2515 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2516 "coremask#portmask");
2517 cmdline_parse_token_num_t cmd_setmask_value =
2518 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2520 cmdline_parse_inst_t cmd_set_fwd_mask = {
2521 .f = cmd_set_mask_parsed,
2523 .help_str = "set coremask|portmask hexadecimal value",
2525 (void *)&cmd_setmask_set,
2526 (void *)&cmd_setmask_mask,
2527 (void *)&cmd_setmask_value,
2533 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2535 struct cmd_set_result {
2536 cmdline_fixed_string_t set;
2537 cmdline_fixed_string_t what;
2541 static void cmd_set_parsed(void *parsed_result,
2542 __attribute__((unused)) struct cmdline *cl,
2543 __attribute__((unused)) void *data)
2545 struct cmd_set_result *res = parsed_result;
2546 if (!strcmp(res->what, "nbport"))
2547 set_fwd_ports_number(res->value);
2548 else if (!strcmp(res->what, "nbcore"))
2549 set_fwd_lcores_number(res->value);
2550 else if (!strcmp(res->what, "burst"))
2551 set_nb_pkt_per_burst(res->value);
2552 else if (!strcmp(res->what, "verbose"))
2553 set_verbose_level(res->value);
2556 cmdline_parse_token_string_t cmd_set_set =
2557 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2558 cmdline_parse_token_string_t cmd_set_what =
2559 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2560 "nbport#nbcore#burst#verbose");
2561 cmdline_parse_token_num_t cmd_set_value =
2562 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2564 cmdline_parse_inst_t cmd_set_numbers = {
2565 .f = cmd_set_parsed,
2567 .help_str = "set nbport|nbcore|burst|verbose value",
2569 (void *)&cmd_set_set,
2570 (void *)&cmd_set_what,
2571 (void *)&cmd_set_value,
2576 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2578 struct cmd_set_txpkts_result {
2579 cmdline_fixed_string_t cmd_keyword;
2580 cmdline_fixed_string_t txpkts;
2581 cmdline_fixed_string_t seg_lengths;
2585 cmd_set_txpkts_parsed(void *parsed_result,
2586 __attribute__((unused)) struct cmdline *cl,
2587 __attribute__((unused)) void *data)
2589 struct cmd_set_txpkts_result *res;
2590 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2591 unsigned int nb_segs;
2593 res = parsed_result;
2594 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2595 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2597 set_tx_pkt_segments(seg_lengths, nb_segs);
2600 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2601 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2602 cmd_keyword, "set");
2603 cmdline_parse_token_string_t cmd_set_txpkts_name =
2604 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2606 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2607 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2610 cmdline_parse_inst_t cmd_set_txpkts = {
2611 .f = cmd_set_txpkts_parsed,
2613 .help_str = "set txpkts x[,y]*",
2615 (void *)&cmd_set_txpkts_keyword,
2616 (void *)&cmd_set_txpkts_name,
2617 (void *)&cmd_set_txpkts_lengths,
2622 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2623 struct cmd_rx_vlan_filter_all_result {
2624 cmdline_fixed_string_t rx_vlan;
2625 cmdline_fixed_string_t what;
2626 cmdline_fixed_string_t all;
2631 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2632 __attribute__((unused)) struct cmdline *cl,
2633 __attribute__((unused)) void *data)
2635 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2637 if (!strcmp(res->what, "add"))
2638 rx_vlan_all_filter_set(res->port_id, 1);
2640 rx_vlan_all_filter_set(res->port_id, 0);
2643 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2644 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2645 rx_vlan, "rx_vlan");
2646 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2647 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2649 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2650 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2652 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2653 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2656 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2657 .f = cmd_rx_vlan_filter_all_parsed,
2659 .help_str = "add/remove all identifiers to/from the set of VLAN "
2660 "Identifiers filtered by a port",
2662 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2663 (void *)&cmd_rx_vlan_filter_all_what,
2664 (void *)&cmd_rx_vlan_filter_all_all,
2665 (void *)&cmd_rx_vlan_filter_all_portid,
2670 /* *** VLAN OFFLOAD SET ON A PORT *** */
2671 struct cmd_vlan_offload_result {
2672 cmdline_fixed_string_t vlan;
2673 cmdline_fixed_string_t set;
2674 cmdline_fixed_string_t what;
2675 cmdline_fixed_string_t on;
2676 cmdline_fixed_string_t port_id;
2680 cmd_vlan_offload_parsed(void *parsed_result,
2681 __attribute__((unused)) struct cmdline *cl,
2682 __attribute__((unused)) void *data)
2685 struct cmd_vlan_offload_result *res = parsed_result;
2688 portid_t port_id = 0;
2692 len = strnlen(str, STR_TOKEN_SIZE);
2694 /* Get port_id first */
2702 tmp = strtoul(str, NULL, 0);
2703 /* If port_id greater that what portid_t can represent, return */
2704 if(tmp >= RTE_MAX_ETHPORTS)
2706 port_id = (portid_t)tmp;
2708 if (!strcmp(res->on, "on"))
2713 if (!strcmp(res->what, "strip"))
2714 rx_vlan_strip_set(port_id, on);
2715 else if(!strcmp(res->what, "stripq")){
2716 uint16_t queue_id = 0;
2718 /* No queue_id, return */
2720 printf("must specify (port,queue_id)\n");
2723 tmp = strtoul(str + i + 1, NULL, 0);
2724 /* If queue_id greater that what 16-bits can represent, return */
2728 queue_id = (uint16_t)tmp;
2729 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2731 else if (!strcmp(res->what, "filter"))
2732 rx_vlan_filter_set(port_id, on);
2734 vlan_extend_set(port_id, on);
2739 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2740 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2742 cmdline_parse_token_string_t cmd_vlan_offload_set =
2743 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2745 cmdline_parse_token_string_t cmd_vlan_offload_what =
2746 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2747 what, "strip#filter#qinq#stripq");
2748 cmdline_parse_token_string_t cmd_vlan_offload_on =
2749 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2751 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2752 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2755 cmdline_parse_inst_t cmd_vlan_offload = {
2756 .f = cmd_vlan_offload_parsed,
2758 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2759 " qinq(extended) for both rx/tx sides ",
2761 (void *)&cmd_vlan_offload_vlan,
2762 (void *)&cmd_vlan_offload_set,
2763 (void *)&cmd_vlan_offload_what,
2764 (void *)&cmd_vlan_offload_on,
2765 (void *)&cmd_vlan_offload_portid,
2770 /* *** VLAN TPID SET ON A PORT *** */
2771 struct cmd_vlan_tpid_result {
2772 cmdline_fixed_string_t vlan;
2773 cmdline_fixed_string_t set;
2774 cmdline_fixed_string_t what;
2780 cmd_vlan_tpid_parsed(void *parsed_result,
2781 __attribute__((unused)) struct cmdline *cl,
2782 __attribute__((unused)) void *data)
2784 struct cmd_vlan_tpid_result *res = parsed_result;
2785 vlan_tpid_set(res->port_id, res->tp_id);
2789 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2790 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2792 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2793 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2795 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2796 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2798 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2799 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2801 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2802 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2805 cmdline_parse_inst_t cmd_vlan_tpid = {
2806 .f = cmd_vlan_tpid_parsed,
2808 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2810 (void *)&cmd_vlan_tpid_vlan,
2811 (void *)&cmd_vlan_tpid_set,
2812 (void *)&cmd_vlan_tpid_what,
2813 (void *)&cmd_vlan_tpid_tpid,
2814 (void *)&cmd_vlan_tpid_portid,
2819 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2820 struct cmd_rx_vlan_filter_result {
2821 cmdline_fixed_string_t rx_vlan;
2822 cmdline_fixed_string_t what;
2828 cmd_rx_vlan_filter_parsed(void *parsed_result,
2829 __attribute__((unused)) struct cmdline *cl,
2830 __attribute__((unused)) void *data)
2832 struct cmd_rx_vlan_filter_result *res = parsed_result;
2834 if (!strcmp(res->what, "add"))
2835 rx_vft_set(res->port_id, res->vlan_id, 1);
2837 rx_vft_set(res->port_id, res->vlan_id, 0);
2840 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2841 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2842 rx_vlan, "rx_vlan");
2843 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2844 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2846 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2847 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2849 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2850 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2853 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2854 .f = cmd_rx_vlan_filter_parsed,
2856 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2857 "Identifiers filtered by a port",
2859 (void *)&cmd_rx_vlan_filter_rx_vlan,
2860 (void *)&cmd_rx_vlan_filter_what,
2861 (void *)&cmd_rx_vlan_filter_vlanid,
2862 (void *)&cmd_rx_vlan_filter_portid,
2867 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2868 struct cmd_tx_vlan_set_result {
2869 cmdline_fixed_string_t tx_vlan;
2870 cmdline_fixed_string_t set;
2876 cmd_tx_vlan_set_parsed(void *parsed_result,
2877 __attribute__((unused)) struct cmdline *cl,
2878 __attribute__((unused)) void *data)
2880 struct cmd_tx_vlan_set_result *res = parsed_result;
2881 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2883 if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) {
2884 printf("Error, as QinQ has been enabled.\n");
2888 tx_vlan_set(res->port_id, res->vlan_id);
2891 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2892 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2893 tx_vlan, "tx_vlan");
2894 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2895 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2897 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2898 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2900 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2901 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2904 cmdline_parse_inst_t cmd_tx_vlan_set = {
2905 .f = cmd_tx_vlan_set_parsed,
2907 .help_str = "enable hardware insertion of a single VLAN header "
2908 "with a given TAG Identifier in packets sent on a port",
2910 (void *)&cmd_tx_vlan_set_tx_vlan,
2911 (void *)&cmd_tx_vlan_set_set,
2912 (void *)&cmd_tx_vlan_set_portid,
2913 (void *)&cmd_tx_vlan_set_vlanid,
2918 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
2919 struct cmd_tx_vlan_set_qinq_result {
2920 cmdline_fixed_string_t tx_vlan;
2921 cmdline_fixed_string_t set;
2924 uint16_t vlan_id_outer;
2928 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
2929 __attribute__((unused)) struct cmdline *cl,
2930 __attribute__((unused)) void *data)
2932 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
2933 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2935 if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) {
2936 printf("Error, as QinQ hasn't been enabled.\n");
2940 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
2943 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
2944 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2945 tx_vlan, "tx_vlan");
2946 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
2947 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2949 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
2950 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2952 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
2953 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2955 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
2956 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2957 vlan_id_outer, UINT16);
2959 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
2960 .f = cmd_tx_vlan_set_qinq_parsed,
2962 .help_str = "enable hardware insertion of double VLAN header "
2963 "with given TAG Identifiers in packets sent on a port",
2965 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
2966 (void *)&cmd_tx_vlan_set_qinq_set,
2967 (void *)&cmd_tx_vlan_set_qinq_portid,
2968 (void *)&cmd_tx_vlan_set_qinq_vlanid,
2969 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
2974 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2975 struct cmd_tx_vlan_set_pvid_result {
2976 cmdline_fixed_string_t tx_vlan;
2977 cmdline_fixed_string_t set;
2978 cmdline_fixed_string_t pvid;
2981 cmdline_fixed_string_t mode;
2985 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2986 __attribute__((unused)) struct cmdline *cl,
2987 __attribute__((unused)) void *data)
2989 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2991 if (strcmp(res->mode, "on") == 0)
2992 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2994 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2997 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2998 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2999 tx_vlan, "tx_vlan");
3000 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3001 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3003 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3004 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3006 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3007 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3009 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3010 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3012 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3013 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3016 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3017 .f = cmd_tx_vlan_set_pvid_parsed,
3019 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3021 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3022 (void *)&cmd_tx_vlan_set_pvid_set,
3023 (void *)&cmd_tx_vlan_set_pvid_pvid,
3024 (void *)&cmd_tx_vlan_set_pvid_port_id,
3025 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3026 (void *)&cmd_tx_vlan_set_pvid_mode,
3031 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3032 struct cmd_tx_vlan_reset_result {
3033 cmdline_fixed_string_t tx_vlan;
3034 cmdline_fixed_string_t reset;
3039 cmd_tx_vlan_reset_parsed(void *parsed_result,
3040 __attribute__((unused)) struct cmdline *cl,
3041 __attribute__((unused)) void *data)
3043 struct cmd_tx_vlan_reset_result *res = parsed_result;
3045 tx_vlan_reset(res->port_id);
3048 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3049 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3050 tx_vlan, "tx_vlan");
3051 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3052 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3054 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3055 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3058 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3059 .f = cmd_tx_vlan_reset_parsed,
3061 .help_str = "disable hardware insertion of a VLAN header in packets "
3064 (void *)&cmd_tx_vlan_reset_tx_vlan,
3065 (void *)&cmd_tx_vlan_reset_reset,
3066 (void *)&cmd_tx_vlan_reset_portid,
3072 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3073 struct cmd_csum_result {
3074 cmdline_fixed_string_t csum;
3075 cmdline_fixed_string_t mode;
3076 cmdline_fixed_string_t proto;
3077 cmdline_fixed_string_t hwsw;
3082 csum_show(int port_id)
3084 struct rte_eth_dev_info dev_info;
3087 ol_flags = ports[port_id].tx_ol_flags;
3088 printf("Parse tunnel is %s\n",
3089 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3090 printf("IP checksum offload is %s\n",
3091 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3092 printf("UDP checksum offload is %s\n",
3093 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3094 printf("TCP checksum offload is %s\n",
3095 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3096 printf("SCTP checksum offload is %s\n",
3097 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3098 printf("Outer-Ip checksum offload is %s\n",
3099 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3101 /* display warnings if configuration is not supported by the NIC */
3102 rte_eth_dev_info_get(port_id, &dev_info);
3103 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3104 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3105 printf("Warning: hardware IP checksum enabled but not "
3106 "supported by port %d\n", port_id);
3108 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3109 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3110 printf("Warning: hardware UDP checksum enabled but not "
3111 "supported by port %d\n", port_id);
3113 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3114 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3115 printf("Warning: hardware TCP checksum enabled but not "
3116 "supported by port %d\n", port_id);
3118 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3119 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3120 printf("Warning: hardware SCTP checksum enabled but not "
3121 "supported by port %d\n", port_id);
3123 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3124 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3125 printf("Warning: hardware outer IP checksum enabled but not "
3126 "supported by port %d\n", port_id);
3131 cmd_csum_parsed(void *parsed_result,
3132 __attribute__((unused)) struct cmdline *cl,
3133 __attribute__((unused)) void *data)
3135 struct cmd_csum_result *res = parsed_result;
3139 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3140 printf("invalid port %d\n", res->port_id);
3144 if (!strcmp(res->mode, "set")) {
3146 if (!strcmp(res->hwsw, "hw"))
3149 if (!strcmp(res->proto, "ip")) {
3150 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3151 } else if (!strcmp(res->proto, "udp")) {
3152 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3153 } else if (!strcmp(res->proto, "tcp")) {
3154 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3155 } else if (!strcmp(res->proto, "sctp")) {
3156 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3157 } else if (!strcmp(res->proto, "outer-ip")) {
3158 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3162 ports[res->port_id].tx_ol_flags |= mask;
3164 ports[res->port_id].tx_ol_flags &= (~mask);
3166 csum_show(res->port_id);
3169 cmdline_parse_token_string_t cmd_csum_csum =
3170 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3172 cmdline_parse_token_string_t cmd_csum_mode =
3173 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3175 cmdline_parse_token_string_t cmd_csum_proto =
3176 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3177 proto, "ip#tcp#udp#sctp#outer-ip");
3178 cmdline_parse_token_string_t cmd_csum_hwsw =
3179 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3181 cmdline_parse_token_num_t cmd_csum_portid =
3182 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3185 cmdline_parse_inst_t cmd_csum_set = {
3186 .f = cmd_csum_parsed,
3188 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3189 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3191 (void *)&cmd_csum_csum,
3192 (void *)&cmd_csum_mode,
3193 (void *)&cmd_csum_proto,
3194 (void *)&cmd_csum_hwsw,
3195 (void *)&cmd_csum_portid,
3200 cmdline_parse_token_string_t cmd_csum_mode_show =
3201 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3204 cmdline_parse_inst_t cmd_csum_show = {
3205 .f = cmd_csum_parsed,
3207 .help_str = "show checksum offload configuration: csum show <port>",
3209 (void *)&cmd_csum_csum,
3210 (void *)&cmd_csum_mode_show,
3211 (void *)&cmd_csum_portid,
3216 /* Enable/disable tunnel parsing */
3217 struct cmd_csum_tunnel_result {
3218 cmdline_fixed_string_t csum;
3219 cmdline_fixed_string_t parse;
3220 cmdline_fixed_string_t onoff;
3225 cmd_csum_tunnel_parsed(void *parsed_result,
3226 __attribute__((unused)) struct cmdline *cl,
3227 __attribute__((unused)) void *data)
3229 struct cmd_csum_tunnel_result *res = parsed_result;
3231 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3234 if (!strcmp(res->onoff, "on"))
3235 ports[res->port_id].tx_ol_flags |=
3236 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3238 ports[res->port_id].tx_ol_flags &=
3239 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3241 csum_show(res->port_id);
3244 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3245 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3247 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3248 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3249 parse, "parse_tunnel");
3250 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3251 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3253 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3254 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3257 cmdline_parse_inst_t cmd_csum_tunnel = {
3258 .f = cmd_csum_tunnel_parsed,
3260 .help_str = "enable/disable parsing of tunnels for csum engine: "
3261 "csum parse_tunnel on|off <tx-port>",
3263 (void *)&cmd_csum_tunnel_csum,
3264 (void *)&cmd_csum_tunnel_parse,
3265 (void *)&cmd_csum_tunnel_onoff,
3266 (void *)&cmd_csum_tunnel_portid,
3271 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3272 struct cmd_tso_set_result {
3273 cmdline_fixed_string_t tso;
3274 cmdline_fixed_string_t mode;
3280 cmd_tso_set_parsed(void *parsed_result,
3281 __attribute__((unused)) struct cmdline *cl,
3282 __attribute__((unused)) void *data)
3284 struct cmd_tso_set_result *res = parsed_result;
3285 struct rte_eth_dev_info dev_info;
3287 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3290 if (!strcmp(res->mode, "set"))
3291 ports[res->port_id].tso_segsz = res->tso_segsz;
3293 if (ports[res->port_id].tso_segsz == 0)
3294 printf("TSO is disabled\n");
3296 printf("TSO segment size is %d\n",
3297 ports[res->port_id].tso_segsz);
3299 /* display warnings if configuration is not supported by the NIC */
3300 rte_eth_dev_info_get(res->port_id, &dev_info);
3301 if ((ports[res->port_id].tso_segsz != 0) &&
3302 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3303 printf("Warning: TSO enabled but not "
3304 "supported by port %d\n", res->port_id);
3308 cmdline_parse_token_string_t cmd_tso_set_tso =
3309 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3311 cmdline_parse_token_string_t cmd_tso_set_mode =
3312 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3314 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3315 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3317 cmdline_parse_token_num_t cmd_tso_set_portid =
3318 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3321 cmdline_parse_inst_t cmd_tso_set = {
3322 .f = cmd_tso_set_parsed,
3324 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3325 "tso set <tso_segsz> <port>",
3327 (void *)&cmd_tso_set_tso,
3328 (void *)&cmd_tso_set_mode,
3329 (void *)&cmd_tso_set_tso_segsz,
3330 (void *)&cmd_tso_set_portid,
3335 cmdline_parse_token_string_t cmd_tso_show_mode =
3336 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3340 cmdline_parse_inst_t cmd_tso_show = {
3341 .f = cmd_tso_set_parsed,
3343 .help_str = "Show TSO segment size for csum engine: "
3346 (void *)&cmd_tso_set_tso,
3347 (void *)&cmd_tso_show_mode,
3348 (void *)&cmd_tso_set_portid,
3353 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3354 struct cmd_set_flush_rx {
3355 cmdline_fixed_string_t set;
3356 cmdline_fixed_string_t flush_rx;
3357 cmdline_fixed_string_t mode;
3361 cmd_set_flush_rx_parsed(void *parsed_result,
3362 __attribute__((unused)) struct cmdline *cl,
3363 __attribute__((unused)) void *data)
3365 struct cmd_set_flush_rx *res = parsed_result;
3366 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3369 cmdline_parse_token_string_t cmd_setflushrx_set =
3370 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3372 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3373 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3374 flush_rx, "flush_rx");
3375 cmdline_parse_token_string_t cmd_setflushrx_mode =
3376 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3380 cmdline_parse_inst_t cmd_set_flush_rx = {
3381 .f = cmd_set_flush_rx_parsed,
3382 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3385 (void *)&cmd_setflushrx_set,
3386 (void *)&cmd_setflushrx_flush_rx,
3387 (void *)&cmd_setflushrx_mode,
3392 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3393 struct cmd_set_link_check {
3394 cmdline_fixed_string_t set;
3395 cmdline_fixed_string_t link_check;
3396 cmdline_fixed_string_t mode;
3400 cmd_set_link_check_parsed(void *parsed_result,
3401 __attribute__((unused)) struct cmdline *cl,
3402 __attribute__((unused)) void *data)
3404 struct cmd_set_link_check *res = parsed_result;
3405 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3408 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3409 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3411 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3412 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3413 link_check, "link_check");
3414 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3415 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3419 cmdline_parse_inst_t cmd_set_link_check = {
3420 .f = cmd_set_link_check_parsed,
3421 .help_str = "set link_check on|off: enable/disable link status check "
3422 "when starting/stopping a port",
3425 (void *)&cmd_setlinkcheck_set,
3426 (void *)&cmd_setlinkcheck_link_check,
3427 (void *)&cmd_setlinkcheck_mode,
3432 #ifdef RTE_NIC_BYPASS
3433 /* *** SET NIC BYPASS MODE *** */
3434 struct cmd_set_bypass_mode_result {
3435 cmdline_fixed_string_t set;
3436 cmdline_fixed_string_t bypass;
3437 cmdline_fixed_string_t mode;
3438 cmdline_fixed_string_t value;
3443 cmd_set_bypass_mode_parsed(void *parsed_result,
3444 __attribute__((unused)) struct cmdline *cl,
3445 __attribute__((unused)) void *data)
3447 struct cmd_set_bypass_mode_result *res = parsed_result;
3448 portid_t port_id = res->port_id;
3449 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3451 if (!bypass_is_supported(port_id))
3454 if (!strcmp(res->value, "bypass"))
3455 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3456 else if (!strcmp(res->value, "isolate"))
3457 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3459 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3461 /* Set the bypass mode for the relevant port. */
3462 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3463 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3467 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3468 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3470 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3471 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3473 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3474 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3476 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3477 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3478 value, "normal#bypass#isolate");
3479 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3480 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3483 cmdline_parse_inst_t cmd_set_bypass_mode = {
3484 .f = cmd_set_bypass_mode_parsed,
3485 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3486 "Set the NIC bypass mode for port_id",
3489 (void *)&cmd_setbypass_mode_set,
3490 (void *)&cmd_setbypass_mode_bypass,
3491 (void *)&cmd_setbypass_mode_mode,
3492 (void *)&cmd_setbypass_mode_value,
3493 (void *)&cmd_setbypass_mode_port,
3498 /* *** SET NIC BYPASS EVENT *** */
3499 struct cmd_set_bypass_event_result {
3500 cmdline_fixed_string_t set;
3501 cmdline_fixed_string_t bypass;
3502 cmdline_fixed_string_t event;
3503 cmdline_fixed_string_t event_value;
3504 cmdline_fixed_string_t mode;
3505 cmdline_fixed_string_t mode_value;
3510 cmd_set_bypass_event_parsed(void *parsed_result,
3511 __attribute__((unused)) struct cmdline *cl,
3512 __attribute__((unused)) void *data)
3515 struct cmd_set_bypass_event_result *res = parsed_result;
3516 portid_t port_id = res->port_id;
3517 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3518 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3520 if (!bypass_is_supported(port_id))
3523 if (!strcmp(res->event_value, "timeout"))
3524 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3525 else if (!strcmp(res->event_value, "os_on"))
3526 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3527 else if (!strcmp(res->event_value, "os_off"))
3528 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3529 else if (!strcmp(res->event_value, "power_on"))
3530 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3531 else if (!strcmp(res->event_value, "power_off"))
3532 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3534 bypass_event = RTE_BYPASS_EVENT_NONE;
3536 if (!strcmp(res->mode_value, "bypass"))
3537 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3538 else if (!strcmp(res->mode_value, "isolate"))
3539 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3541 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3543 /* Set the watchdog timeout. */
3544 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3547 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3548 (rc = rte_eth_dev_wd_timeout_store(port_id,
3549 bypass_timeout)) != 0) {
3550 printf("Failed to set timeout value %u "
3551 "for port %d, errto code: %d.\n",
3552 bypass_timeout, port_id, rc);
3556 /* Set the bypass event to transition to bypass mode. */
3557 if (0 != rte_eth_dev_bypass_event_store(port_id,
3558 bypass_event, bypass_mode)) {
3559 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3564 cmdline_parse_token_string_t cmd_setbypass_event_set =
3565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3567 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3568 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3570 cmdline_parse_token_string_t cmd_setbypass_event_event =
3571 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3573 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3574 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3575 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3576 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3577 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3579 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3580 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3581 mode_value, "normal#bypass#isolate");
3582 cmdline_parse_token_num_t cmd_setbypass_event_port =
3583 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3586 cmdline_parse_inst_t cmd_set_bypass_event = {
3587 .f = cmd_set_bypass_event_parsed,
3588 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3589 "mode (normal|bypass|isolate) (port_id): "
3590 "Set the NIC bypass event mode for port_id",
3593 (void *)&cmd_setbypass_event_set,
3594 (void *)&cmd_setbypass_event_bypass,
3595 (void *)&cmd_setbypass_event_event,
3596 (void *)&cmd_setbypass_event_event_value,
3597 (void *)&cmd_setbypass_event_mode,
3598 (void *)&cmd_setbypass_event_mode_value,
3599 (void *)&cmd_setbypass_event_port,
3605 /* *** SET NIC BYPASS TIMEOUT *** */
3606 struct cmd_set_bypass_timeout_result {
3607 cmdline_fixed_string_t set;
3608 cmdline_fixed_string_t bypass;
3609 cmdline_fixed_string_t timeout;
3610 cmdline_fixed_string_t value;
3614 cmd_set_bypass_timeout_parsed(void *parsed_result,
3615 __attribute__((unused)) struct cmdline *cl,
3616 __attribute__((unused)) void *data)
3618 struct cmd_set_bypass_timeout_result *res = parsed_result;
3620 if (!strcmp(res->value, "1.5"))
3621 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3622 else if (!strcmp(res->value, "2"))
3623 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3624 else if (!strcmp(res->value, "3"))
3625 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3626 else if (!strcmp(res->value, "4"))
3627 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3628 else if (!strcmp(res->value, "8"))
3629 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3630 else if (!strcmp(res->value, "16"))
3631 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3632 else if (!strcmp(res->value, "32"))
3633 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3635 bypass_timeout = RTE_BYPASS_TMT_OFF;
3638 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3639 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3641 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3642 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3644 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3645 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3646 timeout, "timeout");
3647 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3648 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3649 value, "0#1.5#2#3#4#8#16#32");
3651 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3652 .f = cmd_set_bypass_timeout_parsed,
3653 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3654 "Set the NIC bypass watchdog timeout",
3657 (void *)&cmd_setbypass_timeout_set,
3658 (void *)&cmd_setbypass_timeout_bypass,
3659 (void *)&cmd_setbypass_timeout_timeout,
3660 (void *)&cmd_setbypass_timeout_value,
3665 /* *** SHOW NIC BYPASS MODE *** */
3666 struct cmd_show_bypass_config_result {
3667 cmdline_fixed_string_t show;
3668 cmdline_fixed_string_t bypass;
3669 cmdline_fixed_string_t config;
3674 cmd_show_bypass_config_parsed(void *parsed_result,
3675 __attribute__((unused)) struct cmdline *cl,
3676 __attribute__((unused)) void *data)
3678 struct cmd_show_bypass_config_result *res = parsed_result;
3679 uint32_t event_mode;
3680 uint32_t bypass_mode;
3681 portid_t port_id = res->port_id;
3682 uint32_t timeout = bypass_timeout;
3685 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3686 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3687 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3688 {"UNKNOWN", "normal", "bypass", "isolate"};
3689 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3696 int num_events = (sizeof events) / (sizeof events[0]);
3698 if (!bypass_is_supported(port_id))
3701 /* Display the bypass mode.*/
3702 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3703 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3707 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3708 bypass_mode = RTE_BYPASS_MODE_NONE;
3710 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3713 /* Display the bypass timeout.*/
3714 if (!RTE_BYPASS_TMT_VALID(timeout))
3715 timeout = RTE_BYPASS_TMT_OFF;
3717 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3719 /* Display the bypass events and associated modes. */
3720 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3722 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3723 printf("\tFailed to get bypass mode for event = %s\n",
3726 if (!RTE_BYPASS_MODE_VALID(event_mode))
3727 event_mode = RTE_BYPASS_MODE_NONE;
3729 printf("\tbypass event: %-16s = %s\n", events[i],
3735 cmdline_parse_token_string_t cmd_showbypass_config_show =
3736 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3738 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3739 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3741 cmdline_parse_token_string_t cmd_showbypass_config_config =
3742 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3744 cmdline_parse_token_num_t cmd_showbypass_config_port =
3745 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3748 cmdline_parse_inst_t cmd_show_bypass_config = {
3749 .f = cmd_show_bypass_config_parsed,
3750 .help_str = "show bypass config (port_id): "
3751 "Show the NIC bypass config for port_id",
3754 (void *)&cmd_showbypass_config_show,
3755 (void *)&cmd_showbypass_config_bypass,
3756 (void *)&cmd_showbypass_config_config,
3757 (void *)&cmd_showbypass_config_port,
3763 #ifdef RTE_LIBRTE_PMD_BOND
3764 /* *** SET BONDING MODE *** */
3765 struct cmd_set_bonding_mode_result {
3766 cmdline_fixed_string_t set;
3767 cmdline_fixed_string_t bonding;
3768 cmdline_fixed_string_t mode;
3773 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3774 __attribute__((unused)) struct cmdline *cl,
3775 __attribute__((unused)) void *data)
3777 struct cmd_set_bonding_mode_result *res = parsed_result;
3778 portid_t port_id = res->port_id;
3780 /* Set the bonding mode for the relevant port. */
3781 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3782 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3785 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3786 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3788 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3789 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3790 bonding, "bonding");
3791 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3792 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3794 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3795 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3797 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3798 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3801 cmdline_parse_inst_t cmd_set_bonding_mode = {
3802 .f = cmd_set_bonding_mode_parsed,
3803 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3806 (void *) &cmd_setbonding_mode_set,
3807 (void *) &cmd_setbonding_mode_bonding,
3808 (void *) &cmd_setbonding_mode_mode,
3809 (void *) &cmd_setbonding_mode_value,
3810 (void *) &cmd_setbonding_mode_port,
3815 /* *** SET BALANCE XMIT POLICY *** */
3816 struct cmd_set_bonding_balance_xmit_policy_result {
3817 cmdline_fixed_string_t set;
3818 cmdline_fixed_string_t bonding;
3819 cmdline_fixed_string_t balance_xmit_policy;
3821 cmdline_fixed_string_t policy;
3824 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3825 __attribute__((unused)) struct cmdline *cl,
3826 __attribute__((unused)) void *data)
3828 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3829 portid_t port_id = res->port_id;
3832 if (!strcmp(res->policy, "l2")) {
3833 policy = BALANCE_XMIT_POLICY_LAYER2;
3834 } else if (!strcmp(res->policy, "l23")) {
3835 policy = BALANCE_XMIT_POLICY_LAYER23;
3836 } else if (!strcmp(res->policy, "l34")) {
3837 policy = BALANCE_XMIT_POLICY_LAYER34;
3839 printf("\t Invalid xmit policy selection");
3843 /* Set the bonding mode for the relevant port. */
3844 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3845 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3850 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3851 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3853 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3854 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3855 bonding, "bonding");
3856 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3858 balance_xmit_policy, "balance_xmit_policy");
3859 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3860 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3862 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3863 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3864 policy, "l2#l23#l34");
3866 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3867 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3868 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3871 (void *)&cmd_setbonding_balance_xmit_policy_set,
3872 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3873 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3874 (void *)&cmd_setbonding_balance_xmit_policy_port,
3875 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3880 /* *** SHOW NIC BONDING CONFIGURATION *** */
3881 struct cmd_show_bonding_config_result {
3882 cmdline_fixed_string_t show;
3883 cmdline_fixed_string_t bonding;
3884 cmdline_fixed_string_t config;
3888 static void cmd_show_bonding_config_parsed(void *parsed_result,
3889 __attribute__((unused)) struct cmdline *cl,
3890 __attribute__((unused)) void *data)
3892 struct cmd_show_bonding_config_result *res = parsed_result;
3894 uint8_t slaves[RTE_MAX_ETHPORTS];
3895 int num_slaves, num_active_slaves;
3898 portid_t port_id = res->port_id;
3900 /* Display the bonding mode.*/
3901 bonding_mode = rte_eth_bond_mode_get(port_id);
3902 if (bonding_mode < 0) {
3903 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3906 printf("\tBonding mode: %d\n", bonding_mode);
3908 if (bonding_mode == BONDING_MODE_BALANCE) {
3909 int balance_xmit_policy;
3911 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3912 if (balance_xmit_policy < 0) {
3913 printf("\tFailed to get balance xmit policy for port = %d\n",
3917 printf("\tBalance Xmit Policy: ");
3919 switch (balance_xmit_policy) {
3920 case BALANCE_XMIT_POLICY_LAYER2:
3921 printf("BALANCE_XMIT_POLICY_LAYER2");
3923 case BALANCE_XMIT_POLICY_LAYER23:
3924 printf("BALANCE_XMIT_POLICY_LAYER23");
3926 case BALANCE_XMIT_POLICY_LAYER34:
3927 printf("BALANCE_XMIT_POLICY_LAYER34");
3934 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3936 if (num_slaves < 0) {
3937 printf("\tFailed to get slave list for port = %d\n", port_id);
3940 if (num_slaves > 0) {
3941 printf("\tSlaves (%d): [", num_slaves);
3942 for (i = 0; i < num_slaves - 1; i++)
3943 printf("%d ", slaves[i]);
3945 printf("%d]\n", slaves[num_slaves - 1]);
3947 printf("\tSlaves: []\n");
3951 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3954 if (num_active_slaves < 0) {
3955 printf("\tFailed to get active slave list for port = %d\n", port_id);
3958 if (num_active_slaves > 0) {
3959 printf("\tActive Slaves (%d): [", num_active_slaves);
3960 for (i = 0; i < num_active_slaves - 1; i++)
3961 printf("%d ", slaves[i]);
3963 printf("%d]\n", slaves[num_active_slaves - 1]);
3966 printf("\tActive Slaves: []\n");
3970 primary_id = rte_eth_bond_primary_get(port_id);
3971 if (primary_id < 0) {
3972 printf("\tFailed to get primary slave for port = %d\n", port_id);
3975 printf("\tPrimary: [%d]\n", primary_id);
3979 cmdline_parse_token_string_t cmd_showbonding_config_show =
3980 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3982 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3983 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3984 bonding, "bonding");
3985 cmdline_parse_token_string_t cmd_showbonding_config_config =
3986 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3988 cmdline_parse_token_num_t cmd_showbonding_config_port =
3989 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3992 cmdline_parse_inst_t cmd_show_bonding_config = {
3993 .f = cmd_show_bonding_config_parsed,
3994 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3997 (void *)&cmd_showbonding_config_show,
3998 (void *)&cmd_showbonding_config_bonding,
3999 (void *)&cmd_showbonding_config_config,
4000 (void *)&cmd_showbonding_config_port,
4005 /* *** SET BONDING PRIMARY *** */
4006 struct cmd_set_bonding_primary_result {
4007 cmdline_fixed_string_t set;
4008 cmdline_fixed_string_t bonding;
4009 cmdline_fixed_string_t primary;
4014 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4015 __attribute__((unused)) struct cmdline *cl,
4016 __attribute__((unused)) void *data)
4018 struct cmd_set_bonding_primary_result *res = parsed_result;
4019 portid_t master_port_id = res->port_id;
4020 portid_t slave_port_id = res->slave_id;
4022 /* Set the primary slave for a bonded device. */
4023 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4024 printf("\t Failed to set primary slave for port = %d.\n",
4031 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4032 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4034 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4035 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4036 bonding, "bonding");
4037 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4038 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4039 primary, "primary");
4040 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4041 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4043 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4044 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4047 cmdline_parse_inst_t cmd_set_bonding_primary = {
4048 .f = cmd_set_bonding_primary_parsed,
4049 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4052 (void *)&cmd_setbonding_primary_set,
4053 (void *)&cmd_setbonding_primary_bonding,
4054 (void *)&cmd_setbonding_primary_primary,
4055 (void *)&cmd_setbonding_primary_slave,
4056 (void *)&cmd_setbonding_primary_port,
4061 /* *** ADD SLAVE *** */
4062 struct cmd_add_bonding_slave_result {
4063 cmdline_fixed_string_t add;
4064 cmdline_fixed_string_t bonding;
4065 cmdline_fixed_string_t slave;
4070 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4071 __attribute__((unused)) struct cmdline *cl,
4072 __attribute__((unused)) void *data)
4074 struct cmd_add_bonding_slave_result *res = parsed_result;
4075 portid_t master_port_id = res->port_id;
4076 portid_t slave_port_id = res->slave_id;
4078 /* Set the primary slave for a bonded device. */
4079 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4080 printf("\t Failed to add slave %d to master port = %d.\n",
4081 slave_port_id, master_port_id);
4085 set_port_slave_flag(slave_port_id);
4088 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4089 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4091 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4092 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4093 bonding, "bonding");
4094 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4095 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4097 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4098 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4100 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4101 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4104 cmdline_parse_inst_t cmd_add_bonding_slave = {
4105 .f = cmd_add_bonding_slave_parsed,
4106 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4109 (void *)&cmd_addbonding_slave_add,
4110 (void *)&cmd_addbonding_slave_bonding,
4111 (void *)&cmd_addbonding_slave_slave,
4112 (void *)&cmd_addbonding_slave_slaveid,
4113 (void *)&cmd_addbonding_slave_port,
4118 /* *** REMOVE SLAVE *** */
4119 struct cmd_remove_bonding_slave_result {
4120 cmdline_fixed_string_t remove;
4121 cmdline_fixed_string_t bonding;
4122 cmdline_fixed_string_t slave;
4127 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4128 __attribute__((unused)) struct cmdline *cl,
4129 __attribute__((unused)) void *data)
4131 struct cmd_remove_bonding_slave_result *res = parsed_result;
4132 portid_t master_port_id = res->port_id;
4133 portid_t slave_port_id = res->slave_id;
4135 /* Set the primary slave for a bonded device. */
4136 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4137 printf("\t Failed to remove slave %d from master port = %d.\n",
4138 slave_port_id, master_port_id);
4142 clear_port_slave_flag(slave_port_id);
4145 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4146 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4148 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4149 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4150 bonding, "bonding");
4151 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4152 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4154 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4155 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4157 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4158 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4161 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4162 .f = cmd_remove_bonding_slave_parsed,
4163 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4166 (void *)&cmd_removebonding_slave_remove,
4167 (void *)&cmd_removebonding_slave_bonding,
4168 (void *)&cmd_removebonding_slave_slave,
4169 (void *)&cmd_removebonding_slave_slaveid,
4170 (void *)&cmd_removebonding_slave_port,
4175 /* *** CREATE BONDED DEVICE *** */
4176 struct cmd_create_bonded_device_result {
4177 cmdline_fixed_string_t create;
4178 cmdline_fixed_string_t bonded;
4179 cmdline_fixed_string_t device;
4184 static int bond_dev_num = 0;
4186 static void cmd_create_bonded_device_parsed(void *parsed_result,
4187 __attribute__((unused)) struct cmdline *cl,
4188 __attribute__((unused)) void *data)
4190 struct cmd_create_bonded_device_result *res = parsed_result;
4191 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4194 if (test_done == 0) {
4195 printf("Please stop forwarding first\n");
4199 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4202 /* Create a new bonded device. */
4203 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4205 printf("\t Failed to create bonded device.\n");
4208 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4211 /* Update number of ports */
4212 nb_ports = rte_eth_dev_count();
4213 reconfig(port_id, res->socket);
4214 rte_eth_promiscuous_enable(port_id);
4215 ports[port_id].enabled = 1;
4220 cmdline_parse_token_string_t cmd_createbonded_device_create =
4221 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4223 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4224 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4226 cmdline_parse_token_string_t cmd_createbonded_device_device =
4227 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4229 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4230 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4232 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4233 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4236 cmdline_parse_inst_t cmd_create_bonded_device = {
4237 .f = cmd_create_bonded_device_parsed,
4238 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4241 (void *)&cmd_createbonded_device_create,
4242 (void *)&cmd_createbonded_device_bonded,
4243 (void *)&cmd_createbonded_device_device,
4244 (void *)&cmd_createbonded_device_mode,
4245 (void *)&cmd_createbonded_device_socket,
4250 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4251 struct cmd_set_bond_mac_addr_result {
4252 cmdline_fixed_string_t set;
4253 cmdline_fixed_string_t bonding;
4254 cmdline_fixed_string_t mac_addr;
4256 struct ether_addr address;
4259 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4260 __attribute__((unused)) struct cmdline *cl,
4261 __attribute__((unused)) void *data)
4263 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4266 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4269 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4271 /* check the return value and print it if is < 0 */
4273 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4276 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4277 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4278 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4279 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4281 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4282 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4284 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4285 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4286 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4287 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4289 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4290 .f = cmd_set_bond_mac_addr_parsed,
4292 .help_str = "set bonding mac_addr (port_id) (address): ",
4294 (void *)&cmd_set_bond_mac_addr_set,
4295 (void *)&cmd_set_bond_mac_addr_bonding,
4296 (void *)&cmd_set_bond_mac_addr_mac,
4297 (void *)&cmd_set_bond_mac_addr_portnum,
4298 (void *)&cmd_set_bond_mac_addr_addr,
4304 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4305 struct cmd_set_bond_mon_period_result {
4306 cmdline_fixed_string_t set;
4307 cmdline_fixed_string_t bonding;
4308 cmdline_fixed_string_t mon_period;
4313 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4314 __attribute__((unused)) struct cmdline *cl,
4315 __attribute__((unused)) void *data)
4317 struct cmd_set_bond_mon_period_result *res = parsed_result;
4320 if (res->port_num >= nb_ports) {
4321 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4325 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4327 /* check the return value and print it if is < 0 */
4329 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4332 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4333 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4335 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4336 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4337 bonding, "bonding");
4338 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4339 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4340 mon_period, "mon_period");
4341 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4342 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4344 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4345 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4348 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4349 .f = cmd_set_bond_mon_period_parsed,
4351 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4353 (void *)&cmd_set_bond_mon_period_set,
4354 (void *)&cmd_set_bond_mon_period_bonding,
4355 (void *)&cmd_set_bond_mon_period_mon_period,
4356 (void *)&cmd_set_bond_mon_period_portnum,
4357 (void *)&cmd_set_bond_mon_period_period_ms,
4362 #endif /* RTE_LIBRTE_PMD_BOND */
4364 /* *** SET FORWARDING MODE *** */
4365 struct cmd_set_fwd_mode_result {
4366 cmdline_fixed_string_t set;
4367 cmdline_fixed_string_t fwd;
4368 cmdline_fixed_string_t mode;
4371 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4372 __attribute__((unused)) struct cmdline *cl,
4373 __attribute__((unused)) void *data)
4375 struct cmd_set_fwd_mode_result *res = parsed_result;
4377 set_pkt_forwarding_mode(res->mode);
4380 cmdline_parse_token_string_t cmd_setfwd_set =
4381 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4382 cmdline_parse_token_string_t cmd_setfwd_fwd =
4383 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4384 cmdline_parse_token_string_t cmd_setfwd_mode =
4385 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4386 "" /* defined at init */);
4388 cmdline_parse_inst_t cmd_set_fwd_mode = {
4389 .f = cmd_set_fwd_mode_parsed,
4391 .help_str = NULL, /* defined at init */
4393 (void *)&cmd_setfwd_set,
4394 (void *)&cmd_setfwd_fwd,
4395 (void *)&cmd_setfwd_mode,
4400 static void cmd_set_fwd_mode_init(void)
4403 static char token[128];
4404 static char help[256];
4405 cmdline_parse_token_string_t *token_struct;
4407 modes = list_pkt_forwarding_modes();
4408 snprintf(help, sizeof help, "set fwd %s - "
4409 "set packet forwarding mode", modes);
4410 cmd_set_fwd_mode.help_str = help;
4412 /* string token separator is # */
4413 for (c = token; *modes != '\0'; modes++)
4418 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4419 token_struct->string_data.str = token;
4422 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4423 struct cmd_set_burst_tx_retry_result {
4424 cmdline_fixed_string_t set;
4425 cmdline_fixed_string_t burst;
4426 cmdline_fixed_string_t tx;
4427 cmdline_fixed_string_t delay;
4429 cmdline_fixed_string_t retry;
4433 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4434 __attribute__((unused)) struct cmdline *cl,
4435 __attribute__((unused)) void *data)
4437 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4439 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4440 && !strcmp(res->tx, "tx")) {
4441 if (!strcmp(res->delay, "delay"))
4442 burst_tx_delay_time = res->time;
4443 if (!strcmp(res->retry, "retry"))
4444 burst_tx_retry_num = res->retry_num;
4449 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4450 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4451 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4452 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4454 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4455 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4456 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4457 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4458 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4459 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4460 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4461 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4462 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4463 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4465 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4466 .f = cmd_set_burst_tx_retry_parsed,
4467 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4469 (void *)&cmd_set_burst_tx_retry_set,
4470 (void *)&cmd_set_burst_tx_retry_burst,
4471 (void *)&cmd_set_burst_tx_retry_tx,
4472 (void *)&cmd_set_burst_tx_retry_delay,
4473 (void *)&cmd_set_burst_tx_retry_time,
4474 (void *)&cmd_set_burst_tx_retry_retry,
4475 (void *)&cmd_set_burst_tx_retry_retry_num,
4480 /* *** SET PROMISC MODE *** */
4481 struct cmd_set_promisc_mode_result {
4482 cmdline_fixed_string_t set;
4483 cmdline_fixed_string_t promisc;
4484 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4485 uint8_t port_num; /* valid if "allports" argument == 0 */
4486 cmdline_fixed_string_t mode;
4489 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4490 __attribute__((unused)) struct cmdline *cl,
4493 struct cmd_set_promisc_mode_result *res = parsed_result;
4497 if (!strcmp(res->mode, "on"))
4504 FOREACH_PORT(i, ports) {
4506 rte_eth_promiscuous_enable(i);
4508 rte_eth_promiscuous_disable(i);
4513 rte_eth_promiscuous_enable(res->port_num);
4515 rte_eth_promiscuous_disable(res->port_num);
4519 cmdline_parse_token_string_t cmd_setpromisc_set =
4520 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4521 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4522 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4524 cmdline_parse_token_string_t cmd_setpromisc_portall =
4525 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4527 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4528 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4530 cmdline_parse_token_string_t cmd_setpromisc_mode =
4531 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4534 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4535 .f = cmd_set_promisc_mode_parsed,
4537 .help_str = "set promisc all on|off: set promisc mode for all ports",
4539 (void *)&cmd_setpromisc_set,
4540 (void *)&cmd_setpromisc_promisc,
4541 (void *)&cmd_setpromisc_portall,
4542 (void *)&cmd_setpromisc_mode,
4547 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4548 .f = cmd_set_promisc_mode_parsed,
4550 .help_str = "set promisc X on|off: set promisc mode on port X",
4552 (void *)&cmd_setpromisc_set,
4553 (void *)&cmd_setpromisc_promisc,
4554 (void *)&cmd_setpromisc_portnum,
4555 (void *)&cmd_setpromisc_mode,
4560 /* *** SET ALLMULTI MODE *** */
4561 struct cmd_set_allmulti_mode_result {
4562 cmdline_fixed_string_t set;
4563 cmdline_fixed_string_t allmulti;
4564 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4565 uint8_t port_num; /* valid if "allports" argument == 0 */
4566 cmdline_fixed_string_t mode;
4569 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4570 __attribute__((unused)) struct cmdline *cl,
4573 struct cmd_set_allmulti_mode_result *res = parsed_result;
4577 if (!strcmp(res->mode, "on"))
4584 FOREACH_PORT(i, ports) {
4586 rte_eth_allmulticast_enable(i);
4588 rte_eth_allmulticast_disable(i);
4593 rte_eth_allmulticast_enable(res->port_num);
4595 rte_eth_allmulticast_disable(res->port_num);
4599 cmdline_parse_token_string_t cmd_setallmulti_set =
4600 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4601 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4602 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4604 cmdline_parse_token_string_t cmd_setallmulti_portall =
4605 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4607 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4608 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4610 cmdline_parse_token_string_t cmd_setallmulti_mode =
4611 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4614 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4615 .f = cmd_set_allmulti_mode_parsed,
4617 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4619 (void *)&cmd_setallmulti_set,
4620 (void *)&cmd_setallmulti_allmulti,
4621 (void *)&cmd_setallmulti_portall,
4622 (void *)&cmd_setallmulti_mode,
4627 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4628 .f = cmd_set_allmulti_mode_parsed,
4630 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4632 (void *)&cmd_setallmulti_set,
4633 (void *)&cmd_setallmulti_allmulti,
4634 (void *)&cmd_setallmulti_portnum,
4635 (void *)&cmd_setallmulti_mode,
4640 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4641 struct cmd_link_flow_ctrl_set_result {
4642 cmdline_fixed_string_t set;
4643 cmdline_fixed_string_t flow_ctrl;
4644 cmdline_fixed_string_t rx;
4645 cmdline_fixed_string_t rx_lfc_mode;
4646 cmdline_fixed_string_t tx;
4647 cmdline_fixed_string_t tx_lfc_mode;
4648 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4649 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4650 cmdline_fixed_string_t autoneg_str;
4651 cmdline_fixed_string_t autoneg;
4652 cmdline_fixed_string_t hw_str;
4653 uint32_t high_water;
4654 cmdline_fixed_string_t lw_str;
4656 cmdline_fixed_string_t pt_str;
4657 uint16_t pause_time;
4658 cmdline_fixed_string_t xon_str;
4663 cmdline_parse_token_string_t cmd_lfc_set_set =
4664 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4666 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4667 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4668 flow_ctrl, "flow_ctrl");
4669 cmdline_parse_token_string_t cmd_lfc_set_rx =
4670 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4672 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4673 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4674 rx_lfc_mode, "on#off");
4675 cmdline_parse_token_string_t cmd_lfc_set_tx =
4676 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4678 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4679 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4680 tx_lfc_mode, "on#off");
4681 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4682 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4683 hw_str, "high_water");
4684 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4685 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4686 high_water, UINT32);
4687 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4688 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4689 lw_str, "low_water");
4690 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4691 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4693 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4694 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4695 pt_str, "pause_time");
4696 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4697 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4698 pause_time, UINT16);
4699 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4700 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4701 xon_str, "send_xon");
4702 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4703 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4705 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4706 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4707 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4708 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4709 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4710 mac_ctrl_frame_fwd_mode, "on#off");
4711 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4712 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4713 autoneg_str, "autoneg");
4714 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4715 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4717 cmdline_parse_token_num_t cmd_lfc_set_portid =
4718 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4721 /* forward declaration */
4723 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4726 cmdline_parse_inst_t cmd_link_flow_control_set = {
4727 .f = cmd_link_flow_ctrl_set_parsed,
4729 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4730 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4731 autoneg on|off port_id",
4733 (void *)&cmd_lfc_set_set,
4734 (void *)&cmd_lfc_set_flow_ctrl,
4735 (void *)&cmd_lfc_set_rx,
4736 (void *)&cmd_lfc_set_rx_mode,
4737 (void *)&cmd_lfc_set_tx,
4738 (void *)&cmd_lfc_set_tx_mode,
4739 (void *)&cmd_lfc_set_high_water,
4740 (void *)&cmd_lfc_set_low_water,
4741 (void *)&cmd_lfc_set_pause_time,
4742 (void *)&cmd_lfc_set_send_xon,
4743 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4744 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4745 (void *)&cmd_lfc_set_autoneg_str,
4746 (void *)&cmd_lfc_set_autoneg,
4747 (void *)&cmd_lfc_set_portid,
4752 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4753 .f = cmd_link_flow_ctrl_set_parsed,
4754 .data = (void *)&cmd_link_flow_control_set_rx,
4755 .help_str = "Change rx flow control parameter: set flow_ctrl "
4756 "rx on|off port_id",
4758 (void *)&cmd_lfc_set_set,
4759 (void *)&cmd_lfc_set_flow_ctrl,
4760 (void *)&cmd_lfc_set_rx,
4761 (void *)&cmd_lfc_set_rx_mode,
4762 (void *)&cmd_lfc_set_portid,
4767 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4768 .f = cmd_link_flow_ctrl_set_parsed,
4769 .data = (void *)&cmd_link_flow_control_set_tx,
4770 .help_str = "Change tx flow control parameter: set flow_ctrl "
4771 "tx on|off port_id",
4773 (void *)&cmd_lfc_set_set,
4774 (void *)&cmd_lfc_set_flow_ctrl,
4775 (void *)&cmd_lfc_set_tx,
4776 (void *)&cmd_lfc_set_tx_mode,
4777 (void *)&cmd_lfc_set_portid,
4782 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4783 .f = cmd_link_flow_ctrl_set_parsed,
4784 .data = (void *)&cmd_link_flow_control_set_hw,
4785 .help_str = "Change high water flow control parameter: set flow_ctrl "
4786 "high_water value port_id",
4788 (void *)&cmd_lfc_set_set,
4789 (void *)&cmd_lfc_set_flow_ctrl,
4790 (void *)&cmd_lfc_set_high_water_str,
4791 (void *)&cmd_lfc_set_high_water,
4792 (void *)&cmd_lfc_set_portid,
4797 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4798 .f = cmd_link_flow_ctrl_set_parsed,
4799 .data = (void *)&cmd_link_flow_control_set_lw,
4800 .help_str = "Change low water flow control parameter: set flow_ctrl "
4801 "low_water value port_id",
4803 (void *)&cmd_lfc_set_set,
4804 (void *)&cmd_lfc_set_flow_ctrl,
4805 (void *)&cmd_lfc_set_low_water_str,
4806 (void *)&cmd_lfc_set_low_water,
4807 (void *)&cmd_lfc_set_portid,
4812 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4813 .f = cmd_link_flow_ctrl_set_parsed,
4814 .data = (void *)&cmd_link_flow_control_set_pt,
4815 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4816 "pause_time value port_id",
4818 (void *)&cmd_lfc_set_set,
4819 (void *)&cmd_lfc_set_flow_ctrl,
4820 (void *)&cmd_lfc_set_pause_time_str,
4821 (void *)&cmd_lfc_set_pause_time,
4822 (void *)&cmd_lfc_set_portid,
4827 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4828 .f = cmd_link_flow_ctrl_set_parsed,
4829 .data = (void *)&cmd_link_flow_control_set_xon,
4830 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4831 "send_xon value port_id",
4833 (void *)&cmd_lfc_set_set,
4834 (void *)&cmd_lfc_set_flow_ctrl,
4835 (void *)&cmd_lfc_set_send_xon_str,
4836 (void *)&cmd_lfc_set_send_xon,
4837 (void *)&cmd_lfc_set_portid,
4842 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4843 .f = cmd_link_flow_ctrl_set_parsed,
4844 .data = (void *)&cmd_link_flow_control_set_macfwd,
4845 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4846 "mac_ctrl_frame_fwd on|off port_id",
4848 (void *)&cmd_lfc_set_set,
4849 (void *)&cmd_lfc_set_flow_ctrl,
4850 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4851 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4852 (void *)&cmd_lfc_set_portid,
4857 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4858 .f = cmd_link_flow_ctrl_set_parsed,
4859 .data = (void *)&cmd_link_flow_control_set_autoneg,
4860 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4861 "autoneg on|off port_id",
4863 (void *)&cmd_lfc_set_set,
4864 (void *)&cmd_lfc_set_flow_ctrl,
4865 (void *)&cmd_lfc_set_autoneg_str,
4866 (void *)&cmd_lfc_set_autoneg,
4867 (void *)&cmd_lfc_set_portid,
4873 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4874 __attribute__((unused)) struct cmdline *cl,
4877 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4878 cmdline_parse_inst_t *cmd = data;
4879 struct rte_eth_fc_conf fc_conf;
4885 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4886 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4887 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4888 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4890 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4891 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4894 /* Partial command line, retrieve current configuration */
4896 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4898 printf("cannot get current flow ctrl parameters, return"
4899 "code = %d\n", ret);
4903 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4904 (fc_conf.mode == RTE_FC_FULL))
4906 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4907 (fc_conf.mode == RTE_FC_FULL))
4911 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4912 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4914 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4915 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4917 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4919 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4920 fc_conf.high_water = res->high_water;
4922 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4923 fc_conf.low_water = res->low_water;
4925 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4926 fc_conf.pause_time = res->pause_time;
4928 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4929 fc_conf.send_xon = res->send_xon;
4931 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4932 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4933 fc_conf.mac_ctrl_frame_fwd = 1;
4935 fc_conf.mac_ctrl_frame_fwd = 0;
4938 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4939 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4941 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4943 printf("bad flow contrl parameter, return code = %d \n", ret);
4946 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4947 struct cmd_priority_flow_ctrl_set_result {
4948 cmdline_fixed_string_t set;
4949 cmdline_fixed_string_t pfc_ctrl;
4950 cmdline_fixed_string_t rx;
4951 cmdline_fixed_string_t rx_pfc_mode;
4952 cmdline_fixed_string_t tx;
4953 cmdline_fixed_string_t tx_pfc_mode;
4954 uint32_t high_water;
4956 uint16_t pause_time;
4962 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4963 __attribute__((unused)) struct cmdline *cl,
4964 __attribute__((unused)) void *data)
4966 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4967 struct rte_eth_pfc_conf pfc_conf;
4968 int rx_fc_enable, tx_fc_enable;
4972 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4973 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4974 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4975 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4977 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4978 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4981 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4982 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4983 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4984 pfc_conf.fc.high_water = res->high_water;
4985 pfc_conf.fc.low_water = res->low_water;
4986 pfc_conf.fc.pause_time = res->pause_time;
4987 pfc_conf.priority = res->priority;
4989 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4991 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4994 cmdline_parse_token_string_t cmd_pfc_set_set =
4995 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4997 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4998 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4999 pfc_ctrl, "pfc_ctrl");
5000 cmdline_parse_token_string_t cmd_pfc_set_rx =
5001 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5003 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5004 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5005 rx_pfc_mode, "on#off");
5006 cmdline_parse_token_string_t cmd_pfc_set_tx =
5007 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5009 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5010 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5011 tx_pfc_mode, "on#off");
5012 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5013 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5014 high_water, UINT32);
5015 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5016 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5018 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5019 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5020 pause_time, UINT16);
5021 cmdline_parse_token_num_t cmd_pfc_set_priority =
5022 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5024 cmdline_parse_token_num_t cmd_pfc_set_portid =
5025 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5028 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5029 .f = cmd_priority_flow_ctrl_set_parsed,
5031 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5032 tx on|off high_water low_water pause_time priority port_id",
5034 (void *)&cmd_pfc_set_set,
5035 (void *)&cmd_pfc_set_flow_ctrl,
5036 (void *)&cmd_pfc_set_rx,
5037 (void *)&cmd_pfc_set_rx_mode,
5038 (void *)&cmd_pfc_set_tx,
5039 (void *)&cmd_pfc_set_tx_mode,
5040 (void *)&cmd_pfc_set_high_water,
5041 (void *)&cmd_pfc_set_low_water,
5042 (void *)&cmd_pfc_set_pause_time,
5043 (void *)&cmd_pfc_set_priority,
5044 (void *)&cmd_pfc_set_portid,
5049 /* *** RESET CONFIGURATION *** */
5050 struct cmd_reset_result {
5051 cmdline_fixed_string_t reset;
5052 cmdline_fixed_string_t def;
5055 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5057 __attribute__((unused)) void *data)
5059 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5060 set_def_fwd_config();
5063 cmdline_parse_token_string_t cmd_reset_set =
5064 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5065 cmdline_parse_token_string_t cmd_reset_def =
5066 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5069 cmdline_parse_inst_t cmd_reset = {
5070 .f = cmd_reset_parsed,
5072 .help_str = "set default: reset default forwarding configuration",
5074 (void *)&cmd_reset_set,
5075 (void *)&cmd_reset_def,
5080 /* *** START FORWARDING *** */
5081 struct cmd_start_result {
5082 cmdline_fixed_string_t start;
5085 cmdline_parse_token_string_t cmd_start_start =
5086 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5088 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5089 __attribute__((unused)) struct cmdline *cl,
5090 __attribute__((unused)) void *data)
5092 start_packet_forwarding(0);
5095 cmdline_parse_inst_t cmd_start = {
5096 .f = cmd_start_parsed,
5098 .help_str = "start packet forwarding",
5100 (void *)&cmd_start_start,
5105 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5106 struct cmd_start_tx_first_result {
5107 cmdline_fixed_string_t start;
5108 cmdline_fixed_string_t tx_first;
5112 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5113 __attribute__((unused)) struct cmdline *cl,
5114 __attribute__((unused)) void *data)
5116 start_packet_forwarding(1);
5119 cmdline_parse_token_string_t cmd_start_tx_first_start =
5120 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5122 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5123 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5124 tx_first, "tx_first");
5126 cmdline_parse_inst_t cmd_start_tx_first = {
5127 .f = cmd_start_tx_first_parsed,
5129 .help_str = "start packet forwarding, after sending 1 burst of packets",
5131 (void *)&cmd_start_tx_first_start,
5132 (void *)&cmd_start_tx_first_tx_first,
5137 /* *** SET LINK UP *** */
5138 struct cmd_set_link_up_result {
5139 cmdline_fixed_string_t set;
5140 cmdline_fixed_string_t link_up;
5141 cmdline_fixed_string_t port;
5145 cmdline_parse_token_string_t cmd_set_link_up_set =
5146 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5147 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5148 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5150 cmdline_parse_token_string_t cmd_set_link_up_port =
5151 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5152 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5153 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5155 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5156 __attribute__((unused)) struct cmdline *cl,
5157 __attribute__((unused)) void *data)
5159 struct cmd_set_link_up_result *res = parsed_result;
5160 dev_set_link_up(res->port_id);
5163 cmdline_parse_inst_t cmd_set_link_up = {
5164 .f = cmd_set_link_up_parsed,
5166 .help_str = "set link-up port (port id)",
5168 (void *)&cmd_set_link_up_set,
5169 (void *)&cmd_set_link_up_link_up,
5170 (void *)&cmd_set_link_up_port,
5171 (void *)&cmd_set_link_up_port_id,
5176 /* *** SET LINK DOWN *** */
5177 struct cmd_set_link_down_result {
5178 cmdline_fixed_string_t set;
5179 cmdline_fixed_string_t link_down;
5180 cmdline_fixed_string_t port;
5184 cmdline_parse_token_string_t cmd_set_link_down_set =
5185 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5186 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5187 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5189 cmdline_parse_token_string_t cmd_set_link_down_port =
5190 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5191 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5192 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5194 static void cmd_set_link_down_parsed(
5195 __attribute__((unused)) void *parsed_result,
5196 __attribute__((unused)) struct cmdline *cl,
5197 __attribute__((unused)) void *data)
5199 struct cmd_set_link_down_result *res = parsed_result;
5200 dev_set_link_down(res->port_id);
5203 cmdline_parse_inst_t cmd_set_link_down = {
5204 .f = cmd_set_link_down_parsed,
5206 .help_str = "set link-down port (port id)",
5208 (void *)&cmd_set_link_down_set,
5209 (void *)&cmd_set_link_down_link_down,
5210 (void *)&cmd_set_link_down_port,
5211 (void *)&cmd_set_link_down_port_id,
5216 /* *** SHOW CFG *** */
5217 struct cmd_showcfg_result {
5218 cmdline_fixed_string_t show;
5219 cmdline_fixed_string_t cfg;
5220 cmdline_fixed_string_t what;
5223 static void cmd_showcfg_parsed(void *parsed_result,
5224 __attribute__((unused)) struct cmdline *cl,
5225 __attribute__((unused)) void *data)
5227 struct cmd_showcfg_result *res = parsed_result;
5228 if (!strcmp(res->what, "rxtx"))
5229 rxtx_config_display();
5230 else if (!strcmp(res->what, "cores"))
5231 fwd_lcores_config_display();
5232 else if (!strcmp(res->what, "fwd"))
5233 fwd_config_display();
5236 cmdline_parse_token_string_t cmd_showcfg_show =
5237 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5238 cmdline_parse_token_string_t cmd_showcfg_port =
5239 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5240 cmdline_parse_token_string_t cmd_showcfg_what =
5241 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5244 cmdline_parse_inst_t cmd_showcfg = {
5245 .f = cmd_showcfg_parsed,
5247 .help_str = "show config rxtx|cores|fwd",
5249 (void *)&cmd_showcfg_show,
5250 (void *)&cmd_showcfg_port,
5251 (void *)&cmd_showcfg_what,
5256 /* *** SHOW ALL PORT INFO *** */
5257 struct cmd_showportall_result {
5258 cmdline_fixed_string_t show;
5259 cmdline_fixed_string_t port;
5260 cmdline_fixed_string_t what;
5261 cmdline_fixed_string_t all;
5264 static void cmd_showportall_parsed(void *parsed_result,
5265 __attribute__((unused)) struct cmdline *cl,
5266 __attribute__((unused)) void *data)
5270 struct cmd_showportall_result *res = parsed_result;
5271 if (!strcmp(res->show, "clear")) {
5272 if (!strcmp(res->what, "stats"))
5273 FOREACH_PORT(i, ports)
5275 else if (!strcmp(res->what, "xstats"))
5276 FOREACH_PORT(i, ports)
5277 nic_xstats_clear(i);
5278 } else if (!strcmp(res->what, "info"))
5279 FOREACH_PORT(i, ports)
5280 port_infos_display(i);
5281 else if (!strcmp(res->what, "stats"))
5282 FOREACH_PORT(i, ports)
5283 nic_stats_display(i);
5284 else if (!strcmp(res->what, "xstats"))
5285 FOREACH_PORT(i, ports)
5286 nic_xstats_display(i);
5287 else if (!strcmp(res->what, "fdir"))
5288 FOREACH_PORT(i, ports)
5290 else if (!strcmp(res->what, "stat_qmap"))
5291 FOREACH_PORT(i, ports)
5292 nic_stats_mapping_display(i);
5293 else if (!strcmp(res->what, "dcb_tc"))
5294 FOREACH_PORT(i, ports)
5295 port_dcb_info_display(i);
5298 cmdline_parse_token_string_t cmd_showportall_show =
5299 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5301 cmdline_parse_token_string_t cmd_showportall_port =
5302 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5303 cmdline_parse_token_string_t cmd_showportall_what =
5304 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5305 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5306 cmdline_parse_token_string_t cmd_showportall_all =
5307 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5308 cmdline_parse_inst_t cmd_showportall = {
5309 .f = cmd_showportall_parsed,
5311 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5313 (void *)&cmd_showportall_show,
5314 (void *)&cmd_showportall_port,
5315 (void *)&cmd_showportall_what,
5316 (void *)&cmd_showportall_all,
5321 /* *** SHOW PORT INFO *** */
5322 struct cmd_showport_result {
5323 cmdline_fixed_string_t show;
5324 cmdline_fixed_string_t port;
5325 cmdline_fixed_string_t what;
5329 static void cmd_showport_parsed(void *parsed_result,
5330 __attribute__((unused)) struct cmdline *cl,
5331 __attribute__((unused)) void *data)
5333 struct cmd_showport_result *res = parsed_result;
5334 if (!strcmp(res->show, "clear")) {
5335 if (!strcmp(res->what, "stats"))
5336 nic_stats_clear(res->portnum);
5337 else if (!strcmp(res->what, "xstats"))
5338 nic_xstats_clear(res->portnum);
5339 } else if (!strcmp(res->what, "info"))
5340 port_infos_display(res->portnum);
5341 else if (!strcmp(res->what, "stats"))
5342 nic_stats_display(res->portnum);
5343 else if (!strcmp(res->what, "xstats"))
5344 nic_xstats_display(res->portnum);
5345 else if (!strcmp(res->what, "fdir"))
5346 fdir_get_infos(res->portnum);
5347 else if (!strcmp(res->what, "stat_qmap"))
5348 nic_stats_mapping_display(res->portnum);
5349 else if (!strcmp(res->what, "dcb_tc"))
5350 port_dcb_info_display(res->portnum);
5353 cmdline_parse_token_string_t cmd_showport_show =
5354 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5356 cmdline_parse_token_string_t cmd_showport_port =
5357 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5358 cmdline_parse_token_string_t cmd_showport_what =
5359 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5360 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5361 cmdline_parse_token_num_t cmd_showport_portnum =
5362 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5364 cmdline_parse_inst_t cmd_showport = {
5365 .f = cmd_showport_parsed,
5367 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5369 (void *)&cmd_showport_show,
5370 (void *)&cmd_showport_port,
5371 (void *)&cmd_showport_what,
5372 (void *)&cmd_showport_portnum,
5377 /* *** SHOW QUEUE INFO *** */
5378 struct cmd_showqueue_result {
5379 cmdline_fixed_string_t show;
5380 cmdline_fixed_string_t type;
5381 cmdline_fixed_string_t what;
5387 cmd_showqueue_parsed(void *parsed_result,
5388 __attribute__((unused)) struct cmdline *cl,
5389 __attribute__((unused)) void *data)
5391 struct cmd_showqueue_result *res = parsed_result;
5393 if (!strcmp(res->type, "rxq"))
5394 rx_queue_infos_display(res->portnum, res->queuenum);
5395 else if (!strcmp(res->type, "txq"))
5396 tx_queue_infos_display(res->portnum, res->queuenum);
5399 cmdline_parse_token_string_t cmd_showqueue_show =
5400 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5401 cmdline_parse_token_string_t cmd_showqueue_type =
5402 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5403 cmdline_parse_token_string_t cmd_showqueue_what =
5404 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5405 cmdline_parse_token_num_t cmd_showqueue_portnum =
5406 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5407 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5408 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5410 cmdline_parse_inst_t cmd_showqueue = {
5411 .f = cmd_showqueue_parsed,
5413 .help_str = "show rxq|txq info <port number> <queue_number>",
5415 (void *)&cmd_showqueue_show,
5416 (void *)&cmd_showqueue_type,
5417 (void *)&cmd_showqueue_what,
5418 (void *)&cmd_showqueue_portnum,
5419 (void *)&cmd_showqueue_queuenum,
5424 /* *** READ PORT REGISTER *** */
5425 struct cmd_read_reg_result {
5426 cmdline_fixed_string_t read;
5427 cmdline_fixed_string_t reg;
5433 cmd_read_reg_parsed(void *parsed_result,
5434 __attribute__((unused)) struct cmdline *cl,
5435 __attribute__((unused)) void *data)
5437 struct cmd_read_reg_result *res = parsed_result;
5438 port_reg_display(res->port_id, res->reg_off);
5441 cmdline_parse_token_string_t cmd_read_reg_read =
5442 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5443 cmdline_parse_token_string_t cmd_read_reg_reg =
5444 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5445 cmdline_parse_token_num_t cmd_read_reg_port_id =
5446 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5447 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5448 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5450 cmdline_parse_inst_t cmd_read_reg = {
5451 .f = cmd_read_reg_parsed,
5453 .help_str = "read reg port_id reg_off",
5455 (void *)&cmd_read_reg_read,
5456 (void *)&cmd_read_reg_reg,
5457 (void *)&cmd_read_reg_port_id,
5458 (void *)&cmd_read_reg_reg_off,
5463 /* *** READ PORT REGISTER BIT FIELD *** */
5464 struct cmd_read_reg_bit_field_result {
5465 cmdline_fixed_string_t read;
5466 cmdline_fixed_string_t regfield;
5474 cmd_read_reg_bit_field_parsed(void *parsed_result,
5475 __attribute__((unused)) struct cmdline *cl,
5476 __attribute__((unused)) void *data)
5478 struct cmd_read_reg_bit_field_result *res = parsed_result;
5479 port_reg_bit_field_display(res->port_id, res->reg_off,
5480 res->bit1_pos, res->bit2_pos);
5483 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5484 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5486 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5487 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5488 regfield, "regfield");
5489 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5490 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5492 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5493 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5495 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5496 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5498 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5499 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5502 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5503 .f = cmd_read_reg_bit_field_parsed,
5505 .help_str = "read regfield port_id reg_off bit_x bit_y "
5506 "(read register bit field between bit_x and bit_y included)",
5508 (void *)&cmd_read_reg_bit_field_read,
5509 (void *)&cmd_read_reg_bit_field_regfield,
5510 (void *)&cmd_read_reg_bit_field_port_id,
5511 (void *)&cmd_read_reg_bit_field_reg_off,
5512 (void *)&cmd_read_reg_bit_field_bit1_pos,
5513 (void *)&cmd_read_reg_bit_field_bit2_pos,
5518 /* *** READ PORT REGISTER BIT *** */
5519 struct cmd_read_reg_bit_result {
5520 cmdline_fixed_string_t read;
5521 cmdline_fixed_string_t regbit;
5528 cmd_read_reg_bit_parsed(void *parsed_result,
5529 __attribute__((unused)) struct cmdline *cl,
5530 __attribute__((unused)) void *data)
5532 struct cmd_read_reg_bit_result *res = parsed_result;
5533 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5536 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5537 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5538 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5539 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5541 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5542 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5543 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5544 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5545 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5546 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5548 cmdline_parse_inst_t cmd_read_reg_bit = {
5549 .f = cmd_read_reg_bit_parsed,
5551 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5553 (void *)&cmd_read_reg_bit_read,
5554 (void *)&cmd_read_reg_bit_regbit,
5555 (void *)&cmd_read_reg_bit_port_id,
5556 (void *)&cmd_read_reg_bit_reg_off,
5557 (void *)&cmd_read_reg_bit_bit_pos,
5562 /* *** WRITE PORT REGISTER *** */
5563 struct cmd_write_reg_result {
5564 cmdline_fixed_string_t write;
5565 cmdline_fixed_string_t reg;
5572 cmd_write_reg_parsed(void *parsed_result,
5573 __attribute__((unused)) struct cmdline *cl,
5574 __attribute__((unused)) void *data)
5576 struct cmd_write_reg_result *res = parsed_result;
5577 port_reg_set(res->port_id, res->reg_off, res->value);
5580 cmdline_parse_token_string_t cmd_write_reg_write =
5581 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5582 cmdline_parse_token_string_t cmd_write_reg_reg =
5583 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5584 cmdline_parse_token_num_t cmd_write_reg_port_id =
5585 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5586 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5587 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5588 cmdline_parse_token_num_t cmd_write_reg_value =
5589 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5591 cmdline_parse_inst_t cmd_write_reg = {
5592 .f = cmd_write_reg_parsed,
5594 .help_str = "write reg port_id reg_off reg_value",
5596 (void *)&cmd_write_reg_write,
5597 (void *)&cmd_write_reg_reg,
5598 (void *)&cmd_write_reg_port_id,
5599 (void *)&cmd_write_reg_reg_off,
5600 (void *)&cmd_write_reg_value,
5605 /* *** WRITE PORT REGISTER BIT FIELD *** */
5606 struct cmd_write_reg_bit_field_result {
5607 cmdline_fixed_string_t write;
5608 cmdline_fixed_string_t regfield;
5617 cmd_write_reg_bit_field_parsed(void *parsed_result,
5618 __attribute__((unused)) struct cmdline *cl,
5619 __attribute__((unused)) void *data)
5621 struct cmd_write_reg_bit_field_result *res = parsed_result;
5622 port_reg_bit_field_set(res->port_id, res->reg_off,
5623 res->bit1_pos, res->bit2_pos, res->value);
5626 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5627 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5629 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5630 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5631 regfield, "regfield");
5632 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5633 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5635 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5636 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5638 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5639 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5641 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5642 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5644 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5645 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5648 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5649 .f = cmd_write_reg_bit_field_parsed,
5651 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5652 "(set register bit field between bit_x and bit_y included)",
5654 (void *)&cmd_write_reg_bit_field_write,
5655 (void *)&cmd_write_reg_bit_field_regfield,
5656 (void *)&cmd_write_reg_bit_field_port_id,
5657 (void *)&cmd_write_reg_bit_field_reg_off,
5658 (void *)&cmd_write_reg_bit_field_bit1_pos,
5659 (void *)&cmd_write_reg_bit_field_bit2_pos,
5660 (void *)&cmd_write_reg_bit_field_value,
5665 /* *** WRITE PORT REGISTER BIT *** */
5666 struct cmd_write_reg_bit_result {
5667 cmdline_fixed_string_t write;
5668 cmdline_fixed_string_t regbit;
5676 cmd_write_reg_bit_parsed(void *parsed_result,
5677 __attribute__((unused)) struct cmdline *cl,
5678 __attribute__((unused)) void *data)
5680 struct cmd_write_reg_bit_result *res = parsed_result;
5681 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5684 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5685 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5687 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5688 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5690 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5691 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5692 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5693 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5694 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5695 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5696 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5697 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5699 cmdline_parse_inst_t cmd_write_reg_bit = {
5700 .f = cmd_write_reg_bit_parsed,
5702 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5704 (void *)&cmd_write_reg_bit_write,
5705 (void *)&cmd_write_reg_bit_regbit,
5706 (void *)&cmd_write_reg_bit_port_id,
5707 (void *)&cmd_write_reg_bit_reg_off,
5708 (void *)&cmd_write_reg_bit_bit_pos,
5709 (void *)&cmd_write_reg_bit_value,
5714 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5715 struct cmd_read_rxd_txd_result {
5716 cmdline_fixed_string_t read;
5717 cmdline_fixed_string_t rxd_txd;
5724 cmd_read_rxd_txd_parsed(void *parsed_result,
5725 __attribute__((unused)) struct cmdline *cl,
5726 __attribute__((unused)) void *data)
5728 struct cmd_read_rxd_txd_result *res = parsed_result;
5730 if (!strcmp(res->rxd_txd, "rxd"))
5731 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5732 else if (!strcmp(res->rxd_txd, "txd"))
5733 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5736 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5737 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5738 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5739 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5741 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5742 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5743 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5744 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5745 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5746 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5748 cmdline_parse_inst_t cmd_read_rxd_txd = {
5749 .f = cmd_read_rxd_txd_parsed,
5751 .help_str = "read rxd|txd port_id queue_id rxd_id",
5753 (void *)&cmd_read_rxd_txd_read,
5754 (void *)&cmd_read_rxd_txd_rxd_txd,
5755 (void *)&cmd_read_rxd_txd_port_id,
5756 (void *)&cmd_read_rxd_txd_queue_id,
5757 (void *)&cmd_read_rxd_txd_desc_id,
5763 struct cmd_quit_result {
5764 cmdline_fixed_string_t quit;
5767 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5769 __attribute__((unused)) void *data)
5775 cmdline_parse_token_string_t cmd_quit_quit =
5776 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5778 cmdline_parse_inst_t cmd_quit = {
5779 .f = cmd_quit_parsed,
5781 .help_str = "exit application",
5783 (void *)&cmd_quit_quit,
5788 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5789 struct cmd_mac_addr_result {
5790 cmdline_fixed_string_t mac_addr_cmd;
5791 cmdline_fixed_string_t what;
5793 struct ether_addr address;
5796 static void cmd_mac_addr_parsed(void *parsed_result,
5797 __attribute__((unused)) struct cmdline *cl,
5798 __attribute__((unused)) void *data)
5800 struct cmd_mac_addr_result *res = parsed_result;
5803 if (strcmp(res->what, "add") == 0)
5804 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5806 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5808 /* check the return value and print it if is < 0 */
5810 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5814 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5815 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5817 cmdline_parse_token_string_t cmd_mac_addr_what =
5818 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5820 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5821 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5822 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5823 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5825 cmdline_parse_inst_t cmd_mac_addr = {
5826 .f = cmd_mac_addr_parsed,
5828 .help_str = "mac_addr add|remove X <address>: "
5829 "add/remove MAC address on port X",
5831 (void *)&cmd_mac_addr_cmd,
5832 (void *)&cmd_mac_addr_what,
5833 (void *)&cmd_mac_addr_portnum,
5834 (void *)&cmd_mac_addr_addr,
5840 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5841 struct cmd_set_qmap_result {
5842 cmdline_fixed_string_t set;
5843 cmdline_fixed_string_t qmap;
5844 cmdline_fixed_string_t what;
5851 cmd_set_qmap_parsed(void *parsed_result,
5852 __attribute__((unused)) struct cmdline *cl,
5853 __attribute__((unused)) void *data)
5855 struct cmd_set_qmap_result *res = parsed_result;
5856 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5858 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5861 cmdline_parse_token_string_t cmd_setqmap_set =
5862 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5864 cmdline_parse_token_string_t cmd_setqmap_qmap =
5865 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5867 cmdline_parse_token_string_t cmd_setqmap_what =
5868 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5870 cmdline_parse_token_num_t cmd_setqmap_portid =
5871 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5873 cmdline_parse_token_num_t cmd_setqmap_queueid =
5874 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5876 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5877 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5880 cmdline_parse_inst_t cmd_set_qmap = {
5881 .f = cmd_set_qmap_parsed,
5883 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5885 (void *)&cmd_setqmap_set,
5886 (void *)&cmd_setqmap_qmap,
5887 (void *)&cmd_setqmap_what,
5888 (void *)&cmd_setqmap_portid,
5889 (void *)&cmd_setqmap_queueid,
5890 (void *)&cmd_setqmap_mapvalue,
5895 /* *** CONFIGURE UNICAST HASH TABLE *** */
5896 struct cmd_set_uc_hash_table {
5897 cmdline_fixed_string_t set;
5898 cmdline_fixed_string_t port;
5900 cmdline_fixed_string_t what;
5901 struct ether_addr address;
5902 cmdline_fixed_string_t mode;
5906 cmd_set_uc_hash_parsed(void *parsed_result,
5907 __attribute__((unused)) struct cmdline *cl,
5908 __attribute__((unused)) void *data)
5911 struct cmd_set_uc_hash_table *res = parsed_result;
5913 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5915 if (strcmp(res->what, "uta") == 0)
5916 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5917 &res->address,(uint8_t)is_on);
5919 printf("bad unicast hash table parameter, return code = %d \n", ret);
5923 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5926 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5929 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5930 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5932 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5933 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5935 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5936 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5938 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5939 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5942 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5943 .f = cmd_set_uc_hash_parsed,
5945 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5947 (void *)&cmd_set_uc_hash_set,
5948 (void *)&cmd_set_uc_hash_port,
5949 (void *)&cmd_set_uc_hash_portid,
5950 (void *)&cmd_set_uc_hash_what,
5951 (void *)&cmd_set_uc_hash_mac,
5952 (void *)&cmd_set_uc_hash_mode,
5957 struct cmd_set_uc_all_hash_table {
5958 cmdline_fixed_string_t set;
5959 cmdline_fixed_string_t port;
5961 cmdline_fixed_string_t what;
5962 cmdline_fixed_string_t value;
5963 cmdline_fixed_string_t mode;
5967 cmd_set_uc_all_hash_parsed(void *parsed_result,
5968 __attribute__((unused)) struct cmdline *cl,
5969 __attribute__((unused)) void *data)
5972 struct cmd_set_uc_all_hash_table *res = parsed_result;
5974 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5976 if ((strcmp(res->what, "uta") == 0) &&
5977 (strcmp(res->value, "all") == 0))
5978 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5980 printf("bad unicast hash table parameter,"
5981 "return code = %d \n", ret);
5984 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5985 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5987 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5988 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5990 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5991 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5993 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5994 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5996 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5997 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5999 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6000 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6003 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6004 .f = cmd_set_uc_all_hash_parsed,
6006 .help_str = "set port X uta all on|off (X = port number)",
6008 (void *)&cmd_set_uc_all_hash_set,
6009 (void *)&cmd_set_uc_all_hash_port,
6010 (void *)&cmd_set_uc_all_hash_portid,
6011 (void *)&cmd_set_uc_all_hash_what,
6012 (void *)&cmd_set_uc_all_hash_value,
6013 (void *)&cmd_set_uc_all_hash_mode,
6018 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6019 struct cmd_set_vf_macvlan_filter {
6020 cmdline_fixed_string_t set;
6021 cmdline_fixed_string_t port;
6023 cmdline_fixed_string_t vf;
6025 struct ether_addr address;
6026 cmdline_fixed_string_t filter_type;
6027 cmdline_fixed_string_t mode;
6031 cmd_set_vf_macvlan_parsed(void *parsed_result,
6032 __attribute__((unused)) struct cmdline *cl,
6033 __attribute__((unused)) void *data)
6036 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6037 struct rte_eth_mac_filter filter;
6039 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6041 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6043 /* set VF MAC filter */
6047 filter.dst_id = res->vf_id;
6049 if (!strcmp(res->filter_type, "exact-mac"))
6050 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6051 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6052 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6053 else if (!strcmp(res->filter_type, "hashmac"))
6054 filter.filter_type = RTE_MAC_HASH_MATCH;
6055 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6056 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6058 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6061 ret = rte_eth_dev_filter_ctrl(res->port_id,
6062 RTE_ETH_FILTER_MACVLAN,
6066 ret = rte_eth_dev_filter_ctrl(res->port_id,
6067 RTE_ETH_FILTER_MACVLAN,
6068 RTE_ETH_FILTER_DELETE,
6072 printf("bad set MAC hash parameter, return code = %d\n", ret);
6076 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6077 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6079 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6080 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6082 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6083 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6085 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6086 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6088 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6089 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6091 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6092 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6094 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6095 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6096 filter_type, "exact-mac#exact-mac-vlan"
6097 "#hashmac#hashmac-vlan");
6098 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6099 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6102 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6103 .f = cmd_set_vf_macvlan_parsed,
6105 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6106 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6108 "exact match rule:exact match of MAC or MAC and VLAN; "
6109 "hash match rule: hash match of MAC and exact match "
6112 (void *)&cmd_set_vf_macvlan_set,
6113 (void *)&cmd_set_vf_macvlan_port,
6114 (void *)&cmd_set_vf_macvlan_portid,
6115 (void *)&cmd_set_vf_macvlan_vf,
6116 (void *)&cmd_set_vf_macvlan_vf_id,
6117 (void *)&cmd_set_vf_macvlan_mac,
6118 (void *)&cmd_set_vf_macvlan_filter_type,
6119 (void *)&cmd_set_vf_macvlan_mode,
6124 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6125 struct cmd_set_vf_traffic {
6126 cmdline_fixed_string_t set;
6127 cmdline_fixed_string_t port;
6129 cmdline_fixed_string_t vf;
6131 cmdline_fixed_string_t what;
6132 cmdline_fixed_string_t mode;
6136 cmd_set_vf_traffic_parsed(void *parsed_result,
6137 __attribute__((unused)) struct cmdline *cl,
6138 __attribute__((unused)) void *data)
6140 struct cmd_set_vf_traffic *res = parsed_result;
6141 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6142 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6144 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6147 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6148 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6150 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6151 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6153 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6154 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6156 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6157 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6159 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6160 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6162 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6163 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6165 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6166 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6169 cmdline_parse_inst_t cmd_set_vf_traffic = {
6170 .f = cmd_set_vf_traffic_parsed,
6172 .help_str = "set port X vf Y rx|tx on|off"
6173 "(X = port number,Y = vf id)",
6175 (void *)&cmd_setvf_traffic_set,
6176 (void *)&cmd_setvf_traffic_port,
6177 (void *)&cmd_setvf_traffic_portid,
6178 (void *)&cmd_setvf_traffic_vf,
6179 (void *)&cmd_setvf_traffic_vfid,
6180 (void *)&cmd_setvf_traffic_what,
6181 (void *)&cmd_setvf_traffic_mode,
6186 /* *** CONFIGURE VF RECEIVE MODE *** */
6187 struct cmd_set_vf_rxmode {
6188 cmdline_fixed_string_t set;
6189 cmdline_fixed_string_t port;
6191 cmdline_fixed_string_t vf;
6193 cmdline_fixed_string_t what;
6194 cmdline_fixed_string_t mode;
6195 cmdline_fixed_string_t on;
6199 cmd_set_vf_rxmode_parsed(void *parsed_result,
6200 __attribute__((unused)) struct cmdline *cl,
6201 __attribute__((unused)) void *data)
6204 uint16_t rx_mode = 0;
6205 struct cmd_set_vf_rxmode *res = parsed_result;
6207 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6208 if (!strcmp(res->what,"rxmode")) {
6209 if (!strcmp(res->mode, "AUPE"))
6210 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6211 else if (!strcmp(res->mode, "ROPE"))
6212 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6213 else if (!strcmp(res->mode, "BAM"))
6214 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6215 else if (!strncmp(res->mode, "MPE",3))
6216 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6219 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6221 printf("bad VF receive mode parameter, return code = %d \n",
6225 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6226 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6228 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6231 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6232 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6234 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6235 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6237 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6238 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6240 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6241 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6243 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6244 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6245 mode, "AUPE#ROPE#BAM#MPE");
6246 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6247 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6250 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6251 .f = cmd_set_vf_rxmode_parsed,
6253 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6255 (void *)&cmd_set_vf_rxmode_set,
6256 (void *)&cmd_set_vf_rxmode_port,
6257 (void *)&cmd_set_vf_rxmode_portid,
6258 (void *)&cmd_set_vf_rxmode_vf,
6259 (void *)&cmd_set_vf_rxmode_vfid,
6260 (void *)&cmd_set_vf_rxmode_what,
6261 (void *)&cmd_set_vf_rxmode_mode,
6262 (void *)&cmd_set_vf_rxmode_on,
6267 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6268 struct cmd_vf_mac_addr_result {
6269 cmdline_fixed_string_t mac_addr_cmd;
6270 cmdline_fixed_string_t what;
6271 cmdline_fixed_string_t port;
6273 cmdline_fixed_string_t vf;
6275 struct ether_addr address;
6278 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6279 __attribute__((unused)) struct cmdline *cl,
6280 __attribute__((unused)) void *data)
6282 struct cmd_vf_mac_addr_result *res = parsed_result;
6285 if (strcmp(res->what, "add") == 0)
6286 ret = rte_eth_dev_mac_addr_add(res->port_num,
6287 &res->address, res->vf_num);
6289 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6293 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6294 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6295 mac_addr_cmd,"mac_addr");
6296 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6297 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6299 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6300 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6302 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6303 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6305 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6306 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6308 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6309 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6311 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6312 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6315 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6316 .f = cmd_vf_mac_addr_parsed,
6318 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6319 "Y = VF number)add MAC address filtering for a VF on port X",
6321 (void *)&cmd_vf_mac_addr_cmd,
6322 (void *)&cmd_vf_mac_addr_what,
6323 (void *)&cmd_vf_mac_addr_port,
6324 (void *)&cmd_vf_mac_addr_portnum,
6325 (void *)&cmd_vf_mac_addr_vf,
6326 (void *)&cmd_vf_mac_addr_vfnum,
6327 (void *)&cmd_vf_mac_addr_addr,
6332 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6333 struct cmd_vf_rx_vlan_filter {
6334 cmdline_fixed_string_t rx_vlan;
6335 cmdline_fixed_string_t what;
6337 cmdline_fixed_string_t port;
6339 cmdline_fixed_string_t vf;
6344 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6345 __attribute__((unused)) struct cmdline *cl,
6346 __attribute__((unused)) void *data)
6348 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6350 if (!strcmp(res->what, "add"))
6351 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6353 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6356 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6357 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6358 rx_vlan, "rx_vlan");
6359 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6360 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6362 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6363 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6365 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6366 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6368 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6369 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6371 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6372 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6374 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6375 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6378 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6379 .f = cmd_vf_rx_vlan_filter_parsed,
6381 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6382 "Y = port number,Z = hexadecimal VF mask)",
6384 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6385 (void *)&cmd_vf_rx_vlan_filter_what,
6386 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6387 (void *)&cmd_vf_rx_vlan_filter_port,
6388 (void *)&cmd_vf_rx_vlan_filter_portid,
6389 (void *)&cmd_vf_rx_vlan_filter_vf,
6390 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6395 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6396 struct cmd_queue_rate_limit_result {
6397 cmdline_fixed_string_t set;
6398 cmdline_fixed_string_t port;
6400 cmdline_fixed_string_t queue;
6402 cmdline_fixed_string_t rate;
6406 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6407 __attribute__((unused)) struct cmdline *cl,
6408 __attribute__((unused)) void *data)
6410 struct cmd_queue_rate_limit_result *res = parsed_result;
6413 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6414 && (strcmp(res->queue, "queue") == 0)
6415 && (strcmp(res->rate, "rate") == 0))
6416 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6419 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6423 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6424 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6426 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6427 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6429 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6430 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6432 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6433 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6435 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6436 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6438 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6439 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6441 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6442 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6445 cmdline_parse_inst_t cmd_queue_rate_limit = {
6446 .f = cmd_queue_rate_limit_parsed,
6448 .help_str = "set port X queue Y rate Z:(X = port number,"
6449 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6451 (void *)&cmd_queue_rate_limit_set,
6452 (void *)&cmd_queue_rate_limit_port,
6453 (void *)&cmd_queue_rate_limit_portnum,
6454 (void *)&cmd_queue_rate_limit_queue,
6455 (void *)&cmd_queue_rate_limit_queuenum,
6456 (void *)&cmd_queue_rate_limit_rate,
6457 (void *)&cmd_queue_rate_limit_ratenum,
6462 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6463 struct cmd_vf_rate_limit_result {
6464 cmdline_fixed_string_t set;
6465 cmdline_fixed_string_t port;
6467 cmdline_fixed_string_t vf;
6469 cmdline_fixed_string_t rate;
6471 cmdline_fixed_string_t q_msk;
6475 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6476 __attribute__((unused)) struct cmdline *cl,
6477 __attribute__((unused)) void *data)
6479 struct cmd_vf_rate_limit_result *res = parsed_result;
6482 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6483 && (strcmp(res->vf, "vf") == 0)
6484 && (strcmp(res->rate, "rate") == 0)
6485 && (strcmp(res->q_msk, "queue_mask") == 0))
6486 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6487 res->rate_num, res->q_msk_val);
6489 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6493 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6494 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6496 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6497 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6499 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6500 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6502 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6503 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6505 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6506 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6508 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6509 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6511 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6512 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6514 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6515 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6516 q_msk, "queue_mask");
6517 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6518 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6521 cmdline_parse_inst_t cmd_vf_rate_limit = {
6522 .f = cmd_vf_rate_limit_parsed,
6524 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6525 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6526 "for queues of VF on port X",
6528 (void *)&cmd_vf_rate_limit_set,
6529 (void *)&cmd_vf_rate_limit_port,
6530 (void *)&cmd_vf_rate_limit_portnum,
6531 (void *)&cmd_vf_rate_limit_vf,
6532 (void *)&cmd_vf_rate_limit_vfnum,
6533 (void *)&cmd_vf_rate_limit_rate,
6534 (void *)&cmd_vf_rate_limit_ratenum,
6535 (void *)&cmd_vf_rate_limit_q_msk,
6536 (void *)&cmd_vf_rate_limit_q_msk_val,
6541 /* *** ADD TUNNEL FILTER OF A PORT *** */
6542 struct cmd_tunnel_filter_result {
6543 cmdline_fixed_string_t cmd;
6544 cmdline_fixed_string_t what;
6546 struct ether_addr outer_mac;
6547 struct ether_addr inner_mac;
6548 cmdline_ipaddr_t ip_value;
6549 uint16_t inner_vlan;
6550 cmdline_fixed_string_t tunnel_type;
6551 cmdline_fixed_string_t filter_type;
6557 cmd_tunnel_filter_parsed(void *parsed_result,
6558 __attribute__((unused)) struct cmdline *cl,
6559 __attribute__((unused)) void *data)
6561 struct cmd_tunnel_filter_result *res = parsed_result;
6562 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6565 tunnel_filter_conf.outer_mac = &res->outer_mac;
6566 tunnel_filter_conf.inner_mac = &res->inner_mac;
6567 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6569 if (res->ip_value.family == AF_INET) {
6570 tunnel_filter_conf.ip_addr.ipv4_addr =
6571 res->ip_value.addr.ipv4.s_addr;
6572 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6574 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6575 &(res->ip_value.addr.ipv6),
6576 sizeof(struct in6_addr));
6577 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6580 if (!strcmp(res->filter_type, "imac-ivlan"))
6581 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6582 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6583 tunnel_filter_conf.filter_type =
6584 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6585 else if (!strcmp(res->filter_type, "imac-tenid"))
6586 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6587 else if (!strcmp(res->filter_type, "imac"))
6588 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6589 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6590 tunnel_filter_conf.filter_type =
6591 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6593 printf("The filter type is not supported");
6597 if (!strcmp(res->tunnel_type, "vxlan"))
6598 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6599 else if (!strcmp(res->tunnel_type, "nvgre"))
6600 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6602 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6606 tunnel_filter_conf.tenant_id = res->tenant_id;
6607 tunnel_filter_conf.queue_id = res->queue_num;
6608 if (!strcmp(res->what, "add"))
6609 ret = rte_eth_dev_filter_ctrl(res->port_id,
6610 RTE_ETH_FILTER_TUNNEL,
6612 &tunnel_filter_conf);
6614 ret = rte_eth_dev_filter_ctrl(res->port_id,
6615 RTE_ETH_FILTER_TUNNEL,
6616 RTE_ETH_FILTER_DELETE,
6617 &tunnel_filter_conf);
6619 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6623 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6624 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6625 cmd, "tunnel_filter");
6626 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6627 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6629 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6630 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6632 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6633 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6635 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6636 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6638 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6639 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6640 inner_vlan, UINT16);
6641 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6642 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6644 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6645 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6646 tunnel_type, "vxlan#nvgre");
6648 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6649 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6650 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6651 "imac#omac-imac-tenid");
6652 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6653 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6655 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6656 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6659 cmdline_parse_inst_t cmd_tunnel_filter = {
6660 .f = cmd_tunnel_filter_parsed,
6662 .help_str = "add/rm tunnel filter of a port: "
6663 "tunnel_filter add port_id outer_mac inner_mac ip "
6664 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6665 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6666 "imac|omac-imac-tenid) "
6667 "tenant_id queue_num",
6669 (void *)&cmd_tunnel_filter_cmd,
6670 (void *)&cmd_tunnel_filter_what,
6671 (void *)&cmd_tunnel_filter_port_id,
6672 (void *)&cmd_tunnel_filter_outer_mac,
6673 (void *)&cmd_tunnel_filter_inner_mac,
6674 (void *)&cmd_tunnel_filter_ip_value,
6675 (void *)&cmd_tunnel_filter_innner_vlan,
6676 (void *)&cmd_tunnel_filter_tunnel_type,
6677 (void *)&cmd_tunnel_filter_filter_type,
6678 (void *)&cmd_tunnel_filter_tenant_id,
6679 (void *)&cmd_tunnel_filter_queue_num,
6684 /* *** CONFIGURE TUNNEL UDP PORT *** */
6685 struct cmd_tunnel_udp_config {
6686 cmdline_fixed_string_t cmd;
6687 cmdline_fixed_string_t what;
6693 cmd_tunnel_udp_config_parsed(void *parsed_result,
6694 __attribute__((unused)) struct cmdline *cl,
6695 __attribute__((unused)) void *data)
6697 struct cmd_tunnel_udp_config *res = parsed_result;
6698 struct rte_eth_udp_tunnel tunnel_udp;
6701 tunnel_udp.udp_port = res->udp_port;
6703 if (!strcmp(res->cmd, "rx_vxlan_port"))
6704 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6706 if (!strcmp(res->what, "add"))
6707 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6709 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6712 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6715 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6716 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6717 cmd, "rx_vxlan_port");
6718 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6719 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6721 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6722 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6724 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6725 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6728 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6729 .f = cmd_tunnel_udp_config_parsed,
6731 .help_str = "add/rm an tunneling UDP port filter: "
6732 "rx_vxlan_port add udp_port port_id",
6734 (void *)&cmd_tunnel_udp_config_cmd,
6735 (void *)&cmd_tunnel_udp_config_what,
6736 (void *)&cmd_tunnel_udp_config_udp_port,
6737 (void *)&cmd_tunnel_udp_config_port_id,
6742 /* *** GLOBAL CONFIG *** */
6743 struct cmd_global_config_result {
6744 cmdline_fixed_string_t cmd;
6746 cmdline_fixed_string_t cfg_type;
6751 cmd_global_config_parsed(void *parsed_result,
6752 __attribute__((unused)) struct cmdline *cl,
6753 __attribute__((unused)) void *data)
6755 struct cmd_global_config_result *res = parsed_result;
6756 struct rte_eth_global_cfg conf;
6759 memset(&conf, 0, sizeof(conf));
6760 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6761 conf.cfg.gre_key_len = res->len;
6762 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6763 RTE_ETH_FILTER_SET, &conf);
6765 printf("Global config error\n");
6768 cmdline_parse_token_string_t cmd_global_config_cmd =
6769 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6771 cmdline_parse_token_num_t cmd_global_config_port_id =
6772 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6773 cmdline_parse_token_string_t cmd_global_config_type =
6774 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6775 cfg_type, "gre-key-len");
6776 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6777 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6780 cmdline_parse_inst_t cmd_global_config = {
6781 .f = cmd_global_config_parsed,
6782 .data = (void *)NULL,
6783 .help_str = "global_config <port_id> gre-key-len <number>",
6785 (void *)&cmd_global_config_cmd,
6786 (void *)&cmd_global_config_port_id,
6787 (void *)&cmd_global_config_type,
6788 (void *)&cmd_global_config_gre_key_len,
6793 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6794 struct cmd_set_mirror_mask_result {
6795 cmdline_fixed_string_t set;
6796 cmdline_fixed_string_t port;
6798 cmdline_fixed_string_t mirror;
6800 cmdline_fixed_string_t what;
6801 cmdline_fixed_string_t value;
6802 cmdline_fixed_string_t dstpool;
6804 cmdline_fixed_string_t on;
6807 cmdline_parse_token_string_t cmd_mirror_mask_set =
6808 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6810 cmdline_parse_token_string_t cmd_mirror_mask_port =
6811 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6813 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6814 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6816 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6817 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6818 mirror, "mirror-rule");
6819 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6820 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6822 cmdline_parse_token_string_t cmd_mirror_mask_what =
6823 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6824 what, "pool-mirror-up#pool-mirror-down"
6826 cmdline_parse_token_string_t cmd_mirror_mask_value =
6827 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6829 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6830 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6831 dstpool, "dst-pool");
6832 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6833 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6835 cmdline_parse_token_string_t cmd_mirror_mask_on =
6836 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6840 cmd_set_mirror_mask_parsed(void *parsed_result,
6841 __attribute__((unused)) struct cmdline *cl,
6842 __attribute__((unused)) void *data)
6845 struct cmd_set_mirror_mask_result *res = parsed_result;
6846 struct rte_eth_mirror_conf mr_conf;
6848 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6850 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6852 mr_conf.dst_pool = res->dstpool_id;
6854 if (!strcmp(res->what, "pool-mirror-up")) {
6855 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6856 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6857 } else if (!strcmp(res->what, "pool-mirror-down")) {
6858 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6859 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6860 } else if (!strcmp(res->what, "vlan-mirror")) {
6861 mr_conf.rule_type = ETH_MIRROR_VLAN;
6862 nb_item = parse_item_list(res->value, "vlan",
6863 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6867 for (i = 0; i < nb_item; i++) {
6868 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6869 printf("Invalid vlan_id: must be < 4096\n");
6873 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6874 mr_conf.vlan.vlan_mask |= 1ULL << i;
6878 if (!strcmp(res->on, "on"))
6879 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6882 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6885 printf("mirror rule add error: (%s)\n", strerror(-ret));
6888 cmdline_parse_inst_t cmd_set_mirror_mask = {
6889 .f = cmd_set_mirror_mask_parsed,
6891 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6892 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6894 (void *)&cmd_mirror_mask_set,
6895 (void *)&cmd_mirror_mask_port,
6896 (void *)&cmd_mirror_mask_portid,
6897 (void *)&cmd_mirror_mask_mirror,
6898 (void *)&cmd_mirror_mask_ruleid,
6899 (void *)&cmd_mirror_mask_what,
6900 (void *)&cmd_mirror_mask_value,
6901 (void *)&cmd_mirror_mask_dstpool,
6902 (void *)&cmd_mirror_mask_poolid,
6903 (void *)&cmd_mirror_mask_on,
6908 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6909 struct cmd_set_mirror_link_result {
6910 cmdline_fixed_string_t set;
6911 cmdline_fixed_string_t port;
6913 cmdline_fixed_string_t mirror;
6915 cmdline_fixed_string_t what;
6916 cmdline_fixed_string_t dstpool;
6918 cmdline_fixed_string_t on;
6921 cmdline_parse_token_string_t cmd_mirror_link_set =
6922 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6924 cmdline_parse_token_string_t cmd_mirror_link_port =
6925 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6927 cmdline_parse_token_num_t cmd_mirror_link_portid =
6928 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6930 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6931 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6932 mirror, "mirror-rule");
6933 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6934 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6936 cmdline_parse_token_string_t cmd_mirror_link_what =
6937 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6938 what, "uplink-mirror#downlink-mirror");
6939 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6940 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6941 dstpool, "dst-pool");
6942 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6943 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6945 cmdline_parse_token_string_t cmd_mirror_link_on =
6946 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6950 cmd_set_mirror_link_parsed(void *parsed_result,
6951 __attribute__((unused)) struct cmdline *cl,
6952 __attribute__((unused)) void *data)
6955 struct cmd_set_mirror_link_result *res = parsed_result;
6956 struct rte_eth_mirror_conf mr_conf;
6958 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6959 if (!strcmp(res->what, "uplink-mirror"))
6960 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
6962 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
6964 mr_conf.dst_pool = res->dstpool_id;
6966 if (!strcmp(res->on, "on"))
6967 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6970 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6973 /* check the return value and print it if is < 0 */
6975 printf("mirror rule add error: (%s)\n", strerror(-ret));
6979 cmdline_parse_inst_t cmd_set_mirror_link = {
6980 .f = cmd_set_mirror_link_parsed,
6982 .help_str = "set port X mirror-rule Y uplink-mirror|"
6983 "downlink-mirror dst-pool Z on|off",
6985 (void *)&cmd_mirror_link_set,
6986 (void *)&cmd_mirror_link_port,
6987 (void *)&cmd_mirror_link_portid,
6988 (void *)&cmd_mirror_link_mirror,
6989 (void *)&cmd_mirror_link_ruleid,
6990 (void *)&cmd_mirror_link_what,
6991 (void *)&cmd_mirror_link_dstpool,
6992 (void *)&cmd_mirror_link_poolid,
6993 (void *)&cmd_mirror_link_on,
6998 /* *** RESET VM MIRROR RULE *** */
6999 struct cmd_rm_mirror_rule_result {
7000 cmdline_fixed_string_t reset;
7001 cmdline_fixed_string_t port;
7003 cmdline_fixed_string_t mirror;
7007 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7008 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7010 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7011 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7013 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7014 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7016 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7017 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7018 mirror, "mirror-rule");
7019 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7020 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7024 cmd_reset_mirror_rule_parsed(void *parsed_result,
7025 __attribute__((unused)) struct cmdline *cl,
7026 __attribute__((unused)) void *data)
7029 struct cmd_set_mirror_link_result *res = parsed_result;
7031 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7033 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7036 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7037 .f = cmd_reset_mirror_rule_parsed,
7039 .help_str = "reset port X mirror-rule Y",
7041 (void *)&cmd_rm_mirror_rule_reset,
7042 (void *)&cmd_rm_mirror_rule_port,
7043 (void *)&cmd_rm_mirror_rule_portid,
7044 (void *)&cmd_rm_mirror_rule_mirror,
7045 (void *)&cmd_rm_mirror_rule_ruleid,
7050 /* ******************************************************************************** */
7052 struct cmd_dump_result {
7053 cmdline_fixed_string_t dump;
7057 dump_struct_sizes(void)
7059 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7060 DUMP_SIZE(struct rte_mbuf);
7061 DUMP_SIZE(struct rte_mempool);
7062 DUMP_SIZE(struct rte_ring);
7066 static void cmd_dump_parsed(void *parsed_result,
7067 __attribute__((unused)) struct cmdline *cl,
7068 __attribute__((unused)) void *data)
7070 struct cmd_dump_result *res = parsed_result;
7072 if (!strcmp(res->dump, "dump_physmem"))
7073 rte_dump_physmem_layout(stdout);
7074 else if (!strcmp(res->dump, "dump_memzone"))
7075 rte_memzone_dump(stdout);
7076 else if (!strcmp(res->dump, "dump_log_history"))
7077 rte_log_dump_history(stdout);
7078 else if (!strcmp(res->dump, "dump_struct_sizes"))
7079 dump_struct_sizes();
7080 else if (!strcmp(res->dump, "dump_ring"))
7081 rte_ring_list_dump(stdout);
7082 else if (!strcmp(res->dump, "dump_mempool"))
7083 rte_mempool_list_dump(stdout);
7084 else if (!strcmp(res->dump, "dump_devargs"))
7085 rte_eal_devargs_dump(stdout);
7088 cmdline_parse_token_string_t cmd_dump_dump =
7089 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7093 "dump_struct_sizes#"
7098 cmdline_parse_inst_t cmd_dump = {
7099 .f = cmd_dump_parsed, /* function to call */
7100 .data = NULL, /* 2nd arg of func */
7101 .help_str = "dump status",
7102 .tokens = { /* token list, NULL terminated */
7103 (void *)&cmd_dump_dump,
7108 /* ******************************************************************************** */
7110 struct cmd_dump_one_result {
7111 cmdline_fixed_string_t dump;
7112 cmdline_fixed_string_t name;
7115 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7116 __attribute__((unused)) void *data)
7118 struct cmd_dump_one_result *res = parsed_result;
7120 if (!strcmp(res->dump, "dump_ring")) {
7122 r = rte_ring_lookup(res->name);
7124 cmdline_printf(cl, "Cannot find ring\n");
7127 rte_ring_dump(stdout, r);
7128 } else if (!strcmp(res->dump, "dump_mempool")) {
7129 struct rte_mempool *mp;
7130 mp = rte_mempool_lookup(res->name);
7132 cmdline_printf(cl, "Cannot find mempool\n");
7135 rte_mempool_dump(stdout, mp);
7139 cmdline_parse_token_string_t cmd_dump_one_dump =
7140 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7141 "dump_ring#dump_mempool");
7143 cmdline_parse_token_string_t cmd_dump_one_name =
7144 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7146 cmdline_parse_inst_t cmd_dump_one = {
7147 .f = cmd_dump_one_parsed, /* function to call */
7148 .data = NULL, /* 2nd arg of func */
7149 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7150 .tokens = { /* token list, NULL terminated */
7151 (void *)&cmd_dump_one_dump,
7152 (void *)&cmd_dump_one_name,
7157 /* *** Add/Del syn filter *** */
7158 struct cmd_syn_filter_result {
7159 cmdline_fixed_string_t filter;
7161 cmdline_fixed_string_t ops;
7162 cmdline_fixed_string_t priority;
7163 cmdline_fixed_string_t high;
7164 cmdline_fixed_string_t queue;
7169 cmd_syn_filter_parsed(void *parsed_result,
7170 __attribute__((unused)) struct cmdline *cl,
7171 __attribute__((unused)) void *data)
7173 struct cmd_syn_filter_result *res = parsed_result;
7174 struct rte_eth_syn_filter syn_filter;
7177 ret = rte_eth_dev_filter_supported(res->port_id,
7178 RTE_ETH_FILTER_SYN);
7180 printf("syn filter is not supported on port %u.\n",
7185 memset(&syn_filter, 0, sizeof(syn_filter));
7187 if (!strcmp(res->ops, "add")) {
7188 if (!strcmp(res->high, "high"))
7189 syn_filter.hig_pri = 1;
7191 syn_filter.hig_pri = 0;
7193 syn_filter.queue = res->queue_id;
7194 ret = rte_eth_dev_filter_ctrl(res->port_id,
7199 ret = rte_eth_dev_filter_ctrl(res->port_id,
7201 RTE_ETH_FILTER_DELETE,
7205 printf("syn filter programming error: (%s)\n",
7209 cmdline_parse_token_string_t cmd_syn_filter_filter =
7210 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7211 filter, "syn_filter");
7212 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7213 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7215 cmdline_parse_token_string_t cmd_syn_filter_ops =
7216 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7218 cmdline_parse_token_string_t cmd_syn_filter_priority =
7219 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7220 priority, "priority");
7221 cmdline_parse_token_string_t cmd_syn_filter_high =
7222 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7224 cmdline_parse_token_string_t cmd_syn_filter_queue =
7225 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7227 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7228 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7231 cmdline_parse_inst_t cmd_syn_filter = {
7232 .f = cmd_syn_filter_parsed,
7234 .help_str = "add/delete syn filter",
7236 (void *)&cmd_syn_filter_filter,
7237 (void *)&cmd_syn_filter_port_id,
7238 (void *)&cmd_syn_filter_ops,
7239 (void *)&cmd_syn_filter_priority,
7240 (void *)&cmd_syn_filter_high,
7241 (void *)&cmd_syn_filter_queue,
7242 (void *)&cmd_syn_filter_queue_id,
7247 /* *** ADD/REMOVE A 2tuple FILTER *** */
7248 struct cmd_2tuple_filter_result {
7249 cmdline_fixed_string_t filter;
7251 cmdline_fixed_string_t ops;
7252 cmdline_fixed_string_t dst_port;
7253 uint16_t dst_port_value;
7254 cmdline_fixed_string_t protocol;
7255 uint8_t protocol_value;
7256 cmdline_fixed_string_t mask;
7258 cmdline_fixed_string_t tcp_flags;
7259 uint8_t tcp_flags_value;
7260 cmdline_fixed_string_t priority;
7261 uint8_t priority_value;
7262 cmdline_fixed_string_t queue;
7267 cmd_2tuple_filter_parsed(void *parsed_result,
7268 __attribute__((unused)) struct cmdline *cl,
7269 __attribute__((unused)) void *data)
7271 struct rte_eth_ntuple_filter filter;
7272 struct cmd_2tuple_filter_result *res = parsed_result;
7275 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7277 printf("ntuple filter is not supported on port %u.\n",
7282 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7284 filter.flags = RTE_2TUPLE_FLAGS;
7285 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7286 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7287 filter.proto = res->protocol_value;
7288 filter.priority = res->priority_value;
7289 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7290 printf("nonzero tcp_flags is only meaningful"
7291 " when protocol is TCP.\n");
7294 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7295 printf("invalid TCP flags.\n");
7299 if (res->tcp_flags_value != 0) {
7300 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7301 filter.tcp_flags = res->tcp_flags_value;
7304 /* need convert to big endian. */
7305 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7306 filter.queue = res->queue_id;
7308 if (!strcmp(res->ops, "add"))
7309 ret = rte_eth_dev_filter_ctrl(res->port_id,
7310 RTE_ETH_FILTER_NTUPLE,
7314 ret = rte_eth_dev_filter_ctrl(res->port_id,
7315 RTE_ETH_FILTER_NTUPLE,
7316 RTE_ETH_FILTER_DELETE,
7319 printf("2tuple filter programming error: (%s)\n",
7324 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7325 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7326 filter, "2tuple_filter");
7327 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7328 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7330 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7331 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7333 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7334 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7335 dst_port, "dst_port");
7336 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7337 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7338 dst_port_value, UINT16);
7339 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7340 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7341 protocol, "protocol");
7342 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7343 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7344 protocol_value, UINT8);
7345 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7346 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7348 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7349 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7351 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7352 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7353 tcp_flags, "tcp_flags");
7354 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7355 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7356 tcp_flags_value, UINT8);
7357 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7358 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7359 priority, "priority");
7360 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7361 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7362 priority_value, UINT8);
7363 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7364 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7366 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7367 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7370 cmdline_parse_inst_t cmd_2tuple_filter = {
7371 .f = cmd_2tuple_filter_parsed,
7373 .help_str = "add a 2tuple filter",
7375 (void *)&cmd_2tuple_filter_filter,
7376 (void *)&cmd_2tuple_filter_port_id,
7377 (void *)&cmd_2tuple_filter_ops,
7378 (void *)&cmd_2tuple_filter_dst_port,
7379 (void *)&cmd_2tuple_filter_dst_port_value,
7380 (void *)&cmd_2tuple_filter_protocol,
7381 (void *)&cmd_2tuple_filter_protocol_value,
7382 (void *)&cmd_2tuple_filter_mask,
7383 (void *)&cmd_2tuple_filter_mask_value,
7384 (void *)&cmd_2tuple_filter_tcp_flags,
7385 (void *)&cmd_2tuple_filter_tcp_flags_value,
7386 (void *)&cmd_2tuple_filter_priority,
7387 (void *)&cmd_2tuple_filter_priority_value,
7388 (void *)&cmd_2tuple_filter_queue,
7389 (void *)&cmd_2tuple_filter_queue_id,
7394 /* *** ADD/REMOVE A 5tuple FILTER *** */
7395 struct cmd_5tuple_filter_result {
7396 cmdline_fixed_string_t filter;
7398 cmdline_fixed_string_t ops;
7399 cmdline_fixed_string_t dst_ip;
7400 cmdline_ipaddr_t dst_ip_value;
7401 cmdline_fixed_string_t src_ip;
7402 cmdline_ipaddr_t src_ip_value;
7403 cmdline_fixed_string_t dst_port;
7404 uint16_t dst_port_value;
7405 cmdline_fixed_string_t src_port;
7406 uint16_t src_port_value;
7407 cmdline_fixed_string_t protocol;
7408 uint8_t protocol_value;
7409 cmdline_fixed_string_t mask;
7411 cmdline_fixed_string_t tcp_flags;
7412 uint8_t tcp_flags_value;
7413 cmdline_fixed_string_t priority;
7414 uint8_t priority_value;
7415 cmdline_fixed_string_t queue;
7420 cmd_5tuple_filter_parsed(void *parsed_result,
7421 __attribute__((unused)) struct cmdline *cl,
7422 __attribute__((unused)) void *data)
7424 struct rte_eth_ntuple_filter filter;
7425 struct cmd_5tuple_filter_result *res = parsed_result;
7428 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7430 printf("ntuple filter is not supported on port %u.\n",
7435 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7437 filter.flags = RTE_5TUPLE_FLAGS;
7438 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7439 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7440 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7441 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7442 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7443 filter.proto = res->protocol_value;
7444 filter.priority = res->priority_value;
7445 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7446 printf("nonzero tcp_flags is only meaningful"
7447 " when protocol is TCP.\n");
7450 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7451 printf("invalid TCP flags.\n");
7455 if (res->tcp_flags_value != 0) {
7456 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7457 filter.tcp_flags = res->tcp_flags_value;
7460 if (res->dst_ip_value.family == AF_INET)
7461 /* no need to convert, already big endian. */
7462 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7464 if (filter.dst_ip_mask == 0) {
7465 printf("can not support ipv6 involved compare.\n");
7471 if (res->src_ip_value.family == AF_INET)
7472 /* no need to convert, already big endian. */
7473 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7475 if (filter.src_ip_mask == 0) {
7476 printf("can not support ipv6 involved compare.\n");
7481 /* need convert to big endian. */
7482 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7483 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7484 filter.queue = res->queue_id;
7486 if (!strcmp(res->ops, "add"))
7487 ret = rte_eth_dev_filter_ctrl(res->port_id,
7488 RTE_ETH_FILTER_NTUPLE,
7492 ret = rte_eth_dev_filter_ctrl(res->port_id,
7493 RTE_ETH_FILTER_NTUPLE,
7494 RTE_ETH_FILTER_DELETE,
7497 printf("5tuple filter programming error: (%s)\n",
7501 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7502 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7503 filter, "5tuple_filter");
7504 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7505 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7507 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7508 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7510 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7511 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7513 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7514 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7516 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7517 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7519 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7520 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7522 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7523 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7524 dst_port, "dst_port");
7525 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7526 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7527 dst_port_value, UINT16);
7528 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7529 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7530 src_port, "src_port");
7531 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7532 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7533 src_port_value, UINT16);
7534 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7535 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7536 protocol, "protocol");
7537 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7538 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7539 protocol_value, UINT8);
7540 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7541 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7543 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7544 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7546 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7547 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7548 tcp_flags, "tcp_flags");
7549 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7550 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7551 tcp_flags_value, UINT8);
7552 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7553 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7554 priority, "priority");
7555 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7556 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7557 priority_value, UINT8);
7558 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7559 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7561 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7562 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7565 cmdline_parse_inst_t cmd_5tuple_filter = {
7566 .f = cmd_5tuple_filter_parsed,
7568 .help_str = "add/del a 5tuple filter",
7570 (void *)&cmd_5tuple_filter_filter,
7571 (void *)&cmd_5tuple_filter_port_id,
7572 (void *)&cmd_5tuple_filter_ops,
7573 (void *)&cmd_5tuple_filter_dst_ip,
7574 (void *)&cmd_5tuple_filter_dst_ip_value,
7575 (void *)&cmd_5tuple_filter_src_ip,
7576 (void *)&cmd_5tuple_filter_src_ip_value,
7577 (void *)&cmd_5tuple_filter_dst_port,
7578 (void *)&cmd_5tuple_filter_dst_port_value,
7579 (void *)&cmd_5tuple_filter_src_port,
7580 (void *)&cmd_5tuple_filter_src_port_value,
7581 (void *)&cmd_5tuple_filter_protocol,
7582 (void *)&cmd_5tuple_filter_protocol_value,
7583 (void *)&cmd_5tuple_filter_mask,
7584 (void *)&cmd_5tuple_filter_mask_value,
7585 (void *)&cmd_5tuple_filter_tcp_flags,
7586 (void *)&cmd_5tuple_filter_tcp_flags_value,
7587 (void *)&cmd_5tuple_filter_priority,
7588 (void *)&cmd_5tuple_filter_priority_value,
7589 (void *)&cmd_5tuple_filter_queue,
7590 (void *)&cmd_5tuple_filter_queue_id,
7595 /* *** ADD/REMOVE A flex FILTER *** */
7596 struct cmd_flex_filter_result {
7597 cmdline_fixed_string_t filter;
7598 cmdline_fixed_string_t ops;
7600 cmdline_fixed_string_t len;
7602 cmdline_fixed_string_t bytes;
7603 cmdline_fixed_string_t bytes_value;
7604 cmdline_fixed_string_t mask;
7605 cmdline_fixed_string_t mask_value;
7606 cmdline_fixed_string_t priority;
7607 uint8_t priority_value;
7608 cmdline_fixed_string_t queue;
7612 static int xdigit2val(unsigned char c)
7617 else if (isupper(c))
7625 cmd_flex_filter_parsed(void *parsed_result,
7626 __attribute__((unused)) struct cmdline *cl,
7627 __attribute__((unused)) void *data)
7630 struct rte_eth_flex_filter filter;
7631 struct cmd_flex_filter_result *res = parsed_result;
7632 char *bytes_ptr, *mask_ptr;
7633 uint16_t len, i, j = 0;
7638 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7639 printf("the len exceed the max length 128\n");
7642 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7643 filter.len = res->len_value;
7644 filter.priority = res->priority_value;
7645 filter.queue = res->queue_id;
7646 bytes_ptr = res->bytes_value;
7647 mask_ptr = res->mask_value;
7649 /* translate bytes string to array. */
7650 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7651 (bytes_ptr[1] == 'X')))
7653 len = strnlen(bytes_ptr, res->len_value * 2);
7654 if (len == 0 || (len % 8 != 0)) {
7655 printf("please check len and bytes input\n");
7658 for (i = 0; i < len; i++) {
7660 if (isxdigit(c) == 0) {
7661 /* invalid characters. */
7662 printf("invalid input\n");
7665 val = xdigit2val(c);
7668 filter.bytes[j] = byte;
7669 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7676 /* translate mask string to uint8_t array. */
7677 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7678 (mask_ptr[1] == 'X')))
7680 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7682 printf("invalid input\n");
7687 for (i = 0; i < len; i++) {
7689 if (isxdigit(c) == 0) {
7690 /* invalid characters. */
7691 printf("invalid input\n");
7694 val = xdigit2val(c);
7697 filter.mask[j] = byte;
7698 printf("mask[%d]:%02x ", j, filter.mask[j]);
7706 if (!strcmp(res->ops, "add"))
7707 ret = rte_eth_dev_filter_ctrl(res->port_id,
7708 RTE_ETH_FILTER_FLEXIBLE,
7712 ret = rte_eth_dev_filter_ctrl(res->port_id,
7713 RTE_ETH_FILTER_FLEXIBLE,
7714 RTE_ETH_FILTER_DELETE,
7718 printf("flex filter setting error: (%s)\n", strerror(-ret));
7721 cmdline_parse_token_string_t cmd_flex_filter_filter =
7722 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7723 filter, "flex_filter");
7724 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7725 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7727 cmdline_parse_token_string_t cmd_flex_filter_ops =
7728 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7730 cmdline_parse_token_string_t cmd_flex_filter_len =
7731 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7733 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7734 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7736 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7737 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7739 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7740 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7742 cmdline_parse_token_string_t cmd_flex_filter_mask =
7743 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7745 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7746 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7748 cmdline_parse_token_string_t cmd_flex_filter_priority =
7749 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7750 priority, "priority");
7751 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7752 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7753 priority_value, UINT8);
7754 cmdline_parse_token_string_t cmd_flex_filter_queue =
7755 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7757 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7758 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7760 cmdline_parse_inst_t cmd_flex_filter = {
7761 .f = cmd_flex_filter_parsed,
7763 .help_str = "add/del a flex filter",
7765 (void *)&cmd_flex_filter_filter,
7766 (void *)&cmd_flex_filter_port_id,
7767 (void *)&cmd_flex_filter_ops,
7768 (void *)&cmd_flex_filter_len,
7769 (void *)&cmd_flex_filter_len_value,
7770 (void *)&cmd_flex_filter_bytes,
7771 (void *)&cmd_flex_filter_bytes_value,
7772 (void *)&cmd_flex_filter_mask,
7773 (void *)&cmd_flex_filter_mask_value,
7774 (void *)&cmd_flex_filter_priority,
7775 (void *)&cmd_flex_filter_priority_value,
7776 (void *)&cmd_flex_filter_queue,
7777 (void *)&cmd_flex_filter_queue_id,
7782 /* *** Filters Control *** */
7784 /* *** deal with ethertype filter *** */
7785 struct cmd_ethertype_filter_result {
7786 cmdline_fixed_string_t filter;
7788 cmdline_fixed_string_t ops;
7789 cmdline_fixed_string_t mac;
7790 struct ether_addr mac_addr;
7791 cmdline_fixed_string_t ethertype;
7792 uint16_t ethertype_value;
7793 cmdline_fixed_string_t drop;
7794 cmdline_fixed_string_t queue;
7798 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7799 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7800 filter, "ethertype_filter");
7801 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7802 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7804 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7805 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7807 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7808 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7809 mac, "mac_addr#mac_ignr");
7810 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7811 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7813 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7814 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7815 ethertype, "ethertype");
7816 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7817 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7818 ethertype_value, UINT16);
7819 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7820 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7822 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7823 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7825 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7826 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7830 cmd_ethertype_filter_parsed(void *parsed_result,
7831 __attribute__((unused)) struct cmdline *cl,
7832 __attribute__((unused)) void *data)
7834 struct cmd_ethertype_filter_result *res = parsed_result;
7835 struct rte_eth_ethertype_filter filter;
7838 ret = rte_eth_dev_filter_supported(res->port_id,
7839 RTE_ETH_FILTER_ETHERTYPE);
7841 printf("ethertype filter is not supported on port %u.\n",
7846 memset(&filter, 0, sizeof(filter));
7847 if (!strcmp(res->mac, "mac_addr")) {
7848 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7849 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7850 sizeof(struct ether_addr));
7852 if (!strcmp(res->drop, "drop"))
7853 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7854 filter.ether_type = res->ethertype_value;
7855 filter.queue = res->queue_id;
7857 if (!strcmp(res->ops, "add"))
7858 ret = rte_eth_dev_filter_ctrl(res->port_id,
7859 RTE_ETH_FILTER_ETHERTYPE,
7863 ret = rte_eth_dev_filter_ctrl(res->port_id,
7864 RTE_ETH_FILTER_ETHERTYPE,
7865 RTE_ETH_FILTER_DELETE,
7868 printf("ethertype filter programming error: (%s)\n",
7872 cmdline_parse_inst_t cmd_ethertype_filter = {
7873 .f = cmd_ethertype_filter_parsed,
7875 .help_str = "add or delete an ethertype filter entry",
7877 (void *)&cmd_ethertype_filter_filter,
7878 (void *)&cmd_ethertype_filter_port_id,
7879 (void *)&cmd_ethertype_filter_ops,
7880 (void *)&cmd_ethertype_filter_mac,
7881 (void *)&cmd_ethertype_filter_mac_addr,
7882 (void *)&cmd_ethertype_filter_ethertype,
7883 (void *)&cmd_ethertype_filter_ethertype_value,
7884 (void *)&cmd_ethertype_filter_drop,
7885 (void *)&cmd_ethertype_filter_queue,
7886 (void *)&cmd_ethertype_filter_queue_id,
7891 /* *** deal with flow director filter *** */
7892 struct cmd_flow_director_result {
7893 cmdline_fixed_string_t flow_director_filter;
7895 cmdline_fixed_string_t mode;
7896 cmdline_fixed_string_t mode_value;
7897 cmdline_fixed_string_t ops;
7898 cmdline_fixed_string_t flow;
7899 cmdline_fixed_string_t flow_type;
7900 cmdline_fixed_string_t ether;
7901 uint16_t ether_type;
7902 cmdline_fixed_string_t src;
7903 cmdline_ipaddr_t ip_src;
7905 cmdline_fixed_string_t dst;
7906 cmdline_ipaddr_t ip_dst;
7908 cmdline_fixed_string_t verify_tag;
7909 uint32_t verify_tag_value;
7910 cmdline_fixed_string_t vlan;
7911 uint16_t vlan_value;
7912 cmdline_fixed_string_t flexbytes;
7913 cmdline_fixed_string_t flexbytes_value;
7914 cmdline_fixed_string_t drop;
7915 cmdline_fixed_string_t queue;
7917 cmdline_fixed_string_t fd_id;
7918 uint32_t fd_id_value;
7919 cmdline_fixed_string_t mac;
7920 struct ether_addr mac_addr;
7921 cmdline_fixed_string_t tunnel;
7922 cmdline_fixed_string_t tunnel_type;
7923 cmdline_fixed_string_t tunnel_id;
7924 uint32_t tunnel_id_value;
7928 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7931 const char *p, *p0 = q_arg;
7933 unsigned long int_fld;
7934 char *str_fld[max_num];
7939 p = strchr(p0, '(');
7943 p0 = strchr(p, ')');
7948 if (size >= sizeof(s))
7951 snprintf(s, sizeof(s), "%.*s", size, p);
7952 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7953 if (ret < 0 || ret > max_num)
7955 for (i = 0; i < ret; i++) {
7957 int_fld = strtoul(str_fld[i], &end, 0);
7958 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7960 flexbytes[i] = (uint8_t)int_fld;
7966 str2flowtype(char *string)
7969 static const struct {
7972 } flowtype_str[] = {
7973 {"raw", RTE_ETH_FLOW_RAW},
7974 {"ipv4", RTE_ETH_FLOW_IPV4},
7975 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
7976 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
7977 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
7978 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
7979 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
7980 {"ipv6", RTE_ETH_FLOW_IPV6},
7981 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
7982 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
7983 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
7984 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
7985 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
7986 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
7989 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7990 if (!strcmp(flowtype_str[i].str, string))
7991 return flowtype_str[i].type;
7993 return RTE_ETH_FLOW_UNKNOWN;
7997 str2fdir_tunneltype(char *string)
8001 static const struct {
8004 } tunneltype_str[] = {
8005 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8006 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8009 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8010 if (!strcmp(tunneltype_str[i].str, string))
8011 return tunneltype_str[i].type;
8013 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8016 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8018 if ((ip_addr).family == AF_INET) \
8019 (ip) = (ip_addr).addr.ipv4.s_addr; \
8021 printf("invalid parameter.\n"); \
8026 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8028 if ((ip_addr).family == AF_INET6) \
8029 (void)rte_memcpy(&(ip), \
8030 &((ip_addr).addr.ipv6), \
8031 sizeof(struct in6_addr)); \
8033 printf("invalid parameter.\n"); \
8039 cmd_flow_director_filter_parsed(void *parsed_result,
8040 __attribute__((unused)) struct cmdline *cl,
8041 __attribute__((unused)) void *data)
8043 struct cmd_flow_director_result *res = parsed_result;
8044 struct rte_eth_fdir_filter entry;
8045 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8048 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8050 printf("flow director is not supported on port %u.\n",
8054 memset(flexbytes, 0, sizeof(flexbytes));
8055 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8057 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8058 if (strcmp(res->mode_value, "MAC-VLAN")) {
8059 printf("Please set mode to MAC-VLAN.\n");
8062 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8063 if (strcmp(res->mode_value, "Tunnel")) {
8064 printf("Please set mode to Tunnel.\n");
8068 if (strcmp(res->mode_value, "IP")) {
8069 printf("Please set mode to IP.\n");
8072 entry.input.flow_type = str2flowtype(res->flow_type);
8075 ret = parse_flexbytes(res->flexbytes_value,
8077 RTE_ETH_FDIR_MAX_FLEXLEN);
8079 printf("error: Cannot parse flexbytes input.\n");
8083 switch (entry.input.flow_type) {
8084 case RTE_ETH_FLOW_FRAG_IPV4:
8085 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8086 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8087 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8088 IPV4_ADDR_TO_UINT(res->ip_dst,
8089 entry.input.flow.ip4_flow.dst_ip);
8090 IPV4_ADDR_TO_UINT(res->ip_src,
8091 entry.input.flow.ip4_flow.src_ip);
8092 /* need convert to big endian. */
8093 entry.input.flow.udp4_flow.dst_port =
8094 rte_cpu_to_be_16(res->port_dst);
8095 entry.input.flow.udp4_flow.src_port =
8096 rte_cpu_to_be_16(res->port_src);
8098 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8099 IPV4_ADDR_TO_UINT(res->ip_dst,
8100 entry.input.flow.sctp4_flow.ip.dst_ip);
8101 IPV4_ADDR_TO_UINT(res->ip_src,
8102 entry.input.flow.sctp4_flow.ip.src_ip);
8103 /* need convert to big endian. */
8104 entry.input.flow.sctp4_flow.dst_port =
8105 rte_cpu_to_be_16(res->port_dst);
8106 entry.input.flow.sctp4_flow.src_port =
8107 rte_cpu_to_be_16(res->port_src);
8108 entry.input.flow.sctp4_flow.verify_tag =
8109 rte_cpu_to_be_32(res->verify_tag_value);
8111 case RTE_ETH_FLOW_FRAG_IPV6:
8112 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8113 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8114 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8115 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8116 entry.input.flow.ipv6_flow.dst_ip);
8117 IPV6_ADDR_TO_ARRAY(res->ip_src,
8118 entry.input.flow.ipv6_flow.src_ip);
8119 /* need convert to big endian. */
8120 entry.input.flow.udp6_flow.dst_port =
8121 rte_cpu_to_be_16(res->port_dst);
8122 entry.input.flow.udp6_flow.src_port =
8123 rte_cpu_to_be_16(res->port_src);
8125 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8126 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8127 entry.input.flow.sctp6_flow.ip.dst_ip);
8128 IPV6_ADDR_TO_ARRAY(res->ip_src,
8129 entry.input.flow.sctp6_flow.ip.src_ip);
8130 /* need convert to big endian. */
8131 entry.input.flow.sctp6_flow.dst_port =
8132 rte_cpu_to_be_16(res->port_dst);
8133 entry.input.flow.sctp6_flow.src_port =
8134 rte_cpu_to_be_16(res->port_src);
8135 entry.input.flow.sctp6_flow.verify_tag =
8136 rte_cpu_to_be_32(res->verify_tag_value);
8138 case RTE_ETH_FLOW_L2_PAYLOAD:
8139 entry.input.flow.l2_flow.ether_type =
8140 rte_cpu_to_be_16(res->ether_type);
8146 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8147 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8149 sizeof(struct ether_addr));
8151 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8152 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8154 sizeof(struct ether_addr));
8155 entry.input.flow.tunnel_flow.tunnel_type =
8156 str2fdir_tunneltype(res->tunnel_type);
8157 entry.input.flow.tunnel_flow.tunnel_id =
8158 rte_cpu_to_be_32(res->tunnel_id_value);
8161 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8163 RTE_ETH_FDIR_MAX_FLEXLEN);
8165 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8167 entry.action.flex_off = 0; /*use 0 by default */
8168 if (!strcmp(res->drop, "drop"))
8169 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8171 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8172 /* set to report FD ID by default */
8173 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8174 entry.action.rx_queue = res->queue_id;
8175 entry.soft_id = res->fd_id_value;
8176 if (!strcmp(res->ops, "add"))
8177 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8178 RTE_ETH_FILTER_ADD, &entry);
8179 else if (!strcmp(res->ops, "del"))
8180 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8181 RTE_ETH_FILTER_DELETE, &entry);
8183 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8184 RTE_ETH_FILTER_UPDATE, &entry);
8186 printf("flow director programming error: (%s)\n",
8190 cmdline_parse_token_string_t cmd_flow_director_filter =
8191 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8192 flow_director_filter, "flow_director_filter");
8193 cmdline_parse_token_num_t cmd_flow_director_port_id =
8194 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8196 cmdline_parse_token_string_t cmd_flow_director_ops =
8197 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8198 ops, "add#del#update");
8199 cmdline_parse_token_string_t cmd_flow_director_flow =
8200 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8202 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8203 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8204 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8205 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8206 cmdline_parse_token_string_t cmd_flow_director_ether =
8207 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8209 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8210 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8211 ether_type, UINT16);
8212 cmdline_parse_token_string_t cmd_flow_director_src =
8213 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8215 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8216 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8218 cmdline_parse_token_num_t cmd_flow_director_port_src =
8219 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8221 cmdline_parse_token_string_t cmd_flow_director_dst =
8222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8224 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8225 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8227 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8228 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8230 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8232 verify_tag, "verify_tag");
8233 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8234 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8235 verify_tag_value, UINT32);
8236 cmdline_parse_token_string_t cmd_flow_director_vlan =
8237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8239 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8240 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8241 vlan_value, UINT16);
8242 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8244 flexbytes, "flexbytes");
8245 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8247 flexbytes_value, NULL);
8248 cmdline_parse_token_string_t cmd_flow_director_drop =
8249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8251 cmdline_parse_token_string_t cmd_flow_director_queue =
8252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8254 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8255 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8257 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8260 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8261 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8262 fd_id_value, UINT32);
8264 cmdline_parse_token_string_t cmd_flow_director_mode =
8265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8267 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8270 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8272 mode_value, "MAC-VLAN");
8273 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8275 mode_value, "Tunnel");
8276 cmdline_parse_token_string_t cmd_flow_director_mac =
8277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8279 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8280 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8282 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8285 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8287 tunnel_type, "NVGRE#VxLAN");
8288 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8290 tunnel_id, "tunnel-id");
8291 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8293 tunnel_id_value, UINT32);
8295 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8296 .f = cmd_flow_director_filter_parsed,
8298 .help_str = "add or delete an ip flow director entry on NIC",
8300 (void *)&cmd_flow_director_filter,
8301 (void *)&cmd_flow_director_port_id,
8302 (void *)&cmd_flow_director_mode,
8303 (void *)&cmd_flow_director_mode_ip,
8304 (void *)&cmd_flow_director_ops,
8305 (void *)&cmd_flow_director_flow,
8306 (void *)&cmd_flow_director_flow_type,
8307 (void *)&cmd_flow_director_src,
8308 (void *)&cmd_flow_director_ip_src,
8309 (void *)&cmd_flow_director_dst,
8310 (void *)&cmd_flow_director_ip_dst,
8311 (void *)&cmd_flow_director_vlan,
8312 (void *)&cmd_flow_director_vlan_value,
8313 (void *)&cmd_flow_director_flexbytes,
8314 (void *)&cmd_flow_director_flexbytes_value,
8315 (void *)&cmd_flow_director_drop,
8316 (void *)&cmd_flow_director_queue,
8317 (void *)&cmd_flow_director_queue_id,
8318 (void *)&cmd_flow_director_fd_id,
8319 (void *)&cmd_flow_director_fd_id_value,
8324 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8325 .f = cmd_flow_director_filter_parsed,
8327 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8329 (void *)&cmd_flow_director_filter,
8330 (void *)&cmd_flow_director_port_id,
8331 (void *)&cmd_flow_director_mode,
8332 (void *)&cmd_flow_director_mode_ip,
8333 (void *)&cmd_flow_director_ops,
8334 (void *)&cmd_flow_director_flow,
8335 (void *)&cmd_flow_director_flow_type,
8336 (void *)&cmd_flow_director_src,
8337 (void *)&cmd_flow_director_ip_src,
8338 (void *)&cmd_flow_director_port_src,
8339 (void *)&cmd_flow_director_dst,
8340 (void *)&cmd_flow_director_ip_dst,
8341 (void *)&cmd_flow_director_port_dst,
8342 (void *)&cmd_flow_director_vlan,
8343 (void *)&cmd_flow_director_vlan_value,
8344 (void *)&cmd_flow_director_flexbytes,
8345 (void *)&cmd_flow_director_flexbytes_value,
8346 (void *)&cmd_flow_director_drop,
8347 (void *)&cmd_flow_director_queue,
8348 (void *)&cmd_flow_director_queue_id,
8349 (void *)&cmd_flow_director_fd_id,
8350 (void *)&cmd_flow_director_fd_id_value,
8355 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8356 .f = cmd_flow_director_filter_parsed,
8358 .help_str = "add or delete a sctp flow director entry on NIC",
8360 (void *)&cmd_flow_director_filter,
8361 (void *)&cmd_flow_director_port_id,
8362 (void *)&cmd_flow_director_mode,
8363 (void *)&cmd_flow_director_mode_ip,
8364 (void *)&cmd_flow_director_ops,
8365 (void *)&cmd_flow_director_flow,
8366 (void *)&cmd_flow_director_flow_type,
8367 (void *)&cmd_flow_director_src,
8368 (void *)&cmd_flow_director_ip_src,
8369 (void *)&cmd_flow_director_port_dst,
8370 (void *)&cmd_flow_director_dst,
8371 (void *)&cmd_flow_director_ip_dst,
8372 (void *)&cmd_flow_director_port_dst,
8373 (void *)&cmd_flow_director_verify_tag,
8374 (void *)&cmd_flow_director_verify_tag_value,
8375 (void *)&cmd_flow_director_vlan,
8376 (void *)&cmd_flow_director_vlan_value,
8377 (void *)&cmd_flow_director_flexbytes,
8378 (void *)&cmd_flow_director_flexbytes_value,
8379 (void *)&cmd_flow_director_drop,
8380 (void *)&cmd_flow_director_queue,
8381 (void *)&cmd_flow_director_queue_id,
8382 (void *)&cmd_flow_director_fd_id,
8383 (void *)&cmd_flow_director_fd_id_value,
8388 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8389 .f = cmd_flow_director_filter_parsed,
8391 .help_str = "add or delete a L2 flow director entry on NIC",
8393 (void *)&cmd_flow_director_filter,
8394 (void *)&cmd_flow_director_port_id,
8395 (void *)&cmd_flow_director_mode,
8396 (void *)&cmd_flow_director_mode_ip,
8397 (void *)&cmd_flow_director_ops,
8398 (void *)&cmd_flow_director_flow,
8399 (void *)&cmd_flow_director_flow_type,
8400 (void *)&cmd_flow_director_ether,
8401 (void *)&cmd_flow_director_ether_type,
8402 (void *)&cmd_flow_director_flexbytes,
8403 (void *)&cmd_flow_director_flexbytes_value,
8404 (void *)&cmd_flow_director_drop,
8405 (void *)&cmd_flow_director_queue,
8406 (void *)&cmd_flow_director_queue_id,
8407 (void *)&cmd_flow_director_fd_id,
8408 (void *)&cmd_flow_director_fd_id_value,
8413 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8414 .f = cmd_flow_director_filter_parsed,
8416 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8418 (void *)&cmd_flow_director_filter,
8419 (void *)&cmd_flow_director_port_id,
8420 (void *)&cmd_flow_director_mode,
8421 (void *)&cmd_flow_director_mode_mac_vlan,
8422 (void *)&cmd_flow_director_ops,
8423 (void *)&cmd_flow_director_mac,
8424 (void *)&cmd_flow_director_mac_addr,
8425 (void *)&cmd_flow_director_vlan,
8426 (void *)&cmd_flow_director_vlan_value,
8427 (void *)&cmd_flow_director_flexbytes,
8428 (void *)&cmd_flow_director_flexbytes_value,
8429 (void *)&cmd_flow_director_drop,
8430 (void *)&cmd_flow_director_queue,
8431 (void *)&cmd_flow_director_queue_id,
8432 (void *)&cmd_flow_director_fd_id,
8433 (void *)&cmd_flow_director_fd_id_value,
8438 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8439 .f = cmd_flow_director_filter_parsed,
8441 .help_str = "add or delete a tunnel flow director entry on NIC",
8443 (void *)&cmd_flow_director_filter,
8444 (void *)&cmd_flow_director_port_id,
8445 (void *)&cmd_flow_director_mode,
8446 (void *)&cmd_flow_director_mode_tunnel,
8447 (void *)&cmd_flow_director_ops,
8448 (void *)&cmd_flow_director_mac,
8449 (void *)&cmd_flow_director_mac_addr,
8450 (void *)&cmd_flow_director_vlan,
8451 (void *)&cmd_flow_director_vlan_value,
8452 (void *)&cmd_flow_director_tunnel,
8453 (void *)&cmd_flow_director_tunnel_type,
8454 (void *)&cmd_flow_director_tunnel_id,
8455 (void *)&cmd_flow_director_tunnel_id_value,
8456 (void *)&cmd_flow_director_flexbytes,
8457 (void *)&cmd_flow_director_flexbytes_value,
8458 (void *)&cmd_flow_director_drop,
8459 (void *)&cmd_flow_director_queue,
8460 (void *)&cmd_flow_director_queue_id,
8461 (void *)&cmd_flow_director_fd_id,
8462 (void *)&cmd_flow_director_fd_id_value,
8467 struct cmd_flush_flow_director_result {
8468 cmdline_fixed_string_t flush_flow_director;
8472 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8473 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8474 flush_flow_director, "flush_flow_director");
8475 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8476 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8480 cmd_flush_flow_director_parsed(void *parsed_result,
8481 __attribute__((unused)) struct cmdline *cl,
8482 __attribute__((unused)) void *data)
8484 struct cmd_flow_director_result *res = parsed_result;
8487 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8489 printf("flow director is not supported on port %u.\n",
8494 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8495 RTE_ETH_FILTER_FLUSH, NULL);
8497 printf("flow director table flushing error: (%s)\n",
8501 cmdline_parse_inst_t cmd_flush_flow_director = {
8502 .f = cmd_flush_flow_director_parsed,
8504 .help_str = "flush all flow director entries of a device on NIC",
8506 (void *)&cmd_flush_flow_director_flush,
8507 (void *)&cmd_flush_flow_director_port_id,
8512 /* *** deal with flow director mask *** */
8513 struct cmd_flow_director_mask_result {
8514 cmdline_fixed_string_t flow_director_mask;
8516 cmdline_fixed_string_t mode;
8517 cmdline_fixed_string_t mode_value;
8518 cmdline_fixed_string_t vlan;
8520 cmdline_fixed_string_t src_mask;
8521 cmdline_ipaddr_t ipv4_src;
8522 cmdline_ipaddr_t ipv6_src;
8524 cmdline_fixed_string_t dst_mask;
8525 cmdline_ipaddr_t ipv4_dst;
8526 cmdline_ipaddr_t ipv6_dst;
8528 cmdline_fixed_string_t mac;
8529 uint8_t mac_addr_byte_mask;
8530 cmdline_fixed_string_t tunnel_id;
8531 uint32_t tunnel_id_mask;
8532 cmdline_fixed_string_t tunnel_type;
8533 uint8_t tunnel_type_mask;
8537 cmd_flow_director_mask_parsed(void *parsed_result,
8538 __attribute__((unused)) struct cmdline *cl,
8539 __attribute__((unused)) void *data)
8541 struct cmd_flow_director_mask_result *res = parsed_result;
8542 struct rte_eth_fdir_masks *mask;
8543 struct rte_port *port;
8545 if (res->port_id > nb_ports) {
8546 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8550 port = &ports[res->port_id];
8551 /** Check if the port is not started **/
8552 if (port->port_status != RTE_PORT_STOPPED) {
8553 printf("Please stop port %d first\n", res->port_id);
8557 mask = &port->dev_conf.fdir_conf.mask;
8559 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8560 if (strcmp(res->mode_value, "MAC-VLAN")) {
8561 printf("Please set mode to MAC-VLAN.\n");
8565 mask->vlan_tci_mask = res->vlan_mask;
8566 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8567 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8568 if (strcmp(res->mode_value, "Tunnel")) {
8569 printf("Please set mode to Tunnel.\n");
8573 mask->vlan_tci_mask = res->vlan_mask;
8574 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8575 mask->tunnel_id_mask = res->tunnel_id_mask;
8576 mask->tunnel_type_mask = res->tunnel_type_mask;
8578 if (strcmp(res->mode_value, "IP")) {
8579 printf("Please set mode to IP.\n");
8583 mask->vlan_tci_mask = res->vlan_mask;
8584 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8585 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8586 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8587 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8588 mask->src_port_mask = res->port_src;
8589 mask->dst_port_mask = res->port_dst;
8592 cmd_reconfig_device_queue(res->port_id, 1, 1);
8595 cmdline_parse_token_string_t cmd_flow_director_mask =
8596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8597 flow_director_mask, "flow_director_mask");
8598 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8599 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8601 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8604 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8605 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8607 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8609 src_mask, "src_mask");
8610 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8611 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8613 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8614 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8616 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8617 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8619 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8620 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8621 dst_mask, "dst_mask");
8622 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8623 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8625 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8626 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8628 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8629 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8632 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8633 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8635 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8636 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8638 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8639 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8640 mode_value, "MAC-VLAN");
8641 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8642 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8643 mode_value, "Tunnel");
8644 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8647 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8648 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8649 mac_addr_byte_mask, UINT8);
8650 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8652 tunnel_type, "tunnel-type");
8653 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8654 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8655 tunnel_type_mask, UINT8);
8656 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8657 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8658 tunnel_id, "tunnel-id");
8659 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8660 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8661 tunnel_id_mask, UINT32);
8663 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8664 .f = cmd_flow_director_mask_parsed,
8666 .help_str = "set IP mode flow director's mask on NIC",
8668 (void *)&cmd_flow_director_mask,
8669 (void *)&cmd_flow_director_mask_port_id,
8670 (void *)&cmd_flow_director_mask_mode,
8671 (void *)&cmd_flow_director_mask_mode_ip,
8672 (void *)&cmd_flow_director_mask_vlan,
8673 (void *)&cmd_flow_director_mask_vlan_value,
8674 (void *)&cmd_flow_director_mask_src,
8675 (void *)&cmd_flow_director_mask_ipv4_src,
8676 (void *)&cmd_flow_director_mask_ipv6_src,
8677 (void *)&cmd_flow_director_mask_port_src,
8678 (void *)&cmd_flow_director_mask_dst,
8679 (void *)&cmd_flow_director_mask_ipv4_dst,
8680 (void *)&cmd_flow_director_mask_ipv6_dst,
8681 (void *)&cmd_flow_director_mask_port_dst,
8686 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8687 .f = cmd_flow_director_mask_parsed,
8689 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8691 (void *)&cmd_flow_director_mask,
8692 (void *)&cmd_flow_director_mask_port_id,
8693 (void *)&cmd_flow_director_mask_mode,
8694 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8695 (void *)&cmd_flow_director_mask_vlan,
8696 (void *)&cmd_flow_director_mask_vlan_value,
8697 (void *)&cmd_flow_director_mask_mac,
8698 (void *)&cmd_flow_director_mask_mac_value,
8703 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8704 .f = cmd_flow_director_mask_parsed,
8706 .help_str = "set tunnel mode flow director's mask on NIC",
8708 (void *)&cmd_flow_director_mask,
8709 (void *)&cmd_flow_director_mask_port_id,
8710 (void *)&cmd_flow_director_mask_mode,
8711 (void *)&cmd_flow_director_mask_mode_tunnel,
8712 (void *)&cmd_flow_director_mask_vlan,
8713 (void *)&cmd_flow_director_mask_vlan_value,
8714 (void *)&cmd_flow_director_mask_mac,
8715 (void *)&cmd_flow_director_mask_mac_value,
8716 (void *)&cmd_flow_director_mask_tunnel_type,
8717 (void *)&cmd_flow_director_mask_tunnel_type_value,
8718 (void *)&cmd_flow_director_mask_tunnel_id,
8719 (void *)&cmd_flow_director_mask_tunnel_id_value,
8724 /* *** deal with flow director mask on flexible payload *** */
8725 struct cmd_flow_director_flex_mask_result {
8726 cmdline_fixed_string_t flow_director_flexmask;
8728 cmdline_fixed_string_t flow;
8729 cmdline_fixed_string_t flow_type;
8730 cmdline_fixed_string_t mask;
8734 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8735 __attribute__((unused)) struct cmdline *cl,
8736 __attribute__((unused)) void *data)
8738 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8739 struct rte_eth_fdir_info fdir_info;
8740 struct rte_eth_fdir_flex_mask flex_mask;
8741 struct rte_port *port;
8742 uint32_t flow_type_mask;
8746 if (res->port_id > nb_ports) {
8747 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8751 port = &ports[res->port_id];
8752 /** Check if the port is not started **/
8753 if (port->port_status != RTE_PORT_STOPPED) {
8754 printf("Please stop port %d first\n", res->port_id);
8758 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8759 ret = parse_flexbytes(res->mask,
8761 RTE_ETH_FDIR_MAX_FLEXLEN);
8763 printf("error: Cannot parse mask input.\n");
8767 memset(&fdir_info, 0, sizeof(fdir_info));
8768 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8769 RTE_ETH_FILTER_INFO, &fdir_info);
8771 printf("Cannot get FDir filter info\n");
8775 if (!strcmp(res->flow_type, "none")) {
8776 /* means don't specify the flow type */
8777 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8778 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8779 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8780 0, sizeof(struct rte_eth_fdir_flex_mask));
8781 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8782 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8784 sizeof(struct rte_eth_fdir_flex_mask));
8785 cmd_reconfig_device_queue(res->port_id, 1, 1);
8788 flow_type_mask = fdir_info.flow_types_mask[0];
8789 if (!strcmp(res->flow_type, "all")) {
8790 if (!flow_type_mask) {
8791 printf("No flow type supported\n");
8794 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8795 if (flow_type_mask & (1 << i)) {
8796 flex_mask.flow_type = i;
8797 fdir_set_flex_mask(res->port_id, &flex_mask);
8800 cmd_reconfig_device_queue(res->port_id, 1, 1);
8803 flex_mask.flow_type = str2flowtype(res->flow_type);
8804 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8805 printf("Flow type %s not supported on port %d\n",
8806 res->flow_type, res->port_id);
8809 fdir_set_flex_mask(res->port_id, &flex_mask);
8810 cmd_reconfig_device_queue(res->port_id, 1, 1);
8813 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8814 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8815 flow_director_flexmask,
8816 "flow_director_flex_mask");
8817 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8818 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8820 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8821 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8823 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8824 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8825 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8826 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8827 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8831 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8832 .f = cmd_flow_director_flex_mask_parsed,
8834 .help_str = "set flow director's flex mask on NIC",
8836 (void *)&cmd_flow_director_flexmask,
8837 (void *)&cmd_flow_director_flexmask_port_id,
8838 (void *)&cmd_flow_director_flexmask_flow,
8839 (void *)&cmd_flow_director_flexmask_flow_type,
8840 (void *)&cmd_flow_director_flexmask_mask,
8845 /* *** deal with flow director flexible payload configuration *** */
8846 struct cmd_flow_director_flexpayload_result {
8847 cmdline_fixed_string_t flow_director_flexpayload;
8849 cmdline_fixed_string_t payload_layer;
8850 cmdline_fixed_string_t payload_cfg;
8854 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8857 const char *p, *p0 = q_arg;
8859 unsigned long int_fld;
8860 char *str_fld[max_num];
8865 p = strchr(p0, '(');
8869 p0 = strchr(p, ')');
8874 if (size >= sizeof(s))
8877 snprintf(s, sizeof(s), "%.*s", size, p);
8878 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8879 if (ret < 0 || ret > max_num)
8881 for (i = 0; i < ret; i++) {
8883 int_fld = strtoul(str_fld[i], &end, 0);
8884 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8886 offsets[i] = (uint16_t)int_fld;
8892 cmd_flow_director_flxpld_parsed(void *parsed_result,
8893 __attribute__((unused)) struct cmdline *cl,
8894 __attribute__((unused)) void *data)
8896 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8897 struct rte_eth_flex_payload_cfg flex_cfg;
8898 struct rte_port *port;
8901 if (res->port_id > nb_ports) {
8902 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8906 port = &ports[res->port_id];
8907 /** Check if the port is not started **/
8908 if (port->port_status != RTE_PORT_STOPPED) {
8909 printf("Please stop port %d first\n", res->port_id);
8913 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8915 if (!strcmp(res->payload_layer, "raw"))
8916 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8917 else if (!strcmp(res->payload_layer, "l2"))
8918 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8919 else if (!strcmp(res->payload_layer, "l3"))
8920 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8921 else if (!strcmp(res->payload_layer, "l4"))
8922 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8924 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8925 RTE_ETH_FDIR_MAX_FLEXLEN);
8927 printf("error: Cannot parse flex payload input.\n");
8931 fdir_set_flex_payload(res->port_id, &flex_cfg);
8932 cmd_reconfig_device_queue(res->port_id, 1, 1);
8935 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8936 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8937 flow_director_flexpayload,
8938 "flow_director_flex_payload");
8939 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8940 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8942 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8944 payload_layer, "raw#l2#l3#l4");
8945 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8949 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8950 .f = cmd_flow_director_flxpld_parsed,
8952 .help_str = "set flow director's flex payload on NIC",
8954 (void *)&cmd_flow_director_flexpayload,
8955 (void *)&cmd_flow_director_flexpayload_port_id,
8956 (void *)&cmd_flow_director_flexpayload_payload_layer,
8957 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8962 /* *** Classification Filters Control *** */
8963 /* *** Get symmetric hash enable per port *** */
8964 struct cmd_get_sym_hash_ena_per_port_result {
8965 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8970 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8971 __rte_unused struct cmdline *cl,
8972 __rte_unused void *data)
8974 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8975 struct rte_eth_hash_filter_info info;
8978 if (rte_eth_dev_filter_supported(res->port_id,
8979 RTE_ETH_FILTER_HASH) < 0) {
8980 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8985 memset(&info, 0, sizeof(info));
8986 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8987 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8988 RTE_ETH_FILTER_GET, &info);
8991 printf("Cannot get symmetric hash enable per port "
8992 "on port %u\n", res->port_id);
8996 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8997 "enabled" : "disabled", res->port_id);
9000 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9001 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9002 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9003 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9004 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9007 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9008 .f = cmd_get_sym_hash_per_port_parsed,
9010 .help_str = "get_sym_hash_ena_per_port port_id",
9012 (void *)&cmd_get_sym_hash_ena_per_port_all,
9013 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9018 /* *** Set symmetric hash enable per port *** */
9019 struct cmd_set_sym_hash_ena_per_port_result {
9020 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9021 cmdline_fixed_string_t enable;
9026 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9027 __rte_unused struct cmdline *cl,
9028 __rte_unused void *data)
9030 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9031 struct rte_eth_hash_filter_info info;
9034 if (rte_eth_dev_filter_supported(res->port_id,
9035 RTE_ETH_FILTER_HASH) < 0) {
9036 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9041 memset(&info, 0, sizeof(info));
9042 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9043 if (!strcmp(res->enable, "enable"))
9044 info.info.enable = 1;
9045 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9046 RTE_ETH_FILTER_SET, &info);
9048 printf("Cannot set symmetric hash enable per port on "
9049 "port %u\n", res->port_id);
9052 printf("Symmetric hash has been set to %s on port %u\n",
9053 res->enable, res->port_id);
9056 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9057 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9058 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9059 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9060 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9062 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9063 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9064 enable, "enable#disable");
9066 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9067 .f = cmd_set_sym_hash_per_port_parsed,
9069 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9071 (void *)&cmd_set_sym_hash_ena_per_port_all,
9072 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9073 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9078 /* Get global config of hash function */
9079 struct cmd_get_hash_global_config_result {
9080 cmdline_fixed_string_t get_hash_global_config;
9085 flowtype_to_str(uint16_t ftype)
9092 {"ipv4", RTE_ETH_FLOW_IPV4},
9093 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9094 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9095 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9096 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9097 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9098 {"ipv6", RTE_ETH_FLOW_IPV6},
9099 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9100 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9101 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9102 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9103 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9104 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9107 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9108 if (ftype_table[i].ftype == ftype)
9109 return ftype_table[i].str;
9116 cmd_get_hash_global_config_parsed(void *parsed_result,
9117 __rte_unused struct cmdline *cl,
9118 __rte_unused void *data)
9120 struct cmd_get_hash_global_config_result *res = parsed_result;
9121 struct rte_eth_hash_filter_info info;
9122 uint32_t idx, offset;
9127 if (rte_eth_dev_filter_supported(res->port_id,
9128 RTE_ETH_FILTER_HASH) < 0) {
9129 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9134 memset(&info, 0, sizeof(info));
9135 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9136 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9137 RTE_ETH_FILTER_GET, &info);
9139 printf("Cannot get hash global configurations by port %d\n",
9144 switch (info.info.global_conf.hash_func) {
9145 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9146 printf("Hash function is Toeplitz\n");
9148 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9149 printf("Hash function is Simple XOR\n");
9152 printf("Unknown hash function\n");
9156 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9157 idx = i / UINT32_BIT;
9158 offset = i % UINT32_BIT;
9159 if (!(info.info.global_conf.valid_bit_mask[idx] &
9162 str = flowtype_to_str(i);
9165 printf("Symmetric hash is %s globally for flow type %s "
9167 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9168 (1UL << offset)) ? "enabled" : "disabled"), str,
9173 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9174 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9175 get_hash_global_config, "get_hash_global_config");
9176 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9177 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9180 cmdline_parse_inst_t cmd_get_hash_global_config = {
9181 .f = cmd_get_hash_global_config_parsed,
9183 .help_str = "get_hash_global_config port_id",
9185 (void *)&cmd_get_hash_global_config_all,
9186 (void *)&cmd_get_hash_global_config_port_id,
9191 /* Set global config of hash function */
9192 struct cmd_set_hash_global_config_result {
9193 cmdline_fixed_string_t set_hash_global_config;
9195 cmdline_fixed_string_t hash_func;
9196 cmdline_fixed_string_t flow_type;
9197 cmdline_fixed_string_t enable;
9201 cmd_set_hash_global_config_parsed(void *parsed_result,
9202 __rte_unused struct cmdline *cl,
9203 __rte_unused void *data)
9205 struct cmd_set_hash_global_config_result *res = parsed_result;
9206 struct rte_eth_hash_filter_info info;
9207 uint32_t ftype, idx, offset;
9210 if (rte_eth_dev_filter_supported(res->port_id,
9211 RTE_ETH_FILTER_HASH) < 0) {
9212 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9216 memset(&info, 0, sizeof(info));
9217 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9218 if (!strcmp(res->hash_func, "toeplitz"))
9219 info.info.global_conf.hash_func =
9220 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9221 else if (!strcmp(res->hash_func, "simple_xor"))
9222 info.info.global_conf.hash_func =
9223 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9224 else if (!strcmp(res->hash_func, "default"))
9225 info.info.global_conf.hash_func =
9226 RTE_ETH_HASH_FUNCTION_DEFAULT;
9228 ftype = str2flowtype(res->flow_type);
9229 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9230 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9231 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9232 if (!strcmp(res->enable, "enable"))
9233 info.info.global_conf.sym_hash_enable_mask[idx] |=
9235 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9236 RTE_ETH_FILTER_SET, &info);
9238 printf("Cannot set global hash configurations by port %d\n",
9241 printf("Global hash configurations have been set "
9242 "succcessfully by port %d\n", res->port_id);
9245 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9246 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9247 set_hash_global_config, "set_hash_global_config");
9248 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9249 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9251 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9252 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9253 hash_func, "toeplitz#simple_xor#default");
9254 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9255 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9257 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9258 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9259 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9260 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9261 enable, "enable#disable");
9263 cmdline_parse_inst_t cmd_set_hash_global_config = {
9264 .f = cmd_set_hash_global_config_parsed,
9266 .help_str = "set_hash_global_config port_id "
9267 "toeplitz|simple_xor|default "
9268 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9269 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9272 (void *)&cmd_set_hash_global_config_all,
9273 (void *)&cmd_set_hash_global_config_port_id,
9274 (void *)&cmd_set_hash_global_config_hash_func,
9275 (void *)&cmd_set_hash_global_config_flow_type,
9276 (void *)&cmd_set_hash_global_config_enable,
9281 /* Set hash input set */
9282 struct cmd_set_hash_input_set_result {
9283 cmdline_fixed_string_t set_hash_input_set;
9285 cmdline_fixed_string_t flow_type;
9286 cmdline_fixed_string_t inset_field;
9287 cmdline_fixed_string_t select;
9290 static enum rte_eth_input_set_field
9291 str2inset(char *string)
9295 static const struct {
9297 enum rte_eth_input_set_field inset;
9299 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9300 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9301 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9302 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9303 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9304 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9305 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9306 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9307 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9308 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9309 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9310 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9311 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9312 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9313 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9314 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9315 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9316 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9317 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9318 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9319 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9320 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9321 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9322 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9323 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9324 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9325 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9326 {"none", RTE_ETH_INPUT_SET_NONE},
9329 for (i = 0; i < RTE_DIM(inset_table); i++) {
9330 if (!strcmp(string, inset_table[i].str))
9331 return inset_table[i].inset;
9334 return RTE_ETH_INPUT_SET_UNKNOWN;
9338 cmd_set_hash_input_set_parsed(void *parsed_result,
9339 __rte_unused struct cmdline *cl,
9340 __rte_unused void *data)
9342 struct cmd_set_hash_input_set_result *res = parsed_result;
9343 struct rte_eth_hash_filter_info info;
9345 memset(&info, 0, sizeof(info));
9346 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9347 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9348 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9349 info.info.input_set_conf.inset_size = 1;
9350 if (!strcmp(res->select, "select"))
9351 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9352 else if (!strcmp(res->select, "add"))
9353 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9354 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9355 RTE_ETH_FILTER_SET, &info);
9358 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9359 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9360 set_hash_input_set, "set_hash_input_set");
9361 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9362 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9364 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9365 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9367 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9368 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9369 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9370 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9372 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9373 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9374 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9375 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9376 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9378 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9379 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9380 select, "select#add");
9382 cmdline_parse_inst_t cmd_set_hash_input_set = {
9383 .f = cmd_set_hash_input_set_parsed,
9385 .help_str = "set_hash_input_set <port_id> "
9386 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9387 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9388 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9389 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9390 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9391 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9392 "fld-7th|fld-8th|none select|add",
9394 (void *)&cmd_set_hash_input_set_cmd,
9395 (void *)&cmd_set_hash_input_set_port_id,
9396 (void *)&cmd_set_hash_input_set_flow_type,
9397 (void *)&cmd_set_hash_input_set_field,
9398 (void *)&cmd_set_hash_input_set_select,
9403 /* Set flow director input set */
9404 struct cmd_set_fdir_input_set_result {
9405 cmdline_fixed_string_t set_fdir_input_set;
9407 cmdline_fixed_string_t flow_type;
9408 cmdline_fixed_string_t inset_field;
9409 cmdline_fixed_string_t select;
9413 cmd_set_fdir_input_set_parsed(void *parsed_result,
9414 __rte_unused struct cmdline *cl,
9415 __rte_unused void *data)
9417 struct cmd_set_fdir_input_set_result *res = parsed_result;
9418 struct rte_eth_fdir_filter_info info;
9420 memset(&info, 0, sizeof(info));
9421 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9422 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9423 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9424 info.info.input_set_conf.inset_size = 1;
9425 if (!strcmp(res->select, "select"))
9426 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9427 else if (!strcmp(res->select, "add"))
9428 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9429 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9430 RTE_ETH_FILTER_SET, &info);
9433 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9434 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9435 set_fdir_input_set, "set_fdir_input_set");
9436 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9437 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9439 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9440 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9442 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9443 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9444 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9445 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9447 "src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#udp-src-port#udp-dst-port#"
9448 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9449 "sctp-veri-tag#fld-1st#fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#"
9450 "fld-7th#fld-8th#none");
9451 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9452 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9453 select, "select#add");
9455 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9456 .f = cmd_set_fdir_input_set_parsed,
9458 .help_str = "set_fdir_input_set <port_id> "
9459 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9460 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9461 "src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port|"
9462 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|"
9463 "fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9464 "fld-7th|fld-8th|none select|add",
9466 (void *)&cmd_set_fdir_input_set_cmd,
9467 (void *)&cmd_set_fdir_input_set_port_id,
9468 (void *)&cmd_set_fdir_input_set_flow_type,
9469 (void *)&cmd_set_fdir_input_set_field,
9470 (void *)&cmd_set_fdir_input_set_select,
9475 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9476 struct cmd_mcast_addr_result {
9477 cmdline_fixed_string_t mcast_addr_cmd;
9478 cmdline_fixed_string_t what;
9480 struct ether_addr mc_addr;
9483 static void cmd_mcast_addr_parsed(void *parsed_result,
9484 __attribute__((unused)) struct cmdline *cl,
9485 __attribute__((unused)) void *data)
9487 struct cmd_mcast_addr_result *res = parsed_result;
9489 if (!is_multicast_ether_addr(&res->mc_addr)) {
9490 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9491 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9492 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9493 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9496 if (strcmp(res->what, "add") == 0)
9497 mcast_addr_add(res->port_num, &res->mc_addr);
9499 mcast_addr_remove(res->port_num, &res->mc_addr);
9502 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9503 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9504 mcast_addr_cmd, "mcast_addr");
9505 cmdline_parse_token_string_t cmd_mcast_addr_what =
9506 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9508 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9509 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9510 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9511 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9513 cmdline_parse_inst_t cmd_mcast_addr = {
9514 .f = cmd_mcast_addr_parsed,
9516 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9518 (void *)&cmd_mcast_addr_cmd,
9519 (void *)&cmd_mcast_addr_what,
9520 (void *)&cmd_mcast_addr_portnum,
9521 (void *)&cmd_mcast_addr_addr,
9526 /* ******************************************************************************** */
9528 /* list of instructions */
9529 cmdline_parse_ctx_t main_ctx[] = {
9530 (cmdline_parse_inst_t *)&cmd_help_brief,
9531 (cmdline_parse_inst_t *)&cmd_help_long,
9532 (cmdline_parse_inst_t *)&cmd_quit,
9533 (cmdline_parse_inst_t *)&cmd_showport,
9534 (cmdline_parse_inst_t *)&cmd_showqueue,
9535 (cmdline_parse_inst_t *)&cmd_showportall,
9536 (cmdline_parse_inst_t *)&cmd_showcfg,
9537 (cmdline_parse_inst_t *)&cmd_start,
9538 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9539 (cmdline_parse_inst_t *)&cmd_set_link_up,
9540 (cmdline_parse_inst_t *)&cmd_set_link_down,
9541 (cmdline_parse_inst_t *)&cmd_reset,
9542 (cmdline_parse_inst_t *)&cmd_set_numbers,
9543 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9544 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9545 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9546 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9547 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9548 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9549 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9550 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9551 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9552 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9553 (cmdline_parse_inst_t *)&cmd_set_link_check,
9554 #ifdef RTE_NIC_BYPASS
9555 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9556 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9557 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9558 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9560 #ifdef RTE_LIBRTE_PMD_BOND
9561 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9562 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9563 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9564 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9565 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9566 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9567 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9568 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9569 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9571 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9572 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9573 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9574 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9575 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9576 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
9577 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9578 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9579 (cmdline_parse_inst_t *)&cmd_csum_set,
9580 (cmdline_parse_inst_t *)&cmd_csum_show,
9581 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
9582 (cmdline_parse_inst_t *)&cmd_tso_set,
9583 (cmdline_parse_inst_t *)&cmd_tso_show,
9584 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9585 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9586 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9587 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9588 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9589 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9590 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9591 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9592 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9593 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9594 (cmdline_parse_inst_t *)&cmd_config_dcb,
9595 (cmdline_parse_inst_t *)&cmd_read_reg,
9596 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9597 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9598 (cmdline_parse_inst_t *)&cmd_write_reg,
9599 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9600 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9601 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9602 (cmdline_parse_inst_t *)&cmd_stop,
9603 (cmdline_parse_inst_t *)&cmd_mac_addr,
9604 (cmdline_parse_inst_t *)&cmd_set_qmap,
9605 (cmdline_parse_inst_t *)&cmd_operate_port,
9606 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9607 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
9608 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
9609 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9610 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9611 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9612 (cmdline_parse_inst_t *)&cmd_config_mtu,
9613 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9614 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9615 (cmdline_parse_inst_t *)&cmd_config_rss,
9616 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9617 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9618 (cmdline_parse_inst_t *)&cmd_showport_reta,
9619 (cmdline_parse_inst_t *)&cmd_config_burst,
9620 (cmdline_parse_inst_t *)&cmd_config_thresh,
9621 (cmdline_parse_inst_t *)&cmd_config_threshold,
9622 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9623 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9624 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9625 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9626 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9627 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9628 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9629 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9630 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9631 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9632 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9633 (cmdline_parse_inst_t *)&cmd_global_config,
9634 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9635 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9636 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9637 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9638 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9639 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9640 (cmdline_parse_inst_t *)&cmd_dump,
9641 (cmdline_parse_inst_t *)&cmd_dump_one,
9642 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9643 (cmdline_parse_inst_t *)&cmd_syn_filter,
9644 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
9645 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
9646 (cmdline_parse_inst_t *)&cmd_flex_filter,
9647 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9648 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9649 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9650 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
9651 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
9652 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
9653 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9654 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
9655 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
9656 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
9657 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9658 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9659 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9660 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9661 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9662 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9663 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
9664 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
9665 (cmdline_parse_inst_t *)&cmd_mcast_addr,
9669 /* prompt function, called from main on MASTER lcore */
9675 /* initialize non-constant commands */
9676 cmd_set_fwd_mode_init();
9678 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9682 cmdline_interact(cl);
9683 cmdline_stdin_exit(cl);
9687 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9689 if (id == (portid_t)RTE_PORT_ALL) {
9692 FOREACH_PORT(pid, ports) {
9693 /* check if need_reconfig has been set to 1 */
9694 if (ports[pid].need_reconfig == 0)
9695 ports[pid].need_reconfig = dev;
9696 /* check if need_reconfig_queues has been set to 1 */
9697 if (ports[pid].need_reconfig_queues == 0)
9698 ports[pid].need_reconfig_queues = queue;
9700 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
9701 /* check if need_reconfig has been set to 1 */
9702 if (ports[id].need_reconfig == 0)
9703 ports[id].need_reconfig = dev;
9704 /* check if need_reconfig_queues has been set to 1 */
9705 if (ports[id].need_reconfig_queues == 0)
9706 ports[id].need_reconfig_queues = queue;
9710 #ifdef RTE_NIC_BYPASS
9711 #include <rte_pci_dev_ids.h>
9713 bypass_is_supported(portid_t port_id)
9715 struct rte_port *port;
9716 struct rte_pci_id *pci_id;
9718 if (port_id_is_invalid(port_id, ENABLED_WARN))
9721 /* Get the device id. */
9722 port = &ports[port_id];
9723 pci_id = &port->dev_info.pci_dev->id;
9725 /* Check if NIC supports bypass. */
9726 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9730 printf("\tBypass not supported for port_id = %d.\n", port_id);