4 * Copyright(c) 2010-2016 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 struct cmdline *testpmd_cl;
95 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
97 /* *** Help command with introduction. *** */
98 struct cmd_help_brief_result {
99 cmdline_fixed_string_t help;
102 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
104 __attribute__((unused)) void *data)
109 "Help is available for the following sections:\n\n"
110 " help control : Start and stop forwarding.\n"
111 " help display : Displaying port, stats and config "
113 " help config : Configuration information.\n"
114 " help ports : Configuring ports.\n"
115 " help registers : Reading and setting port registers.\n"
116 " help filters : Filters configuration help.\n"
117 " help all : All of the above sections.\n\n"
122 cmdline_parse_token_string_t cmd_help_brief_help =
123 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
125 cmdline_parse_inst_t cmd_help_brief = {
126 .f = cmd_help_brief_parsed,
128 .help_str = "show help",
130 (void *)&cmd_help_brief_help,
135 /* *** Help command with help sections. *** */
136 struct cmd_help_long_result {
137 cmdline_fixed_string_t help;
138 cmdline_fixed_string_t section;
141 static void cmd_help_long_parsed(void *parsed_result,
143 __attribute__((unused)) void *data)
146 struct cmd_help_long_result *res = parsed_result;
148 if (!strcmp(res->section, "all"))
151 if (show_all || !strcmp(res->section, "control")) {
156 "Control forwarding:\n"
157 "-------------------\n\n"
160 " Start packet forwarding with current configuration.\n\n"
163 " Start packet forwarding with current config"
164 " after sending one burst of packets.\n\n"
167 " Stop packet forwarding, and display accumulated"
171 " Quit to prompt.\n\n"
175 if (show_all || !strcmp(res->section, "display")) {
183 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
184 " Display information for port_id, or all.\n\n"
186 "show port X rss reta (size) (mask0,mask1,...)\n"
187 " Display the rss redirection table entry indicated"
188 " by masks on port X. size is used to indicate the"
189 " hardware supported reta size\n\n"
191 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
192 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
193 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
194 " Display the RSS hash functions and RSS hash key"
197 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
198 " Clear information for port_id, or all.\n\n"
200 "show (rxq|txq) info (port_id) (queue_id)\n"
201 " Display information for configured RX/TX queue.\n\n"
203 "show config (rxtx|cores|fwd|txpkts)\n"
204 " Display the given configuration.\n\n"
206 "read rxd (port_id) (queue_id) (rxd_id)\n"
207 " Display an RX descriptor of a port RX queue.\n\n"
209 "read txd (port_id) (queue_id) (txd_id)\n"
210 " Display a TX descriptor of a port TX queue.\n\n"
214 if (show_all || !strcmp(res->section, "config")) {
220 "Configuration changes only become active when"
221 " forwarding is started/restarted.\n\n"
224 " Reset forwarding to the default configuration.\n\n"
226 "set verbose (level)\n"
227 " Set the debug verbosity level X.\n\n"
230 " Set number of ports.\n\n"
233 " Set number of cores.\n\n"
235 "set coremask (mask)\n"
236 " Set the forwarding cores hexadecimal mask.\n\n"
238 "set portmask (mask)\n"
239 " Set the forwarding ports hexadecimal mask.\n\n"
242 " Set number of packets per burst.\n\n"
244 "set burst tx delay (microseconds) retry (num)\n"
245 " Set the transmit delay time and number of retries,"
246 " effective when retry is enabled.\n\n"
248 "set txpkts (x[,y]*)\n"
249 " Set the length of each segment of TXONLY"
250 " and optionally CSUM packets.\n\n"
252 "set txsplit (off|on|rand)\n"
253 " Set the split policy for the TX packets."
254 " Right now only applicable for CSUM and TXONLY"
257 "set corelist (x[,y]*)\n"
258 " Set the list of forwarding cores.\n\n"
260 "set portlist (x[,y]*)\n"
261 " Set the list of forwarding ports.\n\n"
263 "vlan set strip (on|off) (port_id)\n"
264 " Set the VLAN strip on a port.\n\n"
266 "vlan set stripq (on|off) (port_id,queue_id)\n"
267 " Set the VLAN strip for a queue on a port.\n\n"
269 "vlan set filter (on|off) (port_id)\n"
270 " Set the VLAN filter on a port.\n\n"
272 "vlan set qinq (on|off) (port_id)\n"
273 " Set the VLAN QinQ (extended queue in queue)"
276 "vlan set (inner|outer) tpid (value) (port_id)\n"
277 " Set the VLAN TPID for Packet Filtering on"
280 "rx_vlan add (vlan_id|all) (port_id)\n"
281 " Add a vlan_id, or all identifiers, to the set"
282 " of VLAN identifiers filtered by port_id.\n\n"
284 "rx_vlan rm (vlan_id|all) (port_id)\n"
285 " Remove a vlan_id, or all identifiers, from the set"
286 " of VLAN identifiers filtered by port_id.\n\n"
288 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
289 " Add a vlan_id, to the set of VLAN identifiers"
290 "filtered for VF(s) from port_id.\n\n"
292 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
293 " Remove a vlan_id, to the set of VLAN identifiers"
294 "filtered for VF(s) from port_id.\n\n"
296 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
297 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
298 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
299 " add a tunnel filter of a port.\n\n"
301 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
302 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
303 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
304 " remove a tunnel filter of a port.\n\n"
306 "rx_vxlan_port add (udp_port) (port_id)\n"
307 " Add an UDP port for VXLAN packet filter on a port\n\n"
309 "rx_vxlan_port rm (udp_port) (port_id)\n"
310 " Remove an UDP port for VXLAN packet filter on a port\n\n"
312 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
313 " Set hardware insertion of VLAN IDs (single or double VLAN "
314 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
316 "tx_vlan set pvid port_id vlan_id (on|off)\n"
317 " Set port based TX VLAN insertion.\n\n"
319 "tx_vlan reset (port_id)\n"
320 " Disable hardware insertion of a VLAN header in"
321 " packets sent on a port.\n\n"
323 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
324 " Select hardware or software calculation of the"
325 " checksum when transmitting a packet using the"
326 " csum forward engine.\n"
327 " ip|udp|tcp|sctp always concern the inner layer.\n"
328 " outer-ip concerns the outer IP layer in"
329 " case the packet is recognized as a tunnel packet by"
330 " the forward engine (vxlan, gre and ipip are supported)\n"
331 " Please check the NIC datasheet for HW limits.\n\n"
333 "csum parse-tunnel (on|off) (tx_port_id)\n"
334 " If disabled, treat tunnel packets as non-tunneled"
335 " packets (treat inner headers as payload). The port\n"
336 " argument is the port used for TX in csum forward"
339 "csum show (port_id)\n"
340 " Display tx checksum offload configuration\n\n"
342 "tso set (segsize) (portid)\n"
343 " Enable TCP Segmentation Offload in csum forward"
345 " Please check the NIC datasheet for HW limits.\n\n"
348 " Display the status of TCP Segmentation Offload.\n\n"
351 " Set packet forwarding mode.\n\n"
353 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
354 " Add a MAC address on port_id.\n\n"
356 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
357 " Remove a MAC address from port_id.\n\n"
359 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
360 " Add a MAC address for a VF on the port.\n\n"
362 "set port (port_id) uta (mac_address|all) (on|off)\n"
363 " Add/Remove a or all unicast hash filter(s)"
366 "set promisc (port_id|all) (on|off)\n"
367 " Set the promiscuous mode on port_id, or all.\n\n"
369 "set allmulti (port_id|all) (on|off)\n"
370 " Set the allmulti mode on port_id, or all.\n\n"
372 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
373 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
374 " (on|off) autoneg (on|off) (port_id)\n"
375 "set flow_ctrl rx (on|off) (portid)\n"
376 "set flow_ctrl tx (on|off) (portid)\n"
377 "set flow_ctrl high_water (high_water) (portid)\n"
378 "set flow_ctrl low_water (low_water) (portid)\n"
379 "set flow_ctrl pause_time (pause_time) (portid)\n"
380 "set flow_ctrl send_xon (send_xon) (portid)\n"
381 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
382 "set flow_ctrl autoneg (on|off) (port_id)\n"
383 " Set the link flow control parameter on a port.\n\n"
385 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
386 " (low_water) (pause_time) (priority) (port_id)\n"
387 " Set the priority flow control parameter on a"
390 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
391 " Set statistics mapping (qmapping 0..15) for RX/TX"
393 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
394 " on port 0 to mapping 5.\n\n"
396 "set port (port_id) vf (vf_id) rx|tx on|off\n"
397 " Enable/Disable a VF receive/tranmit from a port\n\n"
399 "set port (port_id) vf (vf_id) (mac_addr)"
400 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
401 " Add/Remove unicast or multicast MAC addr filter"
404 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
406 " AUPE:accepts untagged VLAN;"
407 "ROPE:accept unicast hash\n\n"
408 " BAM:accepts broadcast packets;"
409 "MPE:accepts all multicast packets\n\n"
410 " Enable/Disable a VF receive mode of a port\n\n"
412 "set port (port_id) queue (queue_id) rate (rate_num)\n"
413 " Set rate limit for a queue of a port\n\n"
415 "set port (port_id) vf (vf_id) rate (rate_num) "
416 "queue_mask (queue_mask_value)\n"
417 " Set rate limit for queues in VF of a port\n\n"
419 "set port (port_id) mirror-rule (rule_id)"
420 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
421 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
422 " Set pool or vlan type mirror rule on a port.\n"
423 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
424 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
427 "set port (port_id) mirror-rule (rule_id)"
428 " (uplink-mirror|downlink-mirror) dst-pool"
429 " (pool_id) (on|off)\n"
430 " Set uplink or downlink type mirror rule on a port.\n"
431 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
432 " 0 on' enable mirror income traffic to pool 0.\n\n"
434 "reset port (port_id) mirror-rule (rule_id)\n"
435 " Reset a mirror rule.\n\n"
437 "set flush_rx (on|off)\n"
438 " Flush (default) or don't flush RX streams before"
439 " forwarding. Mainly used with PCAP drivers.\n\n"
441 #ifdef RTE_NIC_BYPASS
442 "set bypass mode (normal|bypass|isolate) (port_id)\n"
443 " Set the bypass mode for the lowest port on bypass enabled"
446 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
447 "mode (normal|bypass|isolate) (port_id)\n"
448 " Set the event required to initiate specified bypass mode for"
449 " the lowest port on a bypass enabled NIC where:\n"
450 " timeout = enable bypass after watchdog timeout.\n"
451 " os_on = enable bypass when OS/board is powered on.\n"
452 " os_off = enable bypass when OS/board is powered off.\n"
453 " power_on = enable bypass when power supply is turned on.\n"
454 " power_off = enable bypass when power supply is turned off."
457 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
458 " Set the bypass watchdog timeout to 'n' seconds"
459 " where 0 = instant.\n\n"
461 "show bypass config (port_id)\n"
462 " Show the bypass configuration for a bypass enabled NIC"
463 " using the lowest port on the NIC.\n\n"
465 #ifdef RTE_LIBRTE_PMD_BOND
466 "create bonded device (mode) (socket)\n"
467 " Create a new bonded device with specific bonding mode and socket.\n\n"
469 "add bonding slave (slave_id) (port_id)\n"
470 " Add a slave device to a bonded device.\n\n"
472 "remove bonding slave (slave_id) (port_id)\n"
473 " Remove a slave device from a bonded device.\n\n"
475 "set bonding mode (value) (port_id)\n"
476 " Set the bonding mode on a bonded device.\n\n"
478 "set bonding primary (slave_id) (port_id)\n"
479 " Set the primary slave for a bonded device.\n\n"
481 "show bonding config (port_id)\n"
482 " Show the bonding config for port_id.\n\n"
484 "set bonding mac_addr (port_id) (address)\n"
485 " Set the MAC address of a bonded device.\n\n"
487 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
488 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
490 "set bonding mon_period (port_id) (value)\n"
491 " Set the bonding link status monitoring polling period in ms.\n\n"
493 "set link-up port (port_id)\n"
494 " Set link up for a port.\n\n"
496 "set link-down port (port_id)\n"
497 " Set link down for a port.\n\n"
499 "E-tag set insertion on port-tag-id (value)"
500 " port (port_id) vf (vf_id)\n"
501 " Enable E-tag insertion for a VF on a port\n\n"
503 "E-tag set insertion off port (port_id) vf (vf_id)\n"
504 " Disable E-tag insertion for a VF on a port\n\n"
506 "E-tag set stripping (on|off) port (port_id)\n"
507 " Enable/disable E-tag stripping on a port\n\n"
509 "E-tag set forwarding (on|off) port (port_id)\n"
510 " Enable/disable E-tag based forwarding"
513 "E-tag set filter add e-tag-id (value) dst-pool"
514 " (pool_id) port (port_id)\n"
515 " Add an E-tag forwarding filter on a port\n\n"
517 "E-tag set filter del e-tag-id (value) port (port_id)\n"
518 " Delete an E-tag forwarding filter on a port\n\n"
520 , list_pkt_forwarding_modes()
524 if (show_all || !strcmp(res->section, "ports")) {
530 "----------------\n\n"
532 "port start (port_id|all)\n"
533 " Start all ports or port_id.\n\n"
535 "port stop (port_id|all)\n"
536 " Stop all ports or port_id.\n\n"
538 "port close (port_id|all)\n"
539 " Close all ports or port_id.\n\n"
541 "port attach (ident)\n"
542 " Attach physical or virtual dev by pci address or virtual device name\n\n"
544 "port detach (port_id)\n"
545 " Detach physical or virtual dev by port_id\n\n"
547 "port config (port_id|all)"
548 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
549 " duplex (half|full|auto)\n"
550 " Set speed and duplex for all ports or port_id\n\n"
552 "port config all (rxq|txq|rxd|txd) (value)\n"
553 " Set number for rxq/txq/rxd/txd.\n\n"
555 "port config all max-pkt-len (value)\n"
556 " Set the max packet length.\n\n"
558 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
559 "hw-vlan-strip|hw-vlan-extend|drop-en)"
561 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
564 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
565 " Set the RSS mode.\n\n"
567 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
568 " Set the RSS redirection table.\n\n"
570 "port config (port_id) dcb vt (on|off) (traffic_class)"
572 " Set the DCB mode.\n\n"
574 "port config all burst (value)\n"
575 " Set the number of packets per burst.\n\n"
577 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
579 " Set the ring prefetch/host/writeback threshold"
580 " for tx/rx queue.\n\n"
582 "port config all (txfreet|txrst|rxfreet) (value)\n"
583 " Set free threshold for rx/tx, or set"
584 " tx rs bit threshold.\n\n"
585 "port config mtu X value\n"
586 " Set the MTU of port X to a given value\n\n"
588 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
589 " Start/stop a rx/tx queue of port X. Only take effect"
590 " when port X is started\n\n"
592 "port config (port_id|all) l2-tunnel E-tag ether-type"
594 " Set the value of E-tag ether-type.\n\n"
596 "port config (port_id|all) l2-tunnel E-tag"
597 " (enable|disable)\n"
598 " Enable/disable the E-tag support.\n\n"
602 if (show_all || !strcmp(res->section, "registers")) {
610 "read reg (port_id) (address)\n"
611 " Display value of a port register.\n\n"
613 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
614 " Display a port register bit field.\n\n"
616 "read regbit (port_id) (address) (bit_x)\n"
617 " Display a single port register bit.\n\n"
619 "write reg (port_id) (address) (value)\n"
620 " Set value of a port register.\n\n"
622 "write regfield (port_id) (address) (bit_x) (bit_y)"
624 " Set bit field of a port register.\n\n"
626 "write regbit (port_id) (address) (bit_x) (value)\n"
627 " Set single bit value of a port register.\n\n"
630 if (show_all || !strcmp(res->section, "filters")) {
638 "ethertype_filter (port_id) (add|del)"
639 " (mac_addr|mac_ignr) (mac_address) ethertype"
640 " (ether_type) (drop|fwd) queue (queue_id)\n"
641 " Add/Del an ethertype filter.\n\n"
643 "2tuple_filter (port_id) (add|del)"
644 " dst_port (dst_port_value) protocol (protocol_value)"
645 " mask (mask_value) tcp_flags (tcp_flags_value)"
646 " priority (prio_value) queue (queue_id)\n"
647 " Add/Del a 2tuple filter.\n\n"
649 "5tuple_filter (port_id) (add|del)"
650 " dst_ip (dst_address) src_ip (src_address)"
651 " dst_port (dst_port_value) src_port (src_port_value)"
652 " protocol (protocol_value)"
653 " mask (mask_value) tcp_flags (tcp_flags_value)"
654 " priority (prio_value) queue (queue_id)\n"
655 " Add/Del a 5tuple filter.\n\n"
657 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
658 " Add/Del syn filter.\n\n"
660 "flex_filter (port_id) (add|del) len (len_value)"
661 " bytes (bytes_value) mask (mask_value)"
662 " priority (prio_value) queue (queue_id)\n"
663 " Add/Del a flex filter.\n\n"
665 "flow_director_filter (port_id) mode IP (add|del|update)"
666 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
667 " src (src_ip_address) dst (dst_ip_address)"
668 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
669 " vlan (vlan_value) flexbytes (flexbytes_value)"
670 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
671 " fd_id (fd_id_value)\n"
672 " Add/Del an IP type flow director filter.\n\n"
674 "flow_director_filter (port_id) mode IP (add|del|update)"
675 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
676 " src (src_ip_address) (src_port)"
677 " dst (dst_ip_address) (dst_port)"
678 " tos (tos_value) ttl (ttl_value)"
679 " vlan (vlan_value) flexbytes (flexbytes_value)"
680 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
681 " fd_id (fd_id_value)\n"
682 " Add/Del an UDP/TCP type flow director filter.\n\n"
684 "flow_director_filter (port_id) mode IP (add|del|update)"
685 " flow (ipv4-sctp|ipv6-sctp)"
686 " src (src_ip_address) (src_port)"
687 " dst (dst_ip_address) (dst_port)"
688 " tag (verification_tag) "
689 " tos (tos_value) ttl (ttl_value)"
691 " flexbytes (flexbytes_value) (drop|fwd)"
692 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
693 " Add/Del a SCTP type flow director filter.\n\n"
695 "flow_director_filter (port_id) mode IP (add|del|update)"
696 " flow l2_payload ether (ethertype)"
697 " flexbytes (flexbytes_value) (drop|fwd)"
698 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
699 " Add/Del a l2 payload type flow director filter.\n\n"
701 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
702 " mac (mac_address) vlan (vlan_value)"
703 " flexbytes (flexbytes_value) (drop|fwd)"
704 " queue (queue_id) fd_id (fd_id_value)\n"
705 " Add/Del a MAC-VLAN flow director filter.\n\n"
707 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
708 " mac (mac_address) vlan (vlan_value)"
709 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
710 " flexbytes (flexbytes_value) (drop|fwd)"
711 " queue (queue_id) fd_id (fd_id_value)\n"
712 " Add/Del a Tunnel flow director filter.\n\n"
714 "flush_flow_director (port_id)\n"
715 " Flush all flow director entries of a device.\n\n"
717 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
718 " src_mask (ipv4_src) (ipv6_src) (src_port)"
719 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
720 " Set flow director IP mask.\n\n"
722 "flow_director_mask (port_id) mode MAC-VLAN"
723 " vlan (vlan_value) mac (mac_value)\n"
724 " Set flow director MAC-VLAN mask.\n\n"
726 "flow_director_mask (port_id) mode Tunnel"
727 " vlan (vlan_value) mac (mac_value)"
728 " tunnel-type (tunnel_type_value)"
729 " tunnel-id (tunnel_id_value)\n"
730 " Set flow director Tunnel mask.\n\n"
732 "flow_director_flex_mask (port_id)"
733 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
734 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
736 " Configure mask of flex payload.\n\n"
738 "flow_director_flex_payload (port_id)"
739 " (raw|l2|l3|l4) (config)\n"
740 " Configure flex payload selection.\n\n"
742 "get_sym_hash_ena_per_port (port_id)\n"
743 " get symmetric hash enable configuration per port.\n\n"
745 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
746 " set symmetric hash enable configuration per port"
747 " to enable or disable.\n\n"
749 "get_hash_global_config (port_id)\n"
750 " Get the global configurations of hash filters.\n\n"
752 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
753 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
754 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
755 " (enable|disable)\n"
756 " Set the global configurations of hash filters.\n\n"
758 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
759 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
760 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
761 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
762 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
763 "ipv6-next-header|udp-src-port|udp-dst-port|"
764 "tcp-src-port|tcp-dst-port|sctp-src-port|"
765 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
766 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
767 "fld-8th|none) (select|add)\n"
768 " Set the input set for hash.\n\n"
770 "set_fdir_input_set (port_id) "
771 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
772 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
773 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
774 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
775 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
776 "udp-dst-port|tcp-src-port|tcp-dst-port|"
777 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
779 " Set the input set for FDir.\n\n"
784 cmdline_parse_token_string_t cmd_help_long_help =
785 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
787 cmdline_parse_token_string_t cmd_help_long_section =
788 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
789 "all#control#display#config#"
790 "ports#registers#filters");
792 cmdline_parse_inst_t cmd_help_long = {
793 .f = cmd_help_long_parsed,
795 .help_str = "show help",
797 (void *)&cmd_help_long_help,
798 (void *)&cmd_help_long_section,
804 /* *** start/stop/close all ports *** */
805 struct cmd_operate_port_result {
806 cmdline_fixed_string_t keyword;
807 cmdline_fixed_string_t name;
808 cmdline_fixed_string_t value;
811 static void cmd_operate_port_parsed(void *parsed_result,
812 __attribute__((unused)) struct cmdline *cl,
813 __attribute__((unused)) void *data)
815 struct cmd_operate_port_result *res = parsed_result;
817 if (!strcmp(res->name, "start"))
818 start_port(RTE_PORT_ALL);
819 else if (!strcmp(res->name, "stop"))
820 stop_port(RTE_PORT_ALL);
821 else if (!strcmp(res->name, "close"))
822 close_port(RTE_PORT_ALL);
824 printf("Unknown parameter\n");
827 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
828 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
830 cmdline_parse_token_string_t cmd_operate_port_all_port =
831 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
833 cmdline_parse_token_string_t cmd_operate_port_all_all =
834 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
836 cmdline_parse_inst_t cmd_operate_port = {
837 .f = cmd_operate_port_parsed,
839 .help_str = "port start|stop|close all: start/stop/close all ports",
841 (void *)&cmd_operate_port_all_cmd,
842 (void *)&cmd_operate_port_all_port,
843 (void *)&cmd_operate_port_all_all,
848 /* *** start/stop/close specific port *** */
849 struct cmd_operate_specific_port_result {
850 cmdline_fixed_string_t keyword;
851 cmdline_fixed_string_t name;
855 static void cmd_operate_specific_port_parsed(void *parsed_result,
856 __attribute__((unused)) struct cmdline *cl,
857 __attribute__((unused)) void *data)
859 struct cmd_operate_specific_port_result *res = parsed_result;
861 if (!strcmp(res->name, "start"))
862 start_port(res->value);
863 else if (!strcmp(res->name, "stop"))
864 stop_port(res->value);
865 else if (!strcmp(res->name, "close"))
866 close_port(res->value);
868 printf("Unknown parameter\n");
871 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
872 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
874 cmdline_parse_token_string_t cmd_operate_specific_port_port =
875 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
876 name, "start#stop#close");
877 cmdline_parse_token_num_t cmd_operate_specific_port_id =
878 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
881 cmdline_parse_inst_t cmd_operate_specific_port = {
882 .f = cmd_operate_specific_port_parsed,
884 .help_str = "port start|stop|close X: start/stop/close port X",
886 (void *)&cmd_operate_specific_port_cmd,
887 (void *)&cmd_operate_specific_port_port,
888 (void *)&cmd_operate_specific_port_id,
893 /* *** attach a specified port *** */
894 struct cmd_operate_attach_port_result {
895 cmdline_fixed_string_t port;
896 cmdline_fixed_string_t keyword;
897 cmdline_fixed_string_t identifier;
900 static void cmd_operate_attach_port_parsed(void *parsed_result,
901 __attribute__((unused)) struct cmdline *cl,
902 __attribute__((unused)) void *data)
904 struct cmd_operate_attach_port_result *res = parsed_result;
906 if (!strcmp(res->keyword, "attach"))
907 attach_port(res->identifier);
909 printf("Unknown parameter\n");
912 cmdline_parse_token_string_t cmd_operate_attach_port_port =
913 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
915 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
916 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
918 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
919 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
922 cmdline_parse_inst_t cmd_operate_attach_port = {
923 .f = cmd_operate_attach_port_parsed,
925 .help_str = "port attach identifier, "
926 "identifier: pci address or virtual dev name",
928 (void *)&cmd_operate_attach_port_port,
929 (void *)&cmd_operate_attach_port_keyword,
930 (void *)&cmd_operate_attach_port_identifier,
935 /* *** detach a specified port *** */
936 struct cmd_operate_detach_port_result {
937 cmdline_fixed_string_t port;
938 cmdline_fixed_string_t keyword;
942 static void cmd_operate_detach_port_parsed(void *parsed_result,
943 __attribute__((unused)) struct cmdline *cl,
944 __attribute__((unused)) void *data)
946 struct cmd_operate_detach_port_result *res = parsed_result;
948 if (!strcmp(res->keyword, "detach"))
949 detach_port(res->port_id);
951 printf("Unknown parameter\n");
954 cmdline_parse_token_string_t cmd_operate_detach_port_port =
955 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
957 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
958 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
960 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
961 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
964 cmdline_parse_inst_t cmd_operate_detach_port = {
965 .f = cmd_operate_detach_port_parsed,
967 .help_str = "port detach port_id",
969 (void *)&cmd_operate_detach_port_port,
970 (void *)&cmd_operate_detach_port_keyword,
971 (void *)&cmd_operate_detach_port_port_id,
976 /* *** configure speed for all ports *** */
977 struct cmd_config_speed_all {
978 cmdline_fixed_string_t port;
979 cmdline_fixed_string_t keyword;
980 cmdline_fixed_string_t all;
981 cmdline_fixed_string_t item1;
982 cmdline_fixed_string_t item2;
983 cmdline_fixed_string_t value1;
984 cmdline_fixed_string_t value2;
988 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
993 if (!strcmp(duplexstr, "half")) {
994 duplex = ETH_LINK_HALF_DUPLEX;
995 } else if (!strcmp(duplexstr, "full")) {
996 duplex = ETH_LINK_FULL_DUPLEX;
997 } else if (!strcmp(duplexstr, "auto")) {
998 duplex = ETH_LINK_FULL_DUPLEX;
1000 printf("Unknown duplex parameter\n");
1004 if (!strcmp(speedstr, "10")) {
1005 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1006 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1007 } else if (!strcmp(speedstr, "100")) {
1008 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1009 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1011 if (duplex != ETH_LINK_FULL_DUPLEX) {
1012 printf("Invalid speed/duplex parameters\n");
1015 if (!strcmp(speedstr, "1000")) {
1016 *speed = ETH_LINK_SPEED_1G;
1017 } else if (!strcmp(speedstr, "10000")) {
1018 *speed = ETH_LINK_SPEED_10G;
1019 } else if (!strcmp(speedstr, "25000")) {
1020 *speed = ETH_LINK_SPEED_25G;
1021 } else if (!strcmp(speedstr, "40000")) {
1022 *speed = ETH_LINK_SPEED_40G;
1023 } else if (!strcmp(speedstr, "50000")) {
1024 *speed = ETH_LINK_SPEED_50G;
1025 } else if (!strcmp(speedstr, "100000")) {
1026 *speed = ETH_LINK_SPEED_100G;
1027 } else if (!strcmp(speedstr, "auto")) {
1028 *speed = ETH_LINK_SPEED_AUTONEG;
1030 printf("Unknown speed parameter\n");
1039 cmd_config_speed_all_parsed(void *parsed_result,
1040 __attribute__((unused)) struct cmdline *cl,
1041 __attribute__((unused)) void *data)
1043 struct cmd_config_speed_all *res = parsed_result;
1044 uint32_t link_speed;
1047 if (!all_ports_stopped()) {
1048 printf("Please stop all ports first\n");
1052 if (parse_and_check_speed_duplex(res->value1, res->value2,
1056 FOREACH_PORT(pid, ports) {
1057 ports[pid].dev_conf.link_speeds = link_speed;
1060 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1063 cmdline_parse_token_string_t cmd_config_speed_all_port =
1064 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1065 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1066 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1068 cmdline_parse_token_string_t cmd_config_speed_all_all =
1069 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1070 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1071 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1072 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1073 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1074 "10#100#1000#10000#25000#40000#50000#100000#auto");
1075 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1076 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1077 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1078 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1081 cmdline_parse_inst_t cmd_config_speed_all = {
1082 .f = cmd_config_speed_all_parsed,
1084 .help_str = "port config all speed "
1085 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1088 (void *)&cmd_config_speed_all_port,
1089 (void *)&cmd_config_speed_all_keyword,
1090 (void *)&cmd_config_speed_all_all,
1091 (void *)&cmd_config_speed_all_item1,
1092 (void *)&cmd_config_speed_all_value1,
1093 (void *)&cmd_config_speed_all_item2,
1094 (void *)&cmd_config_speed_all_value2,
1099 /* *** configure speed for specific port *** */
1100 struct cmd_config_speed_specific {
1101 cmdline_fixed_string_t port;
1102 cmdline_fixed_string_t keyword;
1104 cmdline_fixed_string_t item1;
1105 cmdline_fixed_string_t item2;
1106 cmdline_fixed_string_t value1;
1107 cmdline_fixed_string_t value2;
1111 cmd_config_speed_specific_parsed(void *parsed_result,
1112 __attribute__((unused)) struct cmdline *cl,
1113 __attribute__((unused)) void *data)
1115 struct cmd_config_speed_specific *res = parsed_result;
1116 uint32_t link_speed;
1118 if (!all_ports_stopped()) {
1119 printf("Please stop all ports first\n");
1123 if (port_id_is_invalid(res->id, ENABLED_WARN))
1126 if (parse_and_check_speed_duplex(res->value1, res->value2,
1130 ports[res->id].dev_conf.link_speeds = link_speed;
1132 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1136 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1137 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1139 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1140 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1142 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1143 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1144 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1145 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1147 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1148 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1149 "10#100#1000#10000#25000#40000#50000#100000#auto");
1150 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1153 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1154 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1157 cmdline_parse_inst_t cmd_config_speed_specific = {
1158 .f = cmd_config_speed_specific_parsed,
1160 .help_str = "port config X speed "
1161 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1164 (void *)&cmd_config_speed_specific_port,
1165 (void *)&cmd_config_speed_specific_keyword,
1166 (void *)&cmd_config_speed_specific_id,
1167 (void *)&cmd_config_speed_specific_item1,
1168 (void *)&cmd_config_speed_specific_value1,
1169 (void *)&cmd_config_speed_specific_item2,
1170 (void *)&cmd_config_speed_specific_value2,
1175 /* *** configure txq/rxq, txd/rxd *** */
1176 struct cmd_config_rx_tx {
1177 cmdline_fixed_string_t port;
1178 cmdline_fixed_string_t keyword;
1179 cmdline_fixed_string_t all;
1180 cmdline_fixed_string_t name;
1185 cmd_config_rx_tx_parsed(void *parsed_result,
1186 __attribute__((unused)) struct cmdline *cl,
1187 __attribute__((unused)) void *data)
1189 struct cmd_config_rx_tx *res = parsed_result;
1191 if (!all_ports_stopped()) {
1192 printf("Please stop all ports first\n");
1195 if (!strcmp(res->name, "rxq")) {
1196 if (!res->value && !nb_txq) {
1197 printf("Warning: Either rx or tx queues should be non zero\n");
1200 nb_rxq = res->value;
1202 else if (!strcmp(res->name, "txq")) {
1203 if (!res->value && !nb_rxq) {
1204 printf("Warning: Either rx or tx queues should be non zero\n");
1207 nb_txq = res->value;
1209 else if (!strcmp(res->name, "rxd")) {
1210 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1211 printf("rxd %d invalid - must be > 0 && <= %d\n",
1212 res->value, RTE_TEST_RX_DESC_MAX);
1215 nb_rxd = res->value;
1216 } else if (!strcmp(res->name, "txd")) {
1217 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1218 printf("txd %d invalid - must be > 0 && <= %d\n",
1219 res->value, RTE_TEST_TX_DESC_MAX);
1222 nb_txd = res->value;
1224 printf("Unknown parameter\n");
1232 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1235 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1236 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1237 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1238 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1239 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1240 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1241 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1242 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1244 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1245 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1247 cmdline_parse_inst_t cmd_config_rx_tx = {
1248 .f = cmd_config_rx_tx_parsed,
1250 .help_str = "port config all rxq|txq|rxd|txd value",
1252 (void *)&cmd_config_rx_tx_port,
1253 (void *)&cmd_config_rx_tx_keyword,
1254 (void *)&cmd_config_rx_tx_all,
1255 (void *)&cmd_config_rx_tx_name,
1256 (void *)&cmd_config_rx_tx_value,
1261 /* *** config max packet length *** */
1262 struct cmd_config_max_pkt_len_result {
1263 cmdline_fixed_string_t port;
1264 cmdline_fixed_string_t keyword;
1265 cmdline_fixed_string_t all;
1266 cmdline_fixed_string_t name;
1271 cmd_config_max_pkt_len_parsed(void *parsed_result,
1272 __attribute__((unused)) struct cmdline *cl,
1273 __attribute__((unused)) void *data)
1275 struct cmd_config_max_pkt_len_result *res = parsed_result;
1277 if (!all_ports_stopped()) {
1278 printf("Please stop all ports first\n");
1282 if (!strcmp(res->name, "max-pkt-len")) {
1283 if (res->value < ETHER_MIN_LEN) {
1284 printf("max-pkt-len can not be less than %d\n",
1288 if (res->value == rx_mode.max_rx_pkt_len)
1291 rx_mode.max_rx_pkt_len = res->value;
1292 if (res->value > ETHER_MAX_LEN)
1293 rx_mode.jumbo_frame = 1;
1295 rx_mode.jumbo_frame = 0;
1297 printf("Unknown parameter\n");
1303 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1306 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1307 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1309 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1310 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1312 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1313 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1315 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1316 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1318 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1319 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1322 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1323 .f = cmd_config_max_pkt_len_parsed,
1325 .help_str = "port config all max-pkt-len value",
1327 (void *)&cmd_config_max_pkt_len_port,
1328 (void *)&cmd_config_max_pkt_len_keyword,
1329 (void *)&cmd_config_max_pkt_len_all,
1330 (void *)&cmd_config_max_pkt_len_name,
1331 (void *)&cmd_config_max_pkt_len_value,
1336 /* *** configure port MTU *** */
1337 struct cmd_config_mtu_result {
1338 cmdline_fixed_string_t port;
1339 cmdline_fixed_string_t keyword;
1340 cmdline_fixed_string_t mtu;
1346 cmd_config_mtu_parsed(void *parsed_result,
1347 __attribute__((unused)) struct cmdline *cl,
1348 __attribute__((unused)) void *data)
1350 struct cmd_config_mtu_result *res = parsed_result;
1352 if (res->value < ETHER_MIN_LEN) {
1353 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1356 port_mtu_set(res->port_id, res->value);
1359 cmdline_parse_token_string_t cmd_config_mtu_port =
1360 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1362 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1363 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1365 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1366 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1368 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1369 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1370 cmdline_parse_token_num_t cmd_config_mtu_value =
1371 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1373 cmdline_parse_inst_t cmd_config_mtu = {
1374 .f = cmd_config_mtu_parsed,
1376 .help_str = "port config mtu port_id value",
1378 (void *)&cmd_config_mtu_port,
1379 (void *)&cmd_config_mtu_keyword,
1380 (void *)&cmd_config_mtu_mtu,
1381 (void *)&cmd_config_mtu_port_id,
1382 (void *)&cmd_config_mtu_value,
1387 /* *** configure rx mode *** */
1388 struct cmd_config_rx_mode_flag {
1389 cmdline_fixed_string_t port;
1390 cmdline_fixed_string_t keyword;
1391 cmdline_fixed_string_t all;
1392 cmdline_fixed_string_t name;
1393 cmdline_fixed_string_t value;
1397 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1398 __attribute__((unused)) struct cmdline *cl,
1399 __attribute__((unused)) void *data)
1401 struct cmd_config_rx_mode_flag *res = parsed_result;
1403 if (!all_ports_stopped()) {
1404 printf("Please stop all ports first\n");
1408 if (!strcmp(res->name, "crc-strip")) {
1409 if (!strcmp(res->value, "on"))
1410 rx_mode.hw_strip_crc = 1;
1411 else if (!strcmp(res->value, "off"))
1412 rx_mode.hw_strip_crc = 0;
1414 printf("Unknown parameter\n");
1417 } else if (!strcmp(res->name, "scatter")) {
1418 if (!strcmp(res->value, "on"))
1419 rx_mode.enable_scatter = 1;
1420 else if (!strcmp(res->value, "off"))
1421 rx_mode.enable_scatter = 0;
1423 printf("Unknown parameter\n");
1426 } else if (!strcmp(res->name, "rx-cksum")) {
1427 if (!strcmp(res->value, "on"))
1428 rx_mode.hw_ip_checksum = 1;
1429 else if (!strcmp(res->value, "off"))
1430 rx_mode.hw_ip_checksum = 0;
1432 printf("Unknown parameter\n");
1435 } else if (!strcmp(res->name, "hw-vlan")) {
1436 if (!strcmp(res->value, "on")) {
1437 rx_mode.hw_vlan_filter = 1;
1438 rx_mode.hw_vlan_strip = 1;
1440 else if (!strcmp(res->value, "off")) {
1441 rx_mode.hw_vlan_filter = 0;
1442 rx_mode.hw_vlan_strip = 0;
1445 printf("Unknown parameter\n");
1448 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1449 if (!strcmp(res->value, "on"))
1450 rx_mode.hw_vlan_filter = 1;
1451 else if (!strcmp(res->value, "off"))
1452 rx_mode.hw_vlan_filter = 0;
1454 printf("Unknown parameter\n");
1457 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1458 if (!strcmp(res->value, "on"))
1459 rx_mode.hw_vlan_strip = 1;
1460 else if (!strcmp(res->value, "off"))
1461 rx_mode.hw_vlan_strip = 0;
1463 printf("Unknown parameter\n");
1466 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1467 if (!strcmp(res->value, "on"))
1468 rx_mode.hw_vlan_extend = 1;
1469 else if (!strcmp(res->value, "off"))
1470 rx_mode.hw_vlan_extend = 0;
1472 printf("Unknown parameter\n");
1475 } else if (!strcmp(res->name, "drop-en")) {
1476 if (!strcmp(res->value, "on"))
1478 else if (!strcmp(res->value, "off"))
1481 printf("Unknown parameter\n");
1485 printf("Unknown parameter\n");
1491 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1494 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1495 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1496 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1497 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1499 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1500 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1501 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1502 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1503 "crc-strip#scatter#rx-cksum#hw-vlan#"
1504 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1505 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1506 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1509 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1510 .f = cmd_config_rx_mode_flag_parsed,
1512 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1513 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1515 (void *)&cmd_config_rx_mode_flag_port,
1516 (void *)&cmd_config_rx_mode_flag_keyword,
1517 (void *)&cmd_config_rx_mode_flag_all,
1518 (void *)&cmd_config_rx_mode_flag_name,
1519 (void *)&cmd_config_rx_mode_flag_value,
1524 /* *** configure rss *** */
1525 struct cmd_config_rss {
1526 cmdline_fixed_string_t port;
1527 cmdline_fixed_string_t keyword;
1528 cmdline_fixed_string_t all;
1529 cmdline_fixed_string_t name;
1530 cmdline_fixed_string_t value;
1534 cmd_config_rss_parsed(void *parsed_result,
1535 __attribute__((unused)) struct cmdline *cl,
1536 __attribute__((unused)) void *data)
1538 struct cmd_config_rss *res = parsed_result;
1539 struct rte_eth_rss_conf rss_conf;
1543 if (!strcmp(res->value, "all"))
1544 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1545 ETH_RSS_UDP | ETH_RSS_SCTP |
1547 else if (!strcmp(res->value, "ip"))
1548 rss_conf.rss_hf = ETH_RSS_IP;
1549 else if (!strcmp(res->value, "udp"))
1550 rss_conf.rss_hf = ETH_RSS_UDP;
1551 else if (!strcmp(res->value, "tcp"))
1552 rss_conf.rss_hf = ETH_RSS_TCP;
1553 else if (!strcmp(res->value, "sctp"))
1554 rss_conf.rss_hf = ETH_RSS_SCTP;
1555 else if (!strcmp(res->value, "ether"))
1556 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1557 else if (!strcmp(res->value, "port"))
1558 rss_conf.rss_hf = ETH_RSS_PORT;
1559 else if (!strcmp(res->value, "vxlan"))
1560 rss_conf.rss_hf = ETH_RSS_VXLAN;
1561 else if (!strcmp(res->value, "geneve"))
1562 rss_conf.rss_hf = ETH_RSS_GENEVE;
1563 else if (!strcmp(res->value, "nvgre"))
1564 rss_conf.rss_hf = ETH_RSS_NVGRE;
1565 else if (!strcmp(res->value, "none"))
1566 rss_conf.rss_hf = 0;
1568 printf("Unknown parameter\n");
1571 rss_conf.rss_key = NULL;
1572 for (i = 0; i < rte_eth_dev_count(); i++) {
1573 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1575 printf("Configuration of RSS hash at ethernet port %d "
1576 "failed with error (%d): %s.\n",
1577 i, -diag, strerror(-diag));
1581 cmdline_parse_token_string_t cmd_config_rss_port =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1583 cmdline_parse_token_string_t cmd_config_rss_keyword =
1584 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1585 cmdline_parse_token_string_t cmd_config_rss_all =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1587 cmdline_parse_token_string_t cmd_config_rss_name =
1588 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1589 cmdline_parse_token_string_t cmd_config_rss_value =
1590 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1591 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1593 cmdline_parse_inst_t cmd_config_rss = {
1594 .f = cmd_config_rss_parsed,
1596 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1598 (void *)&cmd_config_rss_port,
1599 (void *)&cmd_config_rss_keyword,
1600 (void *)&cmd_config_rss_all,
1601 (void *)&cmd_config_rss_name,
1602 (void *)&cmd_config_rss_value,
1607 /* *** configure rss hash key *** */
1608 struct cmd_config_rss_hash_key {
1609 cmdline_fixed_string_t port;
1610 cmdline_fixed_string_t config;
1612 cmdline_fixed_string_t rss_hash_key;
1613 cmdline_fixed_string_t rss_type;
1614 cmdline_fixed_string_t key;
1618 hexa_digit_to_value(char hexa_digit)
1620 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1621 return (uint8_t) (hexa_digit - '0');
1622 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1623 return (uint8_t) ((hexa_digit - 'a') + 10);
1624 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1625 return (uint8_t) ((hexa_digit - 'A') + 10);
1626 /* Invalid hexa digit */
1631 parse_and_check_key_hexa_digit(char *key, int idx)
1635 hexa_v = hexa_digit_to_value(key[idx]);
1637 printf("invalid key: character %c at position %d is not a "
1638 "valid hexa digit\n", key[idx], idx);
1643 cmd_config_rss_hash_key_parsed(void *parsed_result,
1644 __attribute__((unused)) struct cmdline *cl,
1645 __attribute__((unused)) void *data)
1647 struct cmd_config_rss_hash_key *res = parsed_result;
1648 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1652 struct rte_eth_dev_info dev_info;
1653 uint8_t hash_key_size;
1656 memset(&dev_info, 0, sizeof(dev_info));
1657 rte_eth_dev_info_get(res->port_id, &dev_info);
1658 if (dev_info.hash_key_size > 0 &&
1659 dev_info.hash_key_size <= sizeof(hash_key))
1660 hash_key_size = dev_info.hash_key_size;
1662 printf("dev_info did not provide a valid hash key size\n");
1665 /* Check the length of the RSS hash key */
1666 key_len = strlen(res->key);
1667 if (key_len != (hash_key_size * 2)) {
1668 printf("key length: %d invalid - key must be a string of %d"
1669 " hexa-decimal numbers\n",
1670 (int) key_len, hash_key_size * 2);
1673 /* Translate RSS hash key into binary representation */
1674 for (i = 0; i < hash_key_size; i++) {
1675 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1678 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1681 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1683 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1687 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1688 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1689 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1692 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1693 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1694 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1695 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1696 rss_hash_key, "rss-hash-key");
1697 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1699 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1700 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1701 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1702 "ipv6-tcp-ex#ipv6-udp-ex");
1703 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1704 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1706 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1707 .f = cmd_config_rss_hash_key_parsed,
1710 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1711 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1712 "ipv6-sctp|ipv6-other|l2-payload|"
1713 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1714 "<string of hexa digits (variable length, NIC dependent)>\n",
1716 (void *)&cmd_config_rss_hash_key_port,
1717 (void *)&cmd_config_rss_hash_key_config,
1718 (void *)&cmd_config_rss_hash_key_port_id,
1719 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1720 (void *)&cmd_config_rss_hash_key_rss_type,
1721 (void *)&cmd_config_rss_hash_key_value,
1726 /* *** configure port rxq/txq start/stop *** */
1727 struct cmd_config_rxtx_queue {
1728 cmdline_fixed_string_t port;
1730 cmdline_fixed_string_t rxtxq;
1732 cmdline_fixed_string_t opname;
1736 cmd_config_rxtx_queue_parsed(void *parsed_result,
1737 __attribute__((unused)) struct cmdline *cl,
1738 __attribute__((unused)) void *data)
1740 struct cmd_config_rxtx_queue *res = parsed_result;
1745 if (test_done == 0) {
1746 printf("Please stop forwarding first\n");
1750 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1753 if (port_is_started(res->portid) != 1) {
1754 printf("Please start port %u first\n", res->portid);
1758 if (!strcmp(res->rxtxq, "rxq"))
1760 else if (!strcmp(res->rxtxq, "txq"))
1763 printf("Unknown parameter\n");
1767 if (isrx && rx_queue_id_is_invalid(res->qid))
1769 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1772 if (!strcmp(res->opname, "start"))
1774 else if (!strcmp(res->opname, "stop"))
1777 printf("Unknown parameter\n");
1781 if (isstart && isrx)
1782 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1783 else if (!isstart && isrx)
1784 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1785 else if (isstart && !isrx)
1786 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1788 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1790 if (ret == -ENOTSUP)
1791 printf("Function not supported in PMD driver\n");
1794 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1795 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1796 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1797 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1798 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1799 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1800 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1801 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1802 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1806 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1807 .f = cmd_config_rxtx_queue_parsed,
1809 .help_str = "port X rxq|txq ID start|stop",
1811 (void *)&cmd_config_speed_all_port,
1812 (void *)&cmd_config_rxtx_queue_portid,
1813 (void *)&cmd_config_rxtx_queue_rxtxq,
1814 (void *)&cmd_config_rxtx_queue_qid,
1815 (void *)&cmd_config_rxtx_queue_opname,
1820 /* *** Configure RSS RETA *** */
1821 struct cmd_config_rss_reta {
1822 cmdline_fixed_string_t port;
1823 cmdline_fixed_string_t keyword;
1825 cmdline_fixed_string_t name;
1826 cmdline_fixed_string_t list_name;
1827 cmdline_fixed_string_t list_of_items;
1831 parse_reta_config(const char *str,
1832 struct rte_eth_rss_reta_entry64 *reta_conf,
1833 uint16_t nb_entries)
1837 uint16_t hash_index, idx, shift;
1840 const char *p, *p0 = str;
1847 unsigned long int_fld[_NUM_FLD];
1848 char *str_fld[_NUM_FLD];
1850 while ((p = strchr(p0,'(')) != NULL) {
1852 if((p0 = strchr(p,')')) == NULL)
1856 if(size >= sizeof(s))
1859 snprintf(s, sizeof(s), "%.*s", size, p);
1860 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1862 for (i = 0; i < _NUM_FLD; i++) {
1864 int_fld[i] = strtoul(str_fld[i], &end, 0);
1865 if (errno != 0 || end == str_fld[i] ||
1870 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1871 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1873 if (hash_index >= nb_entries) {
1874 printf("Invalid RETA hash index=%d\n", hash_index);
1878 idx = hash_index / RTE_RETA_GROUP_SIZE;
1879 shift = hash_index % RTE_RETA_GROUP_SIZE;
1880 reta_conf[idx].mask |= (1ULL << shift);
1881 reta_conf[idx].reta[shift] = nb_queue;
1888 cmd_set_rss_reta_parsed(void *parsed_result,
1889 __attribute__((unused)) struct cmdline *cl,
1890 __attribute__((unused)) void *data)
1893 struct rte_eth_dev_info dev_info;
1894 struct rte_eth_rss_reta_entry64 reta_conf[8];
1895 struct cmd_config_rss_reta *res = parsed_result;
1897 memset(&dev_info, 0, sizeof(dev_info));
1898 rte_eth_dev_info_get(res->port_id, &dev_info);
1899 if (dev_info.reta_size == 0) {
1900 printf("Redirection table size is 0 which is "
1901 "invalid for RSS\n");
1904 printf("The reta size of port %d is %u\n",
1905 res->port_id, dev_info.reta_size);
1906 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1907 printf("Currently do not support more than %u entries of "
1908 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1912 memset(reta_conf, 0, sizeof(reta_conf));
1913 if (!strcmp(res->list_name, "reta")) {
1914 if (parse_reta_config(res->list_of_items, reta_conf,
1915 dev_info.reta_size)) {
1916 printf("Invalid RSS Redirection Table "
1917 "config entered\n");
1920 ret = rte_eth_dev_rss_reta_update(res->port_id,
1921 reta_conf, dev_info.reta_size);
1923 printf("Bad redirection table parameter, "
1924 "return code = %d \n", ret);
1928 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1930 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1932 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1933 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1934 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1936 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1938 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1941 cmdline_parse_inst_t cmd_config_rss_reta = {
1942 .f = cmd_set_rss_reta_parsed,
1944 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1946 (void *)&cmd_config_rss_reta_port,
1947 (void *)&cmd_config_rss_reta_keyword,
1948 (void *)&cmd_config_rss_reta_port_id,
1949 (void *)&cmd_config_rss_reta_name,
1950 (void *)&cmd_config_rss_reta_list_name,
1951 (void *)&cmd_config_rss_reta_list_of_items,
1956 /* *** SHOW PORT RETA INFO *** */
1957 struct cmd_showport_reta {
1958 cmdline_fixed_string_t show;
1959 cmdline_fixed_string_t port;
1961 cmdline_fixed_string_t rss;
1962 cmdline_fixed_string_t reta;
1964 cmdline_fixed_string_t list_of_items;
1968 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1969 uint16_t nb_entries,
1973 const char *p, *p0 = str;
1977 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1980 p = strchr(p0, '(');
1984 p0 = strchr(p, ')');
1988 if (size >= sizeof(s)) {
1989 printf("The string size exceeds the internal buffer size\n");
1992 snprintf(s, sizeof(s), "%.*s", size, p);
1993 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1994 if (ret <= 0 || ret != num) {
1995 printf("The bits of masks do not match the number of "
1996 "reta entries: %u\n", num);
1999 for (i = 0; i < ret; i++)
2000 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2006 cmd_showport_reta_parsed(void *parsed_result,
2007 __attribute__((unused)) struct cmdline *cl,
2008 __attribute__((unused)) void *data)
2010 struct cmd_showport_reta *res = parsed_result;
2011 struct rte_eth_rss_reta_entry64 reta_conf[8];
2012 struct rte_eth_dev_info dev_info;
2014 memset(&dev_info, 0, sizeof(dev_info));
2015 rte_eth_dev_info_get(res->port_id, &dev_info);
2016 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2017 res->size > ETH_RSS_RETA_SIZE_512) {
2018 printf("Invalid redirection table size: %u\n", res->size);
2022 memset(reta_conf, 0, sizeof(reta_conf));
2023 if (showport_parse_reta_config(reta_conf, res->size,
2024 res->list_of_items) < 0) {
2025 printf("Invalid string: %s for reta masks\n",
2026 res->list_of_items);
2029 port_rss_reta_info(res->port_id, reta_conf, res->size);
2032 cmdline_parse_token_string_t cmd_showport_reta_show =
2033 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2034 cmdline_parse_token_string_t cmd_showport_reta_port =
2035 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2036 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2037 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2038 cmdline_parse_token_string_t cmd_showport_reta_rss =
2039 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2040 cmdline_parse_token_string_t cmd_showport_reta_reta =
2041 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2042 cmdline_parse_token_num_t cmd_showport_reta_size =
2043 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2044 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2045 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2046 list_of_items, NULL);
2048 cmdline_parse_inst_t cmd_showport_reta = {
2049 .f = cmd_showport_reta_parsed,
2051 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
2053 (void *)&cmd_showport_reta_show,
2054 (void *)&cmd_showport_reta_port,
2055 (void *)&cmd_showport_reta_port_id,
2056 (void *)&cmd_showport_reta_rss,
2057 (void *)&cmd_showport_reta_reta,
2058 (void *)&cmd_showport_reta_size,
2059 (void *)&cmd_showport_reta_list_of_items,
2064 /* *** Show RSS hash configuration *** */
2065 struct cmd_showport_rss_hash {
2066 cmdline_fixed_string_t show;
2067 cmdline_fixed_string_t port;
2069 cmdline_fixed_string_t rss_hash;
2070 cmdline_fixed_string_t rss_type;
2071 cmdline_fixed_string_t key; /* optional argument */
2074 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2075 __attribute__((unused)) struct cmdline *cl,
2078 struct cmd_showport_rss_hash *res = parsed_result;
2080 port_rss_hash_conf_show(res->port_id, res->rss_type,
2081 show_rss_key != NULL);
2084 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2085 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2086 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2087 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2088 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2089 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2090 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2091 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2093 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2094 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2095 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2096 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2097 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2098 "ipv6-tcp-ex#ipv6-udp-ex");
2099 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2100 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2102 cmdline_parse_inst_t cmd_showport_rss_hash = {
2103 .f = cmd_showport_rss_hash_parsed,
2106 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2107 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2108 "ipv6-sctp|ipv6-other|l2-payload|"
2109 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2111 (void *)&cmd_showport_rss_hash_show,
2112 (void *)&cmd_showport_rss_hash_port,
2113 (void *)&cmd_showport_rss_hash_port_id,
2114 (void *)&cmd_showport_rss_hash_rss_hash,
2115 (void *)&cmd_showport_rss_hash_rss_hash_info,
2120 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2121 .f = cmd_showport_rss_hash_parsed,
2124 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2125 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2126 "ipv6-sctp|ipv6-other|l2-payload|"
2127 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2129 (void *)&cmd_showport_rss_hash_show,
2130 (void *)&cmd_showport_rss_hash_port,
2131 (void *)&cmd_showport_rss_hash_port_id,
2132 (void *)&cmd_showport_rss_hash_rss_hash,
2133 (void *)&cmd_showport_rss_hash_rss_hash_info,
2134 (void *)&cmd_showport_rss_hash_rss_key,
2139 /* *** Configure DCB *** */
2140 struct cmd_config_dcb {
2141 cmdline_fixed_string_t port;
2142 cmdline_fixed_string_t config;
2144 cmdline_fixed_string_t dcb;
2145 cmdline_fixed_string_t vt;
2146 cmdline_fixed_string_t vt_en;
2148 cmdline_fixed_string_t pfc;
2149 cmdline_fixed_string_t pfc_en;
2153 cmd_config_dcb_parsed(void *parsed_result,
2154 __attribute__((unused)) struct cmdline *cl,
2155 __attribute__((unused)) void *data)
2157 struct cmd_config_dcb *res = parsed_result;
2158 portid_t port_id = res->port_id;
2159 struct rte_port *port;
2163 port = &ports[port_id];
2164 /** Check if the port is not started **/
2165 if (port->port_status != RTE_PORT_STOPPED) {
2166 printf("Please stop port %d first\n", port_id);
2170 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2171 printf("The invalid number of traffic class,"
2172 " only 4 or 8 allowed.\n");
2176 if (nb_fwd_lcores < res->num_tcs) {
2177 printf("nb_cores shouldn't be less than number of TCs.\n");
2180 if (!strncmp(res->pfc_en, "on", 2))
2185 /* DCB in VT mode */
2186 if (!strncmp(res->vt_en, "on", 2))
2187 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2188 (enum rte_eth_nb_tcs)res->num_tcs,
2191 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2192 (enum rte_eth_nb_tcs)res->num_tcs,
2197 printf("Cannot initialize network ports.\n");
2201 cmd_reconfig_device_queue(port_id, 1, 1);
2204 cmdline_parse_token_string_t cmd_config_dcb_port =
2205 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2206 cmdline_parse_token_string_t cmd_config_dcb_config =
2207 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2208 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2209 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2210 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2211 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2212 cmdline_parse_token_string_t cmd_config_dcb_vt =
2213 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2214 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2215 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2216 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2217 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2218 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2219 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2220 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2221 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2223 cmdline_parse_inst_t cmd_config_dcb = {
2224 .f = cmd_config_dcb_parsed,
2226 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2228 (void *)&cmd_config_dcb_port,
2229 (void *)&cmd_config_dcb_config,
2230 (void *)&cmd_config_dcb_port_id,
2231 (void *)&cmd_config_dcb_dcb,
2232 (void *)&cmd_config_dcb_vt,
2233 (void *)&cmd_config_dcb_vt_en,
2234 (void *)&cmd_config_dcb_num_tcs,
2235 (void *)&cmd_config_dcb_pfc,
2236 (void *)&cmd_config_dcb_pfc_en,
2241 /* *** configure number of packets per burst *** */
2242 struct cmd_config_burst {
2243 cmdline_fixed_string_t port;
2244 cmdline_fixed_string_t keyword;
2245 cmdline_fixed_string_t all;
2246 cmdline_fixed_string_t name;
2251 cmd_config_burst_parsed(void *parsed_result,
2252 __attribute__((unused)) struct cmdline *cl,
2253 __attribute__((unused)) void *data)
2255 struct cmd_config_burst *res = parsed_result;
2257 if (!all_ports_stopped()) {
2258 printf("Please stop all ports first\n");
2262 if (!strcmp(res->name, "burst")) {
2263 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2264 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2267 nb_pkt_per_burst = res->value;
2269 printf("Unknown parameter\n");
2275 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2278 cmdline_parse_token_string_t cmd_config_burst_port =
2279 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2280 cmdline_parse_token_string_t cmd_config_burst_keyword =
2281 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2282 cmdline_parse_token_string_t cmd_config_burst_all =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2284 cmdline_parse_token_string_t cmd_config_burst_name =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2286 cmdline_parse_token_num_t cmd_config_burst_value =
2287 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2289 cmdline_parse_inst_t cmd_config_burst = {
2290 .f = cmd_config_burst_parsed,
2292 .help_str = "port config all burst value",
2294 (void *)&cmd_config_burst_port,
2295 (void *)&cmd_config_burst_keyword,
2296 (void *)&cmd_config_burst_all,
2297 (void *)&cmd_config_burst_name,
2298 (void *)&cmd_config_burst_value,
2303 /* *** configure rx/tx queues *** */
2304 struct cmd_config_thresh {
2305 cmdline_fixed_string_t port;
2306 cmdline_fixed_string_t keyword;
2307 cmdline_fixed_string_t all;
2308 cmdline_fixed_string_t name;
2313 cmd_config_thresh_parsed(void *parsed_result,
2314 __attribute__((unused)) struct cmdline *cl,
2315 __attribute__((unused)) void *data)
2317 struct cmd_config_thresh *res = parsed_result;
2319 if (!all_ports_stopped()) {
2320 printf("Please stop all ports first\n");
2324 if (!strcmp(res->name, "txpt"))
2325 tx_pthresh = res->value;
2326 else if(!strcmp(res->name, "txht"))
2327 tx_hthresh = res->value;
2328 else if(!strcmp(res->name, "txwt"))
2329 tx_wthresh = res->value;
2330 else if(!strcmp(res->name, "rxpt"))
2331 rx_pthresh = res->value;
2332 else if(!strcmp(res->name, "rxht"))
2333 rx_hthresh = res->value;
2334 else if(!strcmp(res->name, "rxwt"))
2335 rx_wthresh = res->value;
2337 printf("Unknown parameter\n");
2343 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2346 cmdline_parse_token_string_t cmd_config_thresh_port =
2347 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2348 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2349 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2350 cmdline_parse_token_string_t cmd_config_thresh_all =
2351 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2352 cmdline_parse_token_string_t cmd_config_thresh_name =
2353 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2354 "txpt#txht#txwt#rxpt#rxht#rxwt");
2355 cmdline_parse_token_num_t cmd_config_thresh_value =
2356 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2358 cmdline_parse_inst_t cmd_config_thresh = {
2359 .f = cmd_config_thresh_parsed,
2361 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2363 (void *)&cmd_config_thresh_port,
2364 (void *)&cmd_config_thresh_keyword,
2365 (void *)&cmd_config_thresh_all,
2366 (void *)&cmd_config_thresh_name,
2367 (void *)&cmd_config_thresh_value,
2372 /* *** configure free/rs threshold *** */
2373 struct cmd_config_threshold {
2374 cmdline_fixed_string_t port;
2375 cmdline_fixed_string_t keyword;
2376 cmdline_fixed_string_t all;
2377 cmdline_fixed_string_t name;
2382 cmd_config_threshold_parsed(void *parsed_result,
2383 __attribute__((unused)) struct cmdline *cl,
2384 __attribute__((unused)) void *data)
2386 struct cmd_config_threshold *res = parsed_result;
2388 if (!all_ports_stopped()) {
2389 printf("Please stop all ports first\n");
2393 if (!strcmp(res->name, "txfreet"))
2394 tx_free_thresh = res->value;
2395 else if (!strcmp(res->name, "txrst"))
2396 tx_rs_thresh = res->value;
2397 else if (!strcmp(res->name, "rxfreet"))
2398 rx_free_thresh = res->value;
2400 printf("Unknown parameter\n");
2406 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2409 cmdline_parse_token_string_t cmd_config_threshold_port =
2410 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2411 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2412 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2414 cmdline_parse_token_string_t cmd_config_threshold_all =
2415 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2416 cmdline_parse_token_string_t cmd_config_threshold_name =
2417 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2418 "txfreet#txrst#rxfreet");
2419 cmdline_parse_token_num_t cmd_config_threshold_value =
2420 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2422 cmdline_parse_inst_t cmd_config_threshold = {
2423 .f = cmd_config_threshold_parsed,
2425 .help_str = "port config all txfreet|txrst|rxfreet value",
2427 (void *)&cmd_config_threshold_port,
2428 (void *)&cmd_config_threshold_keyword,
2429 (void *)&cmd_config_threshold_all,
2430 (void *)&cmd_config_threshold_name,
2431 (void *)&cmd_config_threshold_value,
2437 struct cmd_stop_result {
2438 cmdline_fixed_string_t stop;
2441 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2442 __attribute__((unused)) struct cmdline *cl,
2443 __attribute__((unused)) void *data)
2445 stop_packet_forwarding();
2448 cmdline_parse_token_string_t cmd_stop_stop =
2449 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2451 cmdline_parse_inst_t cmd_stop = {
2452 .f = cmd_stop_parsed,
2454 .help_str = "stop - stop packet forwarding",
2456 (void *)&cmd_stop_stop,
2461 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2464 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2465 unsigned int *parsed_items, int check_unique_values)
2467 unsigned int nb_item;
2475 * First parse all items in the list and store their value.
2480 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2482 if ((c >= '0') && (c <= '9')) {
2483 value = (unsigned int) (value * 10 + (c - '0'));
2488 printf("character %c is not a decimal digit\n", c);
2492 printf("No valid value before comma\n");
2495 if (nb_item < max_items) {
2496 parsed_items[nb_item] = value;
2502 if (nb_item >= max_items) {
2503 printf("Number of %s = %u > %u (maximum items)\n",
2504 item_name, nb_item + 1, max_items);
2507 parsed_items[nb_item++] = value;
2508 if (! check_unique_values)
2512 * Then, check that all values in the list are differents.
2513 * No optimization here...
2515 for (i = 0; i < nb_item; i++) {
2516 for (j = i + 1; j < nb_item; j++) {
2517 if (parsed_items[j] == parsed_items[i]) {
2518 printf("duplicated %s %u at index %u and %u\n",
2519 item_name, parsed_items[i], i, j);
2527 struct cmd_set_list_result {
2528 cmdline_fixed_string_t cmd_keyword;
2529 cmdline_fixed_string_t list_name;
2530 cmdline_fixed_string_t list_of_items;
2533 static void cmd_set_list_parsed(void *parsed_result,
2534 __attribute__((unused)) struct cmdline *cl,
2535 __attribute__((unused)) void *data)
2537 struct cmd_set_list_result *res;
2539 unsigned int lcorelist[RTE_MAX_LCORE];
2540 unsigned int portlist[RTE_MAX_ETHPORTS];
2542 unsigned int nb_item;
2544 if (test_done == 0) {
2545 printf("Please stop forwarding first\n");
2549 res = parsed_result;
2550 if (!strcmp(res->list_name, "corelist")) {
2551 nb_item = parse_item_list(res->list_of_items, "core",
2553 parsed_items.lcorelist, 1);
2555 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2560 if (!strcmp(res->list_name, "portlist")) {
2561 nb_item = parse_item_list(res->list_of_items, "port",
2563 parsed_items.portlist, 1);
2565 set_fwd_ports_list(parsed_items.portlist, nb_item);
2571 cmdline_parse_token_string_t cmd_set_list_keyword =
2572 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2574 cmdline_parse_token_string_t cmd_set_list_name =
2575 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2576 "corelist#portlist");
2577 cmdline_parse_token_string_t cmd_set_list_of_items =
2578 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2581 cmdline_parse_inst_t cmd_set_fwd_list = {
2582 .f = cmd_set_list_parsed,
2584 .help_str = "set corelist|portlist x[,y]*",
2586 (void *)&cmd_set_list_keyword,
2587 (void *)&cmd_set_list_name,
2588 (void *)&cmd_set_list_of_items,
2593 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2595 struct cmd_setmask_result {
2596 cmdline_fixed_string_t set;
2597 cmdline_fixed_string_t mask;
2601 static void cmd_set_mask_parsed(void *parsed_result,
2602 __attribute__((unused)) struct cmdline *cl,
2603 __attribute__((unused)) void *data)
2605 struct cmd_setmask_result *res = parsed_result;
2607 if (test_done == 0) {
2608 printf("Please stop forwarding first\n");
2611 if (!strcmp(res->mask, "coremask")) {
2612 set_fwd_lcores_mask(res->hexavalue);
2614 } else if (!strcmp(res->mask, "portmask")) {
2615 set_fwd_ports_mask(res->hexavalue);
2620 cmdline_parse_token_string_t cmd_setmask_set =
2621 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2622 cmdline_parse_token_string_t cmd_setmask_mask =
2623 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2624 "coremask#portmask");
2625 cmdline_parse_token_num_t cmd_setmask_value =
2626 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2628 cmdline_parse_inst_t cmd_set_fwd_mask = {
2629 .f = cmd_set_mask_parsed,
2631 .help_str = "set coremask|portmask hexadecimal value",
2633 (void *)&cmd_setmask_set,
2634 (void *)&cmd_setmask_mask,
2635 (void *)&cmd_setmask_value,
2641 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2643 struct cmd_set_result {
2644 cmdline_fixed_string_t set;
2645 cmdline_fixed_string_t what;
2649 static void cmd_set_parsed(void *parsed_result,
2650 __attribute__((unused)) struct cmdline *cl,
2651 __attribute__((unused)) void *data)
2653 struct cmd_set_result *res = parsed_result;
2654 if (!strcmp(res->what, "nbport")) {
2655 set_fwd_ports_number(res->value);
2657 } else if (!strcmp(res->what, "nbcore")) {
2658 set_fwd_lcores_number(res->value);
2660 } else if (!strcmp(res->what, "burst"))
2661 set_nb_pkt_per_burst(res->value);
2662 else if (!strcmp(res->what, "verbose"))
2663 set_verbose_level(res->value);
2666 cmdline_parse_token_string_t cmd_set_set =
2667 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2668 cmdline_parse_token_string_t cmd_set_what =
2669 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2670 "nbport#nbcore#burst#verbose");
2671 cmdline_parse_token_num_t cmd_set_value =
2672 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2674 cmdline_parse_inst_t cmd_set_numbers = {
2675 .f = cmd_set_parsed,
2677 .help_str = "set nbport|nbcore|burst|verbose value",
2679 (void *)&cmd_set_set,
2680 (void *)&cmd_set_what,
2681 (void *)&cmd_set_value,
2686 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2688 struct cmd_set_txpkts_result {
2689 cmdline_fixed_string_t cmd_keyword;
2690 cmdline_fixed_string_t txpkts;
2691 cmdline_fixed_string_t seg_lengths;
2695 cmd_set_txpkts_parsed(void *parsed_result,
2696 __attribute__((unused)) struct cmdline *cl,
2697 __attribute__((unused)) void *data)
2699 struct cmd_set_txpkts_result *res;
2700 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2701 unsigned int nb_segs;
2703 res = parsed_result;
2704 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2705 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2707 set_tx_pkt_segments(seg_lengths, nb_segs);
2710 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2711 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2712 cmd_keyword, "set");
2713 cmdline_parse_token_string_t cmd_set_txpkts_name =
2714 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2716 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2717 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2720 cmdline_parse_inst_t cmd_set_txpkts = {
2721 .f = cmd_set_txpkts_parsed,
2723 .help_str = "set txpkts x[,y]*",
2725 (void *)&cmd_set_txpkts_keyword,
2726 (void *)&cmd_set_txpkts_name,
2727 (void *)&cmd_set_txpkts_lengths,
2732 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2734 struct cmd_set_txsplit_result {
2735 cmdline_fixed_string_t cmd_keyword;
2736 cmdline_fixed_string_t txsplit;
2737 cmdline_fixed_string_t mode;
2741 cmd_set_txsplit_parsed(void *parsed_result,
2742 __attribute__((unused)) struct cmdline *cl,
2743 __attribute__((unused)) void *data)
2745 struct cmd_set_txsplit_result *res;
2747 res = parsed_result;
2748 set_tx_pkt_split(res->mode);
2751 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2752 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2753 cmd_keyword, "set");
2754 cmdline_parse_token_string_t cmd_set_txsplit_name =
2755 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2756 txsplit, "txsplit");
2757 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2758 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2761 cmdline_parse_inst_t cmd_set_txsplit = {
2762 .f = cmd_set_txsplit_parsed,
2764 .help_str = "set txsplit on|off|rand",
2766 (void *)&cmd_set_txsplit_keyword,
2767 (void *)&cmd_set_txsplit_name,
2768 (void *)&cmd_set_txsplit_mode,
2773 /* *** CONFIG TX QUEUE FLAGS *** */
2775 struct cmd_config_txqflags_result {
2776 cmdline_fixed_string_t port;
2777 cmdline_fixed_string_t config;
2778 cmdline_fixed_string_t all;
2779 cmdline_fixed_string_t what;
2783 static void cmd_config_txqflags_parsed(void *parsed_result,
2784 __attribute__((unused)) struct cmdline *cl,
2785 __attribute__((unused)) void *data)
2787 struct cmd_config_txqflags_result *res = parsed_result;
2789 if (!all_ports_stopped()) {
2790 printf("Please stop all ports first\n");
2794 if (strcmp(res->what, "txqflags")) {
2795 printf("Unknown parameter\n");
2799 if (res->hexvalue >= 0) {
2800 txq_flags = res->hexvalue;
2802 printf("txqflags must be >= 0\n");
2808 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2811 cmdline_parse_token_string_t cmd_config_txqflags_port =
2812 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2814 cmdline_parse_token_string_t cmd_config_txqflags_config =
2815 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2817 cmdline_parse_token_string_t cmd_config_txqflags_all =
2818 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2820 cmdline_parse_token_string_t cmd_config_txqflags_what =
2821 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2823 cmdline_parse_token_num_t cmd_config_txqflags_value =
2824 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2827 cmdline_parse_inst_t cmd_config_txqflags = {
2828 .f = cmd_config_txqflags_parsed,
2830 .help_str = "port config all txqflags value",
2832 (void *)&cmd_config_txqflags_port,
2833 (void *)&cmd_config_txqflags_config,
2834 (void *)&cmd_config_txqflags_all,
2835 (void *)&cmd_config_txqflags_what,
2836 (void *)&cmd_config_txqflags_value,
2841 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2842 struct cmd_rx_vlan_filter_all_result {
2843 cmdline_fixed_string_t rx_vlan;
2844 cmdline_fixed_string_t what;
2845 cmdline_fixed_string_t all;
2850 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2851 __attribute__((unused)) struct cmdline *cl,
2852 __attribute__((unused)) void *data)
2854 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2856 if (!strcmp(res->what, "add"))
2857 rx_vlan_all_filter_set(res->port_id, 1);
2859 rx_vlan_all_filter_set(res->port_id, 0);
2862 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2863 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2864 rx_vlan, "rx_vlan");
2865 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2866 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2868 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2869 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2871 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2872 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2875 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2876 .f = cmd_rx_vlan_filter_all_parsed,
2878 .help_str = "add/remove all identifiers to/from the set of VLAN "
2879 "Identifiers filtered by a port",
2881 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2882 (void *)&cmd_rx_vlan_filter_all_what,
2883 (void *)&cmd_rx_vlan_filter_all_all,
2884 (void *)&cmd_rx_vlan_filter_all_portid,
2889 /* *** VLAN OFFLOAD SET ON A PORT *** */
2890 struct cmd_vlan_offload_result {
2891 cmdline_fixed_string_t vlan;
2892 cmdline_fixed_string_t set;
2893 cmdline_fixed_string_t vlan_type;
2894 cmdline_fixed_string_t what;
2895 cmdline_fixed_string_t on;
2896 cmdline_fixed_string_t port_id;
2900 cmd_vlan_offload_parsed(void *parsed_result,
2901 __attribute__((unused)) struct cmdline *cl,
2902 __attribute__((unused)) void *data)
2905 struct cmd_vlan_offload_result *res = parsed_result;
2908 portid_t port_id = 0;
2912 len = strnlen(str, STR_TOKEN_SIZE);
2914 /* Get port_id first */
2922 tmp = strtoul(str, NULL, 0);
2923 /* If port_id greater that what portid_t can represent, return */
2924 if(tmp >= RTE_MAX_ETHPORTS)
2926 port_id = (portid_t)tmp;
2928 if (!strcmp(res->on, "on"))
2933 if (!strcmp(res->what, "strip"))
2934 rx_vlan_strip_set(port_id, on);
2935 else if(!strcmp(res->what, "stripq")){
2936 uint16_t queue_id = 0;
2938 /* No queue_id, return */
2940 printf("must specify (port,queue_id)\n");
2943 tmp = strtoul(str + i + 1, NULL, 0);
2944 /* If queue_id greater that what 16-bits can represent, return */
2948 queue_id = (uint16_t)tmp;
2949 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2951 else if (!strcmp(res->what, "filter"))
2952 rx_vlan_filter_set(port_id, on);
2954 vlan_extend_set(port_id, on);
2959 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2960 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2962 cmdline_parse_token_string_t cmd_vlan_offload_set =
2963 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2965 cmdline_parse_token_string_t cmd_vlan_offload_what =
2966 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2967 what, "strip#filter#qinq#stripq");
2968 cmdline_parse_token_string_t cmd_vlan_offload_on =
2969 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2971 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2972 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2975 cmdline_parse_inst_t cmd_vlan_offload = {
2976 .f = cmd_vlan_offload_parsed,
2978 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2979 " qinq(extended) for both rx/tx sides ",
2981 (void *)&cmd_vlan_offload_vlan,
2982 (void *)&cmd_vlan_offload_set,
2983 (void *)&cmd_vlan_offload_what,
2984 (void *)&cmd_vlan_offload_on,
2985 (void *)&cmd_vlan_offload_portid,
2990 /* *** VLAN TPID SET ON A PORT *** */
2991 struct cmd_vlan_tpid_result {
2992 cmdline_fixed_string_t vlan;
2993 cmdline_fixed_string_t set;
2994 cmdline_fixed_string_t vlan_type;
2995 cmdline_fixed_string_t what;
3001 cmd_vlan_tpid_parsed(void *parsed_result,
3002 __attribute__((unused)) struct cmdline *cl,
3003 __attribute__((unused)) void *data)
3005 struct cmd_vlan_tpid_result *res = parsed_result;
3006 enum rte_vlan_type vlan_type;
3008 if (!strcmp(res->vlan_type, "inner"))
3009 vlan_type = ETH_VLAN_TYPE_INNER;
3010 else if (!strcmp(res->vlan_type, "outer"))
3011 vlan_type = ETH_VLAN_TYPE_OUTER;
3013 printf("Unknown vlan type\n");
3016 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3019 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3020 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3022 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3023 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3025 cmdline_parse_token_string_t cmd_vlan_type =
3026 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3027 vlan_type, "inner#outer");
3028 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3029 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3031 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3032 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3034 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3035 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3038 cmdline_parse_inst_t cmd_vlan_tpid = {
3039 .f = cmd_vlan_tpid_parsed,
3041 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
3044 (void *)&cmd_vlan_tpid_vlan,
3045 (void *)&cmd_vlan_tpid_set,
3046 (void *)&cmd_vlan_type,
3047 (void *)&cmd_vlan_tpid_what,
3048 (void *)&cmd_vlan_tpid_tpid,
3049 (void *)&cmd_vlan_tpid_portid,
3054 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3055 struct cmd_rx_vlan_filter_result {
3056 cmdline_fixed_string_t rx_vlan;
3057 cmdline_fixed_string_t what;
3063 cmd_rx_vlan_filter_parsed(void *parsed_result,
3064 __attribute__((unused)) struct cmdline *cl,
3065 __attribute__((unused)) void *data)
3067 struct cmd_rx_vlan_filter_result *res = parsed_result;
3069 if (!strcmp(res->what, "add"))
3070 rx_vft_set(res->port_id, res->vlan_id, 1);
3072 rx_vft_set(res->port_id, res->vlan_id, 0);
3075 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3076 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3077 rx_vlan, "rx_vlan");
3078 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3079 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3081 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3082 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3084 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3085 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3088 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3089 .f = cmd_rx_vlan_filter_parsed,
3091 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
3092 "Identifiers filtered by a port",
3094 (void *)&cmd_rx_vlan_filter_rx_vlan,
3095 (void *)&cmd_rx_vlan_filter_what,
3096 (void *)&cmd_rx_vlan_filter_vlanid,
3097 (void *)&cmd_rx_vlan_filter_portid,
3102 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3103 struct cmd_tx_vlan_set_result {
3104 cmdline_fixed_string_t tx_vlan;
3105 cmdline_fixed_string_t set;
3111 cmd_tx_vlan_set_parsed(void *parsed_result,
3112 __attribute__((unused)) struct cmdline *cl,
3113 __attribute__((unused)) void *data)
3115 struct cmd_tx_vlan_set_result *res = parsed_result;
3117 tx_vlan_set(res->port_id, res->vlan_id);
3120 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3121 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3122 tx_vlan, "tx_vlan");
3123 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3124 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3126 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3127 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3129 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3130 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3133 cmdline_parse_inst_t cmd_tx_vlan_set = {
3134 .f = cmd_tx_vlan_set_parsed,
3136 .help_str = "enable hardware insertion of a single VLAN header "
3137 "with a given TAG Identifier in packets sent on a port",
3139 (void *)&cmd_tx_vlan_set_tx_vlan,
3140 (void *)&cmd_tx_vlan_set_set,
3141 (void *)&cmd_tx_vlan_set_portid,
3142 (void *)&cmd_tx_vlan_set_vlanid,
3147 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3148 struct cmd_tx_vlan_set_qinq_result {
3149 cmdline_fixed_string_t tx_vlan;
3150 cmdline_fixed_string_t set;
3153 uint16_t vlan_id_outer;
3157 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3158 __attribute__((unused)) struct cmdline *cl,
3159 __attribute__((unused)) void *data)
3161 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3163 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3166 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3167 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3168 tx_vlan, "tx_vlan");
3169 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3170 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3172 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3173 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3175 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3176 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3178 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3179 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3180 vlan_id_outer, UINT16);
3182 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3183 .f = cmd_tx_vlan_set_qinq_parsed,
3185 .help_str = "enable hardware insertion of double VLAN header "
3186 "with given TAG Identifiers in packets sent on a port",
3188 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3189 (void *)&cmd_tx_vlan_set_qinq_set,
3190 (void *)&cmd_tx_vlan_set_qinq_portid,
3191 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3192 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3197 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3198 struct cmd_tx_vlan_set_pvid_result {
3199 cmdline_fixed_string_t tx_vlan;
3200 cmdline_fixed_string_t set;
3201 cmdline_fixed_string_t pvid;
3204 cmdline_fixed_string_t mode;
3208 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3209 __attribute__((unused)) struct cmdline *cl,
3210 __attribute__((unused)) void *data)
3212 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3214 if (strcmp(res->mode, "on") == 0)
3215 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3217 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3220 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3222 tx_vlan, "tx_vlan");
3223 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3224 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3226 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3227 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3229 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3230 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3232 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3233 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3235 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3236 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3239 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3240 .f = cmd_tx_vlan_set_pvid_parsed,
3242 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3244 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3245 (void *)&cmd_tx_vlan_set_pvid_set,
3246 (void *)&cmd_tx_vlan_set_pvid_pvid,
3247 (void *)&cmd_tx_vlan_set_pvid_port_id,
3248 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3249 (void *)&cmd_tx_vlan_set_pvid_mode,
3254 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3255 struct cmd_tx_vlan_reset_result {
3256 cmdline_fixed_string_t tx_vlan;
3257 cmdline_fixed_string_t reset;
3262 cmd_tx_vlan_reset_parsed(void *parsed_result,
3263 __attribute__((unused)) struct cmdline *cl,
3264 __attribute__((unused)) void *data)
3266 struct cmd_tx_vlan_reset_result *res = parsed_result;
3268 tx_vlan_reset(res->port_id);
3271 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3272 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3273 tx_vlan, "tx_vlan");
3274 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3275 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3277 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3278 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3281 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3282 .f = cmd_tx_vlan_reset_parsed,
3284 .help_str = "disable hardware insertion of a VLAN header in packets "
3287 (void *)&cmd_tx_vlan_reset_tx_vlan,
3288 (void *)&cmd_tx_vlan_reset_reset,
3289 (void *)&cmd_tx_vlan_reset_portid,
3295 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3296 struct cmd_csum_result {
3297 cmdline_fixed_string_t csum;
3298 cmdline_fixed_string_t mode;
3299 cmdline_fixed_string_t proto;
3300 cmdline_fixed_string_t hwsw;
3305 csum_show(int port_id)
3307 struct rte_eth_dev_info dev_info;
3310 ol_flags = ports[port_id].tx_ol_flags;
3311 printf("Parse tunnel is %s\n",
3312 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3313 printf("IP checksum offload is %s\n",
3314 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3315 printf("UDP checksum offload is %s\n",
3316 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3317 printf("TCP checksum offload is %s\n",
3318 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3319 printf("SCTP checksum offload is %s\n",
3320 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3321 printf("Outer-Ip checksum offload is %s\n",
3322 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3324 /* display warnings if configuration is not supported by the NIC */
3325 rte_eth_dev_info_get(port_id, &dev_info);
3326 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3327 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3328 printf("Warning: hardware IP checksum enabled but not "
3329 "supported by port %d\n", port_id);
3331 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3332 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3333 printf("Warning: hardware UDP checksum enabled but not "
3334 "supported by port %d\n", port_id);
3336 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3337 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3338 printf("Warning: hardware TCP checksum enabled but not "
3339 "supported by port %d\n", port_id);
3341 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3342 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3343 printf("Warning: hardware SCTP checksum enabled but not "
3344 "supported by port %d\n", port_id);
3346 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3347 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3348 printf("Warning: hardware outer IP checksum enabled but not "
3349 "supported by port %d\n", port_id);
3354 cmd_csum_parsed(void *parsed_result,
3355 __attribute__((unused)) struct cmdline *cl,
3356 __attribute__((unused)) void *data)
3358 struct cmd_csum_result *res = parsed_result;
3362 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3363 printf("invalid port %d\n", res->port_id);
3367 if (!strcmp(res->mode, "set")) {
3369 if (!strcmp(res->hwsw, "hw"))
3372 if (!strcmp(res->proto, "ip")) {
3373 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3374 } else if (!strcmp(res->proto, "udp")) {
3375 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3376 } else if (!strcmp(res->proto, "tcp")) {
3377 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3378 } else if (!strcmp(res->proto, "sctp")) {
3379 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3380 } else if (!strcmp(res->proto, "outer-ip")) {
3381 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3385 ports[res->port_id].tx_ol_flags |= mask;
3387 ports[res->port_id].tx_ol_flags &= (~mask);
3389 csum_show(res->port_id);
3392 cmdline_parse_token_string_t cmd_csum_csum =
3393 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3395 cmdline_parse_token_string_t cmd_csum_mode =
3396 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3398 cmdline_parse_token_string_t cmd_csum_proto =
3399 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3400 proto, "ip#tcp#udp#sctp#outer-ip");
3401 cmdline_parse_token_string_t cmd_csum_hwsw =
3402 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3404 cmdline_parse_token_num_t cmd_csum_portid =
3405 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3408 cmdline_parse_inst_t cmd_csum_set = {
3409 .f = cmd_csum_parsed,
3411 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3412 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3414 (void *)&cmd_csum_csum,
3415 (void *)&cmd_csum_mode,
3416 (void *)&cmd_csum_proto,
3417 (void *)&cmd_csum_hwsw,
3418 (void *)&cmd_csum_portid,
3423 cmdline_parse_token_string_t cmd_csum_mode_show =
3424 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3427 cmdline_parse_inst_t cmd_csum_show = {
3428 .f = cmd_csum_parsed,
3430 .help_str = "show checksum offload configuration: csum show <port>",
3432 (void *)&cmd_csum_csum,
3433 (void *)&cmd_csum_mode_show,
3434 (void *)&cmd_csum_portid,
3439 /* Enable/disable tunnel parsing */
3440 struct cmd_csum_tunnel_result {
3441 cmdline_fixed_string_t csum;
3442 cmdline_fixed_string_t parse;
3443 cmdline_fixed_string_t onoff;
3448 cmd_csum_tunnel_parsed(void *parsed_result,
3449 __attribute__((unused)) struct cmdline *cl,
3450 __attribute__((unused)) void *data)
3452 struct cmd_csum_tunnel_result *res = parsed_result;
3454 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3457 if (!strcmp(res->onoff, "on"))
3458 ports[res->port_id].tx_ol_flags |=
3459 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3461 ports[res->port_id].tx_ol_flags &=
3462 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3464 csum_show(res->port_id);
3467 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3468 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3470 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3471 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3472 parse, "parse_tunnel");
3473 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3474 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3476 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3477 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3480 cmdline_parse_inst_t cmd_csum_tunnel = {
3481 .f = cmd_csum_tunnel_parsed,
3483 .help_str = "enable/disable parsing of tunnels for csum engine: "
3484 "csum parse_tunnel on|off <tx-port>",
3486 (void *)&cmd_csum_tunnel_csum,
3487 (void *)&cmd_csum_tunnel_parse,
3488 (void *)&cmd_csum_tunnel_onoff,
3489 (void *)&cmd_csum_tunnel_portid,
3494 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3495 struct cmd_tso_set_result {
3496 cmdline_fixed_string_t tso;
3497 cmdline_fixed_string_t mode;
3503 cmd_tso_set_parsed(void *parsed_result,
3504 __attribute__((unused)) struct cmdline *cl,
3505 __attribute__((unused)) void *data)
3507 struct cmd_tso_set_result *res = parsed_result;
3508 struct rte_eth_dev_info dev_info;
3510 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3513 if (!strcmp(res->mode, "set"))
3514 ports[res->port_id].tso_segsz = res->tso_segsz;
3516 if (ports[res->port_id].tso_segsz == 0)
3517 printf("TSO for non-tunneled packets is disabled\n");
3519 printf("TSO segment size for non-tunneled packets is %d\n",
3520 ports[res->port_id].tso_segsz);
3522 /* display warnings if configuration is not supported by the NIC */
3523 rte_eth_dev_info_get(res->port_id, &dev_info);
3524 if ((ports[res->port_id].tso_segsz != 0) &&
3525 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3526 printf("Warning: TSO enabled but not "
3527 "supported by port %d\n", res->port_id);
3531 cmdline_parse_token_string_t cmd_tso_set_tso =
3532 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3534 cmdline_parse_token_string_t cmd_tso_set_mode =
3535 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3537 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3538 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3540 cmdline_parse_token_num_t cmd_tso_set_portid =
3541 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3544 cmdline_parse_inst_t cmd_tso_set = {
3545 .f = cmd_tso_set_parsed,
3547 .help_str = "Set TSO segment size of non-tunneled packets "
3548 "for csum engine (0 to disable): tso set <tso_segsz> <port>",
3550 (void *)&cmd_tso_set_tso,
3551 (void *)&cmd_tso_set_mode,
3552 (void *)&cmd_tso_set_tso_segsz,
3553 (void *)&cmd_tso_set_portid,
3558 cmdline_parse_token_string_t cmd_tso_show_mode =
3559 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3563 cmdline_parse_inst_t cmd_tso_show = {
3564 .f = cmd_tso_set_parsed,
3566 .help_str = "Show TSO segment size of non-tunneled packets "
3567 "for csum engine: tso show <port>",
3569 (void *)&cmd_tso_set_tso,
3570 (void *)&cmd_tso_show_mode,
3571 (void *)&cmd_tso_set_portid,
3576 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3577 struct cmd_tunnel_tso_set_result {
3578 cmdline_fixed_string_t tso;
3579 cmdline_fixed_string_t mode;
3585 check_tunnel_tso_nic_support(uint8_t port_id)
3587 struct rte_eth_dev_info dev_info;
3589 rte_eth_dev_info_get(port_id, &dev_info);
3590 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3591 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3592 "supported by port %d\n", port_id);
3593 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3594 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3595 "supported by port %d\n", port_id);
3596 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3597 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3598 "supported by port %d\n", port_id);
3599 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3600 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3601 "supported by port %d\n", port_id);
3605 cmd_tunnel_tso_set_parsed(void *parsed_result,
3606 __attribute__((unused)) struct cmdline *cl,
3607 __attribute__((unused)) void *data)
3609 struct cmd_tunnel_tso_set_result *res = parsed_result;
3611 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3614 if (!strcmp(res->mode, "set"))
3615 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3617 if (ports[res->port_id].tunnel_tso_segsz == 0)
3618 printf("TSO for tunneled packets is disabled\n");
3620 printf("TSO segment size for tunneled packets is %d\n",
3621 ports[res->port_id].tunnel_tso_segsz);
3623 /* Below conditions are needed to make it work:
3624 * (1) tunnel TSO is supported by the NIC;
3625 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3627 * (3) for tunneled pkts with outer L3 of IPv4,
3628 * "csum set outer-ip" must be set to hw, because after tso,
3629 * total_len of outer IP header is changed, and the checksum
3630 * of outer IP header calculated by sw should be wrong; that
3631 * is not necessary for IPv6 tunneled pkts because there's no
3632 * checksum in IP header anymore.
3634 check_tunnel_tso_nic_support(res->port_id);
3636 if (!(ports[res->port_id].tx_ol_flags &
3637 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3638 printf("Warning: csum parse_tunnel must be set "
3639 "so that tunneled packets are recognized\n");
3640 if (!(ports[res->port_id].tx_ol_flags &
3641 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3642 printf("Warning: csum set outer-ip must be set to hw "
3643 "if outer L3 is IPv4; not necessary for IPv6\n");
3647 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3648 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3650 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3651 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3653 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3654 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3656 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3657 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3660 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3661 .f = cmd_tunnel_tso_set_parsed,
3663 .help_str = "Set TSO segment size of tunneled packets for csum engine "
3664 "(0 to disable): tunnel_tso set <tso_segsz> <port>",
3666 (void *)&cmd_tunnel_tso_set_tso,
3667 (void *)&cmd_tunnel_tso_set_mode,
3668 (void *)&cmd_tunnel_tso_set_tso_segsz,
3669 (void *)&cmd_tunnel_tso_set_portid,
3674 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3675 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3679 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3680 .f = cmd_tunnel_tso_set_parsed,
3682 .help_str = "Show TSO segment size of tunneled packets "
3683 "for csum engine: tunnel_tso show <port>",
3685 (void *)&cmd_tunnel_tso_set_tso,
3686 (void *)&cmd_tunnel_tso_show_mode,
3687 (void *)&cmd_tunnel_tso_set_portid,
3692 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3693 struct cmd_set_flush_rx {
3694 cmdline_fixed_string_t set;
3695 cmdline_fixed_string_t flush_rx;
3696 cmdline_fixed_string_t mode;
3700 cmd_set_flush_rx_parsed(void *parsed_result,
3701 __attribute__((unused)) struct cmdline *cl,
3702 __attribute__((unused)) void *data)
3704 struct cmd_set_flush_rx *res = parsed_result;
3705 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3708 cmdline_parse_token_string_t cmd_setflushrx_set =
3709 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3711 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3712 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3713 flush_rx, "flush_rx");
3714 cmdline_parse_token_string_t cmd_setflushrx_mode =
3715 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3719 cmdline_parse_inst_t cmd_set_flush_rx = {
3720 .f = cmd_set_flush_rx_parsed,
3721 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3724 (void *)&cmd_setflushrx_set,
3725 (void *)&cmd_setflushrx_flush_rx,
3726 (void *)&cmd_setflushrx_mode,
3731 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3732 struct cmd_set_link_check {
3733 cmdline_fixed_string_t set;
3734 cmdline_fixed_string_t link_check;
3735 cmdline_fixed_string_t mode;
3739 cmd_set_link_check_parsed(void *parsed_result,
3740 __attribute__((unused)) struct cmdline *cl,
3741 __attribute__((unused)) void *data)
3743 struct cmd_set_link_check *res = parsed_result;
3744 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3747 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3748 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3750 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3751 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3752 link_check, "link_check");
3753 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3754 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3758 cmdline_parse_inst_t cmd_set_link_check = {
3759 .f = cmd_set_link_check_parsed,
3760 .help_str = "set link_check on|off: enable/disable link status check "
3761 "when starting/stopping a port",
3764 (void *)&cmd_setlinkcheck_set,
3765 (void *)&cmd_setlinkcheck_link_check,
3766 (void *)&cmd_setlinkcheck_mode,
3771 #ifdef RTE_NIC_BYPASS
3772 /* *** SET NIC BYPASS MODE *** */
3773 struct cmd_set_bypass_mode_result {
3774 cmdline_fixed_string_t set;
3775 cmdline_fixed_string_t bypass;
3776 cmdline_fixed_string_t mode;
3777 cmdline_fixed_string_t value;
3782 cmd_set_bypass_mode_parsed(void *parsed_result,
3783 __attribute__((unused)) struct cmdline *cl,
3784 __attribute__((unused)) void *data)
3786 struct cmd_set_bypass_mode_result *res = parsed_result;
3787 portid_t port_id = res->port_id;
3788 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3790 if (!strcmp(res->value, "bypass"))
3791 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3792 else if (!strcmp(res->value, "isolate"))
3793 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3795 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3797 /* Set the bypass mode for the relevant port. */
3798 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3799 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3803 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3804 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3806 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3807 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3809 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3810 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3812 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3813 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3814 value, "normal#bypass#isolate");
3815 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3816 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3819 cmdline_parse_inst_t cmd_set_bypass_mode = {
3820 .f = cmd_set_bypass_mode_parsed,
3821 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3822 "Set the NIC bypass mode for port_id",
3825 (void *)&cmd_setbypass_mode_set,
3826 (void *)&cmd_setbypass_mode_bypass,
3827 (void *)&cmd_setbypass_mode_mode,
3828 (void *)&cmd_setbypass_mode_value,
3829 (void *)&cmd_setbypass_mode_port,
3834 /* *** SET NIC BYPASS EVENT *** */
3835 struct cmd_set_bypass_event_result {
3836 cmdline_fixed_string_t set;
3837 cmdline_fixed_string_t bypass;
3838 cmdline_fixed_string_t event;
3839 cmdline_fixed_string_t event_value;
3840 cmdline_fixed_string_t mode;
3841 cmdline_fixed_string_t mode_value;
3846 cmd_set_bypass_event_parsed(void *parsed_result,
3847 __attribute__((unused)) struct cmdline *cl,
3848 __attribute__((unused)) void *data)
3851 struct cmd_set_bypass_event_result *res = parsed_result;
3852 portid_t port_id = res->port_id;
3853 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3854 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3856 if (!strcmp(res->event_value, "timeout"))
3857 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3858 else if (!strcmp(res->event_value, "os_on"))
3859 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3860 else if (!strcmp(res->event_value, "os_off"))
3861 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3862 else if (!strcmp(res->event_value, "power_on"))
3863 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3864 else if (!strcmp(res->event_value, "power_off"))
3865 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3867 bypass_event = RTE_BYPASS_EVENT_NONE;
3869 if (!strcmp(res->mode_value, "bypass"))
3870 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3871 else if (!strcmp(res->mode_value, "isolate"))
3872 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3874 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3876 /* Set the watchdog timeout. */
3877 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3880 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3881 (rc = rte_eth_dev_wd_timeout_store(port_id,
3882 bypass_timeout)) != 0) {
3883 printf("Failed to set timeout value %u "
3884 "for port %d, errto code: %d.\n",
3885 bypass_timeout, port_id, rc);
3889 /* Set the bypass event to transition to bypass mode. */
3890 if (0 != rte_eth_dev_bypass_event_store(port_id,
3891 bypass_event, bypass_mode)) {
3892 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3897 cmdline_parse_token_string_t cmd_setbypass_event_set =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3900 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3901 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3903 cmdline_parse_token_string_t cmd_setbypass_event_event =
3904 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3906 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3907 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3908 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3909 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3910 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3912 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3913 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3914 mode_value, "normal#bypass#isolate");
3915 cmdline_parse_token_num_t cmd_setbypass_event_port =
3916 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3919 cmdline_parse_inst_t cmd_set_bypass_event = {
3920 .f = cmd_set_bypass_event_parsed,
3921 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3922 "mode (normal|bypass|isolate) (port_id): "
3923 "Set the NIC bypass event mode for port_id",
3926 (void *)&cmd_setbypass_event_set,
3927 (void *)&cmd_setbypass_event_bypass,
3928 (void *)&cmd_setbypass_event_event,
3929 (void *)&cmd_setbypass_event_event_value,
3930 (void *)&cmd_setbypass_event_mode,
3931 (void *)&cmd_setbypass_event_mode_value,
3932 (void *)&cmd_setbypass_event_port,
3938 /* *** SET NIC BYPASS TIMEOUT *** */
3939 struct cmd_set_bypass_timeout_result {
3940 cmdline_fixed_string_t set;
3941 cmdline_fixed_string_t bypass;
3942 cmdline_fixed_string_t timeout;
3943 cmdline_fixed_string_t value;
3947 cmd_set_bypass_timeout_parsed(void *parsed_result,
3948 __attribute__((unused)) struct cmdline *cl,
3949 __attribute__((unused)) void *data)
3951 struct cmd_set_bypass_timeout_result *res = parsed_result;
3953 if (!strcmp(res->value, "1.5"))
3954 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3955 else if (!strcmp(res->value, "2"))
3956 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3957 else if (!strcmp(res->value, "3"))
3958 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3959 else if (!strcmp(res->value, "4"))
3960 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3961 else if (!strcmp(res->value, "8"))
3962 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3963 else if (!strcmp(res->value, "16"))
3964 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3965 else if (!strcmp(res->value, "32"))
3966 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3968 bypass_timeout = RTE_BYPASS_TMT_OFF;
3971 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3974 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3977 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3978 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3979 timeout, "timeout");
3980 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3982 value, "0#1.5#2#3#4#8#16#32");
3984 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3985 .f = cmd_set_bypass_timeout_parsed,
3986 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3987 "Set the NIC bypass watchdog timeout",
3990 (void *)&cmd_setbypass_timeout_set,
3991 (void *)&cmd_setbypass_timeout_bypass,
3992 (void *)&cmd_setbypass_timeout_timeout,
3993 (void *)&cmd_setbypass_timeout_value,
3998 /* *** SHOW NIC BYPASS MODE *** */
3999 struct cmd_show_bypass_config_result {
4000 cmdline_fixed_string_t show;
4001 cmdline_fixed_string_t bypass;
4002 cmdline_fixed_string_t config;
4007 cmd_show_bypass_config_parsed(void *parsed_result,
4008 __attribute__((unused)) struct cmdline *cl,
4009 __attribute__((unused)) void *data)
4011 struct cmd_show_bypass_config_result *res = parsed_result;
4012 uint32_t event_mode;
4013 uint32_t bypass_mode;
4014 portid_t port_id = res->port_id;
4015 uint32_t timeout = bypass_timeout;
4018 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4019 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4020 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4021 {"UNKNOWN", "normal", "bypass", "isolate"};
4022 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4029 int num_events = (sizeof events) / (sizeof events[0]);
4031 /* Display the bypass mode.*/
4032 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4033 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4037 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4038 bypass_mode = RTE_BYPASS_MODE_NONE;
4040 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4043 /* Display the bypass timeout.*/
4044 if (!RTE_BYPASS_TMT_VALID(timeout))
4045 timeout = RTE_BYPASS_TMT_OFF;
4047 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4049 /* Display the bypass events and associated modes. */
4050 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4052 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4053 printf("\tFailed to get bypass mode for event = %s\n",
4056 if (!RTE_BYPASS_MODE_VALID(event_mode))
4057 event_mode = RTE_BYPASS_MODE_NONE;
4059 printf("\tbypass event: %-16s = %s\n", events[i],
4065 cmdline_parse_token_string_t cmd_showbypass_config_show =
4066 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4068 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4069 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4071 cmdline_parse_token_string_t cmd_showbypass_config_config =
4072 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4074 cmdline_parse_token_num_t cmd_showbypass_config_port =
4075 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4078 cmdline_parse_inst_t cmd_show_bypass_config = {
4079 .f = cmd_show_bypass_config_parsed,
4080 .help_str = "show bypass config (port_id): "
4081 "Show the NIC bypass config for port_id",
4084 (void *)&cmd_showbypass_config_show,
4085 (void *)&cmd_showbypass_config_bypass,
4086 (void *)&cmd_showbypass_config_config,
4087 (void *)&cmd_showbypass_config_port,
4093 #ifdef RTE_LIBRTE_PMD_BOND
4094 /* *** SET BONDING MODE *** */
4095 struct cmd_set_bonding_mode_result {
4096 cmdline_fixed_string_t set;
4097 cmdline_fixed_string_t bonding;
4098 cmdline_fixed_string_t mode;
4103 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4104 __attribute__((unused)) struct cmdline *cl,
4105 __attribute__((unused)) void *data)
4107 struct cmd_set_bonding_mode_result *res = parsed_result;
4108 portid_t port_id = res->port_id;
4110 /* Set the bonding mode for the relevant port. */
4111 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4112 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4115 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4116 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4118 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4119 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4120 bonding, "bonding");
4121 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4122 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4124 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4125 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4127 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4128 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4131 cmdline_parse_inst_t cmd_set_bonding_mode = {
4132 .f = cmd_set_bonding_mode_parsed,
4133 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
4136 (void *) &cmd_setbonding_mode_set,
4137 (void *) &cmd_setbonding_mode_bonding,
4138 (void *) &cmd_setbonding_mode_mode,
4139 (void *) &cmd_setbonding_mode_value,
4140 (void *) &cmd_setbonding_mode_port,
4145 /* *** SET BALANCE XMIT POLICY *** */
4146 struct cmd_set_bonding_balance_xmit_policy_result {
4147 cmdline_fixed_string_t set;
4148 cmdline_fixed_string_t bonding;
4149 cmdline_fixed_string_t balance_xmit_policy;
4151 cmdline_fixed_string_t policy;
4154 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4155 __attribute__((unused)) struct cmdline *cl,
4156 __attribute__((unused)) void *data)
4158 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4159 portid_t port_id = res->port_id;
4162 if (!strcmp(res->policy, "l2")) {
4163 policy = BALANCE_XMIT_POLICY_LAYER2;
4164 } else if (!strcmp(res->policy, "l23")) {
4165 policy = BALANCE_XMIT_POLICY_LAYER23;
4166 } else if (!strcmp(res->policy, "l34")) {
4167 policy = BALANCE_XMIT_POLICY_LAYER34;
4169 printf("\t Invalid xmit policy selection");
4173 /* Set the bonding mode for the relevant port. */
4174 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4175 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4180 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4181 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4183 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4184 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4185 bonding, "bonding");
4186 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4187 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4188 balance_xmit_policy, "balance_xmit_policy");
4189 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4190 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4192 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4193 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4194 policy, "l2#l23#l34");
4196 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4197 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4198 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
4201 (void *)&cmd_setbonding_balance_xmit_policy_set,
4202 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4203 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4204 (void *)&cmd_setbonding_balance_xmit_policy_port,
4205 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4210 /* *** SHOW NIC BONDING CONFIGURATION *** */
4211 struct cmd_show_bonding_config_result {
4212 cmdline_fixed_string_t show;
4213 cmdline_fixed_string_t bonding;
4214 cmdline_fixed_string_t config;
4218 static void cmd_show_bonding_config_parsed(void *parsed_result,
4219 __attribute__((unused)) struct cmdline *cl,
4220 __attribute__((unused)) void *data)
4222 struct cmd_show_bonding_config_result *res = parsed_result;
4224 uint8_t slaves[RTE_MAX_ETHPORTS];
4225 int num_slaves, num_active_slaves;
4228 portid_t port_id = res->port_id;
4230 /* Display the bonding mode.*/
4231 bonding_mode = rte_eth_bond_mode_get(port_id);
4232 if (bonding_mode < 0) {
4233 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4236 printf("\tBonding mode: %d\n", bonding_mode);
4238 if (bonding_mode == BONDING_MODE_BALANCE) {
4239 int balance_xmit_policy;
4241 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4242 if (balance_xmit_policy < 0) {
4243 printf("\tFailed to get balance xmit policy for port = %d\n",
4247 printf("\tBalance Xmit Policy: ");
4249 switch (balance_xmit_policy) {
4250 case BALANCE_XMIT_POLICY_LAYER2:
4251 printf("BALANCE_XMIT_POLICY_LAYER2");
4253 case BALANCE_XMIT_POLICY_LAYER23:
4254 printf("BALANCE_XMIT_POLICY_LAYER23");
4256 case BALANCE_XMIT_POLICY_LAYER34:
4257 printf("BALANCE_XMIT_POLICY_LAYER34");
4264 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4266 if (num_slaves < 0) {
4267 printf("\tFailed to get slave list for port = %d\n", port_id);
4270 if (num_slaves > 0) {
4271 printf("\tSlaves (%d): [", num_slaves);
4272 for (i = 0; i < num_slaves - 1; i++)
4273 printf("%d ", slaves[i]);
4275 printf("%d]\n", slaves[num_slaves - 1]);
4277 printf("\tSlaves: []\n");
4281 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4284 if (num_active_slaves < 0) {
4285 printf("\tFailed to get active slave list for port = %d\n", port_id);
4288 if (num_active_slaves > 0) {
4289 printf("\tActive Slaves (%d): [", num_active_slaves);
4290 for (i = 0; i < num_active_slaves - 1; i++)
4291 printf("%d ", slaves[i]);
4293 printf("%d]\n", slaves[num_active_slaves - 1]);
4296 printf("\tActive Slaves: []\n");
4300 primary_id = rte_eth_bond_primary_get(port_id);
4301 if (primary_id < 0) {
4302 printf("\tFailed to get primary slave for port = %d\n", port_id);
4305 printf("\tPrimary: [%d]\n", primary_id);
4309 cmdline_parse_token_string_t cmd_showbonding_config_show =
4310 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4312 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4313 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4314 bonding, "bonding");
4315 cmdline_parse_token_string_t cmd_showbonding_config_config =
4316 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4318 cmdline_parse_token_num_t cmd_showbonding_config_port =
4319 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4322 cmdline_parse_inst_t cmd_show_bonding_config = {
4323 .f = cmd_show_bonding_config_parsed,
4324 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4327 (void *)&cmd_showbonding_config_show,
4328 (void *)&cmd_showbonding_config_bonding,
4329 (void *)&cmd_showbonding_config_config,
4330 (void *)&cmd_showbonding_config_port,
4335 /* *** SET BONDING PRIMARY *** */
4336 struct cmd_set_bonding_primary_result {
4337 cmdline_fixed_string_t set;
4338 cmdline_fixed_string_t bonding;
4339 cmdline_fixed_string_t primary;
4344 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4345 __attribute__((unused)) struct cmdline *cl,
4346 __attribute__((unused)) void *data)
4348 struct cmd_set_bonding_primary_result *res = parsed_result;
4349 portid_t master_port_id = res->port_id;
4350 portid_t slave_port_id = res->slave_id;
4352 /* Set the primary slave for a bonded device. */
4353 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4354 printf("\t Failed to set primary slave for port = %d.\n",
4361 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4362 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4364 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4365 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4366 bonding, "bonding");
4367 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4368 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4369 primary, "primary");
4370 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4371 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4373 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4374 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4377 cmdline_parse_inst_t cmd_set_bonding_primary = {
4378 .f = cmd_set_bonding_primary_parsed,
4379 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4382 (void *)&cmd_setbonding_primary_set,
4383 (void *)&cmd_setbonding_primary_bonding,
4384 (void *)&cmd_setbonding_primary_primary,
4385 (void *)&cmd_setbonding_primary_slave,
4386 (void *)&cmd_setbonding_primary_port,
4391 /* *** ADD SLAVE *** */
4392 struct cmd_add_bonding_slave_result {
4393 cmdline_fixed_string_t add;
4394 cmdline_fixed_string_t bonding;
4395 cmdline_fixed_string_t slave;
4400 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4401 __attribute__((unused)) struct cmdline *cl,
4402 __attribute__((unused)) void *data)
4404 struct cmd_add_bonding_slave_result *res = parsed_result;
4405 portid_t master_port_id = res->port_id;
4406 portid_t slave_port_id = res->slave_id;
4408 /* Set the primary slave for a bonded device. */
4409 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4410 printf("\t Failed to add slave %d to master port = %d.\n",
4411 slave_port_id, master_port_id);
4415 set_port_slave_flag(slave_port_id);
4418 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4419 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4421 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4422 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4423 bonding, "bonding");
4424 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4425 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4427 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4428 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4430 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4431 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4434 cmdline_parse_inst_t cmd_add_bonding_slave = {
4435 .f = cmd_add_bonding_slave_parsed,
4436 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4439 (void *)&cmd_addbonding_slave_add,
4440 (void *)&cmd_addbonding_slave_bonding,
4441 (void *)&cmd_addbonding_slave_slave,
4442 (void *)&cmd_addbonding_slave_slaveid,
4443 (void *)&cmd_addbonding_slave_port,
4448 /* *** REMOVE SLAVE *** */
4449 struct cmd_remove_bonding_slave_result {
4450 cmdline_fixed_string_t remove;
4451 cmdline_fixed_string_t bonding;
4452 cmdline_fixed_string_t slave;
4457 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4458 __attribute__((unused)) struct cmdline *cl,
4459 __attribute__((unused)) void *data)
4461 struct cmd_remove_bonding_slave_result *res = parsed_result;
4462 portid_t master_port_id = res->port_id;
4463 portid_t slave_port_id = res->slave_id;
4465 /* Set the primary slave for a bonded device. */
4466 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4467 printf("\t Failed to remove slave %d from master port = %d.\n",
4468 slave_port_id, master_port_id);
4472 clear_port_slave_flag(slave_port_id);
4475 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4476 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4478 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4479 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4480 bonding, "bonding");
4481 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4482 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4484 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4485 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4487 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4488 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4491 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4492 .f = cmd_remove_bonding_slave_parsed,
4493 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4496 (void *)&cmd_removebonding_slave_remove,
4497 (void *)&cmd_removebonding_slave_bonding,
4498 (void *)&cmd_removebonding_slave_slave,
4499 (void *)&cmd_removebonding_slave_slaveid,
4500 (void *)&cmd_removebonding_slave_port,
4505 /* *** CREATE BONDED DEVICE *** */
4506 struct cmd_create_bonded_device_result {
4507 cmdline_fixed_string_t create;
4508 cmdline_fixed_string_t bonded;
4509 cmdline_fixed_string_t device;
4514 static int bond_dev_num = 0;
4516 static void cmd_create_bonded_device_parsed(void *parsed_result,
4517 __attribute__((unused)) struct cmdline *cl,
4518 __attribute__((unused)) void *data)
4520 struct cmd_create_bonded_device_result *res = parsed_result;
4521 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4524 if (test_done == 0) {
4525 printf("Please stop forwarding first\n");
4529 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4532 /* Create a new bonded device. */
4533 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4535 printf("\t Failed to create bonded device.\n");
4538 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4541 /* Update number of ports */
4542 nb_ports = rte_eth_dev_count();
4543 reconfig(port_id, res->socket);
4544 rte_eth_promiscuous_enable(port_id);
4545 ports[port_id].enabled = 1;
4550 cmdline_parse_token_string_t cmd_createbonded_device_create =
4551 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4553 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4554 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4556 cmdline_parse_token_string_t cmd_createbonded_device_device =
4557 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4559 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4560 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4562 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4563 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4566 cmdline_parse_inst_t cmd_create_bonded_device = {
4567 .f = cmd_create_bonded_device_parsed,
4568 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4571 (void *)&cmd_createbonded_device_create,
4572 (void *)&cmd_createbonded_device_bonded,
4573 (void *)&cmd_createbonded_device_device,
4574 (void *)&cmd_createbonded_device_mode,
4575 (void *)&cmd_createbonded_device_socket,
4580 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4581 struct cmd_set_bond_mac_addr_result {
4582 cmdline_fixed_string_t set;
4583 cmdline_fixed_string_t bonding;
4584 cmdline_fixed_string_t mac_addr;
4586 struct ether_addr address;
4589 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4590 __attribute__((unused)) struct cmdline *cl,
4591 __attribute__((unused)) void *data)
4593 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4596 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4599 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4601 /* check the return value and print it if is < 0 */
4603 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4606 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4607 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4608 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4609 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4611 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4612 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4614 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4615 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4616 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4617 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4619 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4620 .f = cmd_set_bond_mac_addr_parsed,
4622 .help_str = "set bonding mac_addr (port_id) (address): ",
4624 (void *)&cmd_set_bond_mac_addr_set,
4625 (void *)&cmd_set_bond_mac_addr_bonding,
4626 (void *)&cmd_set_bond_mac_addr_mac,
4627 (void *)&cmd_set_bond_mac_addr_portnum,
4628 (void *)&cmd_set_bond_mac_addr_addr,
4634 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4635 struct cmd_set_bond_mon_period_result {
4636 cmdline_fixed_string_t set;
4637 cmdline_fixed_string_t bonding;
4638 cmdline_fixed_string_t mon_period;
4643 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4644 __attribute__((unused)) struct cmdline *cl,
4645 __attribute__((unused)) void *data)
4647 struct cmd_set_bond_mon_period_result *res = parsed_result;
4650 if (res->port_num >= nb_ports) {
4651 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4655 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4657 /* check the return value and print it if is < 0 */
4659 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4662 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4663 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4665 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4666 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4667 bonding, "bonding");
4668 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4669 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4670 mon_period, "mon_period");
4671 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4672 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4674 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4675 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4678 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4679 .f = cmd_set_bond_mon_period_parsed,
4681 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4683 (void *)&cmd_set_bond_mon_period_set,
4684 (void *)&cmd_set_bond_mon_period_bonding,
4685 (void *)&cmd_set_bond_mon_period_mon_period,
4686 (void *)&cmd_set_bond_mon_period_portnum,
4687 (void *)&cmd_set_bond_mon_period_period_ms,
4692 #endif /* RTE_LIBRTE_PMD_BOND */
4694 /* *** SET FORWARDING MODE *** */
4695 struct cmd_set_fwd_mode_result {
4696 cmdline_fixed_string_t set;
4697 cmdline_fixed_string_t fwd;
4698 cmdline_fixed_string_t mode;
4701 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4702 __attribute__((unused)) struct cmdline *cl,
4703 __attribute__((unused)) void *data)
4705 struct cmd_set_fwd_mode_result *res = parsed_result;
4708 set_pkt_forwarding_mode(res->mode);
4711 cmdline_parse_token_string_t cmd_setfwd_set =
4712 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4713 cmdline_parse_token_string_t cmd_setfwd_fwd =
4714 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4715 cmdline_parse_token_string_t cmd_setfwd_mode =
4716 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4717 "" /* defined at init */);
4719 cmdline_parse_inst_t cmd_set_fwd_mode = {
4720 .f = cmd_set_fwd_mode_parsed,
4722 .help_str = NULL, /* defined at init */
4724 (void *)&cmd_setfwd_set,
4725 (void *)&cmd_setfwd_fwd,
4726 (void *)&cmd_setfwd_mode,
4731 static void cmd_set_fwd_mode_init(void)
4734 static char token[128];
4735 static char help[256];
4736 cmdline_parse_token_string_t *token_struct;
4738 modes = list_pkt_forwarding_modes();
4739 snprintf(help, sizeof help, "set fwd %s - "
4740 "set packet forwarding mode", modes);
4741 cmd_set_fwd_mode.help_str = help;
4743 /* string token separator is # */
4744 for (c = token; *modes != '\0'; modes++)
4749 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4750 token_struct->string_data.str = token;
4753 /* *** SET RETRY FORWARDING MODE *** */
4754 struct cmd_set_fwd_retry_mode_result {
4755 cmdline_fixed_string_t set;
4756 cmdline_fixed_string_t fwd;
4757 cmdline_fixed_string_t mode;
4758 cmdline_fixed_string_t retry;
4761 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4762 __attribute__((unused)) struct cmdline *cl,
4763 __attribute__((unused)) void *data)
4765 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4768 set_pkt_forwarding_mode(res->mode);
4771 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4772 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4774 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4775 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4777 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4778 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4780 "" /* defined at init */);
4781 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4782 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4785 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4786 .f = cmd_set_fwd_retry_mode_parsed,
4788 .help_str = NULL, /* defined at init */
4790 (void *)&cmd_setfwd_retry_set,
4791 (void *)&cmd_setfwd_retry_fwd,
4792 (void *)&cmd_setfwd_retry_mode,
4793 (void *)&cmd_setfwd_retry_retry,
4798 static void cmd_set_fwd_retry_mode_init(void)
4801 static char token[128];
4802 static char help[256];
4803 cmdline_parse_token_string_t *token_struct;
4805 modes = list_pkt_forwarding_retry_modes();
4806 snprintf(help, sizeof(help), "set fwd %s retry - "
4807 "set packet forwarding mode with retry", modes);
4808 cmd_set_fwd_retry_mode.help_str = help;
4810 /* string token separator is # */
4811 for (c = token; *modes != '\0'; modes++)
4816 token_struct = (cmdline_parse_token_string_t *)
4817 cmd_set_fwd_retry_mode.tokens[2];
4818 token_struct->string_data.str = token;
4821 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4822 struct cmd_set_burst_tx_retry_result {
4823 cmdline_fixed_string_t set;
4824 cmdline_fixed_string_t burst;
4825 cmdline_fixed_string_t tx;
4826 cmdline_fixed_string_t delay;
4828 cmdline_fixed_string_t retry;
4832 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4833 __attribute__((unused)) struct cmdline *cl,
4834 __attribute__((unused)) void *data)
4836 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4838 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4839 && !strcmp(res->tx, "tx")) {
4840 if (!strcmp(res->delay, "delay"))
4841 burst_tx_delay_time = res->time;
4842 if (!strcmp(res->retry, "retry"))
4843 burst_tx_retry_num = res->retry_num;
4848 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4849 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4850 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4851 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4853 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4854 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4855 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4856 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4857 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4858 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4859 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4861 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4862 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4864 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4865 .f = cmd_set_burst_tx_retry_parsed,
4866 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4868 (void *)&cmd_set_burst_tx_retry_set,
4869 (void *)&cmd_set_burst_tx_retry_burst,
4870 (void *)&cmd_set_burst_tx_retry_tx,
4871 (void *)&cmd_set_burst_tx_retry_delay,
4872 (void *)&cmd_set_burst_tx_retry_time,
4873 (void *)&cmd_set_burst_tx_retry_retry,
4874 (void *)&cmd_set_burst_tx_retry_retry_num,
4879 /* *** SET PROMISC MODE *** */
4880 struct cmd_set_promisc_mode_result {
4881 cmdline_fixed_string_t set;
4882 cmdline_fixed_string_t promisc;
4883 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4884 uint8_t port_num; /* valid if "allports" argument == 0 */
4885 cmdline_fixed_string_t mode;
4888 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4889 __attribute__((unused)) struct cmdline *cl,
4892 struct cmd_set_promisc_mode_result *res = parsed_result;
4896 if (!strcmp(res->mode, "on"))
4903 FOREACH_PORT(i, ports) {
4905 rte_eth_promiscuous_enable(i);
4907 rte_eth_promiscuous_disable(i);
4912 rte_eth_promiscuous_enable(res->port_num);
4914 rte_eth_promiscuous_disable(res->port_num);
4918 cmdline_parse_token_string_t cmd_setpromisc_set =
4919 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4920 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4921 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4923 cmdline_parse_token_string_t cmd_setpromisc_portall =
4924 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4926 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4927 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4929 cmdline_parse_token_string_t cmd_setpromisc_mode =
4930 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4933 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4934 .f = cmd_set_promisc_mode_parsed,
4936 .help_str = "set promisc all on|off: set promisc mode for all ports",
4938 (void *)&cmd_setpromisc_set,
4939 (void *)&cmd_setpromisc_promisc,
4940 (void *)&cmd_setpromisc_portall,
4941 (void *)&cmd_setpromisc_mode,
4946 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4947 .f = cmd_set_promisc_mode_parsed,
4949 .help_str = "set promisc X on|off: set promisc mode on port X",
4951 (void *)&cmd_setpromisc_set,
4952 (void *)&cmd_setpromisc_promisc,
4953 (void *)&cmd_setpromisc_portnum,
4954 (void *)&cmd_setpromisc_mode,
4959 /* *** SET ALLMULTI MODE *** */
4960 struct cmd_set_allmulti_mode_result {
4961 cmdline_fixed_string_t set;
4962 cmdline_fixed_string_t allmulti;
4963 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4964 uint8_t port_num; /* valid if "allports" argument == 0 */
4965 cmdline_fixed_string_t mode;
4968 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4969 __attribute__((unused)) struct cmdline *cl,
4972 struct cmd_set_allmulti_mode_result *res = parsed_result;
4976 if (!strcmp(res->mode, "on"))
4983 FOREACH_PORT(i, ports) {
4985 rte_eth_allmulticast_enable(i);
4987 rte_eth_allmulticast_disable(i);
4992 rte_eth_allmulticast_enable(res->port_num);
4994 rte_eth_allmulticast_disable(res->port_num);
4998 cmdline_parse_token_string_t cmd_setallmulti_set =
4999 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5000 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5001 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5003 cmdline_parse_token_string_t cmd_setallmulti_portall =
5004 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5006 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5007 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5009 cmdline_parse_token_string_t cmd_setallmulti_mode =
5010 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5013 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5014 .f = cmd_set_allmulti_mode_parsed,
5016 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
5018 (void *)&cmd_setallmulti_set,
5019 (void *)&cmd_setallmulti_allmulti,
5020 (void *)&cmd_setallmulti_portall,
5021 (void *)&cmd_setallmulti_mode,
5026 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5027 .f = cmd_set_allmulti_mode_parsed,
5029 .help_str = "set allmulti X on|off: set allmulti mode on port X",
5031 (void *)&cmd_setallmulti_set,
5032 (void *)&cmd_setallmulti_allmulti,
5033 (void *)&cmd_setallmulti_portnum,
5034 (void *)&cmd_setallmulti_mode,
5039 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5040 struct cmd_link_flow_ctrl_set_result {
5041 cmdline_fixed_string_t set;
5042 cmdline_fixed_string_t flow_ctrl;
5043 cmdline_fixed_string_t rx;
5044 cmdline_fixed_string_t rx_lfc_mode;
5045 cmdline_fixed_string_t tx;
5046 cmdline_fixed_string_t tx_lfc_mode;
5047 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5048 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5049 cmdline_fixed_string_t autoneg_str;
5050 cmdline_fixed_string_t autoneg;
5051 cmdline_fixed_string_t hw_str;
5052 uint32_t high_water;
5053 cmdline_fixed_string_t lw_str;
5055 cmdline_fixed_string_t pt_str;
5056 uint16_t pause_time;
5057 cmdline_fixed_string_t xon_str;
5062 cmdline_parse_token_string_t cmd_lfc_set_set =
5063 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5065 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5066 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5067 flow_ctrl, "flow_ctrl");
5068 cmdline_parse_token_string_t cmd_lfc_set_rx =
5069 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5071 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5072 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5073 rx_lfc_mode, "on#off");
5074 cmdline_parse_token_string_t cmd_lfc_set_tx =
5075 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5077 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5078 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5079 tx_lfc_mode, "on#off");
5080 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5081 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5082 hw_str, "high_water");
5083 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5084 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5085 high_water, UINT32);
5086 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5087 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5088 lw_str, "low_water");
5089 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5090 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5092 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5093 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5094 pt_str, "pause_time");
5095 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5096 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5097 pause_time, UINT16);
5098 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5099 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5100 xon_str, "send_xon");
5101 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5102 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5104 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5105 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5106 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5107 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5108 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5109 mac_ctrl_frame_fwd_mode, "on#off");
5110 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5111 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5112 autoneg_str, "autoneg");
5113 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5114 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5116 cmdline_parse_token_num_t cmd_lfc_set_portid =
5117 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5120 /* forward declaration */
5122 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5125 cmdline_parse_inst_t cmd_link_flow_control_set = {
5126 .f = cmd_link_flow_ctrl_set_parsed,
5128 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
5129 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
5130 autoneg on|off port_id",
5132 (void *)&cmd_lfc_set_set,
5133 (void *)&cmd_lfc_set_flow_ctrl,
5134 (void *)&cmd_lfc_set_rx,
5135 (void *)&cmd_lfc_set_rx_mode,
5136 (void *)&cmd_lfc_set_tx,
5137 (void *)&cmd_lfc_set_tx_mode,
5138 (void *)&cmd_lfc_set_high_water,
5139 (void *)&cmd_lfc_set_low_water,
5140 (void *)&cmd_lfc_set_pause_time,
5141 (void *)&cmd_lfc_set_send_xon,
5142 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5143 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5144 (void *)&cmd_lfc_set_autoneg_str,
5145 (void *)&cmd_lfc_set_autoneg,
5146 (void *)&cmd_lfc_set_portid,
5151 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5152 .f = cmd_link_flow_ctrl_set_parsed,
5153 .data = (void *)&cmd_link_flow_control_set_rx,
5154 .help_str = "Change rx flow control parameter: set flow_ctrl "
5155 "rx on|off port_id",
5157 (void *)&cmd_lfc_set_set,
5158 (void *)&cmd_lfc_set_flow_ctrl,
5159 (void *)&cmd_lfc_set_rx,
5160 (void *)&cmd_lfc_set_rx_mode,
5161 (void *)&cmd_lfc_set_portid,
5166 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5167 .f = cmd_link_flow_ctrl_set_parsed,
5168 .data = (void *)&cmd_link_flow_control_set_tx,
5169 .help_str = "Change tx flow control parameter: set flow_ctrl "
5170 "tx on|off port_id",
5172 (void *)&cmd_lfc_set_set,
5173 (void *)&cmd_lfc_set_flow_ctrl,
5174 (void *)&cmd_lfc_set_tx,
5175 (void *)&cmd_lfc_set_tx_mode,
5176 (void *)&cmd_lfc_set_portid,
5181 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5182 .f = cmd_link_flow_ctrl_set_parsed,
5183 .data = (void *)&cmd_link_flow_control_set_hw,
5184 .help_str = "Change high water flow control parameter: set flow_ctrl "
5185 "high_water value port_id",
5187 (void *)&cmd_lfc_set_set,
5188 (void *)&cmd_lfc_set_flow_ctrl,
5189 (void *)&cmd_lfc_set_high_water_str,
5190 (void *)&cmd_lfc_set_high_water,
5191 (void *)&cmd_lfc_set_portid,
5196 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5197 .f = cmd_link_flow_ctrl_set_parsed,
5198 .data = (void *)&cmd_link_flow_control_set_lw,
5199 .help_str = "Change low water flow control parameter: set flow_ctrl "
5200 "low_water value port_id",
5202 (void *)&cmd_lfc_set_set,
5203 (void *)&cmd_lfc_set_flow_ctrl,
5204 (void *)&cmd_lfc_set_low_water_str,
5205 (void *)&cmd_lfc_set_low_water,
5206 (void *)&cmd_lfc_set_portid,
5211 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5212 .f = cmd_link_flow_ctrl_set_parsed,
5213 .data = (void *)&cmd_link_flow_control_set_pt,
5214 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5215 "pause_time value port_id",
5217 (void *)&cmd_lfc_set_set,
5218 (void *)&cmd_lfc_set_flow_ctrl,
5219 (void *)&cmd_lfc_set_pause_time_str,
5220 (void *)&cmd_lfc_set_pause_time,
5221 (void *)&cmd_lfc_set_portid,
5226 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5227 .f = cmd_link_flow_ctrl_set_parsed,
5228 .data = (void *)&cmd_link_flow_control_set_xon,
5229 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5230 "send_xon value port_id",
5232 (void *)&cmd_lfc_set_set,
5233 (void *)&cmd_lfc_set_flow_ctrl,
5234 (void *)&cmd_lfc_set_send_xon_str,
5235 (void *)&cmd_lfc_set_send_xon,
5236 (void *)&cmd_lfc_set_portid,
5241 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5242 .f = cmd_link_flow_ctrl_set_parsed,
5243 .data = (void *)&cmd_link_flow_control_set_macfwd,
5244 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5245 "mac_ctrl_frame_fwd on|off port_id",
5247 (void *)&cmd_lfc_set_set,
5248 (void *)&cmd_lfc_set_flow_ctrl,
5249 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5250 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5251 (void *)&cmd_lfc_set_portid,
5256 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5257 .f = cmd_link_flow_ctrl_set_parsed,
5258 .data = (void *)&cmd_link_flow_control_set_autoneg,
5259 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5260 "autoneg on|off port_id",
5262 (void *)&cmd_lfc_set_set,
5263 (void *)&cmd_lfc_set_flow_ctrl,
5264 (void *)&cmd_lfc_set_autoneg_str,
5265 (void *)&cmd_lfc_set_autoneg,
5266 (void *)&cmd_lfc_set_portid,
5272 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5273 __attribute__((unused)) struct cmdline *cl,
5276 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5277 cmdline_parse_inst_t *cmd = data;
5278 struct rte_eth_fc_conf fc_conf;
5284 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5285 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5286 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5287 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5289 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5290 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5293 /* Partial command line, retrieve current configuration */
5295 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5297 printf("cannot get current flow ctrl parameters, return"
5298 "code = %d\n", ret);
5302 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5303 (fc_conf.mode == RTE_FC_FULL))
5305 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5306 (fc_conf.mode == RTE_FC_FULL))
5310 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5311 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5313 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5314 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5316 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5318 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5319 fc_conf.high_water = res->high_water;
5321 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5322 fc_conf.low_water = res->low_water;
5324 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5325 fc_conf.pause_time = res->pause_time;
5327 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5328 fc_conf.send_xon = res->send_xon;
5330 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5331 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5332 fc_conf.mac_ctrl_frame_fwd = 1;
5334 fc_conf.mac_ctrl_frame_fwd = 0;
5337 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5338 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5340 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5342 printf("bad flow contrl parameter, return code = %d \n", ret);
5345 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5346 struct cmd_priority_flow_ctrl_set_result {
5347 cmdline_fixed_string_t set;
5348 cmdline_fixed_string_t pfc_ctrl;
5349 cmdline_fixed_string_t rx;
5350 cmdline_fixed_string_t rx_pfc_mode;
5351 cmdline_fixed_string_t tx;
5352 cmdline_fixed_string_t tx_pfc_mode;
5353 uint32_t high_water;
5355 uint16_t pause_time;
5361 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5362 __attribute__((unused)) struct cmdline *cl,
5363 __attribute__((unused)) void *data)
5365 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5366 struct rte_eth_pfc_conf pfc_conf;
5367 int rx_fc_enable, tx_fc_enable;
5371 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5372 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5373 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5374 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5376 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5377 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5380 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5381 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5382 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5383 pfc_conf.fc.high_water = res->high_water;
5384 pfc_conf.fc.low_water = res->low_water;
5385 pfc_conf.fc.pause_time = res->pause_time;
5386 pfc_conf.priority = res->priority;
5388 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5390 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5393 cmdline_parse_token_string_t cmd_pfc_set_set =
5394 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5396 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5397 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5398 pfc_ctrl, "pfc_ctrl");
5399 cmdline_parse_token_string_t cmd_pfc_set_rx =
5400 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5402 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5403 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5404 rx_pfc_mode, "on#off");
5405 cmdline_parse_token_string_t cmd_pfc_set_tx =
5406 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5408 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5409 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5410 tx_pfc_mode, "on#off");
5411 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5412 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5413 high_water, UINT32);
5414 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5415 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5417 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5418 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5419 pause_time, UINT16);
5420 cmdline_parse_token_num_t cmd_pfc_set_priority =
5421 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5423 cmdline_parse_token_num_t cmd_pfc_set_portid =
5424 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5427 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5428 .f = cmd_priority_flow_ctrl_set_parsed,
5430 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5431 tx on|off high_water low_water pause_time priority port_id",
5433 (void *)&cmd_pfc_set_set,
5434 (void *)&cmd_pfc_set_flow_ctrl,
5435 (void *)&cmd_pfc_set_rx,
5436 (void *)&cmd_pfc_set_rx_mode,
5437 (void *)&cmd_pfc_set_tx,
5438 (void *)&cmd_pfc_set_tx_mode,
5439 (void *)&cmd_pfc_set_high_water,
5440 (void *)&cmd_pfc_set_low_water,
5441 (void *)&cmd_pfc_set_pause_time,
5442 (void *)&cmd_pfc_set_priority,
5443 (void *)&cmd_pfc_set_portid,
5448 /* *** RESET CONFIGURATION *** */
5449 struct cmd_reset_result {
5450 cmdline_fixed_string_t reset;
5451 cmdline_fixed_string_t def;
5454 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5456 __attribute__((unused)) void *data)
5458 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5459 set_def_fwd_config();
5462 cmdline_parse_token_string_t cmd_reset_set =
5463 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5464 cmdline_parse_token_string_t cmd_reset_def =
5465 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5468 cmdline_parse_inst_t cmd_reset = {
5469 .f = cmd_reset_parsed,
5471 .help_str = "set default: reset default forwarding configuration",
5473 (void *)&cmd_reset_set,
5474 (void *)&cmd_reset_def,
5479 /* *** START FORWARDING *** */
5480 struct cmd_start_result {
5481 cmdline_fixed_string_t start;
5484 cmdline_parse_token_string_t cmd_start_start =
5485 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5487 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5488 __attribute__((unused)) struct cmdline *cl,
5489 __attribute__((unused)) void *data)
5491 start_packet_forwarding(0);
5494 cmdline_parse_inst_t cmd_start = {
5495 .f = cmd_start_parsed,
5497 .help_str = "start packet forwarding",
5499 (void *)&cmd_start_start,
5504 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5505 struct cmd_start_tx_first_result {
5506 cmdline_fixed_string_t start;
5507 cmdline_fixed_string_t tx_first;
5511 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5512 __attribute__((unused)) struct cmdline *cl,
5513 __attribute__((unused)) void *data)
5515 start_packet_forwarding(1);
5518 cmdline_parse_token_string_t cmd_start_tx_first_start =
5519 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5521 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5522 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5523 tx_first, "tx_first");
5525 cmdline_parse_inst_t cmd_start_tx_first = {
5526 .f = cmd_start_tx_first_parsed,
5528 .help_str = "start packet forwarding, after sending 1 burst of packets",
5530 (void *)&cmd_start_tx_first_start,
5531 (void *)&cmd_start_tx_first_tx_first,
5536 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5537 struct cmd_start_tx_first_n_result {
5538 cmdline_fixed_string_t start;
5539 cmdline_fixed_string_t tx_first;
5544 cmd_start_tx_first_n_parsed(void *parsed_result,
5545 __attribute__((unused)) struct cmdline *cl,
5546 __attribute__((unused)) void *data)
5548 struct cmd_start_tx_first_n_result *res = parsed_result;
5550 start_packet_forwarding(res->tx_num);
5553 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5554 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5556 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5557 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5558 tx_first, "tx_first");
5559 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5560 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5563 cmdline_parse_inst_t cmd_start_tx_first_n = {
5564 .f = cmd_start_tx_first_n_parsed,
5566 .help_str = "start packet forwarding, after sending <num> "
5567 "bursts of packets",
5569 (void *)&cmd_start_tx_first_n_start,
5570 (void *)&cmd_start_tx_first_n_tx_first,
5571 (void *)&cmd_start_tx_first_n_tx_num,
5576 /* *** SET LINK UP *** */
5577 struct cmd_set_link_up_result {
5578 cmdline_fixed_string_t set;
5579 cmdline_fixed_string_t link_up;
5580 cmdline_fixed_string_t port;
5584 cmdline_parse_token_string_t cmd_set_link_up_set =
5585 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5586 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5587 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5589 cmdline_parse_token_string_t cmd_set_link_up_port =
5590 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5591 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5592 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5594 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5595 __attribute__((unused)) struct cmdline *cl,
5596 __attribute__((unused)) void *data)
5598 struct cmd_set_link_up_result *res = parsed_result;
5599 dev_set_link_up(res->port_id);
5602 cmdline_parse_inst_t cmd_set_link_up = {
5603 .f = cmd_set_link_up_parsed,
5605 .help_str = "set link-up port (port id)",
5607 (void *)&cmd_set_link_up_set,
5608 (void *)&cmd_set_link_up_link_up,
5609 (void *)&cmd_set_link_up_port,
5610 (void *)&cmd_set_link_up_port_id,
5615 /* *** SET LINK DOWN *** */
5616 struct cmd_set_link_down_result {
5617 cmdline_fixed_string_t set;
5618 cmdline_fixed_string_t link_down;
5619 cmdline_fixed_string_t port;
5623 cmdline_parse_token_string_t cmd_set_link_down_set =
5624 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5625 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5626 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5628 cmdline_parse_token_string_t cmd_set_link_down_port =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5630 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5631 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5633 static void cmd_set_link_down_parsed(
5634 __attribute__((unused)) void *parsed_result,
5635 __attribute__((unused)) struct cmdline *cl,
5636 __attribute__((unused)) void *data)
5638 struct cmd_set_link_down_result *res = parsed_result;
5639 dev_set_link_down(res->port_id);
5642 cmdline_parse_inst_t cmd_set_link_down = {
5643 .f = cmd_set_link_down_parsed,
5645 .help_str = "set link-down port (port id)",
5647 (void *)&cmd_set_link_down_set,
5648 (void *)&cmd_set_link_down_link_down,
5649 (void *)&cmd_set_link_down_port,
5650 (void *)&cmd_set_link_down_port_id,
5655 /* *** SHOW CFG *** */
5656 struct cmd_showcfg_result {
5657 cmdline_fixed_string_t show;
5658 cmdline_fixed_string_t cfg;
5659 cmdline_fixed_string_t what;
5662 static void cmd_showcfg_parsed(void *parsed_result,
5663 __attribute__((unused)) struct cmdline *cl,
5664 __attribute__((unused)) void *data)
5666 struct cmd_showcfg_result *res = parsed_result;
5667 if (!strcmp(res->what, "rxtx"))
5668 rxtx_config_display();
5669 else if (!strcmp(res->what, "cores"))
5670 fwd_lcores_config_display();
5671 else if (!strcmp(res->what, "fwd"))
5672 pkt_fwd_config_display(&cur_fwd_config);
5673 else if (!strcmp(res->what, "txpkts"))
5674 show_tx_pkt_segments();
5677 cmdline_parse_token_string_t cmd_showcfg_show =
5678 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5679 cmdline_parse_token_string_t cmd_showcfg_port =
5680 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5681 cmdline_parse_token_string_t cmd_showcfg_what =
5682 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5683 "rxtx#cores#fwd#txpkts");
5685 cmdline_parse_inst_t cmd_showcfg = {
5686 .f = cmd_showcfg_parsed,
5688 .help_str = "show config rxtx|cores|fwd|txpkts",
5690 (void *)&cmd_showcfg_show,
5691 (void *)&cmd_showcfg_port,
5692 (void *)&cmd_showcfg_what,
5697 /* *** SHOW ALL PORT INFO *** */
5698 struct cmd_showportall_result {
5699 cmdline_fixed_string_t show;
5700 cmdline_fixed_string_t port;
5701 cmdline_fixed_string_t what;
5702 cmdline_fixed_string_t all;
5705 static void cmd_showportall_parsed(void *parsed_result,
5706 __attribute__((unused)) struct cmdline *cl,
5707 __attribute__((unused)) void *data)
5711 struct cmd_showportall_result *res = parsed_result;
5712 if (!strcmp(res->show, "clear")) {
5713 if (!strcmp(res->what, "stats"))
5714 FOREACH_PORT(i, ports)
5716 else if (!strcmp(res->what, "xstats"))
5717 FOREACH_PORT(i, ports)
5718 nic_xstats_clear(i);
5719 } else if (!strcmp(res->what, "info"))
5720 FOREACH_PORT(i, ports)
5721 port_infos_display(i);
5722 else if (!strcmp(res->what, "stats"))
5723 FOREACH_PORT(i, ports)
5724 nic_stats_display(i);
5725 else if (!strcmp(res->what, "xstats"))
5726 FOREACH_PORT(i, ports)
5727 nic_xstats_display(i);
5728 else if (!strcmp(res->what, "fdir"))
5729 FOREACH_PORT(i, ports)
5731 else if (!strcmp(res->what, "stat_qmap"))
5732 FOREACH_PORT(i, ports)
5733 nic_stats_mapping_display(i);
5734 else if (!strcmp(res->what, "dcb_tc"))
5735 FOREACH_PORT(i, ports)
5736 port_dcb_info_display(i);
5739 cmdline_parse_token_string_t cmd_showportall_show =
5740 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5742 cmdline_parse_token_string_t cmd_showportall_port =
5743 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5744 cmdline_parse_token_string_t cmd_showportall_what =
5745 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5746 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5747 cmdline_parse_token_string_t cmd_showportall_all =
5748 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5749 cmdline_parse_inst_t cmd_showportall = {
5750 .f = cmd_showportall_parsed,
5752 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5754 (void *)&cmd_showportall_show,
5755 (void *)&cmd_showportall_port,
5756 (void *)&cmd_showportall_what,
5757 (void *)&cmd_showportall_all,
5762 /* *** SHOW PORT INFO *** */
5763 struct cmd_showport_result {
5764 cmdline_fixed_string_t show;
5765 cmdline_fixed_string_t port;
5766 cmdline_fixed_string_t what;
5770 static void cmd_showport_parsed(void *parsed_result,
5771 __attribute__((unused)) struct cmdline *cl,
5772 __attribute__((unused)) void *data)
5774 struct cmd_showport_result *res = parsed_result;
5775 if (!strcmp(res->show, "clear")) {
5776 if (!strcmp(res->what, "stats"))
5777 nic_stats_clear(res->portnum);
5778 else if (!strcmp(res->what, "xstats"))
5779 nic_xstats_clear(res->portnum);
5780 } else if (!strcmp(res->what, "info"))
5781 port_infos_display(res->portnum);
5782 else if (!strcmp(res->what, "stats"))
5783 nic_stats_display(res->portnum);
5784 else if (!strcmp(res->what, "xstats"))
5785 nic_xstats_display(res->portnum);
5786 else if (!strcmp(res->what, "fdir"))
5787 fdir_get_infos(res->portnum);
5788 else if (!strcmp(res->what, "stat_qmap"))
5789 nic_stats_mapping_display(res->portnum);
5790 else if (!strcmp(res->what, "dcb_tc"))
5791 port_dcb_info_display(res->portnum);
5794 cmdline_parse_token_string_t cmd_showport_show =
5795 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5797 cmdline_parse_token_string_t cmd_showport_port =
5798 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5799 cmdline_parse_token_string_t cmd_showport_what =
5800 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5801 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5802 cmdline_parse_token_num_t cmd_showport_portnum =
5803 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5805 cmdline_parse_inst_t cmd_showport = {
5806 .f = cmd_showport_parsed,
5808 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5810 (void *)&cmd_showport_show,
5811 (void *)&cmd_showport_port,
5812 (void *)&cmd_showport_what,
5813 (void *)&cmd_showport_portnum,
5818 /* *** SHOW QUEUE INFO *** */
5819 struct cmd_showqueue_result {
5820 cmdline_fixed_string_t show;
5821 cmdline_fixed_string_t type;
5822 cmdline_fixed_string_t what;
5828 cmd_showqueue_parsed(void *parsed_result,
5829 __attribute__((unused)) struct cmdline *cl,
5830 __attribute__((unused)) void *data)
5832 struct cmd_showqueue_result *res = parsed_result;
5834 if (!strcmp(res->type, "rxq"))
5835 rx_queue_infos_display(res->portnum, res->queuenum);
5836 else if (!strcmp(res->type, "txq"))
5837 tx_queue_infos_display(res->portnum, res->queuenum);
5840 cmdline_parse_token_string_t cmd_showqueue_show =
5841 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5842 cmdline_parse_token_string_t cmd_showqueue_type =
5843 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5844 cmdline_parse_token_string_t cmd_showqueue_what =
5845 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5846 cmdline_parse_token_num_t cmd_showqueue_portnum =
5847 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5848 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5849 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5851 cmdline_parse_inst_t cmd_showqueue = {
5852 .f = cmd_showqueue_parsed,
5854 .help_str = "show rxq|txq info <port number> <queue_number>",
5856 (void *)&cmd_showqueue_show,
5857 (void *)&cmd_showqueue_type,
5858 (void *)&cmd_showqueue_what,
5859 (void *)&cmd_showqueue_portnum,
5860 (void *)&cmd_showqueue_queuenum,
5865 /* *** READ PORT REGISTER *** */
5866 struct cmd_read_reg_result {
5867 cmdline_fixed_string_t read;
5868 cmdline_fixed_string_t reg;
5874 cmd_read_reg_parsed(void *parsed_result,
5875 __attribute__((unused)) struct cmdline *cl,
5876 __attribute__((unused)) void *data)
5878 struct cmd_read_reg_result *res = parsed_result;
5879 port_reg_display(res->port_id, res->reg_off);
5882 cmdline_parse_token_string_t cmd_read_reg_read =
5883 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5884 cmdline_parse_token_string_t cmd_read_reg_reg =
5885 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5886 cmdline_parse_token_num_t cmd_read_reg_port_id =
5887 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5888 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5889 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5891 cmdline_parse_inst_t cmd_read_reg = {
5892 .f = cmd_read_reg_parsed,
5894 .help_str = "read reg port_id reg_off",
5896 (void *)&cmd_read_reg_read,
5897 (void *)&cmd_read_reg_reg,
5898 (void *)&cmd_read_reg_port_id,
5899 (void *)&cmd_read_reg_reg_off,
5904 /* *** READ PORT REGISTER BIT FIELD *** */
5905 struct cmd_read_reg_bit_field_result {
5906 cmdline_fixed_string_t read;
5907 cmdline_fixed_string_t regfield;
5915 cmd_read_reg_bit_field_parsed(void *parsed_result,
5916 __attribute__((unused)) struct cmdline *cl,
5917 __attribute__((unused)) void *data)
5919 struct cmd_read_reg_bit_field_result *res = parsed_result;
5920 port_reg_bit_field_display(res->port_id, res->reg_off,
5921 res->bit1_pos, res->bit2_pos);
5924 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5925 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5927 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5928 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5929 regfield, "regfield");
5930 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5931 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5933 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5934 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5936 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5937 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5939 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5940 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5943 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5944 .f = cmd_read_reg_bit_field_parsed,
5946 .help_str = "read regfield port_id reg_off bit_x bit_y "
5947 "(read register bit field between bit_x and bit_y included)",
5949 (void *)&cmd_read_reg_bit_field_read,
5950 (void *)&cmd_read_reg_bit_field_regfield,
5951 (void *)&cmd_read_reg_bit_field_port_id,
5952 (void *)&cmd_read_reg_bit_field_reg_off,
5953 (void *)&cmd_read_reg_bit_field_bit1_pos,
5954 (void *)&cmd_read_reg_bit_field_bit2_pos,
5959 /* *** READ PORT REGISTER BIT *** */
5960 struct cmd_read_reg_bit_result {
5961 cmdline_fixed_string_t read;
5962 cmdline_fixed_string_t regbit;
5969 cmd_read_reg_bit_parsed(void *parsed_result,
5970 __attribute__((unused)) struct cmdline *cl,
5971 __attribute__((unused)) void *data)
5973 struct cmd_read_reg_bit_result *res = parsed_result;
5974 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5977 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5978 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5979 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5980 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5982 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5983 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5984 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5985 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5986 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5987 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5989 cmdline_parse_inst_t cmd_read_reg_bit = {
5990 .f = cmd_read_reg_bit_parsed,
5992 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5994 (void *)&cmd_read_reg_bit_read,
5995 (void *)&cmd_read_reg_bit_regbit,
5996 (void *)&cmd_read_reg_bit_port_id,
5997 (void *)&cmd_read_reg_bit_reg_off,
5998 (void *)&cmd_read_reg_bit_bit_pos,
6003 /* *** WRITE PORT REGISTER *** */
6004 struct cmd_write_reg_result {
6005 cmdline_fixed_string_t write;
6006 cmdline_fixed_string_t reg;
6013 cmd_write_reg_parsed(void *parsed_result,
6014 __attribute__((unused)) struct cmdline *cl,
6015 __attribute__((unused)) void *data)
6017 struct cmd_write_reg_result *res = parsed_result;
6018 port_reg_set(res->port_id, res->reg_off, res->value);
6021 cmdline_parse_token_string_t cmd_write_reg_write =
6022 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6023 cmdline_parse_token_string_t cmd_write_reg_reg =
6024 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6025 cmdline_parse_token_num_t cmd_write_reg_port_id =
6026 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6027 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6028 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6029 cmdline_parse_token_num_t cmd_write_reg_value =
6030 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6032 cmdline_parse_inst_t cmd_write_reg = {
6033 .f = cmd_write_reg_parsed,
6035 .help_str = "write reg port_id reg_off reg_value",
6037 (void *)&cmd_write_reg_write,
6038 (void *)&cmd_write_reg_reg,
6039 (void *)&cmd_write_reg_port_id,
6040 (void *)&cmd_write_reg_reg_off,
6041 (void *)&cmd_write_reg_value,
6046 /* *** WRITE PORT REGISTER BIT FIELD *** */
6047 struct cmd_write_reg_bit_field_result {
6048 cmdline_fixed_string_t write;
6049 cmdline_fixed_string_t regfield;
6058 cmd_write_reg_bit_field_parsed(void *parsed_result,
6059 __attribute__((unused)) struct cmdline *cl,
6060 __attribute__((unused)) void *data)
6062 struct cmd_write_reg_bit_field_result *res = parsed_result;
6063 port_reg_bit_field_set(res->port_id, res->reg_off,
6064 res->bit1_pos, res->bit2_pos, res->value);
6067 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6068 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6070 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6071 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6072 regfield, "regfield");
6073 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6074 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6076 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6077 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6079 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6080 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6082 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6083 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6085 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6086 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6089 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6090 .f = cmd_write_reg_bit_field_parsed,
6092 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
6093 "(set register bit field between bit_x and bit_y included)",
6095 (void *)&cmd_write_reg_bit_field_write,
6096 (void *)&cmd_write_reg_bit_field_regfield,
6097 (void *)&cmd_write_reg_bit_field_port_id,
6098 (void *)&cmd_write_reg_bit_field_reg_off,
6099 (void *)&cmd_write_reg_bit_field_bit1_pos,
6100 (void *)&cmd_write_reg_bit_field_bit2_pos,
6101 (void *)&cmd_write_reg_bit_field_value,
6106 /* *** WRITE PORT REGISTER BIT *** */
6107 struct cmd_write_reg_bit_result {
6108 cmdline_fixed_string_t write;
6109 cmdline_fixed_string_t regbit;
6117 cmd_write_reg_bit_parsed(void *parsed_result,
6118 __attribute__((unused)) struct cmdline *cl,
6119 __attribute__((unused)) void *data)
6121 struct cmd_write_reg_bit_result *res = parsed_result;
6122 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6125 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6126 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6128 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6129 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6131 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6132 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6133 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6134 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6135 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6136 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6137 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6138 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6140 cmdline_parse_inst_t cmd_write_reg_bit = {
6141 .f = cmd_write_reg_bit_parsed,
6143 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
6145 (void *)&cmd_write_reg_bit_write,
6146 (void *)&cmd_write_reg_bit_regbit,
6147 (void *)&cmd_write_reg_bit_port_id,
6148 (void *)&cmd_write_reg_bit_reg_off,
6149 (void *)&cmd_write_reg_bit_bit_pos,
6150 (void *)&cmd_write_reg_bit_value,
6155 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6156 struct cmd_read_rxd_txd_result {
6157 cmdline_fixed_string_t read;
6158 cmdline_fixed_string_t rxd_txd;
6165 cmd_read_rxd_txd_parsed(void *parsed_result,
6166 __attribute__((unused)) struct cmdline *cl,
6167 __attribute__((unused)) void *data)
6169 struct cmd_read_rxd_txd_result *res = parsed_result;
6171 if (!strcmp(res->rxd_txd, "rxd"))
6172 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6173 else if (!strcmp(res->rxd_txd, "txd"))
6174 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6177 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6178 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6179 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6180 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6182 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6183 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6184 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6185 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6186 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6187 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6189 cmdline_parse_inst_t cmd_read_rxd_txd = {
6190 .f = cmd_read_rxd_txd_parsed,
6192 .help_str = "read rxd|txd port_id queue_id rxd_id",
6194 (void *)&cmd_read_rxd_txd_read,
6195 (void *)&cmd_read_rxd_txd_rxd_txd,
6196 (void *)&cmd_read_rxd_txd_port_id,
6197 (void *)&cmd_read_rxd_txd_queue_id,
6198 (void *)&cmd_read_rxd_txd_desc_id,
6204 struct cmd_quit_result {
6205 cmdline_fixed_string_t quit;
6208 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6210 __attribute__((unused)) void *data)
6216 cmdline_parse_token_string_t cmd_quit_quit =
6217 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6219 cmdline_parse_inst_t cmd_quit = {
6220 .f = cmd_quit_parsed,
6222 .help_str = "exit application",
6224 (void *)&cmd_quit_quit,
6229 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6230 struct cmd_mac_addr_result {
6231 cmdline_fixed_string_t mac_addr_cmd;
6232 cmdline_fixed_string_t what;
6234 struct ether_addr address;
6237 static void cmd_mac_addr_parsed(void *parsed_result,
6238 __attribute__((unused)) struct cmdline *cl,
6239 __attribute__((unused)) void *data)
6241 struct cmd_mac_addr_result *res = parsed_result;
6244 if (strcmp(res->what, "add") == 0)
6245 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6247 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6249 /* check the return value and print it if is < 0 */
6251 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6255 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6256 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6258 cmdline_parse_token_string_t cmd_mac_addr_what =
6259 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6261 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6262 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6263 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6264 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6266 cmdline_parse_inst_t cmd_mac_addr = {
6267 .f = cmd_mac_addr_parsed,
6269 .help_str = "mac_addr add|remove X <address>: "
6270 "add/remove MAC address on port X",
6272 (void *)&cmd_mac_addr_cmd,
6273 (void *)&cmd_mac_addr_what,
6274 (void *)&cmd_mac_addr_portnum,
6275 (void *)&cmd_mac_addr_addr,
6281 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6282 struct cmd_set_qmap_result {
6283 cmdline_fixed_string_t set;
6284 cmdline_fixed_string_t qmap;
6285 cmdline_fixed_string_t what;
6292 cmd_set_qmap_parsed(void *parsed_result,
6293 __attribute__((unused)) struct cmdline *cl,
6294 __attribute__((unused)) void *data)
6296 struct cmd_set_qmap_result *res = parsed_result;
6297 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6299 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6302 cmdline_parse_token_string_t cmd_setqmap_set =
6303 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6305 cmdline_parse_token_string_t cmd_setqmap_qmap =
6306 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6308 cmdline_parse_token_string_t cmd_setqmap_what =
6309 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6311 cmdline_parse_token_num_t cmd_setqmap_portid =
6312 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6314 cmdline_parse_token_num_t cmd_setqmap_queueid =
6315 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6317 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6318 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6321 cmdline_parse_inst_t cmd_set_qmap = {
6322 .f = cmd_set_qmap_parsed,
6324 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6326 (void *)&cmd_setqmap_set,
6327 (void *)&cmd_setqmap_qmap,
6328 (void *)&cmd_setqmap_what,
6329 (void *)&cmd_setqmap_portid,
6330 (void *)&cmd_setqmap_queueid,
6331 (void *)&cmd_setqmap_mapvalue,
6336 /* *** CONFIGURE UNICAST HASH TABLE *** */
6337 struct cmd_set_uc_hash_table {
6338 cmdline_fixed_string_t set;
6339 cmdline_fixed_string_t port;
6341 cmdline_fixed_string_t what;
6342 struct ether_addr address;
6343 cmdline_fixed_string_t mode;
6347 cmd_set_uc_hash_parsed(void *parsed_result,
6348 __attribute__((unused)) struct cmdline *cl,
6349 __attribute__((unused)) void *data)
6352 struct cmd_set_uc_hash_table *res = parsed_result;
6354 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6356 if (strcmp(res->what, "uta") == 0)
6357 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6358 &res->address,(uint8_t)is_on);
6360 printf("bad unicast hash table parameter, return code = %d \n", ret);
6364 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6365 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6367 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6368 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6370 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6371 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6373 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6374 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6376 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6377 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6379 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6380 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6383 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6384 .f = cmd_set_uc_hash_parsed,
6386 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6388 (void *)&cmd_set_uc_hash_set,
6389 (void *)&cmd_set_uc_hash_port,
6390 (void *)&cmd_set_uc_hash_portid,
6391 (void *)&cmd_set_uc_hash_what,
6392 (void *)&cmd_set_uc_hash_mac,
6393 (void *)&cmd_set_uc_hash_mode,
6398 struct cmd_set_uc_all_hash_table {
6399 cmdline_fixed_string_t set;
6400 cmdline_fixed_string_t port;
6402 cmdline_fixed_string_t what;
6403 cmdline_fixed_string_t value;
6404 cmdline_fixed_string_t mode;
6408 cmd_set_uc_all_hash_parsed(void *parsed_result,
6409 __attribute__((unused)) struct cmdline *cl,
6410 __attribute__((unused)) void *data)
6413 struct cmd_set_uc_all_hash_table *res = parsed_result;
6415 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6417 if ((strcmp(res->what, "uta") == 0) &&
6418 (strcmp(res->value, "all") == 0))
6419 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6421 printf("bad unicast hash table parameter,"
6422 "return code = %d \n", ret);
6425 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6426 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6428 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6429 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6431 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6432 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6434 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6435 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6437 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6438 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6440 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6441 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6444 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6445 .f = cmd_set_uc_all_hash_parsed,
6447 .help_str = "set port X uta all on|off (X = port number)",
6449 (void *)&cmd_set_uc_all_hash_set,
6450 (void *)&cmd_set_uc_all_hash_port,
6451 (void *)&cmd_set_uc_all_hash_portid,
6452 (void *)&cmd_set_uc_all_hash_what,
6453 (void *)&cmd_set_uc_all_hash_value,
6454 (void *)&cmd_set_uc_all_hash_mode,
6459 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6460 struct cmd_set_vf_macvlan_filter {
6461 cmdline_fixed_string_t set;
6462 cmdline_fixed_string_t port;
6464 cmdline_fixed_string_t vf;
6466 struct ether_addr address;
6467 cmdline_fixed_string_t filter_type;
6468 cmdline_fixed_string_t mode;
6472 cmd_set_vf_macvlan_parsed(void *parsed_result,
6473 __attribute__((unused)) struct cmdline *cl,
6474 __attribute__((unused)) void *data)
6477 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6478 struct rte_eth_mac_filter filter;
6480 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6482 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6484 /* set VF MAC filter */
6488 filter.dst_id = res->vf_id;
6490 if (!strcmp(res->filter_type, "exact-mac"))
6491 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6492 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6493 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6494 else if (!strcmp(res->filter_type, "hashmac"))
6495 filter.filter_type = RTE_MAC_HASH_MATCH;
6496 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6497 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6499 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6502 ret = rte_eth_dev_filter_ctrl(res->port_id,
6503 RTE_ETH_FILTER_MACVLAN,
6507 ret = rte_eth_dev_filter_ctrl(res->port_id,
6508 RTE_ETH_FILTER_MACVLAN,
6509 RTE_ETH_FILTER_DELETE,
6513 printf("bad set MAC hash parameter, return code = %d\n", ret);
6517 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6518 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6520 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6521 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6523 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6524 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6526 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6527 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6529 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6530 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6532 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6533 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6535 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6536 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6537 filter_type, "exact-mac#exact-mac-vlan"
6538 "#hashmac#hashmac-vlan");
6539 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6543 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6544 .f = cmd_set_vf_macvlan_parsed,
6546 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6547 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6549 "exact match rule:exact match of MAC or MAC and VLAN; "
6550 "hash match rule: hash match of MAC and exact match "
6553 (void *)&cmd_set_vf_macvlan_set,
6554 (void *)&cmd_set_vf_macvlan_port,
6555 (void *)&cmd_set_vf_macvlan_portid,
6556 (void *)&cmd_set_vf_macvlan_vf,
6557 (void *)&cmd_set_vf_macvlan_vf_id,
6558 (void *)&cmd_set_vf_macvlan_mac,
6559 (void *)&cmd_set_vf_macvlan_filter_type,
6560 (void *)&cmd_set_vf_macvlan_mode,
6565 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6566 struct cmd_set_vf_traffic {
6567 cmdline_fixed_string_t set;
6568 cmdline_fixed_string_t port;
6570 cmdline_fixed_string_t vf;
6572 cmdline_fixed_string_t what;
6573 cmdline_fixed_string_t mode;
6577 cmd_set_vf_traffic_parsed(void *parsed_result,
6578 __attribute__((unused)) struct cmdline *cl,
6579 __attribute__((unused)) void *data)
6581 struct cmd_set_vf_traffic *res = parsed_result;
6582 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6583 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6585 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6588 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6589 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6591 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6592 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6594 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6595 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6597 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6598 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6600 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6601 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6603 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6604 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6606 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6607 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6610 cmdline_parse_inst_t cmd_set_vf_traffic = {
6611 .f = cmd_set_vf_traffic_parsed,
6613 .help_str = "set port X vf Y rx|tx on|off"
6614 "(X = port number,Y = vf id)",
6616 (void *)&cmd_setvf_traffic_set,
6617 (void *)&cmd_setvf_traffic_port,
6618 (void *)&cmd_setvf_traffic_portid,
6619 (void *)&cmd_setvf_traffic_vf,
6620 (void *)&cmd_setvf_traffic_vfid,
6621 (void *)&cmd_setvf_traffic_what,
6622 (void *)&cmd_setvf_traffic_mode,
6627 /* *** CONFIGURE VF RECEIVE MODE *** */
6628 struct cmd_set_vf_rxmode {
6629 cmdline_fixed_string_t set;
6630 cmdline_fixed_string_t port;
6632 cmdline_fixed_string_t vf;
6634 cmdline_fixed_string_t what;
6635 cmdline_fixed_string_t mode;
6636 cmdline_fixed_string_t on;
6640 cmd_set_vf_rxmode_parsed(void *parsed_result,
6641 __attribute__((unused)) struct cmdline *cl,
6642 __attribute__((unused)) void *data)
6645 uint16_t rx_mode = 0;
6646 struct cmd_set_vf_rxmode *res = parsed_result;
6648 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6649 if (!strcmp(res->what,"rxmode")) {
6650 if (!strcmp(res->mode, "AUPE"))
6651 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6652 else if (!strcmp(res->mode, "ROPE"))
6653 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6654 else if (!strcmp(res->mode, "BAM"))
6655 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6656 else if (!strncmp(res->mode, "MPE",3))
6657 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6660 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6662 printf("bad VF receive mode parameter, return code = %d \n",
6666 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6669 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6670 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6672 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6673 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6675 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6676 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6678 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6679 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6681 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6682 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6684 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6685 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6686 mode, "AUPE#ROPE#BAM#MPE");
6687 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6688 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6691 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6692 .f = cmd_set_vf_rxmode_parsed,
6694 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6696 (void *)&cmd_set_vf_rxmode_set,
6697 (void *)&cmd_set_vf_rxmode_port,
6698 (void *)&cmd_set_vf_rxmode_portid,
6699 (void *)&cmd_set_vf_rxmode_vf,
6700 (void *)&cmd_set_vf_rxmode_vfid,
6701 (void *)&cmd_set_vf_rxmode_what,
6702 (void *)&cmd_set_vf_rxmode_mode,
6703 (void *)&cmd_set_vf_rxmode_on,
6708 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6709 struct cmd_vf_mac_addr_result {
6710 cmdline_fixed_string_t mac_addr_cmd;
6711 cmdline_fixed_string_t what;
6712 cmdline_fixed_string_t port;
6714 cmdline_fixed_string_t vf;
6716 struct ether_addr address;
6719 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6720 __attribute__((unused)) struct cmdline *cl,
6721 __attribute__((unused)) void *data)
6723 struct cmd_vf_mac_addr_result *res = parsed_result;
6726 if (strcmp(res->what, "add") == 0)
6727 ret = rte_eth_dev_mac_addr_add(res->port_num,
6728 &res->address, res->vf_num);
6730 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6734 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6735 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6736 mac_addr_cmd,"mac_addr");
6737 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6738 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6740 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6741 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6743 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6744 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6746 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6747 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6749 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6750 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6752 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6753 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6756 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6757 .f = cmd_vf_mac_addr_parsed,
6759 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6760 "Y = VF number)add MAC address filtering for a VF on port X",
6762 (void *)&cmd_vf_mac_addr_cmd,
6763 (void *)&cmd_vf_mac_addr_what,
6764 (void *)&cmd_vf_mac_addr_port,
6765 (void *)&cmd_vf_mac_addr_portnum,
6766 (void *)&cmd_vf_mac_addr_vf,
6767 (void *)&cmd_vf_mac_addr_vfnum,
6768 (void *)&cmd_vf_mac_addr_addr,
6773 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6774 struct cmd_vf_rx_vlan_filter {
6775 cmdline_fixed_string_t rx_vlan;
6776 cmdline_fixed_string_t what;
6778 cmdline_fixed_string_t port;
6780 cmdline_fixed_string_t vf;
6785 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6786 __attribute__((unused)) struct cmdline *cl,
6787 __attribute__((unused)) void *data)
6789 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6791 if (!strcmp(res->what, "add"))
6792 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6794 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6797 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6798 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6799 rx_vlan, "rx_vlan");
6800 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6801 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6803 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6804 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6806 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6807 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6809 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6810 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6812 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6813 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6815 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6816 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6819 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6820 .f = cmd_vf_rx_vlan_filter_parsed,
6822 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6823 "Y = port number,Z = hexadecimal VF mask)",
6825 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6826 (void *)&cmd_vf_rx_vlan_filter_what,
6827 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6828 (void *)&cmd_vf_rx_vlan_filter_port,
6829 (void *)&cmd_vf_rx_vlan_filter_portid,
6830 (void *)&cmd_vf_rx_vlan_filter_vf,
6831 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6836 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6837 struct cmd_queue_rate_limit_result {
6838 cmdline_fixed_string_t set;
6839 cmdline_fixed_string_t port;
6841 cmdline_fixed_string_t queue;
6843 cmdline_fixed_string_t rate;
6847 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6848 __attribute__((unused)) struct cmdline *cl,
6849 __attribute__((unused)) void *data)
6851 struct cmd_queue_rate_limit_result *res = parsed_result;
6854 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6855 && (strcmp(res->queue, "queue") == 0)
6856 && (strcmp(res->rate, "rate") == 0))
6857 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6860 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6864 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6865 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6867 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6868 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6870 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6871 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6873 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6874 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6876 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6877 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6879 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6880 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6882 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6883 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6886 cmdline_parse_inst_t cmd_queue_rate_limit = {
6887 .f = cmd_queue_rate_limit_parsed,
6889 .help_str = "set port X queue Y rate Z:(X = port number,"
6890 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6892 (void *)&cmd_queue_rate_limit_set,
6893 (void *)&cmd_queue_rate_limit_port,
6894 (void *)&cmd_queue_rate_limit_portnum,
6895 (void *)&cmd_queue_rate_limit_queue,
6896 (void *)&cmd_queue_rate_limit_queuenum,
6897 (void *)&cmd_queue_rate_limit_rate,
6898 (void *)&cmd_queue_rate_limit_ratenum,
6903 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6904 struct cmd_vf_rate_limit_result {
6905 cmdline_fixed_string_t set;
6906 cmdline_fixed_string_t port;
6908 cmdline_fixed_string_t vf;
6910 cmdline_fixed_string_t rate;
6912 cmdline_fixed_string_t q_msk;
6916 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6917 __attribute__((unused)) struct cmdline *cl,
6918 __attribute__((unused)) void *data)
6920 struct cmd_vf_rate_limit_result *res = parsed_result;
6923 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6924 && (strcmp(res->vf, "vf") == 0)
6925 && (strcmp(res->rate, "rate") == 0)
6926 && (strcmp(res->q_msk, "queue_mask") == 0))
6927 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6928 res->rate_num, res->q_msk_val);
6930 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6934 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6935 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6937 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6938 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6940 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6941 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6943 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6944 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6946 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6947 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6949 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6950 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6952 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6953 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6955 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6956 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6957 q_msk, "queue_mask");
6958 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6959 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6962 cmdline_parse_inst_t cmd_vf_rate_limit = {
6963 .f = cmd_vf_rate_limit_parsed,
6965 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6966 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6967 "for queues of VF on port X",
6969 (void *)&cmd_vf_rate_limit_set,
6970 (void *)&cmd_vf_rate_limit_port,
6971 (void *)&cmd_vf_rate_limit_portnum,
6972 (void *)&cmd_vf_rate_limit_vf,
6973 (void *)&cmd_vf_rate_limit_vfnum,
6974 (void *)&cmd_vf_rate_limit_rate,
6975 (void *)&cmd_vf_rate_limit_ratenum,
6976 (void *)&cmd_vf_rate_limit_q_msk,
6977 (void *)&cmd_vf_rate_limit_q_msk_val,
6982 /* *** ADD TUNNEL FILTER OF A PORT *** */
6983 struct cmd_tunnel_filter_result {
6984 cmdline_fixed_string_t cmd;
6985 cmdline_fixed_string_t what;
6987 struct ether_addr outer_mac;
6988 struct ether_addr inner_mac;
6989 cmdline_ipaddr_t ip_value;
6990 uint16_t inner_vlan;
6991 cmdline_fixed_string_t tunnel_type;
6992 cmdline_fixed_string_t filter_type;
6998 cmd_tunnel_filter_parsed(void *parsed_result,
6999 __attribute__((unused)) struct cmdline *cl,
7000 __attribute__((unused)) void *data)
7002 struct cmd_tunnel_filter_result *res = parsed_result;
7003 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7006 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7008 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7009 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7010 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7012 if (res->ip_value.family == AF_INET) {
7013 tunnel_filter_conf.ip_addr.ipv4_addr =
7014 res->ip_value.addr.ipv4.s_addr;
7015 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7017 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7018 &(res->ip_value.addr.ipv6),
7019 sizeof(struct in6_addr));
7020 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7023 if (!strcmp(res->filter_type, "imac-ivlan"))
7024 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7025 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7026 tunnel_filter_conf.filter_type =
7027 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7028 else if (!strcmp(res->filter_type, "imac-tenid"))
7029 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7030 else if (!strcmp(res->filter_type, "imac"))
7031 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7032 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7033 tunnel_filter_conf.filter_type =
7034 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7035 else if (!strcmp(res->filter_type, "oip"))
7036 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7037 else if (!strcmp(res->filter_type, "iip"))
7038 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7040 printf("The filter type is not supported");
7044 if (!strcmp(res->tunnel_type, "vxlan"))
7045 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7046 else if (!strcmp(res->tunnel_type, "nvgre"))
7047 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7048 else if (!strcmp(res->tunnel_type, "ipingre"))
7049 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7051 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7055 tunnel_filter_conf.tenant_id = res->tenant_id;
7056 tunnel_filter_conf.queue_id = res->queue_num;
7057 if (!strcmp(res->what, "add"))
7058 ret = rte_eth_dev_filter_ctrl(res->port_id,
7059 RTE_ETH_FILTER_TUNNEL,
7061 &tunnel_filter_conf);
7063 ret = rte_eth_dev_filter_ctrl(res->port_id,
7064 RTE_ETH_FILTER_TUNNEL,
7065 RTE_ETH_FILTER_DELETE,
7066 &tunnel_filter_conf);
7068 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7072 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7073 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7074 cmd, "tunnel_filter");
7075 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7076 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7078 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7079 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7081 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7082 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7084 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7085 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7087 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7088 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7089 inner_vlan, UINT16);
7090 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7091 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7093 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7094 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7095 tunnel_type, "vxlan#nvgre#ipingre");
7097 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7098 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7099 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7100 "imac#omac-imac-tenid");
7101 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7102 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7104 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7105 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7108 cmdline_parse_inst_t cmd_tunnel_filter = {
7109 .f = cmd_tunnel_filter_parsed,
7111 .help_str = "add/rm tunnel filter of a port: "
7112 "tunnel_filter add port_id outer_mac inner_mac ip "
7113 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
7114 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
7115 "imac|omac-imac-tenid) "
7116 "tenant_id queue_num",
7118 (void *)&cmd_tunnel_filter_cmd,
7119 (void *)&cmd_tunnel_filter_what,
7120 (void *)&cmd_tunnel_filter_port_id,
7121 (void *)&cmd_tunnel_filter_outer_mac,
7122 (void *)&cmd_tunnel_filter_inner_mac,
7123 (void *)&cmd_tunnel_filter_ip_value,
7124 (void *)&cmd_tunnel_filter_innner_vlan,
7125 (void *)&cmd_tunnel_filter_tunnel_type,
7126 (void *)&cmd_tunnel_filter_filter_type,
7127 (void *)&cmd_tunnel_filter_tenant_id,
7128 (void *)&cmd_tunnel_filter_queue_num,
7133 /* *** CONFIGURE TUNNEL UDP PORT *** */
7134 struct cmd_tunnel_udp_config {
7135 cmdline_fixed_string_t cmd;
7136 cmdline_fixed_string_t what;
7142 cmd_tunnel_udp_config_parsed(void *parsed_result,
7143 __attribute__((unused)) struct cmdline *cl,
7144 __attribute__((unused)) void *data)
7146 struct cmd_tunnel_udp_config *res = parsed_result;
7147 struct rte_eth_udp_tunnel tunnel_udp;
7150 tunnel_udp.udp_port = res->udp_port;
7152 if (!strcmp(res->cmd, "rx_vxlan_port"))
7153 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7155 if (!strcmp(res->what, "add"))
7156 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7159 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7163 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7166 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7167 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7168 cmd, "rx_vxlan_port");
7169 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7170 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7172 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7173 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7175 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7176 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7179 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7180 .f = cmd_tunnel_udp_config_parsed,
7182 .help_str = "add/rm an tunneling UDP port filter: "
7183 "rx_vxlan_port add udp_port port_id",
7185 (void *)&cmd_tunnel_udp_config_cmd,
7186 (void *)&cmd_tunnel_udp_config_what,
7187 (void *)&cmd_tunnel_udp_config_udp_port,
7188 (void *)&cmd_tunnel_udp_config_port_id,
7193 /* *** GLOBAL CONFIG *** */
7194 struct cmd_global_config_result {
7195 cmdline_fixed_string_t cmd;
7197 cmdline_fixed_string_t cfg_type;
7202 cmd_global_config_parsed(void *parsed_result,
7203 __attribute__((unused)) struct cmdline *cl,
7204 __attribute__((unused)) void *data)
7206 struct cmd_global_config_result *res = parsed_result;
7207 struct rte_eth_global_cfg conf;
7210 memset(&conf, 0, sizeof(conf));
7211 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7212 conf.cfg.gre_key_len = res->len;
7213 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7214 RTE_ETH_FILTER_SET, &conf);
7216 printf("Global config error\n");
7219 cmdline_parse_token_string_t cmd_global_config_cmd =
7220 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7222 cmdline_parse_token_num_t cmd_global_config_port_id =
7223 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7224 cmdline_parse_token_string_t cmd_global_config_type =
7225 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7226 cfg_type, "gre-key-len");
7227 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7228 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7231 cmdline_parse_inst_t cmd_global_config = {
7232 .f = cmd_global_config_parsed,
7233 .data = (void *)NULL,
7234 .help_str = "global_config <port_id> gre-key-len <number>",
7236 (void *)&cmd_global_config_cmd,
7237 (void *)&cmd_global_config_port_id,
7238 (void *)&cmd_global_config_type,
7239 (void *)&cmd_global_config_gre_key_len,
7244 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7245 struct cmd_set_mirror_mask_result {
7246 cmdline_fixed_string_t set;
7247 cmdline_fixed_string_t port;
7249 cmdline_fixed_string_t mirror;
7251 cmdline_fixed_string_t what;
7252 cmdline_fixed_string_t value;
7253 cmdline_fixed_string_t dstpool;
7255 cmdline_fixed_string_t on;
7258 cmdline_parse_token_string_t cmd_mirror_mask_set =
7259 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7261 cmdline_parse_token_string_t cmd_mirror_mask_port =
7262 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7264 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7265 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7267 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7268 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7269 mirror, "mirror-rule");
7270 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7271 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7273 cmdline_parse_token_string_t cmd_mirror_mask_what =
7274 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7275 what, "pool-mirror-up#pool-mirror-down"
7277 cmdline_parse_token_string_t cmd_mirror_mask_value =
7278 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7280 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7281 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7282 dstpool, "dst-pool");
7283 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7284 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7286 cmdline_parse_token_string_t cmd_mirror_mask_on =
7287 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7291 cmd_set_mirror_mask_parsed(void *parsed_result,
7292 __attribute__((unused)) struct cmdline *cl,
7293 __attribute__((unused)) void *data)
7296 struct cmd_set_mirror_mask_result *res = parsed_result;
7297 struct rte_eth_mirror_conf mr_conf;
7299 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7301 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7303 mr_conf.dst_pool = res->dstpool_id;
7305 if (!strcmp(res->what, "pool-mirror-up")) {
7306 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7307 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7308 } else if (!strcmp(res->what, "pool-mirror-down")) {
7309 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7310 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7311 } else if (!strcmp(res->what, "vlan-mirror")) {
7312 mr_conf.rule_type = ETH_MIRROR_VLAN;
7313 nb_item = parse_item_list(res->value, "vlan",
7314 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7318 for (i = 0; i < nb_item; i++) {
7319 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7320 printf("Invalid vlan_id: must be < 4096\n");
7324 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7325 mr_conf.vlan.vlan_mask |= 1ULL << i;
7329 if (!strcmp(res->on, "on"))
7330 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7333 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7336 printf("mirror rule add error: (%s)\n", strerror(-ret));
7339 cmdline_parse_inst_t cmd_set_mirror_mask = {
7340 .f = cmd_set_mirror_mask_parsed,
7342 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7343 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7345 (void *)&cmd_mirror_mask_set,
7346 (void *)&cmd_mirror_mask_port,
7347 (void *)&cmd_mirror_mask_portid,
7348 (void *)&cmd_mirror_mask_mirror,
7349 (void *)&cmd_mirror_mask_ruleid,
7350 (void *)&cmd_mirror_mask_what,
7351 (void *)&cmd_mirror_mask_value,
7352 (void *)&cmd_mirror_mask_dstpool,
7353 (void *)&cmd_mirror_mask_poolid,
7354 (void *)&cmd_mirror_mask_on,
7359 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7360 struct cmd_set_mirror_link_result {
7361 cmdline_fixed_string_t set;
7362 cmdline_fixed_string_t port;
7364 cmdline_fixed_string_t mirror;
7366 cmdline_fixed_string_t what;
7367 cmdline_fixed_string_t dstpool;
7369 cmdline_fixed_string_t on;
7372 cmdline_parse_token_string_t cmd_mirror_link_set =
7373 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7375 cmdline_parse_token_string_t cmd_mirror_link_port =
7376 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7378 cmdline_parse_token_num_t cmd_mirror_link_portid =
7379 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7381 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7382 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7383 mirror, "mirror-rule");
7384 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7385 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7387 cmdline_parse_token_string_t cmd_mirror_link_what =
7388 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7389 what, "uplink-mirror#downlink-mirror");
7390 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7391 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7392 dstpool, "dst-pool");
7393 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7394 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7396 cmdline_parse_token_string_t cmd_mirror_link_on =
7397 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7401 cmd_set_mirror_link_parsed(void *parsed_result,
7402 __attribute__((unused)) struct cmdline *cl,
7403 __attribute__((unused)) void *data)
7406 struct cmd_set_mirror_link_result *res = parsed_result;
7407 struct rte_eth_mirror_conf mr_conf;
7409 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7410 if (!strcmp(res->what, "uplink-mirror"))
7411 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7413 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7415 mr_conf.dst_pool = res->dstpool_id;
7417 if (!strcmp(res->on, "on"))
7418 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7421 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7424 /* check the return value and print it if is < 0 */
7426 printf("mirror rule add error: (%s)\n", strerror(-ret));
7430 cmdline_parse_inst_t cmd_set_mirror_link = {
7431 .f = cmd_set_mirror_link_parsed,
7433 .help_str = "set port X mirror-rule Y uplink-mirror|"
7434 "downlink-mirror dst-pool Z on|off",
7436 (void *)&cmd_mirror_link_set,
7437 (void *)&cmd_mirror_link_port,
7438 (void *)&cmd_mirror_link_portid,
7439 (void *)&cmd_mirror_link_mirror,
7440 (void *)&cmd_mirror_link_ruleid,
7441 (void *)&cmd_mirror_link_what,
7442 (void *)&cmd_mirror_link_dstpool,
7443 (void *)&cmd_mirror_link_poolid,
7444 (void *)&cmd_mirror_link_on,
7449 /* *** RESET VM MIRROR RULE *** */
7450 struct cmd_rm_mirror_rule_result {
7451 cmdline_fixed_string_t reset;
7452 cmdline_fixed_string_t port;
7454 cmdline_fixed_string_t mirror;
7458 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7459 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7461 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7462 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7464 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7465 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7467 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7468 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7469 mirror, "mirror-rule");
7470 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7471 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7475 cmd_reset_mirror_rule_parsed(void *parsed_result,
7476 __attribute__((unused)) struct cmdline *cl,
7477 __attribute__((unused)) void *data)
7480 struct cmd_set_mirror_link_result *res = parsed_result;
7482 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7484 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7487 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7488 .f = cmd_reset_mirror_rule_parsed,
7490 .help_str = "reset port X mirror-rule Y",
7492 (void *)&cmd_rm_mirror_rule_reset,
7493 (void *)&cmd_rm_mirror_rule_port,
7494 (void *)&cmd_rm_mirror_rule_portid,
7495 (void *)&cmd_rm_mirror_rule_mirror,
7496 (void *)&cmd_rm_mirror_rule_ruleid,
7501 /* ******************************************************************************** */
7503 struct cmd_dump_result {
7504 cmdline_fixed_string_t dump;
7508 dump_struct_sizes(void)
7510 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7511 DUMP_SIZE(struct rte_mbuf);
7512 DUMP_SIZE(struct rte_mempool);
7513 DUMP_SIZE(struct rte_ring);
7517 static void cmd_dump_parsed(void *parsed_result,
7518 __attribute__((unused)) struct cmdline *cl,
7519 __attribute__((unused)) void *data)
7521 struct cmd_dump_result *res = parsed_result;
7523 if (!strcmp(res->dump, "dump_physmem"))
7524 rte_dump_physmem_layout(stdout);
7525 else if (!strcmp(res->dump, "dump_memzone"))
7526 rte_memzone_dump(stdout);
7527 else if (!strcmp(res->dump, "dump_struct_sizes"))
7528 dump_struct_sizes();
7529 else if (!strcmp(res->dump, "dump_ring"))
7530 rte_ring_list_dump(stdout);
7531 else if (!strcmp(res->dump, "dump_mempool"))
7532 rte_mempool_list_dump(stdout);
7533 else if (!strcmp(res->dump, "dump_devargs"))
7534 rte_eal_devargs_dump(stdout);
7537 cmdline_parse_token_string_t cmd_dump_dump =
7538 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7541 "dump_struct_sizes#"
7546 cmdline_parse_inst_t cmd_dump = {
7547 .f = cmd_dump_parsed, /* function to call */
7548 .data = NULL, /* 2nd arg of func */
7549 .help_str = "dump status",
7550 .tokens = { /* token list, NULL terminated */
7551 (void *)&cmd_dump_dump,
7556 /* ******************************************************************************** */
7558 struct cmd_dump_one_result {
7559 cmdline_fixed_string_t dump;
7560 cmdline_fixed_string_t name;
7563 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7564 __attribute__((unused)) void *data)
7566 struct cmd_dump_one_result *res = parsed_result;
7568 if (!strcmp(res->dump, "dump_ring")) {
7570 r = rte_ring_lookup(res->name);
7572 cmdline_printf(cl, "Cannot find ring\n");
7575 rte_ring_dump(stdout, r);
7576 } else if (!strcmp(res->dump, "dump_mempool")) {
7577 struct rte_mempool *mp;
7578 mp = rte_mempool_lookup(res->name);
7580 cmdline_printf(cl, "Cannot find mempool\n");
7583 rte_mempool_dump(stdout, mp);
7587 cmdline_parse_token_string_t cmd_dump_one_dump =
7588 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7589 "dump_ring#dump_mempool");
7591 cmdline_parse_token_string_t cmd_dump_one_name =
7592 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7594 cmdline_parse_inst_t cmd_dump_one = {
7595 .f = cmd_dump_one_parsed, /* function to call */
7596 .data = NULL, /* 2nd arg of func */
7597 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7598 .tokens = { /* token list, NULL terminated */
7599 (void *)&cmd_dump_one_dump,
7600 (void *)&cmd_dump_one_name,
7605 /* *** Add/Del syn filter *** */
7606 struct cmd_syn_filter_result {
7607 cmdline_fixed_string_t filter;
7609 cmdline_fixed_string_t ops;
7610 cmdline_fixed_string_t priority;
7611 cmdline_fixed_string_t high;
7612 cmdline_fixed_string_t queue;
7617 cmd_syn_filter_parsed(void *parsed_result,
7618 __attribute__((unused)) struct cmdline *cl,
7619 __attribute__((unused)) void *data)
7621 struct cmd_syn_filter_result *res = parsed_result;
7622 struct rte_eth_syn_filter syn_filter;
7625 ret = rte_eth_dev_filter_supported(res->port_id,
7626 RTE_ETH_FILTER_SYN);
7628 printf("syn filter is not supported on port %u.\n",
7633 memset(&syn_filter, 0, sizeof(syn_filter));
7635 if (!strcmp(res->ops, "add")) {
7636 if (!strcmp(res->high, "high"))
7637 syn_filter.hig_pri = 1;
7639 syn_filter.hig_pri = 0;
7641 syn_filter.queue = res->queue_id;
7642 ret = rte_eth_dev_filter_ctrl(res->port_id,
7647 ret = rte_eth_dev_filter_ctrl(res->port_id,
7649 RTE_ETH_FILTER_DELETE,
7653 printf("syn filter programming error: (%s)\n",
7657 cmdline_parse_token_string_t cmd_syn_filter_filter =
7658 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7659 filter, "syn_filter");
7660 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7661 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7663 cmdline_parse_token_string_t cmd_syn_filter_ops =
7664 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7666 cmdline_parse_token_string_t cmd_syn_filter_priority =
7667 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7668 priority, "priority");
7669 cmdline_parse_token_string_t cmd_syn_filter_high =
7670 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7672 cmdline_parse_token_string_t cmd_syn_filter_queue =
7673 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7675 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7676 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7679 cmdline_parse_inst_t cmd_syn_filter = {
7680 .f = cmd_syn_filter_parsed,
7682 .help_str = "add/delete syn filter",
7684 (void *)&cmd_syn_filter_filter,
7685 (void *)&cmd_syn_filter_port_id,
7686 (void *)&cmd_syn_filter_ops,
7687 (void *)&cmd_syn_filter_priority,
7688 (void *)&cmd_syn_filter_high,
7689 (void *)&cmd_syn_filter_queue,
7690 (void *)&cmd_syn_filter_queue_id,
7695 /* *** ADD/REMOVE A 2tuple FILTER *** */
7696 struct cmd_2tuple_filter_result {
7697 cmdline_fixed_string_t filter;
7699 cmdline_fixed_string_t ops;
7700 cmdline_fixed_string_t dst_port;
7701 uint16_t dst_port_value;
7702 cmdline_fixed_string_t protocol;
7703 uint8_t protocol_value;
7704 cmdline_fixed_string_t mask;
7706 cmdline_fixed_string_t tcp_flags;
7707 uint8_t tcp_flags_value;
7708 cmdline_fixed_string_t priority;
7709 uint8_t priority_value;
7710 cmdline_fixed_string_t queue;
7715 cmd_2tuple_filter_parsed(void *parsed_result,
7716 __attribute__((unused)) struct cmdline *cl,
7717 __attribute__((unused)) void *data)
7719 struct rte_eth_ntuple_filter filter;
7720 struct cmd_2tuple_filter_result *res = parsed_result;
7723 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7725 printf("ntuple filter is not supported on port %u.\n",
7730 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7732 filter.flags = RTE_2TUPLE_FLAGS;
7733 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7734 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7735 filter.proto = res->protocol_value;
7736 filter.priority = res->priority_value;
7737 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7738 printf("nonzero tcp_flags is only meaningful"
7739 " when protocol is TCP.\n");
7742 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7743 printf("invalid TCP flags.\n");
7747 if (res->tcp_flags_value != 0) {
7748 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7749 filter.tcp_flags = res->tcp_flags_value;
7752 /* need convert to big endian. */
7753 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7754 filter.queue = res->queue_id;
7756 if (!strcmp(res->ops, "add"))
7757 ret = rte_eth_dev_filter_ctrl(res->port_id,
7758 RTE_ETH_FILTER_NTUPLE,
7762 ret = rte_eth_dev_filter_ctrl(res->port_id,
7763 RTE_ETH_FILTER_NTUPLE,
7764 RTE_ETH_FILTER_DELETE,
7767 printf("2tuple filter programming error: (%s)\n",
7772 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7773 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7774 filter, "2tuple_filter");
7775 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7776 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7778 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7779 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7781 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7782 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7783 dst_port, "dst_port");
7784 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7785 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7786 dst_port_value, UINT16);
7787 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7788 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7789 protocol, "protocol");
7790 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7791 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7792 protocol_value, UINT8);
7793 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7794 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7796 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7797 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7799 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7800 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7801 tcp_flags, "tcp_flags");
7802 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7803 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7804 tcp_flags_value, UINT8);
7805 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7806 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7807 priority, "priority");
7808 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7809 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7810 priority_value, UINT8);
7811 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7812 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7814 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7815 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7818 cmdline_parse_inst_t cmd_2tuple_filter = {
7819 .f = cmd_2tuple_filter_parsed,
7821 .help_str = "add a 2tuple filter",
7823 (void *)&cmd_2tuple_filter_filter,
7824 (void *)&cmd_2tuple_filter_port_id,
7825 (void *)&cmd_2tuple_filter_ops,
7826 (void *)&cmd_2tuple_filter_dst_port,
7827 (void *)&cmd_2tuple_filter_dst_port_value,
7828 (void *)&cmd_2tuple_filter_protocol,
7829 (void *)&cmd_2tuple_filter_protocol_value,
7830 (void *)&cmd_2tuple_filter_mask,
7831 (void *)&cmd_2tuple_filter_mask_value,
7832 (void *)&cmd_2tuple_filter_tcp_flags,
7833 (void *)&cmd_2tuple_filter_tcp_flags_value,
7834 (void *)&cmd_2tuple_filter_priority,
7835 (void *)&cmd_2tuple_filter_priority_value,
7836 (void *)&cmd_2tuple_filter_queue,
7837 (void *)&cmd_2tuple_filter_queue_id,
7842 /* *** ADD/REMOVE A 5tuple FILTER *** */
7843 struct cmd_5tuple_filter_result {
7844 cmdline_fixed_string_t filter;
7846 cmdline_fixed_string_t ops;
7847 cmdline_fixed_string_t dst_ip;
7848 cmdline_ipaddr_t dst_ip_value;
7849 cmdline_fixed_string_t src_ip;
7850 cmdline_ipaddr_t src_ip_value;
7851 cmdline_fixed_string_t dst_port;
7852 uint16_t dst_port_value;
7853 cmdline_fixed_string_t src_port;
7854 uint16_t src_port_value;
7855 cmdline_fixed_string_t protocol;
7856 uint8_t protocol_value;
7857 cmdline_fixed_string_t mask;
7859 cmdline_fixed_string_t tcp_flags;
7860 uint8_t tcp_flags_value;
7861 cmdline_fixed_string_t priority;
7862 uint8_t priority_value;
7863 cmdline_fixed_string_t queue;
7868 cmd_5tuple_filter_parsed(void *parsed_result,
7869 __attribute__((unused)) struct cmdline *cl,
7870 __attribute__((unused)) void *data)
7872 struct rte_eth_ntuple_filter filter;
7873 struct cmd_5tuple_filter_result *res = parsed_result;
7876 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7878 printf("ntuple filter is not supported on port %u.\n",
7883 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7885 filter.flags = RTE_5TUPLE_FLAGS;
7886 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7887 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7888 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7889 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7890 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7891 filter.proto = res->protocol_value;
7892 filter.priority = res->priority_value;
7893 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7894 printf("nonzero tcp_flags is only meaningful"
7895 " when protocol is TCP.\n");
7898 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7899 printf("invalid TCP flags.\n");
7903 if (res->tcp_flags_value != 0) {
7904 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7905 filter.tcp_flags = res->tcp_flags_value;
7908 if (res->dst_ip_value.family == AF_INET)
7909 /* no need to convert, already big endian. */
7910 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7912 if (filter.dst_ip_mask == 0) {
7913 printf("can not support ipv6 involved compare.\n");
7919 if (res->src_ip_value.family == AF_INET)
7920 /* no need to convert, already big endian. */
7921 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7923 if (filter.src_ip_mask == 0) {
7924 printf("can not support ipv6 involved compare.\n");
7929 /* need convert to big endian. */
7930 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7931 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7932 filter.queue = res->queue_id;
7934 if (!strcmp(res->ops, "add"))
7935 ret = rte_eth_dev_filter_ctrl(res->port_id,
7936 RTE_ETH_FILTER_NTUPLE,
7940 ret = rte_eth_dev_filter_ctrl(res->port_id,
7941 RTE_ETH_FILTER_NTUPLE,
7942 RTE_ETH_FILTER_DELETE,
7945 printf("5tuple filter programming error: (%s)\n",
7949 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7950 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7951 filter, "5tuple_filter");
7952 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7953 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7955 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7956 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7958 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7959 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7961 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7962 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7964 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7965 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7967 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7968 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7970 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7971 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7972 dst_port, "dst_port");
7973 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7974 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7975 dst_port_value, UINT16);
7976 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7977 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7978 src_port, "src_port");
7979 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7980 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7981 src_port_value, UINT16);
7982 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7983 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7984 protocol, "protocol");
7985 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7986 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7987 protocol_value, UINT8);
7988 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7989 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7991 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7992 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7994 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7995 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7996 tcp_flags, "tcp_flags");
7997 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7998 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7999 tcp_flags_value, UINT8);
8000 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8001 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8002 priority, "priority");
8003 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8004 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8005 priority_value, UINT8);
8006 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8007 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8009 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8010 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8013 cmdline_parse_inst_t cmd_5tuple_filter = {
8014 .f = cmd_5tuple_filter_parsed,
8016 .help_str = "add/del a 5tuple filter",
8018 (void *)&cmd_5tuple_filter_filter,
8019 (void *)&cmd_5tuple_filter_port_id,
8020 (void *)&cmd_5tuple_filter_ops,
8021 (void *)&cmd_5tuple_filter_dst_ip,
8022 (void *)&cmd_5tuple_filter_dst_ip_value,
8023 (void *)&cmd_5tuple_filter_src_ip,
8024 (void *)&cmd_5tuple_filter_src_ip_value,
8025 (void *)&cmd_5tuple_filter_dst_port,
8026 (void *)&cmd_5tuple_filter_dst_port_value,
8027 (void *)&cmd_5tuple_filter_src_port,
8028 (void *)&cmd_5tuple_filter_src_port_value,
8029 (void *)&cmd_5tuple_filter_protocol,
8030 (void *)&cmd_5tuple_filter_protocol_value,
8031 (void *)&cmd_5tuple_filter_mask,
8032 (void *)&cmd_5tuple_filter_mask_value,
8033 (void *)&cmd_5tuple_filter_tcp_flags,
8034 (void *)&cmd_5tuple_filter_tcp_flags_value,
8035 (void *)&cmd_5tuple_filter_priority,
8036 (void *)&cmd_5tuple_filter_priority_value,
8037 (void *)&cmd_5tuple_filter_queue,
8038 (void *)&cmd_5tuple_filter_queue_id,
8043 /* *** ADD/REMOVE A flex FILTER *** */
8044 struct cmd_flex_filter_result {
8045 cmdline_fixed_string_t filter;
8046 cmdline_fixed_string_t ops;
8048 cmdline_fixed_string_t len;
8050 cmdline_fixed_string_t bytes;
8051 cmdline_fixed_string_t bytes_value;
8052 cmdline_fixed_string_t mask;
8053 cmdline_fixed_string_t mask_value;
8054 cmdline_fixed_string_t priority;
8055 uint8_t priority_value;
8056 cmdline_fixed_string_t queue;
8060 static int xdigit2val(unsigned char c)
8065 else if (isupper(c))
8073 cmd_flex_filter_parsed(void *parsed_result,
8074 __attribute__((unused)) struct cmdline *cl,
8075 __attribute__((unused)) void *data)
8078 struct rte_eth_flex_filter filter;
8079 struct cmd_flex_filter_result *res = parsed_result;
8080 char *bytes_ptr, *mask_ptr;
8081 uint16_t len, i, j = 0;
8086 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8087 printf("the len exceed the max length 128\n");
8090 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8091 filter.len = res->len_value;
8092 filter.priority = res->priority_value;
8093 filter.queue = res->queue_id;
8094 bytes_ptr = res->bytes_value;
8095 mask_ptr = res->mask_value;
8097 /* translate bytes string to array. */
8098 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8099 (bytes_ptr[1] == 'X')))
8101 len = strnlen(bytes_ptr, res->len_value * 2);
8102 if (len == 0 || (len % 8 != 0)) {
8103 printf("please check len and bytes input\n");
8106 for (i = 0; i < len; i++) {
8108 if (isxdigit(c) == 0) {
8109 /* invalid characters. */
8110 printf("invalid input\n");
8113 val = xdigit2val(c);
8116 filter.bytes[j] = byte;
8117 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8124 /* translate mask string to uint8_t array. */
8125 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8126 (mask_ptr[1] == 'X')))
8128 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8130 printf("invalid input\n");
8135 for (i = 0; i < len; i++) {
8137 if (isxdigit(c) == 0) {
8138 /* invalid characters. */
8139 printf("invalid input\n");
8142 val = xdigit2val(c);
8145 filter.mask[j] = byte;
8146 printf("mask[%d]:%02x ", j, filter.mask[j]);
8154 if (!strcmp(res->ops, "add"))
8155 ret = rte_eth_dev_filter_ctrl(res->port_id,
8156 RTE_ETH_FILTER_FLEXIBLE,
8160 ret = rte_eth_dev_filter_ctrl(res->port_id,
8161 RTE_ETH_FILTER_FLEXIBLE,
8162 RTE_ETH_FILTER_DELETE,
8166 printf("flex filter setting error: (%s)\n", strerror(-ret));
8169 cmdline_parse_token_string_t cmd_flex_filter_filter =
8170 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8171 filter, "flex_filter");
8172 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8173 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8175 cmdline_parse_token_string_t cmd_flex_filter_ops =
8176 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8178 cmdline_parse_token_string_t cmd_flex_filter_len =
8179 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8181 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8182 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8184 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8185 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8187 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8188 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8190 cmdline_parse_token_string_t cmd_flex_filter_mask =
8191 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8193 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8194 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8196 cmdline_parse_token_string_t cmd_flex_filter_priority =
8197 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8198 priority, "priority");
8199 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8200 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8201 priority_value, UINT8);
8202 cmdline_parse_token_string_t cmd_flex_filter_queue =
8203 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8205 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8206 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8208 cmdline_parse_inst_t cmd_flex_filter = {
8209 .f = cmd_flex_filter_parsed,
8211 .help_str = "add/del a flex filter",
8213 (void *)&cmd_flex_filter_filter,
8214 (void *)&cmd_flex_filter_port_id,
8215 (void *)&cmd_flex_filter_ops,
8216 (void *)&cmd_flex_filter_len,
8217 (void *)&cmd_flex_filter_len_value,
8218 (void *)&cmd_flex_filter_bytes,
8219 (void *)&cmd_flex_filter_bytes_value,
8220 (void *)&cmd_flex_filter_mask,
8221 (void *)&cmd_flex_filter_mask_value,
8222 (void *)&cmd_flex_filter_priority,
8223 (void *)&cmd_flex_filter_priority_value,
8224 (void *)&cmd_flex_filter_queue,
8225 (void *)&cmd_flex_filter_queue_id,
8230 /* *** Filters Control *** */
8232 /* *** deal with ethertype filter *** */
8233 struct cmd_ethertype_filter_result {
8234 cmdline_fixed_string_t filter;
8236 cmdline_fixed_string_t ops;
8237 cmdline_fixed_string_t mac;
8238 struct ether_addr mac_addr;
8239 cmdline_fixed_string_t ethertype;
8240 uint16_t ethertype_value;
8241 cmdline_fixed_string_t drop;
8242 cmdline_fixed_string_t queue;
8246 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8247 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8248 filter, "ethertype_filter");
8249 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8250 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8252 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8253 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8255 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8256 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8257 mac, "mac_addr#mac_ignr");
8258 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8259 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8261 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8262 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8263 ethertype, "ethertype");
8264 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8265 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8266 ethertype_value, UINT16);
8267 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8268 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8270 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8271 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8273 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8274 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8278 cmd_ethertype_filter_parsed(void *parsed_result,
8279 __attribute__((unused)) struct cmdline *cl,
8280 __attribute__((unused)) void *data)
8282 struct cmd_ethertype_filter_result *res = parsed_result;
8283 struct rte_eth_ethertype_filter filter;
8286 ret = rte_eth_dev_filter_supported(res->port_id,
8287 RTE_ETH_FILTER_ETHERTYPE);
8289 printf("ethertype filter is not supported on port %u.\n",
8294 memset(&filter, 0, sizeof(filter));
8295 if (!strcmp(res->mac, "mac_addr")) {
8296 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8297 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8298 sizeof(struct ether_addr));
8300 if (!strcmp(res->drop, "drop"))
8301 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8302 filter.ether_type = res->ethertype_value;
8303 filter.queue = res->queue_id;
8305 if (!strcmp(res->ops, "add"))
8306 ret = rte_eth_dev_filter_ctrl(res->port_id,
8307 RTE_ETH_FILTER_ETHERTYPE,
8311 ret = rte_eth_dev_filter_ctrl(res->port_id,
8312 RTE_ETH_FILTER_ETHERTYPE,
8313 RTE_ETH_FILTER_DELETE,
8316 printf("ethertype filter programming error: (%s)\n",
8320 cmdline_parse_inst_t cmd_ethertype_filter = {
8321 .f = cmd_ethertype_filter_parsed,
8323 .help_str = "add or delete an ethertype filter entry",
8325 (void *)&cmd_ethertype_filter_filter,
8326 (void *)&cmd_ethertype_filter_port_id,
8327 (void *)&cmd_ethertype_filter_ops,
8328 (void *)&cmd_ethertype_filter_mac,
8329 (void *)&cmd_ethertype_filter_mac_addr,
8330 (void *)&cmd_ethertype_filter_ethertype,
8331 (void *)&cmd_ethertype_filter_ethertype_value,
8332 (void *)&cmd_ethertype_filter_drop,
8333 (void *)&cmd_ethertype_filter_queue,
8334 (void *)&cmd_ethertype_filter_queue_id,
8339 /* *** deal with flow director filter *** */
8340 struct cmd_flow_director_result {
8341 cmdline_fixed_string_t flow_director_filter;
8343 cmdline_fixed_string_t mode;
8344 cmdline_fixed_string_t mode_value;
8345 cmdline_fixed_string_t ops;
8346 cmdline_fixed_string_t flow;
8347 cmdline_fixed_string_t flow_type;
8348 cmdline_fixed_string_t ether;
8349 uint16_t ether_type;
8350 cmdline_fixed_string_t src;
8351 cmdline_ipaddr_t ip_src;
8353 cmdline_fixed_string_t dst;
8354 cmdline_ipaddr_t ip_dst;
8356 cmdline_fixed_string_t verify_tag;
8357 uint32_t verify_tag_value;
8358 cmdline_ipaddr_t tos;
8360 cmdline_ipaddr_t proto;
8361 uint8_t proto_value;
8362 cmdline_ipaddr_t ttl;
8364 cmdline_fixed_string_t vlan;
8365 uint16_t vlan_value;
8366 cmdline_fixed_string_t flexbytes;
8367 cmdline_fixed_string_t flexbytes_value;
8368 cmdline_fixed_string_t pf_vf;
8369 cmdline_fixed_string_t drop;
8370 cmdline_fixed_string_t queue;
8372 cmdline_fixed_string_t fd_id;
8373 uint32_t fd_id_value;
8374 cmdline_fixed_string_t mac;
8375 struct ether_addr mac_addr;
8376 cmdline_fixed_string_t tunnel;
8377 cmdline_fixed_string_t tunnel_type;
8378 cmdline_fixed_string_t tunnel_id;
8379 uint32_t tunnel_id_value;
8383 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8386 const char *p, *p0 = q_arg;
8388 unsigned long int_fld;
8389 char *str_fld[max_num];
8394 p = strchr(p0, '(');
8398 p0 = strchr(p, ')');
8403 if (size >= sizeof(s))
8406 snprintf(s, sizeof(s), "%.*s", size, p);
8407 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8408 if (ret < 0 || ret > max_num)
8410 for (i = 0; i < ret; i++) {
8412 int_fld = strtoul(str_fld[i], &end, 0);
8413 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8415 flexbytes[i] = (uint8_t)int_fld;
8421 str2flowtype(char *string)
8424 static const struct {
8427 } flowtype_str[] = {
8428 {"raw", RTE_ETH_FLOW_RAW},
8429 {"ipv4", RTE_ETH_FLOW_IPV4},
8430 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8431 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8432 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8433 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8434 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8435 {"ipv6", RTE_ETH_FLOW_IPV6},
8436 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8437 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8438 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8439 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8440 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8441 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8444 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8445 if (!strcmp(flowtype_str[i].str, string))
8446 return flowtype_str[i].type;
8448 return RTE_ETH_FLOW_UNKNOWN;
8451 static enum rte_eth_fdir_tunnel_type
8452 str2fdir_tunneltype(char *string)
8456 static const struct {
8458 enum rte_eth_fdir_tunnel_type type;
8459 } tunneltype_str[] = {
8460 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8461 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8464 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8465 if (!strcmp(tunneltype_str[i].str, string))
8466 return tunneltype_str[i].type;
8468 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8471 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8473 if ((ip_addr).family == AF_INET) \
8474 (ip) = (ip_addr).addr.ipv4.s_addr; \
8476 printf("invalid parameter.\n"); \
8481 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8483 if ((ip_addr).family == AF_INET6) \
8484 (void)rte_memcpy(&(ip), \
8485 &((ip_addr).addr.ipv6), \
8486 sizeof(struct in6_addr)); \
8488 printf("invalid parameter.\n"); \
8494 cmd_flow_director_filter_parsed(void *parsed_result,
8495 __attribute__((unused)) struct cmdline *cl,
8496 __attribute__((unused)) void *data)
8498 struct cmd_flow_director_result *res = parsed_result;
8499 struct rte_eth_fdir_filter entry;
8500 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8502 unsigned long vf_id;
8505 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8507 printf("flow director is not supported on port %u.\n",
8511 memset(flexbytes, 0, sizeof(flexbytes));
8512 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8514 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8515 if (strcmp(res->mode_value, "MAC-VLAN")) {
8516 printf("Please set mode to MAC-VLAN.\n");
8519 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8520 if (strcmp(res->mode_value, "Tunnel")) {
8521 printf("Please set mode to Tunnel.\n");
8525 if (strcmp(res->mode_value, "IP")) {
8526 printf("Please set mode to IP.\n");
8529 entry.input.flow_type = str2flowtype(res->flow_type);
8532 ret = parse_flexbytes(res->flexbytes_value,
8534 RTE_ETH_FDIR_MAX_FLEXLEN);
8536 printf("error: Cannot parse flexbytes input.\n");
8540 switch (entry.input.flow_type) {
8541 case RTE_ETH_FLOW_FRAG_IPV4:
8542 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8543 entry.input.flow.ip4_flow.proto = res->proto_value;
8544 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8545 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8546 IPV4_ADDR_TO_UINT(res->ip_dst,
8547 entry.input.flow.ip4_flow.dst_ip);
8548 IPV4_ADDR_TO_UINT(res->ip_src,
8549 entry.input.flow.ip4_flow.src_ip);
8550 entry.input.flow.ip4_flow.tos = res->tos_value;
8551 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8552 /* need convert to big endian. */
8553 entry.input.flow.udp4_flow.dst_port =
8554 rte_cpu_to_be_16(res->port_dst);
8555 entry.input.flow.udp4_flow.src_port =
8556 rte_cpu_to_be_16(res->port_src);
8558 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8559 IPV4_ADDR_TO_UINT(res->ip_dst,
8560 entry.input.flow.sctp4_flow.ip.dst_ip);
8561 IPV4_ADDR_TO_UINT(res->ip_src,
8562 entry.input.flow.sctp4_flow.ip.src_ip);
8563 entry.input.flow.ip4_flow.tos = res->tos_value;
8564 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8565 /* need convert to big endian. */
8566 entry.input.flow.sctp4_flow.dst_port =
8567 rte_cpu_to_be_16(res->port_dst);
8568 entry.input.flow.sctp4_flow.src_port =
8569 rte_cpu_to_be_16(res->port_src);
8570 entry.input.flow.sctp4_flow.verify_tag =
8571 rte_cpu_to_be_32(res->verify_tag_value);
8573 case RTE_ETH_FLOW_FRAG_IPV6:
8574 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8575 entry.input.flow.ipv6_flow.proto = res->proto_value;
8576 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8577 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8578 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8579 entry.input.flow.ipv6_flow.dst_ip);
8580 IPV6_ADDR_TO_ARRAY(res->ip_src,
8581 entry.input.flow.ipv6_flow.src_ip);
8582 entry.input.flow.ipv6_flow.tc = res->tos_value;
8583 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8584 /* need convert to big endian. */
8585 entry.input.flow.udp6_flow.dst_port =
8586 rte_cpu_to_be_16(res->port_dst);
8587 entry.input.flow.udp6_flow.src_port =
8588 rte_cpu_to_be_16(res->port_src);
8590 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8591 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8592 entry.input.flow.sctp6_flow.ip.dst_ip);
8593 IPV6_ADDR_TO_ARRAY(res->ip_src,
8594 entry.input.flow.sctp6_flow.ip.src_ip);
8595 entry.input.flow.ipv6_flow.tc = res->tos_value;
8596 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8597 /* need convert to big endian. */
8598 entry.input.flow.sctp6_flow.dst_port =
8599 rte_cpu_to_be_16(res->port_dst);
8600 entry.input.flow.sctp6_flow.src_port =
8601 rte_cpu_to_be_16(res->port_src);
8602 entry.input.flow.sctp6_flow.verify_tag =
8603 rte_cpu_to_be_32(res->verify_tag_value);
8605 case RTE_ETH_FLOW_L2_PAYLOAD:
8606 entry.input.flow.l2_flow.ether_type =
8607 rte_cpu_to_be_16(res->ether_type);
8613 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8614 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8616 sizeof(struct ether_addr));
8618 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8619 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8621 sizeof(struct ether_addr));
8622 entry.input.flow.tunnel_flow.tunnel_type =
8623 str2fdir_tunneltype(res->tunnel_type);
8624 entry.input.flow.tunnel_flow.tunnel_id =
8625 rte_cpu_to_be_32(res->tunnel_id_value);
8628 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8630 RTE_ETH_FDIR_MAX_FLEXLEN);
8632 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8634 entry.action.flex_off = 0; /*use 0 by default */
8635 if (!strcmp(res->drop, "drop"))
8636 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8638 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8640 if (!strcmp(res->pf_vf, "pf"))
8641 entry.input.flow_ext.is_vf = 0;
8642 else if (!strncmp(res->pf_vf, "vf", 2)) {
8643 struct rte_eth_dev_info dev_info;
8645 memset(&dev_info, 0, sizeof(dev_info));
8646 rte_eth_dev_info_get(res->port_id, &dev_info);
8648 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8649 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8650 printf("invalid parameter %s.\n", res->pf_vf);
8653 entry.input.flow_ext.is_vf = 1;
8654 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8656 printf("invalid parameter %s.\n", res->pf_vf);
8660 /* set to report FD ID by default */
8661 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8662 entry.action.rx_queue = res->queue_id;
8663 entry.soft_id = res->fd_id_value;
8664 if (!strcmp(res->ops, "add"))
8665 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8666 RTE_ETH_FILTER_ADD, &entry);
8667 else if (!strcmp(res->ops, "del"))
8668 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8669 RTE_ETH_FILTER_DELETE, &entry);
8671 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8672 RTE_ETH_FILTER_UPDATE, &entry);
8674 printf("flow director programming error: (%s)\n",
8678 cmdline_parse_token_string_t cmd_flow_director_filter =
8679 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8680 flow_director_filter, "flow_director_filter");
8681 cmdline_parse_token_num_t cmd_flow_director_port_id =
8682 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8684 cmdline_parse_token_string_t cmd_flow_director_ops =
8685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8686 ops, "add#del#update");
8687 cmdline_parse_token_string_t cmd_flow_director_flow =
8688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8690 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8692 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8693 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8694 cmdline_parse_token_string_t cmd_flow_director_ether =
8695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8697 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8698 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8699 ether_type, UINT16);
8700 cmdline_parse_token_string_t cmd_flow_director_src =
8701 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8703 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8704 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8706 cmdline_parse_token_num_t cmd_flow_director_port_src =
8707 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8709 cmdline_parse_token_string_t cmd_flow_director_dst =
8710 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8712 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8713 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8715 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8716 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8718 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8719 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8720 verify_tag, "verify_tag");
8721 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8722 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8723 verify_tag_value, UINT32);
8724 cmdline_parse_token_string_t cmd_flow_director_tos =
8725 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8727 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8728 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8730 cmdline_parse_token_string_t cmd_flow_director_proto =
8731 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8733 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8734 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8735 proto_value, UINT8);
8736 cmdline_parse_token_string_t cmd_flow_director_ttl =
8737 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8739 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8740 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8742 cmdline_parse_token_string_t cmd_flow_director_vlan =
8743 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8745 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8746 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8747 vlan_value, UINT16);
8748 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8749 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8750 flexbytes, "flexbytes");
8751 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8752 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8753 flexbytes_value, NULL);
8754 cmdline_parse_token_string_t cmd_flow_director_drop =
8755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8757 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8758 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8760 cmdline_parse_token_string_t cmd_flow_director_queue =
8761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8763 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8764 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8766 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8769 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8770 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8771 fd_id_value, UINT32);
8773 cmdline_parse_token_string_t cmd_flow_director_mode =
8774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8776 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8777 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8779 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8780 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8781 mode_value, "MAC-VLAN");
8782 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8783 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8784 mode_value, "Tunnel");
8785 cmdline_parse_token_string_t cmd_flow_director_mac =
8786 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8788 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8789 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8791 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8794 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8795 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8796 tunnel_type, "NVGRE#VxLAN");
8797 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8798 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8799 tunnel_id, "tunnel-id");
8800 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8801 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8802 tunnel_id_value, UINT32);
8804 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8805 .f = cmd_flow_director_filter_parsed,
8807 .help_str = "add or delete an ip flow director entry on NIC",
8809 (void *)&cmd_flow_director_filter,
8810 (void *)&cmd_flow_director_port_id,
8811 (void *)&cmd_flow_director_mode,
8812 (void *)&cmd_flow_director_mode_ip,
8813 (void *)&cmd_flow_director_ops,
8814 (void *)&cmd_flow_director_flow,
8815 (void *)&cmd_flow_director_flow_type,
8816 (void *)&cmd_flow_director_src,
8817 (void *)&cmd_flow_director_ip_src,
8818 (void *)&cmd_flow_director_dst,
8819 (void *)&cmd_flow_director_ip_dst,
8820 (void *)&cmd_flow_director_tos,
8821 (void *)&cmd_flow_director_tos_value,
8822 (void *)&cmd_flow_director_proto,
8823 (void *)&cmd_flow_director_proto_value,
8824 (void *)&cmd_flow_director_ttl,
8825 (void *)&cmd_flow_director_ttl_value,
8826 (void *)&cmd_flow_director_vlan,
8827 (void *)&cmd_flow_director_vlan_value,
8828 (void *)&cmd_flow_director_flexbytes,
8829 (void *)&cmd_flow_director_flexbytes_value,
8830 (void *)&cmd_flow_director_drop,
8831 (void *)&cmd_flow_director_pf_vf,
8832 (void *)&cmd_flow_director_queue,
8833 (void *)&cmd_flow_director_queue_id,
8834 (void *)&cmd_flow_director_fd_id,
8835 (void *)&cmd_flow_director_fd_id_value,
8840 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8841 .f = cmd_flow_director_filter_parsed,
8843 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8845 (void *)&cmd_flow_director_filter,
8846 (void *)&cmd_flow_director_port_id,
8847 (void *)&cmd_flow_director_mode,
8848 (void *)&cmd_flow_director_mode_ip,
8849 (void *)&cmd_flow_director_ops,
8850 (void *)&cmd_flow_director_flow,
8851 (void *)&cmd_flow_director_flow_type,
8852 (void *)&cmd_flow_director_src,
8853 (void *)&cmd_flow_director_ip_src,
8854 (void *)&cmd_flow_director_port_src,
8855 (void *)&cmd_flow_director_dst,
8856 (void *)&cmd_flow_director_ip_dst,
8857 (void *)&cmd_flow_director_port_dst,
8858 (void *)&cmd_flow_director_tos,
8859 (void *)&cmd_flow_director_tos_value,
8860 (void *)&cmd_flow_director_ttl,
8861 (void *)&cmd_flow_director_ttl_value,
8862 (void *)&cmd_flow_director_vlan,
8863 (void *)&cmd_flow_director_vlan_value,
8864 (void *)&cmd_flow_director_flexbytes,
8865 (void *)&cmd_flow_director_flexbytes_value,
8866 (void *)&cmd_flow_director_drop,
8867 (void *)&cmd_flow_director_pf_vf,
8868 (void *)&cmd_flow_director_queue,
8869 (void *)&cmd_flow_director_queue_id,
8870 (void *)&cmd_flow_director_fd_id,
8871 (void *)&cmd_flow_director_fd_id_value,
8876 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8877 .f = cmd_flow_director_filter_parsed,
8879 .help_str = "add or delete a sctp flow director entry on NIC",
8881 (void *)&cmd_flow_director_filter,
8882 (void *)&cmd_flow_director_port_id,
8883 (void *)&cmd_flow_director_mode,
8884 (void *)&cmd_flow_director_mode_ip,
8885 (void *)&cmd_flow_director_ops,
8886 (void *)&cmd_flow_director_flow,
8887 (void *)&cmd_flow_director_flow_type,
8888 (void *)&cmd_flow_director_src,
8889 (void *)&cmd_flow_director_ip_src,
8890 (void *)&cmd_flow_director_port_dst,
8891 (void *)&cmd_flow_director_dst,
8892 (void *)&cmd_flow_director_ip_dst,
8893 (void *)&cmd_flow_director_port_dst,
8894 (void *)&cmd_flow_director_verify_tag,
8895 (void *)&cmd_flow_director_verify_tag_value,
8896 (void *)&cmd_flow_director_tos,
8897 (void *)&cmd_flow_director_tos_value,
8898 (void *)&cmd_flow_director_ttl,
8899 (void *)&cmd_flow_director_ttl_value,
8900 (void *)&cmd_flow_director_vlan,
8901 (void *)&cmd_flow_director_vlan_value,
8902 (void *)&cmd_flow_director_flexbytes,
8903 (void *)&cmd_flow_director_flexbytes_value,
8904 (void *)&cmd_flow_director_drop,
8905 (void *)&cmd_flow_director_pf_vf,
8906 (void *)&cmd_flow_director_queue,
8907 (void *)&cmd_flow_director_queue_id,
8908 (void *)&cmd_flow_director_fd_id,
8909 (void *)&cmd_flow_director_fd_id_value,
8914 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8915 .f = cmd_flow_director_filter_parsed,
8917 .help_str = "add or delete a L2 flow director entry on NIC",
8919 (void *)&cmd_flow_director_filter,
8920 (void *)&cmd_flow_director_port_id,
8921 (void *)&cmd_flow_director_mode,
8922 (void *)&cmd_flow_director_mode_ip,
8923 (void *)&cmd_flow_director_ops,
8924 (void *)&cmd_flow_director_flow,
8925 (void *)&cmd_flow_director_flow_type,
8926 (void *)&cmd_flow_director_ether,
8927 (void *)&cmd_flow_director_ether_type,
8928 (void *)&cmd_flow_director_flexbytes,
8929 (void *)&cmd_flow_director_flexbytes_value,
8930 (void *)&cmd_flow_director_drop,
8931 (void *)&cmd_flow_director_pf_vf,
8932 (void *)&cmd_flow_director_queue,
8933 (void *)&cmd_flow_director_queue_id,
8934 (void *)&cmd_flow_director_fd_id,
8935 (void *)&cmd_flow_director_fd_id_value,
8940 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8941 .f = cmd_flow_director_filter_parsed,
8943 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8945 (void *)&cmd_flow_director_filter,
8946 (void *)&cmd_flow_director_port_id,
8947 (void *)&cmd_flow_director_mode,
8948 (void *)&cmd_flow_director_mode_mac_vlan,
8949 (void *)&cmd_flow_director_ops,
8950 (void *)&cmd_flow_director_mac,
8951 (void *)&cmd_flow_director_mac_addr,
8952 (void *)&cmd_flow_director_vlan,
8953 (void *)&cmd_flow_director_vlan_value,
8954 (void *)&cmd_flow_director_flexbytes,
8955 (void *)&cmd_flow_director_flexbytes_value,
8956 (void *)&cmd_flow_director_drop,
8957 (void *)&cmd_flow_director_queue,
8958 (void *)&cmd_flow_director_queue_id,
8959 (void *)&cmd_flow_director_fd_id,
8960 (void *)&cmd_flow_director_fd_id_value,
8965 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8966 .f = cmd_flow_director_filter_parsed,
8968 .help_str = "add or delete a tunnel flow director entry on NIC",
8970 (void *)&cmd_flow_director_filter,
8971 (void *)&cmd_flow_director_port_id,
8972 (void *)&cmd_flow_director_mode,
8973 (void *)&cmd_flow_director_mode_tunnel,
8974 (void *)&cmd_flow_director_ops,
8975 (void *)&cmd_flow_director_mac,
8976 (void *)&cmd_flow_director_mac_addr,
8977 (void *)&cmd_flow_director_vlan,
8978 (void *)&cmd_flow_director_vlan_value,
8979 (void *)&cmd_flow_director_tunnel,
8980 (void *)&cmd_flow_director_tunnel_type,
8981 (void *)&cmd_flow_director_tunnel_id,
8982 (void *)&cmd_flow_director_tunnel_id_value,
8983 (void *)&cmd_flow_director_flexbytes,
8984 (void *)&cmd_flow_director_flexbytes_value,
8985 (void *)&cmd_flow_director_drop,
8986 (void *)&cmd_flow_director_queue,
8987 (void *)&cmd_flow_director_queue_id,
8988 (void *)&cmd_flow_director_fd_id,
8989 (void *)&cmd_flow_director_fd_id_value,
8994 struct cmd_flush_flow_director_result {
8995 cmdline_fixed_string_t flush_flow_director;
8999 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9000 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9001 flush_flow_director, "flush_flow_director");
9002 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9003 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9007 cmd_flush_flow_director_parsed(void *parsed_result,
9008 __attribute__((unused)) struct cmdline *cl,
9009 __attribute__((unused)) void *data)
9011 struct cmd_flow_director_result *res = parsed_result;
9014 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9016 printf("flow director is not supported on port %u.\n",
9021 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9022 RTE_ETH_FILTER_FLUSH, NULL);
9024 printf("flow director table flushing error: (%s)\n",
9028 cmdline_parse_inst_t cmd_flush_flow_director = {
9029 .f = cmd_flush_flow_director_parsed,
9031 .help_str = "flush all flow director entries of a device on NIC",
9033 (void *)&cmd_flush_flow_director_flush,
9034 (void *)&cmd_flush_flow_director_port_id,
9039 /* *** deal with flow director mask *** */
9040 struct cmd_flow_director_mask_result {
9041 cmdline_fixed_string_t flow_director_mask;
9043 cmdline_fixed_string_t mode;
9044 cmdline_fixed_string_t mode_value;
9045 cmdline_fixed_string_t vlan;
9047 cmdline_fixed_string_t src_mask;
9048 cmdline_ipaddr_t ipv4_src;
9049 cmdline_ipaddr_t ipv6_src;
9051 cmdline_fixed_string_t dst_mask;
9052 cmdline_ipaddr_t ipv4_dst;
9053 cmdline_ipaddr_t ipv6_dst;
9055 cmdline_fixed_string_t mac;
9056 uint8_t mac_addr_byte_mask;
9057 cmdline_fixed_string_t tunnel_id;
9058 uint32_t tunnel_id_mask;
9059 cmdline_fixed_string_t tunnel_type;
9060 uint8_t tunnel_type_mask;
9064 cmd_flow_director_mask_parsed(void *parsed_result,
9065 __attribute__((unused)) struct cmdline *cl,
9066 __attribute__((unused)) void *data)
9068 struct cmd_flow_director_mask_result *res = parsed_result;
9069 struct rte_eth_fdir_masks *mask;
9070 struct rte_port *port;
9072 if (res->port_id > nb_ports) {
9073 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9077 port = &ports[res->port_id];
9078 /** Check if the port is not started **/
9079 if (port->port_status != RTE_PORT_STOPPED) {
9080 printf("Please stop port %d first\n", res->port_id);
9084 mask = &port->dev_conf.fdir_conf.mask;
9086 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9087 if (strcmp(res->mode_value, "MAC-VLAN")) {
9088 printf("Please set mode to MAC-VLAN.\n");
9092 mask->vlan_tci_mask = res->vlan_mask;
9093 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9094 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9095 if (strcmp(res->mode_value, "Tunnel")) {
9096 printf("Please set mode to Tunnel.\n");
9100 mask->vlan_tci_mask = res->vlan_mask;
9101 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9102 mask->tunnel_id_mask = res->tunnel_id_mask;
9103 mask->tunnel_type_mask = res->tunnel_type_mask;
9105 if (strcmp(res->mode_value, "IP")) {
9106 printf("Please set mode to IP.\n");
9110 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9111 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9112 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9113 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9114 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9115 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9116 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9119 cmd_reconfig_device_queue(res->port_id, 1, 1);
9122 cmdline_parse_token_string_t cmd_flow_director_mask =
9123 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9124 flow_director_mask, "flow_director_mask");
9125 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9126 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9128 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9129 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9131 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9132 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9134 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9135 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9136 src_mask, "src_mask");
9137 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9138 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9140 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9141 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9143 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9144 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9146 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9147 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9148 dst_mask, "dst_mask");
9149 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9150 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9152 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9153 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9155 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9156 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9159 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9162 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9163 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9165 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9166 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9167 mode_value, "MAC-VLAN");
9168 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9169 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9170 mode_value, "Tunnel");
9171 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9172 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9174 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9175 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9176 mac_addr_byte_mask, UINT8);
9177 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9178 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9179 tunnel_type, "tunnel-type");
9180 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9181 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9182 tunnel_type_mask, UINT8);
9183 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9184 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9185 tunnel_id, "tunnel-id");
9186 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9187 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9188 tunnel_id_mask, UINT32);
9190 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9191 .f = cmd_flow_director_mask_parsed,
9193 .help_str = "set IP mode flow director's mask on NIC",
9195 (void *)&cmd_flow_director_mask,
9196 (void *)&cmd_flow_director_mask_port_id,
9197 (void *)&cmd_flow_director_mask_mode,
9198 (void *)&cmd_flow_director_mask_mode_ip,
9199 (void *)&cmd_flow_director_mask_vlan,
9200 (void *)&cmd_flow_director_mask_vlan_value,
9201 (void *)&cmd_flow_director_mask_src,
9202 (void *)&cmd_flow_director_mask_ipv4_src,
9203 (void *)&cmd_flow_director_mask_ipv6_src,
9204 (void *)&cmd_flow_director_mask_port_src,
9205 (void *)&cmd_flow_director_mask_dst,
9206 (void *)&cmd_flow_director_mask_ipv4_dst,
9207 (void *)&cmd_flow_director_mask_ipv6_dst,
9208 (void *)&cmd_flow_director_mask_port_dst,
9213 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9214 .f = cmd_flow_director_mask_parsed,
9216 .help_str = "set MAC VLAN mode flow director's mask on NIC",
9218 (void *)&cmd_flow_director_mask,
9219 (void *)&cmd_flow_director_mask_port_id,
9220 (void *)&cmd_flow_director_mask_mode,
9221 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9222 (void *)&cmd_flow_director_mask_vlan,
9223 (void *)&cmd_flow_director_mask_vlan_value,
9224 (void *)&cmd_flow_director_mask_mac,
9225 (void *)&cmd_flow_director_mask_mac_value,
9230 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9231 .f = cmd_flow_director_mask_parsed,
9233 .help_str = "set tunnel mode flow director's mask on NIC",
9235 (void *)&cmd_flow_director_mask,
9236 (void *)&cmd_flow_director_mask_port_id,
9237 (void *)&cmd_flow_director_mask_mode,
9238 (void *)&cmd_flow_director_mask_mode_tunnel,
9239 (void *)&cmd_flow_director_mask_vlan,
9240 (void *)&cmd_flow_director_mask_vlan_value,
9241 (void *)&cmd_flow_director_mask_mac,
9242 (void *)&cmd_flow_director_mask_mac_value,
9243 (void *)&cmd_flow_director_mask_tunnel_type,
9244 (void *)&cmd_flow_director_mask_tunnel_type_value,
9245 (void *)&cmd_flow_director_mask_tunnel_id,
9246 (void *)&cmd_flow_director_mask_tunnel_id_value,
9251 /* *** deal with flow director mask on flexible payload *** */
9252 struct cmd_flow_director_flex_mask_result {
9253 cmdline_fixed_string_t flow_director_flexmask;
9255 cmdline_fixed_string_t flow;
9256 cmdline_fixed_string_t flow_type;
9257 cmdline_fixed_string_t mask;
9261 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9262 __attribute__((unused)) struct cmdline *cl,
9263 __attribute__((unused)) void *data)
9265 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9266 struct rte_eth_fdir_info fdir_info;
9267 struct rte_eth_fdir_flex_mask flex_mask;
9268 struct rte_port *port;
9269 uint32_t flow_type_mask;
9273 if (res->port_id > nb_ports) {
9274 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9278 port = &ports[res->port_id];
9279 /** Check if the port is not started **/
9280 if (port->port_status != RTE_PORT_STOPPED) {
9281 printf("Please stop port %d first\n", res->port_id);
9285 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9286 ret = parse_flexbytes(res->mask,
9288 RTE_ETH_FDIR_MAX_FLEXLEN);
9290 printf("error: Cannot parse mask input.\n");
9294 memset(&fdir_info, 0, sizeof(fdir_info));
9295 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9296 RTE_ETH_FILTER_INFO, &fdir_info);
9298 printf("Cannot get FDir filter info\n");
9302 if (!strcmp(res->flow_type, "none")) {
9303 /* means don't specify the flow type */
9304 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9305 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9306 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9307 0, sizeof(struct rte_eth_fdir_flex_mask));
9308 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9309 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9311 sizeof(struct rte_eth_fdir_flex_mask));
9312 cmd_reconfig_device_queue(res->port_id, 1, 1);
9315 flow_type_mask = fdir_info.flow_types_mask[0];
9316 if (!strcmp(res->flow_type, "all")) {
9317 if (!flow_type_mask) {
9318 printf("No flow type supported\n");
9321 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9322 if (flow_type_mask & (1 << i)) {
9323 flex_mask.flow_type = i;
9324 fdir_set_flex_mask(res->port_id, &flex_mask);
9327 cmd_reconfig_device_queue(res->port_id, 1, 1);
9330 flex_mask.flow_type = str2flowtype(res->flow_type);
9331 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9332 printf("Flow type %s not supported on port %d\n",
9333 res->flow_type, res->port_id);
9336 fdir_set_flex_mask(res->port_id, &flex_mask);
9337 cmd_reconfig_device_queue(res->port_id, 1, 1);
9340 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9342 flow_director_flexmask,
9343 "flow_director_flex_mask");
9344 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9345 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9347 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9350 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9352 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9353 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9354 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9355 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9358 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9359 .f = cmd_flow_director_flex_mask_parsed,
9361 .help_str = "set flow director's flex mask on NIC",
9363 (void *)&cmd_flow_director_flexmask,
9364 (void *)&cmd_flow_director_flexmask_port_id,
9365 (void *)&cmd_flow_director_flexmask_flow,
9366 (void *)&cmd_flow_director_flexmask_flow_type,
9367 (void *)&cmd_flow_director_flexmask_mask,
9372 /* *** deal with flow director flexible payload configuration *** */
9373 struct cmd_flow_director_flexpayload_result {
9374 cmdline_fixed_string_t flow_director_flexpayload;
9376 cmdline_fixed_string_t payload_layer;
9377 cmdline_fixed_string_t payload_cfg;
9381 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9384 const char *p, *p0 = q_arg;
9386 unsigned long int_fld;
9387 char *str_fld[max_num];
9392 p = strchr(p0, '(');
9396 p0 = strchr(p, ')');
9401 if (size >= sizeof(s))
9404 snprintf(s, sizeof(s), "%.*s", size, p);
9405 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9406 if (ret < 0 || ret > max_num)
9408 for (i = 0; i < ret; i++) {
9410 int_fld = strtoul(str_fld[i], &end, 0);
9411 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9413 offsets[i] = (uint16_t)int_fld;
9419 cmd_flow_director_flxpld_parsed(void *parsed_result,
9420 __attribute__((unused)) struct cmdline *cl,
9421 __attribute__((unused)) void *data)
9423 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9424 struct rte_eth_flex_payload_cfg flex_cfg;
9425 struct rte_port *port;
9428 if (res->port_id > nb_ports) {
9429 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9433 port = &ports[res->port_id];
9434 /** Check if the port is not started **/
9435 if (port->port_status != RTE_PORT_STOPPED) {
9436 printf("Please stop port %d first\n", res->port_id);
9440 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9442 if (!strcmp(res->payload_layer, "raw"))
9443 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9444 else if (!strcmp(res->payload_layer, "l2"))
9445 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9446 else if (!strcmp(res->payload_layer, "l3"))
9447 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9448 else if (!strcmp(res->payload_layer, "l4"))
9449 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9451 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9452 RTE_ETH_FDIR_MAX_FLEXLEN);
9454 printf("error: Cannot parse flex payload input.\n");
9458 fdir_set_flex_payload(res->port_id, &flex_cfg);
9459 cmd_reconfig_device_queue(res->port_id, 1, 1);
9462 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9463 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9464 flow_director_flexpayload,
9465 "flow_director_flex_payload");
9466 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9467 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9469 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9471 payload_layer, "raw#l2#l3#l4");
9472 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9476 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9477 .f = cmd_flow_director_flxpld_parsed,
9479 .help_str = "set flow director's flex payload on NIC",
9481 (void *)&cmd_flow_director_flexpayload,
9482 (void *)&cmd_flow_director_flexpayload_port_id,
9483 (void *)&cmd_flow_director_flexpayload_payload_layer,
9484 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9489 /* *** Classification Filters Control *** */
9490 /* *** Get symmetric hash enable per port *** */
9491 struct cmd_get_sym_hash_ena_per_port_result {
9492 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9497 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9498 __rte_unused struct cmdline *cl,
9499 __rte_unused void *data)
9501 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9502 struct rte_eth_hash_filter_info info;
9505 if (rte_eth_dev_filter_supported(res->port_id,
9506 RTE_ETH_FILTER_HASH) < 0) {
9507 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9512 memset(&info, 0, sizeof(info));
9513 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9514 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9515 RTE_ETH_FILTER_GET, &info);
9518 printf("Cannot get symmetric hash enable per port "
9519 "on port %u\n", res->port_id);
9523 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9524 "enabled" : "disabled", res->port_id);
9527 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9528 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9529 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9530 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9531 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9534 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9535 .f = cmd_get_sym_hash_per_port_parsed,
9537 .help_str = "get_sym_hash_ena_per_port port_id",
9539 (void *)&cmd_get_sym_hash_ena_per_port_all,
9540 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9545 /* *** Set symmetric hash enable per port *** */
9546 struct cmd_set_sym_hash_ena_per_port_result {
9547 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9548 cmdline_fixed_string_t enable;
9553 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9554 __rte_unused struct cmdline *cl,
9555 __rte_unused void *data)
9557 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9558 struct rte_eth_hash_filter_info info;
9561 if (rte_eth_dev_filter_supported(res->port_id,
9562 RTE_ETH_FILTER_HASH) < 0) {
9563 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9568 memset(&info, 0, sizeof(info));
9569 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9570 if (!strcmp(res->enable, "enable"))
9571 info.info.enable = 1;
9572 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9573 RTE_ETH_FILTER_SET, &info);
9575 printf("Cannot set symmetric hash enable per port on "
9576 "port %u\n", res->port_id);
9579 printf("Symmetric hash has been set to %s on port %u\n",
9580 res->enable, res->port_id);
9583 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9584 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9585 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9586 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9587 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9589 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9590 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9591 enable, "enable#disable");
9593 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9594 .f = cmd_set_sym_hash_per_port_parsed,
9596 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9598 (void *)&cmd_set_sym_hash_ena_per_port_all,
9599 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9600 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9605 /* Get global config of hash function */
9606 struct cmd_get_hash_global_config_result {
9607 cmdline_fixed_string_t get_hash_global_config;
9612 flowtype_to_str(uint16_t ftype)
9619 {"ipv4", RTE_ETH_FLOW_IPV4},
9620 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9621 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9622 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9623 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9624 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9625 {"ipv6", RTE_ETH_FLOW_IPV6},
9626 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9627 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9628 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9629 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9630 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9631 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9632 {"port", RTE_ETH_FLOW_PORT},
9633 {"vxlan", RTE_ETH_FLOW_VXLAN},
9634 {"geneve", RTE_ETH_FLOW_GENEVE},
9635 {"nvgre", RTE_ETH_FLOW_NVGRE},
9638 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9639 if (ftype_table[i].ftype == ftype)
9640 return ftype_table[i].str;
9647 cmd_get_hash_global_config_parsed(void *parsed_result,
9648 __rte_unused struct cmdline *cl,
9649 __rte_unused void *data)
9651 struct cmd_get_hash_global_config_result *res = parsed_result;
9652 struct rte_eth_hash_filter_info info;
9653 uint32_t idx, offset;
9658 if (rte_eth_dev_filter_supported(res->port_id,
9659 RTE_ETH_FILTER_HASH) < 0) {
9660 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9665 memset(&info, 0, sizeof(info));
9666 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9667 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9668 RTE_ETH_FILTER_GET, &info);
9670 printf("Cannot get hash global configurations by port %d\n",
9675 switch (info.info.global_conf.hash_func) {
9676 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9677 printf("Hash function is Toeplitz\n");
9679 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9680 printf("Hash function is Simple XOR\n");
9683 printf("Unknown hash function\n");
9687 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9688 idx = i / UINT32_BIT;
9689 offset = i % UINT32_BIT;
9690 if (!(info.info.global_conf.valid_bit_mask[idx] &
9693 str = flowtype_to_str(i);
9696 printf("Symmetric hash is %s globally for flow type %s "
9698 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9699 (1UL << offset)) ? "enabled" : "disabled"), str,
9704 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9705 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9706 get_hash_global_config, "get_hash_global_config");
9707 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9708 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9711 cmdline_parse_inst_t cmd_get_hash_global_config = {
9712 .f = cmd_get_hash_global_config_parsed,
9714 .help_str = "get_hash_global_config port_id",
9716 (void *)&cmd_get_hash_global_config_all,
9717 (void *)&cmd_get_hash_global_config_port_id,
9722 /* Set global config of hash function */
9723 struct cmd_set_hash_global_config_result {
9724 cmdline_fixed_string_t set_hash_global_config;
9726 cmdline_fixed_string_t hash_func;
9727 cmdline_fixed_string_t flow_type;
9728 cmdline_fixed_string_t enable;
9732 cmd_set_hash_global_config_parsed(void *parsed_result,
9733 __rte_unused struct cmdline *cl,
9734 __rte_unused void *data)
9736 struct cmd_set_hash_global_config_result *res = parsed_result;
9737 struct rte_eth_hash_filter_info info;
9738 uint32_t ftype, idx, offset;
9741 if (rte_eth_dev_filter_supported(res->port_id,
9742 RTE_ETH_FILTER_HASH) < 0) {
9743 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9747 memset(&info, 0, sizeof(info));
9748 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9749 if (!strcmp(res->hash_func, "toeplitz"))
9750 info.info.global_conf.hash_func =
9751 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9752 else if (!strcmp(res->hash_func, "simple_xor"))
9753 info.info.global_conf.hash_func =
9754 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9755 else if (!strcmp(res->hash_func, "default"))
9756 info.info.global_conf.hash_func =
9757 RTE_ETH_HASH_FUNCTION_DEFAULT;
9759 ftype = str2flowtype(res->flow_type);
9760 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9761 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9762 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9763 if (!strcmp(res->enable, "enable"))
9764 info.info.global_conf.sym_hash_enable_mask[idx] |=
9766 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9767 RTE_ETH_FILTER_SET, &info);
9769 printf("Cannot set global hash configurations by port %d\n",
9772 printf("Global hash configurations have been set "
9773 "succcessfully by port %d\n", res->port_id);
9776 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9777 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9778 set_hash_global_config, "set_hash_global_config");
9779 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9780 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9782 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9783 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9784 hash_func, "toeplitz#simple_xor#default");
9785 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9786 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9788 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9789 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9790 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9791 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9792 enable, "enable#disable");
9794 cmdline_parse_inst_t cmd_set_hash_global_config = {
9795 .f = cmd_set_hash_global_config_parsed,
9797 .help_str = "set_hash_global_config port_id "
9798 "toeplitz|simple_xor|default "
9799 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9800 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9803 (void *)&cmd_set_hash_global_config_all,
9804 (void *)&cmd_set_hash_global_config_port_id,
9805 (void *)&cmd_set_hash_global_config_hash_func,
9806 (void *)&cmd_set_hash_global_config_flow_type,
9807 (void *)&cmd_set_hash_global_config_enable,
9812 /* Set hash input set */
9813 struct cmd_set_hash_input_set_result {
9814 cmdline_fixed_string_t set_hash_input_set;
9816 cmdline_fixed_string_t flow_type;
9817 cmdline_fixed_string_t inset_field;
9818 cmdline_fixed_string_t select;
9821 static enum rte_eth_input_set_field
9822 str2inset(char *string)
9826 static const struct {
9828 enum rte_eth_input_set_field inset;
9830 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9831 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9832 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9833 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9834 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9835 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9836 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9837 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9838 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9839 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9840 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9841 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9842 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9843 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9844 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9845 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9846 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9847 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9848 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9849 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9850 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9851 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9852 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9853 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9854 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9855 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9856 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9857 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9858 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9859 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9860 {"none", RTE_ETH_INPUT_SET_NONE},
9863 for (i = 0; i < RTE_DIM(inset_table); i++) {
9864 if (!strcmp(string, inset_table[i].str))
9865 return inset_table[i].inset;
9868 return RTE_ETH_INPUT_SET_UNKNOWN;
9872 cmd_set_hash_input_set_parsed(void *parsed_result,
9873 __rte_unused struct cmdline *cl,
9874 __rte_unused void *data)
9876 struct cmd_set_hash_input_set_result *res = parsed_result;
9877 struct rte_eth_hash_filter_info info;
9879 memset(&info, 0, sizeof(info));
9880 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9881 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9882 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9883 info.info.input_set_conf.inset_size = 1;
9884 if (!strcmp(res->select, "select"))
9885 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9886 else if (!strcmp(res->select, "add"))
9887 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9888 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9889 RTE_ETH_FILTER_SET, &info);
9892 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9893 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9894 set_hash_input_set, "set_hash_input_set");
9895 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9896 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9898 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9899 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9901 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9902 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9903 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9904 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9906 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9907 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9908 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9909 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9910 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9912 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9913 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9914 select, "select#add");
9916 cmdline_parse_inst_t cmd_set_hash_input_set = {
9917 .f = cmd_set_hash_input_set_parsed,
9919 .help_str = "set_hash_input_set <port_id> "
9920 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9921 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9922 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9923 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9924 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9925 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9926 "fld-7th|fld-8th|none select|add",
9928 (void *)&cmd_set_hash_input_set_cmd,
9929 (void *)&cmd_set_hash_input_set_port_id,
9930 (void *)&cmd_set_hash_input_set_flow_type,
9931 (void *)&cmd_set_hash_input_set_field,
9932 (void *)&cmd_set_hash_input_set_select,
9937 /* Set flow director input set */
9938 struct cmd_set_fdir_input_set_result {
9939 cmdline_fixed_string_t set_fdir_input_set;
9941 cmdline_fixed_string_t flow_type;
9942 cmdline_fixed_string_t inset_field;
9943 cmdline_fixed_string_t select;
9947 cmd_set_fdir_input_set_parsed(void *parsed_result,
9948 __rte_unused struct cmdline *cl,
9949 __rte_unused void *data)
9951 struct cmd_set_fdir_input_set_result *res = parsed_result;
9952 struct rte_eth_fdir_filter_info info;
9954 memset(&info, 0, sizeof(info));
9955 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9956 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9957 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9958 info.info.input_set_conf.inset_size = 1;
9959 if (!strcmp(res->select, "select"))
9960 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9961 else if (!strcmp(res->select, "add"))
9962 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9963 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9964 RTE_ETH_FILTER_SET, &info);
9967 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9968 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9969 set_fdir_input_set, "set_fdir_input_set");
9970 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9971 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9973 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9974 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9976 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9977 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9978 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9979 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9981 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9982 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
9983 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
9984 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9985 "sctp-veri-tag#none");
9986 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9987 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9988 select, "select#add");
9990 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9991 .f = cmd_set_fdir_input_set_parsed,
9993 .help_str = "set_fdir_input_set <port_id> "
9994 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9995 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9996 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
9997 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
9998 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
9999 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10000 "sctp-veri-tag|none select|add",
10002 (void *)&cmd_set_fdir_input_set_cmd,
10003 (void *)&cmd_set_fdir_input_set_port_id,
10004 (void *)&cmd_set_fdir_input_set_flow_type,
10005 (void *)&cmd_set_fdir_input_set_field,
10006 (void *)&cmd_set_fdir_input_set_select,
10011 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10012 struct cmd_mcast_addr_result {
10013 cmdline_fixed_string_t mcast_addr_cmd;
10014 cmdline_fixed_string_t what;
10016 struct ether_addr mc_addr;
10019 static void cmd_mcast_addr_parsed(void *parsed_result,
10020 __attribute__((unused)) struct cmdline *cl,
10021 __attribute__((unused)) void *data)
10023 struct cmd_mcast_addr_result *res = parsed_result;
10025 if (!is_multicast_ether_addr(&res->mc_addr)) {
10026 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10027 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10028 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10029 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10032 if (strcmp(res->what, "add") == 0)
10033 mcast_addr_add(res->port_num, &res->mc_addr);
10035 mcast_addr_remove(res->port_num, &res->mc_addr);
10038 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10039 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10040 mcast_addr_cmd, "mcast_addr");
10041 cmdline_parse_token_string_t cmd_mcast_addr_what =
10042 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10044 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10045 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10046 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10047 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10049 cmdline_parse_inst_t cmd_mcast_addr = {
10050 .f = cmd_mcast_addr_parsed,
10052 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
10054 (void *)&cmd_mcast_addr_cmd,
10055 (void *)&cmd_mcast_addr_what,
10056 (void *)&cmd_mcast_addr_portnum,
10057 (void *)&cmd_mcast_addr_addr,
10062 /* l2 tunnel config
10063 * only support E-tag now.
10066 /* Ether type config */
10067 struct cmd_config_l2_tunnel_eth_type_result {
10068 cmdline_fixed_string_t port;
10069 cmdline_fixed_string_t config;
10070 cmdline_fixed_string_t all;
10072 cmdline_fixed_string_t l2_tunnel;
10073 cmdline_fixed_string_t l2_tunnel_type;
10074 cmdline_fixed_string_t eth_type;
10075 uint16_t eth_type_val;
10078 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10079 TOKEN_STRING_INITIALIZER
10080 (struct cmd_config_l2_tunnel_eth_type_result,
10082 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10083 TOKEN_STRING_INITIALIZER
10084 (struct cmd_config_l2_tunnel_eth_type_result,
10086 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10087 TOKEN_STRING_INITIALIZER
10088 (struct cmd_config_l2_tunnel_eth_type_result,
10090 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10091 TOKEN_NUM_INITIALIZER
10092 (struct cmd_config_l2_tunnel_eth_type_result,
10094 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10095 TOKEN_STRING_INITIALIZER
10096 (struct cmd_config_l2_tunnel_eth_type_result,
10097 l2_tunnel, "l2-tunnel");
10098 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10099 TOKEN_STRING_INITIALIZER
10100 (struct cmd_config_l2_tunnel_eth_type_result,
10101 l2_tunnel_type, "E-tag");
10102 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10103 TOKEN_STRING_INITIALIZER
10104 (struct cmd_config_l2_tunnel_eth_type_result,
10105 eth_type, "ether-type");
10106 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10107 TOKEN_NUM_INITIALIZER
10108 (struct cmd_config_l2_tunnel_eth_type_result,
10109 eth_type_val, UINT16);
10111 static enum rte_eth_tunnel_type
10112 str2fdir_l2_tunnel_type(char *string)
10116 static const struct {
10118 enum rte_eth_tunnel_type type;
10119 } l2_tunnel_type_str[] = {
10120 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10123 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10124 if (!strcmp(l2_tunnel_type_str[i].str, string))
10125 return l2_tunnel_type_str[i].type;
10127 return RTE_TUNNEL_TYPE_NONE;
10130 /* ether type config for all ports */
10132 cmd_config_l2_tunnel_eth_type_all_parsed
10133 (void *parsed_result,
10134 __attribute__((unused)) struct cmdline *cl,
10135 __attribute__((unused)) void *data)
10137 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10138 struct rte_eth_l2_tunnel_conf entry;
10141 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10142 entry.ether_type = res->eth_type_val;
10144 FOREACH_PORT(pid, ports) {
10145 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10149 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10150 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10152 .help_str = "port config all l2-tunnel ether-type",
10154 (void *)&cmd_config_l2_tunnel_eth_type_port,
10155 (void *)&cmd_config_l2_tunnel_eth_type_config,
10156 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10157 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10158 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10159 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10160 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10165 /* ether type config for a specific port */
10167 cmd_config_l2_tunnel_eth_type_specific_parsed(
10168 void *parsed_result,
10169 __attribute__((unused)) struct cmdline *cl,
10170 __attribute__((unused)) void *data)
10172 struct cmd_config_l2_tunnel_eth_type_result *res =
10174 struct rte_eth_l2_tunnel_conf entry;
10176 if (port_id_is_invalid(res->id, ENABLED_WARN))
10179 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10180 entry.ether_type = res->eth_type_val;
10182 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10185 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10186 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10188 .help_str = "port config l2-tunnel ether-type",
10190 (void *)&cmd_config_l2_tunnel_eth_type_port,
10191 (void *)&cmd_config_l2_tunnel_eth_type_config,
10192 (void *)&cmd_config_l2_tunnel_eth_type_id,
10193 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10194 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10195 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10196 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10201 /* Enable/disable l2 tunnel */
10202 struct cmd_config_l2_tunnel_en_dis_result {
10203 cmdline_fixed_string_t port;
10204 cmdline_fixed_string_t config;
10205 cmdline_fixed_string_t all;
10207 cmdline_fixed_string_t l2_tunnel;
10208 cmdline_fixed_string_t l2_tunnel_type;
10209 cmdline_fixed_string_t en_dis;
10212 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10213 TOKEN_STRING_INITIALIZER
10214 (struct cmd_config_l2_tunnel_en_dis_result,
10216 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10217 TOKEN_STRING_INITIALIZER
10218 (struct cmd_config_l2_tunnel_en_dis_result,
10220 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10221 TOKEN_STRING_INITIALIZER
10222 (struct cmd_config_l2_tunnel_en_dis_result,
10224 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10225 TOKEN_NUM_INITIALIZER
10226 (struct cmd_config_l2_tunnel_en_dis_result,
10228 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10229 TOKEN_STRING_INITIALIZER
10230 (struct cmd_config_l2_tunnel_en_dis_result,
10231 l2_tunnel, "l2-tunnel");
10232 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10233 TOKEN_STRING_INITIALIZER
10234 (struct cmd_config_l2_tunnel_en_dis_result,
10235 l2_tunnel_type, "E-tag");
10236 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10237 TOKEN_STRING_INITIALIZER
10238 (struct cmd_config_l2_tunnel_en_dis_result,
10239 en_dis, "enable#disable");
10241 /* enable/disable l2 tunnel for all ports */
10243 cmd_config_l2_tunnel_en_dis_all_parsed(
10244 void *parsed_result,
10245 __attribute__((unused)) struct cmdline *cl,
10246 __attribute__((unused)) void *data)
10248 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10249 struct rte_eth_l2_tunnel_conf entry;
10253 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10255 if (!strcmp("enable", res->en_dis))
10260 FOREACH_PORT(pid, ports) {
10261 rte_eth_dev_l2_tunnel_offload_set(pid,
10263 ETH_L2_TUNNEL_ENABLE_MASK,
10268 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10269 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10271 .help_str = "port config all l2-tunnel enable/disable",
10273 (void *)&cmd_config_l2_tunnel_en_dis_port,
10274 (void *)&cmd_config_l2_tunnel_en_dis_config,
10275 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10276 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10277 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10278 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10283 /* enable/disable l2 tunnel for a port */
10285 cmd_config_l2_tunnel_en_dis_specific_parsed(
10286 void *parsed_result,
10287 __attribute__((unused)) struct cmdline *cl,
10288 __attribute__((unused)) void *data)
10290 struct cmd_config_l2_tunnel_en_dis_result *res =
10292 struct rte_eth_l2_tunnel_conf entry;
10294 if (port_id_is_invalid(res->id, ENABLED_WARN))
10297 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10299 if (!strcmp("enable", res->en_dis))
10300 rte_eth_dev_l2_tunnel_offload_set(res->id,
10302 ETH_L2_TUNNEL_ENABLE_MASK,
10305 rte_eth_dev_l2_tunnel_offload_set(res->id,
10307 ETH_L2_TUNNEL_ENABLE_MASK,
10311 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10312 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10314 .help_str = "port config l2-tunnel enable/disable",
10316 (void *)&cmd_config_l2_tunnel_en_dis_port,
10317 (void *)&cmd_config_l2_tunnel_en_dis_config,
10318 (void *)&cmd_config_l2_tunnel_en_dis_id,
10319 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10320 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10321 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10326 /* E-tag configuration */
10328 /* Common result structure for all E-tag configuration */
10329 struct cmd_config_e_tag_result {
10330 cmdline_fixed_string_t e_tag;
10331 cmdline_fixed_string_t set;
10332 cmdline_fixed_string_t insertion;
10333 cmdline_fixed_string_t stripping;
10334 cmdline_fixed_string_t forwarding;
10335 cmdline_fixed_string_t filter;
10336 cmdline_fixed_string_t add;
10337 cmdline_fixed_string_t del;
10338 cmdline_fixed_string_t on;
10339 cmdline_fixed_string_t off;
10340 cmdline_fixed_string_t on_off;
10341 cmdline_fixed_string_t port_tag_id;
10342 uint32_t port_tag_id_val;
10343 cmdline_fixed_string_t e_tag_id;
10344 uint16_t e_tag_id_val;
10345 cmdline_fixed_string_t dst_pool;
10346 uint8_t dst_pool_val;
10347 cmdline_fixed_string_t port;
10349 cmdline_fixed_string_t vf;
10353 /* Common CLI fields for all E-tag configuration */
10354 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10355 TOKEN_STRING_INITIALIZER
10356 (struct cmd_config_e_tag_result,
10358 cmdline_parse_token_string_t cmd_config_e_tag_set =
10359 TOKEN_STRING_INITIALIZER
10360 (struct cmd_config_e_tag_result,
10362 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10363 TOKEN_STRING_INITIALIZER
10364 (struct cmd_config_e_tag_result,
10365 insertion, "insertion");
10366 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10367 TOKEN_STRING_INITIALIZER
10368 (struct cmd_config_e_tag_result,
10369 stripping, "stripping");
10370 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10371 TOKEN_STRING_INITIALIZER
10372 (struct cmd_config_e_tag_result,
10373 forwarding, "forwarding");
10374 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10375 TOKEN_STRING_INITIALIZER
10376 (struct cmd_config_e_tag_result,
10378 cmdline_parse_token_string_t cmd_config_e_tag_add =
10379 TOKEN_STRING_INITIALIZER
10380 (struct cmd_config_e_tag_result,
10382 cmdline_parse_token_string_t cmd_config_e_tag_del =
10383 TOKEN_STRING_INITIALIZER
10384 (struct cmd_config_e_tag_result,
10386 cmdline_parse_token_string_t cmd_config_e_tag_on =
10387 TOKEN_STRING_INITIALIZER
10388 (struct cmd_config_e_tag_result,
10390 cmdline_parse_token_string_t cmd_config_e_tag_off =
10391 TOKEN_STRING_INITIALIZER
10392 (struct cmd_config_e_tag_result,
10394 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10395 TOKEN_STRING_INITIALIZER
10396 (struct cmd_config_e_tag_result,
10398 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10399 TOKEN_STRING_INITIALIZER
10400 (struct cmd_config_e_tag_result,
10401 port_tag_id, "port-tag-id");
10402 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10403 TOKEN_NUM_INITIALIZER
10404 (struct cmd_config_e_tag_result,
10405 port_tag_id_val, UINT32);
10406 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10407 TOKEN_STRING_INITIALIZER
10408 (struct cmd_config_e_tag_result,
10409 e_tag_id, "e-tag-id");
10410 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10411 TOKEN_NUM_INITIALIZER
10412 (struct cmd_config_e_tag_result,
10413 e_tag_id_val, UINT16);
10414 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10415 TOKEN_STRING_INITIALIZER
10416 (struct cmd_config_e_tag_result,
10417 dst_pool, "dst-pool");
10418 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10419 TOKEN_NUM_INITIALIZER
10420 (struct cmd_config_e_tag_result,
10421 dst_pool_val, UINT8);
10422 cmdline_parse_token_string_t cmd_config_e_tag_port =
10423 TOKEN_STRING_INITIALIZER
10424 (struct cmd_config_e_tag_result,
10426 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10427 TOKEN_NUM_INITIALIZER
10428 (struct cmd_config_e_tag_result,
10430 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10431 TOKEN_STRING_INITIALIZER
10432 (struct cmd_config_e_tag_result,
10434 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10435 TOKEN_NUM_INITIALIZER
10436 (struct cmd_config_e_tag_result,
10439 /* E-tag insertion configuration */
10441 cmd_config_e_tag_insertion_en_parsed(
10442 void *parsed_result,
10443 __attribute__((unused)) struct cmdline *cl,
10444 __attribute__((unused)) void *data)
10446 struct cmd_config_e_tag_result *res =
10448 struct rte_eth_l2_tunnel_conf entry;
10450 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10453 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10454 entry.tunnel_id = res->port_tag_id_val;
10455 entry.vf_id = res->vf_id;
10456 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10458 ETH_L2_TUNNEL_INSERTION_MASK,
10463 cmd_config_e_tag_insertion_dis_parsed(
10464 void *parsed_result,
10465 __attribute__((unused)) struct cmdline *cl,
10466 __attribute__((unused)) void *data)
10468 struct cmd_config_e_tag_result *res =
10470 struct rte_eth_l2_tunnel_conf entry;
10472 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10475 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10476 entry.vf_id = res->vf_id;
10478 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10480 ETH_L2_TUNNEL_INSERTION_MASK,
10484 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10485 .f = cmd_config_e_tag_insertion_en_parsed,
10487 .help_str = "E-tag insertion enable",
10489 (void *)&cmd_config_e_tag_e_tag,
10490 (void *)&cmd_config_e_tag_set,
10491 (void *)&cmd_config_e_tag_insertion,
10492 (void *)&cmd_config_e_tag_on,
10493 (void *)&cmd_config_e_tag_port_tag_id,
10494 (void *)&cmd_config_e_tag_port_tag_id_val,
10495 (void *)&cmd_config_e_tag_port,
10496 (void *)&cmd_config_e_tag_port_id,
10497 (void *)&cmd_config_e_tag_vf,
10498 (void *)&cmd_config_e_tag_vf_id,
10503 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10504 .f = cmd_config_e_tag_insertion_dis_parsed,
10506 .help_str = "E-tag insertion disable",
10508 (void *)&cmd_config_e_tag_e_tag,
10509 (void *)&cmd_config_e_tag_set,
10510 (void *)&cmd_config_e_tag_insertion,
10511 (void *)&cmd_config_e_tag_off,
10512 (void *)&cmd_config_e_tag_port,
10513 (void *)&cmd_config_e_tag_port_id,
10514 (void *)&cmd_config_e_tag_vf,
10515 (void *)&cmd_config_e_tag_vf_id,
10520 /* E-tag stripping configuration */
10522 cmd_config_e_tag_stripping_parsed(
10523 void *parsed_result,
10524 __attribute__((unused)) struct cmdline *cl,
10525 __attribute__((unused)) void *data)
10527 struct cmd_config_e_tag_result *res =
10529 struct rte_eth_l2_tunnel_conf entry;
10531 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10534 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10536 if (!strcmp(res->on_off, "on"))
10537 rte_eth_dev_l2_tunnel_offload_set
10540 ETH_L2_TUNNEL_STRIPPING_MASK,
10543 rte_eth_dev_l2_tunnel_offload_set
10546 ETH_L2_TUNNEL_STRIPPING_MASK,
10550 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10551 .f = cmd_config_e_tag_stripping_parsed,
10553 .help_str = "E-tag stripping enable/disable",
10555 (void *)&cmd_config_e_tag_e_tag,
10556 (void *)&cmd_config_e_tag_set,
10557 (void *)&cmd_config_e_tag_stripping,
10558 (void *)&cmd_config_e_tag_on_off,
10559 (void *)&cmd_config_e_tag_port,
10560 (void *)&cmd_config_e_tag_port_id,
10565 /* E-tag forwarding configuration */
10567 cmd_config_e_tag_forwarding_parsed(
10568 void *parsed_result,
10569 __attribute__((unused)) struct cmdline *cl,
10570 __attribute__((unused)) void *data)
10572 struct cmd_config_e_tag_result *res = parsed_result;
10573 struct rte_eth_l2_tunnel_conf entry;
10575 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10578 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10580 if (!strcmp(res->on_off, "on"))
10581 rte_eth_dev_l2_tunnel_offload_set
10584 ETH_L2_TUNNEL_FORWARDING_MASK,
10587 rte_eth_dev_l2_tunnel_offload_set
10590 ETH_L2_TUNNEL_FORWARDING_MASK,
10594 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10595 .f = cmd_config_e_tag_forwarding_parsed,
10597 .help_str = "E-tag forwarding enable/disable",
10599 (void *)&cmd_config_e_tag_e_tag,
10600 (void *)&cmd_config_e_tag_set,
10601 (void *)&cmd_config_e_tag_forwarding,
10602 (void *)&cmd_config_e_tag_on_off,
10603 (void *)&cmd_config_e_tag_port,
10604 (void *)&cmd_config_e_tag_port_id,
10609 /* E-tag filter configuration */
10611 cmd_config_e_tag_filter_add_parsed(
10612 void *parsed_result,
10613 __attribute__((unused)) struct cmdline *cl,
10614 __attribute__((unused)) void *data)
10616 struct cmd_config_e_tag_result *res = parsed_result;
10617 struct rte_eth_l2_tunnel_conf entry;
10620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10623 if (res->e_tag_id_val > 0x3fff) {
10624 printf("e-tag-id must be equal or less than 0x3fff.\n");
10628 ret = rte_eth_dev_filter_supported(res->port_id,
10629 RTE_ETH_FILTER_L2_TUNNEL);
10631 printf("E-tag filter is not supported on port %u.\n",
10636 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10637 entry.tunnel_id = res->e_tag_id_val;
10638 entry.pool = res->dst_pool_val;
10640 ret = rte_eth_dev_filter_ctrl(res->port_id,
10641 RTE_ETH_FILTER_L2_TUNNEL,
10642 RTE_ETH_FILTER_ADD,
10645 printf("E-tag filter programming error: (%s)\n",
10649 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10650 .f = cmd_config_e_tag_filter_add_parsed,
10652 .help_str = "E-tag filter add",
10654 (void *)&cmd_config_e_tag_e_tag,
10655 (void *)&cmd_config_e_tag_set,
10656 (void *)&cmd_config_e_tag_filter,
10657 (void *)&cmd_config_e_tag_add,
10658 (void *)&cmd_config_e_tag_e_tag_id,
10659 (void *)&cmd_config_e_tag_e_tag_id_val,
10660 (void *)&cmd_config_e_tag_dst_pool,
10661 (void *)&cmd_config_e_tag_dst_pool_val,
10662 (void *)&cmd_config_e_tag_port,
10663 (void *)&cmd_config_e_tag_port_id,
10669 cmd_config_e_tag_filter_del_parsed(
10670 void *parsed_result,
10671 __attribute__((unused)) struct cmdline *cl,
10672 __attribute__((unused)) void *data)
10674 struct cmd_config_e_tag_result *res = parsed_result;
10675 struct rte_eth_l2_tunnel_conf entry;
10678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10681 if (res->e_tag_id_val > 0x3fff) {
10682 printf("e-tag-id must be less than 0x3fff.\n");
10686 ret = rte_eth_dev_filter_supported(res->port_id,
10687 RTE_ETH_FILTER_L2_TUNNEL);
10689 printf("E-tag filter is not supported on port %u.\n",
10694 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10695 entry.tunnel_id = res->e_tag_id_val;
10697 ret = rte_eth_dev_filter_ctrl(res->port_id,
10698 RTE_ETH_FILTER_L2_TUNNEL,
10699 RTE_ETH_FILTER_DELETE,
10702 printf("E-tag filter programming error: (%s)\n",
10706 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10707 .f = cmd_config_e_tag_filter_del_parsed,
10709 .help_str = "E-tag filter delete",
10711 (void *)&cmd_config_e_tag_e_tag,
10712 (void *)&cmd_config_e_tag_set,
10713 (void *)&cmd_config_e_tag_filter,
10714 (void *)&cmd_config_e_tag_del,
10715 (void *)&cmd_config_e_tag_e_tag_id,
10716 (void *)&cmd_config_e_tag_e_tag_id_val,
10717 (void *)&cmd_config_e_tag_port,
10718 (void *)&cmd_config_e_tag_port_id,
10723 /* ******************************************************************************** */
10725 /* list of instructions */
10726 cmdline_parse_ctx_t main_ctx[] = {
10727 (cmdline_parse_inst_t *)&cmd_help_brief,
10728 (cmdline_parse_inst_t *)&cmd_help_long,
10729 (cmdline_parse_inst_t *)&cmd_quit,
10730 (cmdline_parse_inst_t *)&cmd_showport,
10731 (cmdline_parse_inst_t *)&cmd_showqueue,
10732 (cmdline_parse_inst_t *)&cmd_showportall,
10733 (cmdline_parse_inst_t *)&cmd_showcfg,
10734 (cmdline_parse_inst_t *)&cmd_start,
10735 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10736 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
10737 (cmdline_parse_inst_t *)&cmd_set_link_up,
10738 (cmdline_parse_inst_t *)&cmd_set_link_down,
10739 (cmdline_parse_inst_t *)&cmd_reset,
10740 (cmdline_parse_inst_t *)&cmd_set_numbers,
10741 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10742 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10743 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10744 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10745 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10746 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
10747 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10748 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10749 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10750 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10751 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10752 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10753 (cmdline_parse_inst_t *)&cmd_set_link_check,
10754 #ifdef RTE_NIC_BYPASS
10755 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10756 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10757 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10758 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10760 #ifdef RTE_LIBRTE_PMD_BOND
10761 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10762 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10763 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10764 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10765 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10766 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10767 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10768 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10769 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10771 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10772 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10773 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10774 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10775 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10776 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10777 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10778 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10779 (cmdline_parse_inst_t *)&cmd_csum_set,
10780 (cmdline_parse_inst_t *)&cmd_csum_show,
10781 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10782 (cmdline_parse_inst_t *)&cmd_tso_set,
10783 (cmdline_parse_inst_t *)&cmd_tso_show,
10784 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
10785 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
10786 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10787 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10788 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10789 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10790 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10791 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10792 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10793 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10794 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10795 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10796 (cmdline_parse_inst_t *)&cmd_config_dcb,
10797 (cmdline_parse_inst_t *)&cmd_read_reg,
10798 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10799 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10800 (cmdline_parse_inst_t *)&cmd_write_reg,
10801 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10802 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10803 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10804 (cmdline_parse_inst_t *)&cmd_stop,
10805 (cmdline_parse_inst_t *)&cmd_mac_addr,
10806 (cmdline_parse_inst_t *)&cmd_set_qmap,
10807 (cmdline_parse_inst_t *)&cmd_operate_port,
10808 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10809 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10810 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10811 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10812 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10813 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10814 (cmdline_parse_inst_t *)&cmd_config_mtu,
10815 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10816 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10817 (cmdline_parse_inst_t *)&cmd_config_rss,
10818 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10819 (cmdline_parse_inst_t *)&cmd_config_txqflags,
10820 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10821 (cmdline_parse_inst_t *)&cmd_showport_reta,
10822 (cmdline_parse_inst_t *)&cmd_config_burst,
10823 (cmdline_parse_inst_t *)&cmd_config_thresh,
10824 (cmdline_parse_inst_t *)&cmd_config_threshold,
10825 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10826 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10827 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10828 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10829 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10830 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10831 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10832 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10833 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10834 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10835 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10836 (cmdline_parse_inst_t *)&cmd_global_config,
10837 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10838 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10839 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10840 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10841 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10842 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10843 (cmdline_parse_inst_t *)&cmd_dump,
10844 (cmdline_parse_inst_t *)&cmd_dump_one,
10845 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10846 (cmdline_parse_inst_t *)&cmd_syn_filter,
10847 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10848 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10849 (cmdline_parse_inst_t *)&cmd_flex_filter,
10850 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10851 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10852 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10853 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10854 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10855 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10856 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10857 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10858 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10859 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10860 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10861 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10862 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10863 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10864 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10865 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10866 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10867 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10868 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10869 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10870 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10871 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10872 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10873 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10874 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10875 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10876 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10877 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10878 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10882 /* prompt function, called from main on MASTER lcore */
10886 /* initialize non-constant commands */
10887 cmd_set_fwd_mode_init();
10888 cmd_set_fwd_retry_mode_init();
10890 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10891 if (testpmd_cl == NULL)
10893 cmdline_interact(testpmd_cl);
10894 cmdline_stdin_exit(testpmd_cl);
10900 if (testpmd_cl != NULL)
10901 cmdline_quit(testpmd_cl);
10905 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10907 if (id == (portid_t)RTE_PORT_ALL) {
10910 FOREACH_PORT(pid, ports) {
10911 /* check if need_reconfig has been set to 1 */
10912 if (ports[pid].need_reconfig == 0)
10913 ports[pid].need_reconfig = dev;
10914 /* check if need_reconfig_queues has been set to 1 */
10915 if (ports[pid].need_reconfig_queues == 0)
10916 ports[pid].need_reconfig_queues = queue;
10918 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10919 /* check if need_reconfig has been set to 1 */
10920 if (ports[id].need_reconfig == 0)
10921 ports[id].need_reconfig = dev;
10922 /* check if need_reconfig_queues has been set to 1 */
10923 if (ports[id].need_reconfig_queues == 0)
10924 ports[id].need_reconfig_queues = queue;