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) mode IP (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) pf|vf(vf_id) queue (queue_id)"
637 " fd_id (fd_id_value)\n"
638 " Add/Del an IP type flow director filter.\n\n"
640 "flow_director_filter (port_id) mode IP (add|del|update)"
641 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
642 " src (src_ip_address) (src_port)"
643 " dst (dst_ip_address) (dst_port)"
644 " vlan (vlan_value) flexbytes (flexbytes_value)"
645 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
646 " fd_id (fd_id_value)\n"
647 " Add/Del an UDP/TCP type flow director filter.\n\n"
649 "flow_director_filter (port_id) mode IP (add|del|update)"
650 " flow (ipv4-sctp|ipv6-sctp)"
651 " src (src_ip_address) (src_port)"
652 " dst (dst_ip_address) (dst_port)"
653 " tag (verification_tag) vlan (vlan_value)"
654 " flexbytes (flexbytes_value) (drop|fwd)"
655 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
656 " Add/Del a SCTP type flow director filter.\n\n"
658 "flow_director_filter (port_id) mode IP (add|del|update)"
659 " flow l2_payload ether (ethertype)"
660 " flexbytes (flexbytes_value) (drop|fwd)"
661 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
662 " Add/Del a l2 payload type flow director filter.\n\n"
664 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
665 " mac (mac_address) vlan (vlan_value)"
666 " flexbytes (flexbytes_value) (drop|fwd)"
667 " queue (queue_id) fd_id (fd_id_value)\n"
668 " Add/Del a MAC-VLAN flow director filter.\n\n"
670 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
671 " mac (mac_address) vlan (vlan_value)"
672 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
673 " flexbytes (flexbytes_value) (drop|fwd)"
674 " queue (queue_id) fd_id (fd_id_value)\n"
675 " Add/Del a Tunnel flow director filter.\n\n"
677 "flush_flow_director (port_id)\n"
678 " Flush all flow director entries of a device.\n\n"
680 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
681 " src_mask (ipv4_src) (ipv6_src) (src_port)"
682 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
683 " Set flow director IP mask.\n\n"
685 "flow_director_mask (port_id) mode MAC-VLAN"
686 " vlan (vlan_value) mac (mac_value)\n"
687 " Set flow director MAC-VLAN mask.\n\n"
689 "flow_director_mask (port_id) mode Tunnel"
690 " vlan (vlan_value) mac (mac_value)"
691 " tunnel-type (tunnel_type_value)"
692 " tunnel-id (tunnel_id_value)\n"
693 " Set flow director Tunnel mask.\n\n"
695 "flow_director_flex_mask (port_id)"
696 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
697 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
699 " Configure mask of flex payload.\n\n"
701 "flow_director_flex_payload (port_id)"
702 " (raw|l2|l3|l4) (config)\n"
703 " Configure flex payload selection.\n\n"
705 "get_sym_hash_ena_per_port (port_id)\n"
706 " get symmetric hash enable configuration per port.\n\n"
708 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
709 " set symmetric hash enable configuration per port"
710 " to enable or disable.\n\n"
712 "get_hash_global_config (port_id)\n"
713 " Get the global configurations of hash filters.\n\n"
715 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
716 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
717 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
718 " (enable|disable)\n"
719 " Set the global configurations of hash filters.\n\n"
721 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
722 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
723 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
724 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
725 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
726 "ipv6-next-header|udp-src-port|udp-dst-port|"
727 "tcp-src-port|tcp-dst-port|sctp-src-port|"
728 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
729 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
730 "fld-8th|none) (select|add)\n"
731 " Set the input set for hash.\n\n"
733 "set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
734 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
735 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
736 "l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
737 "udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
738 "sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
739 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
740 "fld-8th|none) (select|add)\n"
741 " Set the input set for FDir.\n\n"
746 cmdline_parse_token_string_t cmd_help_long_help =
747 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
749 cmdline_parse_token_string_t cmd_help_long_section =
750 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
751 "all#control#display#config#"
752 "ports#registers#filters");
754 cmdline_parse_inst_t cmd_help_long = {
755 .f = cmd_help_long_parsed,
757 .help_str = "show help",
759 (void *)&cmd_help_long_help,
760 (void *)&cmd_help_long_section,
766 /* *** start/stop/close all ports *** */
767 struct cmd_operate_port_result {
768 cmdline_fixed_string_t keyword;
769 cmdline_fixed_string_t name;
770 cmdline_fixed_string_t value;
773 static void cmd_operate_port_parsed(void *parsed_result,
774 __attribute__((unused)) struct cmdline *cl,
775 __attribute__((unused)) void *data)
777 struct cmd_operate_port_result *res = parsed_result;
779 if (!strcmp(res->name, "start"))
780 start_port(RTE_PORT_ALL);
781 else if (!strcmp(res->name, "stop"))
782 stop_port(RTE_PORT_ALL);
783 else if (!strcmp(res->name, "close"))
784 close_port(RTE_PORT_ALL);
786 printf("Unknown parameter\n");
789 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
790 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
792 cmdline_parse_token_string_t cmd_operate_port_all_port =
793 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
795 cmdline_parse_token_string_t cmd_operate_port_all_all =
796 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
798 cmdline_parse_inst_t cmd_operate_port = {
799 .f = cmd_operate_port_parsed,
801 .help_str = "port start|stop|close all: start/stop/close all ports",
803 (void *)&cmd_operate_port_all_cmd,
804 (void *)&cmd_operate_port_all_port,
805 (void *)&cmd_operate_port_all_all,
810 /* *** start/stop/close specific port *** */
811 struct cmd_operate_specific_port_result {
812 cmdline_fixed_string_t keyword;
813 cmdline_fixed_string_t name;
817 static void cmd_operate_specific_port_parsed(void *parsed_result,
818 __attribute__((unused)) struct cmdline *cl,
819 __attribute__((unused)) void *data)
821 struct cmd_operate_specific_port_result *res = parsed_result;
823 if (!strcmp(res->name, "start"))
824 start_port(res->value);
825 else if (!strcmp(res->name, "stop"))
826 stop_port(res->value);
827 else if (!strcmp(res->name, "close"))
828 close_port(res->value);
830 printf("Unknown parameter\n");
833 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
834 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
836 cmdline_parse_token_string_t cmd_operate_specific_port_port =
837 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
838 name, "start#stop#close");
839 cmdline_parse_token_num_t cmd_operate_specific_port_id =
840 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
843 cmdline_parse_inst_t cmd_operate_specific_port = {
844 .f = cmd_operate_specific_port_parsed,
846 .help_str = "port start|stop|close X: start/stop/close port X",
848 (void *)&cmd_operate_specific_port_cmd,
849 (void *)&cmd_operate_specific_port_port,
850 (void *)&cmd_operate_specific_port_id,
855 /* *** attach a specified port *** */
856 struct cmd_operate_attach_port_result {
857 cmdline_fixed_string_t port;
858 cmdline_fixed_string_t keyword;
859 cmdline_fixed_string_t identifier;
862 static void cmd_operate_attach_port_parsed(void *parsed_result,
863 __attribute__((unused)) struct cmdline *cl,
864 __attribute__((unused)) void *data)
866 struct cmd_operate_attach_port_result *res = parsed_result;
868 if (!strcmp(res->keyword, "attach"))
869 attach_port(res->identifier);
871 printf("Unknown parameter\n");
874 cmdline_parse_token_string_t cmd_operate_attach_port_port =
875 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
877 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
878 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
880 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
881 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
884 cmdline_parse_inst_t cmd_operate_attach_port = {
885 .f = cmd_operate_attach_port_parsed,
887 .help_str = "port attach identifier, "
888 "identifier: pci address or virtual dev name",
890 (void *)&cmd_operate_attach_port_port,
891 (void *)&cmd_operate_attach_port_keyword,
892 (void *)&cmd_operate_attach_port_identifier,
897 /* *** detach a specified port *** */
898 struct cmd_operate_detach_port_result {
899 cmdline_fixed_string_t port;
900 cmdline_fixed_string_t keyword;
904 static void cmd_operate_detach_port_parsed(void *parsed_result,
905 __attribute__((unused)) struct cmdline *cl,
906 __attribute__((unused)) void *data)
908 struct cmd_operate_detach_port_result *res = parsed_result;
910 if (!strcmp(res->keyword, "detach"))
911 detach_port(res->port_id);
913 printf("Unknown parameter\n");
916 cmdline_parse_token_string_t cmd_operate_detach_port_port =
917 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
919 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
920 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
922 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
923 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
926 cmdline_parse_inst_t cmd_operate_detach_port = {
927 .f = cmd_operate_detach_port_parsed,
929 .help_str = "port detach port_id",
931 (void *)&cmd_operate_detach_port_port,
932 (void *)&cmd_operate_detach_port_keyword,
933 (void *)&cmd_operate_detach_port_port_id,
938 /* *** configure speed for all ports *** */
939 struct cmd_config_speed_all {
940 cmdline_fixed_string_t port;
941 cmdline_fixed_string_t keyword;
942 cmdline_fixed_string_t all;
943 cmdline_fixed_string_t item1;
944 cmdline_fixed_string_t item2;
945 cmdline_fixed_string_t value1;
946 cmdline_fixed_string_t value2;
950 cmd_config_speed_all_parsed(void *parsed_result,
951 __attribute__((unused)) struct cmdline *cl,
952 __attribute__((unused)) void *data)
954 struct cmd_config_speed_all *res = parsed_result;
955 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
956 uint16_t link_duplex = 0;
959 if (!all_ports_stopped()) {
960 printf("Please stop all ports first\n");
964 if (!strcmp(res->value1, "10"))
965 link_speed = ETH_LINK_SPEED_10;
966 else if (!strcmp(res->value1, "100"))
967 link_speed = ETH_LINK_SPEED_100;
968 else if (!strcmp(res->value1, "1000"))
969 link_speed = ETH_LINK_SPEED_1000;
970 else if (!strcmp(res->value1, "10000"))
971 link_speed = ETH_LINK_SPEED_10G;
972 else if (!strcmp(res->value1, "40000"))
973 link_speed = ETH_LINK_SPEED_40G;
974 else if (!strcmp(res->value1, "auto"))
975 link_speed = ETH_LINK_SPEED_AUTONEG;
977 printf("Unknown parameter\n");
981 if (!strcmp(res->value2, "half"))
982 link_duplex = ETH_LINK_HALF_DUPLEX;
983 else if (!strcmp(res->value2, "full"))
984 link_duplex = ETH_LINK_FULL_DUPLEX;
985 else if (!strcmp(res->value2, "auto"))
986 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
988 printf("Unknown parameter\n");
992 FOREACH_PORT(pid, ports) {
993 ports[pid].dev_conf.link_speed = link_speed;
994 ports[pid].dev_conf.link_duplex = link_duplex;
997 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1000 cmdline_parse_token_string_t cmd_config_speed_all_port =
1001 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1002 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1003 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1005 cmdline_parse_token_string_t cmd_config_speed_all_all =
1006 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1007 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1008 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1009 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1010 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1011 "10#100#1000#10000#40000#auto");
1012 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1013 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1014 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1015 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1018 cmdline_parse_inst_t cmd_config_speed_all = {
1019 .f = cmd_config_speed_all_parsed,
1021 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
1024 (void *)&cmd_config_speed_all_port,
1025 (void *)&cmd_config_speed_all_keyword,
1026 (void *)&cmd_config_speed_all_all,
1027 (void *)&cmd_config_speed_all_item1,
1028 (void *)&cmd_config_speed_all_value1,
1029 (void *)&cmd_config_speed_all_item2,
1030 (void *)&cmd_config_speed_all_value2,
1035 /* *** configure speed for specific port *** */
1036 struct cmd_config_speed_specific {
1037 cmdline_fixed_string_t port;
1038 cmdline_fixed_string_t keyword;
1040 cmdline_fixed_string_t item1;
1041 cmdline_fixed_string_t item2;
1042 cmdline_fixed_string_t value1;
1043 cmdline_fixed_string_t value2;
1047 cmd_config_speed_specific_parsed(void *parsed_result,
1048 __attribute__((unused)) struct cmdline *cl,
1049 __attribute__((unused)) void *data)
1051 struct cmd_config_speed_specific *res = parsed_result;
1052 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1053 uint16_t link_duplex = 0;
1055 if (!all_ports_stopped()) {
1056 printf("Please stop all ports first\n");
1060 if (port_id_is_invalid(res->id, ENABLED_WARN))
1063 if (!strcmp(res->value1, "10"))
1064 link_speed = ETH_LINK_SPEED_10;
1065 else if (!strcmp(res->value1, "100"))
1066 link_speed = ETH_LINK_SPEED_100;
1067 else if (!strcmp(res->value1, "1000"))
1068 link_speed = ETH_LINK_SPEED_1000;
1069 else if (!strcmp(res->value1, "10000"))
1070 link_speed = ETH_LINK_SPEED_10000;
1071 else if (!strcmp(res->value1, "40000"))
1072 link_speed = ETH_LINK_SPEED_40G;
1073 else if (!strcmp(res->value1, "auto"))
1074 link_speed = ETH_LINK_SPEED_AUTONEG;
1076 printf("Unknown parameter\n");
1080 if (!strcmp(res->value2, "half"))
1081 link_duplex = ETH_LINK_HALF_DUPLEX;
1082 else if (!strcmp(res->value2, "full"))
1083 link_duplex = ETH_LINK_FULL_DUPLEX;
1084 else if (!strcmp(res->value2, "auto"))
1085 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1087 printf("Unknown parameter\n");
1091 ports[res->id].dev_conf.link_speed = link_speed;
1092 ports[res->id].dev_conf.link_duplex = link_duplex;
1094 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1098 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1099 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1101 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1102 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1104 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1105 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1106 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1107 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1109 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1110 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1111 "10#100#1000#10000#40000#auto");
1112 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1113 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1115 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1116 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1119 cmdline_parse_inst_t cmd_config_speed_specific = {
1120 .f = cmd_config_speed_specific_parsed,
1122 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1125 (void *)&cmd_config_speed_specific_port,
1126 (void *)&cmd_config_speed_specific_keyword,
1127 (void *)&cmd_config_speed_specific_id,
1128 (void *)&cmd_config_speed_specific_item1,
1129 (void *)&cmd_config_speed_specific_value1,
1130 (void *)&cmd_config_speed_specific_item2,
1131 (void *)&cmd_config_speed_specific_value2,
1136 /* *** configure txq/rxq, txd/rxd *** */
1137 struct cmd_config_rx_tx {
1138 cmdline_fixed_string_t port;
1139 cmdline_fixed_string_t keyword;
1140 cmdline_fixed_string_t all;
1141 cmdline_fixed_string_t name;
1146 cmd_config_rx_tx_parsed(void *parsed_result,
1147 __attribute__((unused)) struct cmdline *cl,
1148 __attribute__((unused)) void *data)
1150 struct cmd_config_rx_tx *res = parsed_result;
1152 if (!all_ports_stopped()) {
1153 printf("Please stop all ports first\n");
1157 if (!strcmp(res->name, "rxq")) {
1158 if (res->value <= 0) {
1159 printf("rxq %d invalid - must be > 0\n", res->value);
1162 nb_rxq = res->value;
1164 else if (!strcmp(res->name, "txq")) {
1165 if (res->value <= 0) {
1166 printf("txq %d invalid - must be > 0\n", res->value);
1169 nb_txq = res->value;
1171 else if (!strcmp(res->name, "rxd")) {
1172 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1173 printf("rxd %d invalid - must be > 0 && <= %d\n",
1174 res->value, RTE_TEST_RX_DESC_MAX);
1177 nb_rxd = res->value;
1178 } else if (!strcmp(res->name, "txd")) {
1179 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1180 printf("txd %d invalid - must be > 0 && <= %d\n",
1181 res->value, RTE_TEST_TX_DESC_MAX);
1184 nb_txd = res->value;
1186 printf("Unknown parameter\n");
1192 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1195 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1196 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1197 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1198 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1199 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1200 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1201 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1202 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1204 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1205 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1207 cmdline_parse_inst_t cmd_config_rx_tx = {
1208 .f = cmd_config_rx_tx_parsed,
1210 .help_str = "port config all rxq|txq|rxd|txd value",
1212 (void *)&cmd_config_rx_tx_port,
1213 (void *)&cmd_config_rx_tx_keyword,
1214 (void *)&cmd_config_rx_tx_all,
1215 (void *)&cmd_config_rx_tx_name,
1216 (void *)&cmd_config_rx_tx_value,
1221 /* *** config max packet length *** */
1222 struct cmd_config_max_pkt_len_result {
1223 cmdline_fixed_string_t port;
1224 cmdline_fixed_string_t keyword;
1225 cmdline_fixed_string_t all;
1226 cmdline_fixed_string_t name;
1231 cmd_config_max_pkt_len_parsed(void *parsed_result,
1232 __attribute__((unused)) struct cmdline *cl,
1233 __attribute__((unused)) void *data)
1235 struct cmd_config_max_pkt_len_result *res = parsed_result;
1237 if (!all_ports_stopped()) {
1238 printf("Please stop all ports first\n");
1242 if (!strcmp(res->name, "max-pkt-len")) {
1243 if (res->value < ETHER_MIN_LEN) {
1244 printf("max-pkt-len can not be less than %d\n",
1248 if (res->value == rx_mode.max_rx_pkt_len)
1251 rx_mode.max_rx_pkt_len = res->value;
1252 if (res->value > ETHER_MAX_LEN)
1253 rx_mode.jumbo_frame = 1;
1255 rx_mode.jumbo_frame = 0;
1257 printf("Unknown parameter\n");
1263 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1266 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1267 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1269 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1270 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1272 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1273 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1275 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1276 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1278 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1279 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1282 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1283 .f = cmd_config_max_pkt_len_parsed,
1285 .help_str = "port config all max-pkt-len value",
1287 (void *)&cmd_config_max_pkt_len_port,
1288 (void *)&cmd_config_max_pkt_len_keyword,
1289 (void *)&cmd_config_max_pkt_len_all,
1290 (void *)&cmd_config_max_pkt_len_name,
1291 (void *)&cmd_config_max_pkt_len_value,
1296 /* *** configure port MTU *** */
1297 struct cmd_config_mtu_result {
1298 cmdline_fixed_string_t port;
1299 cmdline_fixed_string_t keyword;
1300 cmdline_fixed_string_t mtu;
1306 cmd_config_mtu_parsed(void *parsed_result,
1307 __attribute__((unused)) struct cmdline *cl,
1308 __attribute__((unused)) void *data)
1310 struct cmd_config_mtu_result *res = parsed_result;
1312 if (res->value < ETHER_MIN_LEN) {
1313 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1316 port_mtu_set(res->port_id, res->value);
1319 cmdline_parse_token_string_t cmd_config_mtu_port =
1320 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1322 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1323 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1325 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1326 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1328 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1329 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1330 cmdline_parse_token_num_t cmd_config_mtu_value =
1331 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1333 cmdline_parse_inst_t cmd_config_mtu = {
1334 .f = cmd_config_mtu_parsed,
1336 .help_str = "port config mtu value",
1338 (void *)&cmd_config_mtu_port,
1339 (void *)&cmd_config_mtu_keyword,
1340 (void *)&cmd_config_mtu_mtu,
1341 (void *)&cmd_config_mtu_port_id,
1342 (void *)&cmd_config_mtu_value,
1347 /* *** configure rx mode *** */
1348 struct cmd_config_rx_mode_flag {
1349 cmdline_fixed_string_t port;
1350 cmdline_fixed_string_t keyword;
1351 cmdline_fixed_string_t all;
1352 cmdline_fixed_string_t name;
1353 cmdline_fixed_string_t value;
1357 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1358 __attribute__((unused)) struct cmdline *cl,
1359 __attribute__((unused)) void *data)
1361 struct cmd_config_rx_mode_flag *res = parsed_result;
1363 if (!all_ports_stopped()) {
1364 printf("Please stop all ports first\n");
1368 if (!strcmp(res->name, "crc-strip")) {
1369 if (!strcmp(res->value, "on"))
1370 rx_mode.hw_strip_crc = 1;
1371 else if (!strcmp(res->value, "off"))
1372 rx_mode.hw_strip_crc = 0;
1374 printf("Unknown parameter\n");
1377 } else if (!strcmp(res->name, "rx-cksum")) {
1378 if (!strcmp(res->value, "on"))
1379 rx_mode.hw_ip_checksum = 1;
1380 else if (!strcmp(res->value, "off"))
1381 rx_mode.hw_ip_checksum = 0;
1383 printf("Unknown parameter\n");
1386 } else if (!strcmp(res->name, "hw-vlan")) {
1387 if (!strcmp(res->value, "on")) {
1388 rx_mode.hw_vlan_filter = 1;
1389 rx_mode.hw_vlan_strip = 1;
1391 else if (!strcmp(res->value, "off")) {
1392 rx_mode.hw_vlan_filter = 0;
1393 rx_mode.hw_vlan_strip = 0;
1396 printf("Unknown parameter\n");
1399 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1400 if (!strcmp(res->value, "on"))
1401 rx_mode.hw_vlan_filter = 1;
1402 else if (!strcmp(res->value, "off"))
1403 rx_mode.hw_vlan_filter = 0;
1405 printf("Unknown parameter\n");
1408 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1409 if (!strcmp(res->value, "on"))
1410 rx_mode.hw_vlan_strip = 1;
1411 else if (!strcmp(res->value, "off"))
1412 rx_mode.hw_vlan_strip = 0;
1414 printf("Unknown parameter\n");
1417 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1418 if (!strcmp(res->value, "on"))
1419 rx_mode.hw_vlan_extend = 1;
1420 else if (!strcmp(res->value, "off"))
1421 rx_mode.hw_vlan_extend = 0;
1423 printf("Unknown parameter\n");
1426 } else if (!strcmp(res->name, "drop-en")) {
1427 if (!strcmp(res->value, "on"))
1429 else if (!strcmp(res->value, "off"))
1432 printf("Unknown parameter\n");
1436 printf("Unknown parameter\n");
1442 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1445 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1446 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1447 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1448 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1450 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1451 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1452 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1453 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1454 "crc-strip#rx-cksum#hw-vlan#"
1455 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1456 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1457 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1460 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1461 .f = cmd_config_rx_mode_flag_parsed,
1463 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1464 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1466 (void *)&cmd_config_rx_mode_flag_port,
1467 (void *)&cmd_config_rx_mode_flag_keyword,
1468 (void *)&cmd_config_rx_mode_flag_all,
1469 (void *)&cmd_config_rx_mode_flag_name,
1470 (void *)&cmd_config_rx_mode_flag_value,
1475 /* *** configure rss *** */
1476 struct cmd_config_rss {
1477 cmdline_fixed_string_t port;
1478 cmdline_fixed_string_t keyword;
1479 cmdline_fixed_string_t all;
1480 cmdline_fixed_string_t name;
1481 cmdline_fixed_string_t value;
1485 cmd_config_rss_parsed(void *parsed_result,
1486 __attribute__((unused)) struct cmdline *cl,
1487 __attribute__((unused)) void *data)
1489 struct cmd_config_rss *res = parsed_result;
1490 struct rte_eth_rss_conf rss_conf;
1493 if (!strcmp(res->value, "all"))
1494 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1495 ETH_RSS_UDP | ETH_RSS_SCTP |
1497 else if (!strcmp(res->value, "ip"))
1498 rss_conf.rss_hf = ETH_RSS_IP;
1499 else if (!strcmp(res->value, "udp"))
1500 rss_conf.rss_hf = ETH_RSS_UDP;
1501 else if (!strcmp(res->value, "tcp"))
1502 rss_conf.rss_hf = ETH_RSS_TCP;
1503 else if (!strcmp(res->value, "sctp"))
1504 rss_conf.rss_hf = ETH_RSS_SCTP;
1505 else if (!strcmp(res->value, "ether"))
1506 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1507 else if (!strcmp(res->value, "none"))
1508 rss_conf.rss_hf = 0;
1510 printf("Unknown parameter\n");
1513 rss_conf.rss_key = NULL;
1514 for (i = 0; i < rte_eth_dev_count(); i++)
1515 rte_eth_dev_rss_hash_update(i, &rss_conf);
1518 cmdline_parse_token_string_t cmd_config_rss_port =
1519 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1520 cmdline_parse_token_string_t cmd_config_rss_keyword =
1521 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1522 cmdline_parse_token_string_t cmd_config_rss_all =
1523 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1524 cmdline_parse_token_string_t cmd_config_rss_name =
1525 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1526 cmdline_parse_token_string_t cmd_config_rss_value =
1527 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1528 "all#ip#tcp#udp#sctp#ether#none");
1530 cmdline_parse_inst_t cmd_config_rss = {
1531 .f = cmd_config_rss_parsed,
1533 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1535 (void *)&cmd_config_rss_port,
1536 (void *)&cmd_config_rss_keyword,
1537 (void *)&cmd_config_rss_all,
1538 (void *)&cmd_config_rss_name,
1539 (void *)&cmd_config_rss_value,
1544 /* *** configure rss hash key *** */
1545 struct cmd_config_rss_hash_key {
1546 cmdline_fixed_string_t port;
1547 cmdline_fixed_string_t config;
1549 cmdline_fixed_string_t rss_hash_key;
1550 cmdline_fixed_string_t rss_type;
1551 cmdline_fixed_string_t key;
1554 #define RSS_HASH_KEY_LENGTH 40
1556 hexa_digit_to_value(char hexa_digit)
1558 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1559 return (uint8_t) (hexa_digit - '0');
1560 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1561 return (uint8_t) ((hexa_digit - 'a') + 10);
1562 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1563 return (uint8_t) ((hexa_digit - 'A') + 10);
1564 /* Invalid hexa digit */
1569 parse_and_check_key_hexa_digit(char *key, int idx)
1573 hexa_v = hexa_digit_to_value(key[idx]);
1575 printf("invalid key: character %c at position %d is not a "
1576 "valid hexa digit\n", key[idx], idx);
1581 cmd_config_rss_hash_key_parsed(void *parsed_result,
1582 __attribute__((unused)) struct cmdline *cl,
1583 __attribute__((unused)) void *data)
1585 struct cmd_config_rss_hash_key *res = parsed_result;
1586 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1591 /* Check the length of the RSS hash key */
1592 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1593 printf("key length: %d invalid - key must be a string of %d"
1594 "hexa-decimal numbers\n", (int) strlen(res->key),
1595 RSS_HASH_KEY_LENGTH * 2);
1598 /* Translate RSS hash key into binary representation */
1599 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1600 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1603 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1606 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1608 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1609 RSS_HASH_KEY_LENGTH);
1612 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1613 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1614 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1615 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1617 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1618 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1619 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1620 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1621 rss_hash_key, "rss-hash-key");
1622 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1623 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1624 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1625 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1626 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1627 "ipv6-tcp-ex#ipv6-udp-ex");
1628 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1631 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1632 .f = cmd_config_rss_hash_key_parsed,
1635 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1636 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1637 "ipv6-sctp|ipv6-other|l2-payload|"
1638 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1640 (void *)&cmd_config_rss_hash_key_port,
1641 (void *)&cmd_config_rss_hash_key_config,
1642 (void *)&cmd_config_rss_hash_key_port_id,
1643 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1644 (void *)&cmd_config_rss_hash_key_rss_type,
1645 (void *)&cmd_config_rss_hash_key_value,
1650 /* *** configure port rxq/txq start/stop *** */
1651 struct cmd_config_rxtx_queue {
1652 cmdline_fixed_string_t port;
1654 cmdline_fixed_string_t rxtxq;
1656 cmdline_fixed_string_t opname;
1660 cmd_config_rxtx_queue_parsed(void *parsed_result,
1661 __attribute__((unused)) struct cmdline *cl,
1662 __attribute__((unused)) void *data)
1664 struct cmd_config_rxtx_queue *res = parsed_result;
1669 if (test_done == 0) {
1670 printf("Please stop forwarding first\n");
1674 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1677 if (port_is_started(res->portid) != 1) {
1678 printf("Please start port %u first\n", res->portid);
1682 if (!strcmp(res->rxtxq, "rxq"))
1684 else if (!strcmp(res->rxtxq, "txq"))
1687 printf("Unknown parameter\n");
1691 if (isrx && rx_queue_id_is_invalid(res->qid))
1693 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1696 if (!strcmp(res->opname, "start"))
1698 else if (!strcmp(res->opname, "stop"))
1701 printf("Unknown parameter\n");
1705 if (isstart && isrx)
1706 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1707 else if (!isstart && isrx)
1708 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1709 else if (isstart && !isrx)
1710 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1712 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1714 if (ret == -ENOTSUP)
1715 printf("Function not supported in PMD driver\n");
1718 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1719 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1720 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1721 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1722 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1724 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1725 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1726 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1727 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1730 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1731 .f = cmd_config_rxtx_queue_parsed,
1733 .help_str = "port X rxq|txq ID start|stop",
1735 (void *)&cmd_config_speed_all_port,
1736 (void *)&cmd_config_rxtx_queue_portid,
1737 (void *)&cmd_config_rxtx_queue_rxtxq,
1738 (void *)&cmd_config_rxtx_queue_qid,
1739 (void *)&cmd_config_rxtx_queue_opname,
1744 /* *** Configure RSS RETA *** */
1745 struct cmd_config_rss_reta {
1746 cmdline_fixed_string_t port;
1747 cmdline_fixed_string_t keyword;
1749 cmdline_fixed_string_t name;
1750 cmdline_fixed_string_t list_name;
1751 cmdline_fixed_string_t list_of_items;
1755 parse_reta_config(const char *str,
1756 struct rte_eth_rss_reta_entry64 *reta_conf,
1757 uint16_t nb_entries)
1761 uint16_t hash_index, idx, shift;
1764 const char *p, *p0 = str;
1771 unsigned long int_fld[_NUM_FLD];
1772 char *str_fld[_NUM_FLD];
1774 while ((p = strchr(p0,'(')) != NULL) {
1776 if((p0 = strchr(p,')')) == NULL)
1780 if(size >= sizeof(s))
1783 snprintf(s, sizeof(s), "%.*s", size, p);
1784 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1786 for (i = 0; i < _NUM_FLD; i++) {
1788 int_fld[i] = strtoul(str_fld[i], &end, 0);
1789 if (errno != 0 || end == str_fld[i] ||
1794 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1795 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1797 if (hash_index >= nb_entries) {
1798 printf("Invalid RETA hash index=%d\n", hash_index);
1802 idx = hash_index / RTE_RETA_GROUP_SIZE;
1803 shift = hash_index % RTE_RETA_GROUP_SIZE;
1804 reta_conf[idx].mask |= (1ULL << shift);
1805 reta_conf[idx].reta[shift] = nb_queue;
1812 cmd_set_rss_reta_parsed(void *parsed_result,
1813 __attribute__((unused)) struct cmdline *cl,
1814 __attribute__((unused)) void *data)
1817 struct rte_eth_dev_info dev_info;
1818 struct rte_eth_rss_reta_entry64 reta_conf[8];
1819 struct cmd_config_rss_reta *res = parsed_result;
1821 memset(&dev_info, 0, sizeof(dev_info));
1822 rte_eth_dev_info_get(res->port_id, &dev_info);
1823 if (dev_info.reta_size == 0) {
1824 printf("Redirection table size is 0 which is "
1825 "invalid for RSS\n");
1828 printf("The reta size of port %d is %u\n",
1829 res->port_id, dev_info.reta_size);
1830 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1831 printf("Currently do not support more than %u entries of "
1832 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1836 memset(reta_conf, 0, sizeof(reta_conf));
1837 if (!strcmp(res->list_name, "reta")) {
1838 if (parse_reta_config(res->list_of_items, reta_conf,
1839 dev_info.reta_size)) {
1840 printf("Invalid RSS Redirection Table "
1841 "config entered\n");
1844 ret = rte_eth_dev_rss_reta_update(res->port_id,
1845 reta_conf, dev_info.reta_size);
1847 printf("Bad redirection table parameter, "
1848 "return code = %d \n", ret);
1852 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1854 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1856 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1857 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1858 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1860 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1862 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1863 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1865 cmdline_parse_inst_t cmd_config_rss_reta = {
1866 .f = cmd_set_rss_reta_parsed,
1868 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1870 (void *)&cmd_config_rss_reta_port,
1871 (void *)&cmd_config_rss_reta_keyword,
1872 (void *)&cmd_config_rss_reta_port_id,
1873 (void *)&cmd_config_rss_reta_name,
1874 (void *)&cmd_config_rss_reta_list_name,
1875 (void *)&cmd_config_rss_reta_list_of_items,
1880 /* *** SHOW PORT RETA INFO *** */
1881 struct cmd_showport_reta {
1882 cmdline_fixed_string_t show;
1883 cmdline_fixed_string_t port;
1885 cmdline_fixed_string_t rss;
1886 cmdline_fixed_string_t reta;
1888 cmdline_fixed_string_t list_of_items;
1892 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1893 uint16_t nb_entries,
1897 const char *p, *p0 = str;
1901 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1904 p = strchr(p0, '(');
1908 p0 = strchr(p, ')');
1912 if (size >= sizeof(s)) {
1913 printf("The string size exceeds the internal buffer size\n");
1916 snprintf(s, sizeof(s), "%.*s", size, p);
1917 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1918 if (ret <= 0 || ret != num) {
1919 printf("The bits of masks do not match the number of "
1920 "reta entries: %u\n", num);
1923 for (i = 0; i < ret; i++)
1924 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1930 cmd_showport_reta_parsed(void *parsed_result,
1931 __attribute__((unused)) struct cmdline *cl,
1932 __attribute__((unused)) void *data)
1934 struct cmd_showport_reta *res = parsed_result;
1935 struct rte_eth_rss_reta_entry64 reta_conf[8];
1936 struct rte_eth_dev_info dev_info;
1938 memset(&dev_info, 0, sizeof(dev_info));
1939 rte_eth_dev_info_get(res->port_id, &dev_info);
1940 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1941 res->size > ETH_RSS_RETA_SIZE_512) {
1942 printf("Invalid redirection table size: %u\n", res->size);
1946 memset(reta_conf, 0, sizeof(reta_conf));
1947 if (showport_parse_reta_config(reta_conf, res->size,
1948 res->list_of_items) < 0) {
1949 printf("Invalid string: %s for reta masks\n",
1950 res->list_of_items);
1953 port_rss_reta_info(res->port_id, reta_conf, res->size);
1956 cmdline_parse_token_string_t cmd_showport_reta_show =
1957 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1958 cmdline_parse_token_string_t cmd_showport_reta_port =
1959 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1960 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1961 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1962 cmdline_parse_token_string_t cmd_showport_reta_rss =
1963 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1964 cmdline_parse_token_string_t cmd_showport_reta_reta =
1965 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1966 cmdline_parse_token_num_t cmd_showport_reta_size =
1967 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1968 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1969 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1970 list_of_items, NULL);
1972 cmdline_parse_inst_t cmd_showport_reta = {
1973 .f = cmd_showport_reta_parsed,
1975 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1977 (void *)&cmd_showport_reta_show,
1978 (void *)&cmd_showport_reta_port,
1979 (void *)&cmd_showport_reta_port_id,
1980 (void *)&cmd_showport_reta_rss,
1981 (void *)&cmd_showport_reta_reta,
1982 (void *)&cmd_showport_reta_size,
1983 (void *)&cmd_showport_reta_list_of_items,
1988 /* *** Show RSS hash configuration *** */
1989 struct cmd_showport_rss_hash {
1990 cmdline_fixed_string_t show;
1991 cmdline_fixed_string_t port;
1993 cmdline_fixed_string_t rss_hash;
1994 cmdline_fixed_string_t rss_type;
1995 cmdline_fixed_string_t key; /* optional argument */
1998 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1999 __attribute__((unused)) struct cmdline *cl,
2002 struct cmd_showport_rss_hash *res = parsed_result;
2004 port_rss_hash_conf_show(res->port_id, res->rss_type,
2005 show_rss_key != NULL);
2008 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2009 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2010 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2011 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2012 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2013 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2014 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2015 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2017 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2018 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2019 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2020 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2021 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2022 "ipv6-tcp-ex#ipv6-udp-ex");
2023 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2024 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2026 cmdline_parse_inst_t cmd_showport_rss_hash = {
2027 .f = cmd_showport_rss_hash_parsed,
2030 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2031 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2032 "ipv6-sctp|ipv6-other|l2-payload|"
2033 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2035 (void *)&cmd_showport_rss_hash_show,
2036 (void *)&cmd_showport_rss_hash_port,
2037 (void *)&cmd_showport_rss_hash_port_id,
2038 (void *)&cmd_showport_rss_hash_rss_hash,
2039 (void *)&cmd_showport_rss_hash_rss_hash_info,
2044 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2045 .f = cmd_showport_rss_hash_parsed,
2048 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2049 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2050 "ipv6-sctp|ipv6-other|l2-payload|"
2051 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2053 (void *)&cmd_showport_rss_hash_show,
2054 (void *)&cmd_showport_rss_hash_port,
2055 (void *)&cmd_showport_rss_hash_port_id,
2056 (void *)&cmd_showport_rss_hash_rss_hash,
2057 (void *)&cmd_showport_rss_hash_rss_hash_info,
2058 (void *)&cmd_showport_rss_hash_rss_key,
2063 /* *** Configure DCB *** */
2064 struct cmd_config_dcb {
2065 cmdline_fixed_string_t port;
2066 cmdline_fixed_string_t config;
2068 cmdline_fixed_string_t dcb;
2069 cmdline_fixed_string_t vt;
2070 cmdline_fixed_string_t vt_en;
2072 cmdline_fixed_string_t pfc;
2073 cmdline_fixed_string_t pfc_en;
2077 cmd_config_dcb_parsed(void *parsed_result,
2078 __attribute__((unused)) struct cmdline *cl,
2079 __attribute__((unused)) void *data)
2081 struct cmd_config_dcb *res = parsed_result;
2082 portid_t port_id = res->port_id;
2083 struct rte_port *port;
2087 port = &ports[port_id];
2088 /** Check if the port is not started **/
2089 if (port->port_status != RTE_PORT_STOPPED) {
2090 printf("Please stop port %d first\n", port_id);
2094 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2095 printf("The invalid number of traffic class,"
2096 " only 4 or 8 allowed.\n");
2100 if (nb_fwd_lcores < res->num_tcs) {
2101 printf("nb_cores shouldn't be less than number of TCs.\n");
2104 if (!strncmp(res->pfc_en, "on", 2))
2109 /* DCB in VT mode */
2110 if (!strncmp(res->vt_en, "on", 2))
2111 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2112 (enum rte_eth_nb_tcs)res->num_tcs,
2115 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2116 (enum rte_eth_nb_tcs)res->num_tcs,
2121 printf("Cannot initialize network ports.\n");
2125 cmd_reconfig_device_queue(port_id, 1, 1);
2128 cmdline_parse_token_string_t cmd_config_dcb_port =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2130 cmdline_parse_token_string_t cmd_config_dcb_config =
2131 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2132 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2133 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2134 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2136 cmdline_parse_token_string_t cmd_config_dcb_vt =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2138 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2139 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2140 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2141 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2142 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2143 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2144 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2145 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2147 cmdline_parse_inst_t cmd_config_dcb = {
2148 .f = cmd_config_dcb_parsed,
2150 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2152 (void *)&cmd_config_dcb_port,
2153 (void *)&cmd_config_dcb_config,
2154 (void *)&cmd_config_dcb_port_id,
2155 (void *)&cmd_config_dcb_dcb,
2156 (void *)&cmd_config_dcb_vt,
2157 (void *)&cmd_config_dcb_vt_en,
2158 (void *)&cmd_config_dcb_num_tcs,
2159 (void *)&cmd_config_dcb_pfc,
2160 (void *)&cmd_config_dcb_pfc_en,
2165 /* *** configure number of packets per burst *** */
2166 struct cmd_config_burst {
2167 cmdline_fixed_string_t port;
2168 cmdline_fixed_string_t keyword;
2169 cmdline_fixed_string_t all;
2170 cmdline_fixed_string_t name;
2175 cmd_config_burst_parsed(void *parsed_result,
2176 __attribute__((unused)) struct cmdline *cl,
2177 __attribute__((unused)) void *data)
2179 struct cmd_config_burst *res = parsed_result;
2181 if (!all_ports_stopped()) {
2182 printf("Please stop all ports first\n");
2186 if (!strcmp(res->name, "burst")) {
2187 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2188 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2191 nb_pkt_per_burst = res->value;
2193 printf("Unknown parameter\n");
2199 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2202 cmdline_parse_token_string_t cmd_config_burst_port =
2203 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2204 cmdline_parse_token_string_t cmd_config_burst_keyword =
2205 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2206 cmdline_parse_token_string_t cmd_config_burst_all =
2207 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2208 cmdline_parse_token_string_t cmd_config_burst_name =
2209 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2210 cmdline_parse_token_num_t cmd_config_burst_value =
2211 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2213 cmdline_parse_inst_t cmd_config_burst = {
2214 .f = cmd_config_burst_parsed,
2216 .help_str = "port config all burst value",
2218 (void *)&cmd_config_burst_port,
2219 (void *)&cmd_config_burst_keyword,
2220 (void *)&cmd_config_burst_all,
2221 (void *)&cmd_config_burst_name,
2222 (void *)&cmd_config_burst_value,
2227 /* *** configure rx/tx queues *** */
2228 struct cmd_config_thresh {
2229 cmdline_fixed_string_t port;
2230 cmdline_fixed_string_t keyword;
2231 cmdline_fixed_string_t all;
2232 cmdline_fixed_string_t name;
2237 cmd_config_thresh_parsed(void *parsed_result,
2238 __attribute__((unused)) struct cmdline *cl,
2239 __attribute__((unused)) void *data)
2241 struct cmd_config_thresh *res = parsed_result;
2243 if (!all_ports_stopped()) {
2244 printf("Please stop all ports first\n");
2248 if (!strcmp(res->name, "txpt"))
2249 tx_pthresh = res->value;
2250 else if(!strcmp(res->name, "txht"))
2251 tx_hthresh = res->value;
2252 else if(!strcmp(res->name, "txwt"))
2253 tx_wthresh = res->value;
2254 else if(!strcmp(res->name, "rxpt"))
2255 rx_pthresh = res->value;
2256 else if(!strcmp(res->name, "rxht"))
2257 rx_hthresh = res->value;
2258 else if(!strcmp(res->name, "rxwt"))
2259 rx_wthresh = res->value;
2261 printf("Unknown parameter\n");
2267 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2270 cmdline_parse_token_string_t cmd_config_thresh_port =
2271 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2272 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2273 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2274 cmdline_parse_token_string_t cmd_config_thresh_all =
2275 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2276 cmdline_parse_token_string_t cmd_config_thresh_name =
2277 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2278 "txpt#txht#txwt#rxpt#rxht#rxwt");
2279 cmdline_parse_token_num_t cmd_config_thresh_value =
2280 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2282 cmdline_parse_inst_t cmd_config_thresh = {
2283 .f = cmd_config_thresh_parsed,
2285 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2287 (void *)&cmd_config_thresh_port,
2288 (void *)&cmd_config_thresh_keyword,
2289 (void *)&cmd_config_thresh_all,
2290 (void *)&cmd_config_thresh_name,
2291 (void *)&cmd_config_thresh_value,
2296 /* *** configure free/rs threshold *** */
2297 struct cmd_config_threshold {
2298 cmdline_fixed_string_t port;
2299 cmdline_fixed_string_t keyword;
2300 cmdline_fixed_string_t all;
2301 cmdline_fixed_string_t name;
2306 cmd_config_threshold_parsed(void *parsed_result,
2307 __attribute__((unused)) struct cmdline *cl,
2308 __attribute__((unused)) void *data)
2310 struct cmd_config_threshold *res = parsed_result;
2312 if (!all_ports_stopped()) {
2313 printf("Please stop all ports first\n");
2317 if (!strcmp(res->name, "txfreet"))
2318 tx_free_thresh = res->value;
2319 else if (!strcmp(res->name, "txrst"))
2320 tx_rs_thresh = res->value;
2321 else if (!strcmp(res->name, "rxfreet"))
2322 rx_free_thresh = res->value;
2324 printf("Unknown parameter\n");
2330 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2333 cmdline_parse_token_string_t cmd_config_threshold_port =
2334 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2335 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2336 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2338 cmdline_parse_token_string_t cmd_config_threshold_all =
2339 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2340 cmdline_parse_token_string_t cmd_config_threshold_name =
2341 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2342 "txfreet#txrst#rxfreet");
2343 cmdline_parse_token_num_t cmd_config_threshold_value =
2344 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2346 cmdline_parse_inst_t cmd_config_threshold = {
2347 .f = cmd_config_threshold_parsed,
2349 .help_str = "port config all txfreet|txrst|rxfreet value",
2351 (void *)&cmd_config_threshold_port,
2352 (void *)&cmd_config_threshold_keyword,
2353 (void *)&cmd_config_threshold_all,
2354 (void *)&cmd_config_threshold_name,
2355 (void *)&cmd_config_threshold_value,
2361 struct cmd_stop_result {
2362 cmdline_fixed_string_t stop;
2365 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2366 __attribute__((unused)) struct cmdline *cl,
2367 __attribute__((unused)) void *data)
2369 stop_packet_forwarding();
2372 cmdline_parse_token_string_t cmd_stop_stop =
2373 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2375 cmdline_parse_inst_t cmd_stop = {
2376 .f = cmd_stop_parsed,
2378 .help_str = "stop - stop packet forwarding",
2380 (void *)&cmd_stop_stop,
2385 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2388 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2389 unsigned int *parsed_items, int check_unique_values)
2391 unsigned int nb_item;
2399 * First parse all items in the list and store their value.
2404 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2406 if ((c >= '0') && (c <= '9')) {
2407 value = (unsigned int) (value * 10 + (c - '0'));
2412 printf("character %c is not a decimal digit\n", c);
2416 printf("No valid value before comma\n");
2419 if (nb_item < max_items) {
2420 parsed_items[nb_item] = value;
2426 if (nb_item >= max_items) {
2427 printf("Number of %s = %u > %u (maximum items)\n",
2428 item_name, nb_item + 1, max_items);
2431 parsed_items[nb_item++] = value;
2432 if (! check_unique_values)
2436 * Then, check that all values in the list are differents.
2437 * No optimization here...
2439 for (i = 0; i < nb_item; i++) {
2440 for (j = i + 1; j < nb_item; j++) {
2441 if (parsed_items[j] == parsed_items[i]) {
2442 printf("duplicated %s %u at index %u and %u\n",
2443 item_name, parsed_items[i], i, j);
2451 struct cmd_set_list_result {
2452 cmdline_fixed_string_t cmd_keyword;
2453 cmdline_fixed_string_t list_name;
2454 cmdline_fixed_string_t list_of_items;
2457 static void cmd_set_list_parsed(void *parsed_result,
2458 __attribute__((unused)) struct cmdline *cl,
2459 __attribute__((unused)) void *data)
2461 struct cmd_set_list_result *res;
2463 unsigned int lcorelist[RTE_MAX_LCORE];
2464 unsigned int portlist[RTE_MAX_ETHPORTS];
2466 unsigned int nb_item;
2468 if (test_done == 0) {
2469 printf("Please stop forwarding first\n");
2473 res = parsed_result;
2474 if (!strcmp(res->list_name, "corelist")) {
2475 nb_item = parse_item_list(res->list_of_items, "core",
2477 parsed_items.lcorelist, 1);
2479 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2482 if (!strcmp(res->list_name, "portlist")) {
2483 nb_item = parse_item_list(res->list_of_items, "port",
2485 parsed_items.portlist, 1);
2487 set_fwd_ports_list(parsed_items.portlist, nb_item);
2491 cmdline_parse_token_string_t cmd_set_list_keyword =
2492 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2494 cmdline_parse_token_string_t cmd_set_list_name =
2495 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2496 "corelist#portlist");
2497 cmdline_parse_token_string_t cmd_set_list_of_items =
2498 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2501 cmdline_parse_inst_t cmd_set_fwd_list = {
2502 .f = cmd_set_list_parsed,
2504 .help_str = "set corelist|portlist x[,y]*",
2506 (void *)&cmd_set_list_keyword,
2507 (void *)&cmd_set_list_name,
2508 (void *)&cmd_set_list_of_items,
2513 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2515 struct cmd_setmask_result {
2516 cmdline_fixed_string_t set;
2517 cmdline_fixed_string_t mask;
2521 static void cmd_set_mask_parsed(void *parsed_result,
2522 __attribute__((unused)) struct cmdline *cl,
2523 __attribute__((unused)) void *data)
2525 struct cmd_setmask_result *res = parsed_result;
2527 if (test_done == 0) {
2528 printf("Please stop forwarding first\n");
2531 if (!strcmp(res->mask, "coremask"))
2532 set_fwd_lcores_mask(res->hexavalue);
2533 else if (!strcmp(res->mask, "portmask"))
2534 set_fwd_ports_mask(res->hexavalue);
2537 cmdline_parse_token_string_t cmd_setmask_set =
2538 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2539 cmdline_parse_token_string_t cmd_setmask_mask =
2540 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2541 "coremask#portmask");
2542 cmdline_parse_token_num_t cmd_setmask_value =
2543 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2545 cmdline_parse_inst_t cmd_set_fwd_mask = {
2546 .f = cmd_set_mask_parsed,
2548 .help_str = "set coremask|portmask hexadecimal value",
2550 (void *)&cmd_setmask_set,
2551 (void *)&cmd_setmask_mask,
2552 (void *)&cmd_setmask_value,
2558 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2560 struct cmd_set_result {
2561 cmdline_fixed_string_t set;
2562 cmdline_fixed_string_t what;
2566 static void cmd_set_parsed(void *parsed_result,
2567 __attribute__((unused)) struct cmdline *cl,
2568 __attribute__((unused)) void *data)
2570 struct cmd_set_result *res = parsed_result;
2571 if (!strcmp(res->what, "nbport"))
2572 set_fwd_ports_number(res->value);
2573 else if (!strcmp(res->what, "nbcore"))
2574 set_fwd_lcores_number(res->value);
2575 else if (!strcmp(res->what, "burst"))
2576 set_nb_pkt_per_burst(res->value);
2577 else if (!strcmp(res->what, "verbose"))
2578 set_verbose_level(res->value);
2581 cmdline_parse_token_string_t cmd_set_set =
2582 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2583 cmdline_parse_token_string_t cmd_set_what =
2584 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2585 "nbport#nbcore#burst#verbose");
2586 cmdline_parse_token_num_t cmd_set_value =
2587 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2589 cmdline_parse_inst_t cmd_set_numbers = {
2590 .f = cmd_set_parsed,
2592 .help_str = "set nbport|nbcore|burst|verbose value",
2594 (void *)&cmd_set_set,
2595 (void *)&cmd_set_what,
2596 (void *)&cmd_set_value,
2601 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2603 struct cmd_set_txpkts_result {
2604 cmdline_fixed_string_t cmd_keyword;
2605 cmdline_fixed_string_t txpkts;
2606 cmdline_fixed_string_t seg_lengths;
2610 cmd_set_txpkts_parsed(void *parsed_result,
2611 __attribute__((unused)) struct cmdline *cl,
2612 __attribute__((unused)) void *data)
2614 struct cmd_set_txpkts_result *res;
2615 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2616 unsigned int nb_segs;
2618 res = parsed_result;
2619 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2620 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2622 set_tx_pkt_segments(seg_lengths, nb_segs);
2625 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2626 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2627 cmd_keyword, "set");
2628 cmdline_parse_token_string_t cmd_set_txpkts_name =
2629 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2631 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2632 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2635 cmdline_parse_inst_t cmd_set_txpkts = {
2636 .f = cmd_set_txpkts_parsed,
2638 .help_str = "set txpkts x[,y]*",
2640 (void *)&cmd_set_txpkts_keyword,
2641 (void *)&cmd_set_txpkts_name,
2642 (void *)&cmd_set_txpkts_lengths,
2647 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2648 struct cmd_rx_vlan_filter_all_result {
2649 cmdline_fixed_string_t rx_vlan;
2650 cmdline_fixed_string_t what;
2651 cmdline_fixed_string_t all;
2656 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2657 __attribute__((unused)) struct cmdline *cl,
2658 __attribute__((unused)) void *data)
2660 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2662 if (!strcmp(res->what, "add"))
2663 rx_vlan_all_filter_set(res->port_id, 1);
2665 rx_vlan_all_filter_set(res->port_id, 0);
2668 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2669 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2670 rx_vlan, "rx_vlan");
2671 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2672 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2674 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2675 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2677 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2678 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2681 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2682 .f = cmd_rx_vlan_filter_all_parsed,
2684 .help_str = "add/remove all identifiers to/from the set of VLAN "
2685 "Identifiers filtered by a port",
2687 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2688 (void *)&cmd_rx_vlan_filter_all_what,
2689 (void *)&cmd_rx_vlan_filter_all_all,
2690 (void *)&cmd_rx_vlan_filter_all_portid,
2695 /* *** VLAN OFFLOAD SET ON A PORT *** */
2696 struct cmd_vlan_offload_result {
2697 cmdline_fixed_string_t vlan;
2698 cmdline_fixed_string_t set;
2699 cmdline_fixed_string_t what;
2700 cmdline_fixed_string_t on;
2701 cmdline_fixed_string_t port_id;
2705 cmd_vlan_offload_parsed(void *parsed_result,
2706 __attribute__((unused)) struct cmdline *cl,
2707 __attribute__((unused)) void *data)
2710 struct cmd_vlan_offload_result *res = parsed_result;
2713 portid_t port_id = 0;
2717 len = strnlen(str, STR_TOKEN_SIZE);
2719 /* Get port_id first */
2727 tmp = strtoul(str, NULL, 0);
2728 /* If port_id greater that what portid_t can represent, return */
2729 if(tmp >= RTE_MAX_ETHPORTS)
2731 port_id = (portid_t)tmp;
2733 if (!strcmp(res->on, "on"))
2738 if (!strcmp(res->what, "strip"))
2739 rx_vlan_strip_set(port_id, on);
2740 else if(!strcmp(res->what, "stripq")){
2741 uint16_t queue_id = 0;
2743 /* No queue_id, return */
2745 printf("must specify (port,queue_id)\n");
2748 tmp = strtoul(str + i + 1, NULL, 0);
2749 /* If queue_id greater that what 16-bits can represent, return */
2753 queue_id = (uint16_t)tmp;
2754 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2756 else if (!strcmp(res->what, "filter"))
2757 rx_vlan_filter_set(port_id, on);
2759 vlan_extend_set(port_id, on);
2764 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2765 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2767 cmdline_parse_token_string_t cmd_vlan_offload_set =
2768 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2770 cmdline_parse_token_string_t cmd_vlan_offload_what =
2771 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2772 what, "strip#filter#qinq#stripq");
2773 cmdline_parse_token_string_t cmd_vlan_offload_on =
2774 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2776 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2777 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2780 cmdline_parse_inst_t cmd_vlan_offload = {
2781 .f = cmd_vlan_offload_parsed,
2783 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2784 " qinq(extended) for both rx/tx sides ",
2786 (void *)&cmd_vlan_offload_vlan,
2787 (void *)&cmd_vlan_offload_set,
2788 (void *)&cmd_vlan_offload_what,
2789 (void *)&cmd_vlan_offload_on,
2790 (void *)&cmd_vlan_offload_portid,
2795 /* *** VLAN TPID SET ON A PORT *** */
2796 struct cmd_vlan_tpid_result {
2797 cmdline_fixed_string_t vlan;
2798 cmdline_fixed_string_t set;
2799 cmdline_fixed_string_t what;
2805 cmd_vlan_tpid_parsed(void *parsed_result,
2806 __attribute__((unused)) struct cmdline *cl,
2807 __attribute__((unused)) void *data)
2809 struct cmd_vlan_tpid_result *res = parsed_result;
2810 vlan_tpid_set(res->port_id, res->tp_id);
2814 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2815 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2817 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2818 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2820 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2821 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2823 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2824 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2826 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2827 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2830 cmdline_parse_inst_t cmd_vlan_tpid = {
2831 .f = cmd_vlan_tpid_parsed,
2833 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2835 (void *)&cmd_vlan_tpid_vlan,
2836 (void *)&cmd_vlan_tpid_set,
2837 (void *)&cmd_vlan_tpid_what,
2838 (void *)&cmd_vlan_tpid_tpid,
2839 (void *)&cmd_vlan_tpid_portid,
2844 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2845 struct cmd_rx_vlan_filter_result {
2846 cmdline_fixed_string_t rx_vlan;
2847 cmdline_fixed_string_t what;
2853 cmd_rx_vlan_filter_parsed(void *parsed_result,
2854 __attribute__((unused)) struct cmdline *cl,
2855 __attribute__((unused)) void *data)
2857 struct cmd_rx_vlan_filter_result *res = parsed_result;
2859 if (!strcmp(res->what, "add"))
2860 rx_vft_set(res->port_id, res->vlan_id, 1);
2862 rx_vft_set(res->port_id, res->vlan_id, 0);
2865 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2866 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2867 rx_vlan, "rx_vlan");
2868 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2869 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2871 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2872 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2874 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2875 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2878 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2879 .f = cmd_rx_vlan_filter_parsed,
2881 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2882 "Identifiers filtered by a port",
2884 (void *)&cmd_rx_vlan_filter_rx_vlan,
2885 (void *)&cmd_rx_vlan_filter_what,
2886 (void *)&cmd_rx_vlan_filter_vlanid,
2887 (void *)&cmd_rx_vlan_filter_portid,
2892 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2893 struct cmd_tx_vlan_set_result {
2894 cmdline_fixed_string_t tx_vlan;
2895 cmdline_fixed_string_t set;
2901 cmd_tx_vlan_set_parsed(void *parsed_result,
2902 __attribute__((unused)) struct cmdline *cl,
2903 __attribute__((unused)) void *data)
2905 struct cmd_tx_vlan_set_result *res = parsed_result;
2906 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2908 if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) {
2909 printf("Error, as QinQ has been enabled.\n");
2913 tx_vlan_set(res->port_id, res->vlan_id);
2916 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2917 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2918 tx_vlan, "tx_vlan");
2919 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2920 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2922 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2923 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2925 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2926 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2929 cmdline_parse_inst_t cmd_tx_vlan_set = {
2930 .f = cmd_tx_vlan_set_parsed,
2932 .help_str = "enable hardware insertion of a single VLAN header "
2933 "with a given TAG Identifier in packets sent on a port",
2935 (void *)&cmd_tx_vlan_set_tx_vlan,
2936 (void *)&cmd_tx_vlan_set_set,
2937 (void *)&cmd_tx_vlan_set_portid,
2938 (void *)&cmd_tx_vlan_set_vlanid,
2943 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
2944 struct cmd_tx_vlan_set_qinq_result {
2945 cmdline_fixed_string_t tx_vlan;
2946 cmdline_fixed_string_t set;
2949 uint16_t vlan_id_outer;
2953 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
2954 __attribute__((unused)) struct cmdline *cl,
2955 __attribute__((unused)) void *data)
2957 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
2958 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2960 if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) {
2961 printf("Error, as QinQ hasn't been enabled.\n");
2965 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
2968 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
2969 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2970 tx_vlan, "tx_vlan");
2971 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
2972 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2974 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
2975 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2977 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
2978 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2980 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
2981 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2982 vlan_id_outer, UINT16);
2984 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
2985 .f = cmd_tx_vlan_set_qinq_parsed,
2987 .help_str = "enable hardware insertion of double VLAN header "
2988 "with given TAG Identifiers in packets sent on a port",
2990 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
2991 (void *)&cmd_tx_vlan_set_qinq_set,
2992 (void *)&cmd_tx_vlan_set_qinq_portid,
2993 (void *)&cmd_tx_vlan_set_qinq_vlanid,
2994 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
2999 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3000 struct cmd_tx_vlan_set_pvid_result {
3001 cmdline_fixed_string_t tx_vlan;
3002 cmdline_fixed_string_t set;
3003 cmdline_fixed_string_t pvid;
3006 cmdline_fixed_string_t mode;
3010 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3011 __attribute__((unused)) struct cmdline *cl,
3012 __attribute__((unused)) void *data)
3014 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3016 if (strcmp(res->mode, "on") == 0)
3017 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3019 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3022 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3023 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3024 tx_vlan, "tx_vlan");
3025 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3026 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3028 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3029 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3031 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3032 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3034 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3035 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3037 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3038 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3041 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3042 .f = cmd_tx_vlan_set_pvid_parsed,
3044 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3046 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3047 (void *)&cmd_tx_vlan_set_pvid_set,
3048 (void *)&cmd_tx_vlan_set_pvid_pvid,
3049 (void *)&cmd_tx_vlan_set_pvid_port_id,
3050 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3051 (void *)&cmd_tx_vlan_set_pvid_mode,
3056 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3057 struct cmd_tx_vlan_reset_result {
3058 cmdline_fixed_string_t tx_vlan;
3059 cmdline_fixed_string_t reset;
3064 cmd_tx_vlan_reset_parsed(void *parsed_result,
3065 __attribute__((unused)) struct cmdline *cl,
3066 __attribute__((unused)) void *data)
3068 struct cmd_tx_vlan_reset_result *res = parsed_result;
3070 tx_vlan_reset(res->port_id);
3073 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3074 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3075 tx_vlan, "tx_vlan");
3076 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3077 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3079 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3080 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3083 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3084 .f = cmd_tx_vlan_reset_parsed,
3086 .help_str = "disable hardware insertion of a VLAN header in packets "
3089 (void *)&cmd_tx_vlan_reset_tx_vlan,
3090 (void *)&cmd_tx_vlan_reset_reset,
3091 (void *)&cmd_tx_vlan_reset_portid,
3097 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3098 struct cmd_csum_result {
3099 cmdline_fixed_string_t csum;
3100 cmdline_fixed_string_t mode;
3101 cmdline_fixed_string_t proto;
3102 cmdline_fixed_string_t hwsw;
3107 csum_show(int port_id)
3109 struct rte_eth_dev_info dev_info;
3112 ol_flags = ports[port_id].tx_ol_flags;
3113 printf("Parse tunnel is %s\n",
3114 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3115 printf("IP checksum offload is %s\n",
3116 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3117 printf("UDP checksum offload is %s\n",
3118 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3119 printf("TCP checksum offload is %s\n",
3120 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3121 printf("SCTP checksum offload is %s\n",
3122 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3123 printf("Outer-Ip checksum offload is %s\n",
3124 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3126 /* display warnings if configuration is not supported by the NIC */
3127 rte_eth_dev_info_get(port_id, &dev_info);
3128 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3129 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3130 printf("Warning: hardware IP checksum enabled but not "
3131 "supported by port %d\n", port_id);
3133 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3134 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3135 printf("Warning: hardware UDP checksum enabled but not "
3136 "supported by port %d\n", port_id);
3138 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3139 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3140 printf("Warning: hardware TCP checksum enabled but not "
3141 "supported by port %d\n", port_id);
3143 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3144 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3145 printf("Warning: hardware SCTP checksum enabled but not "
3146 "supported by port %d\n", port_id);
3148 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3149 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3150 printf("Warning: hardware outer IP checksum enabled but not "
3151 "supported by port %d\n", port_id);
3156 cmd_csum_parsed(void *parsed_result,
3157 __attribute__((unused)) struct cmdline *cl,
3158 __attribute__((unused)) void *data)
3160 struct cmd_csum_result *res = parsed_result;
3164 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3165 printf("invalid port %d\n", res->port_id);
3169 if (!strcmp(res->mode, "set")) {
3171 if (!strcmp(res->hwsw, "hw"))
3174 if (!strcmp(res->proto, "ip")) {
3175 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3176 } else if (!strcmp(res->proto, "udp")) {
3177 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3178 } else if (!strcmp(res->proto, "tcp")) {
3179 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3180 } else if (!strcmp(res->proto, "sctp")) {
3181 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3182 } else if (!strcmp(res->proto, "outer-ip")) {
3183 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3187 ports[res->port_id].tx_ol_flags |= mask;
3189 ports[res->port_id].tx_ol_flags &= (~mask);
3191 csum_show(res->port_id);
3194 cmdline_parse_token_string_t cmd_csum_csum =
3195 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3197 cmdline_parse_token_string_t cmd_csum_mode =
3198 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3200 cmdline_parse_token_string_t cmd_csum_proto =
3201 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3202 proto, "ip#tcp#udp#sctp#outer-ip");
3203 cmdline_parse_token_string_t cmd_csum_hwsw =
3204 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3206 cmdline_parse_token_num_t cmd_csum_portid =
3207 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3210 cmdline_parse_inst_t cmd_csum_set = {
3211 .f = cmd_csum_parsed,
3213 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3214 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3216 (void *)&cmd_csum_csum,
3217 (void *)&cmd_csum_mode,
3218 (void *)&cmd_csum_proto,
3219 (void *)&cmd_csum_hwsw,
3220 (void *)&cmd_csum_portid,
3225 cmdline_parse_token_string_t cmd_csum_mode_show =
3226 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3229 cmdline_parse_inst_t cmd_csum_show = {
3230 .f = cmd_csum_parsed,
3232 .help_str = "show checksum offload configuration: csum show <port>",
3234 (void *)&cmd_csum_csum,
3235 (void *)&cmd_csum_mode_show,
3236 (void *)&cmd_csum_portid,
3241 /* Enable/disable tunnel parsing */
3242 struct cmd_csum_tunnel_result {
3243 cmdline_fixed_string_t csum;
3244 cmdline_fixed_string_t parse;
3245 cmdline_fixed_string_t onoff;
3250 cmd_csum_tunnel_parsed(void *parsed_result,
3251 __attribute__((unused)) struct cmdline *cl,
3252 __attribute__((unused)) void *data)
3254 struct cmd_csum_tunnel_result *res = parsed_result;
3256 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3259 if (!strcmp(res->onoff, "on"))
3260 ports[res->port_id].tx_ol_flags |=
3261 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3263 ports[res->port_id].tx_ol_flags &=
3264 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3266 csum_show(res->port_id);
3269 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3270 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3272 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3273 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3274 parse, "parse_tunnel");
3275 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3276 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3278 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3279 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3282 cmdline_parse_inst_t cmd_csum_tunnel = {
3283 .f = cmd_csum_tunnel_parsed,
3285 .help_str = "enable/disable parsing of tunnels for csum engine: "
3286 "csum parse_tunnel on|off <tx-port>",
3288 (void *)&cmd_csum_tunnel_csum,
3289 (void *)&cmd_csum_tunnel_parse,
3290 (void *)&cmd_csum_tunnel_onoff,
3291 (void *)&cmd_csum_tunnel_portid,
3296 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3297 struct cmd_tso_set_result {
3298 cmdline_fixed_string_t tso;
3299 cmdline_fixed_string_t mode;
3305 cmd_tso_set_parsed(void *parsed_result,
3306 __attribute__((unused)) struct cmdline *cl,
3307 __attribute__((unused)) void *data)
3309 struct cmd_tso_set_result *res = parsed_result;
3310 struct rte_eth_dev_info dev_info;
3312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3315 if (!strcmp(res->mode, "set"))
3316 ports[res->port_id].tso_segsz = res->tso_segsz;
3318 if (ports[res->port_id].tso_segsz == 0)
3319 printf("TSO is disabled\n");
3321 printf("TSO segment size is %d\n",
3322 ports[res->port_id].tso_segsz);
3324 /* display warnings if configuration is not supported by the NIC */
3325 rte_eth_dev_info_get(res->port_id, &dev_info);
3326 if ((ports[res->port_id].tso_segsz != 0) &&
3327 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3328 printf("Warning: TSO enabled but not "
3329 "supported by port %d\n", res->port_id);
3333 cmdline_parse_token_string_t cmd_tso_set_tso =
3334 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3336 cmdline_parse_token_string_t cmd_tso_set_mode =
3337 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3339 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3340 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3342 cmdline_parse_token_num_t cmd_tso_set_portid =
3343 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3346 cmdline_parse_inst_t cmd_tso_set = {
3347 .f = cmd_tso_set_parsed,
3349 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3350 "tso set <tso_segsz> <port>",
3352 (void *)&cmd_tso_set_tso,
3353 (void *)&cmd_tso_set_mode,
3354 (void *)&cmd_tso_set_tso_segsz,
3355 (void *)&cmd_tso_set_portid,
3360 cmdline_parse_token_string_t cmd_tso_show_mode =
3361 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3365 cmdline_parse_inst_t cmd_tso_show = {
3366 .f = cmd_tso_set_parsed,
3368 .help_str = "Show TSO segment size for csum engine: "
3371 (void *)&cmd_tso_set_tso,
3372 (void *)&cmd_tso_show_mode,
3373 (void *)&cmd_tso_set_portid,
3378 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3379 struct cmd_set_flush_rx {
3380 cmdline_fixed_string_t set;
3381 cmdline_fixed_string_t flush_rx;
3382 cmdline_fixed_string_t mode;
3386 cmd_set_flush_rx_parsed(void *parsed_result,
3387 __attribute__((unused)) struct cmdline *cl,
3388 __attribute__((unused)) void *data)
3390 struct cmd_set_flush_rx *res = parsed_result;
3391 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3394 cmdline_parse_token_string_t cmd_setflushrx_set =
3395 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3397 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3398 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3399 flush_rx, "flush_rx");
3400 cmdline_parse_token_string_t cmd_setflushrx_mode =
3401 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3405 cmdline_parse_inst_t cmd_set_flush_rx = {
3406 .f = cmd_set_flush_rx_parsed,
3407 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3410 (void *)&cmd_setflushrx_set,
3411 (void *)&cmd_setflushrx_flush_rx,
3412 (void *)&cmd_setflushrx_mode,
3417 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3418 struct cmd_set_link_check {
3419 cmdline_fixed_string_t set;
3420 cmdline_fixed_string_t link_check;
3421 cmdline_fixed_string_t mode;
3425 cmd_set_link_check_parsed(void *parsed_result,
3426 __attribute__((unused)) struct cmdline *cl,
3427 __attribute__((unused)) void *data)
3429 struct cmd_set_link_check *res = parsed_result;
3430 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3433 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3434 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3436 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3437 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3438 link_check, "link_check");
3439 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3440 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3444 cmdline_parse_inst_t cmd_set_link_check = {
3445 .f = cmd_set_link_check_parsed,
3446 .help_str = "set link_check on|off: enable/disable link status check "
3447 "when starting/stopping a port",
3450 (void *)&cmd_setlinkcheck_set,
3451 (void *)&cmd_setlinkcheck_link_check,
3452 (void *)&cmd_setlinkcheck_mode,
3457 #ifdef RTE_NIC_BYPASS
3458 /* *** SET NIC BYPASS MODE *** */
3459 struct cmd_set_bypass_mode_result {
3460 cmdline_fixed_string_t set;
3461 cmdline_fixed_string_t bypass;
3462 cmdline_fixed_string_t mode;
3463 cmdline_fixed_string_t value;
3468 cmd_set_bypass_mode_parsed(void *parsed_result,
3469 __attribute__((unused)) struct cmdline *cl,
3470 __attribute__((unused)) void *data)
3472 struct cmd_set_bypass_mode_result *res = parsed_result;
3473 portid_t port_id = res->port_id;
3474 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3476 if (!bypass_is_supported(port_id))
3479 if (!strcmp(res->value, "bypass"))
3480 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3481 else if (!strcmp(res->value, "isolate"))
3482 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3484 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3486 /* Set the bypass mode for the relevant port. */
3487 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3488 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3492 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3493 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3495 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3496 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3498 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3499 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3501 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3502 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3503 value, "normal#bypass#isolate");
3504 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3505 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3508 cmdline_parse_inst_t cmd_set_bypass_mode = {
3509 .f = cmd_set_bypass_mode_parsed,
3510 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3511 "Set the NIC bypass mode for port_id",
3514 (void *)&cmd_setbypass_mode_set,
3515 (void *)&cmd_setbypass_mode_bypass,
3516 (void *)&cmd_setbypass_mode_mode,
3517 (void *)&cmd_setbypass_mode_value,
3518 (void *)&cmd_setbypass_mode_port,
3523 /* *** SET NIC BYPASS EVENT *** */
3524 struct cmd_set_bypass_event_result {
3525 cmdline_fixed_string_t set;
3526 cmdline_fixed_string_t bypass;
3527 cmdline_fixed_string_t event;
3528 cmdline_fixed_string_t event_value;
3529 cmdline_fixed_string_t mode;
3530 cmdline_fixed_string_t mode_value;
3535 cmd_set_bypass_event_parsed(void *parsed_result,
3536 __attribute__((unused)) struct cmdline *cl,
3537 __attribute__((unused)) void *data)
3540 struct cmd_set_bypass_event_result *res = parsed_result;
3541 portid_t port_id = res->port_id;
3542 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3543 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3545 if (!bypass_is_supported(port_id))
3548 if (!strcmp(res->event_value, "timeout"))
3549 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3550 else if (!strcmp(res->event_value, "os_on"))
3551 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3552 else if (!strcmp(res->event_value, "os_off"))
3553 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3554 else if (!strcmp(res->event_value, "power_on"))
3555 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3556 else if (!strcmp(res->event_value, "power_off"))
3557 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3559 bypass_event = RTE_BYPASS_EVENT_NONE;
3561 if (!strcmp(res->mode_value, "bypass"))
3562 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3563 else if (!strcmp(res->mode_value, "isolate"))
3564 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3566 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3568 /* Set the watchdog timeout. */
3569 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3572 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3573 (rc = rte_eth_dev_wd_timeout_store(port_id,
3574 bypass_timeout)) != 0) {
3575 printf("Failed to set timeout value %u "
3576 "for port %d, errto code: %d.\n",
3577 bypass_timeout, port_id, rc);
3581 /* Set the bypass event to transition to bypass mode. */
3582 if (0 != rte_eth_dev_bypass_event_store(port_id,
3583 bypass_event, bypass_mode)) {
3584 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3589 cmdline_parse_token_string_t cmd_setbypass_event_set =
3590 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3592 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3593 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3595 cmdline_parse_token_string_t cmd_setbypass_event_event =
3596 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3598 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3599 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3600 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3601 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3602 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3604 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3605 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3606 mode_value, "normal#bypass#isolate");
3607 cmdline_parse_token_num_t cmd_setbypass_event_port =
3608 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3611 cmdline_parse_inst_t cmd_set_bypass_event = {
3612 .f = cmd_set_bypass_event_parsed,
3613 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3614 "mode (normal|bypass|isolate) (port_id): "
3615 "Set the NIC bypass event mode for port_id",
3618 (void *)&cmd_setbypass_event_set,
3619 (void *)&cmd_setbypass_event_bypass,
3620 (void *)&cmd_setbypass_event_event,
3621 (void *)&cmd_setbypass_event_event_value,
3622 (void *)&cmd_setbypass_event_mode,
3623 (void *)&cmd_setbypass_event_mode_value,
3624 (void *)&cmd_setbypass_event_port,
3630 /* *** SET NIC BYPASS TIMEOUT *** */
3631 struct cmd_set_bypass_timeout_result {
3632 cmdline_fixed_string_t set;
3633 cmdline_fixed_string_t bypass;
3634 cmdline_fixed_string_t timeout;
3635 cmdline_fixed_string_t value;
3639 cmd_set_bypass_timeout_parsed(void *parsed_result,
3640 __attribute__((unused)) struct cmdline *cl,
3641 __attribute__((unused)) void *data)
3643 struct cmd_set_bypass_timeout_result *res = parsed_result;
3645 if (!strcmp(res->value, "1.5"))
3646 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3647 else if (!strcmp(res->value, "2"))
3648 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3649 else if (!strcmp(res->value, "3"))
3650 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3651 else if (!strcmp(res->value, "4"))
3652 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3653 else if (!strcmp(res->value, "8"))
3654 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3655 else if (!strcmp(res->value, "16"))
3656 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3657 else if (!strcmp(res->value, "32"))
3658 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3660 bypass_timeout = RTE_BYPASS_TMT_OFF;
3663 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3664 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3666 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3667 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3669 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3670 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3671 timeout, "timeout");
3672 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3673 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3674 value, "0#1.5#2#3#4#8#16#32");
3676 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3677 .f = cmd_set_bypass_timeout_parsed,
3678 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3679 "Set the NIC bypass watchdog timeout",
3682 (void *)&cmd_setbypass_timeout_set,
3683 (void *)&cmd_setbypass_timeout_bypass,
3684 (void *)&cmd_setbypass_timeout_timeout,
3685 (void *)&cmd_setbypass_timeout_value,
3690 /* *** SHOW NIC BYPASS MODE *** */
3691 struct cmd_show_bypass_config_result {
3692 cmdline_fixed_string_t show;
3693 cmdline_fixed_string_t bypass;
3694 cmdline_fixed_string_t config;
3699 cmd_show_bypass_config_parsed(void *parsed_result,
3700 __attribute__((unused)) struct cmdline *cl,
3701 __attribute__((unused)) void *data)
3703 struct cmd_show_bypass_config_result *res = parsed_result;
3704 uint32_t event_mode;
3705 uint32_t bypass_mode;
3706 portid_t port_id = res->port_id;
3707 uint32_t timeout = bypass_timeout;
3710 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3711 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3712 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3713 {"UNKNOWN", "normal", "bypass", "isolate"};
3714 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3721 int num_events = (sizeof events) / (sizeof events[0]);
3723 if (!bypass_is_supported(port_id))
3726 /* Display the bypass mode.*/
3727 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3728 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3732 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3733 bypass_mode = RTE_BYPASS_MODE_NONE;
3735 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3738 /* Display the bypass timeout.*/
3739 if (!RTE_BYPASS_TMT_VALID(timeout))
3740 timeout = RTE_BYPASS_TMT_OFF;
3742 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3744 /* Display the bypass events and associated modes. */
3745 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3747 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3748 printf("\tFailed to get bypass mode for event = %s\n",
3751 if (!RTE_BYPASS_MODE_VALID(event_mode))
3752 event_mode = RTE_BYPASS_MODE_NONE;
3754 printf("\tbypass event: %-16s = %s\n", events[i],
3760 cmdline_parse_token_string_t cmd_showbypass_config_show =
3761 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3763 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3764 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3766 cmdline_parse_token_string_t cmd_showbypass_config_config =
3767 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3769 cmdline_parse_token_num_t cmd_showbypass_config_port =
3770 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3773 cmdline_parse_inst_t cmd_show_bypass_config = {
3774 .f = cmd_show_bypass_config_parsed,
3775 .help_str = "show bypass config (port_id): "
3776 "Show the NIC bypass config for port_id",
3779 (void *)&cmd_showbypass_config_show,
3780 (void *)&cmd_showbypass_config_bypass,
3781 (void *)&cmd_showbypass_config_config,
3782 (void *)&cmd_showbypass_config_port,
3788 #ifdef RTE_LIBRTE_PMD_BOND
3789 /* *** SET BONDING MODE *** */
3790 struct cmd_set_bonding_mode_result {
3791 cmdline_fixed_string_t set;
3792 cmdline_fixed_string_t bonding;
3793 cmdline_fixed_string_t mode;
3798 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3799 __attribute__((unused)) struct cmdline *cl,
3800 __attribute__((unused)) void *data)
3802 struct cmd_set_bonding_mode_result *res = parsed_result;
3803 portid_t port_id = res->port_id;
3805 /* Set the bonding mode for the relevant port. */
3806 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3807 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3810 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3811 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3813 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3814 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3815 bonding, "bonding");
3816 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3817 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3819 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3820 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3822 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3823 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3826 cmdline_parse_inst_t cmd_set_bonding_mode = {
3827 .f = cmd_set_bonding_mode_parsed,
3828 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3831 (void *) &cmd_setbonding_mode_set,
3832 (void *) &cmd_setbonding_mode_bonding,
3833 (void *) &cmd_setbonding_mode_mode,
3834 (void *) &cmd_setbonding_mode_value,
3835 (void *) &cmd_setbonding_mode_port,
3840 /* *** SET BALANCE XMIT POLICY *** */
3841 struct cmd_set_bonding_balance_xmit_policy_result {
3842 cmdline_fixed_string_t set;
3843 cmdline_fixed_string_t bonding;
3844 cmdline_fixed_string_t balance_xmit_policy;
3846 cmdline_fixed_string_t policy;
3849 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3850 __attribute__((unused)) struct cmdline *cl,
3851 __attribute__((unused)) void *data)
3853 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3854 portid_t port_id = res->port_id;
3857 if (!strcmp(res->policy, "l2")) {
3858 policy = BALANCE_XMIT_POLICY_LAYER2;
3859 } else if (!strcmp(res->policy, "l23")) {
3860 policy = BALANCE_XMIT_POLICY_LAYER23;
3861 } else if (!strcmp(res->policy, "l34")) {
3862 policy = BALANCE_XMIT_POLICY_LAYER34;
3864 printf("\t Invalid xmit policy selection");
3868 /* Set the bonding mode for the relevant port. */
3869 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3870 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3875 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3876 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3878 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3879 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3880 bonding, "bonding");
3881 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3882 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3883 balance_xmit_policy, "balance_xmit_policy");
3884 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3885 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3887 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3888 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3889 policy, "l2#l23#l34");
3891 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3892 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3893 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3896 (void *)&cmd_setbonding_balance_xmit_policy_set,
3897 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3898 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3899 (void *)&cmd_setbonding_balance_xmit_policy_port,
3900 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3905 /* *** SHOW NIC BONDING CONFIGURATION *** */
3906 struct cmd_show_bonding_config_result {
3907 cmdline_fixed_string_t show;
3908 cmdline_fixed_string_t bonding;
3909 cmdline_fixed_string_t config;
3913 static void cmd_show_bonding_config_parsed(void *parsed_result,
3914 __attribute__((unused)) struct cmdline *cl,
3915 __attribute__((unused)) void *data)
3917 struct cmd_show_bonding_config_result *res = parsed_result;
3919 uint8_t slaves[RTE_MAX_ETHPORTS];
3920 int num_slaves, num_active_slaves;
3923 portid_t port_id = res->port_id;
3925 /* Display the bonding mode.*/
3926 bonding_mode = rte_eth_bond_mode_get(port_id);
3927 if (bonding_mode < 0) {
3928 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3931 printf("\tBonding mode: %d\n", bonding_mode);
3933 if (bonding_mode == BONDING_MODE_BALANCE) {
3934 int balance_xmit_policy;
3936 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3937 if (balance_xmit_policy < 0) {
3938 printf("\tFailed to get balance xmit policy for port = %d\n",
3942 printf("\tBalance Xmit Policy: ");
3944 switch (balance_xmit_policy) {
3945 case BALANCE_XMIT_POLICY_LAYER2:
3946 printf("BALANCE_XMIT_POLICY_LAYER2");
3948 case BALANCE_XMIT_POLICY_LAYER23:
3949 printf("BALANCE_XMIT_POLICY_LAYER23");
3951 case BALANCE_XMIT_POLICY_LAYER34:
3952 printf("BALANCE_XMIT_POLICY_LAYER34");
3959 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3961 if (num_slaves < 0) {
3962 printf("\tFailed to get slave list for port = %d\n", port_id);
3965 if (num_slaves > 0) {
3966 printf("\tSlaves (%d): [", num_slaves);
3967 for (i = 0; i < num_slaves - 1; i++)
3968 printf("%d ", slaves[i]);
3970 printf("%d]\n", slaves[num_slaves - 1]);
3972 printf("\tSlaves: []\n");
3976 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3979 if (num_active_slaves < 0) {
3980 printf("\tFailed to get active slave list for port = %d\n", port_id);
3983 if (num_active_slaves > 0) {
3984 printf("\tActive Slaves (%d): [", num_active_slaves);
3985 for (i = 0; i < num_active_slaves - 1; i++)
3986 printf("%d ", slaves[i]);
3988 printf("%d]\n", slaves[num_active_slaves - 1]);
3991 printf("\tActive Slaves: []\n");
3995 primary_id = rte_eth_bond_primary_get(port_id);
3996 if (primary_id < 0) {
3997 printf("\tFailed to get primary slave for port = %d\n", port_id);
4000 printf("\tPrimary: [%d]\n", primary_id);
4004 cmdline_parse_token_string_t cmd_showbonding_config_show =
4005 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4007 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4008 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4009 bonding, "bonding");
4010 cmdline_parse_token_string_t cmd_showbonding_config_config =
4011 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4013 cmdline_parse_token_num_t cmd_showbonding_config_port =
4014 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4017 cmdline_parse_inst_t cmd_show_bonding_config = {
4018 .f = cmd_show_bonding_config_parsed,
4019 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4022 (void *)&cmd_showbonding_config_show,
4023 (void *)&cmd_showbonding_config_bonding,
4024 (void *)&cmd_showbonding_config_config,
4025 (void *)&cmd_showbonding_config_port,
4030 /* *** SET BONDING PRIMARY *** */
4031 struct cmd_set_bonding_primary_result {
4032 cmdline_fixed_string_t set;
4033 cmdline_fixed_string_t bonding;
4034 cmdline_fixed_string_t primary;
4039 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4040 __attribute__((unused)) struct cmdline *cl,
4041 __attribute__((unused)) void *data)
4043 struct cmd_set_bonding_primary_result *res = parsed_result;
4044 portid_t master_port_id = res->port_id;
4045 portid_t slave_port_id = res->slave_id;
4047 /* Set the primary slave for a bonded device. */
4048 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4049 printf("\t Failed to set primary slave for port = %d.\n",
4056 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4059 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4060 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4061 bonding, "bonding");
4062 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4063 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4064 primary, "primary");
4065 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4066 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4068 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4069 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4072 cmdline_parse_inst_t cmd_set_bonding_primary = {
4073 .f = cmd_set_bonding_primary_parsed,
4074 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4077 (void *)&cmd_setbonding_primary_set,
4078 (void *)&cmd_setbonding_primary_bonding,
4079 (void *)&cmd_setbonding_primary_primary,
4080 (void *)&cmd_setbonding_primary_slave,
4081 (void *)&cmd_setbonding_primary_port,
4086 /* *** ADD SLAVE *** */
4087 struct cmd_add_bonding_slave_result {
4088 cmdline_fixed_string_t add;
4089 cmdline_fixed_string_t bonding;
4090 cmdline_fixed_string_t slave;
4095 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4096 __attribute__((unused)) struct cmdline *cl,
4097 __attribute__((unused)) void *data)
4099 struct cmd_add_bonding_slave_result *res = parsed_result;
4100 portid_t master_port_id = res->port_id;
4101 portid_t slave_port_id = res->slave_id;
4103 /* Set the primary slave for a bonded device. */
4104 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4105 printf("\t Failed to add slave %d to master port = %d.\n",
4106 slave_port_id, master_port_id);
4110 set_port_slave_flag(slave_port_id);
4113 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4114 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4116 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4117 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4118 bonding, "bonding");
4119 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4120 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4122 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4123 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4125 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4126 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4129 cmdline_parse_inst_t cmd_add_bonding_slave = {
4130 .f = cmd_add_bonding_slave_parsed,
4131 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4134 (void *)&cmd_addbonding_slave_add,
4135 (void *)&cmd_addbonding_slave_bonding,
4136 (void *)&cmd_addbonding_slave_slave,
4137 (void *)&cmd_addbonding_slave_slaveid,
4138 (void *)&cmd_addbonding_slave_port,
4143 /* *** REMOVE SLAVE *** */
4144 struct cmd_remove_bonding_slave_result {
4145 cmdline_fixed_string_t remove;
4146 cmdline_fixed_string_t bonding;
4147 cmdline_fixed_string_t slave;
4152 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4153 __attribute__((unused)) struct cmdline *cl,
4154 __attribute__((unused)) void *data)
4156 struct cmd_remove_bonding_slave_result *res = parsed_result;
4157 portid_t master_port_id = res->port_id;
4158 portid_t slave_port_id = res->slave_id;
4160 /* Set the primary slave for a bonded device. */
4161 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4162 printf("\t Failed to remove slave %d from master port = %d.\n",
4163 slave_port_id, master_port_id);
4167 clear_port_slave_flag(slave_port_id);
4170 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4171 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4173 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4174 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4175 bonding, "bonding");
4176 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4177 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4179 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4180 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4182 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4183 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4186 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4187 .f = cmd_remove_bonding_slave_parsed,
4188 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4191 (void *)&cmd_removebonding_slave_remove,
4192 (void *)&cmd_removebonding_slave_bonding,
4193 (void *)&cmd_removebonding_slave_slave,
4194 (void *)&cmd_removebonding_slave_slaveid,
4195 (void *)&cmd_removebonding_slave_port,
4200 /* *** CREATE BONDED DEVICE *** */
4201 struct cmd_create_bonded_device_result {
4202 cmdline_fixed_string_t create;
4203 cmdline_fixed_string_t bonded;
4204 cmdline_fixed_string_t device;
4209 static int bond_dev_num = 0;
4211 static void cmd_create_bonded_device_parsed(void *parsed_result,
4212 __attribute__((unused)) struct cmdline *cl,
4213 __attribute__((unused)) void *data)
4215 struct cmd_create_bonded_device_result *res = parsed_result;
4216 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4219 if (test_done == 0) {
4220 printf("Please stop forwarding first\n");
4224 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4227 /* Create a new bonded device. */
4228 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4230 printf("\t Failed to create bonded device.\n");
4233 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4236 /* Update number of ports */
4237 nb_ports = rte_eth_dev_count();
4238 reconfig(port_id, res->socket);
4239 rte_eth_promiscuous_enable(port_id);
4240 ports[port_id].enabled = 1;
4245 cmdline_parse_token_string_t cmd_createbonded_device_create =
4246 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4248 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4249 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4251 cmdline_parse_token_string_t cmd_createbonded_device_device =
4252 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4254 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4255 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4257 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4258 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4261 cmdline_parse_inst_t cmd_create_bonded_device = {
4262 .f = cmd_create_bonded_device_parsed,
4263 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4266 (void *)&cmd_createbonded_device_create,
4267 (void *)&cmd_createbonded_device_bonded,
4268 (void *)&cmd_createbonded_device_device,
4269 (void *)&cmd_createbonded_device_mode,
4270 (void *)&cmd_createbonded_device_socket,
4275 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4276 struct cmd_set_bond_mac_addr_result {
4277 cmdline_fixed_string_t set;
4278 cmdline_fixed_string_t bonding;
4279 cmdline_fixed_string_t mac_addr;
4281 struct ether_addr address;
4284 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4285 __attribute__((unused)) struct cmdline *cl,
4286 __attribute__((unused)) void *data)
4288 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4291 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4294 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4296 /* check the return value and print it if is < 0 */
4298 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4301 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4302 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4303 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4304 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4306 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4307 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4309 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4310 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4311 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4312 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4314 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4315 .f = cmd_set_bond_mac_addr_parsed,
4317 .help_str = "set bonding mac_addr (port_id) (address): ",
4319 (void *)&cmd_set_bond_mac_addr_set,
4320 (void *)&cmd_set_bond_mac_addr_bonding,
4321 (void *)&cmd_set_bond_mac_addr_mac,
4322 (void *)&cmd_set_bond_mac_addr_portnum,
4323 (void *)&cmd_set_bond_mac_addr_addr,
4329 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4330 struct cmd_set_bond_mon_period_result {
4331 cmdline_fixed_string_t set;
4332 cmdline_fixed_string_t bonding;
4333 cmdline_fixed_string_t mon_period;
4338 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4339 __attribute__((unused)) struct cmdline *cl,
4340 __attribute__((unused)) void *data)
4342 struct cmd_set_bond_mon_period_result *res = parsed_result;
4345 if (res->port_num >= nb_ports) {
4346 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4350 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4352 /* check the return value and print it if is < 0 */
4354 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4357 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4358 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4360 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4361 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4362 bonding, "bonding");
4363 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4364 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4365 mon_period, "mon_period");
4366 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4367 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4369 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4370 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4373 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4374 .f = cmd_set_bond_mon_period_parsed,
4376 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4378 (void *)&cmd_set_bond_mon_period_set,
4379 (void *)&cmd_set_bond_mon_period_bonding,
4380 (void *)&cmd_set_bond_mon_period_mon_period,
4381 (void *)&cmd_set_bond_mon_period_portnum,
4382 (void *)&cmd_set_bond_mon_period_period_ms,
4387 #endif /* RTE_LIBRTE_PMD_BOND */
4389 /* *** SET FORWARDING MODE *** */
4390 struct cmd_set_fwd_mode_result {
4391 cmdline_fixed_string_t set;
4392 cmdline_fixed_string_t fwd;
4393 cmdline_fixed_string_t mode;
4396 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4397 __attribute__((unused)) struct cmdline *cl,
4398 __attribute__((unused)) void *data)
4400 struct cmd_set_fwd_mode_result *res = parsed_result;
4402 set_pkt_forwarding_mode(res->mode);
4405 cmdline_parse_token_string_t cmd_setfwd_set =
4406 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4407 cmdline_parse_token_string_t cmd_setfwd_fwd =
4408 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4409 cmdline_parse_token_string_t cmd_setfwd_mode =
4410 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4411 "" /* defined at init */);
4413 cmdline_parse_inst_t cmd_set_fwd_mode = {
4414 .f = cmd_set_fwd_mode_parsed,
4416 .help_str = NULL, /* defined at init */
4418 (void *)&cmd_setfwd_set,
4419 (void *)&cmd_setfwd_fwd,
4420 (void *)&cmd_setfwd_mode,
4425 static void cmd_set_fwd_mode_init(void)
4428 static char token[128];
4429 static char help[256];
4430 cmdline_parse_token_string_t *token_struct;
4432 modes = list_pkt_forwarding_modes();
4433 snprintf(help, sizeof help, "set fwd %s - "
4434 "set packet forwarding mode", modes);
4435 cmd_set_fwd_mode.help_str = help;
4437 /* string token separator is # */
4438 for (c = token; *modes != '\0'; modes++)
4443 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4444 token_struct->string_data.str = token;
4447 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4448 struct cmd_set_burst_tx_retry_result {
4449 cmdline_fixed_string_t set;
4450 cmdline_fixed_string_t burst;
4451 cmdline_fixed_string_t tx;
4452 cmdline_fixed_string_t delay;
4454 cmdline_fixed_string_t retry;
4458 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4459 __attribute__((unused)) struct cmdline *cl,
4460 __attribute__((unused)) void *data)
4462 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4464 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4465 && !strcmp(res->tx, "tx")) {
4466 if (!strcmp(res->delay, "delay"))
4467 burst_tx_delay_time = res->time;
4468 if (!strcmp(res->retry, "retry"))
4469 burst_tx_retry_num = res->retry_num;
4474 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4475 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4476 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4477 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4479 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4480 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4481 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4482 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4483 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4484 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4485 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4486 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4487 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4488 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4490 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4491 .f = cmd_set_burst_tx_retry_parsed,
4492 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4494 (void *)&cmd_set_burst_tx_retry_set,
4495 (void *)&cmd_set_burst_tx_retry_burst,
4496 (void *)&cmd_set_burst_tx_retry_tx,
4497 (void *)&cmd_set_burst_tx_retry_delay,
4498 (void *)&cmd_set_burst_tx_retry_time,
4499 (void *)&cmd_set_burst_tx_retry_retry,
4500 (void *)&cmd_set_burst_tx_retry_retry_num,
4505 /* *** SET PROMISC MODE *** */
4506 struct cmd_set_promisc_mode_result {
4507 cmdline_fixed_string_t set;
4508 cmdline_fixed_string_t promisc;
4509 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4510 uint8_t port_num; /* valid if "allports" argument == 0 */
4511 cmdline_fixed_string_t mode;
4514 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4515 __attribute__((unused)) struct cmdline *cl,
4518 struct cmd_set_promisc_mode_result *res = parsed_result;
4522 if (!strcmp(res->mode, "on"))
4529 FOREACH_PORT(i, ports) {
4531 rte_eth_promiscuous_enable(i);
4533 rte_eth_promiscuous_disable(i);
4538 rte_eth_promiscuous_enable(res->port_num);
4540 rte_eth_promiscuous_disable(res->port_num);
4544 cmdline_parse_token_string_t cmd_setpromisc_set =
4545 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4546 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4547 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4549 cmdline_parse_token_string_t cmd_setpromisc_portall =
4550 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4552 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4553 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4555 cmdline_parse_token_string_t cmd_setpromisc_mode =
4556 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4559 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4560 .f = cmd_set_promisc_mode_parsed,
4562 .help_str = "set promisc all on|off: set promisc mode for all ports",
4564 (void *)&cmd_setpromisc_set,
4565 (void *)&cmd_setpromisc_promisc,
4566 (void *)&cmd_setpromisc_portall,
4567 (void *)&cmd_setpromisc_mode,
4572 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4573 .f = cmd_set_promisc_mode_parsed,
4575 .help_str = "set promisc X on|off: set promisc mode on port X",
4577 (void *)&cmd_setpromisc_set,
4578 (void *)&cmd_setpromisc_promisc,
4579 (void *)&cmd_setpromisc_portnum,
4580 (void *)&cmd_setpromisc_mode,
4585 /* *** SET ALLMULTI MODE *** */
4586 struct cmd_set_allmulti_mode_result {
4587 cmdline_fixed_string_t set;
4588 cmdline_fixed_string_t allmulti;
4589 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4590 uint8_t port_num; /* valid if "allports" argument == 0 */
4591 cmdline_fixed_string_t mode;
4594 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4595 __attribute__((unused)) struct cmdline *cl,
4598 struct cmd_set_allmulti_mode_result *res = parsed_result;
4602 if (!strcmp(res->mode, "on"))
4609 FOREACH_PORT(i, ports) {
4611 rte_eth_allmulticast_enable(i);
4613 rte_eth_allmulticast_disable(i);
4618 rte_eth_allmulticast_enable(res->port_num);
4620 rte_eth_allmulticast_disable(res->port_num);
4624 cmdline_parse_token_string_t cmd_setallmulti_set =
4625 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4626 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4627 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4629 cmdline_parse_token_string_t cmd_setallmulti_portall =
4630 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4632 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4633 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4635 cmdline_parse_token_string_t cmd_setallmulti_mode =
4636 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4639 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4640 .f = cmd_set_allmulti_mode_parsed,
4642 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4644 (void *)&cmd_setallmulti_set,
4645 (void *)&cmd_setallmulti_allmulti,
4646 (void *)&cmd_setallmulti_portall,
4647 (void *)&cmd_setallmulti_mode,
4652 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4653 .f = cmd_set_allmulti_mode_parsed,
4655 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4657 (void *)&cmd_setallmulti_set,
4658 (void *)&cmd_setallmulti_allmulti,
4659 (void *)&cmd_setallmulti_portnum,
4660 (void *)&cmd_setallmulti_mode,
4665 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4666 struct cmd_link_flow_ctrl_set_result {
4667 cmdline_fixed_string_t set;
4668 cmdline_fixed_string_t flow_ctrl;
4669 cmdline_fixed_string_t rx;
4670 cmdline_fixed_string_t rx_lfc_mode;
4671 cmdline_fixed_string_t tx;
4672 cmdline_fixed_string_t tx_lfc_mode;
4673 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4674 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4675 cmdline_fixed_string_t autoneg_str;
4676 cmdline_fixed_string_t autoneg;
4677 cmdline_fixed_string_t hw_str;
4678 uint32_t high_water;
4679 cmdline_fixed_string_t lw_str;
4681 cmdline_fixed_string_t pt_str;
4682 uint16_t pause_time;
4683 cmdline_fixed_string_t xon_str;
4688 cmdline_parse_token_string_t cmd_lfc_set_set =
4689 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4691 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4692 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4693 flow_ctrl, "flow_ctrl");
4694 cmdline_parse_token_string_t cmd_lfc_set_rx =
4695 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4697 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4698 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4699 rx_lfc_mode, "on#off");
4700 cmdline_parse_token_string_t cmd_lfc_set_tx =
4701 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4703 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4704 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4705 tx_lfc_mode, "on#off");
4706 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4707 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4708 hw_str, "high_water");
4709 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4710 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4711 high_water, UINT32);
4712 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4713 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4714 lw_str, "low_water");
4715 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4716 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4718 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4719 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4720 pt_str, "pause_time");
4721 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4722 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4723 pause_time, UINT16);
4724 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4725 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4726 xon_str, "send_xon");
4727 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4728 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4730 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4731 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4732 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4733 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4734 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4735 mac_ctrl_frame_fwd_mode, "on#off");
4736 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4737 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4738 autoneg_str, "autoneg");
4739 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4740 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4742 cmdline_parse_token_num_t cmd_lfc_set_portid =
4743 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4746 /* forward declaration */
4748 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4751 cmdline_parse_inst_t cmd_link_flow_control_set = {
4752 .f = cmd_link_flow_ctrl_set_parsed,
4754 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4755 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4756 autoneg 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_tx,
4763 (void *)&cmd_lfc_set_tx_mode,
4764 (void *)&cmd_lfc_set_high_water,
4765 (void *)&cmd_lfc_set_low_water,
4766 (void *)&cmd_lfc_set_pause_time,
4767 (void *)&cmd_lfc_set_send_xon,
4768 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4769 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4770 (void *)&cmd_lfc_set_autoneg_str,
4771 (void *)&cmd_lfc_set_autoneg,
4772 (void *)&cmd_lfc_set_portid,
4777 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4778 .f = cmd_link_flow_ctrl_set_parsed,
4779 .data = (void *)&cmd_link_flow_control_set_rx,
4780 .help_str = "Change rx flow control parameter: set flow_ctrl "
4781 "rx on|off port_id",
4783 (void *)&cmd_lfc_set_set,
4784 (void *)&cmd_lfc_set_flow_ctrl,
4785 (void *)&cmd_lfc_set_rx,
4786 (void *)&cmd_lfc_set_rx_mode,
4787 (void *)&cmd_lfc_set_portid,
4792 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4793 .f = cmd_link_flow_ctrl_set_parsed,
4794 .data = (void *)&cmd_link_flow_control_set_tx,
4795 .help_str = "Change tx flow control parameter: set flow_ctrl "
4796 "tx on|off port_id",
4798 (void *)&cmd_lfc_set_set,
4799 (void *)&cmd_lfc_set_flow_ctrl,
4800 (void *)&cmd_lfc_set_tx,
4801 (void *)&cmd_lfc_set_tx_mode,
4802 (void *)&cmd_lfc_set_portid,
4807 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4808 .f = cmd_link_flow_ctrl_set_parsed,
4809 .data = (void *)&cmd_link_flow_control_set_hw,
4810 .help_str = "Change high water flow control parameter: set flow_ctrl "
4811 "high_water value port_id",
4813 (void *)&cmd_lfc_set_set,
4814 (void *)&cmd_lfc_set_flow_ctrl,
4815 (void *)&cmd_lfc_set_high_water_str,
4816 (void *)&cmd_lfc_set_high_water,
4817 (void *)&cmd_lfc_set_portid,
4822 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4823 .f = cmd_link_flow_ctrl_set_parsed,
4824 .data = (void *)&cmd_link_flow_control_set_lw,
4825 .help_str = "Change low water flow control parameter: set flow_ctrl "
4826 "low_water value port_id",
4828 (void *)&cmd_lfc_set_set,
4829 (void *)&cmd_lfc_set_flow_ctrl,
4830 (void *)&cmd_lfc_set_low_water_str,
4831 (void *)&cmd_lfc_set_low_water,
4832 (void *)&cmd_lfc_set_portid,
4837 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4838 .f = cmd_link_flow_ctrl_set_parsed,
4839 .data = (void *)&cmd_link_flow_control_set_pt,
4840 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4841 "pause_time value port_id",
4843 (void *)&cmd_lfc_set_set,
4844 (void *)&cmd_lfc_set_flow_ctrl,
4845 (void *)&cmd_lfc_set_pause_time_str,
4846 (void *)&cmd_lfc_set_pause_time,
4847 (void *)&cmd_lfc_set_portid,
4852 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4853 .f = cmd_link_flow_ctrl_set_parsed,
4854 .data = (void *)&cmd_link_flow_control_set_xon,
4855 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4856 "send_xon value port_id",
4858 (void *)&cmd_lfc_set_set,
4859 (void *)&cmd_lfc_set_flow_ctrl,
4860 (void *)&cmd_lfc_set_send_xon_str,
4861 (void *)&cmd_lfc_set_send_xon,
4862 (void *)&cmd_lfc_set_portid,
4867 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4868 .f = cmd_link_flow_ctrl_set_parsed,
4869 .data = (void *)&cmd_link_flow_control_set_macfwd,
4870 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4871 "mac_ctrl_frame_fwd on|off port_id",
4873 (void *)&cmd_lfc_set_set,
4874 (void *)&cmd_lfc_set_flow_ctrl,
4875 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4876 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4877 (void *)&cmd_lfc_set_portid,
4882 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4883 .f = cmd_link_flow_ctrl_set_parsed,
4884 .data = (void *)&cmd_link_flow_control_set_autoneg,
4885 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4886 "autoneg on|off port_id",
4888 (void *)&cmd_lfc_set_set,
4889 (void *)&cmd_lfc_set_flow_ctrl,
4890 (void *)&cmd_lfc_set_autoneg_str,
4891 (void *)&cmd_lfc_set_autoneg,
4892 (void *)&cmd_lfc_set_portid,
4898 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4899 __attribute__((unused)) struct cmdline *cl,
4902 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4903 cmdline_parse_inst_t *cmd = data;
4904 struct rte_eth_fc_conf fc_conf;
4910 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4911 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4912 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4913 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4915 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4916 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4919 /* Partial command line, retrieve current configuration */
4921 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4923 printf("cannot get current flow ctrl parameters, return"
4924 "code = %d\n", ret);
4928 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4929 (fc_conf.mode == RTE_FC_FULL))
4931 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4932 (fc_conf.mode == RTE_FC_FULL))
4936 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4937 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4939 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4940 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4942 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4944 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4945 fc_conf.high_water = res->high_water;
4947 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4948 fc_conf.low_water = res->low_water;
4950 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4951 fc_conf.pause_time = res->pause_time;
4953 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4954 fc_conf.send_xon = res->send_xon;
4956 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4957 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4958 fc_conf.mac_ctrl_frame_fwd = 1;
4960 fc_conf.mac_ctrl_frame_fwd = 0;
4963 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4964 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4966 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4968 printf("bad flow contrl parameter, return code = %d \n", ret);
4971 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4972 struct cmd_priority_flow_ctrl_set_result {
4973 cmdline_fixed_string_t set;
4974 cmdline_fixed_string_t pfc_ctrl;
4975 cmdline_fixed_string_t rx;
4976 cmdline_fixed_string_t rx_pfc_mode;
4977 cmdline_fixed_string_t tx;
4978 cmdline_fixed_string_t tx_pfc_mode;
4979 uint32_t high_water;
4981 uint16_t pause_time;
4987 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4988 __attribute__((unused)) struct cmdline *cl,
4989 __attribute__((unused)) void *data)
4991 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4992 struct rte_eth_pfc_conf pfc_conf;
4993 int rx_fc_enable, tx_fc_enable;
4997 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4998 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4999 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5000 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5002 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5003 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5006 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5007 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5008 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5009 pfc_conf.fc.high_water = res->high_water;
5010 pfc_conf.fc.low_water = res->low_water;
5011 pfc_conf.fc.pause_time = res->pause_time;
5012 pfc_conf.priority = res->priority;
5014 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5016 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5019 cmdline_parse_token_string_t cmd_pfc_set_set =
5020 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5022 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5023 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5024 pfc_ctrl, "pfc_ctrl");
5025 cmdline_parse_token_string_t cmd_pfc_set_rx =
5026 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5028 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5029 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5030 rx_pfc_mode, "on#off");
5031 cmdline_parse_token_string_t cmd_pfc_set_tx =
5032 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5034 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5035 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5036 tx_pfc_mode, "on#off");
5037 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5038 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5039 high_water, UINT32);
5040 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5041 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5043 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5044 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5045 pause_time, UINT16);
5046 cmdline_parse_token_num_t cmd_pfc_set_priority =
5047 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5049 cmdline_parse_token_num_t cmd_pfc_set_portid =
5050 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5053 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5054 .f = cmd_priority_flow_ctrl_set_parsed,
5056 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5057 tx on|off high_water low_water pause_time priority port_id",
5059 (void *)&cmd_pfc_set_set,
5060 (void *)&cmd_pfc_set_flow_ctrl,
5061 (void *)&cmd_pfc_set_rx,
5062 (void *)&cmd_pfc_set_rx_mode,
5063 (void *)&cmd_pfc_set_tx,
5064 (void *)&cmd_pfc_set_tx_mode,
5065 (void *)&cmd_pfc_set_high_water,
5066 (void *)&cmd_pfc_set_low_water,
5067 (void *)&cmd_pfc_set_pause_time,
5068 (void *)&cmd_pfc_set_priority,
5069 (void *)&cmd_pfc_set_portid,
5074 /* *** RESET CONFIGURATION *** */
5075 struct cmd_reset_result {
5076 cmdline_fixed_string_t reset;
5077 cmdline_fixed_string_t def;
5080 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5082 __attribute__((unused)) void *data)
5084 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5085 set_def_fwd_config();
5088 cmdline_parse_token_string_t cmd_reset_set =
5089 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5090 cmdline_parse_token_string_t cmd_reset_def =
5091 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5094 cmdline_parse_inst_t cmd_reset = {
5095 .f = cmd_reset_parsed,
5097 .help_str = "set default: reset default forwarding configuration",
5099 (void *)&cmd_reset_set,
5100 (void *)&cmd_reset_def,
5105 /* *** START FORWARDING *** */
5106 struct cmd_start_result {
5107 cmdline_fixed_string_t start;
5110 cmdline_parse_token_string_t cmd_start_start =
5111 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5113 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5114 __attribute__((unused)) struct cmdline *cl,
5115 __attribute__((unused)) void *data)
5117 start_packet_forwarding(0);
5120 cmdline_parse_inst_t cmd_start = {
5121 .f = cmd_start_parsed,
5123 .help_str = "start packet forwarding",
5125 (void *)&cmd_start_start,
5130 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5131 struct cmd_start_tx_first_result {
5132 cmdline_fixed_string_t start;
5133 cmdline_fixed_string_t tx_first;
5137 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5138 __attribute__((unused)) struct cmdline *cl,
5139 __attribute__((unused)) void *data)
5141 start_packet_forwarding(1);
5144 cmdline_parse_token_string_t cmd_start_tx_first_start =
5145 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5147 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5148 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5149 tx_first, "tx_first");
5151 cmdline_parse_inst_t cmd_start_tx_first = {
5152 .f = cmd_start_tx_first_parsed,
5154 .help_str = "start packet forwarding, after sending 1 burst of packets",
5156 (void *)&cmd_start_tx_first_start,
5157 (void *)&cmd_start_tx_first_tx_first,
5162 /* *** SET LINK UP *** */
5163 struct cmd_set_link_up_result {
5164 cmdline_fixed_string_t set;
5165 cmdline_fixed_string_t link_up;
5166 cmdline_fixed_string_t port;
5170 cmdline_parse_token_string_t cmd_set_link_up_set =
5171 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5172 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5173 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5175 cmdline_parse_token_string_t cmd_set_link_up_port =
5176 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5177 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5178 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5180 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5181 __attribute__((unused)) struct cmdline *cl,
5182 __attribute__((unused)) void *data)
5184 struct cmd_set_link_up_result *res = parsed_result;
5185 dev_set_link_up(res->port_id);
5188 cmdline_parse_inst_t cmd_set_link_up = {
5189 .f = cmd_set_link_up_parsed,
5191 .help_str = "set link-up port (port id)",
5193 (void *)&cmd_set_link_up_set,
5194 (void *)&cmd_set_link_up_link_up,
5195 (void *)&cmd_set_link_up_port,
5196 (void *)&cmd_set_link_up_port_id,
5201 /* *** SET LINK DOWN *** */
5202 struct cmd_set_link_down_result {
5203 cmdline_fixed_string_t set;
5204 cmdline_fixed_string_t link_down;
5205 cmdline_fixed_string_t port;
5209 cmdline_parse_token_string_t cmd_set_link_down_set =
5210 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5211 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5212 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5214 cmdline_parse_token_string_t cmd_set_link_down_port =
5215 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5216 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5217 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5219 static void cmd_set_link_down_parsed(
5220 __attribute__((unused)) void *parsed_result,
5221 __attribute__((unused)) struct cmdline *cl,
5222 __attribute__((unused)) void *data)
5224 struct cmd_set_link_down_result *res = parsed_result;
5225 dev_set_link_down(res->port_id);
5228 cmdline_parse_inst_t cmd_set_link_down = {
5229 .f = cmd_set_link_down_parsed,
5231 .help_str = "set link-down port (port id)",
5233 (void *)&cmd_set_link_down_set,
5234 (void *)&cmd_set_link_down_link_down,
5235 (void *)&cmd_set_link_down_port,
5236 (void *)&cmd_set_link_down_port_id,
5241 /* *** SHOW CFG *** */
5242 struct cmd_showcfg_result {
5243 cmdline_fixed_string_t show;
5244 cmdline_fixed_string_t cfg;
5245 cmdline_fixed_string_t what;
5248 static void cmd_showcfg_parsed(void *parsed_result,
5249 __attribute__((unused)) struct cmdline *cl,
5250 __attribute__((unused)) void *data)
5252 struct cmd_showcfg_result *res = parsed_result;
5253 if (!strcmp(res->what, "rxtx"))
5254 rxtx_config_display();
5255 else if (!strcmp(res->what, "cores"))
5256 fwd_lcores_config_display();
5257 else if (!strcmp(res->what, "fwd"))
5258 fwd_config_display();
5261 cmdline_parse_token_string_t cmd_showcfg_show =
5262 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5263 cmdline_parse_token_string_t cmd_showcfg_port =
5264 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5265 cmdline_parse_token_string_t cmd_showcfg_what =
5266 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5269 cmdline_parse_inst_t cmd_showcfg = {
5270 .f = cmd_showcfg_parsed,
5272 .help_str = "show config rxtx|cores|fwd",
5274 (void *)&cmd_showcfg_show,
5275 (void *)&cmd_showcfg_port,
5276 (void *)&cmd_showcfg_what,
5281 /* *** SHOW ALL PORT INFO *** */
5282 struct cmd_showportall_result {
5283 cmdline_fixed_string_t show;
5284 cmdline_fixed_string_t port;
5285 cmdline_fixed_string_t what;
5286 cmdline_fixed_string_t all;
5289 static void cmd_showportall_parsed(void *parsed_result,
5290 __attribute__((unused)) struct cmdline *cl,
5291 __attribute__((unused)) void *data)
5295 struct cmd_showportall_result *res = parsed_result;
5296 if (!strcmp(res->show, "clear")) {
5297 if (!strcmp(res->what, "stats"))
5298 FOREACH_PORT(i, ports)
5300 else if (!strcmp(res->what, "xstats"))
5301 FOREACH_PORT(i, ports)
5302 nic_xstats_clear(i);
5303 } else if (!strcmp(res->what, "info"))
5304 FOREACH_PORT(i, ports)
5305 port_infos_display(i);
5306 else if (!strcmp(res->what, "stats"))
5307 FOREACH_PORT(i, ports)
5308 nic_stats_display(i);
5309 else if (!strcmp(res->what, "xstats"))
5310 FOREACH_PORT(i, ports)
5311 nic_xstats_display(i);
5312 else if (!strcmp(res->what, "fdir"))
5313 FOREACH_PORT(i, ports)
5315 else if (!strcmp(res->what, "stat_qmap"))
5316 FOREACH_PORT(i, ports)
5317 nic_stats_mapping_display(i);
5318 else if (!strcmp(res->what, "dcb_tc"))
5319 FOREACH_PORT(i, ports)
5320 port_dcb_info_display(i);
5323 cmdline_parse_token_string_t cmd_showportall_show =
5324 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5326 cmdline_parse_token_string_t cmd_showportall_port =
5327 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5328 cmdline_parse_token_string_t cmd_showportall_what =
5329 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5330 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5331 cmdline_parse_token_string_t cmd_showportall_all =
5332 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5333 cmdline_parse_inst_t cmd_showportall = {
5334 .f = cmd_showportall_parsed,
5336 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5338 (void *)&cmd_showportall_show,
5339 (void *)&cmd_showportall_port,
5340 (void *)&cmd_showportall_what,
5341 (void *)&cmd_showportall_all,
5346 /* *** SHOW PORT INFO *** */
5347 struct cmd_showport_result {
5348 cmdline_fixed_string_t show;
5349 cmdline_fixed_string_t port;
5350 cmdline_fixed_string_t what;
5354 static void cmd_showport_parsed(void *parsed_result,
5355 __attribute__((unused)) struct cmdline *cl,
5356 __attribute__((unused)) void *data)
5358 struct cmd_showport_result *res = parsed_result;
5359 if (!strcmp(res->show, "clear")) {
5360 if (!strcmp(res->what, "stats"))
5361 nic_stats_clear(res->portnum);
5362 else if (!strcmp(res->what, "xstats"))
5363 nic_xstats_clear(res->portnum);
5364 } else if (!strcmp(res->what, "info"))
5365 port_infos_display(res->portnum);
5366 else if (!strcmp(res->what, "stats"))
5367 nic_stats_display(res->portnum);
5368 else if (!strcmp(res->what, "xstats"))
5369 nic_xstats_display(res->portnum);
5370 else if (!strcmp(res->what, "fdir"))
5371 fdir_get_infos(res->portnum);
5372 else if (!strcmp(res->what, "stat_qmap"))
5373 nic_stats_mapping_display(res->portnum);
5374 else if (!strcmp(res->what, "dcb_tc"))
5375 port_dcb_info_display(res->portnum);
5378 cmdline_parse_token_string_t cmd_showport_show =
5379 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5381 cmdline_parse_token_string_t cmd_showport_port =
5382 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5383 cmdline_parse_token_string_t cmd_showport_what =
5384 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5385 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5386 cmdline_parse_token_num_t cmd_showport_portnum =
5387 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5389 cmdline_parse_inst_t cmd_showport = {
5390 .f = cmd_showport_parsed,
5392 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5394 (void *)&cmd_showport_show,
5395 (void *)&cmd_showport_port,
5396 (void *)&cmd_showport_what,
5397 (void *)&cmd_showport_portnum,
5402 /* *** SHOW QUEUE INFO *** */
5403 struct cmd_showqueue_result {
5404 cmdline_fixed_string_t show;
5405 cmdline_fixed_string_t type;
5406 cmdline_fixed_string_t what;
5412 cmd_showqueue_parsed(void *parsed_result,
5413 __attribute__((unused)) struct cmdline *cl,
5414 __attribute__((unused)) void *data)
5416 struct cmd_showqueue_result *res = parsed_result;
5418 if (!strcmp(res->type, "rxq"))
5419 rx_queue_infos_display(res->portnum, res->queuenum);
5420 else if (!strcmp(res->type, "txq"))
5421 tx_queue_infos_display(res->portnum, res->queuenum);
5424 cmdline_parse_token_string_t cmd_showqueue_show =
5425 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5426 cmdline_parse_token_string_t cmd_showqueue_type =
5427 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5428 cmdline_parse_token_string_t cmd_showqueue_what =
5429 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5430 cmdline_parse_token_num_t cmd_showqueue_portnum =
5431 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5432 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5433 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5435 cmdline_parse_inst_t cmd_showqueue = {
5436 .f = cmd_showqueue_parsed,
5438 .help_str = "show rxq|txq info <port number> <queue_number>",
5440 (void *)&cmd_showqueue_show,
5441 (void *)&cmd_showqueue_type,
5442 (void *)&cmd_showqueue_what,
5443 (void *)&cmd_showqueue_portnum,
5444 (void *)&cmd_showqueue_queuenum,
5449 /* *** READ PORT REGISTER *** */
5450 struct cmd_read_reg_result {
5451 cmdline_fixed_string_t read;
5452 cmdline_fixed_string_t reg;
5458 cmd_read_reg_parsed(void *parsed_result,
5459 __attribute__((unused)) struct cmdline *cl,
5460 __attribute__((unused)) void *data)
5462 struct cmd_read_reg_result *res = parsed_result;
5463 port_reg_display(res->port_id, res->reg_off);
5466 cmdline_parse_token_string_t cmd_read_reg_read =
5467 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5468 cmdline_parse_token_string_t cmd_read_reg_reg =
5469 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5470 cmdline_parse_token_num_t cmd_read_reg_port_id =
5471 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5472 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5473 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5475 cmdline_parse_inst_t cmd_read_reg = {
5476 .f = cmd_read_reg_parsed,
5478 .help_str = "read reg port_id reg_off",
5480 (void *)&cmd_read_reg_read,
5481 (void *)&cmd_read_reg_reg,
5482 (void *)&cmd_read_reg_port_id,
5483 (void *)&cmd_read_reg_reg_off,
5488 /* *** READ PORT REGISTER BIT FIELD *** */
5489 struct cmd_read_reg_bit_field_result {
5490 cmdline_fixed_string_t read;
5491 cmdline_fixed_string_t regfield;
5499 cmd_read_reg_bit_field_parsed(void *parsed_result,
5500 __attribute__((unused)) struct cmdline *cl,
5501 __attribute__((unused)) void *data)
5503 struct cmd_read_reg_bit_field_result *res = parsed_result;
5504 port_reg_bit_field_display(res->port_id, res->reg_off,
5505 res->bit1_pos, res->bit2_pos);
5508 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5509 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5511 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5512 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5513 regfield, "regfield");
5514 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5515 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5517 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5518 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5520 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5521 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5523 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5524 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5527 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5528 .f = cmd_read_reg_bit_field_parsed,
5530 .help_str = "read regfield port_id reg_off bit_x bit_y "
5531 "(read register bit field between bit_x and bit_y included)",
5533 (void *)&cmd_read_reg_bit_field_read,
5534 (void *)&cmd_read_reg_bit_field_regfield,
5535 (void *)&cmd_read_reg_bit_field_port_id,
5536 (void *)&cmd_read_reg_bit_field_reg_off,
5537 (void *)&cmd_read_reg_bit_field_bit1_pos,
5538 (void *)&cmd_read_reg_bit_field_bit2_pos,
5543 /* *** READ PORT REGISTER BIT *** */
5544 struct cmd_read_reg_bit_result {
5545 cmdline_fixed_string_t read;
5546 cmdline_fixed_string_t regbit;
5553 cmd_read_reg_bit_parsed(void *parsed_result,
5554 __attribute__((unused)) struct cmdline *cl,
5555 __attribute__((unused)) void *data)
5557 struct cmd_read_reg_bit_result *res = parsed_result;
5558 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5561 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5562 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5563 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5564 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5566 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5567 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5568 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5569 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5570 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5571 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5573 cmdline_parse_inst_t cmd_read_reg_bit = {
5574 .f = cmd_read_reg_bit_parsed,
5576 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5578 (void *)&cmd_read_reg_bit_read,
5579 (void *)&cmd_read_reg_bit_regbit,
5580 (void *)&cmd_read_reg_bit_port_id,
5581 (void *)&cmd_read_reg_bit_reg_off,
5582 (void *)&cmd_read_reg_bit_bit_pos,
5587 /* *** WRITE PORT REGISTER *** */
5588 struct cmd_write_reg_result {
5589 cmdline_fixed_string_t write;
5590 cmdline_fixed_string_t reg;
5597 cmd_write_reg_parsed(void *parsed_result,
5598 __attribute__((unused)) struct cmdline *cl,
5599 __attribute__((unused)) void *data)
5601 struct cmd_write_reg_result *res = parsed_result;
5602 port_reg_set(res->port_id, res->reg_off, res->value);
5605 cmdline_parse_token_string_t cmd_write_reg_write =
5606 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5607 cmdline_parse_token_string_t cmd_write_reg_reg =
5608 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5609 cmdline_parse_token_num_t cmd_write_reg_port_id =
5610 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5611 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5612 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5613 cmdline_parse_token_num_t cmd_write_reg_value =
5614 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5616 cmdline_parse_inst_t cmd_write_reg = {
5617 .f = cmd_write_reg_parsed,
5619 .help_str = "write reg port_id reg_off reg_value",
5621 (void *)&cmd_write_reg_write,
5622 (void *)&cmd_write_reg_reg,
5623 (void *)&cmd_write_reg_port_id,
5624 (void *)&cmd_write_reg_reg_off,
5625 (void *)&cmd_write_reg_value,
5630 /* *** WRITE PORT REGISTER BIT FIELD *** */
5631 struct cmd_write_reg_bit_field_result {
5632 cmdline_fixed_string_t write;
5633 cmdline_fixed_string_t regfield;
5642 cmd_write_reg_bit_field_parsed(void *parsed_result,
5643 __attribute__((unused)) struct cmdline *cl,
5644 __attribute__((unused)) void *data)
5646 struct cmd_write_reg_bit_field_result *res = parsed_result;
5647 port_reg_bit_field_set(res->port_id, res->reg_off,
5648 res->bit1_pos, res->bit2_pos, res->value);
5651 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5652 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5654 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5655 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5656 regfield, "regfield");
5657 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5658 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5660 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5661 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5663 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5664 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5666 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5667 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5669 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5670 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5673 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5674 .f = cmd_write_reg_bit_field_parsed,
5676 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5677 "(set register bit field between bit_x and bit_y included)",
5679 (void *)&cmd_write_reg_bit_field_write,
5680 (void *)&cmd_write_reg_bit_field_regfield,
5681 (void *)&cmd_write_reg_bit_field_port_id,
5682 (void *)&cmd_write_reg_bit_field_reg_off,
5683 (void *)&cmd_write_reg_bit_field_bit1_pos,
5684 (void *)&cmd_write_reg_bit_field_bit2_pos,
5685 (void *)&cmd_write_reg_bit_field_value,
5690 /* *** WRITE PORT REGISTER BIT *** */
5691 struct cmd_write_reg_bit_result {
5692 cmdline_fixed_string_t write;
5693 cmdline_fixed_string_t regbit;
5701 cmd_write_reg_bit_parsed(void *parsed_result,
5702 __attribute__((unused)) struct cmdline *cl,
5703 __attribute__((unused)) void *data)
5705 struct cmd_write_reg_bit_result *res = parsed_result;
5706 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5709 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5710 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5712 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5713 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5715 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5716 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5717 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5718 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5719 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5720 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5721 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5722 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5724 cmdline_parse_inst_t cmd_write_reg_bit = {
5725 .f = cmd_write_reg_bit_parsed,
5727 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5729 (void *)&cmd_write_reg_bit_write,
5730 (void *)&cmd_write_reg_bit_regbit,
5731 (void *)&cmd_write_reg_bit_port_id,
5732 (void *)&cmd_write_reg_bit_reg_off,
5733 (void *)&cmd_write_reg_bit_bit_pos,
5734 (void *)&cmd_write_reg_bit_value,
5739 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5740 struct cmd_read_rxd_txd_result {
5741 cmdline_fixed_string_t read;
5742 cmdline_fixed_string_t rxd_txd;
5749 cmd_read_rxd_txd_parsed(void *parsed_result,
5750 __attribute__((unused)) struct cmdline *cl,
5751 __attribute__((unused)) void *data)
5753 struct cmd_read_rxd_txd_result *res = parsed_result;
5755 if (!strcmp(res->rxd_txd, "rxd"))
5756 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5757 else if (!strcmp(res->rxd_txd, "txd"))
5758 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5761 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5762 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5763 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5764 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5766 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5767 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5768 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5769 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5770 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5771 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5773 cmdline_parse_inst_t cmd_read_rxd_txd = {
5774 .f = cmd_read_rxd_txd_parsed,
5776 .help_str = "read rxd|txd port_id queue_id rxd_id",
5778 (void *)&cmd_read_rxd_txd_read,
5779 (void *)&cmd_read_rxd_txd_rxd_txd,
5780 (void *)&cmd_read_rxd_txd_port_id,
5781 (void *)&cmd_read_rxd_txd_queue_id,
5782 (void *)&cmd_read_rxd_txd_desc_id,
5788 struct cmd_quit_result {
5789 cmdline_fixed_string_t quit;
5792 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5794 __attribute__((unused)) void *data)
5800 cmdline_parse_token_string_t cmd_quit_quit =
5801 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5803 cmdline_parse_inst_t cmd_quit = {
5804 .f = cmd_quit_parsed,
5806 .help_str = "exit application",
5808 (void *)&cmd_quit_quit,
5813 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5814 struct cmd_mac_addr_result {
5815 cmdline_fixed_string_t mac_addr_cmd;
5816 cmdline_fixed_string_t what;
5818 struct ether_addr address;
5821 static void cmd_mac_addr_parsed(void *parsed_result,
5822 __attribute__((unused)) struct cmdline *cl,
5823 __attribute__((unused)) void *data)
5825 struct cmd_mac_addr_result *res = parsed_result;
5828 if (strcmp(res->what, "add") == 0)
5829 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5831 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5833 /* check the return value and print it if is < 0 */
5835 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5839 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5840 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5842 cmdline_parse_token_string_t cmd_mac_addr_what =
5843 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5845 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5846 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5847 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5848 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5850 cmdline_parse_inst_t cmd_mac_addr = {
5851 .f = cmd_mac_addr_parsed,
5853 .help_str = "mac_addr add|remove X <address>: "
5854 "add/remove MAC address on port X",
5856 (void *)&cmd_mac_addr_cmd,
5857 (void *)&cmd_mac_addr_what,
5858 (void *)&cmd_mac_addr_portnum,
5859 (void *)&cmd_mac_addr_addr,
5865 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5866 struct cmd_set_qmap_result {
5867 cmdline_fixed_string_t set;
5868 cmdline_fixed_string_t qmap;
5869 cmdline_fixed_string_t what;
5876 cmd_set_qmap_parsed(void *parsed_result,
5877 __attribute__((unused)) struct cmdline *cl,
5878 __attribute__((unused)) void *data)
5880 struct cmd_set_qmap_result *res = parsed_result;
5881 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5883 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5886 cmdline_parse_token_string_t cmd_setqmap_set =
5887 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5889 cmdline_parse_token_string_t cmd_setqmap_qmap =
5890 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5892 cmdline_parse_token_string_t cmd_setqmap_what =
5893 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5895 cmdline_parse_token_num_t cmd_setqmap_portid =
5896 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5898 cmdline_parse_token_num_t cmd_setqmap_queueid =
5899 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5901 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5902 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5905 cmdline_parse_inst_t cmd_set_qmap = {
5906 .f = cmd_set_qmap_parsed,
5908 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5910 (void *)&cmd_setqmap_set,
5911 (void *)&cmd_setqmap_qmap,
5912 (void *)&cmd_setqmap_what,
5913 (void *)&cmd_setqmap_portid,
5914 (void *)&cmd_setqmap_queueid,
5915 (void *)&cmd_setqmap_mapvalue,
5920 /* *** CONFIGURE UNICAST HASH TABLE *** */
5921 struct cmd_set_uc_hash_table {
5922 cmdline_fixed_string_t set;
5923 cmdline_fixed_string_t port;
5925 cmdline_fixed_string_t what;
5926 struct ether_addr address;
5927 cmdline_fixed_string_t mode;
5931 cmd_set_uc_hash_parsed(void *parsed_result,
5932 __attribute__((unused)) struct cmdline *cl,
5933 __attribute__((unused)) void *data)
5936 struct cmd_set_uc_hash_table *res = parsed_result;
5938 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5940 if (strcmp(res->what, "uta") == 0)
5941 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5942 &res->address,(uint8_t)is_on);
5944 printf("bad unicast hash table parameter, return code = %d \n", ret);
5948 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5949 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5951 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5952 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5954 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5955 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5957 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5958 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5960 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5961 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5963 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5964 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5967 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5968 .f = cmd_set_uc_hash_parsed,
5970 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5972 (void *)&cmd_set_uc_hash_set,
5973 (void *)&cmd_set_uc_hash_port,
5974 (void *)&cmd_set_uc_hash_portid,
5975 (void *)&cmd_set_uc_hash_what,
5976 (void *)&cmd_set_uc_hash_mac,
5977 (void *)&cmd_set_uc_hash_mode,
5982 struct cmd_set_uc_all_hash_table {
5983 cmdline_fixed_string_t set;
5984 cmdline_fixed_string_t port;
5986 cmdline_fixed_string_t what;
5987 cmdline_fixed_string_t value;
5988 cmdline_fixed_string_t mode;
5992 cmd_set_uc_all_hash_parsed(void *parsed_result,
5993 __attribute__((unused)) struct cmdline *cl,
5994 __attribute__((unused)) void *data)
5997 struct cmd_set_uc_all_hash_table *res = parsed_result;
5999 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6001 if ((strcmp(res->what, "uta") == 0) &&
6002 (strcmp(res->value, "all") == 0))
6003 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6005 printf("bad unicast hash table parameter,"
6006 "return code = %d \n", ret);
6009 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6010 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6012 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6013 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6015 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6016 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6018 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6021 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6024 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6025 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6028 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6029 .f = cmd_set_uc_all_hash_parsed,
6031 .help_str = "set port X uta all on|off (X = port number)",
6033 (void *)&cmd_set_uc_all_hash_set,
6034 (void *)&cmd_set_uc_all_hash_port,
6035 (void *)&cmd_set_uc_all_hash_portid,
6036 (void *)&cmd_set_uc_all_hash_what,
6037 (void *)&cmd_set_uc_all_hash_value,
6038 (void *)&cmd_set_uc_all_hash_mode,
6043 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6044 struct cmd_set_vf_macvlan_filter {
6045 cmdline_fixed_string_t set;
6046 cmdline_fixed_string_t port;
6048 cmdline_fixed_string_t vf;
6050 struct ether_addr address;
6051 cmdline_fixed_string_t filter_type;
6052 cmdline_fixed_string_t mode;
6056 cmd_set_vf_macvlan_parsed(void *parsed_result,
6057 __attribute__((unused)) struct cmdline *cl,
6058 __attribute__((unused)) void *data)
6061 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6062 struct rte_eth_mac_filter filter;
6064 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6066 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6068 /* set VF MAC filter */
6072 filter.dst_id = res->vf_id;
6074 if (!strcmp(res->filter_type, "exact-mac"))
6075 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6076 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6077 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6078 else if (!strcmp(res->filter_type, "hashmac"))
6079 filter.filter_type = RTE_MAC_HASH_MATCH;
6080 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6081 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6083 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6086 ret = rte_eth_dev_filter_ctrl(res->port_id,
6087 RTE_ETH_FILTER_MACVLAN,
6091 ret = rte_eth_dev_filter_ctrl(res->port_id,
6092 RTE_ETH_FILTER_MACVLAN,
6093 RTE_ETH_FILTER_DELETE,
6097 printf("bad set MAC hash parameter, return code = %d\n", ret);
6101 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6102 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6104 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6105 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6107 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6108 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6110 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6111 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6113 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6114 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6116 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6117 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6119 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6120 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6121 filter_type, "exact-mac#exact-mac-vlan"
6122 "#hashmac#hashmac-vlan");
6123 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6124 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6127 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6128 .f = cmd_set_vf_macvlan_parsed,
6130 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6131 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6133 "exact match rule:exact match of MAC or MAC and VLAN; "
6134 "hash match rule: hash match of MAC and exact match "
6137 (void *)&cmd_set_vf_macvlan_set,
6138 (void *)&cmd_set_vf_macvlan_port,
6139 (void *)&cmd_set_vf_macvlan_portid,
6140 (void *)&cmd_set_vf_macvlan_vf,
6141 (void *)&cmd_set_vf_macvlan_vf_id,
6142 (void *)&cmd_set_vf_macvlan_mac,
6143 (void *)&cmd_set_vf_macvlan_filter_type,
6144 (void *)&cmd_set_vf_macvlan_mode,
6149 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6150 struct cmd_set_vf_traffic {
6151 cmdline_fixed_string_t set;
6152 cmdline_fixed_string_t port;
6154 cmdline_fixed_string_t vf;
6156 cmdline_fixed_string_t what;
6157 cmdline_fixed_string_t mode;
6161 cmd_set_vf_traffic_parsed(void *parsed_result,
6162 __attribute__((unused)) struct cmdline *cl,
6163 __attribute__((unused)) void *data)
6165 struct cmd_set_vf_traffic *res = parsed_result;
6166 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6167 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6169 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6172 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6173 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6175 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6176 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6178 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6179 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6181 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6182 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6184 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6185 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6187 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6188 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6190 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6191 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6194 cmdline_parse_inst_t cmd_set_vf_traffic = {
6195 .f = cmd_set_vf_traffic_parsed,
6197 .help_str = "set port X vf Y rx|tx on|off"
6198 "(X = port number,Y = vf id)",
6200 (void *)&cmd_setvf_traffic_set,
6201 (void *)&cmd_setvf_traffic_port,
6202 (void *)&cmd_setvf_traffic_portid,
6203 (void *)&cmd_setvf_traffic_vf,
6204 (void *)&cmd_setvf_traffic_vfid,
6205 (void *)&cmd_setvf_traffic_what,
6206 (void *)&cmd_setvf_traffic_mode,
6211 /* *** CONFIGURE VF RECEIVE MODE *** */
6212 struct cmd_set_vf_rxmode {
6213 cmdline_fixed_string_t set;
6214 cmdline_fixed_string_t port;
6216 cmdline_fixed_string_t vf;
6218 cmdline_fixed_string_t what;
6219 cmdline_fixed_string_t mode;
6220 cmdline_fixed_string_t on;
6224 cmd_set_vf_rxmode_parsed(void *parsed_result,
6225 __attribute__((unused)) struct cmdline *cl,
6226 __attribute__((unused)) void *data)
6229 uint16_t rx_mode = 0;
6230 struct cmd_set_vf_rxmode *res = parsed_result;
6232 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6233 if (!strcmp(res->what,"rxmode")) {
6234 if (!strcmp(res->mode, "AUPE"))
6235 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6236 else if (!strcmp(res->mode, "ROPE"))
6237 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6238 else if (!strcmp(res->mode, "BAM"))
6239 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6240 else if (!strncmp(res->mode, "MPE",3))
6241 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6244 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6246 printf("bad VF receive mode parameter, return code = %d \n",
6250 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6251 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6253 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6254 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6256 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6257 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6259 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6260 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6262 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6263 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6265 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6266 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6268 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6269 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6270 mode, "AUPE#ROPE#BAM#MPE");
6271 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6272 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6275 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6276 .f = cmd_set_vf_rxmode_parsed,
6278 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6280 (void *)&cmd_set_vf_rxmode_set,
6281 (void *)&cmd_set_vf_rxmode_port,
6282 (void *)&cmd_set_vf_rxmode_portid,
6283 (void *)&cmd_set_vf_rxmode_vf,
6284 (void *)&cmd_set_vf_rxmode_vfid,
6285 (void *)&cmd_set_vf_rxmode_what,
6286 (void *)&cmd_set_vf_rxmode_mode,
6287 (void *)&cmd_set_vf_rxmode_on,
6292 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6293 struct cmd_vf_mac_addr_result {
6294 cmdline_fixed_string_t mac_addr_cmd;
6295 cmdline_fixed_string_t what;
6296 cmdline_fixed_string_t port;
6298 cmdline_fixed_string_t vf;
6300 struct ether_addr address;
6303 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6304 __attribute__((unused)) struct cmdline *cl,
6305 __attribute__((unused)) void *data)
6307 struct cmd_vf_mac_addr_result *res = parsed_result;
6310 if (strcmp(res->what, "add") == 0)
6311 ret = rte_eth_dev_mac_addr_add(res->port_num,
6312 &res->address, res->vf_num);
6314 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6318 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6319 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6320 mac_addr_cmd,"mac_addr");
6321 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6322 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6324 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6325 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6327 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6328 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6330 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6331 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6333 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6334 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6336 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6337 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6340 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6341 .f = cmd_vf_mac_addr_parsed,
6343 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6344 "Y = VF number)add MAC address filtering for a VF on port X",
6346 (void *)&cmd_vf_mac_addr_cmd,
6347 (void *)&cmd_vf_mac_addr_what,
6348 (void *)&cmd_vf_mac_addr_port,
6349 (void *)&cmd_vf_mac_addr_portnum,
6350 (void *)&cmd_vf_mac_addr_vf,
6351 (void *)&cmd_vf_mac_addr_vfnum,
6352 (void *)&cmd_vf_mac_addr_addr,
6357 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6358 struct cmd_vf_rx_vlan_filter {
6359 cmdline_fixed_string_t rx_vlan;
6360 cmdline_fixed_string_t what;
6362 cmdline_fixed_string_t port;
6364 cmdline_fixed_string_t vf;
6369 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6370 __attribute__((unused)) struct cmdline *cl,
6371 __attribute__((unused)) void *data)
6373 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6375 if (!strcmp(res->what, "add"))
6376 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6378 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6381 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6382 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6383 rx_vlan, "rx_vlan");
6384 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6385 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6387 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6388 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6390 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6391 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6393 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6394 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6396 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6397 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6399 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6400 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6403 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6404 .f = cmd_vf_rx_vlan_filter_parsed,
6406 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6407 "Y = port number,Z = hexadecimal VF mask)",
6409 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6410 (void *)&cmd_vf_rx_vlan_filter_what,
6411 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6412 (void *)&cmd_vf_rx_vlan_filter_port,
6413 (void *)&cmd_vf_rx_vlan_filter_portid,
6414 (void *)&cmd_vf_rx_vlan_filter_vf,
6415 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6420 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6421 struct cmd_queue_rate_limit_result {
6422 cmdline_fixed_string_t set;
6423 cmdline_fixed_string_t port;
6425 cmdline_fixed_string_t queue;
6427 cmdline_fixed_string_t rate;
6431 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6432 __attribute__((unused)) struct cmdline *cl,
6433 __attribute__((unused)) void *data)
6435 struct cmd_queue_rate_limit_result *res = parsed_result;
6438 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6439 && (strcmp(res->queue, "queue") == 0)
6440 && (strcmp(res->rate, "rate") == 0))
6441 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6444 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6448 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6449 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6451 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6452 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6454 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6455 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6457 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6458 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6460 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6461 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6463 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6464 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6466 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6467 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6470 cmdline_parse_inst_t cmd_queue_rate_limit = {
6471 .f = cmd_queue_rate_limit_parsed,
6473 .help_str = "set port X queue Y rate Z:(X = port number,"
6474 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6476 (void *)&cmd_queue_rate_limit_set,
6477 (void *)&cmd_queue_rate_limit_port,
6478 (void *)&cmd_queue_rate_limit_portnum,
6479 (void *)&cmd_queue_rate_limit_queue,
6480 (void *)&cmd_queue_rate_limit_queuenum,
6481 (void *)&cmd_queue_rate_limit_rate,
6482 (void *)&cmd_queue_rate_limit_ratenum,
6487 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6488 struct cmd_vf_rate_limit_result {
6489 cmdline_fixed_string_t set;
6490 cmdline_fixed_string_t port;
6492 cmdline_fixed_string_t vf;
6494 cmdline_fixed_string_t rate;
6496 cmdline_fixed_string_t q_msk;
6500 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6501 __attribute__((unused)) struct cmdline *cl,
6502 __attribute__((unused)) void *data)
6504 struct cmd_vf_rate_limit_result *res = parsed_result;
6507 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6508 && (strcmp(res->vf, "vf") == 0)
6509 && (strcmp(res->rate, "rate") == 0)
6510 && (strcmp(res->q_msk, "queue_mask") == 0))
6511 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6512 res->rate_num, res->q_msk_val);
6514 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6518 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6519 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6521 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6522 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6524 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6525 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6527 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6528 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6530 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6531 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6533 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6534 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6536 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6537 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6539 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6540 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6541 q_msk, "queue_mask");
6542 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6543 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6546 cmdline_parse_inst_t cmd_vf_rate_limit = {
6547 .f = cmd_vf_rate_limit_parsed,
6549 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6550 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6551 "for queues of VF on port X",
6553 (void *)&cmd_vf_rate_limit_set,
6554 (void *)&cmd_vf_rate_limit_port,
6555 (void *)&cmd_vf_rate_limit_portnum,
6556 (void *)&cmd_vf_rate_limit_vf,
6557 (void *)&cmd_vf_rate_limit_vfnum,
6558 (void *)&cmd_vf_rate_limit_rate,
6559 (void *)&cmd_vf_rate_limit_ratenum,
6560 (void *)&cmd_vf_rate_limit_q_msk,
6561 (void *)&cmd_vf_rate_limit_q_msk_val,
6566 /* *** ADD TUNNEL FILTER OF A PORT *** */
6567 struct cmd_tunnel_filter_result {
6568 cmdline_fixed_string_t cmd;
6569 cmdline_fixed_string_t what;
6571 struct ether_addr outer_mac;
6572 struct ether_addr inner_mac;
6573 cmdline_ipaddr_t ip_value;
6574 uint16_t inner_vlan;
6575 cmdline_fixed_string_t tunnel_type;
6576 cmdline_fixed_string_t filter_type;
6582 cmd_tunnel_filter_parsed(void *parsed_result,
6583 __attribute__((unused)) struct cmdline *cl,
6584 __attribute__((unused)) void *data)
6586 struct cmd_tunnel_filter_result *res = parsed_result;
6587 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6590 tunnel_filter_conf.outer_mac = &res->outer_mac;
6591 tunnel_filter_conf.inner_mac = &res->inner_mac;
6592 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6594 if (res->ip_value.family == AF_INET) {
6595 tunnel_filter_conf.ip_addr.ipv4_addr =
6596 res->ip_value.addr.ipv4.s_addr;
6597 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6599 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6600 &(res->ip_value.addr.ipv6),
6601 sizeof(struct in6_addr));
6602 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6605 if (!strcmp(res->filter_type, "imac-ivlan"))
6606 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6607 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6608 tunnel_filter_conf.filter_type =
6609 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6610 else if (!strcmp(res->filter_type, "imac-tenid"))
6611 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6612 else if (!strcmp(res->filter_type, "imac"))
6613 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6614 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6615 tunnel_filter_conf.filter_type =
6616 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6618 printf("The filter type is not supported");
6622 if (!strcmp(res->tunnel_type, "vxlan"))
6623 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6624 else if (!strcmp(res->tunnel_type, "nvgre"))
6625 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6627 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6631 tunnel_filter_conf.tenant_id = res->tenant_id;
6632 tunnel_filter_conf.queue_id = res->queue_num;
6633 if (!strcmp(res->what, "add"))
6634 ret = rte_eth_dev_filter_ctrl(res->port_id,
6635 RTE_ETH_FILTER_TUNNEL,
6637 &tunnel_filter_conf);
6639 ret = rte_eth_dev_filter_ctrl(res->port_id,
6640 RTE_ETH_FILTER_TUNNEL,
6641 RTE_ETH_FILTER_DELETE,
6642 &tunnel_filter_conf);
6644 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6648 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6649 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6650 cmd, "tunnel_filter");
6651 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6652 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6654 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6655 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6657 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6658 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6660 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6661 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6663 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6664 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6665 inner_vlan, UINT16);
6666 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6667 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6669 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6670 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6671 tunnel_type, "vxlan#nvgre");
6673 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6674 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6675 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6676 "imac#omac-imac-tenid");
6677 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6678 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6680 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6681 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6684 cmdline_parse_inst_t cmd_tunnel_filter = {
6685 .f = cmd_tunnel_filter_parsed,
6687 .help_str = "add/rm tunnel filter of a port: "
6688 "tunnel_filter add port_id outer_mac inner_mac ip "
6689 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6690 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6691 "imac|omac-imac-tenid) "
6692 "tenant_id queue_num",
6694 (void *)&cmd_tunnel_filter_cmd,
6695 (void *)&cmd_tunnel_filter_what,
6696 (void *)&cmd_tunnel_filter_port_id,
6697 (void *)&cmd_tunnel_filter_outer_mac,
6698 (void *)&cmd_tunnel_filter_inner_mac,
6699 (void *)&cmd_tunnel_filter_ip_value,
6700 (void *)&cmd_tunnel_filter_innner_vlan,
6701 (void *)&cmd_tunnel_filter_tunnel_type,
6702 (void *)&cmd_tunnel_filter_filter_type,
6703 (void *)&cmd_tunnel_filter_tenant_id,
6704 (void *)&cmd_tunnel_filter_queue_num,
6709 /* *** CONFIGURE TUNNEL UDP PORT *** */
6710 struct cmd_tunnel_udp_config {
6711 cmdline_fixed_string_t cmd;
6712 cmdline_fixed_string_t what;
6718 cmd_tunnel_udp_config_parsed(void *parsed_result,
6719 __attribute__((unused)) struct cmdline *cl,
6720 __attribute__((unused)) void *data)
6722 struct cmd_tunnel_udp_config *res = parsed_result;
6723 struct rte_eth_udp_tunnel tunnel_udp;
6726 tunnel_udp.udp_port = res->udp_port;
6728 if (!strcmp(res->cmd, "rx_vxlan_port"))
6729 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6731 if (!strcmp(res->what, "add"))
6732 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6734 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6737 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6740 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6741 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6742 cmd, "rx_vxlan_port");
6743 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6744 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6746 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6747 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6749 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6750 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6753 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6754 .f = cmd_tunnel_udp_config_parsed,
6756 .help_str = "add/rm an tunneling UDP port filter: "
6757 "rx_vxlan_port add udp_port port_id",
6759 (void *)&cmd_tunnel_udp_config_cmd,
6760 (void *)&cmd_tunnel_udp_config_what,
6761 (void *)&cmd_tunnel_udp_config_udp_port,
6762 (void *)&cmd_tunnel_udp_config_port_id,
6767 /* *** GLOBAL CONFIG *** */
6768 struct cmd_global_config_result {
6769 cmdline_fixed_string_t cmd;
6771 cmdline_fixed_string_t cfg_type;
6776 cmd_global_config_parsed(void *parsed_result,
6777 __attribute__((unused)) struct cmdline *cl,
6778 __attribute__((unused)) void *data)
6780 struct cmd_global_config_result *res = parsed_result;
6781 struct rte_eth_global_cfg conf;
6784 memset(&conf, 0, sizeof(conf));
6785 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6786 conf.cfg.gre_key_len = res->len;
6787 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6788 RTE_ETH_FILTER_SET, &conf);
6790 printf("Global config error\n");
6793 cmdline_parse_token_string_t cmd_global_config_cmd =
6794 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6796 cmdline_parse_token_num_t cmd_global_config_port_id =
6797 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6798 cmdline_parse_token_string_t cmd_global_config_type =
6799 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6800 cfg_type, "gre-key-len");
6801 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6802 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6805 cmdline_parse_inst_t cmd_global_config = {
6806 .f = cmd_global_config_parsed,
6807 .data = (void *)NULL,
6808 .help_str = "global_config <port_id> gre-key-len <number>",
6810 (void *)&cmd_global_config_cmd,
6811 (void *)&cmd_global_config_port_id,
6812 (void *)&cmd_global_config_type,
6813 (void *)&cmd_global_config_gre_key_len,
6818 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6819 struct cmd_set_mirror_mask_result {
6820 cmdline_fixed_string_t set;
6821 cmdline_fixed_string_t port;
6823 cmdline_fixed_string_t mirror;
6825 cmdline_fixed_string_t what;
6826 cmdline_fixed_string_t value;
6827 cmdline_fixed_string_t dstpool;
6829 cmdline_fixed_string_t on;
6832 cmdline_parse_token_string_t cmd_mirror_mask_set =
6833 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6835 cmdline_parse_token_string_t cmd_mirror_mask_port =
6836 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6838 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6839 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6841 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6842 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6843 mirror, "mirror-rule");
6844 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6845 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6847 cmdline_parse_token_string_t cmd_mirror_mask_what =
6848 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6849 what, "pool-mirror-up#pool-mirror-down"
6851 cmdline_parse_token_string_t cmd_mirror_mask_value =
6852 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6854 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6855 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6856 dstpool, "dst-pool");
6857 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6858 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6860 cmdline_parse_token_string_t cmd_mirror_mask_on =
6861 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6865 cmd_set_mirror_mask_parsed(void *parsed_result,
6866 __attribute__((unused)) struct cmdline *cl,
6867 __attribute__((unused)) void *data)
6870 struct cmd_set_mirror_mask_result *res = parsed_result;
6871 struct rte_eth_mirror_conf mr_conf;
6873 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6875 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6877 mr_conf.dst_pool = res->dstpool_id;
6879 if (!strcmp(res->what, "pool-mirror-up")) {
6880 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6881 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6882 } else if (!strcmp(res->what, "pool-mirror-down")) {
6883 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6884 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6885 } else if (!strcmp(res->what, "vlan-mirror")) {
6886 mr_conf.rule_type = ETH_MIRROR_VLAN;
6887 nb_item = parse_item_list(res->value, "vlan",
6888 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6892 for (i = 0; i < nb_item; i++) {
6893 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6894 printf("Invalid vlan_id: must be < 4096\n");
6898 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6899 mr_conf.vlan.vlan_mask |= 1ULL << i;
6903 if (!strcmp(res->on, "on"))
6904 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6907 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6910 printf("mirror rule add error: (%s)\n", strerror(-ret));
6913 cmdline_parse_inst_t cmd_set_mirror_mask = {
6914 .f = cmd_set_mirror_mask_parsed,
6916 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6917 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6919 (void *)&cmd_mirror_mask_set,
6920 (void *)&cmd_mirror_mask_port,
6921 (void *)&cmd_mirror_mask_portid,
6922 (void *)&cmd_mirror_mask_mirror,
6923 (void *)&cmd_mirror_mask_ruleid,
6924 (void *)&cmd_mirror_mask_what,
6925 (void *)&cmd_mirror_mask_value,
6926 (void *)&cmd_mirror_mask_dstpool,
6927 (void *)&cmd_mirror_mask_poolid,
6928 (void *)&cmd_mirror_mask_on,
6933 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6934 struct cmd_set_mirror_link_result {
6935 cmdline_fixed_string_t set;
6936 cmdline_fixed_string_t port;
6938 cmdline_fixed_string_t mirror;
6940 cmdline_fixed_string_t what;
6941 cmdline_fixed_string_t dstpool;
6943 cmdline_fixed_string_t on;
6946 cmdline_parse_token_string_t cmd_mirror_link_set =
6947 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6949 cmdline_parse_token_string_t cmd_mirror_link_port =
6950 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6952 cmdline_parse_token_num_t cmd_mirror_link_portid =
6953 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6955 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6956 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6957 mirror, "mirror-rule");
6958 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6959 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6961 cmdline_parse_token_string_t cmd_mirror_link_what =
6962 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6963 what, "uplink-mirror#downlink-mirror");
6964 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6965 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6966 dstpool, "dst-pool");
6967 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6968 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6970 cmdline_parse_token_string_t cmd_mirror_link_on =
6971 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6975 cmd_set_mirror_link_parsed(void *parsed_result,
6976 __attribute__((unused)) struct cmdline *cl,
6977 __attribute__((unused)) void *data)
6980 struct cmd_set_mirror_link_result *res = parsed_result;
6981 struct rte_eth_mirror_conf mr_conf;
6983 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6984 if (!strcmp(res->what, "uplink-mirror"))
6985 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
6987 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
6989 mr_conf.dst_pool = res->dstpool_id;
6991 if (!strcmp(res->on, "on"))
6992 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6995 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6998 /* check the return value and print it if is < 0 */
7000 printf("mirror rule add error: (%s)\n", strerror(-ret));
7004 cmdline_parse_inst_t cmd_set_mirror_link = {
7005 .f = cmd_set_mirror_link_parsed,
7007 .help_str = "set port X mirror-rule Y uplink-mirror|"
7008 "downlink-mirror dst-pool Z on|off",
7010 (void *)&cmd_mirror_link_set,
7011 (void *)&cmd_mirror_link_port,
7012 (void *)&cmd_mirror_link_portid,
7013 (void *)&cmd_mirror_link_mirror,
7014 (void *)&cmd_mirror_link_ruleid,
7015 (void *)&cmd_mirror_link_what,
7016 (void *)&cmd_mirror_link_dstpool,
7017 (void *)&cmd_mirror_link_poolid,
7018 (void *)&cmd_mirror_link_on,
7023 /* *** RESET VM MIRROR RULE *** */
7024 struct cmd_rm_mirror_rule_result {
7025 cmdline_fixed_string_t reset;
7026 cmdline_fixed_string_t port;
7028 cmdline_fixed_string_t mirror;
7032 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7033 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7035 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7036 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7038 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7039 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7041 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7042 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7043 mirror, "mirror-rule");
7044 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7045 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7049 cmd_reset_mirror_rule_parsed(void *parsed_result,
7050 __attribute__((unused)) struct cmdline *cl,
7051 __attribute__((unused)) void *data)
7054 struct cmd_set_mirror_link_result *res = parsed_result;
7056 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7058 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7061 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7062 .f = cmd_reset_mirror_rule_parsed,
7064 .help_str = "reset port X mirror-rule Y",
7066 (void *)&cmd_rm_mirror_rule_reset,
7067 (void *)&cmd_rm_mirror_rule_port,
7068 (void *)&cmd_rm_mirror_rule_portid,
7069 (void *)&cmd_rm_mirror_rule_mirror,
7070 (void *)&cmd_rm_mirror_rule_ruleid,
7075 /* ******************************************************************************** */
7077 struct cmd_dump_result {
7078 cmdline_fixed_string_t dump;
7082 dump_struct_sizes(void)
7084 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7085 DUMP_SIZE(struct rte_mbuf);
7086 DUMP_SIZE(struct rte_mempool);
7087 DUMP_SIZE(struct rte_ring);
7091 static void cmd_dump_parsed(void *parsed_result,
7092 __attribute__((unused)) struct cmdline *cl,
7093 __attribute__((unused)) void *data)
7095 struct cmd_dump_result *res = parsed_result;
7097 if (!strcmp(res->dump, "dump_physmem"))
7098 rte_dump_physmem_layout(stdout);
7099 else if (!strcmp(res->dump, "dump_memzone"))
7100 rte_memzone_dump(stdout);
7101 else if (!strcmp(res->dump, "dump_log_history"))
7102 rte_log_dump_history(stdout);
7103 else if (!strcmp(res->dump, "dump_struct_sizes"))
7104 dump_struct_sizes();
7105 else if (!strcmp(res->dump, "dump_ring"))
7106 rte_ring_list_dump(stdout);
7107 else if (!strcmp(res->dump, "dump_mempool"))
7108 rte_mempool_list_dump(stdout);
7109 else if (!strcmp(res->dump, "dump_devargs"))
7110 rte_eal_devargs_dump(stdout);
7113 cmdline_parse_token_string_t cmd_dump_dump =
7114 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7118 "dump_struct_sizes#"
7123 cmdline_parse_inst_t cmd_dump = {
7124 .f = cmd_dump_parsed, /* function to call */
7125 .data = NULL, /* 2nd arg of func */
7126 .help_str = "dump status",
7127 .tokens = { /* token list, NULL terminated */
7128 (void *)&cmd_dump_dump,
7133 /* ******************************************************************************** */
7135 struct cmd_dump_one_result {
7136 cmdline_fixed_string_t dump;
7137 cmdline_fixed_string_t name;
7140 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7141 __attribute__((unused)) void *data)
7143 struct cmd_dump_one_result *res = parsed_result;
7145 if (!strcmp(res->dump, "dump_ring")) {
7147 r = rte_ring_lookup(res->name);
7149 cmdline_printf(cl, "Cannot find ring\n");
7152 rte_ring_dump(stdout, r);
7153 } else if (!strcmp(res->dump, "dump_mempool")) {
7154 struct rte_mempool *mp;
7155 mp = rte_mempool_lookup(res->name);
7157 cmdline_printf(cl, "Cannot find mempool\n");
7160 rte_mempool_dump(stdout, mp);
7164 cmdline_parse_token_string_t cmd_dump_one_dump =
7165 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7166 "dump_ring#dump_mempool");
7168 cmdline_parse_token_string_t cmd_dump_one_name =
7169 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7171 cmdline_parse_inst_t cmd_dump_one = {
7172 .f = cmd_dump_one_parsed, /* function to call */
7173 .data = NULL, /* 2nd arg of func */
7174 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7175 .tokens = { /* token list, NULL terminated */
7176 (void *)&cmd_dump_one_dump,
7177 (void *)&cmd_dump_one_name,
7182 /* *** Add/Del syn filter *** */
7183 struct cmd_syn_filter_result {
7184 cmdline_fixed_string_t filter;
7186 cmdline_fixed_string_t ops;
7187 cmdline_fixed_string_t priority;
7188 cmdline_fixed_string_t high;
7189 cmdline_fixed_string_t queue;
7194 cmd_syn_filter_parsed(void *parsed_result,
7195 __attribute__((unused)) struct cmdline *cl,
7196 __attribute__((unused)) void *data)
7198 struct cmd_syn_filter_result *res = parsed_result;
7199 struct rte_eth_syn_filter syn_filter;
7202 ret = rte_eth_dev_filter_supported(res->port_id,
7203 RTE_ETH_FILTER_SYN);
7205 printf("syn filter is not supported on port %u.\n",
7210 memset(&syn_filter, 0, sizeof(syn_filter));
7212 if (!strcmp(res->ops, "add")) {
7213 if (!strcmp(res->high, "high"))
7214 syn_filter.hig_pri = 1;
7216 syn_filter.hig_pri = 0;
7218 syn_filter.queue = res->queue_id;
7219 ret = rte_eth_dev_filter_ctrl(res->port_id,
7224 ret = rte_eth_dev_filter_ctrl(res->port_id,
7226 RTE_ETH_FILTER_DELETE,
7230 printf("syn filter programming error: (%s)\n",
7234 cmdline_parse_token_string_t cmd_syn_filter_filter =
7235 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7236 filter, "syn_filter");
7237 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7238 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7240 cmdline_parse_token_string_t cmd_syn_filter_ops =
7241 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7243 cmdline_parse_token_string_t cmd_syn_filter_priority =
7244 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7245 priority, "priority");
7246 cmdline_parse_token_string_t cmd_syn_filter_high =
7247 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7249 cmdline_parse_token_string_t cmd_syn_filter_queue =
7250 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7252 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7253 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7256 cmdline_parse_inst_t cmd_syn_filter = {
7257 .f = cmd_syn_filter_parsed,
7259 .help_str = "add/delete syn filter",
7261 (void *)&cmd_syn_filter_filter,
7262 (void *)&cmd_syn_filter_port_id,
7263 (void *)&cmd_syn_filter_ops,
7264 (void *)&cmd_syn_filter_priority,
7265 (void *)&cmd_syn_filter_high,
7266 (void *)&cmd_syn_filter_queue,
7267 (void *)&cmd_syn_filter_queue_id,
7272 /* *** ADD/REMOVE A 2tuple FILTER *** */
7273 struct cmd_2tuple_filter_result {
7274 cmdline_fixed_string_t filter;
7276 cmdline_fixed_string_t ops;
7277 cmdline_fixed_string_t dst_port;
7278 uint16_t dst_port_value;
7279 cmdline_fixed_string_t protocol;
7280 uint8_t protocol_value;
7281 cmdline_fixed_string_t mask;
7283 cmdline_fixed_string_t tcp_flags;
7284 uint8_t tcp_flags_value;
7285 cmdline_fixed_string_t priority;
7286 uint8_t priority_value;
7287 cmdline_fixed_string_t queue;
7292 cmd_2tuple_filter_parsed(void *parsed_result,
7293 __attribute__((unused)) struct cmdline *cl,
7294 __attribute__((unused)) void *data)
7296 struct rte_eth_ntuple_filter filter;
7297 struct cmd_2tuple_filter_result *res = parsed_result;
7300 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7302 printf("ntuple filter is not supported on port %u.\n",
7307 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7309 filter.flags = RTE_2TUPLE_FLAGS;
7310 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7311 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7312 filter.proto = res->protocol_value;
7313 filter.priority = res->priority_value;
7314 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7315 printf("nonzero tcp_flags is only meaningful"
7316 " when protocol is TCP.\n");
7319 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7320 printf("invalid TCP flags.\n");
7324 if (res->tcp_flags_value != 0) {
7325 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7326 filter.tcp_flags = res->tcp_flags_value;
7329 /* need convert to big endian. */
7330 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7331 filter.queue = res->queue_id;
7333 if (!strcmp(res->ops, "add"))
7334 ret = rte_eth_dev_filter_ctrl(res->port_id,
7335 RTE_ETH_FILTER_NTUPLE,
7339 ret = rte_eth_dev_filter_ctrl(res->port_id,
7340 RTE_ETH_FILTER_NTUPLE,
7341 RTE_ETH_FILTER_DELETE,
7344 printf("2tuple filter programming error: (%s)\n",
7349 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7350 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7351 filter, "2tuple_filter");
7352 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7353 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7355 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7356 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7358 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7359 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7360 dst_port, "dst_port");
7361 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7362 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7363 dst_port_value, UINT16);
7364 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7365 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7366 protocol, "protocol");
7367 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7368 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7369 protocol_value, UINT8);
7370 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7371 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7373 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7374 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7376 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7377 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7378 tcp_flags, "tcp_flags");
7379 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7380 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7381 tcp_flags_value, UINT8);
7382 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7383 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7384 priority, "priority");
7385 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7386 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7387 priority_value, UINT8);
7388 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7389 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7391 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7392 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7395 cmdline_parse_inst_t cmd_2tuple_filter = {
7396 .f = cmd_2tuple_filter_parsed,
7398 .help_str = "add a 2tuple filter",
7400 (void *)&cmd_2tuple_filter_filter,
7401 (void *)&cmd_2tuple_filter_port_id,
7402 (void *)&cmd_2tuple_filter_ops,
7403 (void *)&cmd_2tuple_filter_dst_port,
7404 (void *)&cmd_2tuple_filter_dst_port_value,
7405 (void *)&cmd_2tuple_filter_protocol,
7406 (void *)&cmd_2tuple_filter_protocol_value,
7407 (void *)&cmd_2tuple_filter_mask,
7408 (void *)&cmd_2tuple_filter_mask_value,
7409 (void *)&cmd_2tuple_filter_tcp_flags,
7410 (void *)&cmd_2tuple_filter_tcp_flags_value,
7411 (void *)&cmd_2tuple_filter_priority,
7412 (void *)&cmd_2tuple_filter_priority_value,
7413 (void *)&cmd_2tuple_filter_queue,
7414 (void *)&cmd_2tuple_filter_queue_id,
7419 /* *** ADD/REMOVE A 5tuple FILTER *** */
7420 struct cmd_5tuple_filter_result {
7421 cmdline_fixed_string_t filter;
7423 cmdline_fixed_string_t ops;
7424 cmdline_fixed_string_t dst_ip;
7425 cmdline_ipaddr_t dst_ip_value;
7426 cmdline_fixed_string_t src_ip;
7427 cmdline_ipaddr_t src_ip_value;
7428 cmdline_fixed_string_t dst_port;
7429 uint16_t dst_port_value;
7430 cmdline_fixed_string_t src_port;
7431 uint16_t src_port_value;
7432 cmdline_fixed_string_t protocol;
7433 uint8_t protocol_value;
7434 cmdline_fixed_string_t mask;
7436 cmdline_fixed_string_t tcp_flags;
7437 uint8_t tcp_flags_value;
7438 cmdline_fixed_string_t priority;
7439 uint8_t priority_value;
7440 cmdline_fixed_string_t queue;
7445 cmd_5tuple_filter_parsed(void *parsed_result,
7446 __attribute__((unused)) struct cmdline *cl,
7447 __attribute__((unused)) void *data)
7449 struct rte_eth_ntuple_filter filter;
7450 struct cmd_5tuple_filter_result *res = parsed_result;
7453 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7455 printf("ntuple filter is not supported on port %u.\n",
7460 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7462 filter.flags = RTE_5TUPLE_FLAGS;
7463 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7464 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7465 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7466 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7467 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7468 filter.proto = res->protocol_value;
7469 filter.priority = res->priority_value;
7470 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7471 printf("nonzero tcp_flags is only meaningful"
7472 " when protocol is TCP.\n");
7475 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7476 printf("invalid TCP flags.\n");
7480 if (res->tcp_flags_value != 0) {
7481 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7482 filter.tcp_flags = res->tcp_flags_value;
7485 if (res->dst_ip_value.family == AF_INET)
7486 /* no need to convert, already big endian. */
7487 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7489 if (filter.dst_ip_mask == 0) {
7490 printf("can not support ipv6 involved compare.\n");
7496 if (res->src_ip_value.family == AF_INET)
7497 /* no need to convert, already big endian. */
7498 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7500 if (filter.src_ip_mask == 0) {
7501 printf("can not support ipv6 involved compare.\n");
7506 /* need convert to big endian. */
7507 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7508 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7509 filter.queue = res->queue_id;
7511 if (!strcmp(res->ops, "add"))
7512 ret = rte_eth_dev_filter_ctrl(res->port_id,
7513 RTE_ETH_FILTER_NTUPLE,
7517 ret = rte_eth_dev_filter_ctrl(res->port_id,
7518 RTE_ETH_FILTER_NTUPLE,
7519 RTE_ETH_FILTER_DELETE,
7522 printf("5tuple filter programming error: (%s)\n",
7526 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7527 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7528 filter, "5tuple_filter");
7529 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7530 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7532 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7533 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7535 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7536 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7538 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7539 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7541 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7542 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7544 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7545 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7547 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7548 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7549 dst_port, "dst_port");
7550 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7551 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7552 dst_port_value, UINT16);
7553 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7554 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7555 src_port, "src_port");
7556 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7557 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7558 src_port_value, UINT16);
7559 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7560 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7561 protocol, "protocol");
7562 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7563 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7564 protocol_value, UINT8);
7565 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7566 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7568 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7569 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7571 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7572 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7573 tcp_flags, "tcp_flags");
7574 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7575 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7576 tcp_flags_value, UINT8);
7577 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7578 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7579 priority, "priority");
7580 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7581 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7582 priority_value, UINT8);
7583 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7584 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7586 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7587 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7590 cmdline_parse_inst_t cmd_5tuple_filter = {
7591 .f = cmd_5tuple_filter_parsed,
7593 .help_str = "add/del a 5tuple filter",
7595 (void *)&cmd_5tuple_filter_filter,
7596 (void *)&cmd_5tuple_filter_port_id,
7597 (void *)&cmd_5tuple_filter_ops,
7598 (void *)&cmd_5tuple_filter_dst_ip,
7599 (void *)&cmd_5tuple_filter_dst_ip_value,
7600 (void *)&cmd_5tuple_filter_src_ip,
7601 (void *)&cmd_5tuple_filter_src_ip_value,
7602 (void *)&cmd_5tuple_filter_dst_port,
7603 (void *)&cmd_5tuple_filter_dst_port_value,
7604 (void *)&cmd_5tuple_filter_src_port,
7605 (void *)&cmd_5tuple_filter_src_port_value,
7606 (void *)&cmd_5tuple_filter_protocol,
7607 (void *)&cmd_5tuple_filter_protocol_value,
7608 (void *)&cmd_5tuple_filter_mask,
7609 (void *)&cmd_5tuple_filter_mask_value,
7610 (void *)&cmd_5tuple_filter_tcp_flags,
7611 (void *)&cmd_5tuple_filter_tcp_flags_value,
7612 (void *)&cmd_5tuple_filter_priority,
7613 (void *)&cmd_5tuple_filter_priority_value,
7614 (void *)&cmd_5tuple_filter_queue,
7615 (void *)&cmd_5tuple_filter_queue_id,
7620 /* *** ADD/REMOVE A flex FILTER *** */
7621 struct cmd_flex_filter_result {
7622 cmdline_fixed_string_t filter;
7623 cmdline_fixed_string_t ops;
7625 cmdline_fixed_string_t len;
7627 cmdline_fixed_string_t bytes;
7628 cmdline_fixed_string_t bytes_value;
7629 cmdline_fixed_string_t mask;
7630 cmdline_fixed_string_t mask_value;
7631 cmdline_fixed_string_t priority;
7632 uint8_t priority_value;
7633 cmdline_fixed_string_t queue;
7637 static int xdigit2val(unsigned char c)
7642 else if (isupper(c))
7650 cmd_flex_filter_parsed(void *parsed_result,
7651 __attribute__((unused)) struct cmdline *cl,
7652 __attribute__((unused)) void *data)
7655 struct rte_eth_flex_filter filter;
7656 struct cmd_flex_filter_result *res = parsed_result;
7657 char *bytes_ptr, *mask_ptr;
7658 uint16_t len, i, j = 0;
7663 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7664 printf("the len exceed the max length 128\n");
7667 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7668 filter.len = res->len_value;
7669 filter.priority = res->priority_value;
7670 filter.queue = res->queue_id;
7671 bytes_ptr = res->bytes_value;
7672 mask_ptr = res->mask_value;
7674 /* translate bytes string to array. */
7675 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7676 (bytes_ptr[1] == 'X')))
7678 len = strnlen(bytes_ptr, res->len_value * 2);
7679 if (len == 0 || (len % 8 != 0)) {
7680 printf("please check len and bytes input\n");
7683 for (i = 0; i < len; i++) {
7685 if (isxdigit(c) == 0) {
7686 /* invalid characters. */
7687 printf("invalid input\n");
7690 val = xdigit2val(c);
7693 filter.bytes[j] = byte;
7694 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7701 /* translate mask string to uint8_t array. */
7702 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7703 (mask_ptr[1] == 'X')))
7705 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7707 printf("invalid input\n");
7712 for (i = 0; i < len; i++) {
7714 if (isxdigit(c) == 0) {
7715 /* invalid characters. */
7716 printf("invalid input\n");
7719 val = xdigit2val(c);
7722 filter.mask[j] = byte;
7723 printf("mask[%d]:%02x ", j, filter.mask[j]);
7731 if (!strcmp(res->ops, "add"))
7732 ret = rte_eth_dev_filter_ctrl(res->port_id,
7733 RTE_ETH_FILTER_FLEXIBLE,
7737 ret = rte_eth_dev_filter_ctrl(res->port_id,
7738 RTE_ETH_FILTER_FLEXIBLE,
7739 RTE_ETH_FILTER_DELETE,
7743 printf("flex filter setting error: (%s)\n", strerror(-ret));
7746 cmdline_parse_token_string_t cmd_flex_filter_filter =
7747 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7748 filter, "flex_filter");
7749 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7750 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7752 cmdline_parse_token_string_t cmd_flex_filter_ops =
7753 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7755 cmdline_parse_token_string_t cmd_flex_filter_len =
7756 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7758 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7759 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7761 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7762 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7764 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7765 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7767 cmdline_parse_token_string_t cmd_flex_filter_mask =
7768 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7770 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7771 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7773 cmdline_parse_token_string_t cmd_flex_filter_priority =
7774 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7775 priority, "priority");
7776 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7777 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7778 priority_value, UINT8);
7779 cmdline_parse_token_string_t cmd_flex_filter_queue =
7780 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7782 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7783 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7785 cmdline_parse_inst_t cmd_flex_filter = {
7786 .f = cmd_flex_filter_parsed,
7788 .help_str = "add/del a flex filter",
7790 (void *)&cmd_flex_filter_filter,
7791 (void *)&cmd_flex_filter_port_id,
7792 (void *)&cmd_flex_filter_ops,
7793 (void *)&cmd_flex_filter_len,
7794 (void *)&cmd_flex_filter_len_value,
7795 (void *)&cmd_flex_filter_bytes,
7796 (void *)&cmd_flex_filter_bytes_value,
7797 (void *)&cmd_flex_filter_mask,
7798 (void *)&cmd_flex_filter_mask_value,
7799 (void *)&cmd_flex_filter_priority,
7800 (void *)&cmd_flex_filter_priority_value,
7801 (void *)&cmd_flex_filter_queue,
7802 (void *)&cmd_flex_filter_queue_id,
7807 /* *** Filters Control *** */
7809 /* *** deal with ethertype filter *** */
7810 struct cmd_ethertype_filter_result {
7811 cmdline_fixed_string_t filter;
7813 cmdline_fixed_string_t ops;
7814 cmdline_fixed_string_t mac;
7815 struct ether_addr mac_addr;
7816 cmdline_fixed_string_t ethertype;
7817 uint16_t ethertype_value;
7818 cmdline_fixed_string_t drop;
7819 cmdline_fixed_string_t queue;
7823 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7824 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7825 filter, "ethertype_filter");
7826 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7827 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7829 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7830 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7832 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7833 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7834 mac, "mac_addr#mac_ignr");
7835 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7836 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7838 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7839 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7840 ethertype, "ethertype");
7841 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7842 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7843 ethertype_value, UINT16);
7844 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7845 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7847 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7848 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7850 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7851 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7855 cmd_ethertype_filter_parsed(void *parsed_result,
7856 __attribute__((unused)) struct cmdline *cl,
7857 __attribute__((unused)) void *data)
7859 struct cmd_ethertype_filter_result *res = parsed_result;
7860 struct rte_eth_ethertype_filter filter;
7863 ret = rte_eth_dev_filter_supported(res->port_id,
7864 RTE_ETH_FILTER_ETHERTYPE);
7866 printf("ethertype filter is not supported on port %u.\n",
7871 memset(&filter, 0, sizeof(filter));
7872 if (!strcmp(res->mac, "mac_addr")) {
7873 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7874 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7875 sizeof(struct ether_addr));
7877 if (!strcmp(res->drop, "drop"))
7878 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7879 filter.ether_type = res->ethertype_value;
7880 filter.queue = res->queue_id;
7882 if (!strcmp(res->ops, "add"))
7883 ret = rte_eth_dev_filter_ctrl(res->port_id,
7884 RTE_ETH_FILTER_ETHERTYPE,
7888 ret = rte_eth_dev_filter_ctrl(res->port_id,
7889 RTE_ETH_FILTER_ETHERTYPE,
7890 RTE_ETH_FILTER_DELETE,
7893 printf("ethertype filter programming error: (%s)\n",
7897 cmdline_parse_inst_t cmd_ethertype_filter = {
7898 .f = cmd_ethertype_filter_parsed,
7900 .help_str = "add or delete an ethertype filter entry",
7902 (void *)&cmd_ethertype_filter_filter,
7903 (void *)&cmd_ethertype_filter_port_id,
7904 (void *)&cmd_ethertype_filter_ops,
7905 (void *)&cmd_ethertype_filter_mac,
7906 (void *)&cmd_ethertype_filter_mac_addr,
7907 (void *)&cmd_ethertype_filter_ethertype,
7908 (void *)&cmd_ethertype_filter_ethertype_value,
7909 (void *)&cmd_ethertype_filter_drop,
7910 (void *)&cmd_ethertype_filter_queue,
7911 (void *)&cmd_ethertype_filter_queue_id,
7916 /* *** deal with flow director filter *** */
7917 struct cmd_flow_director_result {
7918 cmdline_fixed_string_t flow_director_filter;
7920 cmdline_fixed_string_t mode;
7921 cmdline_fixed_string_t mode_value;
7922 cmdline_fixed_string_t ops;
7923 cmdline_fixed_string_t flow;
7924 cmdline_fixed_string_t flow_type;
7925 cmdline_fixed_string_t ether;
7926 uint16_t ether_type;
7927 cmdline_fixed_string_t src;
7928 cmdline_ipaddr_t ip_src;
7930 cmdline_fixed_string_t dst;
7931 cmdline_ipaddr_t ip_dst;
7933 cmdline_fixed_string_t verify_tag;
7934 uint32_t verify_tag_value;
7935 cmdline_fixed_string_t vlan;
7936 uint16_t vlan_value;
7937 cmdline_fixed_string_t flexbytes;
7938 cmdline_fixed_string_t flexbytes_value;
7939 cmdline_fixed_string_t pf_vf;
7940 cmdline_fixed_string_t drop;
7941 cmdline_fixed_string_t queue;
7943 cmdline_fixed_string_t fd_id;
7944 uint32_t fd_id_value;
7945 cmdline_fixed_string_t mac;
7946 struct ether_addr mac_addr;
7947 cmdline_fixed_string_t tunnel;
7948 cmdline_fixed_string_t tunnel_type;
7949 cmdline_fixed_string_t tunnel_id;
7950 uint32_t tunnel_id_value;
7954 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7957 const char *p, *p0 = q_arg;
7959 unsigned long int_fld;
7960 char *str_fld[max_num];
7965 p = strchr(p0, '(');
7969 p0 = strchr(p, ')');
7974 if (size >= sizeof(s))
7977 snprintf(s, sizeof(s), "%.*s", size, p);
7978 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7979 if (ret < 0 || ret > max_num)
7981 for (i = 0; i < ret; i++) {
7983 int_fld = strtoul(str_fld[i], &end, 0);
7984 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7986 flexbytes[i] = (uint8_t)int_fld;
7992 str2flowtype(char *string)
7995 static const struct {
7998 } flowtype_str[] = {
7999 {"raw", RTE_ETH_FLOW_RAW},
8000 {"ipv4", RTE_ETH_FLOW_IPV4},
8001 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8002 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8003 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8004 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8005 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8006 {"ipv6", RTE_ETH_FLOW_IPV6},
8007 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8008 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8009 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8010 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8011 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8012 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8015 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8016 if (!strcmp(flowtype_str[i].str, string))
8017 return flowtype_str[i].type;
8019 return RTE_ETH_FLOW_UNKNOWN;
8022 static enum rte_eth_fdir_tunnel_type
8023 str2fdir_tunneltype(char *string)
8027 static const struct {
8029 enum rte_eth_fdir_tunnel_type type;
8030 } tunneltype_str[] = {
8031 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8032 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8035 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8036 if (!strcmp(tunneltype_str[i].str, string))
8037 return tunneltype_str[i].type;
8039 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8042 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8044 if ((ip_addr).family == AF_INET) \
8045 (ip) = (ip_addr).addr.ipv4.s_addr; \
8047 printf("invalid parameter.\n"); \
8052 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8054 if ((ip_addr).family == AF_INET6) \
8055 (void)rte_memcpy(&(ip), \
8056 &((ip_addr).addr.ipv6), \
8057 sizeof(struct in6_addr)); \
8059 printf("invalid parameter.\n"); \
8065 cmd_flow_director_filter_parsed(void *parsed_result,
8066 __attribute__((unused)) struct cmdline *cl,
8067 __attribute__((unused)) void *data)
8069 struct cmd_flow_director_result *res = parsed_result;
8070 struct rte_eth_fdir_filter entry;
8071 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8073 unsigned long vf_id;
8076 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8078 printf("flow director is not supported on port %u.\n",
8082 memset(flexbytes, 0, sizeof(flexbytes));
8083 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8085 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8086 if (strcmp(res->mode_value, "MAC-VLAN")) {
8087 printf("Please set mode to MAC-VLAN.\n");
8090 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8091 if (strcmp(res->mode_value, "Tunnel")) {
8092 printf("Please set mode to Tunnel.\n");
8096 if (strcmp(res->mode_value, "IP")) {
8097 printf("Please set mode to IP.\n");
8100 entry.input.flow_type = str2flowtype(res->flow_type);
8103 ret = parse_flexbytes(res->flexbytes_value,
8105 RTE_ETH_FDIR_MAX_FLEXLEN);
8107 printf("error: Cannot parse flexbytes input.\n");
8111 switch (entry.input.flow_type) {
8112 case RTE_ETH_FLOW_FRAG_IPV4:
8113 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8114 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8115 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8116 IPV4_ADDR_TO_UINT(res->ip_dst,
8117 entry.input.flow.ip4_flow.dst_ip);
8118 IPV4_ADDR_TO_UINT(res->ip_src,
8119 entry.input.flow.ip4_flow.src_ip);
8120 /* need convert to big endian. */
8121 entry.input.flow.udp4_flow.dst_port =
8122 rte_cpu_to_be_16(res->port_dst);
8123 entry.input.flow.udp4_flow.src_port =
8124 rte_cpu_to_be_16(res->port_src);
8126 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8127 IPV4_ADDR_TO_UINT(res->ip_dst,
8128 entry.input.flow.sctp4_flow.ip.dst_ip);
8129 IPV4_ADDR_TO_UINT(res->ip_src,
8130 entry.input.flow.sctp4_flow.ip.src_ip);
8131 /* need convert to big endian. */
8132 entry.input.flow.sctp4_flow.dst_port =
8133 rte_cpu_to_be_16(res->port_dst);
8134 entry.input.flow.sctp4_flow.src_port =
8135 rte_cpu_to_be_16(res->port_src);
8136 entry.input.flow.sctp4_flow.verify_tag =
8137 rte_cpu_to_be_32(res->verify_tag_value);
8139 case RTE_ETH_FLOW_FRAG_IPV6:
8140 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8141 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8142 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8143 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8144 entry.input.flow.ipv6_flow.dst_ip);
8145 IPV6_ADDR_TO_ARRAY(res->ip_src,
8146 entry.input.flow.ipv6_flow.src_ip);
8147 /* need convert to big endian. */
8148 entry.input.flow.udp6_flow.dst_port =
8149 rte_cpu_to_be_16(res->port_dst);
8150 entry.input.flow.udp6_flow.src_port =
8151 rte_cpu_to_be_16(res->port_src);
8153 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8154 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8155 entry.input.flow.sctp6_flow.ip.dst_ip);
8156 IPV6_ADDR_TO_ARRAY(res->ip_src,
8157 entry.input.flow.sctp6_flow.ip.src_ip);
8158 /* need convert to big endian. */
8159 entry.input.flow.sctp6_flow.dst_port =
8160 rte_cpu_to_be_16(res->port_dst);
8161 entry.input.flow.sctp6_flow.src_port =
8162 rte_cpu_to_be_16(res->port_src);
8163 entry.input.flow.sctp6_flow.verify_tag =
8164 rte_cpu_to_be_32(res->verify_tag_value);
8166 case RTE_ETH_FLOW_L2_PAYLOAD:
8167 entry.input.flow.l2_flow.ether_type =
8168 rte_cpu_to_be_16(res->ether_type);
8174 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8175 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8177 sizeof(struct ether_addr));
8179 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8180 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8182 sizeof(struct ether_addr));
8183 entry.input.flow.tunnel_flow.tunnel_type =
8184 str2fdir_tunneltype(res->tunnel_type);
8185 entry.input.flow.tunnel_flow.tunnel_id =
8186 rte_cpu_to_be_32(res->tunnel_id_value);
8189 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8191 RTE_ETH_FDIR_MAX_FLEXLEN);
8193 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8195 entry.action.flex_off = 0; /*use 0 by default */
8196 if (!strcmp(res->drop, "drop"))
8197 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8199 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8201 if (!strcmp(res->pf_vf, "pf"))
8202 entry.input.flow_ext.is_vf = 0;
8203 else if (!strncmp(res->pf_vf, "vf", 2)) {
8204 struct rte_eth_dev_info dev_info;
8206 memset(&dev_info, 0, sizeof(dev_info));
8207 rte_eth_dev_info_get(res->port_id, &dev_info);
8209 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8210 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8211 printf("invalid parameter %s.\n", res->pf_vf);
8214 entry.input.flow_ext.is_vf = 1;
8215 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8217 printf("invalid parameter %s.\n", res->pf_vf);
8221 /* set to report FD ID by default */
8222 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8223 entry.action.rx_queue = res->queue_id;
8224 entry.soft_id = res->fd_id_value;
8225 if (!strcmp(res->ops, "add"))
8226 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8227 RTE_ETH_FILTER_ADD, &entry);
8228 else if (!strcmp(res->ops, "del"))
8229 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8230 RTE_ETH_FILTER_DELETE, &entry);
8232 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8233 RTE_ETH_FILTER_UPDATE, &entry);
8235 printf("flow director programming error: (%s)\n",
8239 cmdline_parse_token_string_t cmd_flow_director_filter =
8240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8241 flow_director_filter, "flow_director_filter");
8242 cmdline_parse_token_num_t cmd_flow_director_port_id =
8243 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8245 cmdline_parse_token_string_t cmd_flow_director_ops =
8246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8247 ops, "add#del#update");
8248 cmdline_parse_token_string_t cmd_flow_director_flow =
8249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8251 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8253 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8254 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8255 cmdline_parse_token_string_t cmd_flow_director_ether =
8256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8258 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8259 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8260 ether_type, UINT16);
8261 cmdline_parse_token_string_t cmd_flow_director_src =
8262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8264 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8265 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8267 cmdline_parse_token_num_t cmd_flow_director_port_src =
8268 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8270 cmdline_parse_token_string_t cmd_flow_director_dst =
8271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8273 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8274 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8276 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8277 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8279 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8281 verify_tag, "verify_tag");
8282 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8283 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8284 verify_tag_value, UINT32);
8285 cmdline_parse_token_string_t cmd_flow_director_vlan =
8286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8288 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8289 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8290 vlan_value, UINT16);
8291 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8293 flexbytes, "flexbytes");
8294 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8296 flexbytes_value, NULL);
8297 cmdline_parse_token_string_t cmd_flow_director_drop =
8298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8300 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8301 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8303 cmdline_parse_token_string_t cmd_flow_director_queue =
8304 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8306 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8307 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8309 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8312 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8313 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8314 fd_id_value, UINT32);
8316 cmdline_parse_token_string_t cmd_flow_director_mode =
8317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8319 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8322 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8324 mode_value, "MAC-VLAN");
8325 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8327 mode_value, "Tunnel");
8328 cmdline_parse_token_string_t cmd_flow_director_mac =
8329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8331 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8332 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8334 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8337 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8339 tunnel_type, "NVGRE#VxLAN");
8340 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8342 tunnel_id, "tunnel-id");
8343 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8344 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8345 tunnel_id_value, UINT32);
8347 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8348 .f = cmd_flow_director_filter_parsed,
8350 .help_str = "add or delete an ip flow director entry on NIC",
8352 (void *)&cmd_flow_director_filter,
8353 (void *)&cmd_flow_director_port_id,
8354 (void *)&cmd_flow_director_mode,
8355 (void *)&cmd_flow_director_mode_ip,
8356 (void *)&cmd_flow_director_ops,
8357 (void *)&cmd_flow_director_flow,
8358 (void *)&cmd_flow_director_flow_type,
8359 (void *)&cmd_flow_director_src,
8360 (void *)&cmd_flow_director_ip_src,
8361 (void *)&cmd_flow_director_dst,
8362 (void *)&cmd_flow_director_ip_dst,
8363 (void *)&cmd_flow_director_vlan,
8364 (void *)&cmd_flow_director_vlan_value,
8365 (void *)&cmd_flow_director_flexbytes,
8366 (void *)&cmd_flow_director_flexbytes_value,
8367 (void *)&cmd_flow_director_drop,
8368 (void *)&cmd_flow_director_pf_vf,
8369 (void *)&cmd_flow_director_queue,
8370 (void *)&cmd_flow_director_queue_id,
8371 (void *)&cmd_flow_director_fd_id,
8372 (void *)&cmd_flow_director_fd_id_value,
8377 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8378 .f = cmd_flow_director_filter_parsed,
8380 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8382 (void *)&cmd_flow_director_filter,
8383 (void *)&cmd_flow_director_port_id,
8384 (void *)&cmd_flow_director_mode,
8385 (void *)&cmd_flow_director_mode_ip,
8386 (void *)&cmd_flow_director_ops,
8387 (void *)&cmd_flow_director_flow,
8388 (void *)&cmd_flow_director_flow_type,
8389 (void *)&cmd_flow_director_src,
8390 (void *)&cmd_flow_director_ip_src,
8391 (void *)&cmd_flow_director_port_src,
8392 (void *)&cmd_flow_director_dst,
8393 (void *)&cmd_flow_director_ip_dst,
8394 (void *)&cmd_flow_director_port_dst,
8395 (void *)&cmd_flow_director_vlan,
8396 (void *)&cmd_flow_director_vlan_value,
8397 (void *)&cmd_flow_director_flexbytes,
8398 (void *)&cmd_flow_director_flexbytes_value,
8399 (void *)&cmd_flow_director_drop,
8400 (void *)&cmd_flow_director_pf_vf,
8401 (void *)&cmd_flow_director_queue,
8402 (void *)&cmd_flow_director_queue_id,
8403 (void *)&cmd_flow_director_fd_id,
8404 (void *)&cmd_flow_director_fd_id_value,
8409 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8410 .f = cmd_flow_director_filter_parsed,
8412 .help_str = "add or delete a sctp flow director entry on NIC",
8414 (void *)&cmd_flow_director_filter,
8415 (void *)&cmd_flow_director_port_id,
8416 (void *)&cmd_flow_director_mode,
8417 (void *)&cmd_flow_director_mode_ip,
8418 (void *)&cmd_flow_director_ops,
8419 (void *)&cmd_flow_director_flow,
8420 (void *)&cmd_flow_director_flow_type,
8421 (void *)&cmd_flow_director_src,
8422 (void *)&cmd_flow_director_ip_src,
8423 (void *)&cmd_flow_director_port_dst,
8424 (void *)&cmd_flow_director_dst,
8425 (void *)&cmd_flow_director_ip_dst,
8426 (void *)&cmd_flow_director_port_dst,
8427 (void *)&cmd_flow_director_verify_tag,
8428 (void *)&cmd_flow_director_verify_tag_value,
8429 (void *)&cmd_flow_director_vlan,
8430 (void *)&cmd_flow_director_vlan_value,
8431 (void *)&cmd_flow_director_flexbytes,
8432 (void *)&cmd_flow_director_flexbytes_value,
8433 (void *)&cmd_flow_director_drop,
8434 (void *)&cmd_flow_director_pf_vf,
8435 (void *)&cmd_flow_director_queue,
8436 (void *)&cmd_flow_director_queue_id,
8437 (void *)&cmd_flow_director_fd_id,
8438 (void *)&cmd_flow_director_fd_id_value,
8443 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8444 .f = cmd_flow_director_filter_parsed,
8446 .help_str = "add or delete a L2 flow director entry on NIC",
8448 (void *)&cmd_flow_director_filter,
8449 (void *)&cmd_flow_director_port_id,
8450 (void *)&cmd_flow_director_mode,
8451 (void *)&cmd_flow_director_mode_ip,
8452 (void *)&cmd_flow_director_ops,
8453 (void *)&cmd_flow_director_flow,
8454 (void *)&cmd_flow_director_flow_type,
8455 (void *)&cmd_flow_director_ether,
8456 (void *)&cmd_flow_director_ether_type,
8457 (void *)&cmd_flow_director_flexbytes,
8458 (void *)&cmd_flow_director_flexbytes_value,
8459 (void *)&cmd_flow_director_drop,
8460 (void *)&cmd_flow_director_pf_vf,
8461 (void *)&cmd_flow_director_queue,
8462 (void *)&cmd_flow_director_queue_id,
8463 (void *)&cmd_flow_director_fd_id,
8464 (void *)&cmd_flow_director_fd_id_value,
8469 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8470 .f = cmd_flow_director_filter_parsed,
8472 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8474 (void *)&cmd_flow_director_filter,
8475 (void *)&cmd_flow_director_port_id,
8476 (void *)&cmd_flow_director_mode,
8477 (void *)&cmd_flow_director_mode_mac_vlan,
8478 (void *)&cmd_flow_director_ops,
8479 (void *)&cmd_flow_director_mac,
8480 (void *)&cmd_flow_director_mac_addr,
8481 (void *)&cmd_flow_director_vlan,
8482 (void *)&cmd_flow_director_vlan_value,
8483 (void *)&cmd_flow_director_flexbytes,
8484 (void *)&cmd_flow_director_flexbytes_value,
8485 (void *)&cmd_flow_director_drop,
8486 (void *)&cmd_flow_director_queue,
8487 (void *)&cmd_flow_director_queue_id,
8488 (void *)&cmd_flow_director_fd_id,
8489 (void *)&cmd_flow_director_fd_id_value,
8494 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8495 .f = cmd_flow_director_filter_parsed,
8497 .help_str = "add or delete a tunnel flow director entry on NIC",
8499 (void *)&cmd_flow_director_filter,
8500 (void *)&cmd_flow_director_port_id,
8501 (void *)&cmd_flow_director_mode,
8502 (void *)&cmd_flow_director_mode_tunnel,
8503 (void *)&cmd_flow_director_ops,
8504 (void *)&cmd_flow_director_mac,
8505 (void *)&cmd_flow_director_mac_addr,
8506 (void *)&cmd_flow_director_vlan,
8507 (void *)&cmd_flow_director_vlan_value,
8508 (void *)&cmd_flow_director_tunnel,
8509 (void *)&cmd_flow_director_tunnel_type,
8510 (void *)&cmd_flow_director_tunnel_id,
8511 (void *)&cmd_flow_director_tunnel_id_value,
8512 (void *)&cmd_flow_director_flexbytes,
8513 (void *)&cmd_flow_director_flexbytes_value,
8514 (void *)&cmd_flow_director_drop,
8515 (void *)&cmd_flow_director_queue,
8516 (void *)&cmd_flow_director_queue_id,
8517 (void *)&cmd_flow_director_fd_id,
8518 (void *)&cmd_flow_director_fd_id_value,
8523 struct cmd_flush_flow_director_result {
8524 cmdline_fixed_string_t flush_flow_director;
8528 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8529 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8530 flush_flow_director, "flush_flow_director");
8531 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8532 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8536 cmd_flush_flow_director_parsed(void *parsed_result,
8537 __attribute__((unused)) struct cmdline *cl,
8538 __attribute__((unused)) void *data)
8540 struct cmd_flow_director_result *res = parsed_result;
8543 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8545 printf("flow director is not supported on port %u.\n",
8550 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8551 RTE_ETH_FILTER_FLUSH, NULL);
8553 printf("flow director table flushing error: (%s)\n",
8557 cmdline_parse_inst_t cmd_flush_flow_director = {
8558 .f = cmd_flush_flow_director_parsed,
8560 .help_str = "flush all flow director entries of a device on NIC",
8562 (void *)&cmd_flush_flow_director_flush,
8563 (void *)&cmd_flush_flow_director_port_id,
8568 /* *** deal with flow director mask *** */
8569 struct cmd_flow_director_mask_result {
8570 cmdline_fixed_string_t flow_director_mask;
8572 cmdline_fixed_string_t mode;
8573 cmdline_fixed_string_t mode_value;
8574 cmdline_fixed_string_t vlan;
8576 cmdline_fixed_string_t src_mask;
8577 cmdline_ipaddr_t ipv4_src;
8578 cmdline_ipaddr_t ipv6_src;
8580 cmdline_fixed_string_t dst_mask;
8581 cmdline_ipaddr_t ipv4_dst;
8582 cmdline_ipaddr_t ipv6_dst;
8584 cmdline_fixed_string_t mac;
8585 uint8_t mac_addr_byte_mask;
8586 cmdline_fixed_string_t tunnel_id;
8587 uint32_t tunnel_id_mask;
8588 cmdline_fixed_string_t tunnel_type;
8589 uint8_t tunnel_type_mask;
8593 cmd_flow_director_mask_parsed(void *parsed_result,
8594 __attribute__((unused)) struct cmdline *cl,
8595 __attribute__((unused)) void *data)
8597 struct cmd_flow_director_mask_result *res = parsed_result;
8598 struct rte_eth_fdir_masks *mask;
8599 struct rte_port *port;
8601 if (res->port_id > nb_ports) {
8602 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8606 port = &ports[res->port_id];
8607 /** Check if the port is not started **/
8608 if (port->port_status != RTE_PORT_STOPPED) {
8609 printf("Please stop port %d first\n", res->port_id);
8613 mask = &port->dev_conf.fdir_conf.mask;
8615 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8616 if (strcmp(res->mode_value, "MAC-VLAN")) {
8617 printf("Please set mode to MAC-VLAN.\n");
8621 mask->vlan_tci_mask = res->vlan_mask;
8622 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8623 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8624 if (strcmp(res->mode_value, "Tunnel")) {
8625 printf("Please set mode to Tunnel.\n");
8629 mask->vlan_tci_mask = res->vlan_mask;
8630 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8631 mask->tunnel_id_mask = res->tunnel_id_mask;
8632 mask->tunnel_type_mask = res->tunnel_type_mask;
8634 if (strcmp(res->mode_value, "IP")) {
8635 printf("Please set mode to IP.\n");
8639 mask->vlan_tci_mask = res->vlan_mask;
8640 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8641 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8642 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8643 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8644 mask->src_port_mask = res->port_src;
8645 mask->dst_port_mask = res->port_dst;
8648 cmd_reconfig_device_queue(res->port_id, 1, 1);
8651 cmdline_parse_token_string_t cmd_flow_director_mask =
8652 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8653 flow_director_mask, "flow_director_mask");
8654 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8655 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8657 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8658 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8660 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8661 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8663 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8664 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8665 src_mask, "src_mask");
8666 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8667 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8669 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8670 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8672 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8673 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8675 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8676 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8677 dst_mask, "dst_mask");
8678 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8679 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8681 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8682 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8684 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8685 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8688 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8689 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8691 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8692 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8694 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8696 mode_value, "MAC-VLAN");
8697 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8698 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8699 mode_value, "Tunnel");
8700 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8701 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8703 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8704 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8705 mac_addr_byte_mask, UINT8);
8706 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8707 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8708 tunnel_type, "tunnel-type");
8709 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8710 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8711 tunnel_type_mask, UINT8);
8712 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8713 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8714 tunnel_id, "tunnel-id");
8715 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8716 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8717 tunnel_id_mask, UINT32);
8719 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8720 .f = cmd_flow_director_mask_parsed,
8722 .help_str = "set IP mode flow director's mask on NIC",
8724 (void *)&cmd_flow_director_mask,
8725 (void *)&cmd_flow_director_mask_port_id,
8726 (void *)&cmd_flow_director_mask_mode,
8727 (void *)&cmd_flow_director_mask_mode_ip,
8728 (void *)&cmd_flow_director_mask_vlan,
8729 (void *)&cmd_flow_director_mask_vlan_value,
8730 (void *)&cmd_flow_director_mask_src,
8731 (void *)&cmd_flow_director_mask_ipv4_src,
8732 (void *)&cmd_flow_director_mask_ipv6_src,
8733 (void *)&cmd_flow_director_mask_port_src,
8734 (void *)&cmd_flow_director_mask_dst,
8735 (void *)&cmd_flow_director_mask_ipv4_dst,
8736 (void *)&cmd_flow_director_mask_ipv6_dst,
8737 (void *)&cmd_flow_director_mask_port_dst,
8742 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8743 .f = cmd_flow_director_mask_parsed,
8745 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8747 (void *)&cmd_flow_director_mask,
8748 (void *)&cmd_flow_director_mask_port_id,
8749 (void *)&cmd_flow_director_mask_mode,
8750 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8751 (void *)&cmd_flow_director_mask_vlan,
8752 (void *)&cmd_flow_director_mask_vlan_value,
8753 (void *)&cmd_flow_director_mask_mac,
8754 (void *)&cmd_flow_director_mask_mac_value,
8759 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8760 .f = cmd_flow_director_mask_parsed,
8762 .help_str = "set tunnel mode flow director's mask on NIC",
8764 (void *)&cmd_flow_director_mask,
8765 (void *)&cmd_flow_director_mask_port_id,
8766 (void *)&cmd_flow_director_mask_mode,
8767 (void *)&cmd_flow_director_mask_mode_tunnel,
8768 (void *)&cmd_flow_director_mask_vlan,
8769 (void *)&cmd_flow_director_mask_vlan_value,
8770 (void *)&cmd_flow_director_mask_mac,
8771 (void *)&cmd_flow_director_mask_mac_value,
8772 (void *)&cmd_flow_director_mask_tunnel_type,
8773 (void *)&cmd_flow_director_mask_tunnel_type_value,
8774 (void *)&cmd_flow_director_mask_tunnel_id,
8775 (void *)&cmd_flow_director_mask_tunnel_id_value,
8780 /* *** deal with flow director mask on flexible payload *** */
8781 struct cmd_flow_director_flex_mask_result {
8782 cmdline_fixed_string_t flow_director_flexmask;
8784 cmdline_fixed_string_t flow;
8785 cmdline_fixed_string_t flow_type;
8786 cmdline_fixed_string_t mask;
8790 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8791 __attribute__((unused)) struct cmdline *cl,
8792 __attribute__((unused)) void *data)
8794 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8795 struct rte_eth_fdir_info fdir_info;
8796 struct rte_eth_fdir_flex_mask flex_mask;
8797 struct rte_port *port;
8798 uint32_t flow_type_mask;
8802 if (res->port_id > nb_ports) {
8803 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8807 port = &ports[res->port_id];
8808 /** Check if the port is not started **/
8809 if (port->port_status != RTE_PORT_STOPPED) {
8810 printf("Please stop port %d first\n", res->port_id);
8814 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8815 ret = parse_flexbytes(res->mask,
8817 RTE_ETH_FDIR_MAX_FLEXLEN);
8819 printf("error: Cannot parse mask input.\n");
8823 memset(&fdir_info, 0, sizeof(fdir_info));
8824 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8825 RTE_ETH_FILTER_INFO, &fdir_info);
8827 printf("Cannot get FDir filter info\n");
8831 if (!strcmp(res->flow_type, "none")) {
8832 /* means don't specify the flow type */
8833 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8834 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8835 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8836 0, sizeof(struct rte_eth_fdir_flex_mask));
8837 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8838 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8840 sizeof(struct rte_eth_fdir_flex_mask));
8841 cmd_reconfig_device_queue(res->port_id, 1, 1);
8844 flow_type_mask = fdir_info.flow_types_mask[0];
8845 if (!strcmp(res->flow_type, "all")) {
8846 if (!flow_type_mask) {
8847 printf("No flow type supported\n");
8850 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8851 if (flow_type_mask & (1 << i)) {
8852 flex_mask.flow_type = i;
8853 fdir_set_flex_mask(res->port_id, &flex_mask);
8856 cmd_reconfig_device_queue(res->port_id, 1, 1);
8859 flex_mask.flow_type = str2flowtype(res->flow_type);
8860 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8861 printf("Flow type %s not supported on port %d\n",
8862 res->flow_type, res->port_id);
8865 fdir_set_flex_mask(res->port_id, &flex_mask);
8866 cmd_reconfig_device_queue(res->port_id, 1, 1);
8869 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8871 flow_director_flexmask,
8872 "flow_director_flex_mask");
8873 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8874 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8876 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8877 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8879 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8881 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8882 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8883 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8884 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8887 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8888 .f = cmd_flow_director_flex_mask_parsed,
8890 .help_str = "set flow director's flex mask on NIC",
8892 (void *)&cmd_flow_director_flexmask,
8893 (void *)&cmd_flow_director_flexmask_port_id,
8894 (void *)&cmd_flow_director_flexmask_flow,
8895 (void *)&cmd_flow_director_flexmask_flow_type,
8896 (void *)&cmd_flow_director_flexmask_mask,
8901 /* *** deal with flow director flexible payload configuration *** */
8902 struct cmd_flow_director_flexpayload_result {
8903 cmdline_fixed_string_t flow_director_flexpayload;
8905 cmdline_fixed_string_t payload_layer;
8906 cmdline_fixed_string_t payload_cfg;
8910 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8913 const char *p, *p0 = q_arg;
8915 unsigned long int_fld;
8916 char *str_fld[max_num];
8921 p = strchr(p0, '(');
8925 p0 = strchr(p, ')');
8930 if (size >= sizeof(s))
8933 snprintf(s, sizeof(s), "%.*s", size, p);
8934 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8935 if (ret < 0 || ret > max_num)
8937 for (i = 0; i < ret; i++) {
8939 int_fld = strtoul(str_fld[i], &end, 0);
8940 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8942 offsets[i] = (uint16_t)int_fld;
8948 cmd_flow_director_flxpld_parsed(void *parsed_result,
8949 __attribute__((unused)) struct cmdline *cl,
8950 __attribute__((unused)) void *data)
8952 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8953 struct rte_eth_flex_payload_cfg flex_cfg;
8954 struct rte_port *port;
8957 if (res->port_id > nb_ports) {
8958 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8962 port = &ports[res->port_id];
8963 /** Check if the port is not started **/
8964 if (port->port_status != RTE_PORT_STOPPED) {
8965 printf("Please stop port %d first\n", res->port_id);
8969 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8971 if (!strcmp(res->payload_layer, "raw"))
8972 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8973 else if (!strcmp(res->payload_layer, "l2"))
8974 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8975 else if (!strcmp(res->payload_layer, "l3"))
8976 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8977 else if (!strcmp(res->payload_layer, "l4"))
8978 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8980 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8981 RTE_ETH_FDIR_MAX_FLEXLEN);
8983 printf("error: Cannot parse flex payload input.\n");
8987 fdir_set_flex_payload(res->port_id, &flex_cfg);
8988 cmd_reconfig_device_queue(res->port_id, 1, 1);
8991 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8992 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8993 flow_director_flexpayload,
8994 "flow_director_flex_payload");
8995 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8996 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8998 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8999 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9000 payload_layer, "raw#l2#l3#l4");
9001 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9002 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9005 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9006 .f = cmd_flow_director_flxpld_parsed,
9008 .help_str = "set flow director's flex payload on NIC",
9010 (void *)&cmd_flow_director_flexpayload,
9011 (void *)&cmd_flow_director_flexpayload_port_id,
9012 (void *)&cmd_flow_director_flexpayload_payload_layer,
9013 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9018 /* *** Classification Filters Control *** */
9019 /* *** Get symmetric hash enable per port *** */
9020 struct cmd_get_sym_hash_ena_per_port_result {
9021 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9026 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9027 __rte_unused struct cmdline *cl,
9028 __rte_unused void *data)
9030 struct cmd_get_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 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9044 RTE_ETH_FILTER_GET, &info);
9047 printf("Cannot get symmetric hash enable per port "
9048 "on port %u\n", res->port_id);
9052 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9053 "enabled" : "disabled", res->port_id);
9056 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9057 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9058 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9059 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9060 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9063 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9064 .f = cmd_get_sym_hash_per_port_parsed,
9066 .help_str = "get_sym_hash_ena_per_port port_id",
9068 (void *)&cmd_get_sym_hash_ena_per_port_all,
9069 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9074 /* *** Set symmetric hash enable per port *** */
9075 struct cmd_set_sym_hash_ena_per_port_result {
9076 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9077 cmdline_fixed_string_t enable;
9082 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9083 __rte_unused struct cmdline *cl,
9084 __rte_unused void *data)
9086 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9087 struct rte_eth_hash_filter_info info;
9090 if (rte_eth_dev_filter_supported(res->port_id,
9091 RTE_ETH_FILTER_HASH) < 0) {
9092 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9097 memset(&info, 0, sizeof(info));
9098 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9099 if (!strcmp(res->enable, "enable"))
9100 info.info.enable = 1;
9101 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9102 RTE_ETH_FILTER_SET, &info);
9104 printf("Cannot set symmetric hash enable per port on "
9105 "port %u\n", res->port_id);
9108 printf("Symmetric hash has been set to %s on port %u\n",
9109 res->enable, res->port_id);
9112 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9113 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9114 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9115 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9116 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9118 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9119 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9120 enable, "enable#disable");
9122 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9123 .f = cmd_set_sym_hash_per_port_parsed,
9125 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9127 (void *)&cmd_set_sym_hash_ena_per_port_all,
9128 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9129 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9134 /* Get global config of hash function */
9135 struct cmd_get_hash_global_config_result {
9136 cmdline_fixed_string_t get_hash_global_config;
9141 flowtype_to_str(uint16_t ftype)
9148 {"ipv4", RTE_ETH_FLOW_IPV4},
9149 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9150 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9151 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9152 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9153 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9154 {"ipv6", RTE_ETH_FLOW_IPV6},
9155 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9156 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9157 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9158 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9159 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9160 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9163 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9164 if (ftype_table[i].ftype == ftype)
9165 return ftype_table[i].str;
9172 cmd_get_hash_global_config_parsed(void *parsed_result,
9173 __rte_unused struct cmdline *cl,
9174 __rte_unused void *data)
9176 struct cmd_get_hash_global_config_result *res = parsed_result;
9177 struct rte_eth_hash_filter_info info;
9178 uint32_t idx, offset;
9183 if (rte_eth_dev_filter_supported(res->port_id,
9184 RTE_ETH_FILTER_HASH) < 0) {
9185 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9190 memset(&info, 0, sizeof(info));
9191 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9192 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9193 RTE_ETH_FILTER_GET, &info);
9195 printf("Cannot get hash global configurations by port %d\n",
9200 switch (info.info.global_conf.hash_func) {
9201 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9202 printf("Hash function is Toeplitz\n");
9204 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9205 printf("Hash function is Simple XOR\n");
9208 printf("Unknown hash function\n");
9212 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9213 idx = i / UINT32_BIT;
9214 offset = i % UINT32_BIT;
9215 if (!(info.info.global_conf.valid_bit_mask[idx] &
9218 str = flowtype_to_str(i);
9221 printf("Symmetric hash is %s globally for flow type %s "
9223 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9224 (1UL << offset)) ? "enabled" : "disabled"), str,
9229 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9230 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9231 get_hash_global_config, "get_hash_global_config");
9232 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9233 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9236 cmdline_parse_inst_t cmd_get_hash_global_config = {
9237 .f = cmd_get_hash_global_config_parsed,
9239 .help_str = "get_hash_global_config port_id",
9241 (void *)&cmd_get_hash_global_config_all,
9242 (void *)&cmd_get_hash_global_config_port_id,
9247 /* Set global config of hash function */
9248 struct cmd_set_hash_global_config_result {
9249 cmdline_fixed_string_t set_hash_global_config;
9251 cmdline_fixed_string_t hash_func;
9252 cmdline_fixed_string_t flow_type;
9253 cmdline_fixed_string_t enable;
9257 cmd_set_hash_global_config_parsed(void *parsed_result,
9258 __rte_unused struct cmdline *cl,
9259 __rte_unused void *data)
9261 struct cmd_set_hash_global_config_result *res = parsed_result;
9262 struct rte_eth_hash_filter_info info;
9263 uint32_t ftype, idx, offset;
9266 if (rte_eth_dev_filter_supported(res->port_id,
9267 RTE_ETH_FILTER_HASH) < 0) {
9268 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9272 memset(&info, 0, sizeof(info));
9273 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9274 if (!strcmp(res->hash_func, "toeplitz"))
9275 info.info.global_conf.hash_func =
9276 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9277 else if (!strcmp(res->hash_func, "simple_xor"))
9278 info.info.global_conf.hash_func =
9279 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9280 else if (!strcmp(res->hash_func, "default"))
9281 info.info.global_conf.hash_func =
9282 RTE_ETH_HASH_FUNCTION_DEFAULT;
9284 ftype = str2flowtype(res->flow_type);
9285 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9286 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9287 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9288 if (!strcmp(res->enable, "enable"))
9289 info.info.global_conf.sym_hash_enable_mask[idx] |=
9291 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9292 RTE_ETH_FILTER_SET, &info);
9294 printf("Cannot set global hash configurations by port %d\n",
9297 printf("Global hash configurations have been set "
9298 "succcessfully by port %d\n", res->port_id);
9301 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9302 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9303 set_hash_global_config, "set_hash_global_config");
9304 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9305 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9307 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9308 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9309 hash_func, "toeplitz#simple_xor#default");
9310 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9311 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9313 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9314 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9315 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9316 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9317 enable, "enable#disable");
9319 cmdline_parse_inst_t cmd_set_hash_global_config = {
9320 .f = cmd_set_hash_global_config_parsed,
9322 .help_str = "set_hash_global_config port_id "
9323 "toeplitz|simple_xor|default "
9324 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9325 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9328 (void *)&cmd_set_hash_global_config_all,
9329 (void *)&cmd_set_hash_global_config_port_id,
9330 (void *)&cmd_set_hash_global_config_hash_func,
9331 (void *)&cmd_set_hash_global_config_flow_type,
9332 (void *)&cmd_set_hash_global_config_enable,
9337 /* Set hash input set */
9338 struct cmd_set_hash_input_set_result {
9339 cmdline_fixed_string_t set_hash_input_set;
9341 cmdline_fixed_string_t flow_type;
9342 cmdline_fixed_string_t inset_field;
9343 cmdline_fixed_string_t select;
9346 static enum rte_eth_input_set_field
9347 str2inset(char *string)
9351 static const struct {
9353 enum rte_eth_input_set_field inset;
9355 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9356 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9357 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9358 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9359 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9360 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9361 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9362 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9363 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9364 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9365 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9366 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9367 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9368 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9369 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9370 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9371 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9372 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9373 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9374 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9375 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9376 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9377 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9378 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9379 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9380 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9381 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9382 {"none", RTE_ETH_INPUT_SET_NONE},
9385 for (i = 0; i < RTE_DIM(inset_table); i++) {
9386 if (!strcmp(string, inset_table[i].str))
9387 return inset_table[i].inset;
9390 return RTE_ETH_INPUT_SET_UNKNOWN;
9394 cmd_set_hash_input_set_parsed(void *parsed_result,
9395 __rte_unused struct cmdline *cl,
9396 __rte_unused void *data)
9398 struct cmd_set_hash_input_set_result *res = parsed_result;
9399 struct rte_eth_hash_filter_info info;
9401 memset(&info, 0, sizeof(info));
9402 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9403 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9404 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9405 info.info.input_set_conf.inset_size = 1;
9406 if (!strcmp(res->select, "select"))
9407 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9408 else if (!strcmp(res->select, "add"))
9409 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9410 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9411 RTE_ETH_FILTER_SET, &info);
9414 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9415 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9416 set_hash_input_set, "set_hash_input_set");
9417 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9418 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9420 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9421 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9423 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9424 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9425 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9426 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9428 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9429 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9430 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9431 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9432 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9434 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9435 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9436 select, "select#add");
9438 cmdline_parse_inst_t cmd_set_hash_input_set = {
9439 .f = cmd_set_hash_input_set_parsed,
9441 .help_str = "set_hash_input_set <port_id> "
9442 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9443 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9444 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9445 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9446 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9447 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9448 "fld-7th|fld-8th|none select|add",
9450 (void *)&cmd_set_hash_input_set_cmd,
9451 (void *)&cmd_set_hash_input_set_port_id,
9452 (void *)&cmd_set_hash_input_set_flow_type,
9453 (void *)&cmd_set_hash_input_set_field,
9454 (void *)&cmd_set_hash_input_set_select,
9459 /* Set flow director input set */
9460 struct cmd_set_fdir_input_set_result {
9461 cmdline_fixed_string_t set_fdir_input_set;
9463 cmdline_fixed_string_t flow_type;
9464 cmdline_fixed_string_t inset_field;
9465 cmdline_fixed_string_t select;
9469 cmd_set_fdir_input_set_parsed(void *parsed_result,
9470 __rte_unused struct cmdline *cl,
9471 __rte_unused void *data)
9473 struct cmd_set_fdir_input_set_result *res = parsed_result;
9474 struct rte_eth_fdir_filter_info info;
9476 memset(&info, 0, sizeof(info));
9477 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9478 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9479 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9480 info.info.input_set_conf.inset_size = 1;
9481 if (!strcmp(res->select, "select"))
9482 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9483 else if (!strcmp(res->select, "add"))
9484 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9485 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9486 RTE_ETH_FILTER_SET, &info);
9489 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9490 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9491 set_fdir_input_set, "set_fdir_input_set");
9492 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9493 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9495 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9496 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9498 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9499 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9500 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9501 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9503 "src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#udp-src-port#udp-dst-port#"
9504 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9505 "sctp-veri-tag#fld-1st#fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#"
9506 "fld-7th#fld-8th#none");
9507 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9508 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9509 select, "select#add");
9511 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9512 .f = cmd_set_fdir_input_set_parsed,
9514 .help_str = "set_fdir_input_set <port_id> "
9515 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9516 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9517 "src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port|"
9518 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|"
9519 "fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9520 "fld-7th|fld-8th|none select|add",
9522 (void *)&cmd_set_fdir_input_set_cmd,
9523 (void *)&cmd_set_fdir_input_set_port_id,
9524 (void *)&cmd_set_fdir_input_set_flow_type,
9525 (void *)&cmd_set_fdir_input_set_field,
9526 (void *)&cmd_set_fdir_input_set_select,
9531 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9532 struct cmd_mcast_addr_result {
9533 cmdline_fixed_string_t mcast_addr_cmd;
9534 cmdline_fixed_string_t what;
9536 struct ether_addr mc_addr;
9539 static void cmd_mcast_addr_parsed(void *parsed_result,
9540 __attribute__((unused)) struct cmdline *cl,
9541 __attribute__((unused)) void *data)
9543 struct cmd_mcast_addr_result *res = parsed_result;
9545 if (!is_multicast_ether_addr(&res->mc_addr)) {
9546 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9547 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9548 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9549 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9552 if (strcmp(res->what, "add") == 0)
9553 mcast_addr_add(res->port_num, &res->mc_addr);
9555 mcast_addr_remove(res->port_num, &res->mc_addr);
9558 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9559 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9560 mcast_addr_cmd, "mcast_addr");
9561 cmdline_parse_token_string_t cmd_mcast_addr_what =
9562 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9564 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9565 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9566 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9567 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9569 cmdline_parse_inst_t cmd_mcast_addr = {
9570 .f = cmd_mcast_addr_parsed,
9572 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9574 (void *)&cmd_mcast_addr_cmd,
9575 (void *)&cmd_mcast_addr_what,
9576 (void *)&cmd_mcast_addr_portnum,
9577 (void *)&cmd_mcast_addr_addr,
9582 /* ******************************************************************************** */
9584 /* list of instructions */
9585 cmdline_parse_ctx_t main_ctx[] = {
9586 (cmdline_parse_inst_t *)&cmd_help_brief,
9587 (cmdline_parse_inst_t *)&cmd_help_long,
9588 (cmdline_parse_inst_t *)&cmd_quit,
9589 (cmdline_parse_inst_t *)&cmd_showport,
9590 (cmdline_parse_inst_t *)&cmd_showqueue,
9591 (cmdline_parse_inst_t *)&cmd_showportall,
9592 (cmdline_parse_inst_t *)&cmd_showcfg,
9593 (cmdline_parse_inst_t *)&cmd_start,
9594 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9595 (cmdline_parse_inst_t *)&cmd_set_link_up,
9596 (cmdline_parse_inst_t *)&cmd_set_link_down,
9597 (cmdline_parse_inst_t *)&cmd_reset,
9598 (cmdline_parse_inst_t *)&cmd_set_numbers,
9599 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9600 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9601 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9602 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9603 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9604 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9605 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9606 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9607 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9608 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9609 (cmdline_parse_inst_t *)&cmd_set_link_check,
9610 #ifdef RTE_NIC_BYPASS
9611 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9612 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9613 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9614 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9616 #ifdef RTE_LIBRTE_PMD_BOND
9617 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9618 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9619 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9620 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9621 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9622 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9623 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9624 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9625 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9627 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9628 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9629 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9630 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9631 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9632 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
9633 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9634 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9635 (cmdline_parse_inst_t *)&cmd_csum_set,
9636 (cmdline_parse_inst_t *)&cmd_csum_show,
9637 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
9638 (cmdline_parse_inst_t *)&cmd_tso_set,
9639 (cmdline_parse_inst_t *)&cmd_tso_show,
9640 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9641 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9642 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9643 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9644 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9645 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9646 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9647 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9648 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9649 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9650 (cmdline_parse_inst_t *)&cmd_config_dcb,
9651 (cmdline_parse_inst_t *)&cmd_read_reg,
9652 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9653 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9654 (cmdline_parse_inst_t *)&cmd_write_reg,
9655 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9656 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9657 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9658 (cmdline_parse_inst_t *)&cmd_stop,
9659 (cmdline_parse_inst_t *)&cmd_mac_addr,
9660 (cmdline_parse_inst_t *)&cmd_set_qmap,
9661 (cmdline_parse_inst_t *)&cmd_operate_port,
9662 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9663 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
9664 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
9665 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9666 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9667 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9668 (cmdline_parse_inst_t *)&cmd_config_mtu,
9669 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9670 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9671 (cmdline_parse_inst_t *)&cmd_config_rss,
9672 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9673 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9674 (cmdline_parse_inst_t *)&cmd_showport_reta,
9675 (cmdline_parse_inst_t *)&cmd_config_burst,
9676 (cmdline_parse_inst_t *)&cmd_config_thresh,
9677 (cmdline_parse_inst_t *)&cmd_config_threshold,
9678 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9679 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9680 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9681 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9682 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9683 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9684 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9685 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9686 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9687 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9688 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9689 (cmdline_parse_inst_t *)&cmd_global_config,
9690 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9691 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9692 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9693 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9694 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9695 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9696 (cmdline_parse_inst_t *)&cmd_dump,
9697 (cmdline_parse_inst_t *)&cmd_dump_one,
9698 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9699 (cmdline_parse_inst_t *)&cmd_syn_filter,
9700 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
9701 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
9702 (cmdline_parse_inst_t *)&cmd_flex_filter,
9703 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9704 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9705 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9706 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
9707 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
9708 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
9709 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9710 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
9711 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
9712 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
9713 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9714 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9715 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9716 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9717 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9718 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9719 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
9720 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
9721 (cmdline_parse_inst_t *)&cmd_mcast_addr,
9725 /* prompt function, called from main on MASTER lcore */
9731 /* initialize non-constant commands */
9732 cmd_set_fwd_mode_init();
9734 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9738 cmdline_interact(cl);
9739 cmdline_stdin_exit(cl);
9743 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9745 if (id == (portid_t)RTE_PORT_ALL) {
9748 FOREACH_PORT(pid, ports) {
9749 /* check if need_reconfig has been set to 1 */
9750 if (ports[pid].need_reconfig == 0)
9751 ports[pid].need_reconfig = dev;
9752 /* check if need_reconfig_queues has been set to 1 */
9753 if (ports[pid].need_reconfig_queues == 0)
9754 ports[pid].need_reconfig_queues = queue;
9756 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
9757 /* check if need_reconfig has been set to 1 */
9758 if (ports[id].need_reconfig == 0)
9759 ports[id].need_reconfig = dev;
9760 /* check if need_reconfig_queues has been set to 1 */
9761 if (ports[id].need_reconfig_queues == 0)
9762 ports[id].need_reconfig_queues = queue;
9766 #ifdef RTE_NIC_BYPASS
9767 #include <rte_pci_dev_ids.h>
9769 bypass_is_supported(portid_t port_id)
9771 struct rte_port *port;
9772 struct rte_pci_id *pci_id;
9774 if (port_id_is_invalid(port_id, ENABLED_WARN))
9777 /* Get the device id. */
9778 port = &ports[port_id];
9779 pci_id = &port->dev_info.pci_dev->id;
9781 /* Check if NIC supports bypass. */
9782 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9786 printf("\tBypass not supported for port_id = %d.\n", port_id);