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