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>
90 #ifdef RTE_LIBRTE_IXGBE_PMD
91 #include <rte_pmd_ixgbe.h>
95 static struct cmdline *testpmd_cl;
97 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
99 /* *** Help command with introduction. *** */
100 struct cmd_help_brief_result {
101 cmdline_fixed_string_t help;
104 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
106 __attribute__((unused)) void *data)
111 "Help is available for the following sections:\n\n"
112 " help control : Start and stop forwarding.\n"
113 " help display : Displaying port, stats and config "
115 " help config : Configuration information.\n"
116 " help ports : Configuring ports.\n"
117 " help registers : Reading and setting port registers.\n"
118 " help filters : Filters configuration help.\n"
119 " help all : All of the above sections.\n\n"
124 cmdline_parse_token_string_t cmd_help_brief_help =
125 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
127 cmdline_parse_inst_t cmd_help_brief = {
128 .f = cmd_help_brief_parsed,
130 .help_str = "help: Show help",
132 (void *)&cmd_help_brief_help,
137 /* *** Help command with help sections. *** */
138 struct cmd_help_long_result {
139 cmdline_fixed_string_t help;
140 cmdline_fixed_string_t section;
143 static void cmd_help_long_parsed(void *parsed_result,
145 __attribute__((unused)) void *data)
148 struct cmd_help_long_result *res = parsed_result;
150 if (!strcmp(res->section, "all"))
153 if (show_all || !strcmp(res->section, "control")) {
158 "Control forwarding:\n"
159 "-------------------\n\n"
162 " Start packet forwarding with current configuration.\n\n"
165 " Start packet forwarding with current config"
166 " after sending one burst of packets.\n\n"
169 " Stop packet forwarding, and display accumulated"
173 " Quit to prompt.\n\n"
177 if (show_all || !strcmp(res->section, "display")) {
185 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
186 " Display information for port_id, or all.\n\n"
188 "show port X rss reta (size) (mask0,mask1,...)\n"
189 " Display the rss redirection table entry indicated"
190 " by masks on port X. size is used to indicate the"
191 " hardware supported reta size\n\n"
193 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
194 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
195 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
196 " Display the RSS hash functions and RSS hash key"
199 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
200 " Clear information for port_id, or all.\n\n"
202 "show (rxq|txq) info (port_id) (queue_id)\n"
203 " Display information for configured RX/TX queue.\n\n"
205 "show config (rxtx|cores|fwd|txpkts)\n"
206 " Display the given configuration.\n\n"
208 "read rxd (port_id) (queue_id) (rxd_id)\n"
209 " Display an RX descriptor of a port RX queue.\n\n"
211 "read txd (port_id) (queue_id) (txd_id)\n"
212 " Display a TX descriptor of a port TX queue.\n\n"
216 if (show_all || !strcmp(res->section, "config")) {
222 "Configuration changes only become active when"
223 " forwarding is started/restarted.\n\n"
226 " Reset forwarding to the default configuration.\n\n"
228 "set verbose (level)\n"
229 " Set the debug verbosity level X.\n\n"
232 " Set number of ports.\n\n"
235 " Set number of cores.\n\n"
237 "set coremask (mask)\n"
238 " Set the forwarding cores hexadecimal mask.\n\n"
240 "set portmask (mask)\n"
241 " Set the forwarding ports hexadecimal mask.\n\n"
244 " Set number of packets per burst.\n\n"
246 "set burst tx delay (microseconds) retry (num)\n"
247 " Set the transmit delay time and number of retries,"
248 " effective when retry is enabled.\n\n"
250 "set txpkts (x[,y]*)\n"
251 " Set the length of each segment of TXONLY"
252 " and optionally CSUM packets.\n\n"
254 "set txsplit (off|on|rand)\n"
255 " Set the split policy for the TX packets."
256 " Right now only applicable for CSUM and TXONLY"
259 "set corelist (x[,y]*)\n"
260 " Set the list of forwarding cores.\n\n"
262 "set portlist (x[,y]*)\n"
263 " Set the list of forwarding ports.\n\n"
265 #ifdef RTE_LIBRTE_IXGBE_PMD
266 "set tx loopback (port_id) (on|off)\n"
267 " Enable or disable tx loopback.\n\n"
269 "set all queues drop (port_id) (on|off)\n"
270 " Set drop enable bit for all queues.\n\n"
272 "set vf split drop (port_id) (vf_id) (on|off)\n"
273 " Set split drop enable bit for a VF from the PF.\n\n"
275 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
276 " Set MAC antispoof for a VF from the PF.\n\n"
279 "vlan set strip (on|off) (port_id)\n"
280 " Set the VLAN strip on a port.\n\n"
282 "vlan set stripq (on|off) (port_id,queue_id)\n"
283 " Set the VLAN strip for a queue on a port.\n\n"
285 #ifdef RTE_LIBRTE_IXGBE_PMD
286 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
287 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
289 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
290 " Set VLAN insert for a VF from the PF.\n\n"
292 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
293 " Set VLAN antispoof for a VF from the PF.\n\n"
296 "vlan set filter (on|off) (port_id)\n"
297 " Set the VLAN filter on a port.\n\n"
299 "vlan set qinq (on|off) (port_id)\n"
300 " Set the VLAN QinQ (extended queue in queue)"
303 "vlan set (inner|outer) tpid (value) (port_id)\n"
304 " Set the VLAN TPID for Packet Filtering on"
307 "rx_vlan add (vlan_id|all) (port_id)\n"
308 " Add a vlan_id, or all identifiers, to the set"
309 " of VLAN identifiers filtered by port_id.\n\n"
311 "rx_vlan rm (vlan_id|all) (port_id)\n"
312 " Remove a vlan_id, or all identifiers, from the set"
313 " of VLAN identifiers filtered by port_id.\n\n"
315 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
316 " Add a vlan_id, to the set of VLAN identifiers"
317 "filtered for VF(s) from port_id.\n\n"
319 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
320 " Remove a vlan_id, to the set of VLAN identifiers"
321 "filtered for VF(s) from port_id.\n\n"
323 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
324 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
325 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
326 " add a tunnel filter of a port.\n\n"
328 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
329 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
330 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
331 " remove a tunnel filter of a port.\n\n"
333 "rx_vxlan_port add (udp_port) (port_id)\n"
334 " Add an UDP port for VXLAN packet filter on a port\n\n"
336 "rx_vxlan_port rm (udp_port) (port_id)\n"
337 " Remove an UDP port for VXLAN packet filter on a port\n\n"
339 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
340 " Set hardware insertion of VLAN IDs (single or double VLAN "
341 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
343 "tx_vlan set pvid port_id vlan_id (on|off)\n"
344 " Set port based TX VLAN insertion.\n\n"
346 "tx_vlan reset (port_id)\n"
347 " Disable hardware insertion of a VLAN header in"
348 " packets sent on a port.\n\n"
350 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
351 " Select hardware or software calculation of the"
352 " checksum when transmitting a packet using the"
353 " csum forward engine.\n"
354 " ip|udp|tcp|sctp always concern the inner layer.\n"
355 " outer-ip concerns the outer IP layer in"
356 " case the packet is recognized as a tunnel packet by"
357 " the forward engine (vxlan, gre and ipip are supported)\n"
358 " Please check the NIC datasheet for HW limits.\n\n"
360 "csum parse-tunnel (on|off) (tx_port_id)\n"
361 " If disabled, treat tunnel packets as non-tunneled"
362 " packets (treat inner headers as payload). The port\n"
363 " argument is the port used for TX in csum forward"
366 "csum show (port_id)\n"
367 " Display tx checksum offload configuration\n\n"
369 "tso set (segsize) (portid)\n"
370 " Enable TCP Segmentation Offload in csum forward"
372 " Please check the NIC datasheet for HW limits.\n\n"
375 " Display the status of TCP Segmentation Offload.\n\n"
378 " Set packet forwarding mode.\n\n"
380 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
381 " Add a MAC address on port_id.\n\n"
383 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
384 " Remove a MAC address from port_id.\n\n"
386 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
387 " Add a MAC address for a VF on the port.\n\n"
389 #ifdef RTE_LIBRTE_IXGBE_PMD
390 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
391 " Set the MAC address for a VF from the PF.\n\n"
394 "set port (port_id) uta (mac_address|all) (on|off)\n"
395 " Add/Remove a or all unicast hash filter(s)"
398 "set promisc (port_id|all) (on|off)\n"
399 " Set the promiscuous mode on port_id, or all.\n\n"
401 "set allmulti (port_id|all) (on|off)\n"
402 " Set the allmulti mode on port_id, or all.\n\n"
404 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
405 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
406 " (on|off) autoneg (on|off) (port_id)\n"
407 "set flow_ctrl rx (on|off) (portid)\n"
408 "set flow_ctrl tx (on|off) (portid)\n"
409 "set flow_ctrl high_water (high_water) (portid)\n"
410 "set flow_ctrl low_water (low_water) (portid)\n"
411 "set flow_ctrl pause_time (pause_time) (portid)\n"
412 "set flow_ctrl send_xon (send_xon) (portid)\n"
413 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
414 "set flow_ctrl autoneg (on|off) (port_id)\n"
415 " Set the link flow control parameter on a port.\n\n"
417 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
418 " (low_water) (pause_time) (priority) (port_id)\n"
419 " Set the priority flow control parameter on a"
422 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
423 " Set statistics mapping (qmapping 0..15) for RX/TX"
425 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
426 " on port 0 to mapping 5.\n\n"
428 "set port (port_id) vf (vf_id) rx|tx on|off\n"
429 " Enable/Disable a VF receive/tranmit from a port\n\n"
431 "set port (port_id) vf (vf_id) (mac_addr)"
432 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
433 " Add/Remove unicast or multicast MAC addr filter"
436 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
438 " AUPE:accepts untagged VLAN;"
439 "ROPE:accept unicast hash\n\n"
440 " BAM:accepts broadcast packets;"
441 "MPE:accepts all multicast packets\n\n"
442 " Enable/Disable a VF receive mode of a port\n\n"
444 "set port (port_id) queue (queue_id) rate (rate_num)\n"
445 " Set rate limit for a queue of a port\n\n"
447 "set port (port_id) vf (vf_id) rate (rate_num) "
448 "queue_mask (queue_mask_value)\n"
449 " Set rate limit for queues in VF of a port\n\n"
451 "set port (port_id) mirror-rule (rule_id)"
452 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
453 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
454 " Set pool or vlan type mirror rule on a port.\n"
455 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
456 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
459 "set port (port_id) mirror-rule (rule_id)"
460 " (uplink-mirror|downlink-mirror) dst-pool"
461 " (pool_id) (on|off)\n"
462 " Set uplink or downlink type mirror rule on a port.\n"
463 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
464 " 0 on' enable mirror income traffic to pool 0.\n\n"
466 "reset port (port_id) mirror-rule (rule_id)\n"
467 " Reset a mirror rule.\n\n"
469 "set flush_rx (on|off)\n"
470 " Flush (default) or don't flush RX streams before"
471 " forwarding. Mainly used with PCAP drivers.\n\n"
473 #ifdef RTE_NIC_BYPASS
474 "set bypass mode (normal|bypass|isolate) (port_id)\n"
475 " Set the bypass mode for the lowest port on bypass enabled"
478 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
479 "mode (normal|bypass|isolate) (port_id)\n"
480 " Set the event required to initiate specified bypass mode for"
481 " the lowest port on a bypass enabled NIC where:\n"
482 " timeout = enable bypass after watchdog timeout.\n"
483 " os_on = enable bypass when OS/board is powered on.\n"
484 " os_off = enable bypass when OS/board is powered off.\n"
485 " power_on = enable bypass when power supply is turned on.\n"
486 " power_off = enable bypass when power supply is turned off."
489 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
490 " Set the bypass watchdog timeout to 'n' seconds"
491 " where 0 = instant.\n\n"
493 "show bypass config (port_id)\n"
494 " Show the bypass configuration for a bypass enabled NIC"
495 " using the lowest port on the NIC.\n\n"
497 #ifdef RTE_LIBRTE_PMD_BOND
498 "create bonded device (mode) (socket)\n"
499 " Create a new bonded device with specific bonding mode and socket.\n\n"
501 "add bonding slave (slave_id) (port_id)\n"
502 " Add a slave device to a bonded device.\n\n"
504 "remove bonding slave (slave_id) (port_id)\n"
505 " Remove a slave device from a bonded device.\n\n"
507 "set bonding mode (value) (port_id)\n"
508 " Set the bonding mode on a bonded device.\n\n"
510 "set bonding primary (slave_id) (port_id)\n"
511 " Set the primary slave for a bonded device.\n\n"
513 "show bonding config (port_id)\n"
514 " Show the bonding config for port_id.\n\n"
516 "set bonding mac_addr (port_id) (address)\n"
517 " Set the MAC address of a bonded device.\n\n"
519 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
520 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
522 "set bonding mon_period (port_id) (value)\n"
523 " Set the bonding link status monitoring polling period in ms.\n\n"
525 "set link-up port (port_id)\n"
526 " Set link up for a port.\n\n"
528 "set link-down port (port_id)\n"
529 " Set link down for a port.\n\n"
531 "E-tag set insertion on port-tag-id (value)"
532 " port (port_id) vf (vf_id)\n"
533 " Enable E-tag insertion for a VF on a port\n\n"
535 "E-tag set insertion off port (port_id) vf (vf_id)\n"
536 " Disable E-tag insertion for a VF on a port\n\n"
538 "E-tag set stripping (on|off) port (port_id)\n"
539 " Enable/disable E-tag stripping on a port\n\n"
541 "E-tag set forwarding (on|off) port (port_id)\n"
542 " Enable/disable E-tag based forwarding"
545 "E-tag set filter add e-tag-id (value) dst-pool"
546 " (pool_id) port (port_id)\n"
547 " Add an E-tag forwarding filter on a port\n\n"
549 "E-tag set filter del e-tag-id (value) port (port_id)\n"
550 " Delete an E-tag forwarding filter on a port\n\n"
552 , list_pkt_forwarding_modes()
556 if (show_all || !strcmp(res->section, "ports")) {
562 "----------------\n\n"
564 "port start (port_id|all)\n"
565 " Start all ports or port_id.\n\n"
567 "port stop (port_id|all)\n"
568 " Stop all ports or port_id.\n\n"
570 "port close (port_id|all)\n"
571 " Close all ports or port_id.\n\n"
573 "port attach (ident)\n"
574 " Attach physical or virtual dev by pci address or virtual device name\n\n"
576 "port detach (port_id)\n"
577 " Detach physical or virtual dev by port_id\n\n"
579 "port config (port_id|all)"
580 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
581 " duplex (half|full|auto)\n"
582 " Set speed and duplex for all ports or port_id\n\n"
584 "port config all (rxq|txq|rxd|txd) (value)\n"
585 " Set number for rxq/txq/rxd/txd.\n\n"
587 "port config all max-pkt-len (value)\n"
588 " Set the max packet length.\n\n"
590 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
591 "hw-vlan-strip|hw-vlan-extend|drop-en)"
593 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
596 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
597 " Set the RSS mode.\n\n"
599 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
600 " Set the RSS redirection table.\n\n"
602 "port config (port_id) dcb vt (on|off) (traffic_class)"
604 " Set the DCB mode.\n\n"
606 "port config all burst (value)\n"
607 " Set the number of packets per burst.\n\n"
609 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
611 " Set the ring prefetch/host/writeback threshold"
612 " for tx/rx queue.\n\n"
614 "port config all (txfreet|txrst|rxfreet) (value)\n"
615 " Set free threshold for rx/tx, or set"
616 " tx rs bit threshold.\n\n"
617 "port config mtu X value\n"
618 " Set the MTU of port X to a given value\n\n"
620 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
621 " Start/stop a rx/tx queue of port X. Only take effect"
622 " when port X is started\n\n"
624 "port config (port_id|all) l2-tunnel E-tag ether-type"
626 " Set the value of E-tag ether-type.\n\n"
628 "port config (port_id|all) l2-tunnel E-tag"
629 " (enable|disable)\n"
630 " Enable/disable the E-tag support.\n\n"
634 if (show_all || !strcmp(res->section, "registers")) {
642 "read reg (port_id) (address)\n"
643 " Display value of a port register.\n\n"
645 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
646 " Display a port register bit field.\n\n"
648 "read regbit (port_id) (address) (bit_x)\n"
649 " Display a single port register bit.\n\n"
651 "write reg (port_id) (address) (value)\n"
652 " Set value of a port register.\n\n"
654 "write regfield (port_id) (address) (bit_x) (bit_y)"
656 " Set bit field of a port register.\n\n"
658 "write regbit (port_id) (address) (bit_x) (value)\n"
659 " Set single bit value of a port register.\n\n"
662 if (show_all || !strcmp(res->section, "filters")) {
670 "ethertype_filter (port_id) (add|del)"
671 " (mac_addr|mac_ignr) (mac_address) ethertype"
672 " (ether_type) (drop|fwd) queue (queue_id)\n"
673 " Add/Del an ethertype filter.\n\n"
675 "2tuple_filter (port_id) (add|del)"
676 " dst_port (dst_port_value) protocol (protocol_value)"
677 " mask (mask_value) tcp_flags (tcp_flags_value)"
678 " priority (prio_value) queue (queue_id)\n"
679 " Add/Del a 2tuple filter.\n\n"
681 "5tuple_filter (port_id) (add|del)"
682 " dst_ip (dst_address) src_ip (src_address)"
683 " dst_port (dst_port_value) src_port (src_port_value)"
684 " protocol (protocol_value)"
685 " mask (mask_value) tcp_flags (tcp_flags_value)"
686 " priority (prio_value) queue (queue_id)\n"
687 " Add/Del a 5tuple filter.\n\n"
689 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
690 " Add/Del syn filter.\n\n"
692 "flex_filter (port_id) (add|del) len (len_value)"
693 " bytes (bytes_value) mask (mask_value)"
694 " priority (prio_value) queue (queue_id)\n"
695 " Add/Del a flex filter.\n\n"
697 "flow_director_filter (port_id) mode IP (add|del|update)"
698 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
699 " src (src_ip_address) dst (dst_ip_address)"
700 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
701 " vlan (vlan_value) flexbytes (flexbytes_value)"
702 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
703 " fd_id (fd_id_value)\n"
704 " Add/Del an IP type flow director filter.\n\n"
706 "flow_director_filter (port_id) mode IP (add|del|update)"
707 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
708 " src (src_ip_address) (src_port)"
709 " dst (dst_ip_address) (dst_port)"
710 " tos (tos_value) ttl (ttl_value)"
711 " vlan (vlan_value) flexbytes (flexbytes_value)"
712 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
713 " fd_id (fd_id_value)\n"
714 " Add/Del an UDP/TCP type flow director filter.\n\n"
716 "flow_director_filter (port_id) mode IP (add|del|update)"
717 " flow (ipv4-sctp|ipv6-sctp)"
718 " src (src_ip_address) (src_port)"
719 " dst (dst_ip_address) (dst_port)"
720 " tag (verification_tag) "
721 " tos (tos_value) ttl (ttl_value)"
723 " flexbytes (flexbytes_value) (drop|fwd)"
724 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
725 " Add/Del a SCTP type flow director filter.\n\n"
727 "flow_director_filter (port_id) mode IP (add|del|update)"
728 " flow l2_payload ether (ethertype)"
729 " flexbytes (flexbytes_value) (drop|fwd)"
730 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
731 " Add/Del a l2 payload type flow director filter.\n\n"
733 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
734 " mac (mac_address) vlan (vlan_value)"
735 " flexbytes (flexbytes_value) (drop|fwd)"
736 " queue (queue_id) fd_id (fd_id_value)\n"
737 " Add/Del a MAC-VLAN flow director filter.\n\n"
739 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
740 " mac (mac_address) vlan (vlan_value)"
741 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
742 " flexbytes (flexbytes_value) (drop|fwd)"
743 " queue (queue_id) fd_id (fd_id_value)\n"
744 " Add/Del a Tunnel flow director filter.\n\n"
746 "flush_flow_director (port_id)\n"
747 " Flush all flow director entries of a device.\n\n"
749 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
750 " src_mask (ipv4_src) (ipv6_src) (src_port)"
751 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
752 " Set flow director IP mask.\n\n"
754 "flow_director_mask (port_id) mode MAC-VLAN"
755 " vlan (vlan_value)\n"
756 " Set flow director MAC-VLAN mask.\n\n"
758 "flow_director_mask (port_id) mode Tunnel"
759 " vlan (vlan_value) mac (mac_value)"
760 " tunnel-type (tunnel_type_value)"
761 " tunnel-id (tunnel_id_value)\n"
762 " Set flow director Tunnel mask.\n\n"
764 "flow_director_flex_mask (port_id)"
765 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
766 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
768 " Configure mask of flex payload.\n\n"
770 "flow_director_flex_payload (port_id)"
771 " (raw|l2|l3|l4) (config)\n"
772 " Configure flex payload selection.\n\n"
774 "get_sym_hash_ena_per_port (port_id)\n"
775 " get symmetric hash enable configuration per port.\n\n"
777 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
778 " set symmetric hash enable configuration per port"
779 " to enable or disable.\n\n"
781 "get_hash_global_config (port_id)\n"
782 " Get the global configurations of hash filters.\n\n"
784 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
785 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
786 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
787 " (enable|disable)\n"
788 " Set the global configurations of hash filters.\n\n"
790 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
791 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
792 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
793 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
794 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
795 "ipv6-next-header|udp-src-port|udp-dst-port|"
796 "tcp-src-port|tcp-dst-port|sctp-src-port|"
797 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
798 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
799 "fld-8th|none) (select|add)\n"
800 " Set the input set for hash.\n\n"
802 "set_fdir_input_set (port_id) "
803 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
804 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
805 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
806 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
807 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
808 "udp-dst-port|tcp-src-port|tcp-dst-port|"
809 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
811 " Set the input set for FDir.\n\n"
816 cmdline_parse_token_string_t cmd_help_long_help =
817 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
819 cmdline_parse_token_string_t cmd_help_long_section =
820 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
821 "all#control#display#config#"
822 "ports#registers#filters");
824 cmdline_parse_inst_t cmd_help_long = {
825 .f = cmd_help_long_parsed,
827 .help_str = "help all|control|display|config|ports|register|filters: "
830 (void *)&cmd_help_long_help,
831 (void *)&cmd_help_long_section,
837 /* *** start/stop/close all ports *** */
838 struct cmd_operate_port_result {
839 cmdline_fixed_string_t keyword;
840 cmdline_fixed_string_t name;
841 cmdline_fixed_string_t value;
844 static void cmd_operate_port_parsed(void *parsed_result,
845 __attribute__((unused)) struct cmdline *cl,
846 __attribute__((unused)) void *data)
848 struct cmd_operate_port_result *res = parsed_result;
850 if (!strcmp(res->name, "start"))
851 start_port(RTE_PORT_ALL);
852 else if (!strcmp(res->name, "stop"))
853 stop_port(RTE_PORT_ALL);
854 else if (!strcmp(res->name, "close"))
855 close_port(RTE_PORT_ALL);
857 printf("Unknown parameter\n");
860 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
861 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
863 cmdline_parse_token_string_t cmd_operate_port_all_port =
864 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
866 cmdline_parse_token_string_t cmd_operate_port_all_all =
867 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
869 cmdline_parse_inst_t cmd_operate_port = {
870 .f = cmd_operate_port_parsed,
872 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
874 (void *)&cmd_operate_port_all_cmd,
875 (void *)&cmd_operate_port_all_port,
876 (void *)&cmd_operate_port_all_all,
881 /* *** start/stop/close specific port *** */
882 struct cmd_operate_specific_port_result {
883 cmdline_fixed_string_t keyword;
884 cmdline_fixed_string_t name;
888 static void cmd_operate_specific_port_parsed(void *parsed_result,
889 __attribute__((unused)) struct cmdline *cl,
890 __attribute__((unused)) void *data)
892 struct cmd_operate_specific_port_result *res = parsed_result;
894 if (!strcmp(res->name, "start"))
895 start_port(res->value);
896 else if (!strcmp(res->name, "stop"))
897 stop_port(res->value);
898 else if (!strcmp(res->name, "close"))
899 close_port(res->value);
901 printf("Unknown parameter\n");
904 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
905 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
907 cmdline_parse_token_string_t cmd_operate_specific_port_port =
908 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
909 name, "start#stop#close");
910 cmdline_parse_token_num_t cmd_operate_specific_port_id =
911 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
914 cmdline_parse_inst_t cmd_operate_specific_port = {
915 .f = cmd_operate_specific_port_parsed,
917 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
919 (void *)&cmd_operate_specific_port_cmd,
920 (void *)&cmd_operate_specific_port_port,
921 (void *)&cmd_operate_specific_port_id,
926 /* *** attach a specified port *** */
927 struct cmd_operate_attach_port_result {
928 cmdline_fixed_string_t port;
929 cmdline_fixed_string_t keyword;
930 cmdline_fixed_string_t identifier;
933 static void cmd_operate_attach_port_parsed(void *parsed_result,
934 __attribute__((unused)) struct cmdline *cl,
935 __attribute__((unused)) void *data)
937 struct cmd_operate_attach_port_result *res = parsed_result;
939 if (!strcmp(res->keyword, "attach"))
940 attach_port(res->identifier);
942 printf("Unknown parameter\n");
945 cmdline_parse_token_string_t cmd_operate_attach_port_port =
946 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
948 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
949 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
951 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
952 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
955 cmdline_parse_inst_t cmd_operate_attach_port = {
956 .f = cmd_operate_attach_port_parsed,
958 .help_str = "port attach <identifier>: "
959 "(identifier: pci address or virtual dev name)",
961 (void *)&cmd_operate_attach_port_port,
962 (void *)&cmd_operate_attach_port_keyword,
963 (void *)&cmd_operate_attach_port_identifier,
968 /* *** detach a specified port *** */
969 struct cmd_operate_detach_port_result {
970 cmdline_fixed_string_t port;
971 cmdline_fixed_string_t keyword;
975 static void cmd_operate_detach_port_parsed(void *parsed_result,
976 __attribute__((unused)) struct cmdline *cl,
977 __attribute__((unused)) void *data)
979 struct cmd_operate_detach_port_result *res = parsed_result;
981 if (!strcmp(res->keyword, "detach"))
982 detach_port(res->port_id);
984 printf("Unknown parameter\n");
987 cmdline_parse_token_string_t cmd_operate_detach_port_port =
988 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
990 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
991 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
993 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
994 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
997 cmdline_parse_inst_t cmd_operate_detach_port = {
998 .f = cmd_operate_detach_port_parsed,
1000 .help_str = "port detach <port_id>",
1002 (void *)&cmd_operate_detach_port_port,
1003 (void *)&cmd_operate_detach_port_keyword,
1004 (void *)&cmd_operate_detach_port_port_id,
1009 /* *** configure speed for all ports *** */
1010 struct cmd_config_speed_all {
1011 cmdline_fixed_string_t port;
1012 cmdline_fixed_string_t keyword;
1013 cmdline_fixed_string_t all;
1014 cmdline_fixed_string_t item1;
1015 cmdline_fixed_string_t item2;
1016 cmdline_fixed_string_t value1;
1017 cmdline_fixed_string_t value2;
1021 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1026 if (!strcmp(duplexstr, "half")) {
1027 duplex = ETH_LINK_HALF_DUPLEX;
1028 } else if (!strcmp(duplexstr, "full")) {
1029 duplex = ETH_LINK_FULL_DUPLEX;
1030 } else if (!strcmp(duplexstr, "auto")) {
1031 duplex = ETH_LINK_FULL_DUPLEX;
1033 printf("Unknown duplex parameter\n");
1037 if (!strcmp(speedstr, "10")) {
1038 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1039 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1040 } else if (!strcmp(speedstr, "100")) {
1041 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1042 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1044 if (duplex != ETH_LINK_FULL_DUPLEX) {
1045 printf("Invalid speed/duplex parameters\n");
1048 if (!strcmp(speedstr, "1000")) {
1049 *speed = ETH_LINK_SPEED_1G;
1050 } else if (!strcmp(speedstr, "10000")) {
1051 *speed = ETH_LINK_SPEED_10G;
1052 } else if (!strcmp(speedstr, "25000")) {
1053 *speed = ETH_LINK_SPEED_25G;
1054 } else if (!strcmp(speedstr, "40000")) {
1055 *speed = ETH_LINK_SPEED_40G;
1056 } else if (!strcmp(speedstr, "50000")) {
1057 *speed = ETH_LINK_SPEED_50G;
1058 } else if (!strcmp(speedstr, "100000")) {
1059 *speed = ETH_LINK_SPEED_100G;
1060 } else if (!strcmp(speedstr, "auto")) {
1061 *speed = ETH_LINK_SPEED_AUTONEG;
1063 printf("Unknown speed parameter\n");
1072 cmd_config_speed_all_parsed(void *parsed_result,
1073 __attribute__((unused)) struct cmdline *cl,
1074 __attribute__((unused)) void *data)
1076 struct cmd_config_speed_all *res = parsed_result;
1077 uint32_t link_speed;
1080 if (!all_ports_stopped()) {
1081 printf("Please stop all ports first\n");
1085 if (parse_and_check_speed_duplex(res->value1, res->value2,
1089 FOREACH_PORT(pid, ports) {
1090 ports[pid].dev_conf.link_speeds = link_speed;
1093 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1096 cmdline_parse_token_string_t cmd_config_speed_all_port =
1097 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1098 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1099 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1101 cmdline_parse_token_string_t cmd_config_speed_all_all =
1102 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1103 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1104 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1105 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1106 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1107 "10#100#1000#10000#25000#40000#50000#100000#auto");
1108 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1109 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1110 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1111 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1114 cmdline_parse_inst_t cmd_config_speed_all = {
1115 .f = cmd_config_speed_all_parsed,
1117 .help_str = "port config all speed "
1118 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1121 (void *)&cmd_config_speed_all_port,
1122 (void *)&cmd_config_speed_all_keyword,
1123 (void *)&cmd_config_speed_all_all,
1124 (void *)&cmd_config_speed_all_item1,
1125 (void *)&cmd_config_speed_all_value1,
1126 (void *)&cmd_config_speed_all_item2,
1127 (void *)&cmd_config_speed_all_value2,
1132 /* *** configure speed for specific port *** */
1133 struct cmd_config_speed_specific {
1134 cmdline_fixed_string_t port;
1135 cmdline_fixed_string_t keyword;
1137 cmdline_fixed_string_t item1;
1138 cmdline_fixed_string_t item2;
1139 cmdline_fixed_string_t value1;
1140 cmdline_fixed_string_t value2;
1144 cmd_config_speed_specific_parsed(void *parsed_result,
1145 __attribute__((unused)) struct cmdline *cl,
1146 __attribute__((unused)) void *data)
1148 struct cmd_config_speed_specific *res = parsed_result;
1149 uint32_t link_speed;
1151 if (!all_ports_stopped()) {
1152 printf("Please stop all ports first\n");
1156 if (port_id_is_invalid(res->id, ENABLED_WARN))
1159 if (parse_and_check_speed_duplex(res->value1, res->value2,
1163 ports[res->id].dev_conf.link_speeds = link_speed;
1165 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1169 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1170 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1172 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1173 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1175 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1176 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1177 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1178 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1180 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1181 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1182 "10#100#1000#10000#25000#40000#50000#100000#auto");
1183 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1184 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1186 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1187 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1190 cmdline_parse_inst_t cmd_config_speed_specific = {
1191 .f = cmd_config_speed_specific_parsed,
1193 .help_str = "port config <port_id> speed "
1194 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1197 (void *)&cmd_config_speed_specific_port,
1198 (void *)&cmd_config_speed_specific_keyword,
1199 (void *)&cmd_config_speed_specific_id,
1200 (void *)&cmd_config_speed_specific_item1,
1201 (void *)&cmd_config_speed_specific_value1,
1202 (void *)&cmd_config_speed_specific_item2,
1203 (void *)&cmd_config_speed_specific_value2,
1208 /* *** configure txq/rxq, txd/rxd *** */
1209 struct cmd_config_rx_tx {
1210 cmdline_fixed_string_t port;
1211 cmdline_fixed_string_t keyword;
1212 cmdline_fixed_string_t all;
1213 cmdline_fixed_string_t name;
1218 cmd_config_rx_tx_parsed(void *parsed_result,
1219 __attribute__((unused)) struct cmdline *cl,
1220 __attribute__((unused)) void *data)
1222 struct cmd_config_rx_tx *res = parsed_result;
1224 if (!all_ports_stopped()) {
1225 printf("Please stop all ports first\n");
1228 if (!strcmp(res->name, "rxq")) {
1229 if (!res->value && !nb_txq) {
1230 printf("Warning: Either rx or tx queues should be non zero\n");
1233 nb_rxq = res->value;
1235 else if (!strcmp(res->name, "txq")) {
1236 if (!res->value && !nb_rxq) {
1237 printf("Warning: Either rx or tx queues should be non zero\n");
1240 nb_txq = res->value;
1242 else if (!strcmp(res->name, "rxd")) {
1243 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1244 printf("rxd %d invalid - must be > 0 && <= %d\n",
1245 res->value, RTE_TEST_RX_DESC_MAX);
1248 nb_rxd = res->value;
1249 } else if (!strcmp(res->name, "txd")) {
1250 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1251 printf("txd %d invalid - must be > 0 && <= %d\n",
1252 res->value, RTE_TEST_TX_DESC_MAX);
1255 nb_txd = res->value;
1257 printf("Unknown parameter\n");
1265 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1268 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1269 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1270 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1271 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1272 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1273 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1274 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1275 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1277 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1278 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1280 cmdline_parse_inst_t cmd_config_rx_tx = {
1281 .f = cmd_config_rx_tx_parsed,
1283 .help_str = "port config all rxq|txq|rxd|txd <value>",
1285 (void *)&cmd_config_rx_tx_port,
1286 (void *)&cmd_config_rx_tx_keyword,
1287 (void *)&cmd_config_rx_tx_all,
1288 (void *)&cmd_config_rx_tx_name,
1289 (void *)&cmd_config_rx_tx_value,
1294 /* *** config max packet length *** */
1295 struct cmd_config_max_pkt_len_result {
1296 cmdline_fixed_string_t port;
1297 cmdline_fixed_string_t keyword;
1298 cmdline_fixed_string_t all;
1299 cmdline_fixed_string_t name;
1304 cmd_config_max_pkt_len_parsed(void *parsed_result,
1305 __attribute__((unused)) struct cmdline *cl,
1306 __attribute__((unused)) void *data)
1308 struct cmd_config_max_pkt_len_result *res = parsed_result;
1310 if (!all_ports_stopped()) {
1311 printf("Please stop all ports first\n");
1315 if (!strcmp(res->name, "max-pkt-len")) {
1316 if (res->value < ETHER_MIN_LEN) {
1317 printf("max-pkt-len can not be less than %d\n",
1321 if (res->value == rx_mode.max_rx_pkt_len)
1324 rx_mode.max_rx_pkt_len = res->value;
1325 if (res->value > ETHER_MAX_LEN)
1326 rx_mode.jumbo_frame = 1;
1328 rx_mode.jumbo_frame = 0;
1330 printf("Unknown parameter\n");
1336 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1339 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1340 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1342 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1343 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1345 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1346 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1348 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1349 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1351 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1352 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1355 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1356 .f = cmd_config_max_pkt_len_parsed,
1358 .help_str = "port config all max-pkt-len <value>",
1360 (void *)&cmd_config_max_pkt_len_port,
1361 (void *)&cmd_config_max_pkt_len_keyword,
1362 (void *)&cmd_config_max_pkt_len_all,
1363 (void *)&cmd_config_max_pkt_len_name,
1364 (void *)&cmd_config_max_pkt_len_value,
1369 /* *** configure port MTU *** */
1370 struct cmd_config_mtu_result {
1371 cmdline_fixed_string_t port;
1372 cmdline_fixed_string_t keyword;
1373 cmdline_fixed_string_t mtu;
1379 cmd_config_mtu_parsed(void *parsed_result,
1380 __attribute__((unused)) struct cmdline *cl,
1381 __attribute__((unused)) void *data)
1383 struct cmd_config_mtu_result *res = parsed_result;
1385 if (res->value < ETHER_MIN_LEN) {
1386 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1389 port_mtu_set(res->port_id, res->value);
1392 cmdline_parse_token_string_t cmd_config_mtu_port =
1393 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1395 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1398 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1401 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1402 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1403 cmdline_parse_token_num_t cmd_config_mtu_value =
1404 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1406 cmdline_parse_inst_t cmd_config_mtu = {
1407 .f = cmd_config_mtu_parsed,
1409 .help_str = "port config mtu <port_id> <value>",
1411 (void *)&cmd_config_mtu_port,
1412 (void *)&cmd_config_mtu_keyword,
1413 (void *)&cmd_config_mtu_mtu,
1414 (void *)&cmd_config_mtu_port_id,
1415 (void *)&cmd_config_mtu_value,
1420 /* *** configure rx mode *** */
1421 struct cmd_config_rx_mode_flag {
1422 cmdline_fixed_string_t port;
1423 cmdline_fixed_string_t keyword;
1424 cmdline_fixed_string_t all;
1425 cmdline_fixed_string_t name;
1426 cmdline_fixed_string_t value;
1430 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1431 __attribute__((unused)) struct cmdline *cl,
1432 __attribute__((unused)) void *data)
1434 struct cmd_config_rx_mode_flag *res = parsed_result;
1436 if (!all_ports_stopped()) {
1437 printf("Please stop all ports first\n");
1441 if (!strcmp(res->name, "crc-strip")) {
1442 if (!strcmp(res->value, "on"))
1443 rx_mode.hw_strip_crc = 1;
1444 else if (!strcmp(res->value, "off"))
1445 rx_mode.hw_strip_crc = 0;
1447 printf("Unknown parameter\n");
1450 } else if (!strcmp(res->name, "scatter")) {
1451 if (!strcmp(res->value, "on"))
1452 rx_mode.enable_scatter = 1;
1453 else if (!strcmp(res->value, "off"))
1454 rx_mode.enable_scatter = 0;
1456 printf("Unknown parameter\n");
1459 } else if (!strcmp(res->name, "rx-cksum")) {
1460 if (!strcmp(res->value, "on"))
1461 rx_mode.hw_ip_checksum = 1;
1462 else if (!strcmp(res->value, "off"))
1463 rx_mode.hw_ip_checksum = 0;
1465 printf("Unknown parameter\n");
1468 } else if (!strcmp(res->name, "hw-vlan")) {
1469 if (!strcmp(res->value, "on")) {
1470 rx_mode.hw_vlan_filter = 1;
1471 rx_mode.hw_vlan_strip = 1;
1473 else if (!strcmp(res->value, "off")) {
1474 rx_mode.hw_vlan_filter = 0;
1475 rx_mode.hw_vlan_strip = 0;
1478 printf("Unknown parameter\n");
1481 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1482 if (!strcmp(res->value, "on"))
1483 rx_mode.hw_vlan_filter = 1;
1484 else if (!strcmp(res->value, "off"))
1485 rx_mode.hw_vlan_filter = 0;
1487 printf("Unknown parameter\n");
1490 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1491 if (!strcmp(res->value, "on"))
1492 rx_mode.hw_vlan_strip = 1;
1493 else if (!strcmp(res->value, "off"))
1494 rx_mode.hw_vlan_strip = 0;
1496 printf("Unknown parameter\n");
1499 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1500 if (!strcmp(res->value, "on"))
1501 rx_mode.hw_vlan_extend = 1;
1502 else if (!strcmp(res->value, "off"))
1503 rx_mode.hw_vlan_extend = 0;
1505 printf("Unknown parameter\n");
1508 } else if (!strcmp(res->name, "drop-en")) {
1509 if (!strcmp(res->value, "on"))
1511 else if (!strcmp(res->value, "off"))
1514 printf("Unknown parameter\n");
1518 printf("Unknown parameter\n");
1524 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1527 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1528 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1529 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1530 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1532 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1533 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1534 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1535 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1536 "crc-strip#scatter#rx-cksum#hw-vlan#"
1537 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1538 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1539 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1542 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1543 .f = cmd_config_rx_mode_flag_parsed,
1545 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1546 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1548 (void *)&cmd_config_rx_mode_flag_port,
1549 (void *)&cmd_config_rx_mode_flag_keyword,
1550 (void *)&cmd_config_rx_mode_flag_all,
1551 (void *)&cmd_config_rx_mode_flag_name,
1552 (void *)&cmd_config_rx_mode_flag_value,
1557 /* *** configure rss *** */
1558 struct cmd_config_rss {
1559 cmdline_fixed_string_t port;
1560 cmdline_fixed_string_t keyword;
1561 cmdline_fixed_string_t all;
1562 cmdline_fixed_string_t name;
1563 cmdline_fixed_string_t value;
1567 cmd_config_rss_parsed(void *parsed_result,
1568 __attribute__((unused)) struct cmdline *cl,
1569 __attribute__((unused)) void *data)
1571 struct cmd_config_rss *res = parsed_result;
1572 struct rte_eth_rss_conf rss_conf;
1576 if (!strcmp(res->value, "all"))
1577 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1578 ETH_RSS_UDP | ETH_RSS_SCTP |
1580 else if (!strcmp(res->value, "ip"))
1581 rss_conf.rss_hf = ETH_RSS_IP;
1582 else if (!strcmp(res->value, "udp"))
1583 rss_conf.rss_hf = ETH_RSS_UDP;
1584 else if (!strcmp(res->value, "tcp"))
1585 rss_conf.rss_hf = ETH_RSS_TCP;
1586 else if (!strcmp(res->value, "sctp"))
1587 rss_conf.rss_hf = ETH_RSS_SCTP;
1588 else if (!strcmp(res->value, "ether"))
1589 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1590 else if (!strcmp(res->value, "port"))
1591 rss_conf.rss_hf = ETH_RSS_PORT;
1592 else if (!strcmp(res->value, "vxlan"))
1593 rss_conf.rss_hf = ETH_RSS_VXLAN;
1594 else if (!strcmp(res->value, "geneve"))
1595 rss_conf.rss_hf = ETH_RSS_GENEVE;
1596 else if (!strcmp(res->value, "nvgre"))
1597 rss_conf.rss_hf = ETH_RSS_NVGRE;
1598 else if (!strcmp(res->value, "none"))
1599 rss_conf.rss_hf = 0;
1601 printf("Unknown parameter\n");
1604 rss_conf.rss_key = NULL;
1605 for (i = 0; i < rte_eth_dev_count(); i++) {
1606 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1608 printf("Configuration of RSS hash at ethernet port %d "
1609 "failed with error (%d): %s.\n",
1610 i, -diag, strerror(-diag));
1614 cmdline_parse_token_string_t cmd_config_rss_port =
1615 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1616 cmdline_parse_token_string_t cmd_config_rss_keyword =
1617 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1618 cmdline_parse_token_string_t cmd_config_rss_all =
1619 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1620 cmdline_parse_token_string_t cmd_config_rss_name =
1621 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1622 cmdline_parse_token_string_t cmd_config_rss_value =
1623 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1624 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1626 cmdline_parse_inst_t cmd_config_rss = {
1627 .f = cmd_config_rss_parsed,
1629 .help_str = "port config all rss "
1630 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1632 (void *)&cmd_config_rss_port,
1633 (void *)&cmd_config_rss_keyword,
1634 (void *)&cmd_config_rss_all,
1635 (void *)&cmd_config_rss_name,
1636 (void *)&cmd_config_rss_value,
1641 /* *** configure rss hash key *** */
1642 struct cmd_config_rss_hash_key {
1643 cmdline_fixed_string_t port;
1644 cmdline_fixed_string_t config;
1646 cmdline_fixed_string_t rss_hash_key;
1647 cmdline_fixed_string_t rss_type;
1648 cmdline_fixed_string_t key;
1652 hexa_digit_to_value(char hexa_digit)
1654 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1655 return (uint8_t) (hexa_digit - '0');
1656 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1657 return (uint8_t) ((hexa_digit - 'a') + 10);
1658 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1659 return (uint8_t) ((hexa_digit - 'A') + 10);
1660 /* Invalid hexa digit */
1665 parse_and_check_key_hexa_digit(char *key, int idx)
1669 hexa_v = hexa_digit_to_value(key[idx]);
1671 printf("invalid key: character %c at position %d is not a "
1672 "valid hexa digit\n", key[idx], idx);
1677 cmd_config_rss_hash_key_parsed(void *parsed_result,
1678 __attribute__((unused)) struct cmdline *cl,
1679 __attribute__((unused)) void *data)
1681 struct cmd_config_rss_hash_key *res = parsed_result;
1682 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1686 struct rte_eth_dev_info dev_info;
1687 uint8_t hash_key_size;
1690 memset(&dev_info, 0, sizeof(dev_info));
1691 rte_eth_dev_info_get(res->port_id, &dev_info);
1692 if (dev_info.hash_key_size > 0 &&
1693 dev_info.hash_key_size <= sizeof(hash_key))
1694 hash_key_size = dev_info.hash_key_size;
1696 printf("dev_info did not provide a valid hash key size\n");
1699 /* Check the length of the RSS hash key */
1700 key_len = strlen(res->key);
1701 if (key_len != (hash_key_size * 2)) {
1702 printf("key length: %d invalid - key must be a string of %d"
1703 " hexa-decimal numbers\n",
1704 (int) key_len, hash_key_size * 2);
1707 /* Translate RSS hash key into binary representation */
1708 for (i = 0; i < hash_key_size; i++) {
1709 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1712 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1715 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1717 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1721 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1723 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1724 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1726 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1727 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1728 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1729 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1730 rss_hash_key, "rss-hash-key");
1731 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1733 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1734 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1735 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1736 "ipv6-tcp-ex#ipv6-udp-ex");
1737 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1740 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1741 .f = cmd_config_rss_hash_key_parsed,
1743 .help_str = "port config <port_id> rss-hash-key "
1744 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1745 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1746 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1747 "<string of hex digits (variable length, NIC dependent)>",
1749 (void *)&cmd_config_rss_hash_key_port,
1750 (void *)&cmd_config_rss_hash_key_config,
1751 (void *)&cmd_config_rss_hash_key_port_id,
1752 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1753 (void *)&cmd_config_rss_hash_key_rss_type,
1754 (void *)&cmd_config_rss_hash_key_value,
1759 /* *** configure port rxq/txq start/stop *** */
1760 struct cmd_config_rxtx_queue {
1761 cmdline_fixed_string_t port;
1763 cmdline_fixed_string_t rxtxq;
1765 cmdline_fixed_string_t opname;
1769 cmd_config_rxtx_queue_parsed(void *parsed_result,
1770 __attribute__((unused)) struct cmdline *cl,
1771 __attribute__((unused)) void *data)
1773 struct cmd_config_rxtx_queue *res = parsed_result;
1778 if (test_done == 0) {
1779 printf("Please stop forwarding first\n");
1783 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1786 if (port_is_started(res->portid) != 1) {
1787 printf("Please start port %u first\n", res->portid);
1791 if (!strcmp(res->rxtxq, "rxq"))
1793 else if (!strcmp(res->rxtxq, "txq"))
1796 printf("Unknown parameter\n");
1800 if (isrx && rx_queue_id_is_invalid(res->qid))
1802 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1805 if (!strcmp(res->opname, "start"))
1807 else if (!strcmp(res->opname, "stop"))
1810 printf("Unknown parameter\n");
1814 if (isstart && isrx)
1815 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1816 else if (!isstart && isrx)
1817 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1818 else if (isstart && !isrx)
1819 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1821 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1823 if (ret == -ENOTSUP)
1824 printf("Function not supported in PMD driver\n");
1827 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1828 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1829 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1830 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1831 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1833 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1834 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1835 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1836 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1839 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1840 .f = cmd_config_rxtx_queue_parsed,
1842 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1844 (void *)&cmd_config_speed_all_port,
1845 (void *)&cmd_config_rxtx_queue_portid,
1846 (void *)&cmd_config_rxtx_queue_rxtxq,
1847 (void *)&cmd_config_rxtx_queue_qid,
1848 (void *)&cmd_config_rxtx_queue_opname,
1853 /* *** Configure RSS RETA *** */
1854 struct cmd_config_rss_reta {
1855 cmdline_fixed_string_t port;
1856 cmdline_fixed_string_t keyword;
1858 cmdline_fixed_string_t name;
1859 cmdline_fixed_string_t list_name;
1860 cmdline_fixed_string_t list_of_items;
1864 parse_reta_config(const char *str,
1865 struct rte_eth_rss_reta_entry64 *reta_conf,
1866 uint16_t nb_entries)
1870 uint16_t hash_index, idx, shift;
1873 const char *p, *p0 = str;
1880 unsigned long int_fld[_NUM_FLD];
1881 char *str_fld[_NUM_FLD];
1883 while ((p = strchr(p0,'(')) != NULL) {
1885 if((p0 = strchr(p,')')) == NULL)
1889 if(size >= sizeof(s))
1892 snprintf(s, sizeof(s), "%.*s", size, p);
1893 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1895 for (i = 0; i < _NUM_FLD; i++) {
1897 int_fld[i] = strtoul(str_fld[i], &end, 0);
1898 if (errno != 0 || end == str_fld[i] ||
1903 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1904 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1906 if (hash_index >= nb_entries) {
1907 printf("Invalid RETA hash index=%d\n", hash_index);
1911 idx = hash_index / RTE_RETA_GROUP_SIZE;
1912 shift = hash_index % RTE_RETA_GROUP_SIZE;
1913 reta_conf[idx].mask |= (1ULL << shift);
1914 reta_conf[idx].reta[shift] = nb_queue;
1921 cmd_set_rss_reta_parsed(void *parsed_result,
1922 __attribute__((unused)) struct cmdline *cl,
1923 __attribute__((unused)) void *data)
1926 struct rte_eth_dev_info dev_info;
1927 struct rte_eth_rss_reta_entry64 reta_conf[8];
1928 struct cmd_config_rss_reta *res = parsed_result;
1930 memset(&dev_info, 0, sizeof(dev_info));
1931 rte_eth_dev_info_get(res->port_id, &dev_info);
1932 if (dev_info.reta_size == 0) {
1933 printf("Redirection table size is 0 which is "
1934 "invalid for RSS\n");
1937 printf("The reta size of port %d is %u\n",
1938 res->port_id, dev_info.reta_size);
1939 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1940 printf("Currently do not support more than %u entries of "
1941 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1945 memset(reta_conf, 0, sizeof(reta_conf));
1946 if (!strcmp(res->list_name, "reta")) {
1947 if (parse_reta_config(res->list_of_items, reta_conf,
1948 dev_info.reta_size)) {
1949 printf("Invalid RSS Redirection Table "
1950 "config entered\n");
1953 ret = rte_eth_dev_rss_reta_update(res->port_id,
1954 reta_conf, dev_info.reta_size);
1956 printf("Bad redirection table parameter, "
1957 "return code = %d \n", ret);
1961 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1962 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1963 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1965 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1966 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1967 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1968 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1969 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1970 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1971 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1972 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1974 cmdline_parse_inst_t cmd_config_rss_reta = {
1975 .f = cmd_set_rss_reta_parsed,
1977 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
1979 (void *)&cmd_config_rss_reta_port,
1980 (void *)&cmd_config_rss_reta_keyword,
1981 (void *)&cmd_config_rss_reta_port_id,
1982 (void *)&cmd_config_rss_reta_name,
1983 (void *)&cmd_config_rss_reta_list_name,
1984 (void *)&cmd_config_rss_reta_list_of_items,
1989 /* *** SHOW PORT RETA INFO *** */
1990 struct cmd_showport_reta {
1991 cmdline_fixed_string_t show;
1992 cmdline_fixed_string_t port;
1994 cmdline_fixed_string_t rss;
1995 cmdline_fixed_string_t reta;
1997 cmdline_fixed_string_t list_of_items;
2001 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2002 uint16_t nb_entries,
2006 const char *p, *p0 = str;
2010 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2013 p = strchr(p0, '(');
2017 p0 = strchr(p, ')');
2021 if (size >= sizeof(s)) {
2022 printf("The string size exceeds the internal buffer size\n");
2025 snprintf(s, sizeof(s), "%.*s", size, p);
2026 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2027 if (ret <= 0 || ret != num) {
2028 printf("The bits of masks do not match the number of "
2029 "reta entries: %u\n", num);
2032 for (i = 0; i < ret; i++)
2033 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2039 cmd_showport_reta_parsed(void *parsed_result,
2040 __attribute__((unused)) struct cmdline *cl,
2041 __attribute__((unused)) void *data)
2043 struct cmd_showport_reta *res = parsed_result;
2044 struct rte_eth_rss_reta_entry64 reta_conf[8];
2045 struct rte_eth_dev_info dev_info;
2047 memset(&dev_info, 0, sizeof(dev_info));
2048 rte_eth_dev_info_get(res->port_id, &dev_info);
2049 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2050 res->size > ETH_RSS_RETA_SIZE_512) {
2051 printf("Invalid redirection table size: %u\n", res->size);
2055 memset(reta_conf, 0, sizeof(reta_conf));
2056 if (showport_parse_reta_config(reta_conf, res->size,
2057 res->list_of_items) < 0) {
2058 printf("Invalid string: %s for reta masks\n",
2059 res->list_of_items);
2062 port_rss_reta_info(res->port_id, reta_conf, res->size);
2065 cmdline_parse_token_string_t cmd_showport_reta_show =
2066 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2067 cmdline_parse_token_string_t cmd_showport_reta_port =
2068 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2069 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2070 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2071 cmdline_parse_token_string_t cmd_showport_reta_rss =
2072 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2073 cmdline_parse_token_string_t cmd_showport_reta_reta =
2074 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2075 cmdline_parse_token_num_t cmd_showport_reta_size =
2076 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2077 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2078 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2079 list_of_items, NULL);
2081 cmdline_parse_inst_t cmd_showport_reta = {
2082 .f = cmd_showport_reta_parsed,
2084 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2086 (void *)&cmd_showport_reta_show,
2087 (void *)&cmd_showport_reta_port,
2088 (void *)&cmd_showport_reta_port_id,
2089 (void *)&cmd_showport_reta_rss,
2090 (void *)&cmd_showport_reta_reta,
2091 (void *)&cmd_showport_reta_size,
2092 (void *)&cmd_showport_reta_list_of_items,
2097 /* *** Show RSS hash configuration *** */
2098 struct cmd_showport_rss_hash {
2099 cmdline_fixed_string_t show;
2100 cmdline_fixed_string_t port;
2102 cmdline_fixed_string_t rss_hash;
2103 cmdline_fixed_string_t rss_type;
2104 cmdline_fixed_string_t key; /* optional argument */
2107 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2108 __attribute__((unused)) struct cmdline *cl,
2111 struct cmd_showport_rss_hash *res = parsed_result;
2113 port_rss_hash_conf_show(res->port_id, res->rss_type,
2114 show_rss_key != NULL);
2117 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2118 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2119 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2120 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2121 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2122 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2123 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2124 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2126 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2127 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2128 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2129 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2130 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2131 "ipv6-tcp-ex#ipv6-udp-ex");
2132 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2133 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2135 cmdline_parse_inst_t cmd_showport_rss_hash = {
2136 .f = cmd_showport_rss_hash_parsed,
2138 .help_str = "show port <port_id> rss-hash "
2139 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2140 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2141 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2143 (void *)&cmd_showport_rss_hash_show,
2144 (void *)&cmd_showport_rss_hash_port,
2145 (void *)&cmd_showport_rss_hash_port_id,
2146 (void *)&cmd_showport_rss_hash_rss_hash,
2147 (void *)&cmd_showport_rss_hash_rss_hash_info,
2152 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2153 .f = cmd_showport_rss_hash_parsed,
2155 .help_str = "show port <port_id> rss-hash "
2156 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2157 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2158 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2160 (void *)&cmd_showport_rss_hash_show,
2161 (void *)&cmd_showport_rss_hash_port,
2162 (void *)&cmd_showport_rss_hash_port_id,
2163 (void *)&cmd_showport_rss_hash_rss_hash,
2164 (void *)&cmd_showport_rss_hash_rss_hash_info,
2165 (void *)&cmd_showport_rss_hash_rss_key,
2170 /* *** Configure DCB *** */
2171 struct cmd_config_dcb {
2172 cmdline_fixed_string_t port;
2173 cmdline_fixed_string_t config;
2175 cmdline_fixed_string_t dcb;
2176 cmdline_fixed_string_t vt;
2177 cmdline_fixed_string_t vt_en;
2179 cmdline_fixed_string_t pfc;
2180 cmdline_fixed_string_t pfc_en;
2184 cmd_config_dcb_parsed(void *parsed_result,
2185 __attribute__((unused)) struct cmdline *cl,
2186 __attribute__((unused)) void *data)
2188 struct cmd_config_dcb *res = parsed_result;
2189 portid_t port_id = res->port_id;
2190 struct rte_port *port;
2194 port = &ports[port_id];
2195 /** Check if the port is not started **/
2196 if (port->port_status != RTE_PORT_STOPPED) {
2197 printf("Please stop port %d first\n", port_id);
2201 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2202 printf("The invalid number of traffic class,"
2203 " only 4 or 8 allowed.\n");
2207 if (nb_fwd_lcores < res->num_tcs) {
2208 printf("nb_cores shouldn't be less than number of TCs.\n");
2211 if (!strncmp(res->pfc_en, "on", 2))
2216 /* DCB in VT mode */
2217 if (!strncmp(res->vt_en, "on", 2))
2218 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2219 (enum rte_eth_nb_tcs)res->num_tcs,
2222 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2223 (enum rte_eth_nb_tcs)res->num_tcs,
2228 printf("Cannot initialize network ports.\n");
2232 cmd_reconfig_device_queue(port_id, 1, 1);
2235 cmdline_parse_token_string_t cmd_config_dcb_port =
2236 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2237 cmdline_parse_token_string_t cmd_config_dcb_config =
2238 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2239 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2240 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2241 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2242 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2243 cmdline_parse_token_string_t cmd_config_dcb_vt =
2244 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2245 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2246 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2247 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2248 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2249 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2251 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2254 cmdline_parse_inst_t cmd_config_dcb = {
2255 .f = cmd_config_dcb_parsed,
2257 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2259 (void *)&cmd_config_dcb_port,
2260 (void *)&cmd_config_dcb_config,
2261 (void *)&cmd_config_dcb_port_id,
2262 (void *)&cmd_config_dcb_dcb,
2263 (void *)&cmd_config_dcb_vt,
2264 (void *)&cmd_config_dcb_vt_en,
2265 (void *)&cmd_config_dcb_num_tcs,
2266 (void *)&cmd_config_dcb_pfc,
2267 (void *)&cmd_config_dcb_pfc_en,
2272 /* *** configure number of packets per burst *** */
2273 struct cmd_config_burst {
2274 cmdline_fixed_string_t port;
2275 cmdline_fixed_string_t keyword;
2276 cmdline_fixed_string_t all;
2277 cmdline_fixed_string_t name;
2282 cmd_config_burst_parsed(void *parsed_result,
2283 __attribute__((unused)) struct cmdline *cl,
2284 __attribute__((unused)) void *data)
2286 struct cmd_config_burst *res = parsed_result;
2288 if (!all_ports_stopped()) {
2289 printf("Please stop all ports first\n");
2293 if (!strcmp(res->name, "burst")) {
2294 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2295 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2298 nb_pkt_per_burst = res->value;
2300 printf("Unknown parameter\n");
2306 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2309 cmdline_parse_token_string_t cmd_config_burst_port =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2311 cmdline_parse_token_string_t cmd_config_burst_keyword =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2313 cmdline_parse_token_string_t cmd_config_burst_all =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2315 cmdline_parse_token_string_t cmd_config_burst_name =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2317 cmdline_parse_token_num_t cmd_config_burst_value =
2318 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2320 cmdline_parse_inst_t cmd_config_burst = {
2321 .f = cmd_config_burst_parsed,
2323 .help_str = "port config all burst <value>",
2325 (void *)&cmd_config_burst_port,
2326 (void *)&cmd_config_burst_keyword,
2327 (void *)&cmd_config_burst_all,
2328 (void *)&cmd_config_burst_name,
2329 (void *)&cmd_config_burst_value,
2334 /* *** configure rx/tx queues *** */
2335 struct cmd_config_thresh {
2336 cmdline_fixed_string_t port;
2337 cmdline_fixed_string_t keyword;
2338 cmdline_fixed_string_t all;
2339 cmdline_fixed_string_t name;
2344 cmd_config_thresh_parsed(void *parsed_result,
2345 __attribute__((unused)) struct cmdline *cl,
2346 __attribute__((unused)) void *data)
2348 struct cmd_config_thresh *res = parsed_result;
2350 if (!all_ports_stopped()) {
2351 printf("Please stop all ports first\n");
2355 if (!strcmp(res->name, "txpt"))
2356 tx_pthresh = res->value;
2357 else if(!strcmp(res->name, "txht"))
2358 tx_hthresh = res->value;
2359 else if(!strcmp(res->name, "txwt"))
2360 tx_wthresh = res->value;
2361 else if(!strcmp(res->name, "rxpt"))
2362 rx_pthresh = res->value;
2363 else if(!strcmp(res->name, "rxht"))
2364 rx_hthresh = res->value;
2365 else if(!strcmp(res->name, "rxwt"))
2366 rx_wthresh = res->value;
2368 printf("Unknown parameter\n");
2374 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2377 cmdline_parse_token_string_t cmd_config_thresh_port =
2378 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2379 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2380 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2381 cmdline_parse_token_string_t cmd_config_thresh_all =
2382 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2383 cmdline_parse_token_string_t cmd_config_thresh_name =
2384 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2385 "txpt#txht#txwt#rxpt#rxht#rxwt");
2386 cmdline_parse_token_num_t cmd_config_thresh_value =
2387 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2389 cmdline_parse_inst_t cmd_config_thresh = {
2390 .f = cmd_config_thresh_parsed,
2392 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2394 (void *)&cmd_config_thresh_port,
2395 (void *)&cmd_config_thresh_keyword,
2396 (void *)&cmd_config_thresh_all,
2397 (void *)&cmd_config_thresh_name,
2398 (void *)&cmd_config_thresh_value,
2403 /* *** configure free/rs threshold *** */
2404 struct cmd_config_threshold {
2405 cmdline_fixed_string_t port;
2406 cmdline_fixed_string_t keyword;
2407 cmdline_fixed_string_t all;
2408 cmdline_fixed_string_t name;
2413 cmd_config_threshold_parsed(void *parsed_result,
2414 __attribute__((unused)) struct cmdline *cl,
2415 __attribute__((unused)) void *data)
2417 struct cmd_config_threshold *res = parsed_result;
2419 if (!all_ports_stopped()) {
2420 printf("Please stop all ports first\n");
2424 if (!strcmp(res->name, "txfreet"))
2425 tx_free_thresh = res->value;
2426 else if (!strcmp(res->name, "txrst"))
2427 tx_rs_thresh = res->value;
2428 else if (!strcmp(res->name, "rxfreet"))
2429 rx_free_thresh = res->value;
2431 printf("Unknown parameter\n");
2437 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2440 cmdline_parse_token_string_t cmd_config_threshold_port =
2441 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2442 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2443 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2445 cmdline_parse_token_string_t cmd_config_threshold_all =
2446 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2447 cmdline_parse_token_string_t cmd_config_threshold_name =
2448 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2449 "txfreet#txrst#rxfreet");
2450 cmdline_parse_token_num_t cmd_config_threshold_value =
2451 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2453 cmdline_parse_inst_t cmd_config_threshold = {
2454 .f = cmd_config_threshold_parsed,
2456 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2458 (void *)&cmd_config_threshold_port,
2459 (void *)&cmd_config_threshold_keyword,
2460 (void *)&cmd_config_threshold_all,
2461 (void *)&cmd_config_threshold_name,
2462 (void *)&cmd_config_threshold_value,
2468 struct cmd_stop_result {
2469 cmdline_fixed_string_t stop;
2472 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2473 __attribute__((unused)) struct cmdline *cl,
2474 __attribute__((unused)) void *data)
2476 stop_packet_forwarding();
2479 cmdline_parse_token_string_t cmd_stop_stop =
2480 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2482 cmdline_parse_inst_t cmd_stop = {
2483 .f = cmd_stop_parsed,
2485 .help_str = "stop: Stop packet forwarding",
2487 (void *)&cmd_stop_stop,
2492 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2495 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2496 unsigned int *parsed_items, int check_unique_values)
2498 unsigned int nb_item;
2506 * First parse all items in the list and store their value.
2511 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2513 if ((c >= '0') && (c <= '9')) {
2514 value = (unsigned int) (value * 10 + (c - '0'));
2519 printf("character %c is not a decimal digit\n", c);
2523 printf("No valid value before comma\n");
2526 if (nb_item < max_items) {
2527 parsed_items[nb_item] = value;
2533 if (nb_item >= max_items) {
2534 printf("Number of %s = %u > %u (maximum items)\n",
2535 item_name, nb_item + 1, max_items);
2538 parsed_items[nb_item++] = value;
2539 if (! check_unique_values)
2543 * Then, check that all values in the list are differents.
2544 * No optimization here...
2546 for (i = 0; i < nb_item; i++) {
2547 for (j = i + 1; j < nb_item; j++) {
2548 if (parsed_items[j] == parsed_items[i]) {
2549 printf("duplicated %s %u at index %u and %u\n",
2550 item_name, parsed_items[i], i, j);
2558 struct cmd_set_list_result {
2559 cmdline_fixed_string_t cmd_keyword;
2560 cmdline_fixed_string_t list_name;
2561 cmdline_fixed_string_t list_of_items;
2564 static void cmd_set_list_parsed(void *parsed_result,
2565 __attribute__((unused)) struct cmdline *cl,
2566 __attribute__((unused)) void *data)
2568 struct cmd_set_list_result *res;
2570 unsigned int lcorelist[RTE_MAX_LCORE];
2571 unsigned int portlist[RTE_MAX_ETHPORTS];
2573 unsigned int nb_item;
2575 if (test_done == 0) {
2576 printf("Please stop forwarding first\n");
2580 res = parsed_result;
2581 if (!strcmp(res->list_name, "corelist")) {
2582 nb_item = parse_item_list(res->list_of_items, "core",
2584 parsed_items.lcorelist, 1);
2586 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2591 if (!strcmp(res->list_name, "portlist")) {
2592 nb_item = parse_item_list(res->list_of_items, "port",
2594 parsed_items.portlist, 1);
2596 set_fwd_ports_list(parsed_items.portlist, nb_item);
2602 cmdline_parse_token_string_t cmd_set_list_keyword =
2603 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2605 cmdline_parse_token_string_t cmd_set_list_name =
2606 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2607 "corelist#portlist");
2608 cmdline_parse_token_string_t cmd_set_list_of_items =
2609 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2612 cmdline_parse_inst_t cmd_set_fwd_list = {
2613 .f = cmd_set_list_parsed,
2615 .help_str = "set corelist|portlist <list0[,list1]*>",
2617 (void *)&cmd_set_list_keyword,
2618 (void *)&cmd_set_list_name,
2619 (void *)&cmd_set_list_of_items,
2624 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2626 struct cmd_setmask_result {
2627 cmdline_fixed_string_t set;
2628 cmdline_fixed_string_t mask;
2632 static void cmd_set_mask_parsed(void *parsed_result,
2633 __attribute__((unused)) struct cmdline *cl,
2634 __attribute__((unused)) void *data)
2636 struct cmd_setmask_result *res = parsed_result;
2638 if (test_done == 0) {
2639 printf("Please stop forwarding first\n");
2642 if (!strcmp(res->mask, "coremask")) {
2643 set_fwd_lcores_mask(res->hexavalue);
2645 } else if (!strcmp(res->mask, "portmask")) {
2646 set_fwd_ports_mask(res->hexavalue);
2651 cmdline_parse_token_string_t cmd_setmask_set =
2652 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2653 cmdline_parse_token_string_t cmd_setmask_mask =
2654 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2655 "coremask#portmask");
2656 cmdline_parse_token_num_t cmd_setmask_value =
2657 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2659 cmdline_parse_inst_t cmd_set_fwd_mask = {
2660 .f = cmd_set_mask_parsed,
2662 .help_str = "set coremask|portmask <hexadecimal value>",
2664 (void *)&cmd_setmask_set,
2665 (void *)&cmd_setmask_mask,
2666 (void *)&cmd_setmask_value,
2672 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2674 struct cmd_set_result {
2675 cmdline_fixed_string_t set;
2676 cmdline_fixed_string_t what;
2680 static void cmd_set_parsed(void *parsed_result,
2681 __attribute__((unused)) struct cmdline *cl,
2682 __attribute__((unused)) void *data)
2684 struct cmd_set_result *res = parsed_result;
2685 if (!strcmp(res->what, "nbport")) {
2686 set_fwd_ports_number(res->value);
2688 } else if (!strcmp(res->what, "nbcore")) {
2689 set_fwd_lcores_number(res->value);
2691 } else if (!strcmp(res->what, "burst"))
2692 set_nb_pkt_per_burst(res->value);
2693 else if (!strcmp(res->what, "verbose"))
2694 set_verbose_level(res->value);
2697 cmdline_parse_token_string_t cmd_set_set =
2698 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2699 cmdline_parse_token_string_t cmd_set_what =
2700 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2701 "nbport#nbcore#burst#verbose");
2702 cmdline_parse_token_num_t cmd_set_value =
2703 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2705 cmdline_parse_inst_t cmd_set_numbers = {
2706 .f = cmd_set_parsed,
2708 .help_str = "set nbport|nbcore|burst|verbose <value>",
2710 (void *)&cmd_set_set,
2711 (void *)&cmd_set_what,
2712 (void *)&cmd_set_value,
2717 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2719 struct cmd_set_txpkts_result {
2720 cmdline_fixed_string_t cmd_keyword;
2721 cmdline_fixed_string_t txpkts;
2722 cmdline_fixed_string_t seg_lengths;
2726 cmd_set_txpkts_parsed(void *parsed_result,
2727 __attribute__((unused)) struct cmdline *cl,
2728 __attribute__((unused)) void *data)
2730 struct cmd_set_txpkts_result *res;
2731 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2732 unsigned int nb_segs;
2734 res = parsed_result;
2735 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2736 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2738 set_tx_pkt_segments(seg_lengths, nb_segs);
2741 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2742 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2743 cmd_keyword, "set");
2744 cmdline_parse_token_string_t cmd_set_txpkts_name =
2745 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2747 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2748 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2751 cmdline_parse_inst_t cmd_set_txpkts = {
2752 .f = cmd_set_txpkts_parsed,
2754 .help_str = "set txpkts <len0[,len1]*>",
2756 (void *)&cmd_set_txpkts_keyword,
2757 (void *)&cmd_set_txpkts_name,
2758 (void *)&cmd_set_txpkts_lengths,
2763 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2765 struct cmd_set_txsplit_result {
2766 cmdline_fixed_string_t cmd_keyword;
2767 cmdline_fixed_string_t txsplit;
2768 cmdline_fixed_string_t mode;
2772 cmd_set_txsplit_parsed(void *parsed_result,
2773 __attribute__((unused)) struct cmdline *cl,
2774 __attribute__((unused)) void *data)
2776 struct cmd_set_txsplit_result *res;
2778 res = parsed_result;
2779 set_tx_pkt_split(res->mode);
2782 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2783 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2784 cmd_keyword, "set");
2785 cmdline_parse_token_string_t cmd_set_txsplit_name =
2786 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2787 txsplit, "txsplit");
2788 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2789 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2792 cmdline_parse_inst_t cmd_set_txsplit = {
2793 .f = cmd_set_txsplit_parsed,
2795 .help_str = "set txsplit on|off|rand",
2797 (void *)&cmd_set_txsplit_keyword,
2798 (void *)&cmd_set_txsplit_name,
2799 (void *)&cmd_set_txsplit_mode,
2804 /* *** CONFIG TX QUEUE FLAGS *** */
2806 struct cmd_config_txqflags_result {
2807 cmdline_fixed_string_t port;
2808 cmdline_fixed_string_t config;
2809 cmdline_fixed_string_t all;
2810 cmdline_fixed_string_t what;
2814 static void cmd_config_txqflags_parsed(void *parsed_result,
2815 __attribute__((unused)) struct cmdline *cl,
2816 __attribute__((unused)) void *data)
2818 struct cmd_config_txqflags_result *res = parsed_result;
2820 if (!all_ports_stopped()) {
2821 printf("Please stop all ports first\n");
2825 if (strcmp(res->what, "txqflags")) {
2826 printf("Unknown parameter\n");
2830 if (res->hexvalue >= 0) {
2831 txq_flags = res->hexvalue;
2833 printf("txqflags must be >= 0\n");
2839 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2842 cmdline_parse_token_string_t cmd_config_txqflags_port =
2843 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2845 cmdline_parse_token_string_t cmd_config_txqflags_config =
2846 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2848 cmdline_parse_token_string_t cmd_config_txqflags_all =
2849 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2851 cmdline_parse_token_string_t cmd_config_txqflags_what =
2852 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2854 cmdline_parse_token_num_t cmd_config_txqflags_value =
2855 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2858 cmdline_parse_inst_t cmd_config_txqflags = {
2859 .f = cmd_config_txqflags_parsed,
2861 .help_str = "port config all txqflags <value>",
2863 (void *)&cmd_config_txqflags_port,
2864 (void *)&cmd_config_txqflags_config,
2865 (void *)&cmd_config_txqflags_all,
2866 (void *)&cmd_config_txqflags_what,
2867 (void *)&cmd_config_txqflags_value,
2872 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2873 struct cmd_rx_vlan_filter_all_result {
2874 cmdline_fixed_string_t rx_vlan;
2875 cmdline_fixed_string_t what;
2876 cmdline_fixed_string_t all;
2881 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2882 __attribute__((unused)) struct cmdline *cl,
2883 __attribute__((unused)) void *data)
2885 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2887 if (!strcmp(res->what, "add"))
2888 rx_vlan_all_filter_set(res->port_id, 1);
2890 rx_vlan_all_filter_set(res->port_id, 0);
2893 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2894 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2895 rx_vlan, "rx_vlan");
2896 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2897 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2899 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2900 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2902 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2903 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2906 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2907 .f = cmd_rx_vlan_filter_all_parsed,
2909 .help_str = "rx_vlan add|rm all <port_id>: "
2910 "Add/Remove all identifiers to/from the set of VLAN "
2911 "identifiers filtered by a port",
2913 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2914 (void *)&cmd_rx_vlan_filter_all_what,
2915 (void *)&cmd_rx_vlan_filter_all_all,
2916 (void *)&cmd_rx_vlan_filter_all_portid,
2921 /* *** VLAN OFFLOAD SET ON A PORT *** */
2922 struct cmd_vlan_offload_result {
2923 cmdline_fixed_string_t vlan;
2924 cmdline_fixed_string_t set;
2925 cmdline_fixed_string_t vlan_type;
2926 cmdline_fixed_string_t what;
2927 cmdline_fixed_string_t on;
2928 cmdline_fixed_string_t port_id;
2932 cmd_vlan_offload_parsed(void *parsed_result,
2933 __attribute__((unused)) struct cmdline *cl,
2934 __attribute__((unused)) void *data)
2937 struct cmd_vlan_offload_result *res = parsed_result;
2940 portid_t port_id = 0;
2944 len = strnlen(str, STR_TOKEN_SIZE);
2946 /* Get port_id first */
2954 tmp = strtoul(str, NULL, 0);
2955 /* If port_id greater that what portid_t can represent, return */
2956 if(tmp >= RTE_MAX_ETHPORTS)
2958 port_id = (portid_t)tmp;
2960 if (!strcmp(res->on, "on"))
2965 if (!strcmp(res->what, "strip"))
2966 rx_vlan_strip_set(port_id, on);
2967 else if(!strcmp(res->what, "stripq")){
2968 uint16_t queue_id = 0;
2970 /* No queue_id, return */
2972 printf("must specify (port,queue_id)\n");
2975 tmp = strtoul(str + i + 1, NULL, 0);
2976 /* If queue_id greater that what 16-bits can represent, return */
2980 queue_id = (uint16_t)tmp;
2981 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2983 else if (!strcmp(res->what, "filter"))
2984 rx_vlan_filter_set(port_id, on);
2986 vlan_extend_set(port_id, on);
2991 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2992 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2994 cmdline_parse_token_string_t cmd_vlan_offload_set =
2995 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2997 cmdline_parse_token_string_t cmd_vlan_offload_what =
2998 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2999 what, "strip#filter#qinq#stripq");
3000 cmdline_parse_token_string_t cmd_vlan_offload_on =
3001 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3003 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3004 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3007 cmdline_parse_inst_t cmd_vlan_offload = {
3008 .f = cmd_vlan_offload_parsed,
3010 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3011 "<port_id[,queue_id]>: "
3012 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3014 (void *)&cmd_vlan_offload_vlan,
3015 (void *)&cmd_vlan_offload_set,
3016 (void *)&cmd_vlan_offload_what,
3017 (void *)&cmd_vlan_offload_on,
3018 (void *)&cmd_vlan_offload_portid,
3023 /* *** VLAN TPID SET ON A PORT *** */
3024 struct cmd_vlan_tpid_result {
3025 cmdline_fixed_string_t vlan;
3026 cmdline_fixed_string_t set;
3027 cmdline_fixed_string_t vlan_type;
3028 cmdline_fixed_string_t what;
3034 cmd_vlan_tpid_parsed(void *parsed_result,
3035 __attribute__((unused)) struct cmdline *cl,
3036 __attribute__((unused)) void *data)
3038 struct cmd_vlan_tpid_result *res = parsed_result;
3039 enum rte_vlan_type vlan_type;
3041 if (!strcmp(res->vlan_type, "inner"))
3042 vlan_type = ETH_VLAN_TYPE_INNER;
3043 else if (!strcmp(res->vlan_type, "outer"))
3044 vlan_type = ETH_VLAN_TYPE_OUTER;
3046 printf("Unknown vlan type\n");
3049 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3052 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3053 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3055 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3056 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3058 cmdline_parse_token_string_t cmd_vlan_type =
3059 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3060 vlan_type, "inner#outer");
3061 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3062 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3064 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3065 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3067 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3068 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3071 cmdline_parse_inst_t cmd_vlan_tpid = {
3072 .f = cmd_vlan_tpid_parsed,
3074 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3075 "Set the VLAN Ether type",
3077 (void *)&cmd_vlan_tpid_vlan,
3078 (void *)&cmd_vlan_tpid_set,
3079 (void *)&cmd_vlan_type,
3080 (void *)&cmd_vlan_tpid_what,
3081 (void *)&cmd_vlan_tpid_tpid,
3082 (void *)&cmd_vlan_tpid_portid,
3087 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3088 struct cmd_rx_vlan_filter_result {
3089 cmdline_fixed_string_t rx_vlan;
3090 cmdline_fixed_string_t what;
3096 cmd_rx_vlan_filter_parsed(void *parsed_result,
3097 __attribute__((unused)) struct cmdline *cl,
3098 __attribute__((unused)) void *data)
3100 struct cmd_rx_vlan_filter_result *res = parsed_result;
3102 if (!strcmp(res->what, "add"))
3103 rx_vft_set(res->port_id, res->vlan_id, 1);
3105 rx_vft_set(res->port_id, res->vlan_id, 0);
3108 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3109 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3110 rx_vlan, "rx_vlan");
3111 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3112 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3114 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3115 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3117 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3118 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3121 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3122 .f = cmd_rx_vlan_filter_parsed,
3124 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3125 "Add/Remove a VLAN identifier to/from the set of VLAN "
3126 "identifiers filtered by a port",
3128 (void *)&cmd_rx_vlan_filter_rx_vlan,
3129 (void *)&cmd_rx_vlan_filter_what,
3130 (void *)&cmd_rx_vlan_filter_vlanid,
3131 (void *)&cmd_rx_vlan_filter_portid,
3136 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3137 struct cmd_tx_vlan_set_result {
3138 cmdline_fixed_string_t tx_vlan;
3139 cmdline_fixed_string_t set;
3145 cmd_tx_vlan_set_parsed(void *parsed_result,
3146 __attribute__((unused)) struct cmdline *cl,
3147 __attribute__((unused)) void *data)
3149 struct cmd_tx_vlan_set_result *res = parsed_result;
3151 tx_vlan_set(res->port_id, res->vlan_id);
3154 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3155 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3156 tx_vlan, "tx_vlan");
3157 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3158 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3160 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3161 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3163 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3164 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3167 cmdline_parse_inst_t cmd_tx_vlan_set = {
3168 .f = cmd_tx_vlan_set_parsed,
3170 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3171 "Enable hardware insertion of a single VLAN header "
3172 "with a given TAG Identifier in packets sent on a port",
3174 (void *)&cmd_tx_vlan_set_tx_vlan,
3175 (void *)&cmd_tx_vlan_set_set,
3176 (void *)&cmd_tx_vlan_set_portid,
3177 (void *)&cmd_tx_vlan_set_vlanid,
3182 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3183 struct cmd_tx_vlan_set_qinq_result {
3184 cmdline_fixed_string_t tx_vlan;
3185 cmdline_fixed_string_t set;
3188 uint16_t vlan_id_outer;
3192 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3193 __attribute__((unused)) struct cmdline *cl,
3194 __attribute__((unused)) void *data)
3196 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3198 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3201 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3202 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3203 tx_vlan, "tx_vlan");
3204 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3205 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3207 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3208 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3210 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3211 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3213 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3214 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3215 vlan_id_outer, UINT16);
3217 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3218 .f = cmd_tx_vlan_set_qinq_parsed,
3220 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3221 "Enable hardware insertion of double VLAN header "
3222 "with given TAG Identifiers in packets sent on a port",
3224 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3225 (void *)&cmd_tx_vlan_set_qinq_set,
3226 (void *)&cmd_tx_vlan_set_qinq_portid,
3227 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3228 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3233 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3234 struct cmd_tx_vlan_set_pvid_result {
3235 cmdline_fixed_string_t tx_vlan;
3236 cmdline_fixed_string_t set;
3237 cmdline_fixed_string_t pvid;
3240 cmdline_fixed_string_t mode;
3244 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3245 __attribute__((unused)) struct cmdline *cl,
3246 __attribute__((unused)) void *data)
3248 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3250 if (strcmp(res->mode, "on") == 0)
3251 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3253 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3256 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3257 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3258 tx_vlan, "tx_vlan");
3259 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3260 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3262 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3263 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3265 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3266 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3268 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3269 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3271 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3272 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3275 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3276 .f = cmd_tx_vlan_set_pvid_parsed,
3278 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3280 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3281 (void *)&cmd_tx_vlan_set_pvid_set,
3282 (void *)&cmd_tx_vlan_set_pvid_pvid,
3283 (void *)&cmd_tx_vlan_set_pvid_port_id,
3284 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3285 (void *)&cmd_tx_vlan_set_pvid_mode,
3290 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3291 struct cmd_tx_vlan_reset_result {
3292 cmdline_fixed_string_t tx_vlan;
3293 cmdline_fixed_string_t reset;
3298 cmd_tx_vlan_reset_parsed(void *parsed_result,
3299 __attribute__((unused)) struct cmdline *cl,
3300 __attribute__((unused)) void *data)
3302 struct cmd_tx_vlan_reset_result *res = parsed_result;
3304 tx_vlan_reset(res->port_id);
3307 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3308 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3309 tx_vlan, "tx_vlan");
3310 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3311 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3313 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3314 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3317 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3318 .f = cmd_tx_vlan_reset_parsed,
3320 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3321 "VLAN header in packets sent on a port",
3323 (void *)&cmd_tx_vlan_reset_tx_vlan,
3324 (void *)&cmd_tx_vlan_reset_reset,
3325 (void *)&cmd_tx_vlan_reset_portid,
3331 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3332 struct cmd_csum_result {
3333 cmdline_fixed_string_t csum;
3334 cmdline_fixed_string_t mode;
3335 cmdline_fixed_string_t proto;
3336 cmdline_fixed_string_t hwsw;
3341 csum_show(int port_id)
3343 struct rte_eth_dev_info dev_info;
3346 ol_flags = ports[port_id].tx_ol_flags;
3347 printf("Parse tunnel is %s\n",
3348 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3349 printf("IP checksum offload is %s\n",
3350 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3351 printf("UDP checksum offload is %s\n",
3352 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3353 printf("TCP checksum offload is %s\n",
3354 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3355 printf("SCTP checksum offload is %s\n",
3356 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3357 printf("Outer-Ip checksum offload is %s\n",
3358 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3360 /* display warnings if configuration is not supported by the NIC */
3361 rte_eth_dev_info_get(port_id, &dev_info);
3362 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3363 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3364 printf("Warning: hardware IP checksum enabled but not "
3365 "supported by port %d\n", port_id);
3367 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3368 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3369 printf("Warning: hardware UDP checksum enabled but not "
3370 "supported by port %d\n", port_id);
3372 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3373 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3374 printf("Warning: hardware TCP checksum enabled but not "
3375 "supported by port %d\n", port_id);
3377 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3378 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3379 printf("Warning: hardware SCTP checksum enabled but not "
3380 "supported by port %d\n", port_id);
3382 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3383 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3384 printf("Warning: hardware outer IP checksum enabled but not "
3385 "supported by port %d\n", port_id);
3390 cmd_csum_parsed(void *parsed_result,
3391 __attribute__((unused)) struct cmdline *cl,
3392 __attribute__((unused)) void *data)
3394 struct cmd_csum_result *res = parsed_result;
3398 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3399 printf("invalid port %d\n", res->port_id);
3403 if (!strcmp(res->mode, "set")) {
3405 if (!strcmp(res->hwsw, "hw"))
3408 if (!strcmp(res->proto, "ip")) {
3409 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3410 } else if (!strcmp(res->proto, "udp")) {
3411 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3412 } else if (!strcmp(res->proto, "tcp")) {
3413 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3414 } else if (!strcmp(res->proto, "sctp")) {
3415 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3416 } else if (!strcmp(res->proto, "outer-ip")) {
3417 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3421 ports[res->port_id].tx_ol_flags |= mask;
3423 ports[res->port_id].tx_ol_flags &= (~mask);
3425 csum_show(res->port_id);
3428 cmdline_parse_token_string_t cmd_csum_csum =
3429 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3431 cmdline_parse_token_string_t cmd_csum_mode =
3432 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3434 cmdline_parse_token_string_t cmd_csum_proto =
3435 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3436 proto, "ip#tcp#udp#sctp#outer-ip");
3437 cmdline_parse_token_string_t cmd_csum_hwsw =
3438 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3440 cmdline_parse_token_num_t cmd_csum_portid =
3441 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3444 cmdline_parse_inst_t cmd_csum_set = {
3445 .f = cmd_csum_parsed,
3447 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3448 "Enable/Disable hardware calculation of L3/L4 checksum when "
3449 "using csum forward engine",
3451 (void *)&cmd_csum_csum,
3452 (void *)&cmd_csum_mode,
3453 (void *)&cmd_csum_proto,
3454 (void *)&cmd_csum_hwsw,
3455 (void *)&cmd_csum_portid,
3460 cmdline_parse_token_string_t cmd_csum_mode_show =
3461 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3464 cmdline_parse_inst_t cmd_csum_show = {
3465 .f = cmd_csum_parsed,
3467 .help_str = "csum show <port_id>: Show checksum offload configuration",
3469 (void *)&cmd_csum_csum,
3470 (void *)&cmd_csum_mode_show,
3471 (void *)&cmd_csum_portid,
3476 /* Enable/disable tunnel parsing */
3477 struct cmd_csum_tunnel_result {
3478 cmdline_fixed_string_t csum;
3479 cmdline_fixed_string_t parse;
3480 cmdline_fixed_string_t onoff;
3485 cmd_csum_tunnel_parsed(void *parsed_result,
3486 __attribute__((unused)) struct cmdline *cl,
3487 __attribute__((unused)) void *data)
3489 struct cmd_csum_tunnel_result *res = parsed_result;
3491 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3494 if (!strcmp(res->onoff, "on"))
3495 ports[res->port_id].tx_ol_flags |=
3496 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3498 ports[res->port_id].tx_ol_flags &=
3499 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3501 csum_show(res->port_id);
3504 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3505 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3507 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3508 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3509 parse, "parse_tunnel");
3510 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3511 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3513 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3514 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3517 cmdline_parse_inst_t cmd_csum_tunnel = {
3518 .f = cmd_csum_tunnel_parsed,
3520 .help_str = "csum parse_tunnel on|off <port_id>: "
3521 "Enable/Disable parsing of tunnels for csum engine",
3523 (void *)&cmd_csum_tunnel_csum,
3524 (void *)&cmd_csum_tunnel_parse,
3525 (void *)&cmd_csum_tunnel_onoff,
3526 (void *)&cmd_csum_tunnel_portid,
3531 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3532 struct cmd_tso_set_result {
3533 cmdline_fixed_string_t tso;
3534 cmdline_fixed_string_t mode;
3540 cmd_tso_set_parsed(void *parsed_result,
3541 __attribute__((unused)) struct cmdline *cl,
3542 __attribute__((unused)) void *data)
3544 struct cmd_tso_set_result *res = parsed_result;
3545 struct rte_eth_dev_info dev_info;
3547 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3550 if (!strcmp(res->mode, "set"))
3551 ports[res->port_id].tso_segsz = res->tso_segsz;
3553 if (ports[res->port_id].tso_segsz == 0)
3554 printf("TSO for non-tunneled packets is disabled\n");
3556 printf("TSO segment size for non-tunneled packets is %d\n",
3557 ports[res->port_id].tso_segsz);
3559 /* display warnings if configuration is not supported by the NIC */
3560 rte_eth_dev_info_get(res->port_id, &dev_info);
3561 if ((ports[res->port_id].tso_segsz != 0) &&
3562 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3563 printf("Warning: TSO enabled but not "
3564 "supported by port %d\n", res->port_id);
3568 cmdline_parse_token_string_t cmd_tso_set_tso =
3569 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3571 cmdline_parse_token_string_t cmd_tso_set_mode =
3572 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3574 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3575 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3577 cmdline_parse_token_num_t cmd_tso_set_portid =
3578 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3581 cmdline_parse_inst_t cmd_tso_set = {
3582 .f = cmd_tso_set_parsed,
3584 .help_str = "tso set <tso_segsz> <port_id>: "
3585 "Set TSO segment size of non-tunneled packets for csum engine "
3588 (void *)&cmd_tso_set_tso,
3589 (void *)&cmd_tso_set_mode,
3590 (void *)&cmd_tso_set_tso_segsz,
3591 (void *)&cmd_tso_set_portid,
3596 cmdline_parse_token_string_t cmd_tso_show_mode =
3597 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3601 cmdline_parse_inst_t cmd_tso_show = {
3602 .f = cmd_tso_set_parsed,
3604 .help_str = "tso show <port_id>: "
3605 "Show TSO segment size of non-tunneled packets for csum engine",
3607 (void *)&cmd_tso_set_tso,
3608 (void *)&cmd_tso_show_mode,
3609 (void *)&cmd_tso_set_portid,
3614 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3615 struct cmd_tunnel_tso_set_result {
3616 cmdline_fixed_string_t tso;
3617 cmdline_fixed_string_t mode;
3623 check_tunnel_tso_nic_support(uint8_t port_id)
3625 struct rte_eth_dev_info dev_info;
3627 rte_eth_dev_info_get(port_id, &dev_info);
3628 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3629 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3630 "supported by port %d\n", port_id);
3631 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3632 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3633 "supported by port %d\n", port_id);
3634 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3635 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3636 "supported by port %d\n", port_id);
3637 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3638 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3639 "supported by port %d\n", port_id);
3643 cmd_tunnel_tso_set_parsed(void *parsed_result,
3644 __attribute__((unused)) struct cmdline *cl,
3645 __attribute__((unused)) void *data)
3647 struct cmd_tunnel_tso_set_result *res = parsed_result;
3649 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3652 if (!strcmp(res->mode, "set"))
3653 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3655 if (ports[res->port_id].tunnel_tso_segsz == 0)
3656 printf("TSO for tunneled packets is disabled\n");
3658 printf("TSO segment size for tunneled packets is %d\n",
3659 ports[res->port_id].tunnel_tso_segsz);
3661 /* Below conditions are needed to make it work:
3662 * (1) tunnel TSO is supported by the NIC;
3663 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3665 * (3) for tunneled pkts with outer L3 of IPv4,
3666 * "csum set outer-ip" must be set to hw, because after tso,
3667 * total_len of outer IP header is changed, and the checksum
3668 * of outer IP header calculated by sw should be wrong; that
3669 * is not necessary for IPv6 tunneled pkts because there's no
3670 * checksum in IP header anymore.
3672 check_tunnel_tso_nic_support(res->port_id);
3674 if (!(ports[res->port_id].tx_ol_flags &
3675 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3676 printf("Warning: csum parse_tunnel must be set "
3677 "so that tunneled packets are recognized\n");
3678 if (!(ports[res->port_id].tx_ol_flags &
3679 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3680 printf("Warning: csum set outer-ip must be set to hw "
3681 "if outer L3 is IPv4; not necessary for IPv6\n");
3685 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3686 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3688 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3689 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3691 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3692 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3694 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3695 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3698 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3699 .f = cmd_tunnel_tso_set_parsed,
3701 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3702 "Set TSO segment size of tunneled packets for csum engine "
3705 (void *)&cmd_tunnel_tso_set_tso,
3706 (void *)&cmd_tunnel_tso_set_mode,
3707 (void *)&cmd_tunnel_tso_set_tso_segsz,
3708 (void *)&cmd_tunnel_tso_set_portid,
3713 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3714 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3718 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3719 .f = cmd_tunnel_tso_set_parsed,
3721 .help_str = "tunnel_tso show <port_id> "
3722 "Show TSO segment size of tunneled packets for csum engine",
3724 (void *)&cmd_tunnel_tso_set_tso,
3725 (void *)&cmd_tunnel_tso_show_mode,
3726 (void *)&cmd_tunnel_tso_set_portid,
3731 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3732 struct cmd_set_flush_rx {
3733 cmdline_fixed_string_t set;
3734 cmdline_fixed_string_t flush_rx;
3735 cmdline_fixed_string_t mode;
3739 cmd_set_flush_rx_parsed(void *parsed_result,
3740 __attribute__((unused)) struct cmdline *cl,
3741 __attribute__((unused)) void *data)
3743 struct cmd_set_flush_rx *res = parsed_result;
3744 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3747 cmdline_parse_token_string_t cmd_setflushrx_set =
3748 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3750 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3751 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3752 flush_rx, "flush_rx");
3753 cmdline_parse_token_string_t cmd_setflushrx_mode =
3754 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3758 cmdline_parse_inst_t cmd_set_flush_rx = {
3759 .f = cmd_set_flush_rx_parsed,
3760 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3763 (void *)&cmd_setflushrx_set,
3764 (void *)&cmd_setflushrx_flush_rx,
3765 (void *)&cmd_setflushrx_mode,
3770 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3771 struct cmd_set_link_check {
3772 cmdline_fixed_string_t set;
3773 cmdline_fixed_string_t link_check;
3774 cmdline_fixed_string_t mode;
3778 cmd_set_link_check_parsed(void *parsed_result,
3779 __attribute__((unused)) struct cmdline *cl,
3780 __attribute__((unused)) void *data)
3782 struct cmd_set_link_check *res = parsed_result;
3783 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3786 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3789 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3790 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3791 link_check, "link_check");
3792 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3793 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3797 cmdline_parse_inst_t cmd_set_link_check = {
3798 .f = cmd_set_link_check_parsed,
3799 .help_str = "set link_check on|off: Enable/Disable link status check "
3800 "when starting/stopping a port",
3803 (void *)&cmd_setlinkcheck_set,
3804 (void *)&cmd_setlinkcheck_link_check,
3805 (void *)&cmd_setlinkcheck_mode,
3810 #ifdef RTE_NIC_BYPASS
3811 /* *** SET NIC BYPASS MODE *** */
3812 struct cmd_set_bypass_mode_result {
3813 cmdline_fixed_string_t set;
3814 cmdline_fixed_string_t bypass;
3815 cmdline_fixed_string_t mode;
3816 cmdline_fixed_string_t value;
3821 cmd_set_bypass_mode_parsed(void *parsed_result,
3822 __attribute__((unused)) struct cmdline *cl,
3823 __attribute__((unused)) void *data)
3825 struct cmd_set_bypass_mode_result *res = parsed_result;
3826 portid_t port_id = res->port_id;
3827 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3829 if (!strcmp(res->value, "bypass"))
3830 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3831 else if (!strcmp(res->value, "isolate"))
3832 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3834 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3836 /* Set the bypass mode for the relevant port. */
3837 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3838 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3842 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3843 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3845 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3846 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3848 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3849 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3851 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3853 value, "normal#bypass#isolate");
3854 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3855 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3858 cmdline_parse_inst_t cmd_set_bypass_mode = {
3859 .f = cmd_set_bypass_mode_parsed,
3860 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3861 "Set the NIC bypass mode for port_id",
3864 (void *)&cmd_setbypass_mode_set,
3865 (void *)&cmd_setbypass_mode_bypass,
3866 (void *)&cmd_setbypass_mode_mode,
3867 (void *)&cmd_setbypass_mode_value,
3868 (void *)&cmd_setbypass_mode_port,
3873 /* *** SET NIC BYPASS EVENT *** */
3874 struct cmd_set_bypass_event_result {
3875 cmdline_fixed_string_t set;
3876 cmdline_fixed_string_t bypass;
3877 cmdline_fixed_string_t event;
3878 cmdline_fixed_string_t event_value;
3879 cmdline_fixed_string_t mode;
3880 cmdline_fixed_string_t mode_value;
3885 cmd_set_bypass_event_parsed(void *parsed_result,
3886 __attribute__((unused)) struct cmdline *cl,
3887 __attribute__((unused)) void *data)
3890 struct cmd_set_bypass_event_result *res = parsed_result;
3891 portid_t port_id = res->port_id;
3892 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3893 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3895 if (!strcmp(res->event_value, "timeout"))
3896 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3897 else if (!strcmp(res->event_value, "os_on"))
3898 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3899 else if (!strcmp(res->event_value, "os_off"))
3900 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3901 else if (!strcmp(res->event_value, "power_on"))
3902 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3903 else if (!strcmp(res->event_value, "power_off"))
3904 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3906 bypass_event = RTE_BYPASS_EVENT_NONE;
3908 if (!strcmp(res->mode_value, "bypass"))
3909 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3910 else if (!strcmp(res->mode_value, "isolate"))
3911 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3913 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3915 /* Set the watchdog timeout. */
3916 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3919 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3920 (rc = rte_eth_dev_wd_timeout_store(port_id,
3921 bypass_timeout)) != 0) {
3922 printf("Failed to set timeout value %u "
3923 "for port %d, errto code: %d.\n",
3924 bypass_timeout, port_id, rc);
3928 /* Set the bypass event to transition to bypass mode. */
3929 if (0 != rte_eth_dev_bypass_event_store(port_id,
3930 bypass_event, bypass_mode)) {
3931 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3936 cmdline_parse_token_string_t cmd_setbypass_event_set =
3937 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3939 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3940 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3942 cmdline_parse_token_string_t cmd_setbypass_event_event =
3943 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3945 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3946 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3947 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3948 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3949 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3951 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3952 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3953 mode_value, "normal#bypass#isolate");
3954 cmdline_parse_token_num_t cmd_setbypass_event_port =
3955 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3958 cmdline_parse_inst_t cmd_set_bypass_event = {
3959 .f = cmd_set_bypass_event_parsed,
3960 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
3961 "power_off mode normal|bypass|isolate <port_id>: "
3962 "Set the NIC bypass event mode for port_id",
3965 (void *)&cmd_setbypass_event_set,
3966 (void *)&cmd_setbypass_event_bypass,
3967 (void *)&cmd_setbypass_event_event,
3968 (void *)&cmd_setbypass_event_event_value,
3969 (void *)&cmd_setbypass_event_mode,
3970 (void *)&cmd_setbypass_event_mode_value,
3971 (void *)&cmd_setbypass_event_port,
3977 /* *** SET NIC BYPASS TIMEOUT *** */
3978 struct cmd_set_bypass_timeout_result {
3979 cmdline_fixed_string_t set;
3980 cmdline_fixed_string_t bypass;
3981 cmdline_fixed_string_t timeout;
3982 cmdline_fixed_string_t value;
3986 cmd_set_bypass_timeout_parsed(void *parsed_result,
3987 __attribute__((unused)) struct cmdline *cl,
3988 __attribute__((unused)) void *data)
3990 struct cmd_set_bypass_timeout_result *res = parsed_result;
3992 if (!strcmp(res->value, "1.5"))
3993 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3994 else if (!strcmp(res->value, "2"))
3995 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3996 else if (!strcmp(res->value, "3"))
3997 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3998 else if (!strcmp(res->value, "4"))
3999 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4000 else if (!strcmp(res->value, "8"))
4001 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4002 else if (!strcmp(res->value, "16"))
4003 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4004 else if (!strcmp(res->value, "32"))
4005 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4007 bypass_timeout = RTE_BYPASS_TMT_OFF;
4010 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4011 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4013 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4014 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4016 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4017 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4018 timeout, "timeout");
4019 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4020 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4021 value, "0#1.5#2#3#4#8#16#32");
4023 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4024 .f = cmd_set_bypass_timeout_parsed,
4025 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4026 "Set the NIC bypass watchdog timeout in seconds",
4029 (void *)&cmd_setbypass_timeout_set,
4030 (void *)&cmd_setbypass_timeout_bypass,
4031 (void *)&cmd_setbypass_timeout_timeout,
4032 (void *)&cmd_setbypass_timeout_value,
4037 /* *** SHOW NIC BYPASS MODE *** */
4038 struct cmd_show_bypass_config_result {
4039 cmdline_fixed_string_t show;
4040 cmdline_fixed_string_t bypass;
4041 cmdline_fixed_string_t config;
4046 cmd_show_bypass_config_parsed(void *parsed_result,
4047 __attribute__((unused)) struct cmdline *cl,
4048 __attribute__((unused)) void *data)
4050 struct cmd_show_bypass_config_result *res = parsed_result;
4051 uint32_t event_mode;
4052 uint32_t bypass_mode;
4053 portid_t port_id = res->port_id;
4054 uint32_t timeout = bypass_timeout;
4057 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4058 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4059 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4060 {"UNKNOWN", "normal", "bypass", "isolate"};
4061 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4068 int num_events = (sizeof events) / (sizeof events[0]);
4070 /* Display the bypass mode.*/
4071 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4072 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4076 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4077 bypass_mode = RTE_BYPASS_MODE_NONE;
4079 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4082 /* Display the bypass timeout.*/
4083 if (!RTE_BYPASS_TMT_VALID(timeout))
4084 timeout = RTE_BYPASS_TMT_OFF;
4086 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4088 /* Display the bypass events and associated modes. */
4089 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4091 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4092 printf("\tFailed to get bypass mode for event = %s\n",
4095 if (!RTE_BYPASS_MODE_VALID(event_mode))
4096 event_mode = RTE_BYPASS_MODE_NONE;
4098 printf("\tbypass event: %-16s = %s\n", events[i],
4104 cmdline_parse_token_string_t cmd_showbypass_config_show =
4105 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4107 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4108 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4110 cmdline_parse_token_string_t cmd_showbypass_config_config =
4111 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4113 cmdline_parse_token_num_t cmd_showbypass_config_port =
4114 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4117 cmdline_parse_inst_t cmd_show_bypass_config = {
4118 .f = cmd_show_bypass_config_parsed,
4119 .help_str = "show bypass config <port_id>: "
4120 "Show the NIC bypass config for port_id",
4123 (void *)&cmd_showbypass_config_show,
4124 (void *)&cmd_showbypass_config_bypass,
4125 (void *)&cmd_showbypass_config_config,
4126 (void *)&cmd_showbypass_config_port,
4132 #ifdef RTE_LIBRTE_PMD_BOND
4133 /* *** SET BONDING MODE *** */
4134 struct cmd_set_bonding_mode_result {
4135 cmdline_fixed_string_t set;
4136 cmdline_fixed_string_t bonding;
4137 cmdline_fixed_string_t mode;
4142 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4143 __attribute__((unused)) struct cmdline *cl,
4144 __attribute__((unused)) void *data)
4146 struct cmd_set_bonding_mode_result *res = parsed_result;
4147 portid_t port_id = res->port_id;
4149 /* Set the bonding mode for the relevant port. */
4150 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4151 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4154 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4155 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4157 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4158 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4159 bonding, "bonding");
4160 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4161 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4163 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4164 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4166 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4167 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4170 cmdline_parse_inst_t cmd_set_bonding_mode = {
4171 .f = cmd_set_bonding_mode_parsed,
4172 .help_str = "set bonding mode <mode_value> <port_id>: "
4173 "Set the bonding mode for port_id",
4176 (void *) &cmd_setbonding_mode_set,
4177 (void *) &cmd_setbonding_mode_bonding,
4178 (void *) &cmd_setbonding_mode_mode,
4179 (void *) &cmd_setbonding_mode_value,
4180 (void *) &cmd_setbonding_mode_port,
4185 /* *** SET BALANCE XMIT POLICY *** */
4186 struct cmd_set_bonding_balance_xmit_policy_result {
4187 cmdline_fixed_string_t set;
4188 cmdline_fixed_string_t bonding;
4189 cmdline_fixed_string_t balance_xmit_policy;
4191 cmdline_fixed_string_t policy;
4194 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4195 __attribute__((unused)) struct cmdline *cl,
4196 __attribute__((unused)) void *data)
4198 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4199 portid_t port_id = res->port_id;
4202 if (!strcmp(res->policy, "l2")) {
4203 policy = BALANCE_XMIT_POLICY_LAYER2;
4204 } else if (!strcmp(res->policy, "l23")) {
4205 policy = BALANCE_XMIT_POLICY_LAYER23;
4206 } else if (!strcmp(res->policy, "l34")) {
4207 policy = BALANCE_XMIT_POLICY_LAYER34;
4209 printf("\t Invalid xmit policy selection");
4213 /* Set the bonding mode for the relevant port. */
4214 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4215 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4220 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4221 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4223 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4224 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4225 bonding, "bonding");
4226 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4227 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4228 balance_xmit_policy, "balance_xmit_policy");
4229 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4230 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4232 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4233 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4234 policy, "l2#l23#l34");
4236 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4237 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4238 .help_str = "set bonding balance_xmit_policy <port_id> "
4240 "Set the bonding balance_xmit_policy for port_id",
4243 (void *)&cmd_setbonding_balance_xmit_policy_set,
4244 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4245 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4246 (void *)&cmd_setbonding_balance_xmit_policy_port,
4247 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4252 /* *** SHOW NIC BONDING CONFIGURATION *** */
4253 struct cmd_show_bonding_config_result {
4254 cmdline_fixed_string_t show;
4255 cmdline_fixed_string_t bonding;
4256 cmdline_fixed_string_t config;
4260 static void cmd_show_bonding_config_parsed(void *parsed_result,
4261 __attribute__((unused)) struct cmdline *cl,
4262 __attribute__((unused)) void *data)
4264 struct cmd_show_bonding_config_result *res = parsed_result;
4266 uint8_t slaves[RTE_MAX_ETHPORTS];
4267 int num_slaves, num_active_slaves;
4270 portid_t port_id = res->port_id;
4272 /* Display the bonding mode.*/
4273 bonding_mode = rte_eth_bond_mode_get(port_id);
4274 if (bonding_mode < 0) {
4275 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4278 printf("\tBonding mode: %d\n", bonding_mode);
4280 if (bonding_mode == BONDING_MODE_BALANCE) {
4281 int balance_xmit_policy;
4283 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4284 if (balance_xmit_policy < 0) {
4285 printf("\tFailed to get balance xmit policy for port = %d\n",
4289 printf("\tBalance Xmit Policy: ");
4291 switch (balance_xmit_policy) {
4292 case BALANCE_XMIT_POLICY_LAYER2:
4293 printf("BALANCE_XMIT_POLICY_LAYER2");
4295 case BALANCE_XMIT_POLICY_LAYER23:
4296 printf("BALANCE_XMIT_POLICY_LAYER23");
4298 case BALANCE_XMIT_POLICY_LAYER34:
4299 printf("BALANCE_XMIT_POLICY_LAYER34");
4306 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4308 if (num_slaves < 0) {
4309 printf("\tFailed to get slave list for port = %d\n", port_id);
4312 if (num_slaves > 0) {
4313 printf("\tSlaves (%d): [", num_slaves);
4314 for (i = 0; i < num_slaves - 1; i++)
4315 printf("%d ", slaves[i]);
4317 printf("%d]\n", slaves[num_slaves - 1]);
4319 printf("\tSlaves: []\n");
4323 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4326 if (num_active_slaves < 0) {
4327 printf("\tFailed to get active slave list for port = %d\n", port_id);
4330 if (num_active_slaves > 0) {
4331 printf("\tActive Slaves (%d): [", num_active_slaves);
4332 for (i = 0; i < num_active_slaves - 1; i++)
4333 printf("%d ", slaves[i]);
4335 printf("%d]\n", slaves[num_active_slaves - 1]);
4338 printf("\tActive Slaves: []\n");
4342 primary_id = rte_eth_bond_primary_get(port_id);
4343 if (primary_id < 0) {
4344 printf("\tFailed to get primary slave for port = %d\n", port_id);
4347 printf("\tPrimary: [%d]\n", primary_id);
4351 cmdline_parse_token_string_t cmd_showbonding_config_show =
4352 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4354 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4355 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4356 bonding, "bonding");
4357 cmdline_parse_token_string_t cmd_showbonding_config_config =
4358 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4360 cmdline_parse_token_num_t cmd_showbonding_config_port =
4361 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4364 cmdline_parse_inst_t cmd_show_bonding_config = {
4365 .f = cmd_show_bonding_config_parsed,
4366 .help_str = "show bonding config <port_id>: "
4367 "Show the bonding config for port_id",
4370 (void *)&cmd_showbonding_config_show,
4371 (void *)&cmd_showbonding_config_bonding,
4372 (void *)&cmd_showbonding_config_config,
4373 (void *)&cmd_showbonding_config_port,
4378 /* *** SET BONDING PRIMARY *** */
4379 struct cmd_set_bonding_primary_result {
4380 cmdline_fixed_string_t set;
4381 cmdline_fixed_string_t bonding;
4382 cmdline_fixed_string_t primary;
4387 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4388 __attribute__((unused)) struct cmdline *cl,
4389 __attribute__((unused)) void *data)
4391 struct cmd_set_bonding_primary_result *res = parsed_result;
4392 portid_t master_port_id = res->port_id;
4393 portid_t slave_port_id = res->slave_id;
4395 /* Set the primary slave for a bonded device. */
4396 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4397 printf("\t Failed to set primary slave for port = %d.\n",
4404 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4405 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4407 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4408 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4409 bonding, "bonding");
4410 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4411 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4412 primary, "primary");
4413 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4414 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4416 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4417 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4420 cmdline_parse_inst_t cmd_set_bonding_primary = {
4421 .f = cmd_set_bonding_primary_parsed,
4422 .help_str = "set bonding primary <slave_id> <port_id>: "
4423 "Set the primary slave for port_id",
4426 (void *)&cmd_setbonding_primary_set,
4427 (void *)&cmd_setbonding_primary_bonding,
4428 (void *)&cmd_setbonding_primary_primary,
4429 (void *)&cmd_setbonding_primary_slave,
4430 (void *)&cmd_setbonding_primary_port,
4435 /* *** ADD SLAVE *** */
4436 struct cmd_add_bonding_slave_result {
4437 cmdline_fixed_string_t add;
4438 cmdline_fixed_string_t bonding;
4439 cmdline_fixed_string_t slave;
4444 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4445 __attribute__((unused)) struct cmdline *cl,
4446 __attribute__((unused)) void *data)
4448 struct cmd_add_bonding_slave_result *res = parsed_result;
4449 portid_t master_port_id = res->port_id;
4450 portid_t slave_port_id = res->slave_id;
4452 /* Set the primary slave for a bonded device. */
4453 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4454 printf("\t Failed to add slave %d to master port = %d.\n",
4455 slave_port_id, master_port_id);
4459 set_port_slave_flag(slave_port_id);
4462 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4463 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4465 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4466 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4467 bonding, "bonding");
4468 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4469 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4471 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4472 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4474 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4475 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4478 cmdline_parse_inst_t cmd_add_bonding_slave = {
4479 .f = cmd_add_bonding_slave_parsed,
4480 .help_str = "add bonding slave <slave_id> <port_id>: "
4481 "Add a slave device to a bonded device",
4484 (void *)&cmd_addbonding_slave_add,
4485 (void *)&cmd_addbonding_slave_bonding,
4486 (void *)&cmd_addbonding_slave_slave,
4487 (void *)&cmd_addbonding_slave_slaveid,
4488 (void *)&cmd_addbonding_slave_port,
4493 /* *** REMOVE SLAVE *** */
4494 struct cmd_remove_bonding_slave_result {
4495 cmdline_fixed_string_t remove;
4496 cmdline_fixed_string_t bonding;
4497 cmdline_fixed_string_t slave;
4502 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4503 __attribute__((unused)) struct cmdline *cl,
4504 __attribute__((unused)) void *data)
4506 struct cmd_remove_bonding_slave_result *res = parsed_result;
4507 portid_t master_port_id = res->port_id;
4508 portid_t slave_port_id = res->slave_id;
4510 /* Set the primary slave for a bonded device. */
4511 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4512 printf("\t Failed to remove slave %d from master port = %d.\n",
4513 slave_port_id, master_port_id);
4517 clear_port_slave_flag(slave_port_id);
4520 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4521 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4523 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4524 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4525 bonding, "bonding");
4526 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4527 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4529 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4530 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4532 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4533 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4536 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4537 .f = cmd_remove_bonding_slave_parsed,
4538 .help_str = "remove bonding slave <slave_id> <port_id>: "
4539 "Remove a slave device from a bonded device",
4542 (void *)&cmd_removebonding_slave_remove,
4543 (void *)&cmd_removebonding_slave_bonding,
4544 (void *)&cmd_removebonding_slave_slave,
4545 (void *)&cmd_removebonding_slave_slaveid,
4546 (void *)&cmd_removebonding_slave_port,
4551 /* *** CREATE BONDED DEVICE *** */
4552 struct cmd_create_bonded_device_result {
4553 cmdline_fixed_string_t create;
4554 cmdline_fixed_string_t bonded;
4555 cmdline_fixed_string_t device;
4560 static int bond_dev_num = 0;
4562 static void cmd_create_bonded_device_parsed(void *parsed_result,
4563 __attribute__((unused)) struct cmdline *cl,
4564 __attribute__((unused)) void *data)
4566 struct cmd_create_bonded_device_result *res = parsed_result;
4567 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4570 if (test_done == 0) {
4571 printf("Please stop forwarding first\n");
4575 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4578 /* Create a new bonded device. */
4579 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4581 printf("\t Failed to create bonded device.\n");
4584 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4587 /* Update number of ports */
4588 nb_ports = rte_eth_dev_count();
4589 reconfig(port_id, res->socket);
4590 rte_eth_promiscuous_enable(port_id);
4591 ports[port_id].enabled = 1;
4596 cmdline_parse_token_string_t cmd_createbonded_device_create =
4597 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4599 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4600 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4602 cmdline_parse_token_string_t cmd_createbonded_device_device =
4603 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4605 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4606 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4608 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4609 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4612 cmdline_parse_inst_t cmd_create_bonded_device = {
4613 .f = cmd_create_bonded_device_parsed,
4614 .help_str = "create bonded device <mode> <socket>: "
4615 "Create a new bonded device with specific bonding mode and socket",
4618 (void *)&cmd_createbonded_device_create,
4619 (void *)&cmd_createbonded_device_bonded,
4620 (void *)&cmd_createbonded_device_device,
4621 (void *)&cmd_createbonded_device_mode,
4622 (void *)&cmd_createbonded_device_socket,
4627 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4628 struct cmd_set_bond_mac_addr_result {
4629 cmdline_fixed_string_t set;
4630 cmdline_fixed_string_t bonding;
4631 cmdline_fixed_string_t mac_addr;
4633 struct ether_addr address;
4636 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4637 __attribute__((unused)) struct cmdline *cl,
4638 __attribute__((unused)) void *data)
4640 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4643 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4646 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4648 /* check the return value and print it if is < 0 */
4650 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4653 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4654 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4655 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4656 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4658 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4659 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4661 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4662 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4663 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4664 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4666 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4667 .f = cmd_set_bond_mac_addr_parsed,
4669 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4671 (void *)&cmd_set_bond_mac_addr_set,
4672 (void *)&cmd_set_bond_mac_addr_bonding,
4673 (void *)&cmd_set_bond_mac_addr_mac,
4674 (void *)&cmd_set_bond_mac_addr_portnum,
4675 (void *)&cmd_set_bond_mac_addr_addr,
4681 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4682 struct cmd_set_bond_mon_period_result {
4683 cmdline_fixed_string_t set;
4684 cmdline_fixed_string_t bonding;
4685 cmdline_fixed_string_t mon_period;
4690 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4691 __attribute__((unused)) struct cmdline *cl,
4692 __attribute__((unused)) void *data)
4694 struct cmd_set_bond_mon_period_result *res = parsed_result;
4697 if (res->port_num >= nb_ports) {
4698 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4702 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4704 /* check the return value and print it if is < 0 */
4706 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4709 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4710 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4712 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4713 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4714 bonding, "bonding");
4715 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4716 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4717 mon_period, "mon_period");
4718 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4719 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4721 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4722 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4725 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4726 .f = cmd_set_bond_mon_period_parsed,
4728 .help_str = "set bonding mon_period <port_id> <period_ms>",
4730 (void *)&cmd_set_bond_mon_period_set,
4731 (void *)&cmd_set_bond_mon_period_bonding,
4732 (void *)&cmd_set_bond_mon_period_mon_period,
4733 (void *)&cmd_set_bond_mon_period_portnum,
4734 (void *)&cmd_set_bond_mon_period_period_ms,
4739 #endif /* RTE_LIBRTE_PMD_BOND */
4741 /* *** SET FORWARDING MODE *** */
4742 struct cmd_set_fwd_mode_result {
4743 cmdline_fixed_string_t set;
4744 cmdline_fixed_string_t fwd;
4745 cmdline_fixed_string_t mode;
4748 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4749 __attribute__((unused)) struct cmdline *cl,
4750 __attribute__((unused)) void *data)
4752 struct cmd_set_fwd_mode_result *res = parsed_result;
4755 set_pkt_forwarding_mode(res->mode);
4758 cmdline_parse_token_string_t cmd_setfwd_set =
4759 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4760 cmdline_parse_token_string_t cmd_setfwd_fwd =
4761 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4762 cmdline_parse_token_string_t cmd_setfwd_mode =
4763 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4764 "" /* defined at init */);
4766 cmdline_parse_inst_t cmd_set_fwd_mode = {
4767 .f = cmd_set_fwd_mode_parsed,
4769 .help_str = NULL, /* defined at init */
4771 (void *)&cmd_setfwd_set,
4772 (void *)&cmd_setfwd_fwd,
4773 (void *)&cmd_setfwd_mode,
4778 static void cmd_set_fwd_mode_init(void)
4781 static char token[128];
4782 static char help[256];
4783 cmdline_parse_token_string_t *token_struct;
4785 modes = list_pkt_forwarding_modes();
4786 snprintf(help, sizeof(help), "set fwd %s: "
4787 "Set packet forwarding mode", modes);
4788 cmd_set_fwd_mode.help_str = help;
4790 /* string token separator is # */
4791 for (c = token; *modes != '\0'; modes++)
4796 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4797 token_struct->string_data.str = token;
4800 /* *** SET RETRY FORWARDING MODE *** */
4801 struct cmd_set_fwd_retry_mode_result {
4802 cmdline_fixed_string_t set;
4803 cmdline_fixed_string_t fwd;
4804 cmdline_fixed_string_t mode;
4805 cmdline_fixed_string_t retry;
4808 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4809 __attribute__((unused)) struct cmdline *cl,
4810 __attribute__((unused)) void *data)
4812 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4815 set_pkt_forwarding_mode(res->mode);
4818 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4819 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4821 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4822 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4824 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4825 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4827 "" /* defined at init */);
4828 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4829 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4832 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4833 .f = cmd_set_fwd_retry_mode_parsed,
4835 .help_str = NULL, /* defined at init */
4837 (void *)&cmd_setfwd_retry_set,
4838 (void *)&cmd_setfwd_retry_fwd,
4839 (void *)&cmd_setfwd_retry_mode,
4840 (void *)&cmd_setfwd_retry_retry,
4845 static void cmd_set_fwd_retry_mode_init(void)
4848 static char token[128];
4849 static char help[256];
4850 cmdline_parse_token_string_t *token_struct;
4852 modes = list_pkt_forwarding_retry_modes();
4853 snprintf(help, sizeof(help), "set fwd %s retry: "
4854 "Set packet forwarding mode with retry", modes);
4855 cmd_set_fwd_retry_mode.help_str = help;
4857 /* string token separator is # */
4858 for (c = token; *modes != '\0'; modes++)
4863 token_struct = (cmdline_parse_token_string_t *)
4864 cmd_set_fwd_retry_mode.tokens[2];
4865 token_struct->string_data.str = token;
4868 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4869 struct cmd_set_burst_tx_retry_result {
4870 cmdline_fixed_string_t set;
4871 cmdline_fixed_string_t burst;
4872 cmdline_fixed_string_t tx;
4873 cmdline_fixed_string_t delay;
4875 cmdline_fixed_string_t retry;
4879 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4880 __attribute__((unused)) struct cmdline *cl,
4881 __attribute__((unused)) void *data)
4883 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4885 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4886 && !strcmp(res->tx, "tx")) {
4887 if (!strcmp(res->delay, "delay"))
4888 burst_tx_delay_time = res->time;
4889 if (!strcmp(res->retry, "retry"))
4890 burst_tx_retry_num = res->retry_num;
4895 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4896 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4897 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4898 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4900 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4901 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4902 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4903 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4904 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4905 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4906 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4907 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4908 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4909 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4911 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4912 .f = cmd_set_burst_tx_retry_parsed,
4913 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4915 (void *)&cmd_set_burst_tx_retry_set,
4916 (void *)&cmd_set_burst_tx_retry_burst,
4917 (void *)&cmd_set_burst_tx_retry_tx,
4918 (void *)&cmd_set_burst_tx_retry_delay,
4919 (void *)&cmd_set_burst_tx_retry_time,
4920 (void *)&cmd_set_burst_tx_retry_retry,
4921 (void *)&cmd_set_burst_tx_retry_retry_num,
4926 /* *** SET PROMISC MODE *** */
4927 struct cmd_set_promisc_mode_result {
4928 cmdline_fixed_string_t set;
4929 cmdline_fixed_string_t promisc;
4930 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4931 uint8_t port_num; /* valid if "allports" argument == 0 */
4932 cmdline_fixed_string_t mode;
4935 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4936 __attribute__((unused)) struct cmdline *cl,
4939 struct cmd_set_promisc_mode_result *res = parsed_result;
4943 if (!strcmp(res->mode, "on"))
4950 FOREACH_PORT(i, ports) {
4952 rte_eth_promiscuous_enable(i);
4954 rte_eth_promiscuous_disable(i);
4959 rte_eth_promiscuous_enable(res->port_num);
4961 rte_eth_promiscuous_disable(res->port_num);
4965 cmdline_parse_token_string_t cmd_setpromisc_set =
4966 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4967 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4968 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4970 cmdline_parse_token_string_t cmd_setpromisc_portall =
4971 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4973 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4974 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4976 cmdline_parse_token_string_t cmd_setpromisc_mode =
4977 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4980 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4981 .f = cmd_set_promisc_mode_parsed,
4983 .help_str = "set promisc all on|off: Set promisc mode for all ports",
4985 (void *)&cmd_setpromisc_set,
4986 (void *)&cmd_setpromisc_promisc,
4987 (void *)&cmd_setpromisc_portall,
4988 (void *)&cmd_setpromisc_mode,
4993 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4994 .f = cmd_set_promisc_mode_parsed,
4996 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
4998 (void *)&cmd_setpromisc_set,
4999 (void *)&cmd_setpromisc_promisc,
5000 (void *)&cmd_setpromisc_portnum,
5001 (void *)&cmd_setpromisc_mode,
5006 /* *** SET ALLMULTI MODE *** */
5007 struct cmd_set_allmulti_mode_result {
5008 cmdline_fixed_string_t set;
5009 cmdline_fixed_string_t allmulti;
5010 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5011 uint8_t port_num; /* valid if "allports" argument == 0 */
5012 cmdline_fixed_string_t mode;
5015 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5016 __attribute__((unused)) struct cmdline *cl,
5019 struct cmd_set_allmulti_mode_result *res = parsed_result;
5023 if (!strcmp(res->mode, "on"))
5030 FOREACH_PORT(i, ports) {
5032 rte_eth_allmulticast_enable(i);
5034 rte_eth_allmulticast_disable(i);
5039 rte_eth_allmulticast_enable(res->port_num);
5041 rte_eth_allmulticast_disable(res->port_num);
5045 cmdline_parse_token_string_t cmd_setallmulti_set =
5046 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5047 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5048 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5050 cmdline_parse_token_string_t cmd_setallmulti_portall =
5051 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5053 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5054 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5056 cmdline_parse_token_string_t cmd_setallmulti_mode =
5057 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5060 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5061 .f = cmd_set_allmulti_mode_parsed,
5063 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5065 (void *)&cmd_setallmulti_set,
5066 (void *)&cmd_setallmulti_allmulti,
5067 (void *)&cmd_setallmulti_portall,
5068 (void *)&cmd_setallmulti_mode,
5073 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5074 .f = cmd_set_allmulti_mode_parsed,
5076 .help_str = "set allmulti <port_id> on|off: "
5077 "Set allmulti mode on port_id",
5079 (void *)&cmd_setallmulti_set,
5080 (void *)&cmd_setallmulti_allmulti,
5081 (void *)&cmd_setallmulti_portnum,
5082 (void *)&cmd_setallmulti_mode,
5087 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5088 struct cmd_link_flow_ctrl_set_result {
5089 cmdline_fixed_string_t set;
5090 cmdline_fixed_string_t flow_ctrl;
5091 cmdline_fixed_string_t rx;
5092 cmdline_fixed_string_t rx_lfc_mode;
5093 cmdline_fixed_string_t tx;
5094 cmdline_fixed_string_t tx_lfc_mode;
5095 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5096 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5097 cmdline_fixed_string_t autoneg_str;
5098 cmdline_fixed_string_t autoneg;
5099 cmdline_fixed_string_t hw_str;
5100 uint32_t high_water;
5101 cmdline_fixed_string_t lw_str;
5103 cmdline_fixed_string_t pt_str;
5104 uint16_t pause_time;
5105 cmdline_fixed_string_t xon_str;
5110 cmdline_parse_token_string_t cmd_lfc_set_set =
5111 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5113 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5114 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5115 flow_ctrl, "flow_ctrl");
5116 cmdline_parse_token_string_t cmd_lfc_set_rx =
5117 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5119 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5120 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5121 rx_lfc_mode, "on#off");
5122 cmdline_parse_token_string_t cmd_lfc_set_tx =
5123 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5125 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5126 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5127 tx_lfc_mode, "on#off");
5128 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5129 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5130 hw_str, "high_water");
5131 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5132 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5133 high_water, UINT32);
5134 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5135 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5136 lw_str, "low_water");
5137 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5138 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5140 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5141 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5142 pt_str, "pause_time");
5143 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5144 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5145 pause_time, UINT16);
5146 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5147 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5148 xon_str, "send_xon");
5149 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5150 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5152 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5153 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5154 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5155 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5156 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5157 mac_ctrl_frame_fwd_mode, "on#off");
5158 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5159 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5160 autoneg_str, "autoneg");
5161 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5162 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5164 cmdline_parse_token_num_t cmd_lfc_set_portid =
5165 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5168 /* forward declaration */
5170 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5173 cmdline_parse_inst_t cmd_link_flow_control_set = {
5174 .f = cmd_link_flow_ctrl_set_parsed,
5176 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5177 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5178 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5180 (void *)&cmd_lfc_set_set,
5181 (void *)&cmd_lfc_set_flow_ctrl,
5182 (void *)&cmd_lfc_set_rx,
5183 (void *)&cmd_lfc_set_rx_mode,
5184 (void *)&cmd_lfc_set_tx,
5185 (void *)&cmd_lfc_set_tx_mode,
5186 (void *)&cmd_lfc_set_high_water,
5187 (void *)&cmd_lfc_set_low_water,
5188 (void *)&cmd_lfc_set_pause_time,
5189 (void *)&cmd_lfc_set_send_xon,
5190 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5191 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5192 (void *)&cmd_lfc_set_autoneg_str,
5193 (void *)&cmd_lfc_set_autoneg,
5194 (void *)&cmd_lfc_set_portid,
5199 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5200 .f = cmd_link_flow_ctrl_set_parsed,
5201 .data = (void *)&cmd_link_flow_control_set_rx,
5202 .help_str = "set flow_ctrl rx on|off <port_id>: "
5203 "Change rx flow control parameter",
5205 (void *)&cmd_lfc_set_set,
5206 (void *)&cmd_lfc_set_flow_ctrl,
5207 (void *)&cmd_lfc_set_rx,
5208 (void *)&cmd_lfc_set_rx_mode,
5209 (void *)&cmd_lfc_set_portid,
5214 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5215 .f = cmd_link_flow_ctrl_set_parsed,
5216 .data = (void *)&cmd_link_flow_control_set_tx,
5217 .help_str = "set flow_ctrl tx on|off <port_id>: "
5218 "Change tx flow control parameter",
5220 (void *)&cmd_lfc_set_set,
5221 (void *)&cmd_lfc_set_flow_ctrl,
5222 (void *)&cmd_lfc_set_tx,
5223 (void *)&cmd_lfc_set_tx_mode,
5224 (void *)&cmd_lfc_set_portid,
5229 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5230 .f = cmd_link_flow_ctrl_set_parsed,
5231 .data = (void *)&cmd_link_flow_control_set_hw,
5232 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5233 "Change high water flow control parameter",
5235 (void *)&cmd_lfc_set_set,
5236 (void *)&cmd_lfc_set_flow_ctrl,
5237 (void *)&cmd_lfc_set_high_water_str,
5238 (void *)&cmd_lfc_set_high_water,
5239 (void *)&cmd_lfc_set_portid,
5244 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5245 .f = cmd_link_flow_ctrl_set_parsed,
5246 .data = (void *)&cmd_link_flow_control_set_lw,
5247 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5248 "Change low water flow control parameter",
5250 (void *)&cmd_lfc_set_set,
5251 (void *)&cmd_lfc_set_flow_ctrl,
5252 (void *)&cmd_lfc_set_low_water_str,
5253 (void *)&cmd_lfc_set_low_water,
5254 (void *)&cmd_lfc_set_portid,
5259 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5260 .f = cmd_link_flow_ctrl_set_parsed,
5261 .data = (void *)&cmd_link_flow_control_set_pt,
5262 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5263 "Change pause time flow control parameter",
5265 (void *)&cmd_lfc_set_set,
5266 (void *)&cmd_lfc_set_flow_ctrl,
5267 (void *)&cmd_lfc_set_pause_time_str,
5268 (void *)&cmd_lfc_set_pause_time,
5269 (void *)&cmd_lfc_set_portid,
5274 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5275 .f = cmd_link_flow_ctrl_set_parsed,
5276 .data = (void *)&cmd_link_flow_control_set_xon,
5277 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5278 "Change send_xon flow control parameter",
5280 (void *)&cmd_lfc_set_set,
5281 (void *)&cmd_lfc_set_flow_ctrl,
5282 (void *)&cmd_lfc_set_send_xon_str,
5283 (void *)&cmd_lfc_set_send_xon,
5284 (void *)&cmd_lfc_set_portid,
5289 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5290 .f = cmd_link_flow_ctrl_set_parsed,
5291 .data = (void *)&cmd_link_flow_control_set_macfwd,
5292 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5293 "Change mac ctrl fwd flow control parameter",
5295 (void *)&cmd_lfc_set_set,
5296 (void *)&cmd_lfc_set_flow_ctrl,
5297 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5298 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5299 (void *)&cmd_lfc_set_portid,
5304 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5305 .f = cmd_link_flow_ctrl_set_parsed,
5306 .data = (void *)&cmd_link_flow_control_set_autoneg,
5307 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5308 "Change autoneg flow control parameter",
5310 (void *)&cmd_lfc_set_set,
5311 (void *)&cmd_lfc_set_flow_ctrl,
5312 (void *)&cmd_lfc_set_autoneg_str,
5313 (void *)&cmd_lfc_set_autoneg,
5314 (void *)&cmd_lfc_set_portid,
5320 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5321 __attribute__((unused)) struct cmdline *cl,
5324 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5325 cmdline_parse_inst_t *cmd = data;
5326 struct rte_eth_fc_conf fc_conf;
5332 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5333 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5334 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5335 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5337 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5338 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5341 /* Partial command line, retrieve current configuration */
5343 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5345 printf("cannot get current flow ctrl parameters, return"
5346 "code = %d\n", ret);
5350 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5351 (fc_conf.mode == RTE_FC_FULL))
5353 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5354 (fc_conf.mode == RTE_FC_FULL))
5358 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5359 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5361 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5362 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5364 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5366 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5367 fc_conf.high_water = res->high_water;
5369 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5370 fc_conf.low_water = res->low_water;
5372 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5373 fc_conf.pause_time = res->pause_time;
5375 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5376 fc_conf.send_xon = res->send_xon;
5378 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5379 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5380 fc_conf.mac_ctrl_frame_fwd = 1;
5382 fc_conf.mac_ctrl_frame_fwd = 0;
5385 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5386 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5388 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5390 printf("bad flow contrl parameter, return code = %d \n", ret);
5393 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5394 struct cmd_priority_flow_ctrl_set_result {
5395 cmdline_fixed_string_t set;
5396 cmdline_fixed_string_t pfc_ctrl;
5397 cmdline_fixed_string_t rx;
5398 cmdline_fixed_string_t rx_pfc_mode;
5399 cmdline_fixed_string_t tx;
5400 cmdline_fixed_string_t tx_pfc_mode;
5401 uint32_t high_water;
5403 uint16_t pause_time;
5409 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5410 __attribute__((unused)) struct cmdline *cl,
5411 __attribute__((unused)) void *data)
5413 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5414 struct rte_eth_pfc_conf pfc_conf;
5415 int rx_fc_enable, tx_fc_enable;
5419 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5420 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5421 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5422 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5424 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5425 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5428 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5429 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5430 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5431 pfc_conf.fc.high_water = res->high_water;
5432 pfc_conf.fc.low_water = res->low_water;
5433 pfc_conf.fc.pause_time = res->pause_time;
5434 pfc_conf.priority = res->priority;
5436 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5438 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5441 cmdline_parse_token_string_t cmd_pfc_set_set =
5442 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5444 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5445 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5446 pfc_ctrl, "pfc_ctrl");
5447 cmdline_parse_token_string_t cmd_pfc_set_rx =
5448 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5450 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5451 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5452 rx_pfc_mode, "on#off");
5453 cmdline_parse_token_string_t cmd_pfc_set_tx =
5454 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5456 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5457 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5458 tx_pfc_mode, "on#off");
5459 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5460 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5461 high_water, UINT32);
5462 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5463 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5465 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5466 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5467 pause_time, UINT16);
5468 cmdline_parse_token_num_t cmd_pfc_set_priority =
5469 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5471 cmdline_parse_token_num_t cmd_pfc_set_portid =
5472 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5475 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5476 .f = cmd_priority_flow_ctrl_set_parsed,
5478 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5479 "<pause_time> <priority> <port_id>: "
5480 "Configure the Ethernet priority flow control",
5482 (void *)&cmd_pfc_set_set,
5483 (void *)&cmd_pfc_set_flow_ctrl,
5484 (void *)&cmd_pfc_set_rx,
5485 (void *)&cmd_pfc_set_rx_mode,
5486 (void *)&cmd_pfc_set_tx,
5487 (void *)&cmd_pfc_set_tx_mode,
5488 (void *)&cmd_pfc_set_high_water,
5489 (void *)&cmd_pfc_set_low_water,
5490 (void *)&cmd_pfc_set_pause_time,
5491 (void *)&cmd_pfc_set_priority,
5492 (void *)&cmd_pfc_set_portid,
5497 /* *** RESET CONFIGURATION *** */
5498 struct cmd_reset_result {
5499 cmdline_fixed_string_t reset;
5500 cmdline_fixed_string_t def;
5503 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5505 __attribute__((unused)) void *data)
5507 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5508 set_def_fwd_config();
5511 cmdline_parse_token_string_t cmd_reset_set =
5512 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5513 cmdline_parse_token_string_t cmd_reset_def =
5514 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5517 cmdline_parse_inst_t cmd_reset = {
5518 .f = cmd_reset_parsed,
5520 .help_str = "set default: Reset default forwarding configuration",
5522 (void *)&cmd_reset_set,
5523 (void *)&cmd_reset_def,
5528 /* *** START FORWARDING *** */
5529 struct cmd_start_result {
5530 cmdline_fixed_string_t start;
5533 cmdline_parse_token_string_t cmd_start_start =
5534 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5536 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5537 __attribute__((unused)) struct cmdline *cl,
5538 __attribute__((unused)) void *data)
5540 start_packet_forwarding(0);
5543 cmdline_parse_inst_t cmd_start = {
5544 .f = cmd_start_parsed,
5546 .help_str = "start: Start packet forwarding",
5548 (void *)&cmd_start_start,
5553 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5554 struct cmd_start_tx_first_result {
5555 cmdline_fixed_string_t start;
5556 cmdline_fixed_string_t tx_first;
5560 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5561 __attribute__((unused)) struct cmdline *cl,
5562 __attribute__((unused)) void *data)
5564 start_packet_forwarding(1);
5567 cmdline_parse_token_string_t cmd_start_tx_first_start =
5568 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5570 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5571 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5572 tx_first, "tx_first");
5574 cmdline_parse_inst_t cmd_start_tx_first = {
5575 .f = cmd_start_tx_first_parsed,
5577 .help_str = "start tx_first: Start packet forwarding, "
5578 "after sending 1 burst of packets",
5580 (void *)&cmd_start_tx_first_start,
5581 (void *)&cmd_start_tx_first_tx_first,
5586 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5587 struct cmd_start_tx_first_n_result {
5588 cmdline_fixed_string_t start;
5589 cmdline_fixed_string_t tx_first;
5594 cmd_start_tx_first_n_parsed(void *parsed_result,
5595 __attribute__((unused)) struct cmdline *cl,
5596 __attribute__((unused)) void *data)
5598 struct cmd_start_tx_first_n_result *res = parsed_result;
5600 start_packet_forwarding(res->tx_num);
5603 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5604 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5606 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5607 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5608 tx_first, "tx_first");
5609 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5610 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5613 cmdline_parse_inst_t cmd_start_tx_first_n = {
5614 .f = cmd_start_tx_first_n_parsed,
5616 .help_str = "start tx_first <num>: "
5617 "packet forwarding, after sending <num> bursts of packets",
5619 (void *)&cmd_start_tx_first_n_start,
5620 (void *)&cmd_start_tx_first_n_tx_first,
5621 (void *)&cmd_start_tx_first_n_tx_num,
5626 /* *** SET LINK UP *** */
5627 struct cmd_set_link_up_result {
5628 cmdline_fixed_string_t set;
5629 cmdline_fixed_string_t link_up;
5630 cmdline_fixed_string_t port;
5634 cmdline_parse_token_string_t cmd_set_link_up_set =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5636 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5637 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5639 cmdline_parse_token_string_t cmd_set_link_up_port =
5640 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5641 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5642 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5644 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5645 __attribute__((unused)) struct cmdline *cl,
5646 __attribute__((unused)) void *data)
5648 struct cmd_set_link_up_result *res = parsed_result;
5649 dev_set_link_up(res->port_id);
5652 cmdline_parse_inst_t cmd_set_link_up = {
5653 .f = cmd_set_link_up_parsed,
5655 .help_str = "set link-up port <port id>",
5657 (void *)&cmd_set_link_up_set,
5658 (void *)&cmd_set_link_up_link_up,
5659 (void *)&cmd_set_link_up_port,
5660 (void *)&cmd_set_link_up_port_id,
5665 /* *** SET LINK DOWN *** */
5666 struct cmd_set_link_down_result {
5667 cmdline_fixed_string_t set;
5668 cmdline_fixed_string_t link_down;
5669 cmdline_fixed_string_t port;
5673 cmdline_parse_token_string_t cmd_set_link_down_set =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5675 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5676 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5678 cmdline_parse_token_string_t cmd_set_link_down_port =
5679 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5680 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5681 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5683 static void cmd_set_link_down_parsed(
5684 __attribute__((unused)) void *parsed_result,
5685 __attribute__((unused)) struct cmdline *cl,
5686 __attribute__((unused)) void *data)
5688 struct cmd_set_link_down_result *res = parsed_result;
5689 dev_set_link_down(res->port_id);
5692 cmdline_parse_inst_t cmd_set_link_down = {
5693 .f = cmd_set_link_down_parsed,
5695 .help_str = "set link-down port <port id>",
5697 (void *)&cmd_set_link_down_set,
5698 (void *)&cmd_set_link_down_link_down,
5699 (void *)&cmd_set_link_down_port,
5700 (void *)&cmd_set_link_down_port_id,
5705 /* *** SHOW CFG *** */
5706 struct cmd_showcfg_result {
5707 cmdline_fixed_string_t show;
5708 cmdline_fixed_string_t cfg;
5709 cmdline_fixed_string_t what;
5712 static void cmd_showcfg_parsed(void *parsed_result,
5713 __attribute__((unused)) struct cmdline *cl,
5714 __attribute__((unused)) void *data)
5716 struct cmd_showcfg_result *res = parsed_result;
5717 if (!strcmp(res->what, "rxtx"))
5718 rxtx_config_display();
5719 else if (!strcmp(res->what, "cores"))
5720 fwd_lcores_config_display();
5721 else if (!strcmp(res->what, "fwd"))
5722 pkt_fwd_config_display(&cur_fwd_config);
5723 else if (!strcmp(res->what, "txpkts"))
5724 show_tx_pkt_segments();
5727 cmdline_parse_token_string_t cmd_showcfg_show =
5728 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5729 cmdline_parse_token_string_t cmd_showcfg_port =
5730 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5731 cmdline_parse_token_string_t cmd_showcfg_what =
5732 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5733 "rxtx#cores#fwd#txpkts");
5735 cmdline_parse_inst_t cmd_showcfg = {
5736 .f = cmd_showcfg_parsed,
5738 .help_str = "show config rxtx|cores|fwd|txpkts",
5740 (void *)&cmd_showcfg_show,
5741 (void *)&cmd_showcfg_port,
5742 (void *)&cmd_showcfg_what,
5747 /* *** SHOW ALL PORT INFO *** */
5748 struct cmd_showportall_result {
5749 cmdline_fixed_string_t show;
5750 cmdline_fixed_string_t port;
5751 cmdline_fixed_string_t what;
5752 cmdline_fixed_string_t all;
5755 static void cmd_showportall_parsed(void *parsed_result,
5756 __attribute__((unused)) struct cmdline *cl,
5757 __attribute__((unused)) void *data)
5761 struct cmd_showportall_result *res = parsed_result;
5762 if (!strcmp(res->show, "clear")) {
5763 if (!strcmp(res->what, "stats"))
5764 FOREACH_PORT(i, ports)
5766 else if (!strcmp(res->what, "xstats"))
5767 FOREACH_PORT(i, ports)
5768 nic_xstats_clear(i);
5769 } else if (!strcmp(res->what, "info"))
5770 FOREACH_PORT(i, ports)
5771 port_infos_display(i);
5772 else if (!strcmp(res->what, "stats"))
5773 FOREACH_PORT(i, ports)
5774 nic_stats_display(i);
5775 else if (!strcmp(res->what, "xstats"))
5776 FOREACH_PORT(i, ports)
5777 nic_xstats_display(i);
5778 else if (!strcmp(res->what, "fdir"))
5779 FOREACH_PORT(i, ports)
5781 else if (!strcmp(res->what, "stat_qmap"))
5782 FOREACH_PORT(i, ports)
5783 nic_stats_mapping_display(i);
5784 else if (!strcmp(res->what, "dcb_tc"))
5785 FOREACH_PORT(i, ports)
5786 port_dcb_info_display(i);
5789 cmdline_parse_token_string_t cmd_showportall_show =
5790 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5792 cmdline_parse_token_string_t cmd_showportall_port =
5793 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5794 cmdline_parse_token_string_t cmd_showportall_what =
5795 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5796 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5797 cmdline_parse_token_string_t cmd_showportall_all =
5798 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5799 cmdline_parse_inst_t cmd_showportall = {
5800 .f = cmd_showportall_parsed,
5802 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5804 (void *)&cmd_showportall_show,
5805 (void *)&cmd_showportall_port,
5806 (void *)&cmd_showportall_what,
5807 (void *)&cmd_showportall_all,
5812 /* *** SHOW PORT INFO *** */
5813 struct cmd_showport_result {
5814 cmdline_fixed_string_t show;
5815 cmdline_fixed_string_t port;
5816 cmdline_fixed_string_t what;
5820 static void cmd_showport_parsed(void *parsed_result,
5821 __attribute__((unused)) struct cmdline *cl,
5822 __attribute__((unused)) void *data)
5824 struct cmd_showport_result *res = parsed_result;
5825 if (!strcmp(res->show, "clear")) {
5826 if (!strcmp(res->what, "stats"))
5827 nic_stats_clear(res->portnum);
5828 else if (!strcmp(res->what, "xstats"))
5829 nic_xstats_clear(res->portnum);
5830 } else if (!strcmp(res->what, "info"))
5831 port_infos_display(res->portnum);
5832 else if (!strcmp(res->what, "stats"))
5833 nic_stats_display(res->portnum);
5834 else if (!strcmp(res->what, "xstats"))
5835 nic_xstats_display(res->portnum);
5836 else if (!strcmp(res->what, "fdir"))
5837 fdir_get_infos(res->portnum);
5838 else if (!strcmp(res->what, "stat_qmap"))
5839 nic_stats_mapping_display(res->portnum);
5840 else if (!strcmp(res->what, "dcb_tc"))
5841 port_dcb_info_display(res->portnum);
5844 cmdline_parse_token_string_t cmd_showport_show =
5845 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5847 cmdline_parse_token_string_t cmd_showport_port =
5848 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5849 cmdline_parse_token_string_t cmd_showport_what =
5850 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5851 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5852 cmdline_parse_token_num_t cmd_showport_portnum =
5853 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5855 cmdline_parse_inst_t cmd_showport = {
5856 .f = cmd_showport_parsed,
5858 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5861 (void *)&cmd_showport_show,
5862 (void *)&cmd_showport_port,
5863 (void *)&cmd_showport_what,
5864 (void *)&cmd_showport_portnum,
5869 /* *** SHOW QUEUE INFO *** */
5870 struct cmd_showqueue_result {
5871 cmdline_fixed_string_t show;
5872 cmdline_fixed_string_t type;
5873 cmdline_fixed_string_t what;
5879 cmd_showqueue_parsed(void *parsed_result,
5880 __attribute__((unused)) struct cmdline *cl,
5881 __attribute__((unused)) void *data)
5883 struct cmd_showqueue_result *res = parsed_result;
5885 if (!strcmp(res->type, "rxq"))
5886 rx_queue_infos_display(res->portnum, res->queuenum);
5887 else if (!strcmp(res->type, "txq"))
5888 tx_queue_infos_display(res->portnum, res->queuenum);
5891 cmdline_parse_token_string_t cmd_showqueue_show =
5892 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5893 cmdline_parse_token_string_t cmd_showqueue_type =
5894 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5895 cmdline_parse_token_string_t cmd_showqueue_what =
5896 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5897 cmdline_parse_token_num_t cmd_showqueue_portnum =
5898 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5899 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5900 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5902 cmdline_parse_inst_t cmd_showqueue = {
5903 .f = cmd_showqueue_parsed,
5905 .help_str = "show rxq|txq info <port_id> <queue_id>",
5907 (void *)&cmd_showqueue_show,
5908 (void *)&cmd_showqueue_type,
5909 (void *)&cmd_showqueue_what,
5910 (void *)&cmd_showqueue_portnum,
5911 (void *)&cmd_showqueue_queuenum,
5916 /* *** READ PORT REGISTER *** */
5917 struct cmd_read_reg_result {
5918 cmdline_fixed_string_t read;
5919 cmdline_fixed_string_t reg;
5925 cmd_read_reg_parsed(void *parsed_result,
5926 __attribute__((unused)) struct cmdline *cl,
5927 __attribute__((unused)) void *data)
5929 struct cmd_read_reg_result *res = parsed_result;
5930 port_reg_display(res->port_id, res->reg_off);
5933 cmdline_parse_token_string_t cmd_read_reg_read =
5934 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5935 cmdline_parse_token_string_t cmd_read_reg_reg =
5936 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5937 cmdline_parse_token_num_t cmd_read_reg_port_id =
5938 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5939 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5940 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5942 cmdline_parse_inst_t cmd_read_reg = {
5943 .f = cmd_read_reg_parsed,
5945 .help_str = "read reg <port_id> <reg_off>",
5947 (void *)&cmd_read_reg_read,
5948 (void *)&cmd_read_reg_reg,
5949 (void *)&cmd_read_reg_port_id,
5950 (void *)&cmd_read_reg_reg_off,
5955 /* *** READ PORT REGISTER BIT FIELD *** */
5956 struct cmd_read_reg_bit_field_result {
5957 cmdline_fixed_string_t read;
5958 cmdline_fixed_string_t regfield;
5966 cmd_read_reg_bit_field_parsed(void *parsed_result,
5967 __attribute__((unused)) struct cmdline *cl,
5968 __attribute__((unused)) void *data)
5970 struct cmd_read_reg_bit_field_result *res = parsed_result;
5971 port_reg_bit_field_display(res->port_id, res->reg_off,
5972 res->bit1_pos, res->bit2_pos);
5975 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5976 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5978 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5979 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5980 regfield, "regfield");
5981 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5982 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5984 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5985 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5987 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5988 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5990 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5991 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5994 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5995 .f = cmd_read_reg_bit_field_parsed,
5997 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
5998 "Read register bit field between bit_x and bit_y included",
6000 (void *)&cmd_read_reg_bit_field_read,
6001 (void *)&cmd_read_reg_bit_field_regfield,
6002 (void *)&cmd_read_reg_bit_field_port_id,
6003 (void *)&cmd_read_reg_bit_field_reg_off,
6004 (void *)&cmd_read_reg_bit_field_bit1_pos,
6005 (void *)&cmd_read_reg_bit_field_bit2_pos,
6010 /* *** READ PORT REGISTER BIT *** */
6011 struct cmd_read_reg_bit_result {
6012 cmdline_fixed_string_t read;
6013 cmdline_fixed_string_t regbit;
6020 cmd_read_reg_bit_parsed(void *parsed_result,
6021 __attribute__((unused)) struct cmdline *cl,
6022 __attribute__((unused)) void *data)
6024 struct cmd_read_reg_bit_result *res = parsed_result;
6025 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6028 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6029 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6030 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6031 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6033 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6034 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6035 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6036 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6037 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6038 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6040 cmdline_parse_inst_t cmd_read_reg_bit = {
6041 .f = cmd_read_reg_bit_parsed,
6043 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6045 (void *)&cmd_read_reg_bit_read,
6046 (void *)&cmd_read_reg_bit_regbit,
6047 (void *)&cmd_read_reg_bit_port_id,
6048 (void *)&cmd_read_reg_bit_reg_off,
6049 (void *)&cmd_read_reg_bit_bit_pos,
6054 /* *** WRITE PORT REGISTER *** */
6055 struct cmd_write_reg_result {
6056 cmdline_fixed_string_t write;
6057 cmdline_fixed_string_t reg;
6064 cmd_write_reg_parsed(void *parsed_result,
6065 __attribute__((unused)) struct cmdline *cl,
6066 __attribute__((unused)) void *data)
6068 struct cmd_write_reg_result *res = parsed_result;
6069 port_reg_set(res->port_id, res->reg_off, res->value);
6072 cmdline_parse_token_string_t cmd_write_reg_write =
6073 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6074 cmdline_parse_token_string_t cmd_write_reg_reg =
6075 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6076 cmdline_parse_token_num_t cmd_write_reg_port_id =
6077 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6078 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6079 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6080 cmdline_parse_token_num_t cmd_write_reg_value =
6081 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6083 cmdline_parse_inst_t cmd_write_reg = {
6084 .f = cmd_write_reg_parsed,
6086 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6088 (void *)&cmd_write_reg_write,
6089 (void *)&cmd_write_reg_reg,
6090 (void *)&cmd_write_reg_port_id,
6091 (void *)&cmd_write_reg_reg_off,
6092 (void *)&cmd_write_reg_value,
6097 /* *** WRITE PORT REGISTER BIT FIELD *** */
6098 struct cmd_write_reg_bit_field_result {
6099 cmdline_fixed_string_t write;
6100 cmdline_fixed_string_t regfield;
6109 cmd_write_reg_bit_field_parsed(void *parsed_result,
6110 __attribute__((unused)) struct cmdline *cl,
6111 __attribute__((unused)) void *data)
6113 struct cmd_write_reg_bit_field_result *res = parsed_result;
6114 port_reg_bit_field_set(res->port_id, res->reg_off,
6115 res->bit1_pos, res->bit2_pos, res->value);
6118 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6119 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6121 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6122 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6123 regfield, "regfield");
6124 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6125 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6127 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6128 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6130 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6131 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6133 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6134 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6136 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6137 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6140 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6141 .f = cmd_write_reg_bit_field_parsed,
6143 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6145 "Set register bit field between bit_x and bit_y included",
6147 (void *)&cmd_write_reg_bit_field_write,
6148 (void *)&cmd_write_reg_bit_field_regfield,
6149 (void *)&cmd_write_reg_bit_field_port_id,
6150 (void *)&cmd_write_reg_bit_field_reg_off,
6151 (void *)&cmd_write_reg_bit_field_bit1_pos,
6152 (void *)&cmd_write_reg_bit_field_bit2_pos,
6153 (void *)&cmd_write_reg_bit_field_value,
6158 /* *** WRITE PORT REGISTER BIT *** */
6159 struct cmd_write_reg_bit_result {
6160 cmdline_fixed_string_t write;
6161 cmdline_fixed_string_t regbit;
6169 cmd_write_reg_bit_parsed(void *parsed_result,
6170 __attribute__((unused)) struct cmdline *cl,
6171 __attribute__((unused)) void *data)
6173 struct cmd_write_reg_bit_result *res = parsed_result;
6174 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6177 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6178 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6180 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6181 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6183 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6184 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6185 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6186 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6187 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6188 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6189 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6190 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6192 cmdline_parse_inst_t cmd_write_reg_bit = {
6193 .f = cmd_write_reg_bit_parsed,
6195 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6198 (void *)&cmd_write_reg_bit_write,
6199 (void *)&cmd_write_reg_bit_regbit,
6200 (void *)&cmd_write_reg_bit_port_id,
6201 (void *)&cmd_write_reg_bit_reg_off,
6202 (void *)&cmd_write_reg_bit_bit_pos,
6203 (void *)&cmd_write_reg_bit_value,
6208 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6209 struct cmd_read_rxd_txd_result {
6210 cmdline_fixed_string_t read;
6211 cmdline_fixed_string_t rxd_txd;
6218 cmd_read_rxd_txd_parsed(void *parsed_result,
6219 __attribute__((unused)) struct cmdline *cl,
6220 __attribute__((unused)) void *data)
6222 struct cmd_read_rxd_txd_result *res = parsed_result;
6224 if (!strcmp(res->rxd_txd, "rxd"))
6225 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6226 else if (!strcmp(res->rxd_txd, "txd"))
6227 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6230 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6231 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6232 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6233 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6235 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6236 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6237 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6238 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6239 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6240 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6242 cmdline_parse_inst_t cmd_read_rxd_txd = {
6243 .f = cmd_read_rxd_txd_parsed,
6245 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6247 (void *)&cmd_read_rxd_txd_read,
6248 (void *)&cmd_read_rxd_txd_rxd_txd,
6249 (void *)&cmd_read_rxd_txd_port_id,
6250 (void *)&cmd_read_rxd_txd_queue_id,
6251 (void *)&cmd_read_rxd_txd_desc_id,
6257 struct cmd_quit_result {
6258 cmdline_fixed_string_t quit;
6261 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6263 __attribute__((unused)) void *data)
6269 cmdline_parse_token_string_t cmd_quit_quit =
6270 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6272 cmdline_parse_inst_t cmd_quit = {
6273 .f = cmd_quit_parsed,
6275 .help_str = "quit: Exit application",
6277 (void *)&cmd_quit_quit,
6282 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6283 struct cmd_mac_addr_result {
6284 cmdline_fixed_string_t mac_addr_cmd;
6285 cmdline_fixed_string_t what;
6287 struct ether_addr address;
6290 static void cmd_mac_addr_parsed(void *parsed_result,
6291 __attribute__((unused)) struct cmdline *cl,
6292 __attribute__((unused)) void *data)
6294 struct cmd_mac_addr_result *res = parsed_result;
6297 if (strcmp(res->what, "add") == 0)
6298 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6300 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6302 /* check the return value and print it if is < 0 */
6304 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6308 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6309 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6311 cmdline_parse_token_string_t cmd_mac_addr_what =
6312 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6314 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6315 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6316 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6317 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6319 cmdline_parse_inst_t cmd_mac_addr = {
6320 .f = cmd_mac_addr_parsed,
6322 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6323 "Add/Remove MAC address on port_id",
6325 (void *)&cmd_mac_addr_cmd,
6326 (void *)&cmd_mac_addr_what,
6327 (void *)&cmd_mac_addr_portnum,
6328 (void *)&cmd_mac_addr_addr,
6334 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6335 struct cmd_set_qmap_result {
6336 cmdline_fixed_string_t set;
6337 cmdline_fixed_string_t qmap;
6338 cmdline_fixed_string_t what;
6345 cmd_set_qmap_parsed(void *parsed_result,
6346 __attribute__((unused)) struct cmdline *cl,
6347 __attribute__((unused)) void *data)
6349 struct cmd_set_qmap_result *res = parsed_result;
6350 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6352 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6355 cmdline_parse_token_string_t cmd_setqmap_set =
6356 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6358 cmdline_parse_token_string_t cmd_setqmap_qmap =
6359 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6361 cmdline_parse_token_string_t cmd_setqmap_what =
6362 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6364 cmdline_parse_token_num_t cmd_setqmap_portid =
6365 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6367 cmdline_parse_token_num_t cmd_setqmap_queueid =
6368 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6370 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6371 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6374 cmdline_parse_inst_t cmd_set_qmap = {
6375 .f = cmd_set_qmap_parsed,
6377 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6378 "Set statistics mapping value on tx|rx queue_id of port_id",
6380 (void *)&cmd_setqmap_set,
6381 (void *)&cmd_setqmap_qmap,
6382 (void *)&cmd_setqmap_what,
6383 (void *)&cmd_setqmap_portid,
6384 (void *)&cmd_setqmap_queueid,
6385 (void *)&cmd_setqmap_mapvalue,
6390 /* *** CONFIGURE UNICAST HASH TABLE *** */
6391 struct cmd_set_uc_hash_table {
6392 cmdline_fixed_string_t set;
6393 cmdline_fixed_string_t port;
6395 cmdline_fixed_string_t what;
6396 struct ether_addr address;
6397 cmdline_fixed_string_t mode;
6401 cmd_set_uc_hash_parsed(void *parsed_result,
6402 __attribute__((unused)) struct cmdline *cl,
6403 __attribute__((unused)) void *data)
6406 struct cmd_set_uc_hash_table *res = parsed_result;
6408 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6410 if (strcmp(res->what, "uta") == 0)
6411 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6412 &res->address,(uint8_t)is_on);
6414 printf("bad unicast hash table parameter, return code = %d \n", ret);
6418 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6419 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6421 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6422 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6424 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6425 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6427 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6428 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6430 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6431 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6433 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6434 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6437 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6438 .f = cmd_set_uc_hash_parsed,
6440 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6442 (void *)&cmd_set_uc_hash_set,
6443 (void *)&cmd_set_uc_hash_port,
6444 (void *)&cmd_set_uc_hash_portid,
6445 (void *)&cmd_set_uc_hash_what,
6446 (void *)&cmd_set_uc_hash_mac,
6447 (void *)&cmd_set_uc_hash_mode,
6452 struct cmd_set_uc_all_hash_table {
6453 cmdline_fixed_string_t set;
6454 cmdline_fixed_string_t port;
6456 cmdline_fixed_string_t what;
6457 cmdline_fixed_string_t value;
6458 cmdline_fixed_string_t mode;
6462 cmd_set_uc_all_hash_parsed(void *parsed_result,
6463 __attribute__((unused)) struct cmdline *cl,
6464 __attribute__((unused)) void *data)
6467 struct cmd_set_uc_all_hash_table *res = parsed_result;
6469 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6471 if ((strcmp(res->what, "uta") == 0) &&
6472 (strcmp(res->value, "all") == 0))
6473 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6475 printf("bad unicast hash table parameter,"
6476 "return code = %d \n", ret);
6479 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6482 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6485 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6486 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6488 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6491 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6492 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6494 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6495 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6498 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6499 .f = cmd_set_uc_all_hash_parsed,
6501 .help_str = "set port <port_id> uta all on|off",
6503 (void *)&cmd_set_uc_all_hash_set,
6504 (void *)&cmd_set_uc_all_hash_port,
6505 (void *)&cmd_set_uc_all_hash_portid,
6506 (void *)&cmd_set_uc_all_hash_what,
6507 (void *)&cmd_set_uc_all_hash_value,
6508 (void *)&cmd_set_uc_all_hash_mode,
6513 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6514 struct cmd_set_vf_macvlan_filter {
6515 cmdline_fixed_string_t set;
6516 cmdline_fixed_string_t port;
6518 cmdline_fixed_string_t vf;
6520 struct ether_addr address;
6521 cmdline_fixed_string_t filter_type;
6522 cmdline_fixed_string_t mode;
6526 cmd_set_vf_macvlan_parsed(void *parsed_result,
6527 __attribute__((unused)) struct cmdline *cl,
6528 __attribute__((unused)) void *data)
6531 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6532 struct rte_eth_mac_filter filter;
6534 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6536 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6538 /* set VF MAC filter */
6542 filter.dst_id = res->vf_id;
6544 if (!strcmp(res->filter_type, "exact-mac"))
6545 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6546 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6547 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6548 else if (!strcmp(res->filter_type, "hashmac"))
6549 filter.filter_type = RTE_MAC_HASH_MATCH;
6550 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6551 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6553 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6556 ret = rte_eth_dev_filter_ctrl(res->port_id,
6557 RTE_ETH_FILTER_MACVLAN,
6561 ret = rte_eth_dev_filter_ctrl(res->port_id,
6562 RTE_ETH_FILTER_MACVLAN,
6563 RTE_ETH_FILTER_DELETE,
6567 printf("bad set MAC hash parameter, return code = %d\n", ret);
6571 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6572 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6574 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6575 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6577 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6578 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6580 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6581 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6583 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6584 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6586 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6587 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6589 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6590 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6591 filter_type, "exact-mac#exact-mac-vlan"
6592 "#hashmac#hashmac-vlan");
6593 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6594 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6597 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6598 .f = cmd_set_vf_macvlan_parsed,
6600 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6601 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6602 "Exact match rule: exact match of MAC or MAC and VLAN; "
6603 "hash match rule: hash match of MAC and exact match of VLAN",
6605 (void *)&cmd_set_vf_macvlan_set,
6606 (void *)&cmd_set_vf_macvlan_port,
6607 (void *)&cmd_set_vf_macvlan_portid,
6608 (void *)&cmd_set_vf_macvlan_vf,
6609 (void *)&cmd_set_vf_macvlan_vf_id,
6610 (void *)&cmd_set_vf_macvlan_mac,
6611 (void *)&cmd_set_vf_macvlan_filter_type,
6612 (void *)&cmd_set_vf_macvlan_mode,
6617 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6618 struct cmd_set_vf_traffic {
6619 cmdline_fixed_string_t set;
6620 cmdline_fixed_string_t port;
6622 cmdline_fixed_string_t vf;
6624 cmdline_fixed_string_t what;
6625 cmdline_fixed_string_t mode;
6629 cmd_set_vf_traffic_parsed(void *parsed_result,
6630 __attribute__((unused)) struct cmdline *cl,
6631 __attribute__((unused)) void *data)
6633 struct cmd_set_vf_traffic *res = parsed_result;
6634 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6635 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6637 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6640 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6641 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6643 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6644 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6646 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6647 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6649 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6650 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6652 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6653 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6655 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6656 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6658 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6659 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6662 cmdline_parse_inst_t cmd_set_vf_traffic = {
6663 .f = cmd_set_vf_traffic_parsed,
6665 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6667 (void *)&cmd_setvf_traffic_set,
6668 (void *)&cmd_setvf_traffic_port,
6669 (void *)&cmd_setvf_traffic_portid,
6670 (void *)&cmd_setvf_traffic_vf,
6671 (void *)&cmd_setvf_traffic_vfid,
6672 (void *)&cmd_setvf_traffic_what,
6673 (void *)&cmd_setvf_traffic_mode,
6678 /* *** CONFIGURE VF RECEIVE MODE *** */
6679 struct cmd_set_vf_rxmode {
6680 cmdline_fixed_string_t set;
6681 cmdline_fixed_string_t port;
6683 cmdline_fixed_string_t vf;
6685 cmdline_fixed_string_t what;
6686 cmdline_fixed_string_t mode;
6687 cmdline_fixed_string_t on;
6691 cmd_set_vf_rxmode_parsed(void *parsed_result,
6692 __attribute__((unused)) struct cmdline *cl,
6693 __attribute__((unused)) void *data)
6696 uint16_t rx_mode = 0;
6697 struct cmd_set_vf_rxmode *res = parsed_result;
6699 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6700 if (!strcmp(res->what,"rxmode")) {
6701 if (!strcmp(res->mode, "AUPE"))
6702 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6703 else if (!strcmp(res->mode, "ROPE"))
6704 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6705 else if (!strcmp(res->mode, "BAM"))
6706 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6707 else if (!strncmp(res->mode, "MPE",3))
6708 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6711 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6713 printf("bad VF receive mode parameter, return code = %d \n",
6717 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6718 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6720 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6721 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6723 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6724 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6726 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6727 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6729 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6730 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6732 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6733 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6735 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6736 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6737 mode, "AUPE#ROPE#BAM#MPE");
6738 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6739 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6742 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6743 .f = cmd_set_vf_rxmode_parsed,
6745 .help_str = "set port <port_id> vf <vf_id> rxmode "
6746 "AUPE|ROPE|BAM|MPE on|off",
6748 (void *)&cmd_set_vf_rxmode_set,
6749 (void *)&cmd_set_vf_rxmode_port,
6750 (void *)&cmd_set_vf_rxmode_portid,
6751 (void *)&cmd_set_vf_rxmode_vf,
6752 (void *)&cmd_set_vf_rxmode_vfid,
6753 (void *)&cmd_set_vf_rxmode_what,
6754 (void *)&cmd_set_vf_rxmode_mode,
6755 (void *)&cmd_set_vf_rxmode_on,
6760 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6761 struct cmd_vf_mac_addr_result {
6762 cmdline_fixed_string_t mac_addr_cmd;
6763 cmdline_fixed_string_t what;
6764 cmdline_fixed_string_t port;
6766 cmdline_fixed_string_t vf;
6768 struct ether_addr address;
6771 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6772 __attribute__((unused)) struct cmdline *cl,
6773 __attribute__((unused)) void *data)
6775 struct cmd_vf_mac_addr_result *res = parsed_result;
6778 if (strcmp(res->what, "add") == 0)
6779 ret = rte_eth_dev_mac_addr_add(res->port_num,
6780 &res->address, res->vf_num);
6782 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6786 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6787 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6788 mac_addr_cmd,"mac_addr");
6789 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6790 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6792 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6793 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6795 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6796 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6798 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6799 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6801 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6802 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6804 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6805 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6808 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6809 .f = cmd_vf_mac_addr_parsed,
6811 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6812 "Add MAC address filtering for a VF on port_id",
6814 (void *)&cmd_vf_mac_addr_cmd,
6815 (void *)&cmd_vf_mac_addr_what,
6816 (void *)&cmd_vf_mac_addr_port,
6817 (void *)&cmd_vf_mac_addr_portnum,
6818 (void *)&cmd_vf_mac_addr_vf,
6819 (void *)&cmd_vf_mac_addr_vfnum,
6820 (void *)&cmd_vf_mac_addr_addr,
6825 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6826 struct cmd_vf_rx_vlan_filter {
6827 cmdline_fixed_string_t rx_vlan;
6828 cmdline_fixed_string_t what;
6830 cmdline_fixed_string_t port;
6832 cmdline_fixed_string_t vf;
6837 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6838 __attribute__((unused)) struct cmdline *cl,
6839 __attribute__((unused)) void *data)
6841 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6843 if (!strcmp(res->what, "add"))
6844 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6846 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6849 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6850 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6851 rx_vlan, "rx_vlan");
6852 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6853 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6855 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6856 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6858 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6859 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6861 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6862 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6864 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6865 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6867 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6868 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6871 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6872 .f = cmd_vf_rx_vlan_filter_parsed,
6874 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6875 "(vf_mask = hexadecimal VF mask)",
6877 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6878 (void *)&cmd_vf_rx_vlan_filter_what,
6879 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6880 (void *)&cmd_vf_rx_vlan_filter_port,
6881 (void *)&cmd_vf_rx_vlan_filter_portid,
6882 (void *)&cmd_vf_rx_vlan_filter_vf,
6883 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6888 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6889 struct cmd_queue_rate_limit_result {
6890 cmdline_fixed_string_t set;
6891 cmdline_fixed_string_t port;
6893 cmdline_fixed_string_t queue;
6895 cmdline_fixed_string_t rate;
6899 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6900 __attribute__((unused)) struct cmdline *cl,
6901 __attribute__((unused)) void *data)
6903 struct cmd_queue_rate_limit_result *res = parsed_result;
6906 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6907 && (strcmp(res->queue, "queue") == 0)
6908 && (strcmp(res->rate, "rate") == 0))
6909 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6912 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6916 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6917 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6919 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6920 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6922 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6923 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6925 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6926 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6928 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6929 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6931 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6932 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6934 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6935 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6938 cmdline_parse_inst_t cmd_queue_rate_limit = {
6939 .f = cmd_queue_rate_limit_parsed,
6941 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6942 "Set rate limit for a queue on port_id",
6944 (void *)&cmd_queue_rate_limit_set,
6945 (void *)&cmd_queue_rate_limit_port,
6946 (void *)&cmd_queue_rate_limit_portnum,
6947 (void *)&cmd_queue_rate_limit_queue,
6948 (void *)&cmd_queue_rate_limit_queuenum,
6949 (void *)&cmd_queue_rate_limit_rate,
6950 (void *)&cmd_queue_rate_limit_ratenum,
6955 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6956 struct cmd_vf_rate_limit_result {
6957 cmdline_fixed_string_t set;
6958 cmdline_fixed_string_t port;
6960 cmdline_fixed_string_t vf;
6962 cmdline_fixed_string_t rate;
6964 cmdline_fixed_string_t q_msk;
6968 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6969 __attribute__((unused)) struct cmdline *cl,
6970 __attribute__((unused)) void *data)
6972 struct cmd_vf_rate_limit_result *res = parsed_result;
6975 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6976 && (strcmp(res->vf, "vf") == 0)
6977 && (strcmp(res->rate, "rate") == 0)
6978 && (strcmp(res->q_msk, "queue_mask") == 0))
6979 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6980 res->rate_num, res->q_msk_val);
6982 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6986 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6987 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6989 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6990 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6992 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6993 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6995 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6996 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6998 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6999 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7001 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7002 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7004 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7005 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7007 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7008 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7009 q_msk, "queue_mask");
7010 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7011 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7014 cmdline_parse_inst_t cmd_vf_rate_limit = {
7015 .f = cmd_vf_rate_limit_parsed,
7017 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7018 "queue_mask <queue_mask_value>: "
7019 "Set rate limit for queues of VF on port_id",
7021 (void *)&cmd_vf_rate_limit_set,
7022 (void *)&cmd_vf_rate_limit_port,
7023 (void *)&cmd_vf_rate_limit_portnum,
7024 (void *)&cmd_vf_rate_limit_vf,
7025 (void *)&cmd_vf_rate_limit_vfnum,
7026 (void *)&cmd_vf_rate_limit_rate,
7027 (void *)&cmd_vf_rate_limit_ratenum,
7028 (void *)&cmd_vf_rate_limit_q_msk,
7029 (void *)&cmd_vf_rate_limit_q_msk_val,
7034 /* *** ADD TUNNEL FILTER OF A PORT *** */
7035 struct cmd_tunnel_filter_result {
7036 cmdline_fixed_string_t cmd;
7037 cmdline_fixed_string_t what;
7039 struct ether_addr outer_mac;
7040 struct ether_addr inner_mac;
7041 cmdline_ipaddr_t ip_value;
7042 uint16_t inner_vlan;
7043 cmdline_fixed_string_t tunnel_type;
7044 cmdline_fixed_string_t filter_type;
7050 cmd_tunnel_filter_parsed(void *parsed_result,
7051 __attribute__((unused)) struct cmdline *cl,
7052 __attribute__((unused)) void *data)
7054 struct cmd_tunnel_filter_result *res = parsed_result;
7055 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7058 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7060 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7061 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7062 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7064 if (res->ip_value.family == AF_INET) {
7065 tunnel_filter_conf.ip_addr.ipv4_addr =
7066 res->ip_value.addr.ipv4.s_addr;
7067 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7069 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7070 &(res->ip_value.addr.ipv6),
7071 sizeof(struct in6_addr));
7072 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7075 if (!strcmp(res->filter_type, "imac-ivlan"))
7076 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7077 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7078 tunnel_filter_conf.filter_type =
7079 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7080 else if (!strcmp(res->filter_type, "imac-tenid"))
7081 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7082 else if (!strcmp(res->filter_type, "imac"))
7083 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7084 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7085 tunnel_filter_conf.filter_type =
7086 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7087 else if (!strcmp(res->filter_type, "oip"))
7088 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7089 else if (!strcmp(res->filter_type, "iip"))
7090 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7092 printf("The filter type is not supported");
7096 if (!strcmp(res->tunnel_type, "vxlan"))
7097 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7098 else if (!strcmp(res->tunnel_type, "nvgre"))
7099 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7100 else if (!strcmp(res->tunnel_type, "ipingre"))
7101 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7103 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7107 tunnel_filter_conf.tenant_id = res->tenant_id;
7108 tunnel_filter_conf.queue_id = res->queue_num;
7109 if (!strcmp(res->what, "add"))
7110 ret = rte_eth_dev_filter_ctrl(res->port_id,
7111 RTE_ETH_FILTER_TUNNEL,
7113 &tunnel_filter_conf);
7115 ret = rte_eth_dev_filter_ctrl(res->port_id,
7116 RTE_ETH_FILTER_TUNNEL,
7117 RTE_ETH_FILTER_DELETE,
7118 &tunnel_filter_conf);
7120 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7124 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7125 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7126 cmd, "tunnel_filter");
7127 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7128 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7130 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7131 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7133 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7134 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7136 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7137 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7139 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7140 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7141 inner_vlan, UINT16);
7142 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7143 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7145 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7146 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7147 tunnel_type, "vxlan#nvgre#ipingre");
7149 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7150 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7151 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7152 "imac#omac-imac-tenid");
7153 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7154 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7156 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7157 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7160 cmdline_parse_inst_t cmd_tunnel_filter = {
7161 .f = cmd_tunnel_filter_parsed,
7163 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7164 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7165 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7166 "<queue_id>: Add/Rm tunnel filter of a port",
7168 (void *)&cmd_tunnel_filter_cmd,
7169 (void *)&cmd_tunnel_filter_what,
7170 (void *)&cmd_tunnel_filter_port_id,
7171 (void *)&cmd_tunnel_filter_outer_mac,
7172 (void *)&cmd_tunnel_filter_inner_mac,
7173 (void *)&cmd_tunnel_filter_ip_value,
7174 (void *)&cmd_tunnel_filter_innner_vlan,
7175 (void *)&cmd_tunnel_filter_tunnel_type,
7176 (void *)&cmd_tunnel_filter_filter_type,
7177 (void *)&cmd_tunnel_filter_tenant_id,
7178 (void *)&cmd_tunnel_filter_queue_num,
7183 /* *** CONFIGURE TUNNEL UDP PORT *** */
7184 struct cmd_tunnel_udp_config {
7185 cmdline_fixed_string_t cmd;
7186 cmdline_fixed_string_t what;
7192 cmd_tunnel_udp_config_parsed(void *parsed_result,
7193 __attribute__((unused)) struct cmdline *cl,
7194 __attribute__((unused)) void *data)
7196 struct cmd_tunnel_udp_config *res = parsed_result;
7197 struct rte_eth_udp_tunnel tunnel_udp;
7200 tunnel_udp.udp_port = res->udp_port;
7202 if (!strcmp(res->cmd, "rx_vxlan_port"))
7203 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7205 if (!strcmp(res->what, "add"))
7206 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7209 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7213 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7216 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7217 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7218 cmd, "rx_vxlan_port");
7219 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7220 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7222 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7223 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7225 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7226 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7229 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7230 .f = cmd_tunnel_udp_config_parsed,
7232 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7233 "Add/Remove a tunneling UDP port filter",
7235 (void *)&cmd_tunnel_udp_config_cmd,
7236 (void *)&cmd_tunnel_udp_config_what,
7237 (void *)&cmd_tunnel_udp_config_udp_port,
7238 (void *)&cmd_tunnel_udp_config_port_id,
7243 /* *** GLOBAL CONFIG *** */
7244 struct cmd_global_config_result {
7245 cmdline_fixed_string_t cmd;
7247 cmdline_fixed_string_t cfg_type;
7252 cmd_global_config_parsed(void *parsed_result,
7253 __attribute__((unused)) struct cmdline *cl,
7254 __attribute__((unused)) void *data)
7256 struct cmd_global_config_result *res = parsed_result;
7257 struct rte_eth_global_cfg conf;
7260 memset(&conf, 0, sizeof(conf));
7261 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7262 conf.cfg.gre_key_len = res->len;
7263 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7264 RTE_ETH_FILTER_SET, &conf);
7266 printf("Global config error\n");
7269 cmdline_parse_token_string_t cmd_global_config_cmd =
7270 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7272 cmdline_parse_token_num_t cmd_global_config_port_id =
7273 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7274 cmdline_parse_token_string_t cmd_global_config_type =
7275 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7276 cfg_type, "gre-key-len");
7277 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7278 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7281 cmdline_parse_inst_t cmd_global_config = {
7282 .f = cmd_global_config_parsed,
7283 .data = (void *)NULL,
7284 .help_str = "global_config <port_id> gre-key-len <key_len>",
7286 (void *)&cmd_global_config_cmd,
7287 (void *)&cmd_global_config_port_id,
7288 (void *)&cmd_global_config_type,
7289 (void *)&cmd_global_config_gre_key_len,
7294 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7295 struct cmd_set_mirror_mask_result {
7296 cmdline_fixed_string_t set;
7297 cmdline_fixed_string_t port;
7299 cmdline_fixed_string_t mirror;
7301 cmdline_fixed_string_t what;
7302 cmdline_fixed_string_t value;
7303 cmdline_fixed_string_t dstpool;
7305 cmdline_fixed_string_t on;
7308 cmdline_parse_token_string_t cmd_mirror_mask_set =
7309 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7311 cmdline_parse_token_string_t cmd_mirror_mask_port =
7312 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7314 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7315 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7317 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7318 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7319 mirror, "mirror-rule");
7320 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7321 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7323 cmdline_parse_token_string_t cmd_mirror_mask_what =
7324 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7325 what, "pool-mirror-up#pool-mirror-down"
7327 cmdline_parse_token_string_t cmd_mirror_mask_value =
7328 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7330 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7331 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7332 dstpool, "dst-pool");
7333 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7334 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7336 cmdline_parse_token_string_t cmd_mirror_mask_on =
7337 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7341 cmd_set_mirror_mask_parsed(void *parsed_result,
7342 __attribute__((unused)) struct cmdline *cl,
7343 __attribute__((unused)) void *data)
7346 struct cmd_set_mirror_mask_result *res = parsed_result;
7347 struct rte_eth_mirror_conf mr_conf;
7349 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7351 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7353 mr_conf.dst_pool = res->dstpool_id;
7355 if (!strcmp(res->what, "pool-mirror-up")) {
7356 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7357 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7358 } else if (!strcmp(res->what, "pool-mirror-down")) {
7359 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7360 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7361 } else if (!strcmp(res->what, "vlan-mirror")) {
7362 mr_conf.rule_type = ETH_MIRROR_VLAN;
7363 nb_item = parse_item_list(res->value, "vlan",
7364 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7368 for (i = 0; i < nb_item; i++) {
7369 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7370 printf("Invalid vlan_id: must be < 4096\n");
7374 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7375 mr_conf.vlan.vlan_mask |= 1ULL << i;
7379 if (!strcmp(res->on, "on"))
7380 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7383 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7386 printf("mirror rule add error: (%s)\n", strerror(-ret));
7389 cmdline_parse_inst_t cmd_set_mirror_mask = {
7390 .f = cmd_set_mirror_mask_parsed,
7392 .help_str = "set port <port_id> mirror-rule <rule_id> "
7393 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7394 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7396 (void *)&cmd_mirror_mask_set,
7397 (void *)&cmd_mirror_mask_port,
7398 (void *)&cmd_mirror_mask_portid,
7399 (void *)&cmd_mirror_mask_mirror,
7400 (void *)&cmd_mirror_mask_ruleid,
7401 (void *)&cmd_mirror_mask_what,
7402 (void *)&cmd_mirror_mask_value,
7403 (void *)&cmd_mirror_mask_dstpool,
7404 (void *)&cmd_mirror_mask_poolid,
7405 (void *)&cmd_mirror_mask_on,
7410 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7411 struct cmd_set_mirror_link_result {
7412 cmdline_fixed_string_t set;
7413 cmdline_fixed_string_t port;
7415 cmdline_fixed_string_t mirror;
7417 cmdline_fixed_string_t what;
7418 cmdline_fixed_string_t dstpool;
7420 cmdline_fixed_string_t on;
7423 cmdline_parse_token_string_t cmd_mirror_link_set =
7424 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7426 cmdline_parse_token_string_t cmd_mirror_link_port =
7427 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7429 cmdline_parse_token_num_t cmd_mirror_link_portid =
7430 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7432 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7433 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7434 mirror, "mirror-rule");
7435 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7436 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7438 cmdline_parse_token_string_t cmd_mirror_link_what =
7439 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7440 what, "uplink-mirror#downlink-mirror");
7441 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7442 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7443 dstpool, "dst-pool");
7444 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7445 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7447 cmdline_parse_token_string_t cmd_mirror_link_on =
7448 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7452 cmd_set_mirror_link_parsed(void *parsed_result,
7453 __attribute__((unused)) struct cmdline *cl,
7454 __attribute__((unused)) void *data)
7457 struct cmd_set_mirror_link_result *res = parsed_result;
7458 struct rte_eth_mirror_conf mr_conf;
7460 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7461 if (!strcmp(res->what, "uplink-mirror"))
7462 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7464 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7466 mr_conf.dst_pool = res->dstpool_id;
7468 if (!strcmp(res->on, "on"))
7469 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7472 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7475 /* check the return value and print it if is < 0 */
7477 printf("mirror rule add error: (%s)\n", strerror(-ret));
7481 cmdline_parse_inst_t cmd_set_mirror_link = {
7482 .f = cmd_set_mirror_link_parsed,
7484 .help_str = "set port <port_id> mirror-rule <rule_id> "
7485 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7487 (void *)&cmd_mirror_link_set,
7488 (void *)&cmd_mirror_link_port,
7489 (void *)&cmd_mirror_link_portid,
7490 (void *)&cmd_mirror_link_mirror,
7491 (void *)&cmd_mirror_link_ruleid,
7492 (void *)&cmd_mirror_link_what,
7493 (void *)&cmd_mirror_link_dstpool,
7494 (void *)&cmd_mirror_link_poolid,
7495 (void *)&cmd_mirror_link_on,
7500 /* *** RESET VM MIRROR RULE *** */
7501 struct cmd_rm_mirror_rule_result {
7502 cmdline_fixed_string_t reset;
7503 cmdline_fixed_string_t port;
7505 cmdline_fixed_string_t mirror;
7509 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7510 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7512 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7513 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7515 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7516 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7518 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7519 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7520 mirror, "mirror-rule");
7521 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7522 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7526 cmd_reset_mirror_rule_parsed(void *parsed_result,
7527 __attribute__((unused)) struct cmdline *cl,
7528 __attribute__((unused)) void *data)
7531 struct cmd_set_mirror_link_result *res = parsed_result;
7533 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7535 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7538 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7539 .f = cmd_reset_mirror_rule_parsed,
7541 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7543 (void *)&cmd_rm_mirror_rule_reset,
7544 (void *)&cmd_rm_mirror_rule_port,
7545 (void *)&cmd_rm_mirror_rule_portid,
7546 (void *)&cmd_rm_mirror_rule_mirror,
7547 (void *)&cmd_rm_mirror_rule_ruleid,
7552 /* ******************************************************************************** */
7554 struct cmd_dump_result {
7555 cmdline_fixed_string_t dump;
7559 dump_struct_sizes(void)
7561 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7562 DUMP_SIZE(struct rte_mbuf);
7563 DUMP_SIZE(struct rte_mempool);
7564 DUMP_SIZE(struct rte_ring);
7568 static void cmd_dump_parsed(void *parsed_result,
7569 __attribute__((unused)) struct cmdline *cl,
7570 __attribute__((unused)) void *data)
7572 struct cmd_dump_result *res = parsed_result;
7574 if (!strcmp(res->dump, "dump_physmem"))
7575 rte_dump_physmem_layout(stdout);
7576 else if (!strcmp(res->dump, "dump_memzone"))
7577 rte_memzone_dump(stdout);
7578 else if (!strcmp(res->dump, "dump_struct_sizes"))
7579 dump_struct_sizes();
7580 else if (!strcmp(res->dump, "dump_ring"))
7581 rte_ring_list_dump(stdout);
7582 else if (!strcmp(res->dump, "dump_mempool"))
7583 rte_mempool_list_dump(stdout);
7584 else if (!strcmp(res->dump, "dump_devargs"))
7585 rte_eal_devargs_dump(stdout);
7588 cmdline_parse_token_string_t cmd_dump_dump =
7589 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7592 "dump_struct_sizes#"
7597 cmdline_parse_inst_t cmd_dump = {
7598 .f = cmd_dump_parsed, /* function to call */
7599 .data = NULL, /* 2nd arg of func */
7600 .help_str = "Dump status",
7601 .tokens = { /* token list, NULL terminated */
7602 (void *)&cmd_dump_dump,
7607 /* ******************************************************************************** */
7609 struct cmd_dump_one_result {
7610 cmdline_fixed_string_t dump;
7611 cmdline_fixed_string_t name;
7614 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7615 __attribute__((unused)) void *data)
7617 struct cmd_dump_one_result *res = parsed_result;
7619 if (!strcmp(res->dump, "dump_ring")) {
7621 r = rte_ring_lookup(res->name);
7623 cmdline_printf(cl, "Cannot find ring\n");
7626 rte_ring_dump(stdout, r);
7627 } else if (!strcmp(res->dump, "dump_mempool")) {
7628 struct rte_mempool *mp;
7629 mp = rte_mempool_lookup(res->name);
7631 cmdline_printf(cl, "Cannot find mempool\n");
7634 rte_mempool_dump(stdout, mp);
7638 cmdline_parse_token_string_t cmd_dump_one_dump =
7639 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7640 "dump_ring#dump_mempool");
7642 cmdline_parse_token_string_t cmd_dump_one_name =
7643 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7645 cmdline_parse_inst_t cmd_dump_one = {
7646 .f = cmd_dump_one_parsed, /* function to call */
7647 .data = NULL, /* 2nd arg of func */
7648 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7649 .tokens = { /* token list, NULL terminated */
7650 (void *)&cmd_dump_one_dump,
7651 (void *)&cmd_dump_one_name,
7656 /* *** Add/Del syn filter *** */
7657 struct cmd_syn_filter_result {
7658 cmdline_fixed_string_t filter;
7660 cmdline_fixed_string_t ops;
7661 cmdline_fixed_string_t priority;
7662 cmdline_fixed_string_t high;
7663 cmdline_fixed_string_t queue;
7668 cmd_syn_filter_parsed(void *parsed_result,
7669 __attribute__((unused)) struct cmdline *cl,
7670 __attribute__((unused)) void *data)
7672 struct cmd_syn_filter_result *res = parsed_result;
7673 struct rte_eth_syn_filter syn_filter;
7676 ret = rte_eth_dev_filter_supported(res->port_id,
7677 RTE_ETH_FILTER_SYN);
7679 printf("syn filter is not supported on port %u.\n",
7684 memset(&syn_filter, 0, sizeof(syn_filter));
7686 if (!strcmp(res->ops, "add")) {
7687 if (!strcmp(res->high, "high"))
7688 syn_filter.hig_pri = 1;
7690 syn_filter.hig_pri = 0;
7692 syn_filter.queue = res->queue_id;
7693 ret = rte_eth_dev_filter_ctrl(res->port_id,
7698 ret = rte_eth_dev_filter_ctrl(res->port_id,
7700 RTE_ETH_FILTER_DELETE,
7704 printf("syn filter programming error: (%s)\n",
7708 cmdline_parse_token_string_t cmd_syn_filter_filter =
7709 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7710 filter, "syn_filter");
7711 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7712 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7714 cmdline_parse_token_string_t cmd_syn_filter_ops =
7715 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7717 cmdline_parse_token_string_t cmd_syn_filter_priority =
7718 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7719 priority, "priority");
7720 cmdline_parse_token_string_t cmd_syn_filter_high =
7721 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7723 cmdline_parse_token_string_t cmd_syn_filter_queue =
7724 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7726 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7727 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7730 cmdline_parse_inst_t cmd_syn_filter = {
7731 .f = cmd_syn_filter_parsed,
7733 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7734 "<queue_id>: Add/Delete syn filter",
7736 (void *)&cmd_syn_filter_filter,
7737 (void *)&cmd_syn_filter_port_id,
7738 (void *)&cmd_syn_filter_ops,
7739 (void *)&cmd_syn_filter_priority,
7740 (void *)&cmd_syn_filter_high,
7741 (void *)&cmd_syn_filter_queue,
7742 (void *)&cmd_syn_filter_queue_id,
7747 /* *** ADD/REMOVE A 2tuple FILTER *** */
7748 struct cmd_2tuple_filter_result {
7749 cmdline_fixed_string_t filter;
7751 cmdline_fixed_string_t ops;
7752 cmdline_fixed_string_t dst_port;
7753 uint16_t dst_port_value;
7754 cmdline_fixed_string_t protocol;
7755 uint8_t protocol_value;
7756 cmdline_fixed_string_t mask;
7758 cmdline_fixed_string_t tcp_flags;
7759 uint8_t tcp_flags_value;
7760 cmdline_fixed_string_t priority;
7761 uint8_t priority_value;
7762 cmdline_fixed_string_t queue;
7767 cmd_2tuple_filter_parsed(void *parsed_result,
7768 __attribute__((unused)) struct cmdline *cl,
7769 __attribute__((unused)) void *data)
7771 struct rte_eth_ntuple_filter filter;
7772 struct cmd_2tuple_filter_result *res = parsed_result;
7775 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7777 printf("ntuple filter is not supported on port %u.\n",
7782 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7784 filter.flags = RTE_2TUPLE_FLAGS;
7785 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7786 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7787 filter.proto = res->protocol_value;
7788 filter.priority = res->priority_value;
7789 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7790 printf("nonzero tcp_flags is only meaningful"
7791 " when protocol is TCP.\n");
7794 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7795 printf("invalid TCP flags.\n");
7799 if (res->tcp_flags_value != 0) {
7800 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7801 filter.tcp_flags = res->tcp_flags_value;
7804 /* need convert to big endian. */
7805 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7806 filter.queue = res->queue_id;
7808 if (!strcmp(res->ops, "add"))
7809 ret = rte_eth_dev_filter_ctrl(res->port_id,
7810 RTE_ETH_FILTER_NTUPLE,
7814 ret = rte_eth_dev_filter_ctrl(res->port_id,
7815 RTE_ETH_FILTER_NTUPLE,
7816 RTE_ETH_FILTER_DELETE,
7819 printf("2tuple filter programming error: (%s)\n",
7824 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7825 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7826 filter, "2tuple_filter");
7827 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7828 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7830 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7831 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7833 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7834 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7835 dst_port, "dst_port");
7836 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7837 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7838 dst_port_value, UINT16);
7839 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7840 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7841 protocol, "protocol");
7842 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7843 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7844 protocol_value, UINT8);
7845 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7846 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7848 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7849 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7851 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7852 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7853 tcp_flags, "tcp_flags");
7854 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7855 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7856 tcp_flags_value, UINT8);
7857 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7858 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7859 priority, "priority");
7860 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7861 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7862 priority_value, UINT8);
7863 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7864 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7866 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7867 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7870 cmdline_parse_inst_t cmd_2tuple_filter = {
7871 .f = cmd_2tuple_filter_parsed,
7873 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7874 "<value> mask <value> tcp_flags <value> priority <value> queue "
7875 "<queue_id>: Add a 2tuple filter",
7877 (void *)&cmd_2tuple_filter_filter,
7878 (void *)&cmd_2tuple_filter_port_id,
7879 (void *)&cmd_2tuple_filter_ops,
7880 (void *)&cmd_2tuple_filter_dst_port,
7881 (void *)&cmd_2tuple_filter_dst_port_value,
7882 (void *)&cmd_2tuple_filter_protocol,
7883 (void *)&cmd_2tuple_filter_protocol_value,
7884 (void *)&cmd_2tuple_filter_mask,
7885 (void *)&cmd_2tuple_filter_mask_value,
7886 (void *)&cmd_2tuple_filter_tcp_flags,
7887 (void *)&cmd_2tuple_filter_tcp_flags_value,
7888 (void *)&cmd_2tuple_filter_priority,
7889 (void *)&cmd_2tuple_filter_priority_value,
7890 (void *)&cmd_2tuple_filter_queue,
7891 (void *)&cmd_2tuple_filter_queue_id,
7896 /* *** ADD/REMOVE A 5tuple FILTER *** */
7897 struct cmd_5tuple_filter_result {
7898 cmdline_fixed_string_t filter;
7900 cmdline_fixed_string_t ops;
7901 cmdline_fixed_string_t dst_ip;
7902 cmdline_ipaddr_t dst_ip_value;
7903 cmdline_fixed_string_t src_ip;
7904 cmdline_ipaddr_t src_ip_value;
7905 cmdline_fixed_string_t dst_port;
7906 uint16_t dst_port_value;
7907 cmdline_fixed_string_t src_port;
7908 uint16_t src_port_value;
7909 cmdline_fixed_string_t protocol;
7910 uint8_t protocol_value;
7911 cmdline_fixed_string_t mask;
7913 cmdline_fixed_string_t tcp_flags;
7914 uint8_t tcp_flags_value;
7915 cmdline_fixed_string_t priority;
7916 uint8_t priority_value;
7917 cmdline_fixed_string_t queue;
7922 cmd_5tuple_filter_parsed(void *parsed_result,
7923 __attribute__((unused)) struct cmdline *cl,
7924 __attribute__((unused)) void *data)
7926 struct rte_eth_ntuple_filter filter;
7927 struct cmd_5tuple_filter_result *res = parsed_result;
7930 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7932 printf("ntuple filter is not supported on port %u.\n",
7937 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7939 filter.flags = RTE_5TUPLE_FLAGS;
7940 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7941 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7942 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7943 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7944 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7945 filter.proto = res->protocol_value;
7946 filter.priority = res->priority_value;
7947 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7948 printf("nonzero tcp_flags is only meaningful"
7949 " when protocol is TCP.\n");
7952 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7953 printf("invalid TCP flags.\n");
7957 if (res->tcp_flags_value != 0) {
7958 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7959 filter.tcp_flags = res->tcp_flags_value;
7962 if (res->dst_ip_value.family == AF_INET)
7963 /* no need to convert, already big endian. */
7964 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7966 if (filter.dst_ip_mask == 0) {
7967 printf("can not support ipv6 involved compare.\n");
7973 if (res->src_ip_value.family == AF_INET)
7974 /* no need to convert, already big endian. */
7975 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7977 if (filter.src_ip_mask == 0) {
7978 printf("can not support ipv6 involved compare.\n");
7983 /* need convert to big endian. */
7984 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7985 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7986 filter.queue = res->queue_id;
7988 if (!strcmp(res->ops, "add"))
7989 ret = rte_eth_dev_filter_ctrl(res->port_id,
7990 RTE_ETH_FILTER_NTUPLE,
7994 ret = rte_eth_dev_filter_ctrl(res->port_id,
7995 RTE_ETH_FILTER_NTUPLE,
7996 RTE_ETH_FILTER_DELETE,
7999 printf("5tuple filter programming error: (%s)\n",
8003 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8004 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8005 filter, "5tuple_filter");
8006 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8007 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8009 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8010 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8012 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8013 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8015 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8016 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8018 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8019 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8021 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8022 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8024 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8025 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8026 dst_port, "dst_port");
8027 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8028 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8029 dst_port_value, UINT16);
8030 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8031 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8032 src_port, "src_port");
8033 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8034 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8035 src_port_value, UINT16);
8036 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8037 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8038 protocol, "protocol");
8039 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8040 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8041 protocol_value, UINT8);
8042 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8043 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8045 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8046 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8048 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8049 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8050 tcp_flags, "tcp_flags");
8051 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8052 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8053 tcp_flags_value, UINT8);
8054 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8055 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8056 priority, "priority");
8057 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8058 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8059 priority_value, UINT8);
8060 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8061 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8063 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8064 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8067 cmdline_parse_inst_t cmd_5tuple_filter = {
8068 .f = cmd_5tuple_filter_parsed,
8070 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8071 "src_ip <value> dst_port <value> src_port <value> "
8072 "protocol <value> mask <value> tcp_flags <value> "
8073 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8075 (void *)&cmd_5tuple_filter_filter,
8076 (void *)&cmd_5tuple_filter_port_id,
8077 (void *)&cmd_5tuple_filter_ops,
8078 (void *)&cmd_5tuple_filter_dst_ip,
8079 (void *)&cmd_5tuple_filter_dst_ip_value,
8080 (void *)&cmd_5tuple_filter_src_ip,
8081 (void *)&cmd_5tuple_filter_src_ip_value,
8082 (void *)&cmd_5tuple_filter_dst_port,
8083 (void *)&cmd_5tuple_filter_dst_port_value,
8084 (void *)&cmd_5tuple_filter_src_port,
8085 (void *)&cmd_5tuple_filter_src_port_value,
8086 (void *)&cmd_5tuple_filter_protocol,
8087 (void *)&cmd_5tuple_filter_protocol_value,
8088 (void *)&cmd_5tuple_filter_mask,
8089 (void *)&cmd_5tuple_filter_mask_value,
8090 (void *)&cmd_5tuple_filter_tcp_flags,
8091 (void *)&cmd_5tuple_filter_tcp_flags_value,
8092 (void *)&cmd_5tuple_filter_priority,
8093 (void *)&cmd_5tuple_filter_priority_value,
8094 (void *)&cmd_5tuple_filter_queue,
8095 (void *)&cmd_5tuple_filter_queue_id,
8100 /* *** ADD/REMOVE A flex FILTER *** */
8101 struct cmd_flex_filter_result {
8102 cmdline_fixed_string_t filter;
8103 cmdline_fixed_string_t ops;
8105 cmdline_fixed_string_t len;
8107 cmdline_fixed_string_t bytes;
8108 cmdline_fixed_string_t bytes_value;
8109 cmdline_fixed_string_t mask;
8110 cmdline_fixed_string_t mask_value;
8111 cmdline_fixed_string_t priority;
8112 uint8_t priority_value;
8113 cmdline_fixed_string_t queue;
8117 static int xdigit2val(unsigned char c)
8122 else if (isupper(c))
8130 cmd_flex_filter_parsed(void *parsed_result,
8131 __attribute__((unused)) struct cmdline *cl,
8132 __attribute__((unused)) void *data)
8135 struct rte_eth_flex_filter filter;
8136 struct cmd_flex_filter_result *res = parsed_result;
8137 char *bytes_ptr, *mask_ptr;
8138 uint16_t len, i, j = 0;
8143 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8144 printf("the len exceed the max length 128\n");
8147 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8148 filter.len = res->len_value;
8149 filter.priority = res->priority_value;
8150 filter.queue = res->queue_id;
8151 bytes_ptr = res->bytes_value;
8152 mask_ptr = res->mask_value;
8154 /* translate bytes string to array. */
8155 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8156 (bytes_ptr[1] == 'X')))
8158 len = strnlen(bytes_ptr, res->len_value * 2);
8159 if (len == 0 || (len % 8 != 0)) {
8160 printf("please check len and bytes input\n");
8163 for (i = 0; i < len; i++) {
8165 if (isxdigit(c) == 0) {
8166 /* invalid characters. */
8167 printf("invalid input\n");
8170 val = xdigit2val(c);
8173 filter.bytes[j] = byte;
8174 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8181 /* translate mask string to uint8_t array. */
8182 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8183 (mask_ptr[1] == 'X')))
8185 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8187 printf("invalid input\n");
8192 for (i = 0; i < len; i++) {
8194 if (isxdigit(c) == 0) {
8195 /* invalid characters. */
8196 printf("invalid input\n");
8199 val = xdigit2val(c);
8202 filter.mask[j] = byte;
8203 printf("mask[%d]:%02x ", j, filter.mask[j]);
8211 if (!strcmp(res->ops, "add"))
8212 ret = rte_eth_dev_filter_ctrl(res->port_id,
8213 RTE_ETH_FILTER_FLEXIBLE,
8217 ret = rte_eth_dev_filter_ctrl(res->port_id,
8218 RTE_ETH_FILTER_FLEXIBLE,
8219 RTE_ETH_FILTER_DELETE,
8223 printf("flex filter setting error: (%s)\n", strerror(-ret));
8226 cmdline_parse_token_string_t cmd_flex_filter_filter =
8227 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8228 filter, "flex_filter");
8229 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8230 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8232 cmdline_parse_token_string_t cmd_flex_filter_ops =
8233 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8235 cmdline_parse_token_string_t cmd_flex_filter_len =
8236 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8238 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8239 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8241 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8242 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8244 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8245 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8247 cmdline_parse_token_string_t cmd_flex_filter_mask =
8248 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8250 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8251 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8253 cmdline_parse_token_string_t cmd_flex_filter_priority =
8254 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8255 priority, "priority");
8256 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8257 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8258 priority_value, UINT8);
8259 cmdline_parse_token_string_t cmd_flex_filter_queue =
8260 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8262 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8263 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8265 cmdline_parse_inst_t cmd_flex_filter = {
8266 .f = cmd_flex_filter_parsed,
8268 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8269 "<value> mask <value> priority <value> queue <queue_id>: "
8270 "Add/Del a flex filter",
8272 (void *)&cmd_flex_filter_filter,
8273 (void *)&cmd_flex_filter_port_id,
8274 (void *)&cmd_flex_filter_ops,
8275 (void *)&cmd_flex_filter_len,
8276 (void *)&cmd_flex_filter_len_value,
8277 (void *)&cmd_flex_filter_bytes,
8278 (void *)&cmd_flex_filter_bytes_value,
8279 (void *)&cmd_flex_filter_mask,
8280 (void *)&cmd_flex_filter_mask_value,
8281 (void *)&cmd_flex_filter_priority,
8282 (void *)&cmd_flex_filter_priority_value,
8283 (void *)&cmd_flex_filter_queue,
8284 (void *)&cmd_flex_filter_queue_id,
8289 /* *** Filters Control *** */
8291 /* *** deal with ethertype filter *** */
8292 struct cmd_ethertype_filter_result {
8293 cmdline_fixed_string_t filter;
8295 cmdline_fixed_string_t ops;
8296 cmdline_fixed_string_t mac;
8297 struct ether_addr mac_addr;
8298 cmdline_fixed_string_t ethertype;
8299 uint16_t ethertype_value;
8300 cmdline_fixed_string_t drop;
8301 cmdline_fixed_string_t queue;
8305 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8306 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8307 filter, "ethertype_filter");
8308 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8309 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8311 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8312 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8314 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8315 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8316 mac, "mac_addr#mac_ignr");
8317 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8318 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8320 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8321 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8322 ethertype, "ethertype");
8323 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8324 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8325 ethertype_value, UINT16);
8326 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8327 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8329 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8330 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8332 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8333 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8337 cmd_ethertype_filter_parsed(void *parsed_result,
8338 __attribute__((unused)) struct cmdline *cl,
8339 __attribute__((unused)) void *data)
8341 struct cmd_ethertype_filter_result *res = parsed_result;
8342 struct rte_eth_ethertype_filter filter;
8345 ret = rte_eth_dev_filter_supported(res->port_id,
8346 RTE_ETH_FILTER_ETHERTYPE);
8348 printf("ethertype filter is not supported on port %u.\n",
8353 memset(&filter, 0, sizeof(filter));
8354 if (!strcmp(res->mac, "mac_addr")) {
8355 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8356 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8357 sizeof(struct ether_addr));
8359 if (!strcmp(res->drop, "drop"))
8360 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8361 filter.ether_type = res->ethertype_value;
8362 filter.queue = res->queue_id;
8364 if (!strcmp(res->ops, "add"))
8365 ret = rte_eth_dev_filter_ctrl(res->port_id,
8366 RTE_ETH_FILTER_ETHERTYPE,
8370 ret = rte_eth_dev_filter_ctrl(res->port_id,
8371 RTE_ETH_FILTER_ETHERTYPE,
8372 RTE_ETH_FILTER_DELETE,
8375 printf("ethertype filter programming error: (%s)\n",
8379 cmdline_parse_inst_t cmd_ethertype_filter = {
8380 .f = cmd_ethertype_filter_parsed,
8382 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8383 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8384 "Add or delete an ethertype filter entry",
8386 (void *)&cmd_ethertype_filter_filter,
8387 (void *)&cmd_ethertype_filter_port_id,
8388 (void *)&cmd_ethertype_filter_ops,
8389 (void *)&cmd_ethertype_filter_mac,
8390 (void *)&cmd_ethertype_filter_mac_addr,
8391 (void *)&cmd_ethertype_filter_ethertype,
8392 (void *)&cmd_ethertype_filter_ethertype_value,
8393 (void *)&cmd_ethertype_filter_drop,
8394 (void *)&cmd_ethertype_filter_queue,
8395 (void *)&cmd_ethertype_filter_queue_id,
8400 /* *** deal with flow director filter *** */
8401 struct cmd_flow_director_result {
8402 cmdline_fixed_string_t flow_director_filter;
8404 cmdline_fixed_string_t mode;
8405 cmdline_fixed_string_t mode_value;
8406 cmdline_fixed_string_t ops;
8407 cmdline_fixed_string_t flow;
8408 cmdline_fixed_string_t flow_type;
8409 cmdline_fixed_string_t ether;
8410 uint16_t ether_type;
8411 cmdline_fixed_string_t src;
8412 cmdline_ipaddr_t ip_src;
8414 cmdline_fixed_string_t dst;
8415 cmdline_ipaddr_t ip_dst;
8417 cmdline_fixed_string_t verify_tag;
8418 uint32_t verify_tag_value;
8419 cmdline_ipaddr_t tos;
8421 cmdline_ipaddr_t proto;
8422 uint8_t proto_value;
8423 cmdline_ipaddr_t ttl;
8425 cmdline_fixed_string_t vlan;
8426 uint16_t vlan_value;
8427 cmdline_fixed_string_t flexbytes;
8428 cmdline_fixed_string_t flexbytes_value;
8429 cmdline_fixed_string_t pf_vf;
8430 cmdline_fixed_string_t drop;
8431 cmdline_fixed_string_t queue;
8433 cmdline_fixed_string_t fd_id;
8434 uint32_t fd_id_value;
8435 cmdline_fixed_string_t mac;
8436 struct ether_addr mac_addr;
8437 cmdline_fixed_string_t tunnel;
8438 cmdline_fixed_string_t tunnel_type;
8439 cmdline_fixed_string_t tunnel_id;
8440 uint32_t tunnel_id_value;
8444 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8447 const char *p, *p0 = q_arg;
8449 unsigned long int_fld;
8450 char *str_fld[max_num];
8455 p = strchr(p0, '(');
8459 p0 = strchr(p, ')');
8464 if (size >= sizeof(s))
8467 snprintf(s, sizeof(s), "%.*s", size, p);
8468 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8469 if (ret < 0 || ret > max_num)
8471 for (i = 0; i < ret; i++) {
8473 int_fld = strtoul(str_fld[i], &end, 0);
8474 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8476 flexbytes[i] = (uint8_t)int_fld;
8482 str2flowtype(char *string)
8485 static const struct {
8488 } flowtype_str[] = {
8489 {"raw", RTE_ETH_FLOW_RAW},
8490 {"ipv4", RTE_ETH_FLOW_IPV4},
8491 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8492 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8493 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8494 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8495 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8496 {"ipv6", RTE_ETH_FLOW_IPV6},
8497 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8498 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8499 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8500 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8501 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8502 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8505 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8506 if (!strcmp(flowtype_str[i].str, string))
8507 return flowtype_str[i].type;
8509 return RTE_ETH_FLOW_UNKNOWN;
8512 static enum rte_eth_fdir_tunnel_type
8513 str2fdir_tunneltype(char *string)
8517 static const struct {
8519 enum rte_eth_fdir_tunnel_type type;
8520 } tunneltype_str[] = {
8521 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8522 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8525 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8526 if (!strcmp(tunneltype_str[i].str, string))
8527 return tunneltype_str[i].type;
8529 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8532 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8534 if ((ip_addr).family == AF_INET) \
8535 (ip) = (ip_addr).addr.ipv4.s_addr; \
8537 printf("invalid parameter.\n"); \
8542 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8544 if ((ip_addr).family == AF_INET6) \
8545 (void)rte_memcpy(&(ip), \
8546 &((ip_addr).addr.ipv6), \
8547 sizeof(struct in6_addr)); \
8549 printf("invalid parameter.\n"); \
8555 cmd_flow_director_filter_parsed(void *parsed_result,
8556 __attribute__((unused)) struct cmdline *cl,
8557 __attribute__((unused)) void *data)
8559 struct cmd_flow_director_result *res = parsed_result;
8560 struct rte_eth_fdir_filter entry;
8561 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8563 unsigned long vf_id;
8566 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8568 printf("flow director is not supported on port %u.\n",
8572 memset(flexbytes, 0, sizeof(flexbytes));
8573 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8575 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8576 if (strcmp(res->mode_value, "MAC-VLAN")) {
8577 printf("Please set mode to MAC-VLAN.\n");
8580 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8581 if (strcmp(res->mode_value, "Tunnel")) {
8582 printf("Please set mode to Tunnel.\n");
8586 if (strcmp(res->mode_value, "IP")) {
8587 printf("Please set mode to IP.\n");
8590 entry.input.flow_type = str2flowtype(res->flow_type);
8593 ret = parse_flexbytes(res->flexbytes_value,
8595 RTE_ETH_FDIR_MAX_FLEXLEN);
8597 printf("error: Cannot parse flexbytes input.\n");
8601 switch (entry.input.flow_type) {
8602 case RTE_ETH_FLOW_FRAG_IPV4:
8603 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8604 entry.input.flow.ip4_flow.proto = res->proto_value;
8605 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8606 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8607 IPV4_ADDR_TO_UINT(res->ip_dst,
8608 entry.input.flow.ip4_flow.dst_ip);
8609 IPV4_ADDR_TO_UINT(res->ip_src,
8610 entry.input.flow.ip4_flow.src_ip);
8611 entry.input.flow.ip4_flow.tos = res->tos_value;
8612 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8613 /* need convert to big endian. */
8614 entry.input.flow.udp4_flow.dst_port =
8615 rte_cpu_to_be_16(res->port_dst);
8616 entry.input.flow.udp4_flow.src_port =
8617 rte_cpu_to_be_16(res->port_src);
8619 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8620 IPV4_ADDR_TO_UINT(res->ip_dst,
8621 entry.input.flow.sctp4_flow.ip.dst_ip);
8622 IPV4_ADDR_TO_UINT(res->ip_src,
8623 entry.input.flow.sctp4_flow.ip.src_ip);
8624 entry.input.flow.ip4_flow.tos = res->tos_value;
8625 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8626 /* need convert to big endian. */
8627 entry.input.flow.sctp4_flow.dst_port =
8628 rte_cpu_to_be_16(res->port_dst);
8629 entry.input.flow.sctp4_flow.src_port =
8630 rte_cpu_to_be_16(res->port_src);
8631 entry.input.flow.sctp4_flow.verify_tag =
8632 rte_cpu_to_be_32(res->verify_tag_value);
8634 case RTE_ETH_FLOW_FRAG_IPV6:
8635 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8636 entry.input.flow.ipv6_flow.proto = res->proto_value;
8637 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8638 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8639 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8640 entry.input.flow.ipv6_flow.dst_ip);
8641 IPV6_ADDR_TO_ARRAY(res->ip_src,
8642 entry.input.flow.ipv6_flow.src_ip);
8643 entry.input.flow.ipv6_flow.tc = res->tos_value;
8644 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8645 /* need convert to big endian. */
8646 entry.input.flow.udp6_flow.dst_port =
8647 rte_cpu_to_be_16(res->port_dst);
8648 entry.input.flow.udp6_flow.src_port =
8649 rte_cpu_to_be_16(res->port_src);
8651 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8652 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8653 entry.input.flow.sctp6_flow.ip.dst_ip);
8654 IPV6_ADDR_TO_ARRAY(res->ip_src,
8655 entry.input.flow.sctp6_flow.ip.src_ip);
8656 entry.input.flow.ipv6_flow.tc = res->tos_value;
8657 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8658 /* need convert to big endian. */
8659 entry.input.flow.sctp6_flow.dst_port =
8660 rte_cpu_to_be_16(res->port_dst);
8661 entry.input.flow.sctp6_flow.src_port =
8662 rte_cpu_to_be_16(res->port_src);
8663 entry.input.flow.sctp6_flow.verify_tag =
8664 rte_cpu_to_be_32(res->verify_tag_value);
8666 case RTE_ETH_FLOW_L2_PAYLOAD:
8667 entry.input.flow.l2_flow.ether_type =
8668 rte_cpu_to_be_16(res->ether_type);
8674 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8675 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8677 sizeof(struct ether_addr));
8679 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8680 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8682 sizeof(struct ether_addr));
8683 entry.input.flow.tunnel_flow.tunnel_type =
8684 str2fdir_tunneltype(res->tunnel_type);
8685 entry.input.flow.tunnel_flow.tunnel_id =
8686 rte_cpu_to_be_32(res->tunnel_id_value);
8689 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8691 RTE_ETH_FDIR_MAX_FLEXLEN);
8693 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8695 entry.action.flex_off = 0; /*use 0 by default */
8696 if (!strcmp(res->drop, "drop"))
8697 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8699 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8701 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8702 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8703 if (!strcmp(res->pf_vf, "pf"))
8704 entry.input.flow_ext.is_vf = 0;
8705 else if (!strncmp(res->pf_vf, "vf", 2)) {
8706 struct rte_eth_dev_info dev_info;
8708 memset(&dev_info, 0, sizeof(dev_info));
8709 rte_eth_dev_info_get(res->port_id, &dev_info);
8711 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8712 if (errno != 0 || *end != '\0' ||
8713 vf_id >= dev_info.max_vfs) {
8714 printf("invalid parameter %s.\n", res->pf_vf);
8717 entry.input.flow_ext.is_vf = 1;
8718 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8720 printf("invalid parameter %s.\n", res->pf_vf);
8725 /* set to report FD ID by default */
8726 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8727 entry.action.rx_queue = res->queue_id;
8728 entry.soft_id = res->fd_id_value;
8729 if (!strcmp(res->ops, "add"))
8730 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8731 RTE_ETH_FILTER_ADD, &entry);
8732 else if (!strcmp(res->ops, "del"))
8733 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8734 RTE_ETH_FILTER_DELETE, &entry);
8736 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8737 RTE_ETH_FILTER_UPDATE, &entry);
8739 printf("flow director programming error: (%s)\n",
8743 cmdline_parse_token_string_t cmd_flow_director_filter =
8744 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8745 flow_director_filter, "flow_director_filter");
8746 cmdline_parse_token_num_t cmd_flow_director_port_id =
8747 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8749 cmdline_parse_token_string_t cmd_flow_director_ops =
8750 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8751 ops, "add#del#update");
8752 cmdline_parse_token_string_t cmd_flow_director_flow =
8753 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8755 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8756 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8757 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8758 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8759 cmdline_parse_token_string_t cmd_flow_director_ether =
8760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8762 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8763 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8764 ether_type, UINT16);
8765 cmdline_parse_token_string_t cmd_flow_director_src =
8766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8768 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8769 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8771 cmdline_parse_token_num_t cmd_flow_director_port_src =
8772 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8774 cmdline_parse_token_string_t cmd_flow_director_dst =
8775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8777 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8778 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8780 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8781 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8783 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8785 verify_tag, "verify_tag");
8786 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8787 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8788 verify_tag_value, UINT32);
8789 cmdline_parse_token_string_t cmd_flow_director_tos =
8790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8792 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8793 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8795 cmdline_parse_token_string_t cmd_flow_director_proto =
8796 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8798 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8799 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8800 proto_value, UINT8);
8801 cmdline_parse_token_string_t cmd_flow_director_ttl =
8802 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8804 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8805 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8807 cmdline_parse_token_string_t cmd_flow_director_vlan =
8808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8810 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8811 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8812 vlan_value, UINT16);
8813 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8814 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8815 flexbytes, "flexbytes");
8816 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8817 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8818 flexbytes_value, NULL);
8819 cmdline_parse_token_string_t cmd_flow_director_drop =
8820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8822 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8825 cmdline_parse_token_string_t cmd_flow_director_queue =
8826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8828 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8829 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8831 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8834 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8835 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8836 fd_id_value, UINT32);
8838 cmdline_parse_token_string_t cmd_flow_director_mode =
8839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8841 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8844 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8845 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8846 mode_value, "MAC-VLAN");
8847 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8848 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8849 mode_value, "Tunnel");
8850 cmdline_parse_token_string_t cmd_flow_director_mac =
8851 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8853 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8854 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8856 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8859 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8860 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8861 tunnel_type, "NVGRE#VxLAN");
8862 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8864 tunnel_id, "tunnel-id");
8865 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8866 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8867 tunnel_id_value, UINT32);
8869 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8870 .f = cmd_flow_director_filter_parsed,
8872 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8873 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8874 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8875 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8876 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8877 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8878 "fd_id <fd_id_value>: "
8879 "Add or delete an ip 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_dst,
8891 (void *)&cmd_flow_director_ip_dst,
8892 (void *)&cmd_flow_director_tos,
8893 (void *)&cmd_flow_director_tos_value,
8894 (void *)&cmd_flow_director_proto,
8895 (void *)&cmd_flow_director_proto_value,
8896 (void *)&cmd_flow_director_ttl,
8897 (void *)&cmd_flow_director_ttl_value,
8898 (void *)&cmd_flow_director_vlan,
8899 (void *)&cmd_flow_director_vlan_value,
8900 (void *)&cmd_flow_director_flexbytes,
8901 (void *)&cmd_flow_director_flexbytes_value,
8902 (void *)&cmd_flow_director_drop,
8903 (void *)&cmd_flow_director_pf_vf,
8904 (void *)&cmd_flow_director_queue,
8905 (void *)&cmd_flow_director_queue_id,
8906 (void *)&cmd_flow_director_fd_id,
8907 (void *)&cmd_flow_director_fd_id_value,
8912 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8913 .f = cmd_flow_director_filter_parsed,
8915 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8916 "director entry on NIC",
8918 (void *)&cmd_flow_director_filter,
8919 (void *)&cmd_flow_director_port_id,
8920 (void *)&cmd_flow_director_mode,
8921 (void *)&cmd_flow_director_mode_ip,
8922 (void *)&cmd_flow_director_ops,
8923 (void *)&cmd_flow_director_flow,
8924 (void *)&cmd_flow_director_flow_type,
8925 (void *)&cmd_flow_director_src,
8926 (void *)&cmd_flow_director_ip_src,
8927 (void *)&cmd_flow_director_port_src,
8928 (void *)&cmd_flow_director_dst,
8929 (void *)&cmd_flow_director_ip_dst,
8930 (void *)&cmd_flow_director_port_dst,
8931 (void *)&cmd_flow_director_tos,
8932 (void *)&cmd_flow_director_tos_value,
8933 (void *)&cmd_flow_director_ttl,
8934 (void *)&cmd_flow_director_ttl_value,
8935 (void *)&cmd_flow_director_vlan,
8936 (void *)&cmd_flow_director_vlan_value,
8937 (void *)&cmd_flow_director_flexbytes,
8938 (void *)&cmd_flow_director_flexbytes_value,
8939 (void *)&cmd_flow_director_drop,
8940 (void *)&cmd_flow_director_pf_vf,
8941 (void *)&cmd_flow_director_queue,
8942 (void *)&cmd_flow_director_queue_id,
8943 (void *)&cmd_flow_director_fd_id,
8944 (void *)&cmd_flow_director_fd_id_value,
8949 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8950 .f = cmd_flow_director_filter_parsed,
8952 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
8953 "director entry on NIC",
8955 (void *)&cmd_flow_director_filter,
8956 (void *)&cmd_flow_director_port_id,
8957 (void *)&cmd_flow_director_mode,
8958 (void *)&cmd_flow_director_mode_ip,
8959 (void *)&cmd_flow_director_ops,
8960 (void *)&cmd_flow_director_flow,
8961 (void *)&cmd_flow_director_flow_type,
8962 (void *)&cmd_flow_director_src,
8963 (void *)&cmd_flow_director_ip_src,
8964 (void *)&cmd_flow_director_port_dst,
8965 (void *)&cmd_flow_director_dst,
8966 (void *)&cmd_flow_director_ip_dst,
8967 (void *)&cmd_flow_director_port_dst,
8968 (void *)&cmd_flow_director_verify_tag,
8969 (void *)&cmd_flow_director_verify_tag_value,
8970 (void *)&cmd_flow_director_tos,
8971 (void *)&cmd_flow_director_tos_value,
8972 (void *)&cmd_flow_director_ttl,
8973 (void *)&cmd_flow_director_ttl_value,
8974 (void *)&cmd_flow_director_vlan,
8975 (void *)&cmd_flow_director_vlan_value,
8976 (void *)&cmd_flow_director_flexbytes,
8977 (void *)&cmd_flow_director_flexbytes_value,
8978 (void *)&cmd_flow_director_drop,
8979 (void *)&cmd_flow_director_pf_vf,
8980 (void *)&cmd_flow_director_queue,
8981 (void *)&cmd_flow_director_queue_id,
8982 (void *)&cmd_flow_director_fd_id,
8983 (void *)&cmd_flow_director_fd_id_value,
8988 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8989 .f = cmd_flow_director_filter_parsed,
8991 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
8992 "director entry on NIC",
8994 (void *)&cmd_flow_director_filter,
8995 (void *)&cmd_flow_director_port_id,
8996 (void *)&cmd_flow_director_mode,
8997 (void *)&cmd_flow_director_mode_ip,
8998 (void *)&cmd_flow_director_ops,
8999 (void *)&cmd_flow_director_flow,
9000 (void *)&cmd_flow_director_flow_type,
9001 (void *)&cmd_flow_director_ether,
9002 (void *)&cmd_flow_director_ether_type,
9003 (void *)&cmd_flow_director_flexbytes,
9004 (void *)&cmd_flow_director_flexbytes_value,
9005 (void *)&cmd_flow_director_drop,
9006 (void *)&cmd_flow_director_pf_vf,
9007 (void *)&cmd_flow_director_queue,
9008 (void *)&cmd_flow_director_queue_id,
9009 (void *)&cmd_flow_director_fd_id,
9010 (void *)&cmd_flow_director_fd_id_value,
9015 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9016 .f = cmd_flow_director_filter_parsed,
9018 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9019 "director entry on NIC",
9021 (void *)&cmd_flow_director_filter,
9022 (void *)&cmd_flow_director_port_id,
9023 (void *)&cmd_flow_director_mode,
9024 (void *)&cmd_flow_director_mode_mac_vlan,
9025 (void *)&cmd_flow_director_ops,
9026 (void *)&cmd_flow_director_mac,
9027 (void *)&cmd_flow_director_mac_addr,
9028 (void *)&cmd_flow_director_vlan,
9029 (void *)&cmd_flow_director_vlan_value,
9030 (void *)&cmd_flow_director_flexbytes,
9031 (void *)&cmd_flow_director_flexbytes_value,
9032 (void *)&cmd_flow_director_drop,
9033 (void *)&cmd_flow_director_queue,
9034 (void *)&cmd_flow_director_queue_id,
9035 (void *)&cmd_flow_director_fd_id,
9036 (void *)&cmd_flow_director_fd_id_value,
9041 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9042 .f = cmd_flow_director_filter_parsed,
9044 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9045 "director entry on NIC",
9047 (void *)&cmd_flow_director_filter,
9048 (void *)&cmd_flow_director_port_id,
9049 (void *)&cmd_flow_director_mode,
9050 (void *)&cmd_flow_director_mode_tunnel,
9051 (void *)&cmd_flow_director_ops,
9052 (void *)&cmd_flow_director_mac,
9053 (void *)&cmd_flow_director_mac_addr,
9054 (void *)&cmd_flow_director_vlan,
9055 (void *)&cmd_flow_director_vlan_value,
9056 (void *)&cmd_flow_director_tunnel,
9057 (void *)&cmd_flow_director_tunnel_type,
9058 (void *)&cmd_flow_director_tunnel_id,
9059 (void *)&cmd_flow_director_tunnel_id_value,
9060 (void *)&cmd_flow_director_flexbytes,
9061 (void *)&cmd_flow_director_flexbytes_value,
9062 (void *)&cmd_flow_director_drop,
9063 (void *)&cmd_flow_director_queue,
9064 (void *)&cmd_flow_director_queue_id,
9065 (void *)&cmd_flow_director_fd_id,
9066 (void *)&cmd_flow_director_fd_id_value,
9071 struct cmd_flush_flow_director_result {
9072 cmdline_fixed_string_t flush_flow_director;
9076 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9077 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9078 flush_flow_director, "flush_flow_director");
9079 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9080 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9084 cmd_flush_flow_director_parsed(void *parsed_result,
9085 __attribute__((unused)) struct cmdline *cl,
9086 __attribute__((unused)) void *data)
9088 struct cmd_flow_director_result *res = parsed_result;
9091 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9093 printf("flow director is not supported on port %u.\n",
9098 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9099 RTE_ETH_FILTER_FLUSH, NULL);
9101 printf("flow director table flushing error: (%s)\n",
9105 cmdline_parse_inst_t cmd_flush_flow_director = {
9106 .f = cmd_flush_flow_director_parsed,
9108 .help_str = "flush_flow_director <port_id>: "
9109 "Flush all flow director entries of a device on NIC",
9111 (void *)&cmd_flush_flow_director_flush,
9112 (void *)&cmd_flush_flow_director_port_id,
9117 /* *** deal with flow director mask *** */
9118 struct cmd_flow_director_mask_result {
9119 cmdline_fixed_string_t flow_director_mask;
9121 cmdline_fixed_string_t mode;
9122 cmdline_fixed_string_t mode_value;
9123 cmdline_fixed_string_t vlan;
9125 cmdline_fixed_string_t src_mask;
9126 cmdline_ipaddr_t ipv4_src;
9127 cmdline_ipaddr_t ipv6_src;
9129 cmdline_fixed_string_t dst_mask;
9130 cmdline_ipaddr_t ipv4_dst;
9131 cmdline_ipaddr_t ipv6_dst;
9133 cmdline_fixed_string_t mac;
9134 uint8_t mac_addr_byte_mask;
9135 cmdline_fixed_string_t tunnel_id;
9136 uint32_t tunnel_id_mask;
9137 cmdline_fixed_string_t tunnel_type;
9138 uint8_t tunnel_type_mask;
9142 cmd_flow_director_mask_parsed(void *parsed_result,
9143 __attribute__((unused)) struct cmdline *cl,
9144 __attribute__((unused)) void *data)
9146 struct cmd_flow_director_mask_result *res = parsed_result;
9147 struct rte_eth_fdir_masks *mask;
9148 struct rte_port *port;
9150 if (res->port_id > nb_ports) {
9151 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9155 port = &ports[res->port_id];
9156 /** Check if the port is not started **/
9157 if (port->port_status != RTE_PORT_STOPPED) {
9158 printf("Please stop port %d first\n", res->port_id);
9162 mask = &port->dev_conf.fdir_conf.mask;
9164 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9165 if (strcmp(res->mode_value, "MAC-VLAN")) {
9166 printf("Please set mode to MAC-VLAN.\n");
9170 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9171 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9172 if (strcmp(res->mode_value, "Tunnel")) {
9173 printf("Please set mode to Tunnel.\n");
9177 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9178 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9179 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9180 mask->tunnel_type_mask = res->tunnel_type_mask;
9182 if (strcmp(res->mode_value, "IP")) {
9183 printf("Please set mode to IP.\n");
9187 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9188 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9189 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9190 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9191 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9192 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9193 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9196 cmd_reconfig_device_queue(res->port_id, 1, 1);
9199 cmdline_parse_token_string_t cmd_flow_director_mask =
9200 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9201 flow_director_mask, "flow_director_mask");
9202 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9203 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9205 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9206 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9208 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9209 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9211 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9212 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9213 src_mask, "src_mask");
9214 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9215 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9217 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9218 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9220 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9221 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9223 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9224 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9225 dst_mask, "dst_mask");
9226 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9227 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9229 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9230 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9232 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9233 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9236 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9239 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9242 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9244 mode_value, "MAC-VLAN");
9245 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9247 mode_value, "Tunnel");
9248 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9251 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9252 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9253 mac_addr_byte_mask, UINT8);
9254 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9256 tunnel_type, "tunnel-type");
9257 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9258 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9259 tunnel_type_mask, UINT8);
9260 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9262 tunnel_id, "tunnel-id");
9263 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9264 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9265 tunnel_id_mask, UINT32);
9267 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9268 .f = cmd_flow_director_mask_parsed,
9270 .help_str = "flow_director_mask ... : "
9271 "Set IP mode flow director's mask on NIC",
9273 (void *)&cmd_flow_director_mask,
9274 (void *)&cmd_flow_director_mask_port_id,
9275 (void *)&cmd_flow_director_mask_mode,
9276 (void *)&cmd_flow_director_mask_mode_ip,
9277 (void *)&cmd_flow_director_mask_vlan,
9278 (void *)&cmd_flow_director_mask_vlan_value,
9279 (void *)&cmd_flow_director_mask_src,
9280 (void *)&cmd_flow_director_mask_ipv4_src,
9281 (void *)&cmd_flow_director_mask_ipv6_src,
9282 (void *)&cmd_flow_director_mask_port_src,
9283 (void *)&cmd_flow_director_mask_dst,
9284 (void *)&cmd_flow_director_mask_ipv4_dst,
9285 (void *)&cmd_flow_director_mask_ipv6_dst,
9286 (void *)&cmd_flow_director_mask_port_dst,
9291 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9292 .f = cmd_flow_director_mask_parsed,
9294 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9295 "flow director's mask on NIC",
9297 (void *)&cmd_flow_director_mask,
9298 (void *)&cmd_flow_director_mask_port_id,
9299 (void *)&cmd_flow_director_mask_mode,
9300 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9301 (void *)&cmd_flow_director_mask_vlan,
9302 (void *)&cmd_flow_director_mask_vlan_value,
9307 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9308 .f = cmd_flow_director_mask_parsed,
9310 .help_str = "flow_director_mask ... : Set tunnel mode "
9311 "flow director's mask on NIC",
9313 (void *)&cmd_flow_director_mask,
9314 (void *)&cmd_flow_director_mask_port_id,
9315 (void *)&cmd_flow_director_mask_mode,
9316 (void *)&cmd_flow_director_mask_mode_tunnel,
9317 (void *)&cmd_flow_director_mask_vlan,
9318 (void *)&cmd_flow_director_mask_vlan_value,
9319 (void *)&cmd_flow_director_mask_mac,
9320 (void *)&cmd_flow_director_mask_mac_value,
9321 (void *)&cmd_flow_director_mask_tunnel_type,
9322 (void *)&cmd_flow_director_mask_tunnel_type_value,
9323 (void *)&cmd_flow_director_mask_tunnel_id,
9324 (void *)&cmd_flow_director_mask_tunnel_id_value,
9329 /* *** deal with flow director mask on flexible payload *** */
9330 struct cmd_flow_director_flex_mask_result {
9331 cmdline_fixed_string_t flow_director_flexmask;
9333 cmdline_fixed_string_t flow;
9334 cmdline_fixed_string_t flow_type;
9335 cmdline_fixed_string_t mask;
9339 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9340 __attribute__((unused)) struct cmdline *cl,
9341 __attribute__((unused)) void *data)
9343 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9344 struct rte_eth_fdir_info fdir_info;
9345 struct rte_eth_fdir_flex_mask flex_mask;
9346 struct rte_port *port;
9347 uint32_t flow_type_mask;
9351 if (res->port_id > nb_ports) {
9352 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9356 port = &ports[res->port_id];
9357 /** Check if the port is not started **/
9358 if (port->port_status != RTE_PORT_STOPPED) {
9359 printf("Please stop port %d first\n", res->port_id);
9363 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9364 ret = parse_flexbytes(res->mask,
9366 RTE_ETH_FDIR_MAX_FLEXLEN);
9368 printf("error: Cannot parse mask input.\n");
9372 memset(&fdir_info, 0, sizeof(fdir_info));
9373 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9374 RTE_ETH_FILTER_INFO, &fdir_info);
9376 printf("Cannot get FDir filter info\n");
9380 if (!strcmp(res->flow_type, "none")) {
9381 /* means don't specify the flow type */
9382 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9383 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9384 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9385 0, sizeof(struct rte_eth_fdir_flex_mask));
9386 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9387 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9389 sizeof(struct rte_eth_fdir_flex_mask));
9390 cmd_reconfig_device_queue(res->port_id, 1, 1);
9393 flow_type_mask = fdir_info.flow_types_mask[0];
9394 if (!strcmp(res->flow_type, "all")) {
9395 if (!flow_type_mask) {
9396 printf("No flow type supported\n");
9399 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9400 if (flow_type_mask & (1 << i)) {
9401 flex_mask.flow_type = i;
9402 fdir_set_flex_mask(res->port_id, &flex_mask);
9405 cmd_reconfig_device_queue(res->port_id, 1, 1);
9408 flex_mask.flow_type = str2flowtype(res->flow_type);
9409 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9410 printf("Flow type %s not supported on port %d\n",
9411 res->flow_type, res->port_id);
9414 fdir_set_flex_mask(res->port_id, &flex_mask);
9415 cmd_reconfig_device_queue(res->port_id, 1, 1);
9418 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9419 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9420 flow_director_flexmask,
9421 "flow_director_flex_mask");
9422 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9423 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9425 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9426 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9428 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9430 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9431 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9432 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9436 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9437 .f = cmd_flow_director_flex_mask_parsed,
9439 .help_str = "flow_director_flex_mask ... : "
9440 "Set flow director's flex mask on NIC",
9442 (void *)&cmd_flow_director_flexmask,
9443 (void *)&cmd_flow_director_flexmask_port_id,
9444 (void *)&cmd_flow_director_flexmask_flow,
9445 (void *)&cmd_flow_director_flexmask_flow_type,
9446 (void *)&cmd_flow_director_flexmask_mask,
9451 /* *** deal with flow director flexible payload configuration *** */
9452 struct cmd_flow_director_flexpayload_result {
9453 cmdline_fixed_string_t flow_director_flexpayload;
9455 cmdline_fixed_string_t payload_layer;
9456 cmdline_fixed_string_t payload_cfg;
9460 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9463 const char *p, *p0 = q_arg;
9465 unsigned long int_fld;
9466 char *str_fld[max_num];
9471 p = strchr(p0, '(');
9475 p0 = strchr(p, ')');
9480 if (size >= sizeof(s))
9483 snprintf(s, sizeof(s), "%.*s", size, p);
9484 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9485 if (ret < 0 || ret > max_num)
9487 for (i = 0; i < ret; i++) {
9489 int_fld = strtoul(str_fld[i], &end, 0);
9490 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9492 offsets[i] = (uint16_t)int_fld;
9498 cmd_flow_director_flxpld_parsed(void *parsed_result,
9499 __attribute__((unused)) struct cmdline *cl,
9500 __attribute__((unused)) void *data)
9502 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9503 struct rte_eth_flex_payload_cfg flex_cfg;
9504 struct rte_port *port;
9507 if (res->port_id > nb_ports) {
9508 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9512 port = &ports[res->port_id];
9513 /** Check if the port is not started **/
9514 if (port->port_status != RTE_PORT_STOPPED) {
9515 printf("Please stop port %d first\n", res->port_id);
9519 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9521 if (!strcmp(res->payload_layer, "raw"))
9522 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9523 else if (!strcmp(res->payload_layer, "l2"))
9524 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9525 else if (!strcmp(res->payload_layer, "l3"))
9526 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9527 else if (!strcmp(res->payload_layer, "l4"))
9528 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9530 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9531 RTE_ETH_FDIR_MAX_FLEXLEN);
9533 printf("error: Cannot parse flex payload input.\n");
9537 fdir_set_flex_payload(res->port_id, &flex_cfg);
9538 cmd_reconfig_device_queue(res->port_id, 1, 1);
9541 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9542 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9543 flow_director_flexpayload,
9544 "flow_director_flex_payload");
9545 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9546 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9548 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9549 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9550 payload_layer, "raw#l2#l3#l4");
9551 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9555 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9556 .f = cmd_flow_director_flxpld_parsed,
9558 .help_str = "flow_director_flexpayload ... : "
9559 "Set flow director's flex payload on NIC",
9561 (void *)&cmd_flow_director_flexpayload,
9562 (void *)&cmd_flow_director_flexpayload_port_id,
9563 (void *)&cmd_flow_director_flexpayload_payload_layer,
9564 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9569 /* *** Classification Filters Control *** */
9570 /* *** Get symmetric hash enable per port *** */
9571 struct cmd_get_sym_hash_ena_per_port_result {
9572 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9577 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9578 __rte_unused struct cmdline *cl,
9579 __rte_unused void *data)
9581 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9582 struct rte_eth_hash_filter_info info;
9585 if (rte_eth_dev_filter_supported(res->port_id,
9586 RTE_ETH_FILTER_HASH) < 0) {
9587 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9592 memset(&info, 0, sizeof(info));
9593 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9594 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9595 RTE_ETH_FILTER_GET, &info);
9598 printf("Cannot get symmetric hash enable per port "
9599 "on port %u\n", res->port_id);
9603 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9604 "enabled" : "disabled", res->port_id);
9607 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9608 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9609 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9610 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9611 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9614 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9615 .f = cmd_get_sym_hash_per_port_parsed,
9617 .help_str = "get_sym_hash_ena_per_port <port_id>",
9619 (void *)&cmd_get_sym_hash_ena_per_port_all,
9620 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9625 /* *** Set symmetric hash enable per port *** */
9626 struct cmd_set_sym_hash_ena_per_port_result {
9627 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9628 cmdline_fixed_string_t enable;
9633 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9634 __rte_unused struct cmdline *cl,
9635 __rte_unused void *data)
9637 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9638 struct rte_eth_hash_filter_info info;
9641 if (rte_eth_dev_filter_supported(res->port_id,
9642 RTE_ETH_FILTER_HASH) < 0) {
9643 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9648 memset(&info, 0, sizeof(info));
9649 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9650 if (!strcmp(res->enable, "enable"))
9651 info.info.enable = 1;
9652 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9653 RTE_ETH_FILTER_SET, &info);
9655 printf("Cannot set symmetric hash enable per port on "
9656 "port %u\n", res->port_id);
9659 printf("Symmetric hash has been set to %s on port %u\n",
9660 res->enable, res->port_id);
9663 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9664 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9665 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9666 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9667 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9669 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9670 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9671 enable, "enable#disable");
9673 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9674 .f = cmd_set_sym_hash_per_port_parsed,
9676 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9678 (void *)&cmd_set_sym_hash_ena_per_port_all,
9679 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9680 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9685 /* Get global config of hash function */
9686 struct cmd_get_hash_global_config_result {
9687 cmdline_fixed_string_t get_hash_global_config;
9692 flowtype_to_str(uint16_t ftype)
9699 {"ipv4", RTE_ETH_FLOW_IPV4},
9700 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9701 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9702 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9703 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9704 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9705 {"ipv6", RTE_ETH_FLOW_IPV6},
9706 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9707 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9708 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9709 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9710 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9711 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9712 {"port", RTE_ETH_FLOW_PORT},
9713 {"vxlan", RTE_ETH_FLOW_VXLAN},
9714 {"geneve", RTE_ETH_FLOW_GENEVE},
9715 {"nvgre", RTE_ETH_FLOW_NVGRE},
9718 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9719 if (ftype_table[i].ftype == ftype)
9720 return ftype_table[i].str;
9727 cmd_get_hash_global_config_parsed(void *parsed_result,
9728 __rte_unused struct cmdline *cl,
9729 __rte_unused void *data)
9731 struct cmd_get_hash_global_config_result *res = parsed_result;
9732 struct rte_eth_hash_filter_info info;
9733 uint32_t idx, offset;
9738 if (rte_eth_dev_filter_supported(res->port_id,
9739 RTE_ETH_FILTER_HASH) < 0) {
9740 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9745 memset(&info, 0, sizeof(info));
9746 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9747 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9748 RTE_ETH_FILTER_GET, &info);
9750 printf("Cannot get hash global configurations by port %d\n",
9755 switch (info.info.global_conf.hash_func) {
9756 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9757 printf("Hash function is Toeplitz\n");
9759 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9760 printf("Hash function is Simple XOR\n");
9763 printf("Unknown hash function\n");
9767 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9768 idx = i / UINT32_BIT;
9769 offset = i % UINT32_BIT;
9770 if (!(info.info.global_conf.valid_bit_mask[idx] &
9773 str = flowtype_to_str(i);
9776 printf("Symmetric hash is %s globally for flow type %s "
9778 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9779 (1UL << offset)) ? "enabled" : "disabled"), str,
9784 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9785 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9786 get_hash_global_config, "get_hash_global_config");
9787 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9788 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9791 cmdline_parse_inst_t cmd_get_hash_global_config = {
9792 .f = cmd_get_hash_global_config_parsed,
9794 .help_str = "get_hash_global_config <port_id>",
9796 (void *)&cmd_get_hash_global_config_all,
9797 (void *)&cmd_get_hash_global_config_port_id,
9802 /* Set global config of hash function */
9803 struct cmd_set_hash_global_config_result {
9804 cmdline_fixed_string_t set_hash_global_config;
9806 cmdline_fixed_string_t hash_func;
9807 cmdline_fixed_string_t flow_type;
9808 cmdline_fixed_string_t enable;
9812 cmd_set_hash_global_config_parsed(void *parsed_result,
9813 __rte_unused struct cmdline *cl,
9814 __rte_unused void *data)
9816 struct cmd_set_hash_global_config_result *res = parsed_result;
9817 struct rte_eth_hash_filter_info info;
9818 uint32_t ftype, idx, offset;
9821 if (rte_eth_dev_filter_supported(res->port_id,
9822 RTE_ETH_FILTER_HASH) < 0) {
9823 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9827 memset(&info, 0, sizeof(info));
9828 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9829 if (!strcmp(res->hash_func, "toeplitz"))
9830 info.info.global_conf.hash_func =
9831 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9832 else if (!strcmp(res->hash_func, "simple_xor"))
9833 info.info.global_conf.hash_func =
9834 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9835 else if (!strcmp(res->hash_func, "default"))
9836 info.info.global_conf.hash_func =
9837 RTE_ETH_HASH_FUNCTION_DEFAULT;
9839 ftype = str2flowtype(res->flow_type);
9840 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9841 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9842 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9843 if (!strcmp(res->enable, "enable"))
9844 info.info.global_conf.sym_hash_enable_mask[idx] |=
9846 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9847 RTE_ETH_FILTER_SET, &info);
9849 printf("Cannot set global hash configurations by port %d\n",
9852 printf("Global hash configurations have been set "
9853 "succcessfully by port %d\n", res->port_id);
9856 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9857 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9858 set_hash_global_config, "set_hash_global_config");
9859 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9860 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9862 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9863 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9864 hash_func, "toeplitz#simple_xor#default");
9865 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9866 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9868 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9869 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9870 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9871 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9872 enable, "enable#disable");
9874 cmdline_parse_inst_t cmd_set_hash_global_config = {
9875 .f = cmd_set_hash_global_config_parsed,
9877 .help_str = "set_hash_global_config <port_id> "
9878 "toeplitz|simple_xor|default "
9879 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9880 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9881 "l2_payload enable|disable",
9883 (void *)&cmd_set_hash_global_config_all,
9884 (void *)&cmd_set_hash_global_config_port_id,
9885 (void *)&cmd_set_hash_global_config_hash_func,
9886 (void *)&cmd_set_hash_global_config_flow_type,
9887 (void *)&cmd_set_hash_global_config_enable,
9892 /* Set hash input set */
9893 struct cmd_set_hash_input_set_result {
9894 cmdline_fixed_string_t set_hash_input_set;
9896 cmdline_fixed_string_t flow_type;
9897 cmdline_fixed_string_t inset_field;
9898 cmdline_fixed_string_t select;
9901 static enum rte_eth_input_set_field
9902 str2inset(char *string)
9906 static const struct {
9908 enum rte_eth_input_set_field inset;
9910 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9911 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9912 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9913 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9914 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9915 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9916 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9917 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9918 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9919 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9920 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9921 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9922 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9923 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9924 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9925 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9926 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9927 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9928 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9929 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9930 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9931 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9932 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9933 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9934 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9935 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9936 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9937 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9938 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9939 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9940 {"none", RTE_ETH_INPUT_SET_NONE},
9943 for (i = 0; i < RTE_DIM(inset_table); i++) {
9944 if (!strcmp(string, inset_table[i].str))
9945 return inset_table[i].inset;
9948 return RTE_ETH_INPUT_SET_UNKNOWN;
9952 cmd_set_hash_input_set_parsed(void *parsed_result,
9953 __rte_unused struct cmdline *cl,
9954 __rte_unused void *data)
9956 struct cmd_set_hash_input_set_result *res = parsed_result;
9957 struct rte_eth_hash_filter_info info;
9959 memset(&info, 0, sizeof(info));
9960 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9961 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9962 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9963 info.info.input_set_conf.inset_size = 1;
9964 if (!strcmp(res->select, "select"))
9965 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9966 else if (!strcmp(res->select, "add"))
9967 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9968 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9969 RTE_ETH_FILTER_SET, &info);
9972 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9973 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9974 set_hash_input_set, "set_hash_input_set");
9975 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9976 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9978 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9979 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9981 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9982 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9983 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9984 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9986 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9987 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9988 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9989 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9990 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9992 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9993 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9994 select, "select#add");
9996 cmdline_parse_inst_t cmd_set_hash_input_set = {
9997 .f = cmd_set_hash_input_set_parsed,
9999 .help_str = "set_hash_input_set <port_id> "
10000 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10001 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10002 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10003 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10004 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10005 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10006 "fld-7th|fld-8th|none select|add",
10008 (void *)&cmd_set_hash_input_set_cmd,
10009 (void *)&cmd_set_hash_input_set_port_id,
10010 (void *)&cmd_set_hash_input_set_flow_type,
10011 (void *)&cmd_set_hash_input_set_field,
10012 (void *)&cmd_set_hash_input_set_select,
10017 /* Set flow director input set */
10018 struct cmd_set_fdir_input_set_result {
10019 cmdline_fixed_string_t set_fdir_input_set;
10021 cmdline_fixed_string_t flow_type;
10022 cmdline_fixed_string_t inset_field;
10023 cmdline_fixed_string_t select;
10027 cmd_set_fdir_input_set_parsed(void *parsed_result,
10028 __rte_unused struct cmdline *cl,
10029 __rte_unused void *data)
10031 struct cmd_set_fdir_input_set_result *res = parsed_result;
10032 struct rte_eth_fdir_filter_info info;
10034 memset(&info, 0, sizeof(info));
10035 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10036 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10037 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10038 info.info.input_set_conf.inset_size = 1;
10039 if (!strcmp(res->select, "select"))
10040 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10041 else if (!strcmp(res->select, "add"))
10042 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10043 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10044 RTE_ETH_FILTER_SET, &info);
10047 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10048 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10049 set_fdir_input_set, "set_fdir_input_set");
10050 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10051 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10053 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10054 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10056 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10057 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10058 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10059 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10061 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10062 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10063 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10064 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10065 "sctp-veri-tag#none");
10066 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10067 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10068 select, "select#add");
10070 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10071 .f = cmd_set_fdir_input_set_parsed,
10073 .help_str = "set_fdir_input_set <port_id> "
10074 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10075 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10076 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10077 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10078 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10079 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10080 "sctp-veri-tag|none select|add",
10082 (void *)&cmd_set_fdir_input_set_cmd,
10083 (void *)&cmd_set_fdir_input_set_port_id,
10084 (void *)&cmd_set_fdir_input_set_flow_type,
10085 (void *)&cmd_set_fdir_input_set_field,
10086 (void *)&cmd_set_fdir_input_set_select,
10091 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10092 struct cmd_mcast_addr_result {
10093 cmdline_fixed_string_t mcast_addr_cmd;
10094 cmdline_fixed_string_t what;
10096 struct ether_addr mc_addr;
10099 static void cmd_mcast_addr_parsed(void *parsed_result,
10100 __attribute__((unused)) struct cmdline *cl,
10101 __attribute__((unused)) void *data)
10103 struct cmd_mcast_addr_result *res = parsed_result;
10105 if (!is_multicast_ether_addr(&res->mc_addr)) {
10106 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10107 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10108 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10109 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10112 if (strcmp(res->what, "add") == 0)
10113 mcast_addr_add(res->port_num, &res->mc_addr);
10115 mcast_addr_remove(res->port_num, &res->mc_addr);
10118 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10119 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10120 mcast_addr_cmd, "mcast_addr");
10121 cmdline_parse_token_string_t cmd_mcast_addr_what =
10122 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10124 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10125 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10126 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10127 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10129 cmdline_parse_inst_t cmd_mcast_addr = {
10130 .f = cmd_mcast_addr_parsed,
10132 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10133 "Add/Remove multicast MAC address on port_id",
10135 (void *)&cmd_mcast_addr_cmd,
10136 (void *)&cmd_mcast_addr_what,
10137 (void *)&cmd_mcast_addr_portnum,
10138 (void *)&cmd_mcast_addr_addr,
10143 /* l2 tunnel config
10144 * only support E-tag now.
10147 /* Ether type config */
10148 struct cmd_config_l2_tunnel_eth_type_result {
10149 cmdline_fixed_string_t port;
10150 cmdline_fixed_string_t config;
10151 cmdline_fixed_string_t all;
10153 cmdline_fixed_string_t l2_tunnel;
10154 cmdline_fixed_string_t l2_tunnel_type;
10155 cmdline_fixed_string_t eth_type;
10156 uint16_t eth_type_val;
10159 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10160 TOKEN_STRING_INITIALIZER
10161 (struct cmd_config_l2_tunnel_eth_type_result,
10163 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10164 TOKEN_STRING_INITIALIZER
10165 (struct cmd_config_l2_tunnel_eth_type_result,
10167 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10168 TOKEN_STRING_INITIALIZER
10169 (struct cmd_config_l2_tunnel_eth_type_result,
10171 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10172 TOKEN_NUM_INITIALIZER
10173 (struct cmd_config_l2_tunnel_eth_type_result,
10175 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10176 TOKEN_STRING_INITIALIZER
10177 (struct cmd_config_l2_tunnel_eth_type_result,
10178 l2_tunnel, "l2-tunnel");
10179 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10180 TOKEN_STRING_INITIALIZER
10181 (struct cmd_config_l2_tunnel_eth_type_result,
10182 l2_tunnel_type, "E-tag");
10183 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10184 TOKEN_STRING_INITIALIZER
10185 (struct cmd_config_l2_tunnel_eth_type_result,
10186 eth_type, "ether-type");
10187 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10188 TOKEN_NUM_INITIALIZER
10189 (struct cmd_config_l2_tunnel_eth_type_result,
10190 eth_type_val, UINT16);
10192 static enum rte_eth_tunnel_type
10193 str2fdir_l2_tunnel_type(char *string)
10197 static const struct {
10199 enum rte_eth_tunnel_type type;
10200 } l2_tunnel_type_str[] = {
10201 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10204 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10205 if (!strcmp(l2_tunnel_type_str[i].str, string))
10206 return l2_tunnel_type_str[i].type;
10208 return RTE_TUNNEL_TYPE_NONE;
10211 /* ether type config for all ports */
10213 cmd_config_l2_tunnel_eth_type_all_parsed
10214 (void *parsed_result,
10215 __attribute__((unused)) struct cmdline *cl,
10216 __attribute__((unused)) void *data)
10218 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10219 struct rte_eth_l2_tunnel_conf entry;
10222 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10223 entry.ether_type = res->eth_type_val;
10225 FOREACH_PORT(pid, ports) {
10226 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10230 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10231 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10233 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10235 (void *)&cmd_config_l2_tunnel_eth_type_port,
10236 (void *)&cmd_config_l2_tunnel_eth_type_config,
10237 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10238 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10239 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10240 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10241 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10246 /* ether type config for a specific port */
10248 cmd_config_l2_tunnel_eth_type_specific_parsed(
10249 void *parsed_result,
10250 __attribute__((unused)) struct cmdline *cl,
10251 __attribute__((unused)) void *data)
10253 struct cmd_config_l2_tunnel_eth_type_result *res =
10255 struct rte_eth_l2_tunnel_conf entry;
10257 if (port_id_is_invalid(res->id, ENABLED_WARN))
10260 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10261 entry.ether_type = res->eth_type_val;
10263 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10266 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10267 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10269 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10271 (void *)&cmd_config_l2_tunnel_eth_type_port,
10272 (void *)&cmd_config_l2_tunnel_eth_type_config,
10273 (void *)&cmd_config_l2_tunnel_eth_type_id,
10274 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10275 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10276 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10277 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10282 /* Enable/disable l2 tunnel */
10283 struct cmd_config_l2_tunnel_en_dis_result {
10284 cmdline_fixed_string_t port;
10285 cmdline_fixed_string_t config;
10286 cmdline_fixed_string_t all;
10288 cmdline_fixed_string_t l2_tunnel;
10289 cmdline_fixed_string_t l2_tunnel_type;
10290 cmdline_fixed_string_t en_dis;
10293 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10294 TOKEN_STRING_INITIALIZER
10295 (struct cmd_config_l2_tunnel_en_dis_result,
10297 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10298 TOKEN_STRING_INITIALIZER
10299 (struct cmd_config_l2_tunnel_en_dis_result,
10301 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10302 TOKEN_STRING_INITIALIZER
10303 (struct cmd_config_l2_tunnel_en_dis_result,
10305 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10306 TOKEN_NUM_INITIALIZER
10307 (struct cmd_config_l2_tunnel_en_dis_result,
10309 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10310 TOKEN_STRING_INITIALIZER
10311 (struct cmd_config_l2_tunnel_en_dis_result,
10312 l2_tunnel, "l2-tunnel");
10313 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10314 TOKEN_STRING_INITIALIZER
10315 (struct cmd_config_l2_tunnel_en_dis_result,
10316 l2_tunnel_type, "E-tag");
10317 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10318 TOKEN_STRING_INITIALIZER
10319 (struct cmd_config_l2_tunnel_en_dis_result,
10320 en_dis, "enable#disable");
10322 /* enable/disable l2 tunnel for all ports */
10324 cmd_config_l2_tunnel_en_dis_all_parsed(
10325 void *parsed_result,
10326 __attribute__((unused)) struct cmdline *cl,
10327 __attribute__((unused)) void *data)
10329 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10330 struct rte_eth_l2_tunnel_conf entry;
10334 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10336 if (!strcmp("enable", res->en_dis))
10341 FOREACH_PORT(pid, ports) {
10342 rte_eth_dev_l2_tunnel_offload_set(pid,
10344 ETH_L2_TUNNEL_ENABLE_MASK,
10349 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10350 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10352 .help_str = "port config all l2-tunnel E-tag enable|disable",
10354 (void *)&cmd_config_l2_tunnel_en_dis_port,
10355 (void *)&cmd_config_l2_tunnel_en_dis_config,
10356 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10357 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10358 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10359 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10364 /* enable/disable l2 tunnel for a port */
10366 cmd_config_l2_tunnel_en_dis_specific_parsed(
10367 void *parsed_result,
10368 __attribute__((unused)) struct cmdline *cl,
10369 __attribute__((unused)) void *data)
10371 struct cmd_config_l2_tunnel_en_dis_result *res =
10373 struct rte_eth_l2_tunnel_conf entry;
10375 if (port_id_is_invalid(res->id, ENABLED_WARN))
10378 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10380 if (!strcmp("enable", res->en_dis))
10381 rte_eth_dev_l2_tunnel_offload_set(res->id,
10383 ETH_L2_TUNNEL_ENABLE_MASK,
10386 rte_eth_dev_l2_tunnel_offload_set(res->id,
10388 ETH_L2_TUNNEL_ENABLE_MASK,
10392 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10393 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10395 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10397 (void *)&cmd_config_l2_tunnel_en_dis_port,
10398 (void *)&cmd_config_l2_tunnel_en_dis_config,
10399 (void *)&cmd_config_l2_tunnel_en_dis_id,
10400 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10401 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10402 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10407 /* E-tag configuration */
10409 /* Common result structure for all E-tag configuration */
10410 struct cmd_config_e_tag_result {
10411 cmdline_fixed_string_t e_tag;
10412 cmdline_fixed_string_t set;
10413 cmdline_fixed_string_t insertion;
10414 cmdline_fixed_string_t stripping;
10415 cmdline_fixed_string_t forwarding;
10416 cmdline_fixed_string_t filter;
10417 cmdline_fixed_string_t add;
10418 cmdline_fixed_string_t del;
10419 cmdline_fixed_string_t on;
10420 cmdline_fixed_string_t off;
10421 cmdline_fixed_string_t on_off;
10422 cmdline_fixed_string_t port_tag_id;
10423 uint32_t port_tag_id_val;
10424 cmdline_fixed_string_t e_tag_id;
10425 uint16_t e_tag_id_val;
10426 cmdline_fixed_string_t dst_pool;
10427 uint8_t dst_pool_val;
10428 cmdline_fixed_string_t port;
10430 cmdline_fixed_string_t vf;
10434 /* Common CLI fields for all E-tag configuration */
10435 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10436 TOKEN_STRING_INITIALIZER
10437 (struct cmd_config_e_tag_result,
10439 cmdline_parse_token_string_t cmd_config_e_tag_set =
10440 TOKEN_STRING_INITIALIZER
10441 (struct cmd_config_e_tag_result,
10443 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10444 TOKEN_STRING_INITIALIZER
10445 (struct cmd_config_e_tag_result,
10446 insertion, "insertion");
10447 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10448 TOKEN_STRING_INITIALIZER
10449 (struct cmd_config_e_tag_result,
10450 stripping, "stripping");
10451 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10452 TOKEN_STRING_INITIALIZER
10453 (struct cmd_config_e_tag_result,
10454 forwarding, "forwarding");
10455 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10456 TOKEN_STRING_INITIALIZER
10457 (struct cmd_config_e_tag_result,
10459 cmdline_parse_token_string_t cmd_config_e_tag_add =
10460 TOKEN_STRING_INITIALIZER
10461 (struct cmd_config_e_tag_result,
10463 cmdline_parse_token_string_t cmd_config_e_tag_del =
10464 TOKEN_STRING_INITIALIZER
10465 (struct cmd_config_e_tag_result,
10467 cmdline_parse_token_string_t cmd_config_e_tag_on =
10468 TOKEN_STRING_INITIALIZER
10469 (struct cmd_config_e_tag_result,
10471 cmdline_parse_token_string_t cmd_config_e_tag_off =
10472 TOKEN_STRING_INITIALIZER
10473 (struct cmd_config_e_tag_result,
10475 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10476 TOKEN_STRING_INITIALIZER
10477 (struct cmd_config_e_tag_result,
10479 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10480 TOKEN_STRING_INITIALIZER
10481 (struct cmd_config_e_tag_result,
10482 port_tag_id, "port-tag-id");
10483 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10484 TOKEN_NUM_INITIALIZER
10485 (struct cmd_config_e_tag_result,
10486 port_tag_id_val, UINT32);
10487 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10488 TOKEN_STRING_INITIALIZER
10489 (struct cmd_config_e_tag_result,
10490 e_tag_id, "e-tag-id");
10491 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10492 TOKEN_NUM_INITIALIZER
10493 (struct cmd_config_e_tag_result,
10494 e_tag_id_val, UINT16);
10495 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10496 TOKEN_STRING_INITIALIZER
10497 (struct cmd_config_e_tag_result,
10498 dst_pool, "dst-pool");
10499 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10500 TOKEN_NUM_INITIALIZER
10501 (struct cmd_config_e_tag_result,
10502 dst_pool_val, UINT8);
10503 cmdline_parse_token_string_t cmd_config_e_tag_port =
10504 TOKEN_STRING_INITIALIZER
10505 (struct cmd_config_e_tag_result,
10507 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10508 TOKEN_NUM_INITIALIZER
10509 (struct cmd_config_e_tag_result,
10511 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10512 TOKEN_STRING_INITIALIZER
10513 (struct cmd_config_e_tag_result,
10515 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10516 TOKEN_NUM_INITIALIZER
10517 (struct cmd_config_e_tag_result,
10520 /* E-tag insertion configuration */
10522 cmd_config_e_tag_insertion_en_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;
10535 entry.tunnel_id = res->port_tag_id_val;
10536 entry.vf_id = res->vf_id;
10537 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10539 ETH_L2_TUNNEL_INSERTION_MASK,
10544 cmd_config_e_tag_insertion_dis_parsed(
10545 void *parsed_result,
10546 __attribute__((unused)) struct cmdline *cl,
10547 __attribute__((unused)) void *data)
10549 struct cmd_config_e_tag_result *res =
10551 struct rte_eth_l2_tunnel_conf entry;
10553 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10556 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10557 entry.vf_id = res->vf_id;
10559 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10561 ETH_L2_TUNNEL_INSERTION_MASK,
10565 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10566 .f = cmd_config_e_tag_insertion_en_parsed,
10568 .help_str = "E-tag ... : E-tag insertion enable",
10570 (void *)&cmd_config_e_tag_e_tag,
10571 (void *)&cmd_config_e_tag_set,
10572 (void *)&cmd_config_e_tag_insertion,
10573 (void *)&cmd_config_e_tag_on,
10574 (void *)&cmd_config_e_tag_port_tag_id,
10575 (void *)&cmd_config_e_tag_port_tag_id_val,
10576 (void *)&cmd_config_e_tag_port,
10577 (void *)&cmd_config_e_tag_port_id,
10578 (void *)&cmd_config_e_tag_vf,
10579 (void *)&cmd_config_e_tag_vf_id,
10584 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10585 .f = cmd_config_e_tag_insertion_dis_parsed,
10587 .help_str = "E-tag ... : E-tag insertion disable",
10589 (void *)&cmd_config_e_tag_e_tag,
10590 (void *)&cmd_config_e_tag_set,
10591 (void *)&cmd_config_e_tag_insertion,
10592 (void *)&cmd_config_e_tag_off,
10593 (void *)&cmd_config_e_tag_port,
10594 (void *)&cmd_config_e_tag_port_id,
10595 (void *)&cmd_config_e_tag_vf,
10596 (void *)&cmd_config_e_tag_vf_id,
10601 /* E-tag stripping configuration */
10603 cmd_config_e_tag_stripping_parsed(
10604 void *parsed_result,
10605 __attribute__((unused)) struct cmdline *cl,
10606 __attribute__((unused)) void *data)
10608 struct cmd_config_e_tag_result *res =
10610 struct rte_eth_l2_tunnel_conf entry;
10612 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10615 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10617 if (!strcmp(res->on_off, "on"))
10618 rte_eth_dev_l2_tunnel_offload_set
10621 ETH_L2_TUNNEL_STRIPPING_MASK,
10624 rte_eth_dev_l2_tunnel_offload_set
10627 ETH_L2_TUNNEL_STRIPPING_MASK,
10631 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10632 .f = cmd_config_e_tag_stripping_parsed,
10634 .help_str = "E-tag ... : E-tag stripping enable/disable",
10636 (void *)&cmd_config_e_tag_e_tag,
10637 (void *)&cmd_config_e_tag_set,
10638 (void *)&cmd_config_e_tag_stripping,
10639 (void *)&cmd_config_e_tag_on_off,
10640 (void *)&cmd_config_e_tag_port,
10641 (void *)&cmd_config_e_tag_port_id,
10646 /* E-tag forwarding configuration */
10648 cmd_config_e_tag_forwarding_parsed(
10649 void *parsed_result,
10650 __attribute__((unused)) struct cmdline *cl,
10651 __attribute__((unused)) void *data)
10653 struct cmd_config_e_tag_result *res = parsed_result;
10654 struct rte_eth_l2_tunnel_conf entry;
10656 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10659 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10661 if (!strcmp(res->on_off, "on"))
10662 rte_eth_dev_l2_tunnel_offload_set
10665 ETH_L2_TUNNEL_FORWARDING_MASK,
10668 rte_eth_dev_l2_tunnel_offload_set
10671 ETH_L2_TUNNEL_FORWARDING_MASK,
10675 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10676 .f = cmd_config_e_tag_forwarding_parsed,
10678 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10680 (void *)&cmd_config_e_tag_e_tag,
10681 (void *)&cmd_config_e_tag_set,
10682 (void *)&cmd_config_e_tag_forwarding,
10683 (void *)&cmd_config_e_tag_on_off,
10684 (void *)&cmd_config_e_tag_port,
10685 (void *)&cmd_config_e_tag_port_id,
10690 /* E-tag filter configuration */
10692 cmd_config_e_tag_filter_add_parsed(
10693 void *parsed_result,
10694 __attribute__((unused)) struct cmdline *cl,
10695 __attribute__((unused)) void *data)
10697 struct cmd_config_e_tag_result *res = parsed_result;
10698 struct rte_eth_l2_tunnel_conf entry;
10701 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10704 if (res->e_tag_id_val > 0x3fff) {
10705 printf("e-tag-id must be equal or less than 0x3fff.\n");
10709 ret = rte_eth_dev_filter_supported(res->port_id,
10710 RTE_ETH_FILTER_L2_TUNNEL);
10712 printf("E-tag filter is not supported on port %u.\n",
10717 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10718 entry.tunnel_id = res->e_tag_id_val;
10719 entry.pool = res->dst_pool_val;
10721 ret = rte_eth_dev_filter_ctrl(res->port_id,
10722 RTE_ETH_FILTER_L2_TUNNEL,
10723 RTE_ETH_FILTER_ADD,
10726 printf("E-tag filter programming error: (%s)\n",
10730 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10731 .f = cmd_config_e_tag_filter_add_parsed,
10733 .help_str = "E-tag ... : E-tag filter add",
10735 (void *)&cmd_config_e_tag_e_tag,
10736 (void *)&cmd_config_e_tag_set,
10737 (void *)&cmd_config_e_tag_filter,
10738 (void *)&cmd_config_e_tag_add,
10739 (void *)&cmd_config_e_tag_e_tag_id,
10740 (void *)&cmd_config_e_tag_e_tag_id_val,
10741 (void *)&cmd_config_e_tag_dst_pool,
10742 (void *)&cmd_config_e_tag_dst_pool_val,
10743 (void *)&cmd_config_e_tag_port,
10744 (void *)&cmd_config_e_tag_port_id,
10750 cmd_config_e_tag_filter_del_parsed(
10751 void *parsed_result,
10752 __attribute__((unused)) struct cmdline *cl,
10753 __attribute__((unused)) void *data)
10755 struct cmd_config_e_tag_result *res = parsed_result;
10756 struct rte_eth_l2_tunnel_conf entry;
10759 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10762 if (res->e_tag_id_val > 0x3fff) {
10763 printf("e-tag-id must be less than 0x3fff.\n");
10767 ret = rte_eth_dev_filter_supported(res->port_id,
10768 RTE_ETH_FILTER_L2_TUNNEL);
10770 printf("E-tag filter is not supported on port %u.\n",
10775 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10776 entry.tunnel_id = res->e_tag_id_val;
10778 ret = rte_eth_dev_filter_ctrl(res->port_id,
10779 RTE_ETH_FILTER_L2_TUNNEL,
10780 RTE_ETH_FILTER_DELETE,
10783 printf("E-tag filter programming error: (%s)\n",
10787 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10788 .f = cmd_config_e_tag_filter_del_parsed,
10790 .help_str = "E-tag ... : E-tag filter delete",
10792 (void *)&cmd_config_e_tag_e_tag,
10793 (void *)&cmd_config_e_tag_set,
10794 (void *)&cmd_config_e_tag_filter,
10795 (void *)&cmd_config_e_tag_del,
10796 (void *)&cmd_config_e_tag_e_tag_id,
10797 (void *)&cmd_config_e_tag_e_tag_id_val,
10798 (void *)&cmd_config_e_tag_port,
10799 (void *)&cmd_config_e_tag_port_id,
10803 #ifdef RTE_LIBRTE_IXGBE_PMD
10805 /* vf vlan anti spoof configuration */
10807 /* Common result structure for vf vlan anti spoof */
10808 struct cmd_vf_vlan_anti_spoof_result {
10809 cmdline_fixed_string_t set;
10810 cmdline_fixed_string_t vf;
10811 cmdline_fixed_string_t vlan;
10812 cmdline_fixed_string_t antispoof;
10815 cmdline_fixed_string_t on_off;
10818 /* Common CLI fields for vf vlan anti spoof enable disable */
10819 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10820 TOKEN_STRING_INITIALIZER
10821 (struct cmd_vf_vlan_anti_spoof_result,
10823 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10824 TOKEN_STRING_INITIALIZER
10825 (struct cmd_vf_vlan_anti_spoof_result,
10827 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10828 TOKEN_STRING_INITIALIZER
10829 (struct cmd_vf_vlan_anti_spoof_result,
10831 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10832 TOKEN_STRING_INITIALIZER
10833 (struct cmd_vf_vlan_anti_spoof_result,
10834 antispoof, "antispoof");
10835 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10836 TOKEN_NUM_INITIALIZER
10837 (struct cmd_vf_vlan_anti_spoof_result,
10839 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10840 TOKEN_NUM_INITIALIZER
10841 (struct cmd_vf_vlan_anti_spoof_result,
10843 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10844 TOKEN_STRING_INITIALIZER
10845 (struct cmd_vf_vlan_anti_spoof_result,
10849 cmd_set_vf_vlan_anti_spoof_parsed(
10850 void *parsed_result,
10851 __attribute__((unused)) struct cmdline *cl,
10852 __attribute__((unused)) void *data)
10854 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10856 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10858 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id,
10864 printf("invalid vf_id %d\n", res->vf_id);
10867 printf("invalid port_id %d\n", res->port_id);
10870 printf("programming error: (%s)\n", strerror(-ret));
10874 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10875 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10877 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10879 (void *)&cmd_vf_vlan_anti_spoof_set,
10880 (void *)&cmd_vf_vlan_anti_spoof_vf,
10881 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10882 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10883 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10884 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10885 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10890 /* vf mac anti spoof configuration */
10892 /* Common result structure for vf mac anti spoof */
10893 struct cmd_vf_mac_anti_spoof_result {
10894 cmdline_fixed_string_t set;
10895 cmdline_fixed_string_t vf;
10896 cmdline_fixed_string_t mac;
10897 cmdline_fixed_string_t antispoof;
10900 cmdline_fixed_string_t on_off;
10903 /* Common CLI fields for vf mac anti spoof enable disable */
10904 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10905 TOKEN_STRING_INITIALIZER
10906 (struct cmd_vf_mac_anti_spoof_result,
10908 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10909 TOKEN_STRING_INITIALIZER
10910 (struct cmd_vf_mac_anti_spoof_result,
10912 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10913 TOKEN_STRING_INITIALIZER
10914 (struct cmd_vf_mac_anti_spoof_result,
10916 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10917 TOKEN_STRING_INITIALIZER
10918 (struct cmd_vf_mac_anti_spoof_result,
10919 antispoof, "antispoof");
10920 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10921 TOKEN_NUM_INITIALIZER
10922 (struct cmd_vf_mac_anti_spoof_result,
10924 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10925 TOKEN_NUM_INITIALIZER
10926 (struct cmd_vf_mac_anti_spoof_result,
10928 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10929 TOKEN_STRING_INITIALIZER
10930 (struct cmd_vf_mac_anti_spoof_result,
10934 cmd_set_vf_mac_anti_spoof_parsed(
10935 void *parsed_result,
10936 __attribute__((unused)) struct cmdline *cl,
10937 __attribute__((unused)) void *data)
10939 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10941 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10943 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id,
10949 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10952 printf("invalid port_id %d\n", res->port_id);
10955 printf("programming error: (%s)\n", strerror(-ret));
10959 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10960 .f = cmd_set_vf_mac_anti_spoof_parsed,
10962 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10964 (void *)&cmd_vf_mac_anti_spoof_set,
10965 (void *)&cmd_vf_mac_anti_spoof_vf,
10966 (void *)&cmd_vf_mac_anti_spoof_mac,
10967 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10968 (void *)&cmd_vf_mac_anti_spoof_port_id,
10969 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10970 (void *)&cmd_vf_mac_anti_spoof_on_off,
10975 /* vf vlan strip queue configuration */
10977 /* Common result structure for vf mac anti spoof */
10978 struct cmd_vf_vlan_stripq_result {
10979 cmdline_fixed_string_t set;
10980 cmdline_fixed_string_t vf;
10981 cmdline_fixed_string_t vlan;
10982 cmdline_fixed_string_t stripq;
10985 cmdline_fixed_string_t on_off;
10988 /* Common CLI fields for vf vlan strip enable disable */
10989 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10990 TOKEN_STRING_INITIALIZER
10991 (struct cmd_vf_vlan_stripq_result,
10993 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10994 TOKEN_STRING_INITIALIZER
10995 (struct cmd_vf_vlan_stripq_result,
10997 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10998 TOKEN_STRING_INITIALIZER
10999 (struct cmd_vf_vlan_stripq_result,
11001 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11002 TOKEN_STRING_INITIALIZER
11003 (struct cmd_vf_vlan_stripq_result,
11005 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11006 TOKEN_NUM_INITIALIZER
11007 (struct cmd_vf_vlan_stripq_result,
11009 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11010 TOKEN_NUM_INITIALIZER
11011 (struct cmd_vf_vlan_stripq_result,
11013 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11014 TOKEN_STRING_INITIALIZER
11015 (struct cmd_vf_vlan_stripq_result,
11019 cmd_set_vf_vlan_stripq_parsed(
11020 void *parsed_result,
11021 __attribute__((unused)) struct cmdline *cl,
11022 __attribute__((unused)) void *data)
11024 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11026 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11028 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
11033 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11036 printf("invalid port_id %d\n", res->port_id);
11039 printf("programming error: (%s)\n", strerror(-ret));
11043 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11044 .f = cmd_set_vf_vlan_stripq_parsed,
11046 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11048 (void *)&cmd_vf_vlan_stripq_set,
11049 (void *)&cmd_vf_vlan_stripq_vf,
11050 (void *)&cmd_vf_vlan_stripq_vlan,
11051 (void *)&cmd_vf_vlan_stripq_stripq,
11052 (void *)&cmd_vf_vlan_stripq_port_id,
11053 (void *)&cmd_vf_vlan_stripq_vf_id,
11054 (void *)&cmd_vf_vlan_stripq_on_off,
11059 /* vf vlan insert configuration */
11061 /* Common result structure for vf vlan insert */
11062 struct cmd_vf_vlan_insert_result {
11063 cmdline_fixed_string_t set;
11064 cmdline_fixed_string_t vf;
11065 cmdline_fixed_string_t vlan;
11066 cmdline_fixed_string_t insert;
11072 /* Common CLI fields for vf vlan insert enable disable */
11073 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11074 TOKEN_STRING_INITIALIZER
11075 (struct cmd_vf_vlan_insert_result,
11077 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11078 TOKEN_STRING_INITIALIZER
11079 (struct cmd_vf_vlan_insert_result,
11081 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11082 TOKEN_STRING_INITIALIZER
11083 (struct cmd_vf_vlan_insert_result,
11085 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11086 TOKEN_STRING_INITIALIZER
11087 (struct cmd_vf_vlan_insert_result,
11089 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11090 TOKEN_NUM_INITIALIZER
11091 (struct cmd_vf_vlan_insert_result,
11093 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11094 TOKEN_NUM_INITIALIZER
11095 (struct cmd_vf_vlan_insert_result,
11097 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11098 TOKEN_NUM_INITIALIZER
11099 (struct cmd_vf_vlan_insert_result,
11103 cmd_set_vf_vlan_insert_parsed(
11104 void *parsed_result,
11105 __attribute__((unused)) struct cmdline *cl,
11106 __attribute__((unused)) void *data)
11108 struct cmd_vf_vlan_insert_result *res = parsed_result;
11111 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id);
11116 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11119 printf("invalid port_id %d\n", res->port_id);
11122 printf("programming error: (%s)\n", strerror(-ret));
11126 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11127 .f = cmd_set_vf_vlan_insert_parsed,
11129 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11131 (void *)&cmd_vf_vlan_insert_set,
11132 (void *)&cmd_vf_vlan_insert_vf,
11133 (void *)&cmd_vf_vlan_insert_vlan,
11134 (void *)&cmd_vf_vlan_insert_insert,
11135 (void *)&cmd_vf_vlan_insert_port_id,
11136 (void *)&cmd_vf_vlan_insert_vf_id,
11137 (void *)&cmd_vf_vlan_insert_vlan_id,
11142 /* tx loopback configuration */
11144 /* Common result structure for tx loopback */
11145 struct cmd_tx_loopback_result {
11146 cmdline_fixed_string_t set;
11147 cmdline_fixed_string_t tx;
11148 cmdline_fixed_string_t loopback;
11150 cmdline_fixed_string_t on_off;
11153 /* Common CLI fields for tx loopback enable disable */
11154 cmdline_parse_token_string_t cmd_tx_loopback_set =
11155 TOKEN_STRING_INITIALIZER
11156 (struct cmd_tx_loopback_result,
11158 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11159 TOKEN_STRING_INITIALIZER
11160 (struct cmd_tx_loopback_result,
11162 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11163 TOKEN_STRING_INITIALIZER
11164 (struct cmd_tx_loopback_result,
11165 loopback, "loopback");
11166 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11167 TOKEN_NUM_INITIALIZER
11168 (struct cmd_tx_loopback_result,
11170 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11171 TOKEN_STRING_INITIALIZER
11172 (struct cmd_tx_loopback_result,
11176 cmd_set_tx_loopback_parsed(
11177 void *parsed_result,
11178 __attribute__((unused)) struct cmdline *cl,
11179 __attribute__((unused)) void *data)
11181 struct cmd_tx_loopback_result *res = parsed_result;
11183 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11185 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11190 printf("invalid is_on %d\n", is_on);
11193 printf("invalid port_id %d\n", res->port_id);
11196 printf("programming error: (%s)\n", strerror(-ret));
11200 cmdline_parse_inst_t cmd_set_tx_loopback = {
11201 .f = cmd_set_tx_loopback_parsed,
11203 .help_str = "set tx loopback <port_id> on|off",
11205 (void *)&cmd_tx_loopback_set,
11206 (void *)&cmd_tx_loopback_tx,
11207 (void *)&cmd_tx_loopback_loopback,
11208 (void *)&cmd_tx_loopback_port_id,
11209 (void *)&cmd_tx_loopback_on_off,
11214 /* all queues drop enable configuration */
11216 /* Common result structure for all queues drop enable */
11217 struct cmd_all_queues_drop_en_result {
11218 cmdline_fixed_string_t set;
11219 cmdline_fixed_string_t all;
11220 cmdline_fixed_string_t queues;
11221 cmdline_fixed_string_t drop;
11223 cmdline_fixed_string_t on_off;
11226 /* Common CLI fields for tx loopback enable disable */
11227 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11228 TOKEN_STRING_INITIALIZER
11229 (struct cmd_all_queues_drop_en_result,
11231 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11232 TOKEN_STRING_INITIALIZER
11233 (struct cmd_all_queues_drop_en_result,
11235 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11236 TOKEN_STRING_INITIALIZER
11237 (struct cmd_all_queues_drop_en_result,
11239 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11240 TOKEN_STRING_INITIALIZER
11241 (struct cmd_all_queues_drop_en_result,
11243 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11244 TOKEN_NUM_INITIALIZER
11245 (struct cmd_all_queues_drop_en_result,
11247 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11248 TOKEN_STRING_INITIALIZER
11249 (struct cmd_all_queues_drop_en_result,
11253 cmd_set_all_queues_drop_en_parsed(
11254 void *parsed_result,
11255 __attribute__((unused)) struct cmdline *cl,
11256 __attribute__((unused)) void *data)
11258 struct cmd_all_queues_drop_en_result *res = parsed_result;
11260 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11262 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11267 printf("invalid is_on %d\n", is_on);
11270 printf("invalid port_id %d\n", res->port_id);
11273 printf("programming error: (%s)\n", strerror(-ret));
11277 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11278 .f = cmd_set_all_queues_drop_en_parsed,
11280 .help_str = "set all queues drop <port_id> on|off",
11282 (void *)&cmd_all_queues_drop_en_set,
11283 (void *)&cmd_all_queues_drop_en_all,
11284 (void *)&cmd_all_queues_drop_en_queues,
11285 (void *)&cmd_all_queues_drop_en_drop,
11286 (void *)&cmd_all_queues_drop_en_port_id,
11287 (void *)&cmd_all_queues_drop_en_on_off,
11292 /* vf split drop enable configuration */
11294 /* Common result structure for vf split drop enable */
11295 struct cmd_vf_split_drop_en_result {
11296 cmdline_fixed_string_t set;
11297 cmdline_fixed_string_t vf;
11298 cmdline_fixed_string_t split;
11299 cmdline_fixed_string_t drop;
11302 cmdline_fixed_string_t on_off;
11305 /* Common CLI fields for vf split drop enable disable */
11306 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11307 TOKEN_STRING_INITIALIZER
11308 (struct cmd_vf_split_drop_en_result,
11310 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11311 TOKEN_STRING_INITIALIZER
11312 (struct cmd_vf_split_drop_en_result,
11314 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11315 TOKEN_STRING_INITIALIZER
11316 (struct cmd_vf_split_drop_en_result,
11318 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11319 TOKEN_STRING_INITIALIZER
11320 (struct cmd_vf_split_drop_en_result,
11322 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11323 TOKEN_NUM_INITIALIZER
11324 (struct cmd_vf_split_drop_en_result,
11326 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11327 TOKEN_NUM_INITIALIZER
11328 (struct cmd_vf_split_drop_en_result,
11330 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11331 TOKEN_STRING_INITIALIZER
11332 (struct cmd_vf_split_drop_en_result,
11336 cmd_set_vf_split_drop_en_parsed(
11337 void *parsed_result,
11338 __attribute__((unused)) struct cmdline *cl,
11339 __attribute__((unused)) void *data)
11341 struct cmd_vf_split_drop_en_result *res = parsed_result;
11343 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11345 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11351 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11354 printf("invalid port_id %d\n", res->port_id);
11357 printf("programming error: (%s)\n", strerror(-ret));
11361 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11362 .f = cmd_set_vf_split_drop_en_parsed,
11364 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11366 (void *)&cmd_vf_split_drop_en_set,
11367 (void *)&cmd_vf_split_drop_en_vf,
11368 (void *)&cmd_vf_split_drop_en_split,
11369 (void *)&cmd_vf_split_drop_en_drop,
11370 (void *)&cmd_vf_split_drop_en_port_id,
11371 (void *)&cmd_vf_split_drop_en_vf_id,
11372 (void *)&cmd_vf_split_drop_en_on_off,
11377 /* vf mac address configuration */
11379 /* Common result structure for vf mac address */
11380 struct cmd_set_vf_mac_addr_result {
11381 cmdline_fixed_string_t set;
11382 cmdline_fixed_string_t vf;
11383 cmdline_fixed_string_t mac;
11384 cmdline_fixed_string_t addr;
11387 struct ether_addr mac_addr;
11391 /* Common CLI fields for vf split drop enable disable */
11392 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11393 TOKEN_STRING_INITIALIZER
11394 (struct cmd_set_vf_mac_addr_result,
11396 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11397 TOKEN_STRING_INITIALIZER
11398 (struct cmd_set_vf_mac_addr_result,
11400 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11401 TOKEN_STRING_INITIALIZER
11402 (struct cmd_set_vf_mac_addr_result,
11404 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11405 TOKEN_STRING_INITIALIZER
11406 (struct cmd_set_vf_mac_addr_result,
11408 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11409 TOKEN_NUM_INITIALIZER
11410 (struct cmd_set_vf_mac_addr_result,
11412 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11413 TOKEN_NUM_INITIALIZER
11414 (struct cmd_set_vf_mac_addr_result,
11416 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11417 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11421 cmd_set_vf_mac_addr_parsed(
11422 void *parsed_result,
11423 __attribute__((unused)) struct cmdline *cl,
11424 __attribute__((unused)) void *data)
11426 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11429 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11435 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11438 printf("invalid port_id %d\n", res->port_id);
11441 printf("programming error: (%s)\n", strerror(-ret));
11445 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11446 .f = cmd_set_vf_mac_addr_parsed,
11448 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11450 (void *)&cmd_set_vf_mac_addr_set,
11451 (void *)&cmd_set_vf_mac_addr_vf,
11452 (void *)&cmd_set_vf_mac_addr_mac,
11453 (void *)&cmd_set_vf_mac_addr_addr,
11454 (void *)&cmd_set_vf_mac_addr_port_id,
11455 (void *)&cmd_set_vf_mac_addr_vf_id,
11456 (void *)&cmd_set_vf_mac_addr_mac_addr,
11462 /* ******************************************************************************** */
11464 /* list of instructions */
11465 cmdline_parse_ctx_t main_ctx[] = {
11466 (cmdline_parse_inst_t *)&cmd_help_brief,
11467 (cmdline_parse_inst_t *)&cmd_help_long,
11468 (cmdline_parse_inst_t *)&cmd_quit,
11469 (cmdline_parse_inst_t *)&cmd_showport,
11470 (cmdline_parse_inst_t *)&cmd_showqueue,
11471 (cmdline_parse_inst_t *)&cmd_showportall,
11472 (cmdline_parse_inst_t *)&cmd_showcfg,
11473 (cmdline_parse_inst_t *)&cmd_start,
11474 (cmdline_parse_inst_t *)&cmd_start_tx_first,
11475 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
11476 (cmdline_parse_inst_t *)&cmd_set_link_up,
11477 (cmdline_parse_inst_t *)&cmd_set_link_down,
11478 (cmdline_parse_inst_t *)&cmd_reset,
11479 (cmdline_parse_inst_t *)&cmd_set_numbers,
11480 (cmdline_parse_inst_t *)&cmd_set_txpkts,
11481 (cmdline_parse_inst_t *)&cmd_set_txsplit,
11482 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
11483 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
11484 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
11485 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
11486 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
11487 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
11488 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
11489 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
11490 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
11491 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
11492 (cmdline_parse_inst_t *)&cmd_set_link_check,
11493 #ifdef RTE_NIC_BYPASS
11494 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
11495 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
11496 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
11497 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
11499 #ifdef RTE_LIBRTE_PMD_BOND
11500 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
11501 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
11502 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
11503 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
11504 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
11505 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
11506 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
11507 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
11508 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
11510 (cmdline_parse_inst_t *)&cmd_vlan_offload,
11511 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
11512 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
11513 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
11514 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
11515 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
11516 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
11517 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
11518 (cmdline_parse_inst_t *)&cmd_csum_set,
11519 (cmdline_parse_inst_t *)&cmd_csum_show,
11520 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
11521 (cmdline_parse_inst_t *)&cmd_tso_set,
11522 (cmdline_parse_inst_t *)&cmd_tso_show,
11523 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
11524 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
11525 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
11526 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
11527 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
11528 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
11529 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
11530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
11531 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
11532 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
11533 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
11534 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
11535 (cmdline_parse_inst_t *)&cmd_config_dcb,
11536 (cmdline_parse_inst_t *)&cmd_read_reg,
11537 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
11538 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
11539 (cmdline_parse_inst_t *)&cmd_write_reg,
11540 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
11541 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
11542 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
11543 (cmdline_parse_inst_t *)&cmd_stop,
11544 (cmdline_parse_inst_t *)&cmd_mac_addr,
11545 (cmdline_parse_inst_t *)&cmd_set_qmap,
11546 (cmdline_parse_inst_t *)&cmd_operate_port,
11547 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
11548 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
11549 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
11550 (cmdline_parse_inst_t *)&cmd_config_speed_all,
11551 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
11552 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
11553 (cmdline_parse_inst_t *)&cmd_config_mtu,
11554 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
11555 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
11556 (cmdline_parse_inst_t *)&cmd_config_rss,
11557 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
11558 (cmdline_parse_inst_t *)&cmd_config_txqflags,
11559 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
11560 (cmdline_parse_inst_t *)&cmd_showport_reta,
11561 (cmdline_parse_inst_t *)&cmd_config_burst,
11562 (cmdline_parse_inst_t *)&cmd_config_thresh,
11563 (cmdline_parse_inst_t *)&cmd_config_threshold,
11564 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
11565 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
11566 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
11567 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
11568 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
11569 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
11570 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
11571 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
11572 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
11573 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
11574 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
11575 (cmdline_parse_inst_t *)&cmd_global_config,
11576 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
11577 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
11578 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
11579 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
11580 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
11581 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
11582 (cmdline_parse_inst_t *)&cmd_dump,
11583 (cmdline_parse_inst_t *)&cmd_dump_one,
11584 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
11585 (cmdline_parse_inst_t *)&cmd_syn_filter,
11586 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
11587 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
11588 (cmdline_parse_inst_t *)&cmd_flex_filter,
11589 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
11590 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
11591 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
11592 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
11593 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
11594 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
11595 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
11596 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
11597 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
11598 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
11599 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
11600 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
11601 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
11602 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
11603 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
11604 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
11605 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
11606 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
11607 (cmdline_parse_inst_t *)&cmd_mcast_addr,
11608 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
11609 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
11610 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
11611 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
11612 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
11613 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
11614 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
11615 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
11616 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
11617 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
11618 #ifdef RTE_LIBRTE_IXGBE_PMD
11619 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
11620 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
11621 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
11622 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
11623 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
11624 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
11625 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
11626 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
11631 /* prompt function, called from main on MASTER lcore */
11635 /* initialize non-constant commands */
11636 cmd_set_fwd_mode_init();
11637 cmd_set_fwd_retry_mode_init();
11639 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
11640 if (testpmd_cl == NULL)
11642 cmdline_interact(testpmd_cl);
11643 cmdline_stdin_exit(testpmd_cl);
11649 if (testpmd_cl != NULL)
11650 cmdline_quit(testpmd_cl);
11654 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
11656 if (id == (portid_t)RTE_PORT_ALL) {
11659 FOREACH_PORT(pid, ports) {
11660 /* check if need_reconfig has been set to 1 */
11661 if (ports[pid].need_reconfig == 0)
11662 ports[pid].need_reconfig = dev;
11663 /* check if need_reconfig_queues has been set to 1 */
11664 if (ports[pid].need_reconfig_queues == 0)
11665 ports[pid].need_reconfig_queues = queue;
11667 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
11668 /* check if need_reconfig has been set to 1 */
11669 if (ports[id].need_reconfig == 0)
11670 ports[id].need_reconfig = dev;
11671 /* check if need_reconfig_queues has been set to 1 */
11672 if (ports[id].need_reconfig_queues == 0)
11673 ports[id].need_reconfig_queues = queue;