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
= "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
= "show help",
829 (void *)&cmd_help_long_help
,
830 (void *)&cmd_help_long_section
,
836 /* *** start/stop/close all ports *** */
837 struct cmd_operate_port_result
{
838 cmdline_fixed_string_t keyword
;
839 cmdline_fixed_string_t name
;
840 cmdline_fixed_string_t value
;
843 static void cmd_operate_port_parsed(void *parsed_result
,
844 __attribute__((unused
)) struct cmdline
*cl
,
845 __attribute__((unused
)) void *data
)
847 struct cmd_operate_port_result
*res
= parsed_result
;
849 if (!strcmp(res
->name
, "start"))
850 start_port(RTE_PORT_ALL
);
851 else if (!strcmp(res
->name
, "stop"))
852 stop_port(RTE_PORT_ALL
);
853 else if (!strcmp(res
->name
, "close"))
854 close_port(RTE_PORT_ALL
);
856 printf("Unknown parameter\n");
859 cmdline_parse_token_string_t cmd_operate_port_all_cmd
=
860 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result
, keyword
,
862 cmdline_parse_token_string_t cmd_operate_port_all_port
=
863 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result
, name
,
865 cmdline_parse_token_string_t cmd_operate_port_all_all
=
866 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result
, value
, "all");
868 cmdline_parse_inst_t cmd_operate_port
= {
869 .f
= cmd_operate_port_parsed
,
871 .help_str
= "port start|stop|close all: start/stop/close all ports",
873 (void *)&cmd_operate_port_all_cmd
,
874 (void *)&cmd_operate_port_all_port
,
875 (void *)&cmd_operate_port_all_all
,
880 /* *** start/stop/close specific port *** */
881 struct cmd_operate_specific_port_result
{
882 cmdline_fixed_string_t keyword
;
883 cmdline_fixed_string_t name
;
887 static void cmd_operate_specific_port_parsed(void *parsed_result
,
888 __attribute__((unused
)) struct cmdline
*cl
,
889 __attribute__((unused
)) void *data
)
891 struct cmd_operate_specific_port_result
*res
= parsed_result
;
893 if (!strcmp(res
->name
, "start"))
894 start_port(res
->value
);
895 else if (!strcmp(res
->name
, "stop"))
896 stop_port(res
->value
);
897 else if (!strcmp(res
->name
, "close"))
898 close_port(res
->value
);
900 printf("Unknown parameter\n");
903 cmdline_parse_token_string_t cmd_operate_specific_port_cmd
=
904 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result
,
906 cmdline_parse_token_string_t cmd_operate_specific_port_port
=
907 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result
,
908 name
, "start#stop#close");
909 cmdline_parse_token_num_t cmd_operate_specific_port_id
=
910 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result
,
913 cmdline_parse_inst_t cmd_operate_specific_port
= {
914 .f
= cmd_operate_specific_port_parsed
,
916 .help_str
= "port start|stop|close X: start/stop/close port X",
918 (void *)&cmd_operate_specific_port_cmd
,
919 (void *)&cmd_operate_specific_port_port
,
920 (void *)&cmd_operate_specific_port_id
,
925 /* *** attach a specified port *** */
926 struct cmd_operate_attach_port_result
{
927 cmdline_fixed_string_t port
;
928 cmdline_fixed_string_t keyword
;
929 cmdline_fixed_string_t identifier
;
932 static void cmd_operate_attach_port_parsed(void *parsed_result
,
933 __attribute__((unused
)) struct cmdline
*cl
,
934 __attribute__((unused
)) void *data
)
936 struct cmd_operate_attach_port_result
*res
= parsed_result
;
938 if (!strcmp(res
->keyword
, "attach"))
939 attach_port(res
->identifier
);
941 printf("Unknown parameter\n");
944 cmdline_parse_token_string_t cmd_operate_attach_port_port
=
945 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result
,
947 cmdline_parse_token_string_t cmd_operate_attach_port_keyword
=
948 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result
,
950 cmdline_parse_token_string_t cmd_operate_attach_port_identifier
=
951 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result
,
954 cmdline_parse_inst_t cmd_operate_attach_port
= {
955 .f
= cmd_operate_attach_port_parsed
,
957 .help_str
= "port attach identifier, "
958 "identifier: pci address or virtual dev name",
960 (void *)&cmd_operate_attach_port_port
,
961 (void *)&cmd_operate_attach_port_keyword
,
962 (void *)&cmd_operate_attach_port_identifier
,
967 /* *** detach a specified port *** */
968 struct cmd_operate_detach_port_result
{
969 cmdline_fixed_string_t port
;
970 cmdline_fixed_string_t keyword
;
974 static void cmd_operate_detach_port_parsed(void *parsed_result
,
975 __attribute__((unused
)) struct cmdline
*cl
,
976 __attribute__((unused
)) void *data
)
978 struct cmd_operate_detach_port_result
*res
= parsed_result
;
980 if (!strcmp(res
->keyword
, "detach"))
981 detach_port(res
->port_id
);
983 printf("Unknown parameter\n");
986 cmdline_parse_token_string_t cmd_operate_detach_port_port
=
987 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result
,
989 cmdline_parse_token_string_t cmd_operate_detach_port_keyword
=
990 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result
,
992 cmdline_parse_token_num_t cmd_operate_detach_port_port_id
=
993 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result
,
996 cmdline_parse_inst_t cmd_operate_detach_port
= {
997 .f
= cmd_operate_detach_port_parsed
,
999 .help_str
= "port detach port_id",
1001 (void *)&cmd_operate_detach_port_port
,
1002 (void *)&cmd_operate_detach_port_keyword
,
1003 (void *)&cmd_operate_detach_port_port_id
,
1008 /* *** configure speed for all ports *** */
1009 struct cmd_config_speed_all
{
1010 cmdline_fixed_string_t port
;
1011 cmdline_fixed_string_t keyword
;
1012 cmdline_fixed_string_t all
;
1013 cmdline_fixed_string_t item1
;
1014 cmdline_fixed_string_t item2
;
1015 cmdline_fixed_string_t value1
;
1016 cmdline_fixed_string_t value2
;
1020 parse_and_check_speed_duplex(char *speedstr
, char *duplexstr
, uint32_t *speed
)
1025 if (!strcmp(duplexstr
, "half")) {
1026 duplex
= ETH_LINK_HALF_DUPLEX
;
1027 } else if (!strcmp(duplexstr
, "full")) {
1028 duplex
= ETH_LINK_FULL_DUPLEX
;
1029 } else if (!strcmp(duplexstr
, "auto")) {
1030 duplex
= ETH_LINK_FULL_DUPLEX
;
1032 printf("Unknown duplex parameter\n");
1036 if (!strcmp(speedstr
, "10")) {
1037 *speed
= (duplex
== ETH_LINK_HALF_DUPLEX
) ?
1038 ETH_LINK_SPEED_10M_HD
: ETH_LINK_SPEED_10M
;
1039 } else if (!strcmp(speedstr
, "100")) {
1040 *speed
= (duplex
== ETH_LINK_HALF_DUPLEX
) ?
1041 ETH_LINK_SPEED_100M_HD
: ETH_LINK_SPEED_100M
;
1043 if (duplex
!= ETH_LINK_FULL_DUPLEX
) {
1044 printf("Invalid speed/duplex parameters\n");
1047 if (!strcmp(speedstr
, "1000")) {
1048 *speed
= ETH_LINK_SPEED_1G
;
1049 } else if (!strcmp(speedstr
, "10000")) {
1050 *speed
= ETH_LINK_SPEED_10G
;
1051 } else if (!strcmp(speedstr
, "25000")) {
1052 *speed
= ETH_LINK_SPEED_25G
;
1053 } else if (!strcmp(speedstr
, "40000")) {
1054 *speed
= ETH_LINK_SPEED_40G
;
1055 } else if (!strcmp(speedstr
, "50000")) {
1056 *speed
= ETH_LINK_SPEED_50G
;
1057 } else if (!strcmp(speedstr
, "100000")) {
1058 *speed
= ETH_LINK_SPEED_100G
;
1059 } else if (!strcmp(speedstr
, "auto")) {
1060 *speed
= ETH_LINK_SPEED_AUTONEG
;
1062 printf("Unknown speed parameter\n");
1071 cmd_config_speed_all_parsed(void *parsed_result
,
1072 __attribute__((unused
)) struct cmdline
*cl
,
1073 __attribute__((unused
)) void *data
)
1075 struct cmd_config_speed_all
*res
= parsed_result
;
1076 uint32_t link_speed
;
1079 if (!all_ports_stopped()) {
1080 printf("Please stop all ports first\n");
1084 if (parse_and_check_speed_duplex(res
->value1
, res
->value2
,
1088 FOREACH_PORT(pid
, ports
) {
1089 ports
[pid
].dev_conf
.link_speeds
= link_speed
;
1092 cmd_reconfig_device_queue(RTE_PORT_ALL
, 1, 1);
1095 cmdline_parse_token_string_t cmd_config_speed_all_port
=
1096 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all
, port
, "port");
1097 cmdline_parse_token_string_t cmd_config_speed_all_keyword
=
1098 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all
, keyword
,
1100 cmdline_parse_token_string_t cmd_config_speed_all_all
=
1101 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all
, all
, "all");
1102 cmdline_parse_token_string_t cmd_config_speed_all_item1
=
1103 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all
, item1
, "speed");
1104 cmdline_parse_token_string_t cmd_config_speed_all_value1
=
1105 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all
, value1
,
1106 "10#100#1000#10000#25000#40000#50000#100000#auto");
1107 cmdline_parse_token_string_t cmd_config_speed_all_item2
=
1108 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all
, item2
, "duplex");
1109 cmdline_parse_token_string_t cmd_config_speed_all_value2
=
1110 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all
, value2
,
1113 cmdline_parse_inst_t cmd_config_speed_all
= {
1114 .f
= cmd_config_speed_all_parsed
,
1116 .help_str
= "port config all speed "
1117 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1120 (void *)&cmd_config_speed_all_port
,
1121 (void *)&cmd_config_speed_all_keyword
,
1122 (void *)&cmd_config_speed_all_all
,
1123 (void *)&cmd_config_speed_all_item1
,
1124 (void *)&cmd_config_speed_all_value1
,
1125 (void *)&cmd_config_speed_all_item2
,
1126 (void *)&cmd_config_speed_all_value2
,
1131 /* *** configure speed for specific port *** */
1132 struct cmd_config_speed_specific
{
1133 cmdline_fixed_string_t port
;
1134 cmdline_fixed_string_t keyword
;
1136 cmdline_fixed_string_t item1
;
1137 cmdline_fixed_string_t item2
;
1138 cmdline_fixed_string_t value1
;
1139 cmdline_fixed_string_t value2
;
1143 cmd_config_speed_specific_parsed(void *parsed_result
,
1144 __attribute__((unused
)) struct cmdline
*cl
,
1145 __attribute__((unused
)) void *data
)
1147 struct cmd_config_speed_specific
*res
= parsed_result
;
1148 uint32_t link_speed
;
1150 if (!all_ports_stopped()) {
1151 printf("Please stop all ports first\n");
1155 if (port_id_is_invalid(res
->id
, ENABLED_WARN
))
1158 if (parse_and_check_speed_duplex(res
->value1
, res
->value2
,
1162 ports
[res
->id
].dev_conf
.link_speeds
= link_speed
;
1164 cmd_reconfig_device_queue(RTE_PORT_ALL
, 1, 1);
1168 cmdline_parse_token_string_t cmd_config_speed_specific_port
=
1169 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific
, port
,
1171 cmdline_parse_token_string_t cmd_config_speed_specific_keyword
=
1172 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific
, keyword
,
1174 cmdline_parse_token_num_t cmd_config_speed_specific_id
=
1175 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific
, id
, UINT8
);
1176 cmdline_parse_token_string_t cmd_config_speed_specific_item1
=
1177 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific
, item1
,
1179 cmdline_parse_token_string_t cmd_config_speed_specific_value1
=
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific
, value1
,
1181 "10#100#1000#10000#25000#40000#50000#100000#auto");
1182 cmdline_parse_token_string_t cmd_config_speed_specific_item2
=
1183 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific
, item2
,
1185 cmdline_parse_token_string_t cmd_config_speed_specific_value2
=
1186 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific
, value2
,
1189 cmdline_parse_inst_t cmd_config_speed_specific
= {
1190 .f
= cmd_config_speed_specific_parsed
,
1192 .help_str
= "port config X speed "
1193 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1196 (void *)&cmd_config_speed_specific_port
,
1197 (void *)&cmd_config_speed_specific_keyword
,
1198 (void *)&cmd_config_speed_specific_id
,
1199 (void *)&cmd_config_speed_specific_item1
,
1200 (void *)&cmd_config_speed_specific_value1
,
1201 (void *)&cmd_config_speed_specific_item2
,
1202 (void *)&cmd_config_speed_specific_value2
,
1207 /* *** configure txq/rxq, txd/rxd *** */
1208 struct cmd_config_rx_tx
{
1209 cmdline_fixed_string_t port
;
1210 cmdline_fixed_string_t keyword
;
1211 cmdline_fixed_string_t all
;
1212 cmdline_fixed_string_t name
;
1217 cmd_config_rx_tx_parsed(void *parsed_result
,
1218 __attribute__((unused
)) struct cmdline
*cl
,
1219 __attribute__((unused
)) void *data
)
1221 struct cmd_config_rx_tx
*res
= parsed_result
;
1223 if (!all_ports_stopped()) {
1224 printf("Please stop all ports first\n");
1227 if (!strcmp(res
->name
, "rxq")) {
1228 if (!res
->value
&& !nb_txq
) {
1229 printf("Warning: Either rx or tx queues should be non zero\n");
1232 nb_rxq
= res
->value
;
1234 else if (!strcmp(res
->name
, "txq")) {
1235 if (!res
->value
&& !nb_rxq
) {
1236 printf("Warning: Either rx or tx queues should be non zero\n");
1239 nb_txq
= res
->value
;
1241 else if (!strcmp(res
->name
, "rxd")) {
1242 if (res
->value
<= 0 || res
->value
> RTE_TEST_RX_DESC_MAX
) {
1243 printf("rxd %d invalid - must be > 0 && <= %d\n",
1244 res
->value
, RTE_TEST_RX_DESC_MAX
);
1247 nb_rxd
= res
->value
;
1248 } else if (!strcmp(res
->name
, "txd")) {
1249 if (res
->value
<= 0 || res
->value
> RTE_TEST_TX_DESC_MAX
) {
1250 printf("txd %d invalid - must be > 0 && <= %d\n",
1251 res
->value
, RTE_TEST_TX_DESC_MAX
);
1254 nb_txd
= res
->value
;
1256 printf("Unknown parameter\n");
1264 cmd_reconfig_device_queue(RTE_PORT_ALL
, 1, 1);
1267 cmdline_parse_token_string_t cmd_config_rx_tx_port
=
1268 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx
, port
, "port");
1269 cmdline_parse_token_string_t cmd_config_rx_tx_keyword
=
1270 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx
, keyword
, "config");
1271 cmdline_parse_token_string_t cmd_config_rx_tx_all
=
1272 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx
, all
, "all");
1273 cmdline_parse_token_string_t cmd_config_rx_tx_name
=
1274 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx
, name
,
1276 cmdline_parse_token_num_t cmd_config_rx_tx_value
=
1277 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx
, value
, UINT16
);
1279 cmdline_parse_inst_t cmd_config_rx_tx
= {
1280 .f
= cmd_config_rx_tx_parsed
,
1282 .help_str
= "port config all rxq|txq|rxd|txd value",
1284 (void *)&cmd_config_rx_tx_port
,
1285 (void *)&cmd_config_rx_tx_keyword
,
1286 (void *)&cmd_config_rx_tx_all
,
1287 (void *)&cmd_config_rx_tx_name
,
1288 (void *)&cmd_config_rx_tx_value
,
1293 /* *** config max packet length *** */
1294 struct cmd_config_max_pkt_len_result
{
1295 cmdline_fixed_string_t port
;
1296 cmdline_fixed_string_t keyword
;
1297 cmdline_fixed_string_t all
;
1298 cmdline_fixed_string_t name
;
1303 cmd_config_max_pkt_len_parsed(void *parsed_result
,
1304 __attribute__((unused
)) struct cmdline
*cl
,
1305 __attribute__((unused
)) void *data
)
1307 struct cmd_config_max_pkt_len_result
*res
= parsed_result
;
1309 if (!all_ports_stopped()) {
1310 printf("Please stop all ports first\n");
1314 if (!strcmp(res
->name
, "max-pkt-len")) {
1315 if (res
->value
< ETHER_MIN_LEN
) {
1316 printf("max-pkt-len can not be less than %d\n",
1320 if (res
->value
== rx_mode
.max_rx_pkt_len
)
1323 rx_mode
.max_rx_pkt_len
= res
->value
;
1324 if (res
->value
> ETHER_MAX_LEN
)
1325 rx_mode
.jumbo_frame
= 1;
1327 rx_mode
.jumbo_frame
= 0;
1329 printf("Unknown parameter\n");
1335 cmd_reconfig_device_queue(RTE_PORT_ALL
, 1, 1);
1338 cmdline_parse_token_string_t cmd_config_max_pkt_len_port
=
1339 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result
, port
,
1341 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword
=
1342 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result
, keyword
,
1344 cmdline_parse_token_string_t cmd_config_max_pkt_len_all
=
1345 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result
, all
,
1347 cmdline_parse_token_string_t cmd_config_max_pkt_len_name
=
1348 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result
, name
,
1350 cmdline_parse_token_num_t cmd_config_max_pkt_len_value
=
1351 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result
, value
,
1354 cmdline_parse_inst_t cmd_config_max_pkt_len
= {
1355 .f
= cmd_config_max_pkt_len_parsed
,
1357 .help_str
= "port config all max-pkt-len value",
1359 (void *)&cmd_config_max_pkt_len_port
,
1360 (void *)&cmd_config_max_pkt_len_keyword
,
1361 (void *)&cmd_config_max_pkt_len_all
,
1362 (void *)&cmd_config_max_pkt_len_name
,
1363 (void *)&cmd_config_max_pkt_len_value
,
1368 /* *** configure port MTU *** */
1369 struct cmd_config_mtu_result
{
1370 cmdline_fixed_string_t port
;
1371 cmdline_fixed_string_t keyword
;
1372 cmdline_fixed_string_t mtu
;
1378 cmd_config_mtu_parsed(void *parsed_result
,
1379 __attribute__((unused
)) struct cmdline
*cl
,
1380 __attribute__((unused
)) void *data
)
1382 struct cmd_config_mtu_result
*res
= parsed_result
;
1384 if (res
->value
< ETHER_MIN_LEN
) {
1385 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN
);
1388 port_mtu_set(res
->port_id
, res
->value
);
1391 cmdline_parse_token_string_t cmd_config_mtu_port
=
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result
, port
,
1394 cmdline_parse_token_string_t cmd_config_mtu_keyword
=
1395 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result
, keyword
,
1397 cmdline_parse_token_string_t cmd_config_mtu_mtu
=
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result
, keyword
,
1400 cmdline_parse_token_num_t cmd_config_mtu_port_id
=
1401 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result
, port_id
, UINT8
);
1402 cmdline_parse_token_num_t cmd_config_mtu_value
=
1403 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result
, value
, UINT16
);
1405 cmdline_parse_inst_t cmd_config_mtu
= {
1406 .f
= cmd_config_mtu_parsed
,
1408 .help_str
= "port config mtu port_id value",
1410 (void *)&cmd_config_mtu_port
,
1411 (void *)&cmd_config_mtu_keyword
,
1412 (void *)&cmd_config_mtu_mtu
,
1413 (void *)&cmd_config_mtu_port_id
,
1414 (void *)&cmd_config_mtu_value
,
1419 /* *** configure rx mode *** */
1420 struct cmd_config_rx_mode_flag
{
1421 cmdline_fixed_string_t port
;
1422 cmdline_fixed_string_t keyword
;
1423 cmdline_fixed_string_t all
;
1424 cmdline_fixed_string_t name
;
1425 cmdline_fixed_string_t value
;
1429 cmd_config_rx_mode_flag_parsed(void *parsed_result
,
1430 __attribute__((unused
)) struct cmdline
*cl
,
1431 __attribute__((unused
)) void *data
)
1433 struct cmd_config_rx_mode_flag
*res
= parsed_result
;
1435 if (!all_ports_stopped()) {
1436 printf("Please stop all ports first\n");
1440 if (!strcmp(res
->name
, "crc-strip")) {
1441 if (!strcmp(res
->value
, "on"))
1442 rx_mode
.hw_strip_crc
= 1;
1443 else if (!strcmp(res
->value
, "off"))
1444 rx_mode
.hw_strip_crc
= 0;
1446 printf("Unknown parameter\n");
1449 } else if (!strcmp(res
->name
, "scatter")) {
1450 if (!strcmp(res
->value
, "on"))
1451 rx_mode
.enable_scatter
= 1;
1452 else if (!strcmp(res
->value
, "off"))
1453 rx_mode
.enable_scatter
= 0;
1455 printf("Unknown parameter\n");
1458 } else if (!strcmp(res
->name
, "rx-cksum")) {
1459 if (!strcmp(res
->value
, "on"))
1460 rx_mode
.hw_ip_checksum
= 1;
1461 else if (!strcmp(res
->value
, "off"))
1462 rx_mode
.hw_ip_checksum
= 0;
1464 printf("Unknown parameter\n");
1467 } else if (!strcmp(res
->name
, "hw-vlan")) {
1468 if (!strcmp(res
->value
, "on")) {
1469 rx_mode
.hw_vlan_filter
= 1;
1470 rx_mode
.hw_vlan_strip
= 1;
1472 else if (!strcmp(res
->value
, "off")) {
1473 rx_mode
.hw_vlan_filter
= 0;
1474 rx_mode
.hw_vlan_strip
= 0;
1477 printf("Unknown parameter\n");
1480 } else if (!strcmp(res
->name
, "hw-vlan-filter")) {
1481 if (!strcmp(res
->value
, "on"))
1482 rx_mode
.hw_vlan_filter
= 1;
1483 else if (!strcmp(res
->value
, "off"))
1484 rx_mode
.hw_vlan_filter
= 0;
1486 printf("Unknown parameter\n");
1489 } else if (!strcmp(res
->name
, "hw-vlan-strip")) {
1490 if (!strcmp(res
->value
, "on"))
1491 rx_mode
.hw_vlan_strip
= 1;
1492 else if (!strcmp(res
->value
, "off"))
1493 rx_mode
.hw_vlan_strip
= 0;
1495 printf("Unknown parameter\n");
1498 } else if (!strcmp(res
->name
, "hw-vlan-extend")) {
1499 if (!strcmp(res
->value
, "on"))
1500 rx_mode
.hw_vlan_extend
= 1;
1501 else if (!strcmp(res
->value
, "off"))
1502 rx_mode
.hw_vlan_extend
= 0;
1504 printf("Unknown parameter\n");
1507 } else if (!strcmp(res
->name
, "drop-en")) {
1508 if (!strcmp(res
->value
, "on"))
1510 else if (!strcmp(res
->value
, "off"))
1513 printf("Unknown parameter\n");
1517 printf("Unknown parameter\n");
1523 cmd_reconfig_device_queue(RTE_PORT_ALL
, 1, 1);
1526 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port
=
1527 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag
, port
, "port");
1528 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword
=
1529 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag
, keyword
,
1531 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all
=
1532 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag
, all
, "all");
1533 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name
=
1534 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag
, name
,
1535 "crc-strip#scatter#rx-cksum#hw-vlan#"
1536 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1537 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value
=
1538 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag
, value
,
1541 cmdline_parse_inst_t cmd_config_rx_mode_flag
= {
1542 .f
= cmd_config_rx_mode_flag_parsed
,
1544 .help_str
= "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1545 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1547 (void *)&cmd_config_rx_mode_flag_port
,
1548 (void *)&cmd_config_rx_mode_flag_keyword
,
1549 (void *)&cmd_config_rx_mode_flag_all
,
1550 (void *)&cmd_config_rx_mode_flag_name
,
1551 (void *)&cmd_config_rx_mode_flag_value
,
1556 /* *** configure rss *** */
1557 struct cmd_config_rss
{
1558 cmdline_fixed_string_t port
;
1559 cmdline_fixed_string_t keyword
;
1560 cmdline_fixed_string_t all
;
1561 cmdline_fixed_string_t name
;
1562 cmdline_fixed_string_t value
;
1566 cmd_config_rss_parsed(void *parsed_result
,
1567 __attribute__((unused
)) struct cmdline
*cl
,
1568 __attribute__((unused
)) void *data
)
1570 struct cmd_config_rss
*res
= parsed_result
;
1571 struct rte_eth_rss_conf rss_conf
;
1575 if (!strcmp(res
->value
, "all"))
1576 rss_conf
.rss_hf
= ETH_RSS_IP
| ETH_RSS_TCP
|
1577 ETH_RSS_UDP
| ETH_RSS_SCTP
|
1579 else if (!strcmp(res
->value
, "ip"))
1580 rss_conf
.rss_hf
= ETH_RSS_IP
;
1581 else if (!strcmp(res
->value
, "udp"))
1582 rss_conf
.rss_hf
= ETH_RSS_UDP
;
1583 else if (!strcmp(res
->value
, "tcp"))
1584 rss_conf
.rss_hf
= ETH_RSS_TCP
;
1585 else if (!strcmp(res
->value
, "sctp"))
1586 rss_conf
.rss_hf
= ETH_RSS_SCTP
;
1587 else if (!strcmp(res
->value
, "ether"))
1588 rss_conf
.rss_hf
= ETH_RSS_L2_PAYLOAD
;
1589 else if (!strcmp(res
->value
, "port"))
1590 rss_conf
.rss_hf
= ETH_RSS_PORT
;
1591 else if (!strcmp(res
->value
, "vxlan"))
1592 rss_conf
.rss_hf
= ETH_RSS_VXLAN
;
1593 else if (!strcmp(res
->value
, "geneve"))
1594 rss_conf
.rss_hf
= ETH_RSS_GENEVE
;
1595 else if (!strcmp(res
->value
, "nvgre"))
1596 rss_conf
.rss_hf
= ETH_RSS_NVGRE
;
1597 else if (!strcmp(res
->value
, "none"))
1598 rss_conf
.rss_hf
= 0;
1600 printf("Unknown parameter\n");
1603 rss_conf
.rss_key
= NULL
;
1604 for (i
= 0; i
< rte_eth_dev_count(); i
++) {
1605 diag
= rte_eth_dev_rss_hash_update(i
, &rss_conf
);
1607 printf("Configuration of RSS hash at ethernet port %d "
1608 "failed with error (%d): %s.\n",
1609 i
, -diag
, strerror(-diag
));
1613 cmdline_parse_token_string_t cmd_config_rss_port
=
1614 TOKEN_STRING_INITIALIZER(struct cmd_config_rss
, port
, "port");
1615 cmdline_parse_token_string_t cmd_config_rss_keyword
=
1616 TOKEN_STRING_INITIALIZER(struct cmd_config_rss
, keyword
, "config");
1617 cmdline_parse_token_string_t cmd_config_rss_all
=
1618 TOKEN_STRING_INITIALIZER(struct cmd_config_rss
, all
, "all");
1619 cmdline_parse_token_string_t cmd_config_rss_name
=
1620 TOKEN_STRING_INITIALIZER(struct cmd_config_rss
, name
, "rss");
1621 cmdline_parse_token_string_t cmd_config_rss_value
=
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_rss
, value
,
1623 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1625 cmdline_parse_inst_t cmd_config_rss
= {
1626 .f
= cmd_config_rss_parsed
,
1628 .help_str
= "port config all rss all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1630 (void *)&cmd_config_rss_port
,
1631 (void *)&cmd_config_rss_keyword
,
1632 (void *)&cmd_config_rss_all
,
1633 (void *)&cmd_config_rss_name
,
1634 (void *)&cmd_config_rss_value
,
1639 /* *** configure rss hash key *** */
1640 struct cmd_config_rss_hash_key
{
1641 cmdline_fixed_string_t port
;
1642 cmdline_fixed_string_t config
;
1644 cmdline_fixed_string_t rss_hash_key
;
1645 cmdline_fixed_string_t rss_type
;
1646 cmdline_fixed_string_t key
;
1650 hexa_digit_to_value(char hexa_digit
)
1652 if ((hexa_digit
>= '0') && (hexa_digit
<= '9'))
1653 return (uint8_t) (hexa_digit
- '0');
1654 if ((hexa_digit
>= 'a') && (hexa_digit
<= 'f'))
1655 return (uint8_t) ((hexa_digit
- 'a') + 10);
1656 if ((hexa_digit
>= 'A') && (hexa_digit
<= 'F'))
1657 return (uint8_t) ((hexa_digit
- 'A') + 10);
1658 /* Invalid hexa digit */
1663 parse_and_check_key_hexa_digit(char *key
, int idx
)
1667 hexa_v
= hexa_digit_to_value(key
[idx
]);
1669 printf("invalid key: character %c at position %d is not a "
1670 "valid hexa digit\n", key
[idx
], idx
);
1675 cmd_config_rss_hash_key_parsed(void *parsed_result
,
1676 __attribute__((unused
)) struct cmdline
*cl
,
1677 __attribute__((unused
)) void *data
)
1679 struct cmd_config_rss_hash_key
*res
= parsed_result
;
1680 uint8_t hash_key
[RSS_HASH_KEY_LENGTH
];
1684 struct rte_eth_dev_info dev_info
;
1685 uint8_t hash_key_size
;
1688 memset(&dev_info
, 0, sizeof(dev_info
));
1689 rte_eth_dev_info_get(res
->port_id
, &dev_info
);
1690 if (dev_info
.hash_key_size
> 0 &&
1691 dev_info
.hash_key_size
<= sizeof(hash_key
))
1692 hash_key_size
= dev_info
.hash_key_size
;
1694 printf("dev_info did not provide a valid hash key size\n");
1697 /* Check the length of the RSS hash key */
1698 key_len
= strlen(res
->key
);
1699 if (key_len
!= (hash_key_size
* 2)) {
1700 printf("key length: %d invalid - key must be a string of %d"
1701 " hexa-decimal numbers\n",
1702 (int) key_len
, hash_key_size
* 2);
1705 /* Translate RSS hash key into binary representation */
1706 for (i
= 0; i
< hash_key_size
; i
++) {
1707 xdgt0
= parse_and_check_key_hexa_digit(res
->key
, (i
* 2));
1710 xdgt1
= parse_and_check_key_hexa_digit(res
->key
, (i
* 2) + 1);
1713 hash_key
[i
] = (uint8_t) ((xdgt0
* 16) + xdgt1
);
1715 port_rss_hash_key_update(res
->port_id
, res
->rss_type
, hash_key
,
1719 cmdline_parse_token_string_t cmd_config_rss_hash_key_port
=
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key
, port
, "port");
1721 cmdline_parse_token_string_t cmd_config_rss_hash_key_config
=
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key
, config
,
1724 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id
=
1725 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key
, port_id
, UINT8
);
1726 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key
=
1727 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key
,
1728 rss_hash_key
, "rss-hash-key");
1729 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type
=
1730 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key
, rss_type
,
1731 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1732 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1733 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1734 "ipv6-tcp-ex#ipv6-udp-ex");
1735 cmdline_parse_token_string_t cmd_config_rss_hash_key_value
=
1736 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key
, key
, NULL
);
1738 cmdline_parse_inst_t cmd_config_rss_hash_key
= {
1739 .f
= cmd_config_rss_hash_key_parsed
,
1742 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1743 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1744 "ipv6-sctp|ipv6-other|l2-payload|"
1745 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1746 "<string of hexa digits (variable length, NIC dependent)>\n",
1748 (void *)&cmd_config_rss_hash_key_port
,
1749 (void *)&cmd_config_rss_hash_key_config
,
1750 (void *)&cmd_config_rss_hash_key_port_id
,
1751 (void *)&cmd_config_rss_hash_key_rss_hash_key
,
1752 (void *)&cmd_config_rss_hash_key_rss_type
,
1753 (void *)&cmd_config_rss_hash_key_value
,
1758 /* *** configure port rxq/txq start/stop *** */
1759 struct cmd_config_rxtx_queue
{
1760 cmdline_fixed_string_t port
;
1762 cmdline_fixed_string_t rxtxq
;
1764 cmdline_fixed_string_t opname
;
1768 cmd_config_rxtx_queue_parsed(void *parsed_result
,
1769 __attribute__((unused
)) struct cmdline
*cl
,
1770 __attribute__((unused
)) void *data
)
1772 struct cmd_config_rxtx_queue
*res
= parsed_result
;
1777 if (test_done
== 0) {
1778 printf("Please stop forwarding first\n");
1782 if (port_id_is_invalid(res
->portid
, ENABLED_WARN
))
1785 if (port_is_started(res
->portid
) != 1) {
1786 printf("Please start port %u first\n", res
->portid
);
1790 if (!strcmp(res
->rxtxq
, "rxq"))
1792 else if (!strcmp(res
->rxtxq
, "txq"))
1795 printf("Unknown parameter\n");
1799 if (isrx
&& rx_queue_id_is_invalid(res
->qid
))
1801 else if (!isrx
&& tx_queue_id_is_invalid(res
->qid
))
1804 if (!strcmp(res
->opname
, "start"))
1806 else if (!strcmp(res
->opname
, "stop"))
1809 printf("Unknown parameter\n");
1813 if (isstart
&& isrx
)
1814 ret
= rte_eth_dev_rx_queue_start(res
->portid
, res
->qid
);
1815 else if (!isstart
&& isrx
)
1816 ret
= rte_eth_dev_rx_queue_stop(res
->portid
, res
->qid
);
1817 else if (isstart
&& !isrx
)
1818 ret
= rte_eth_dev_tx_queue_start(res
->portid
, res
->qid
);
1820 ret
= rte_eth_dev_tx_queue_stop(res
->portid
, res
->qid
);
1822 if (ret
== -ENOTSUP
)
1823 printf("Function not supported in PMD driver\n");
1826 cmdline_parse_token_string_t cmd_config_rxtx_queue_port
=
1827 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue
, port
, "port");
1828 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid
=
1829 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue
, portid
, UINT8
);
1830 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq
=
1831 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue
, rxtxq
, "rxq#txq");
1832 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid
=
1833 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue
, qid
, UINT16
);
1834 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname
=
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue
, opname
,
1838 cmdline_parse_inst_t cmd_config_rxtx_queue
= {
1839 .f
= cmd_config_rxtx_queue_parsed
,
1841 .help_str
= "port X rxq|txq ID start|stop",
1843 (void *)&cmd_config_speed_all_port
,
1844 (void *)&cmd_config_rxtx_queue_portid
,
1845 (void *)&cmd_config_rxtx_queue_rxtxq
,
1846 (void *)&cmd_config_rxtx_queue_qid
,
1847 (void *)&cmd_config_rxtx_queue_opname
,
1852 /* *** Configure RSS RETA *** */
1853 struct cmd_config_rss_reta
{
1854 cmdline_fixed_string_t port
;
1855 cmdline_fixed_string_t keyword
;
1857 cmdline_fixed_string_t name
;
1858 cmdline_fixed_string_t list_name
;
1859 cmdline_fixed_string_t list_of_items
;
1863 parse_reta_config(const char *str
,
1864 struct rte_eth_rss_reta_entry64
*reta_conf
,
1865 uint16_t nb_entries
)
1869 uint16_t hash_index
, idx
, shift
;
1872 const char *p
, *p0
= str
;
1879 unsigned long int_fld
[_NUM_FLD
];
1880 char *str_fld
[_NUM_FLD
];
1882 while ((p
= strchr(p0
,'(')) != NULL
) {
1884 if((p0
= strchr(p
,')')) == NULL
)
1888 if(size
>= sizeof(s
))
1891 snprintf(s
, sizeof(s
), "%.*s", size
, p
);
1892 if (rte_strsplit(s
, sizeof(s
), str_fld
, _NUM_FLD
, ',') != _NUM_FLD
)
1894 for (i
= 0; i
< _NUM_FLD
; i
++) {
1896 int_fld
[i
] = strtoul(str_fld
[i
], &end
, 0);
1897 if (errno
!= 0 || end
== str_fld
[i
] ||
1902 hash_index
= (uint16_t)int_fld
[FLD_HASH_INDEX
];
1903 nb_queue
= (uint16_t)int_fld
[FLD_QUEUE
];
1905 if (hash_index
>= nb_entries
) {
1906 printf("Invalid RETA hash index=%d\n", hash_index
);
1910 idx
= hash_index
/ RTE_RETA_GROUP_SIZE
;
1911 shift
= hash_index
% RTE_RETA_GROUP_SIZE
;
1912 reta_conf
[idx
].mask
|= (1ULL << shift
);
1913 reta_conf
[idx
].reta
[shift
] = nb_queue
;
1920 cmd_set_rss_reta_parsed(void *parsed_result
,
1921 __attribute__((unused
)) struct cmdline
*cl
,
1922 __attribute__((unused
)) void *data
)
1925 struct rte_eth_dev_info dev_info
;
1926 struct rte_eth_rss_reta_entry64 reta_conf
[8];
1927 struct cmd_config_rss_reta
*res
= parsed_result
;
1929 memset(&dev_info
, 0, sizeof(dev_info
));
1930 rte_eth_dev_info_get(res
->port_id
, &dev_info
);
1931 if (dev_info
.reta_size
== 0) {
1932 printf("Redirection table size is 0 which is "
1933 "invalid for RSS\n");
1936 printf("The reta size of port %d is %u\n",
1937 res
->port_id
, dev_info
.reta_size
);
1938 if (dev_info
.reta_size
> ETH_RSS_RETA_SIZE_512
) {
1939 printf("Currently do not support more than %u entries of "
1940 "redirection table\n", ETH_RSS_RETA_SIZE_512
);
1944 memset(reta_conf
, 0, sizeof(reta_conf
));
1945 if (!strcmp(res
->list_name
, "reta")) {
1946 if (parse_reta_config(res
->list_of_items
, reta_conf
,
1947 dev_info
.reta_size
)) {
1948 printf("Invalid RSS Redirection Table "
1949 "config entered\n");
1952 ret
= rte_eth_dev_rss_reta_update(res
->port_id
,
1953 reta_conf
, dev_info
.reta_size
);
1955 printf("Bad redirection table parameter, "
1956 "return code = %d \n", ret
);
1960 cmdline_parse_token_string_t cmd_config_rss_reta_port
=
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta
, port
, "port");
1962 cmdline_parse_token_string_t cmd_config_rss_reta_keyword
=
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta
, keyword
, "config");
1964 cmdline_parse_token_num_t cmd_config_rss_reta_port_id
=
1965 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta
, port_id
, UINT8
);
1966 cmdline_parse_token_string_t cmd_config_rss_reta_name
=
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta
, name
, "rss");
1968 cmdline_parse_token_string_t cmd_config_rss_reta_list_name
=
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta
, list_name
, "reta");
1970 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items
=
1971 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta
, list_of_items
,
1973 cmdline_parse_inst_t cmd_config_rss_reta
= {
1974 .f
= cmd_set_rss_reta_parsed
,
1976 .help_str
= "port config X rss reta (hash,queue)[,(hash,queue)]",
1978 (void *)&cmd_config_rss_reta_port
,
1979 (void *)&cmd_config_rss_reta_keyword
,
1980 (void *)&cmd_config_rss_reta_port_id
,
1981 (void *)&cmd_config_rss_reta_name
,
1982 (void *)&cmd_config_rss_reta_list_name
,
1983 (void *)&cmd_config_rss_reta_list_of_items
,
1988 /* *** SHOW PORT RETA INFO *** */
1989 struct cmd_showport_reta
{
1990 cmdline_fixed_string_t show
;
1991 cmdline_fixed_string_t port
;
1993 cmdline_fixed_string_t rss
;
1994 cmdline_fixed_string_t reta
;
1996 cmdline_fixed_string_t list_of_items
;
2000 showport_parse_reta_config(struct rte_eth_rss_reta_entry64
*conf
,
2001 uint16_t nb_entries
,
2005 const char *p
, *p0
= str
;
2009 uint16_t i
, num
= nb_entries
/ RTE_RETA_GROUP_SIZE
;
2012 p
= strchr(p0
, '(');
2016 p0
= strchr(p
, ')');
2020 if (size
>= sizeof(s
)) {
2021 printf("The string size exceeds the internal buffer size\n");
2024 snprintf(s
, sizeof(s
), "%.*s", size
, p
);
2025 ret
= rte_strsplit(s
, sizeof(s
), str_fld
, num
, ',');
2026 if (ret
<= 0 || ret
!= num
) {
2027 printf("The bits of masks do not match the number of "
2028 "reta entries: %u\n", num
);
2031 for (i
= 0; i
< ret
; i
++)
2032 conf
[i
].mask
= (uint64_t)strtoul(str_fld
[i
], &end
, 0);
2038 cmd_showport_reta_parsed(void *parsed_result
,
2039 __attribute__((unused
)) struct cmdline
*cl
,
2040 __attribute__((unused
)) void *data
)
2042 struct cmd_showport_reta
*res
= parsed_result
;
2043 struct rte_eth_rss_reta_entry64 reta_conf
[8];
2044 struct rte_eth_dev_info dev_info
;
2046 memset(&dev_info
, 0, sizeof(dev_info
));
2047 rte_eth_dev_info_get(res
->port_id
, &dev_info
);
2048 if (dev_info
.reta_size
== 0 || res
->size
!= dev_info
.reta_size
||
2049 res
->size
> ETH_RSS_RETA_SIZE_512
) {
2050 printf("Invalid redirection table size: %u\n", res
->size
);
2054 memset(reta_conf
, 0, sizeof(reta_conf
));
2055 if (showport_parse_reta_config(reta_conf
, res
->size
,
2056 res
->list_of_items
) < 0) {
2057 printf("Invalid string: %s for reta masks\n",
2058 res
->list_of_items
);
2061 port_rss_reta_info(res
->port_id
, reta_conf
, res
->size
);
2064 cmdline_parse_token_string_t cmd_showport_reta_show
=
2065 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta
, show
, "show");
2066 cmdline_parse_token_string_t cmd_showport_reta_port
=
2067 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta
, port
, "port");
2068 cmdline_parse_token_num_t cmd_showport_reta_port_id
=
2069 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta
, port_id
, UINT8
);
2070 cmdline_parse_token_string_t cmd_showport_reta_rss
=
2071 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta
, rss
, "rss");
2072 cmdline_parse_token_string_t cmd_showport_reta_reta
=
2073 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta
, reta
, "reta");
2074 cmdline_parse_token_num_t cmd_showport_reta_size
=
2075 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta
, size
, UINT16
);
2076 cmdline_parse_token_string_t cmd_showport_reta_list_of_items
=
2077 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta
,
2078 list_of_items
, NULL
);
2080 cmdline_parse_inst_t cmd_showport_reta
= {
2081 .f
= cmd_showport_reta_parsed
,
2083 .help_str
= "show port X rss reta (size) (mask0,mask1,...)",
2085 (void *)&cmd_showport_reta_show
,
2086 (void *)&cmd_showport_reta_port
,
2087 (void *)&cmd_showport_reta_port_id
,
2088 (void *)&cmd_showport_reta_rss
,
2089 (void *)&cmd_showport_reta_reta
,
2090 (void *)&cmd_showport_reta_size
,
2091 (void *)&cmd_showport_reta_list_of_items
,
2096 /* *** Show RSS hash configuration *** */
2097 struct cmd_showport_rss_hash
{
2098 cmdline_fixed_string_t show
;
2099 cmdline_fixed_string_t port
;
2101 cmdline_fixed_string_t rss_hash
;
2102 cmdline_fixed_string_t rss_type
;
2103 cmdline_fixed_string_t key
; /* optional argument */
2106 static void cmd_showport_rss_hash_parsed(void *parsed_result
,
2107 __attribute__((unused
)) struct cmdline
*cl
,
2110 struct cmd_showport_rss_hash
*res
= parsed_result
;
2112 port_rss_hash_conf_show(res
->port_id
, res
->rss_type
,
2113 show_rss_key
!= NULL
);
2116 cmdline_parse_token_string_t cmd_showport_rss_hash_show
=
2117 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash
, show
, "show");
2118 cmdline_parse_token_string_t cmd_showport_rss_hash_port
=
2119 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash
, port
, "port");
2120 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id
=
2121 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash
, port_id
, UINT8
);
2122 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash
=
2123 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash
, rss_hash
,
2125 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info
=
2126 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash
, rss_type
,
2127 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2128 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2129 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2130 "ipv6-tcp-ex#ipv6-udp-ex");
2131 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key
=
2132 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash
, key
, "key");
2134 cmdline_parse_inst_t cmd_showport_rss_hash
= {
2135 .f
= cmd_showport_rss_hash_parsed
,
2138 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2139 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2140 "ipv6-sctp|ipv6-other|l2-payload|"
2141 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
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
,
2156 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2157 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2158 "ipv6-sctp|ipv6-other|l2-payload|"
2159 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2161 (void *)&cmd_showport_rss_hash_show
,
2162 (void *)&cmd_showport_rss_hash_port
,
2163 (void *)&cmd_showport_rss_hash_port_id
,
2164 (void *)&cmd_showport_rss_hash_rss_hash
,
2165 (void *)&cmd_showport_rss_hash_rss_hash_info
,
2166 (void *)&cmd_showport_rss_hash_rss_key
,
2171 /* *** Configure DCB *** */
2172 struct cmd_config_dcb
{
2173 cmdline_fixed_string_t port
;
2174 cmdline_fixed_string_t config
;
2176 cmdline_fixed_string_t dcb
;
2177 cmdline_fixed_string_t vt
;
2178 cmdline_fixed_string_t vt_en
;
2180 cmdline_fixed_string_t pfc
;
2181 cmdline_fixed_string_t pfc_en
;
2185 cmd_config_dcb_parsed(void *parsed_result
,
2186 __attribute__((unused
)) struct cmdline
*cl
,
2187 __attribute__((unused
)) void *data
)
2189 struct cmd_config_dcb
*res
= parsed_result
;
2190 portid_t port_id
= res
->port_id
;
2191 struct rte_port
*port
;
2195 port
= &ports
[port_id
];
2196 /** Check if the port is not started **/
2197 if (port
->port_status
!= RTE_PORT_STOPPED
) {
2198 printf("Please stop port %d first\n", port_id
);
2202 if ((res
->num_tcs
!= ETH_4_TCS
) && (res
->num_tcs
!= ETH_8_TCS
)) {
2203 printf("The invalid number of traffic class,"
2204 " only 4 or 8 allowed.\n");
2208 if (nb_fwd_lcores
< res
->num_tcs
) {
2209 printf("nb_cores shouldn't be less than number of TCs.\n");
2212 if (!strncmp(res
->pfc_en
, "on", 2))
2217 /* DCB in VT mode */
2218 if (!strncmp(res
->vt_en
, "on", 2))
2219 ret
= init_port_dcb_config(port_id
, DCB_VT_ENABLED
,
2220 (enum rte_eth_nb_tcs
)res
->num_tcs
,
2223 ret
= init_port_dcb_config(port_id
, DCB_ENABLED
,
2224 (enum rte_eth_nb_tcs
)res
->num_tcs
,
2229 printf("Cannot initialize network ports.\n");
2233 cmd_reconfig_device_queue(port_id
, 1, 1);
2236 cmdline_parse_token_string_t cmd_config_dcb_port
=
2237 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb
, port
, "port");
2238 cmdline_parse_token_string_t cmd_config_dcb_config
=
2239 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb
, config
, "config");
2240 cmdline_parse_token_num_t cmd_config_dcb_port_id
=
2241 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb
, port_id
, UINT8
);
2242 cmdline_parse_token_string_t cmd_config_dcb_dcb
=
2243 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb
, dcb
, "dcb");
2244 cmdline_parse_token_string_t cmd_config_dcb_vt
=
2245 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb
, vt
, "vt");
2246 cmdline_parse_token_string_t cmd_config_dcb_vt_en
=
2247 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb
, vt_en
, "on#off");
2248 cmdline_parse_token_num_t cmd_config_dcb_num_tcs
=
2249 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb
, num_tcs
, UINT8
);
2250 cmdline_parse_token_string_t cmd_config_dcb_pfc
=
2251 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb
, pfc
, "pfc");
2252 cmdline_parse_token_string_t cmd_config_dcb_pfc_en
=
2253 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb
, pfc_en
, "on#off");
2255 cmdline_parse_inst_t cmd_config_dcb
= {
2256 .f
= cmd_config_dcb_parsed
,
2258 .help_str
= "port config port-id dcb vt on|off nb-tcs pfc on|off",
2260 (void *)&cmd_config_dcb_port
,
2261 (void *)&cmd_config_dcb_config
,
2262 (void *)&cmd_config_dcb_port_id
,
2263 (void *)&cmd_config_dcb_dcb
,
2264 (void *)&cmd_config_dcb_vt
,
2265 (void *)&cmd_config_dcb_vt_en
,
2266 (void *)&cmd_config_dcb_num_tcs
,
2267 (void *)&cmd_config_dcb_pfc
,
2268 (void *)&cmd_config_dcb_pfc_en
,
2273 /* *** configure number of packets per burst *** */
2274 struct cmd_config_burst
{
2275 cmdline_fixed_string_t port
;
2276 cmdline_fixed_string_t keyword
;
2277 cmdline_fixed_string_t all
;
2278 cmdline_fixed_string_t name
;
2283 cmd_config_burst_parsed(void *parsed_result
,
2284 __attribute__((unused
)) struct cmdline
*cl
,
2285 __attribute__((unused
)) void *data
)
2287 struct cmd_config_burst
*res
= parsed_result
;
2289 if (!all_ports_stopped()) {
2290 printf("Please stop all ports first\n");
2294 if (!strcmp(res
->name
, "burst")) {
2295 if (res
->value
< 1 || res
->value
> MAX_PKT_BURST
) {
2296 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST
);
2299 nb_pkt_per_burst
= res
->value
;
2301 printf("Unknown parameter\n");
2307 cmd_reconfig_device_queue(RTE_PORT_ALL
, 1, 1);
2310 cmdline_parse_token_string_t cmd_config_burst_port
=
2311 TOKEN_STRING_INITIALIZER(struct cmd_config_burst
, port
, "port");
2312 cmdline_parse_token_string_t cmd_config_burst_keyword
=
2313 TOKEN_STRING_INITIALIZER(struct cmd_config_burst
, keyword
, "config");
2314 cmdline_parse_token_string_t cmd_config_burst_all
=
2315 TOKEN_STRING_INITIALIZER(struct cmd_config_burst
, all
, "all");
2316 cmdline_parse_token_string_t cmd_config_burst_name
=
2317 TOKEN_STRING_INITIALIZER(struct cmd_config_burst
, name
, "burst");
2318 cmdline_parse_token_num_t cmd_config_burst_value
=
2319 TOKEN_NUM_INITIALIZER(struct cmd_config_burst
, value
, UINT16
);
2321 cmdline_parse_inst_t cmd_config_burst
= {
2322 .f
= cmd_config_burst_parsed
,
2324 .help_str
= "port config all burst value",
2326 (void *)&cmd_config_burst_port
,
2327 (void *)&cmd_config_burst_keyword
,
2328 (void *)&cmd_config_burst_all
,
2329 (void *)&cmd_config_burst_name
,
2330 (void *)&cmd_config_burst_value
,
2335 /* *** configure rx/tx queues *** */
2336 struct cmd_config_thresh
{
2337 cmdline_fixed_string_t port
;
2338 cmdline_fixed_string_t keyword
;
2339 cmdline_fixed_string_t all
;
2340 cmdline_fixed_string_t name
;
2345 cmd_config_thresh_parsed(void *parsed_result
,
2346 __attribute__((unused
)) struct cmdline
*cl
,
2347 __attribute__((unused
)) void *data
)
2349 struct cmd_config_thresh
*res
= parsed_result
;
2351 if (!all_ports_stopped()) {
2352 printf("Please stop all ports first\n");
2356 if (!strcmp(res
->name
, "txpt"))
2357 tx_pthresh
= res
->value
;
2358 else if(!strcmp(res
->name
, "txht"))
2359 tx_hthresh
= res
->value
;
2360 else if(!strcmp(res
->name
, "txwt"))
2361 tx_wthresh
= res
->value
;
2362 else if(!strcmp(res
->name
, "rxpt"))
2363 rx_pthresh
= res
->value
;
2364 else if(!strcmp(res
->name
, "rxht"))
2365 rx_hthresh
= res
->value
;
2366 else if(!strcmp(res
->name
, "rxwt"))
2367 rx_wthresh
= res
->value
;
2369 printf("Unknown parameter\n");
2375 cmd_reconfig_device_queue(RTE_PORT_ALL
, 1, 1);
2378 cmdline_parse_token_string_t cmd_config_thresh_port
=
2379 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh
, port
, "port");
2380 cmdline_parse_token_string_t cmd_config_thresh_keyword
=
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh
, keyword
, "config");
2382 cmdline_parse_token_string_t cmd_config_thresh_all
=
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh
, all
, "all");
2384 cmdline_parse_token_string_t cmd_config_thresh_name
=
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh
, name
,
2386 "txpt#txht#txwt#rxpt#rxht#rxwt");
2387 cmdline_parse_token_num_t cmd_config_thresh_value
=
2388 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh
, value
, UINT8
);
2390 cmdline_parse_inst_t cmd_config_thresh
= {
2391 .f
= cmd_config_thresh_parsed
,
2393 .help_str
= "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2395 (void *)&cmd_config_thresh_port
,
2396 (void *)&cmd_config_thresh_keyword
,
2397 (void *)&cmd_config_thresh_all
,
2398 (void *)&cmd_config_thresh_name
,
2399 (void *)&cmd_config_thresh_value
,
2404 /* *** configure free/rs threshold *** */
2405 struct cmd_config_threshold
{
2406 cmdline_fixed_string_t port
;
2407 cmdline_fixed_string_t keyword
;
2408 cmdline_fixed_string_t all
;
2409 cmdline_fixed_string_t name
;
2414 cmd_config_threshold_parsed(void *parsed_result
,
2415 __attribute__((unused
)) struct cmdline
*cl
,
2416 __attribute__((unused
)) void *data
)
2418 struct cmd_config_threshold
*res
= parsed_result
;
2420 if (!all_ports_stopped()) {
2421 printf("Please stop all ports first\n");
2425 if (!strcmp(res
->name
, "txfreet"))
2426 tx_free_thresh
= res
->value
;
2427 else if (!strcmp(res
->name
, "txrst"))
2428 tx_rs_thresh
= res
->value
;
2429 else if (!strcmp(res
->name
, "rxfreet"))
2430 rx_free_thresh
= res
->value
;
2432 printf("Unknown parameter\n");
2438 cmd_reconfig_device_queue(RTE_PORT_ALL
, 1, 1);
2441 cmdline_parse_token_string_t cmd_config_threshold_port
=
2442 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold
, port
, "port");
2443 cmdline_parse_token_string_t cmd_config_threshold_keyword
=
2444 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold
, keyword
,
2446 cmdline_parse_token_string_t cmd_config_threshold_all
=
2447 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold
, all
, "all");
2448 cmdline_parse_token_string_t cmd_config_threshold_name
=
2449 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold
, name
,
2450 "txfreet#txrst#rxfreet");
2451 cmdline_parse_token_num_t cmd_config_threshold_value
=
2452 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold
, value
, UINT16
);
2454 cmdline_parse_inst_t cmd_config_threshold
= {
2455 .f
= cmd_config_threshold_parsed
,
2457 .help_str
= "port config all txfreet|txrst|rxfreet value",
2459 (void *)&cmd_config_threshold_port
,
2460 (void *)&cmd_config_threshold_keyword
,
2461 (void *)&cmd_config_threshold_all
,
2462 (void *)&cmd_config_threshold_name
,
2463 (void *)&cmd_config_threshold_value
,
2469 struct cmd_stop_result
{
2470 cmdline_fixed_string_t stop
;
2473 static void cmd_stop_parsed(__attribute__((unused
)) void *parsed_result
,
2474 __attribute__((unused
)) struct cmdline
*cl
,
2475 __attribute__((unused
)) void *data
)
2477 stop_packet_forwarding();
2480 cmdline_parse_token_string_t cmd_stop_stop
=
2481 TOKEN_STRING_INITIALIZER(struct cmd_stop_result
, stop
, "stop");
2483 cmdline_parse_inst_t cmd_stop
= {
2484 .f
= cmd_stop_parsed
,
2486 .help_str
= "stop - stop packet forwarding",
2488 (void *)&cmd_stop_stop
,
2493 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2496 parse_item_list(char* str
, const char* item_name
, unsigned int max_items
,
2497 unsigned int *parsed_items
, int check_unique_values
)
2499 unsigned int nb_item
;
2507 * First parse all items in the list and store their value.
2512 for (i
= 0; i
< strnlen(str
, STR_TOKEN_SIZE
); i
++) {
2514 if ((c
>= '0') && (c
<= '9')) {
2515 value
= (unsigned int) (value
* 10 + (c
- '0'));
2520 printf("character %c is not a decimal digit\n", c
);
2524 printf("No valid value before comma\n");
2527 if (nb_item
< max_items
) {
2528 parsed_items
[nb_item
] = value
;
2534 if (nb_item
>= max_items
) {
2535 printf("Number of %s = %u > %u (maximum items)\n",
2536 item_name
, nb_item
+ 1, max_items
);
2539 parsed_items
[nb_item
++] = value
;
2540 if (! check_unique_values
)
2544 * Then, check that all values in the list are differents.
2545 * No optimization here...
2547 for (i
= 0; i
< nb_item
; i
++) {
2548 for (j
= i
+ 1; j
< nb_item
; j
++) {
2549 if (parsed_items
[j
] == parsed_items
[i
]) {
2550 printf("duplicated %s %u at index %u and %u\n",
2551 item_name
, parsed_items
[i
], i
, j
);
2559 struct cmd_set_list_result
{
2560 cmdline_fixed_string_t cmd_keyword
;
2561 cmdline_fixed_string_t list_name
;
2562 cmdline_fixed_string_t list_of_items
;
2565 static void cmd_set_list_parsed(void *parsed_result
,
2566 __attribute__((unused
)) struct cmdline
*cl
,
2567 __attribute__((unused
)) void *data
)
2569 struct cmd_set_list_result
*res
;
2571 unsigned int lcorelist
[RTE_MAX_LCORE
];
2572 unsigned int portlist
[RTE_MAX_ETHPORTS
];
2574 unsigned int nb_item
;
2576 if (test_done
== 0) {
2577 printf("Please stop forwarding first\n");
2581 res
= parsed_result
;
2582 if (!strcmp(res
->list_name
, "corelist")) {
2583 nb_item
= parse_item_list(res
->list_of_items
, "core",
2585 parsed_items
.lcorelist
, 1);
2587 set_fwd_lcores_list(parsed_items
.lcorelist
, nb_item
);
2592 if (!strcmp(res
->list_name
, "portlist")) {
2593 nb_item
= parse_item_list(res
->list_of_items
, "port",
2595 parsed_items
.portlist
, 1);
2597 set_fwd_ports_list(parsed_items
.portlist
, nb_item
);
2603 cmdline_parse_token_string_t cmd_set_list_keyword
=
2604 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result
, cmd_keyword
,
2606 cmdline_parse_token_string_t cmd_set_list_name
=
2607 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result
, list_name
,
2608 "corelist#portlist");
2609 cmdline_parse_token_string_t cmd_set_list_of_items
=
2610 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result
, list_of_items
,
2613 cmdline_parse_inst_t cmd_set_fwd_list
= {
2614 .f
= cmd_set_list_parsed
,
2616 .help_str
= "set corelist|portlist x[,y]*",
2618 (void *)&cmd_set_list_keyword
,
2619 (void *)&cmd_set_list_name
,
2620 (void *)&cmd_set_list_of_items
,
2625 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2627 struct cmd_setmask_result
{
2628 cmdline_fixed_string_t set
;
2629 cmdline_fixed_string_t mask
;
2633 static void cmd_set_mask_parsed(void *parsed_result
,
2634 __attribute__((unused
)) struct cmdline
*cl
,
2635 __attribute__((unused
)) void *data
)
2637 struct cmd_setmask_result
*res
= parsed_result
;
2639 if (test_done
== 0) {
2640 printf("Please stop forwarding first\n");
2643 if (!strcmp(res
->mask
, "coremask")) {
2644 set_fwd_lcores_mask(res
->hexavalue
);
2646 } else if (!strcmp(res
->mask
, "portmask")) {
2647 set_fwd_ports_mask(res
->hexavalue
);
2652 cmdline_parse_token_string_t cmd_setmask_set
=
2653 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result
, set
, "set");
2654 cmdline_parse_token_string_t cmd_setmask_mask
=
2655 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result
, mask
,
2656 "coremask#portmask");
2657 cmdline_parse_token_num_t cmd_setmask_value
=
2658 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result
, hexavalue
, UINT64
);
2660 cmdline_parse_inst_t cmd_set_fwd_mask
= {
2661 .f
= cmd_set_mask_parsed
,
2663 .help_str
= "set coremask|portmask hexadecimal value",
2665 (void *)&cmd_setmask_set
,
2666 (void *)&cmd_setmask_mask
,
2667 (void *)&cmd_setmask_value
,
2673 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2675 struct cmd_set_result
{
2676 cmdline_fixed_string_t set
;
2677 cmdline_fixed_string_t what
;
2681 static void cmd_set_parsed(void *parsed_result
,
2682 __attribute__((unused
)) struct cmdline
*cl
,
2683 __attribute__((unused
)) void *data
)
2685 struct cmd_set_result
*res
= parsed_result
;
2686 if (!strcmp(res
->what
, "nbport")) {
2687 set_fwd_ports_number(res
->value
);
2689 } else if (!strcmp(res
->what
, "nbcore")) {
2690 set_fwd_lcores_number(res
->value
);
2692 } else if (!strcmp(res
->what
, "burst"))
2693 set_nb_pkt_per_burst(res
->value
);
2694 else if (!strcmp(res
->what
, "verbose"))
2695 set_verbose_level(res
->value
);
2698 cmdline_parse_token_string_t cmd_set_set
=
2699 TOKEN_STRING_INITIALIZER(struct cmd_set_result
, set
, "set");
2700 cmdline_parse_token_string_t cmd_set_what
=
2701 TOKEN_STRING_INITIALIZER(struct cmd_set_result
, what
,
2702 "nbport#nbcore#burst#verbose");
2703 cmdline_parse_token_num_t cmd_set_value
=
2704 TOKEN_NUM_INITIALIZER(struct cmd_set_result
, value
, UINT16
);
2706 cmdline_parse_inst_t cmd_set_numbers
= {
2707 .f
= cmd_set_parsed
,
2709 .help_str
= "set nbport|nbcore|burst|verbose value",
2711 (void *)&cmd_set_set
,
2712 (void *)&cmd_set_what
,
2713 (void *)&cmd_set_value
,
2718 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2720 struct cmd_set_txpkts_result
{
2721 cmdline_fixed_string_t cmd_keyword
;
2722 cmdline_fixed_string_t txpkts
;
2723 cmdline_fixed_string_t seg_lengths
;
2727 cmd_set_txpkts_parsed(void *parsed_result
,
2728 __attribute__((unused
)) struct cmdline
*cl
,
2729 __attribute__((unused
)) void *data
)
2731 struct cmd_set_txpkts_result
*res
;
2732 unsigned seg_lengths
[RTE_MAX_SEGS_PER_PKT
];
2733 unsigned int nb_segs
;
2735 res
= parsed_result
;
2736 nb_segs
= parse_item_list(res
->seg_lengths
, "segment lengths",
2737 RTE_MAX_SEGS_PER_PKT
, seg_lengths
, 0);
2739 set_tx_pkt_segments(seg_lengths
, nb_segs
);
2742 cmdline_parse_token_string_t cmd_set_txpkts_keyword
=
2743 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result
,
2744 cmd_keyword
, "set");
2745 cmdline_parse_token_string_t cmd_set_txpkts_name
=
2746 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result
,
2748 cmdline_parse_token_string_t cmd_set_txpkts_lengths
=
2749 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result
,
2752 cmdline_parse_inst_t cmd_set_txpkts
= {
2753 .f
= cmd_set_txpkts_parsed
,
2755 .help_str
= "set txpkts x[,y]*",
2757 (void *)&cmd_set_txpkts_keyword
,
2758 (void *)&cmd_set_txpkts_name
,
2759 (void *)&cmd_set_txpkts_lengths
,
2764 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2766 struct cmd_set_txsplit_result
{
2767 cmdline_fixed_string_t cmd_keyword
;
2768 cmdline_fixed_string_t txsplit
;
2769 cmdline_fixed_string_t mode
;
2773 cmd_set_txsplit_parsed(void *parsed_result
,
2774 __attribute__((unused
)) struct cmdline
*cl
,
2775 __attribute__((unused
)) void *data
)
2777 struct cmd_set_txsplit_result
*res
;
2779 res
= parsed_result
;
2780 set_tx_pkt_split(res
->mode
);
2783 cmdline_parse_token_string_t cmd_set_txsplit_keyword
=
2784 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result
,
2785 cmd_keyword
, "set");
2786 cmdline_parse_token_string_t cmd_set_txsplit_name
=
2787 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result
,
2788 txsplit
, "txsplit");
2789 cmdline_parse_token_string_t cmd_set_txsplit_mode
=
2790 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result
,
2793 cmdline_parse_inst_t cmd_set_txsplit
= {
2794 .f
= cmd_set_txsplit_parsed
,
2796 .help_str
= "set txsplit on|off|rand",
2798 (void *)&cmd_set_txsplit_keyword
,
2799 (void *)&cmd_set_txsplit_name
,
2800 (void *)&cmd_set_txsplit_mode
,
2805 /* *** CONFIG TX QUEUE FLAGS *** */
2807 struct cmd_config_txqflags_result
{
2808 cmdline_fixed_string_t port
;
2809 cmdline_fixed_string_t config
;
2810 cmdline_fixed_string_t all
;
2811 cmdline_fixed_string_t what
;
2815 static void cmd_config_txqflags_parsed(void *parsed_result
,
2816 __attribute__((unused
)) struct cmdline
*cl
,
2817 __attribute__((unused
)) void *data
)
2819 struct cmd_config_txqflags_result
*res
= parsed_result
;
2821 if (!all_ports_stopped()) {
2822 printf("Please stop all ports first\n");
2826 if (strcmp(res
->what
, "txqflags")) {
2827 printf("Unknown parameter\n");
2831 if (res
->hexvalue
>= 0) {
2832 txq_flags
= res
->hexvalue
;
2834 printf("txqflags must be >= 0\n");
2840 cmd_reconfig_device_queue(RTE_PORT_ALL
, 1, 1);
2843 cmdline_parse_token_string_t cmd_config_txqflags_port
=
2844 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result
, port
,
2846 cmdline_parse_token_string_t cmd_config_txqflags_config
=
2847 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result
, config
,
2849 cmdline_parse_token_string_t cmd_config_txqflags_all
=
2850 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result
, all
,
2852 cmdline_parse_token_string_t cmd_config_txqflags_what
=
2853 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result
, what
,
2855 cmdline_parse_token_num_t cmd_config_txqflags_value
=
2856 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result
,
2859 cmdline_parse_inst_t cmd_config_txqflags
= {
2860 .f
= cmd_config_txqflags_parsed
,
2862 .help_str
= "port config all txqflags value",
2864 (void *)&cmd_config_txqflags_port
,
2865 (void *)&cmd_config_txqflags_config
,
2866 (void *)&cmd_config_txqflags_all
,
2867 (void *)&cmd_config_txqflags_what
,
2868 (void *)&cmd_config_txqflags_value
,
2873 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2874 struct cmd_rx_vlan_filter_all_result
{
2875 cmdline_fixed_string_t rx_vlan
;
2876 cmdline_fixed_string_t what
;
2877 cmdline_fixed_string_t all
;
2882 cmd_rx_vlan_filter_all_parsed(void *parsed_result
,
2883 __attribute__((unused
)) struct cmdline
*cl
,
2884 __attribute__((unused
)) void *data
)
2886 struct cmd_rx_vlan_filter_all_result
*res
= parsed_result
;
2888 if (!strcmp(res
->what
, "add"))
2889 rx_vlan_all_filter_set(res
->port_id
, 1);
2891 rx_vlan_all_filter_set(res
->port_id
, 0);
2894 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan
=
2895 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result
,
2896 rx_vlan
, "rx_vlan");
2897 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what
=
2898 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result
,
2900 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all
=
2901 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result
,
2903 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid
=
2904 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result
,
2907 cmdline_parse_inst_t cmd_rx_vlan_filter_all
= {
2908 .f
= cmd_rx_vlan_filter_all_parsed
,
2910 .help_str
= "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
= "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
3011 " qinq(extended) for both rx/tx sides ",
3013 (void *)&cmd_vlan_offload_vlan
,
3014 (void *)&cmd_vlan_offload_set
,
3015 (void *)&cmd_vlan_offload_what
,
3016 (void *)&cmd_vlan_offload_on
,
3017 (void *)&cmd_vlan_offload_portid
,
3022 /* *** VLAN TPID SET ON A PORT *** */
3023 struct cmd_vlan_tpid_result
{
3024 cmdline_fixed_string_t vlan
;
3025 cmdline_fixed_string_t set
;
3026 cmdline_fixed_string_t vlan_type
;
3027 cmdline_fixed_string_t what
;
3033 cmd_vlan_tpid_parsed(void *parsed_result
,
3034 __attribute__((unused
)) struct cmdline
*cl
,
3035 __attribute__((unused
)) void *data
)
3037 struct cmd_vlan_tpid_result
*res
= parsed_result
;
3038 enum rte_vlan_type vlan_type
;
3040 if (!strcmp(res
->vlan_type
, "inner"))
3041 vlan_type
= ETH_VLAN_TYPE_INNER
;
3042 else if (!strcmp(res
->vlan_type
, "outer"))
3043 vlan_type
= ETH_VLAN_TYPE_OUTER
;
3045 printf("Unknown vlan type\n");
3048 vlan_tpid_set(res
->port_id
, vlan_type
, res
->tp_id
);
3051 cmdline_parse_token_string_t cmd_vlan_tpid_vlan
=
3052 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result
,
3054 cmdline_parse_token_string_t cmd_vlan_tpid_set
=
3055 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result
,
3057 cmdline_parse_token_string_t cmd_vlan_type
=
3058 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result
,
3059 vlan_type
, "inner#outer");
3060 cmdline_parse_token_string_t cmd_vlan_tpid_what
=
3061 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result
,
3063 cmdline_parse_token_num_t cmd_vlan_tpid_tpid
=
3064 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result
,
3066 cmdline_parse_token_num_t cmd_vlan_tpid_portid
=
3067 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result
,
3070 cmdline_parse_inst_t cmd_vlan_tpid
= {
3071 .f
= cmd_vlan_tpid_parsed
,
3073 .help_str
= "set inner|outer tpid tp_id port_id, set the VLAN "
3076 (void *)&cmd_vlan_tpid_vlan
,
3077 (void *)&cmd_vlan_tpid_set
,
3078 (void *)&cmd_vlan_type
,
3079 (void *)&cmd_vlan_tpid_what
,
3080 (void *)&cmd_vlan_tpid_tpid
,
3081 (void *)&cmd_vlan_tpid_portid
,
3086 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3087 struct cmd_rx_vlan_filter_result
{
3088 cmdline_fixed_string_t rx_vlan
;
3089 cmdline_fixed_string_t what
;
3095 cmd_rx_vlan_filter_parsed(void *parsed_result
,
3096 __attribute__((unused
)) struct cmdline
*cl
,
3097 __attribute__((unused
)) void *data
)
3099 struct cmd_rx_vlan_filter_result
*res
= parsed_result
;
3101 if (!strcmp(res
->what
, "add"))
3102 rx_vft_set(res
->port_id
, res
->vlan_id
, 1);
3104 rx_vft_set(res
->port_id
, res
->vlan_id
, 0);
3107 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan
=
3108 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result
,
3109 rx_vlan
, "rx_vlan");
3110 cmdline_parse_token_string_t cmd_rx_vlan_filter_what
=
3111 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result
,
3113 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid
=
3114 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result
,
3116 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid
=
3117 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result
,
3120 cmdline_parse_inst_t cmd_rx_vlan_filter
= {
3121 .f
= cmd_rx_vlan_filter_parsed
,
3123 .help_str
= "add/remove a VLAN identifier to/from the set of VLAN "
3124 "Identifiers filtered by a port",
3126 (void *)&cmd_rx_vlan_filter_rx_vlan
,
3127 (void *)&cmd_rx_vlan_filter_what
,
3128 (void *)&cmd_rx_vlan_filter_vlanid
,
3129 (void *)&cmd_rx_vlan_filter_portid
,
3134 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3135 struct cmd_tx_vlan_set_result
{
3136 cmdline_fixed_string_t tx_vlan
;
3137 cmdline_fixed_string_t set
;
3143 cmd_tx_vlan_set_parsed(void *parsed_result
,
3144 __attribute__((unused
)) struct cmdline
*cl
,
3145 __attribute__((unused
)) void *data
)
3147 struct cmd_tx_vlan_set_result
*res
= parsed_result
;
3149 tx_vlan_set(res
->port_id
, res
->vlan_id
);
3152 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan
=
3153 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result
,
3154 tx_vlan
, "tx_vlan");
3155 cmdline_parse_token_string_t cmd_tx_vlan_set_set
=
3156 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result
,
3158 cmdline_parse_token_num_t cmd_tx_vlan_set_portid
=
3159 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result
,
3161 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid
=
3162 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result
,
3165 cmdline_parse_inst_t cmd_tx_vlan_set
= {
3166 .f
= cmd_tx_vlan_set_parsed
,
3168 .help_str
= "enable hardware insertion of a single VLAN header "
3169 "with a given TAG Identifier in packets sent on a port",
3171 (void *)&cmd_tx_vlan_set_tx_vlan
,
3172 (void *)&cmd_tx_vlan_set_set
,
3173 (void *)&cmd_tx_vlan_set_portid
,
3174 (void *)&cmd_tx_vlan_set_vlanid
,
3179 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3180 struct cmd_tx_vlan_set_qinq_result
{
3181 cmdline_fixed_string_t tx_vlan
;
3182 cmdline_fixed_string_t set
;
3185 uint16_t vlan_id_outer
;
3189 cmd_tx_vlan_set_qinq_parsed(void *parsed_result
,
3190 __attribute__((unused
)) struct cmdline
*cl
,
3191 __attribute__((unused
)) void *data
)
3193 struct cmd_tx_vlan_set_qinq_result
*res
= parsed_result
;
3195 tx_qinq_set(res
->port_id
, res
->vlan_id
, res
->vlan_id_outer
);
3198 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan
=
3199 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result
,
3200 tx_vlan
, "tx_vlan");
3201 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set
=
3202 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result
,
3204 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid
=
3205 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result
,
3207 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid
=
3208 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result
,
3210 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer
=
3211 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result
,
3212 vlan_id_outer
, UINT16
);
3214 cmdline_parse_inst_t cmd_tx_vlan_set_qinq
= {
3215 .f
= cmd_tx_vlan_set_qinq_parsed
,
3217 .help_str
= "enable hardware insertion of double VLAN header "
3218 "with given TAG Identifiers in packets sent on a port",
3220 (void *)&cmd_tx_vlan_set_qinq_tx_vlan
,
3221 (void *)&cmd_tx_vlan_set_qinq_set
,
3222 (void *)&cmd_tx_vlan_set_qinq_portid
,
3223 (void *)&cmd_tx_vlan_set_qinq_vlanid
,
3224 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer
,
3229 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3230 struct cmd_tx_vlan_set_pvid_result
{
3231 cmdline_fixed_string_t tx_vlan
;
3232 cmdline_fixed_string_t set
;
3233 cmdline_fixed_string_t pvid
;
3236 cmdline_fixed_string_t mode
;
3240 cmd_tx_vlan_set_pvid_parsed(void *parsed_result
,
3241 __attribute__((unused
)) struct cmdline
*cl
,
3242 __attribute__((unused
)) void *data
)
3244 struct cmd_tx_vlan_set_pvid_result
*res
= parsed_result
;
3246 if (strcmp(res
->mode
, "on") == 0)
3247 tx_vlan_pvid_set(res
->port_id
, res
->vlan_id
, 1);
3249 tx_vlan_pvid_set(res
->port_id
, res
->vlan_id
, 0);
3252 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan
=
3253 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result
,
3254 tx_vlan
, "tx_vlan");
3255 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set
=
3256 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result
,
3258 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid
=
3259 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result
,
3261 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id
=
3262 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result
,
3264 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id
=
3265 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result
,
3267 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode
=
3268 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result
,
3271 cmdline_parse_inst_t cmd_tx_vlan_set_pvid
= {
3272 .f
= cmd_tx_vlan_set_pvid_parsed
,
3274 .help_str
= "tx_vlan set pvid port_id vlan_id (on|off)",
3276 (void *)&cmd_tx_vlan_set_pvid_tx_vlan
,
3277 (void *)&cmd_tx_vlan_set_pvid_set
,
3278 (void *)&cmd_tx_vlan_set_pvid_pvid
,
3279 (void *)&cmd_tx_vlan_set_pvid_port_id
,
3280 (void *)&cmd_tx_vlan_set_pvid_vlan_id
,
3281 (void *)&cmd_tx_vlan_set_pvid_mode
,
3286 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3287 struct cmd_tx_vlan_reset_result
{
3288 cmdline_fixed_string_t tx_vlan
;
3289 cmdline_fixed_string_t reset
;
3294 cmd_tx_vlan_reset_parsed(void *parsed_result
,
3295 __attribute__((unused
)) struct cmdline
*cl
,
3296 __attribute__((unused
)) void *data
)
3298 struct cmd_tx_vlan_reset_result
*res
= parsed_result
;
3300 tx_vlan_reset(res
->port_id
);
3303 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan
=
3304 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result
,
3305 tx_vlan
, "tx_vlan");
3306 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset
=
3307 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result
,
3309 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid
=
3310 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result
,
3313 cmdline_parse_inst_t cmd_tx_vlan_reset
= {
3314 .f
= cmd_tx_vlan_reset_parsed
,
3316 .help_str
= "disable hardware insertion of a VLAN header in packets "
3319 (void *)&cmd_tx_vlan_reset_tx_vlan
,
3320 (void *)&cmd_tx_vlan_reset_reset
,
3321 (void *)&cmd_tx_vlan_reset_portid
,
3327 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3328 struct cmd_csum_result
{
3329 cmdline_fixed_string_t csum
;
3330 cmdline_fixed_string_t mode
;
3331 cmdline_fixed_string_t proto
;
3332 cmdline_fixed_string_t hwsw
;
3337 csum_show(int port_id
)
3339 struct rte_eth_dev_info dev_info
;
3342 ol_flags
= ports
[port_id
].tx_ol_flags
;
3343 printf("Parse tunnel is %s\n",
3344 (ol_flags
& TESTPMD_TX_OFFLOAD_PARSE_TUNNEL
) ? "on" : "off");
3345 printf("IP checksum offload is %s\n",
3346 (ol_flags
& TESTPMD_TX_OFFLOAD_IP_CKSUM
) ? "hw" : "sw");
3347 printf("UDP checksum offload is %s\n",
3348 (ol_flags
& TESTPMD_TX_OFFLOAD_UDP_CKSUM
) ? "hw" : "sw");
3349 printf("TCP checksum offload is %s\n",
3350 (ol_flags
& TESTPMD_TX_OFFLOAD_TCP_CKSUM
) ? "hw" : "sw");
3351 printf("SCTP checksum offload is %s\n",
3352 (ol_flags
& TESTPMD_TX_OFFLOAD_SCTP_CKSUM
) ? "hw" : "sw");
3353 printf("Outer-Ip checksum offload is %s\n",
3354 (ol_flags
& TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM
) ? "hw" : "sw");
3356 /* display warnings if configuration is not supported by the NIC */
3357 rte_eth_dev_info_get(port_id
, &dev_info
);
3358 if ((ol_flags
& TESTPMD_TX_OFFLOAD_IP_CKSUM
) &&
3359 (dev_info
.tx_offload_capa
& DEV_TX_OFFLOAD_IPV4_CKSUM
) == 0) {
3360 printf("Warning: hardware IP checksum enabled but not "
3361 "supported by port %d\n", port_id
);
3363 if ((ol_flags
& TESTPMD_TX_OFFLOAD_UDP_CKSUM
) &&
3364 (dev_info
.tx_offload_capa
& DEV_TX_OFFLOAD_UDP_CKSUM
) == 0) {
3365 printf("Warning: hardware UDP checksum enabled but not "
3366 "supported by port %d\n", port_id
);
3368 if ((ol_flags
& TESTPMD_TX_OFFLOAD_TCP_CKSUM
) &&
3369 (dev_info
.tx_offload_capa
& DEV_TX_OFFLOAD_TCP_CKSUM
) == 0) {
3370 printf("Warning: hardware TCP checksum enabled but not "
3371 "supported by port %d\n", port_id
);
3373 if ((ol_flags
& TESTPMD_TX_OFFLOAD_SCTP_CKSUM
) &&
3374 (dev_info
.tx_offload_capa
& DEV_TX_OFFLOAD_SCTP_CKSUM
) == 0) {
3375 printf("Warning: hardware SCTP checksum enabled but not "
3376 "supported by port %d\n", port_id
);
3378 if ((ol_flags
& TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM
) &&
3379 (dev_info
.tx_offload_capa
& DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM
) == 0) {
3380 printf("Warning: hardware outer IP checksum enabled but not "
3381 "supported by port %d\n", port_id
);
3386 cmd_csum_parsed(void *parsed_result
,
3387 __attribute__((unused
)) struct cmdline
*cl
,
3388 __attribute__((unused
)) void *data
)
3390 struct cmd_csum_result
*res
= parsed_result
;
3394 if (port_id_is_invalid(res
->port_id
, ENABLED_WARN
)) {
3395 printf("invalid port %d\n", res
->port_id
);
3399 if (!strcmp(res
->mode
, "set")) {
3401 if (!strcmp(res
->hwsw
, "hw"))
3404 if (!strcmp(res
->proto
, "ip")) {
3405 mask
= TESTPMD_TX_OFFLOAD_IP_CKSUM
;
3406 } else if (!strcmp(res
->proto
, "udp")) {
3407 mask
= TESTPMD_TX_OFFLOAD_UDP_CKSUM
;
3408 } else if (!strcmp(res
->proto
, "tcp")) {
3409 mask
= TESTPMD_TX_OFFLOAD_TCP_CKSUM
;
3410 } else if (!strcmp(res
->proto
, "sctp")) {
3411 mask
= TESTPMD_TX_OFFLOAD_SCTP_CKSUM
;
3412 } else if (!strcmp(res
->proto
, "outer-ip")) {
3413 mask
= TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM
;
3417 ports
[res
->port_id
].tx_ol_flags
|= mask
;
3419 ports
[res
->port_id
].tx_ol_flags
&= (~mask
);
3421 csum_show(res
->port_id
);
3424 cmdline_parse_token_string_t cmd_csum_csum
=
3425 TOKEN_STRING_INITIALIZER(struct cmd_csum_result
,
3427 cmdline_parse_token_string_t cmd_csum_mode
=
3428 TOKEN_STRING_INITIALIZER(struct cmd_csum_result
,
3430 cmdline_parse_token_string_t cmd_csum_proto
=
3431 TOKEN_STRING_INITIALIZER(struct cmd_csum_result
,
3432 proto
, "ip#tcp#udp#sctp#outer-ip");
3433 cmdline_parse_token_string_t cmd_csum_hwsw
=
3434 TOKEN_STRING_INITIALIZER(struct cmd_csum_result
,
3436 cmdline_parse_token_num_t cmd_csum_portid
=
3437 TOKEN_NUM_INITIALIZER(struct cmd_csum_result
,
3440 cmdline_parse_inst_t cmd_csum_set
= {
3441 .f
= cmd_csum_parsed
,
3443 .help_str
= "enable/disable hardware calculation of L3/L4 checksum when "
3444 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3446 (void *)&cmd_csum_csum
,
3447 (void *)&cmd_csum_mode
,
3448 (void *)&cmd_csum_proto
,
3449 (void *)&cmd_csum_hwsw
,
3450 (void *)&cmd_csum_portid
,
3455 cmdline_parse_token_string_t cmd_csum_mode_show
=
3456 TOKEN_STRING_INITIALIZER(struct cmd_csum_result
,
3459 cmdline_parse_inst_t cmd_csum_show
= {
3460 .f
= cmd_csum_parsed
,
3462 .help_str
= "show checksum offload configuration: csum show <port>",
3464 (void *)&cmd_csum_csum
,
3465 (void *)&cmd_csum_mode_show
,
3466 (void *)&cmd_csum_portid
,
3471 /* Enable/disable tunnel parsing */
3472 struct cmd_csum_tunnel_result
{
3473 cmdline_fixed_string_t csum
;
3474 cmdline_fixed_string_t parse
;
3475 cmdline_fixed_string_t onoff
;
3480 cmd_csum_tunnel_parsed(void *parsed_result
,
3481 __attribute__((unused
)) struct cmdline
*cl
,
3482 __attribute__((unused
)) void *data
)
3484 struct cmd_csum_tunnel_result
*res
= parsed_result
;
3486 if (port_id_is_invalid(res
->port_id
, ENABLED_WARN
))
3489 if (!strcmp(res
->onoff
, "on"))
3490 ports
[res
->port_id
].tx_ol_flags
|=
3491 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL
;
3493 ports
[res
->port_id
].tx_ol_flags
&=
3494 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL
);
3496 csum_show(res
->port_id
);
3499 cmdline_parse_token_string_t cmd_csum_tunnel_csum
=
3500 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result
,
3502 cmdline_parse_token_string_t cmd_csum_tunnel_parse
=
3503 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result
,
3504 parse
, "parse_tunnel");
3505 cmdline_parse_token_string_t cmd_csum_tunnel_onoff
=
3506 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result
,
3508 cmdline_parse_token_num_t cmd_csum_tunnel_portid
=
3509 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result
,
3512 cmdline_parse_inst_t cmd_csum_tunnel
= {
3513 .f
= cmd_csum_tunnel_parsed
,
3515 .help_str
= "enable/disable parsing of tunnels for csum engine: "
3516 "csum parse_tunnel on|off <tx-port>",
3518 (void *)&cmd_csum_tunnel_csum
,
3519 (void *)&cmd_csum_tunnel_parse
,
3520 (void *)&cmd_csum_tunnel_onoff
,
3521 (void *)&cmd_csum_tunnel_portid
,
3526 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3527 struct cmd_tso_set_result
{
3528 cmdline_fixed_string_t tso
;
3529 cmdline_fixed_string_t mode
;
3535 cmd_tso_set_parsed(void *parsed_result
,
3536 __attribute__((unused
)) struct cmdline
*cl
,
3537 __attribute__((unused
)) void *data
)
3539 struct cmd_tso_set_result
*res
= parsed_result
;
3540 struct rte_eth_dev_info dev_info
;
3542 if (port_id_is_invalid(res
->port_id
, ENABLED_WARN
))
3545 if (!strcmp(res
->mode
, "set"))
3546 ports
[res
->port_id
].tso_segsz
= res
->tso_segsz
;
3548 if (ports
[res
->port_id
].tso_segsz
== 0)
3549 printf("TSO for non-tunneled packets is disabled\n");
3551 printf("TSO segment size for non-tunneled packets is %d\n",
3552 ports
[res
->port_id
].tso_segsz
);
3554 /* display warnings if configuration is not supported by the NIC */
3555 rte_eth_dev_info_get(res
->port_id
, &dev_info
);
3556 if ((ports
[res
->port_id
].tso_segsz
!= 0) &&
3557 (dev_info
.tx_offload_capa
& DEV_TX_OFFLOAD_TCP_TSO
) == 0) {
3558 printf("Warning: TSO enabled but not "
3559 "supported by port %d\n", res
->port_id
);
3563 cmdline_parse_token_string_t cmd_tso_set_tso
=
3564 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result
,
3566 cmdline_parse_token_string_t cmd_tso_set_mode
=
3567 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result
,
3569 cmdline_parse_token_num_t cmd_tso_set_tso_segsz
=
3570 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result
,
3572 cmdline_parse_token_num_t cmd_tso_set_portid
=
3573 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result
,
3576 cmdline_parse_inst_t cmd_tso_set
= {
3577 .f
= cmd_tso_set_parsed
,
3579 .help_str
= "Set TSO segment size of non-tunneled packets "
3580 "for csum engine (0 to disable): tso set <tso_segsz> <port>",
3582 (void *)&cmd_tso_set_tso
,
3583 (void *)&cmd_tso_set_mode
,
3584 (void *)&cmd_tso_set_tso_segsz
,
3585 (void *)&cmd_tso_set_portid
,
3590 cmdline_parse_token_string_t cmd_tso_show_mode
=
3591 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result
,
3595 cmdline_parse_inst_t cmd_tso_show
= {
3596 .f
= cmd_tso_set_parsed
,
3598 .help_str
= "Show TSO segment size of non-tunneled packets "
3599 "for csum engine: tso show <port>",
3601 (void *)&cmd_tso_set_tso
,
3602 (void *)&cmd_tso_show_mode
,
3603 (void *)&cmd_tso_set_portid
,
3608 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3609 struct cmd_tunnel_tso_set_result
{
3610 cmdline_fixed_string_t tso
;
3611 cmdline_fixed_string_t mode
;
3617 check_tunnel_tso_nic_support(uint8_t port_id
)
3619 struct rte_eth_dev_info dev_info
;
3621 rte_eth_dev_info_get(port_id
, &dev_info
);
3622 if (!(dev_info
.tx_offload_capa
& DEV_TX_OFFLOAD_VXLAN_TNL_TSO
))
3623 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3624 "supported by port %d\n", port_id
);
3625 if (!(dev_info
.tx_offload_capa
& DEV_TX_OFFLOAD_GRE_TNL_TSO
))
3626 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3627 "supported by port %d\n", port_id
);
3628 if (!(dev_info
.tx_offload_capa
& DEV_TX_OFFLOAD_IPIP_TNL_TSO
))
3629 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3630 "supported by port %d\n", port_id
);
3631 if (!(dev_info
.tx_offload_capa
& DEV_TX_OFFLOAD_GENEVE_TNL_TSO
))
3632 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3633 "supported by port %d\n", port_id
);
3637 cmd_tunnel_tso_set_parsed(void *parsed_result
,
3638 __attribute__((unused
)) struct cmdline
*cl
,
3639 __attribute__((unused
)) void *data
)
3641 struct cmd_tunnel_tso_set_result
*res
= parsed_result
;
3643 if (port_id_is_invalid(res
->port_id
, ENABLED_WARN
))
3646 if (!strcmp(res
->mode
, "set"))
3647 ports
[res
->port_id
].tunnel_tso_segsz
= res
->tso_segsz
;
3649 if (ports
[res
->port_id
].tunnel_tso_segsz
== 0)
3650 printf("TSO for tunneled packets is disabled\n");
3652 printf("TSO segment size for tunneled packets is %d\n",
3653 ports
[res
->port_id
].tunnel_tso_segsz
);
3655 /* Below conditions are needed to make it work:
3656 * (1) tunnel TSO is supported by the NIC;
3657 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3659 * (3) for tunneled pkts with outer L3 of IPv4,
3660 * "csum set outer-ip" must be set to hw, because after tso,
3661 * total_len of outer IP header is changed, and the checksum
3662 * of outer IP header calculated by sw should be wrong; that
3663 * is not necessary for IPv6 tunneled pkts because there's no
3664 * checksum in IP header anymore.
3666 check_tunnel_tso_nic_support(res
->port_id
);
3668 if (!(ports
[res
->port_id
].tx_ol_flags
&
3669 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL
))
3670 printf("Warning: csum parse_tunnel must be set "
3671 "so that tunneled packets are recognized\n");
3672 if (!(ports
[res
->port_id
].tx_ol_flags
&
3673 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM
))
3674 printf("Warning: csum set outer-ip must be set to hw "
3675 "if outer L3 is IPv4; not necessary for IPv6\n");
3679 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso
=
3680 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result
,
3682 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode
=
3683 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result
,
3685 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz
=
3686 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result
,
3688 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid
=
3689 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result
,
3692 cmdline_parse_inst_t cmd_tunnel_tso_set
= {
3693 .f
= cmd_tunnel_tso_set_parsed
,
3695 .help_str
= "Set TSO segment size of tunneled packets for csum engine "
3696 "(0 to disable): tunnel_tso set <tso_segsz> <port>",
3698 (void *)&cmd_tunnel_tso_set_tso
,
3699 (void *)&cmd_tunnel_tso_set_mode
,
3700 (void *)&cmd_tunnel_tso_set_tso_segsz
,
3701 (void *)&cmd_tunnel_tso_set_portid
,
3706 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode
=
3707 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result
,
3711 cmdline_parse_inst_t cmd_tunnel_tso_show
= {
3712 .f
= cmd_tunnel_tso_set_parsed
,
3714 .help_str
= "Show TSO segment size of tunneled packets "
3715 "for csum engine: tunnel_tso show <port>",
3717 (void *)&cmd_tunnel_tso_set_tso
,
3718 (void *)&cmd_tunnel_tso_show_mode
,
3719 (void *)&cmd_tunnel_tso_set_portid
,
3724 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3725 struct cmd_set_flush_rx
{
3726 cmdline_fixed_string_t set
;
3727 cmdline_fixed_string_t flush_rx
;
3728 cmdline_fixed_string_t mode
;
3732 cmd_set_flush_rx_parsed(void *parsed_result
,
3733 __attribute__((unused
)) struct cmdline
*cl
,
3734 __attribute__((unused
)) void *data
)
3736 struct cmd_set_flush_rx
*res
= parsed_result
;
3737 no_flush_rx
= (uint8_t)((strcmp(res
->mode
, "on") == 0) ? 0 : 1);
3740 cmdline_parse_token_string_t cmd_setflushrx_set
=
3741 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx
,
3743 cmdline_parse_token_string_t cmd_setflushrx_flush_rx
=
3744 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx
,
3745 flush_rx
, "flush_rx");
3746 cmdline_parse_token_string_t cmd_setflushrx_mode
=
3747 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx
,
3751 cmdline_parse_inst_t cmd_set_flush_rx
= {
3752 .f
= cmd_set_flush_rx_parsed
,
3753 .help_str
= "set flush_rx on|off: enable/disable flush on rx streams",
3756 (void *)&cmd_setflushrx_set
,
3757 (void *)&cmd_setflushrx_flush_rx
,
3758 (void *)&cmd_setflushrx_mode
,
3763 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3764 struct cmd_set_link_check
{
3765 cmdline_fixed_string_t set
;
3766 cmdline_fixed_string_t link_check
;
3767 cmdline_fixed_string_t mode
;
3771 cmd_set_link_check_parsed(void *parsed_result
,
3772 __attribute__((unused
)) struct cmdline
*cl
,
3773 __attribute__((unused
)) void *data
)
3775 struct cmd_set_link_check
*res
= parsed_result
;
3776 no_link_check
= (uint8_t)((strcmp(res
->mode
, "on") == 0) ? 0 : 1);
3779 cmdline_parse_token_string_t cmd_setlinkcheck_set
=
3780 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check
,
3782 cmdline_parse_token_string_t cmd_setlinkcheck_link_check
=
3783 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check
,
3784 link_check
, "link_check");
3785 cmdline_parse_token_string_t cmd_setlinkcheck_mode
=
3786 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check
,
3790 cmdline_parse_inst_t cmd_set_link_check
= {
3791 .f
= cmd_set_link_check_parsed
,
3792 .help_str
= "set link_check on|off: enable/disable link status check "
3793 "when starting/stopping a port",
3796 (void *)&cmd_setlinkcheck_set
,
3797 (void *)&cmd_setlinkcheck_link_check
,
3798 (void *)&cmd_setlinkcheck_mode
,
3803 #ifdef RTE_NIC_BYPASS
3804 /* *** SET NIC BYPASS MODE *** */
3805 struct cmd_set_bypass_mode_result
{
3806 cmdline_fixed_string_t set
;
3807 cmdline_fixed_string_t bypass
;
3808 cmdline_fixed_string_t mode
;
3809 cmdline_fixed_string_t value
;
3814 cmd_set_bypass_mode_parsed(void *parsed_result
,
3815 __attribute__((unused
)) struct cmdline
*cl
,
3816 __attribute__((unused
)) void *data
)
3818 struct cmd_set_bypass_mode_result
*res
= parsed_result
;
3819 portid_t port_id
= res
->port_id
;
3820 uint32_t bypass_mode
= RTE_BYPASS_MODE_NORMAL
;
3822 if (!strcmp(res
->value
, "bypass"))
3823 bypass_mode
= RTE_BYPASS_MODE_BYPASS
;
3824 else if (!strcmp(res
->value
, "isolate"))
3825 bypass_mode
= RTE_BYPASS_MODE_ISOLATE
;
3827 bypass_mode
= RTE_BYPASS_MODE_NORMAL
;
3829 /* Set the bypass mode for the relevant port. */
3830 if (0 != rte_eth_dev_bypass_state_set(port_id
, &bypass_mode
)) {
3831 printf("\t Failed to set bypass mode for port = %d.\n", port_id
);
3835 cmdline_parse_token_string_t cmd_setbypass_mode_set
=
3836 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result
,
3838 cmdline_parse_token_string_t cmd_setbypass_mode_bypass
=
3839 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result
,
3841 cmdline_parse_token_string_t cmd_setbypass_mode_mode
=
3842 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result
,
3844 cmdline_parse_token_string_t cmd_setbypass_mode_value
=
3845 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result
,
3846 value
, "normal#bypass#isolate");
3847 cmdline_parse_token_num_t cmd_setbypass_mode_port
=
3848 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result
,
3851 cmdline_parse_inst_t cmd_set_bypass_mode
= {
3852 .f
= cmd_set_bypass_mode_parsed
,
3853 .help_str
= "set bypass mode (normal|bypass|isolate) (port_id): "
3854 "Set the NIC bypass mode for port_id",
3857 (void *)&cmd_setbypass_mode_set
,
3858 (void *)&cmd_setbypass_mode_bypass
,
3859 (void *)&cmd_setbypass_mode_mode
,
3860 (void *)&cmd_setbypass_mode_value
,
3861 (void *)&cmd_setbypass_mode_port
,
3866 /* *** SET NIC BYPASS EVENT *** */
3867 struct cmd_set_bypass_event_result
{
3868 cmdline_fixed_string_t set
;
3869 cmdline_fixed_string_t bypass
;
3870 cmdline_fixed_string_t event
;
3871 cmdline_fixed_string_t event_value
;
3872 cmdline_fixed_string_t mode
;
3873 cmdline_fixed_string_t mode_value
;
3878 cmd_set_bypass_event_parsed(void *parsed_result
,
3879 __attribute__((unused
)) struct cmdline
*cl
,
3880 __attribute__((unused
)) void *data
)
3883 struct cmd_set_bypass_event_result
*res
= parsed_result
;
3884 portid_t port_id
= res
->port_id
;
3885 uint32_t bypass_event
= RTE_BYPASS_EVENT_NONE
;
3886 uint32_t bypass_mode
= RTE_BYPASS_MODE_NORMAL
;
3888 if (!strcmp(res
->event_value
, "timeout"))
3889 bypass_event
= RTE_BYPASS_EVENT_TIMEOUT
;
3890 else if (!strcmp(res
->event_value
, "os_on"))
3891 bypass_event
= RTE_BYPASS_EVENT_OS_ON
;
3892 else if (!strcmp(res
->event_value
, "os_off"))
3893 bypass_event
= RTE_BYPASS_EVENT_OS_OFF
;
3894 else if (!strcmp(res
->event_value
, "power_on"))
3895 bypass_event
= RTE_BYPASS_EVENT_POWER_ON
;
3896 else if (!strcmp(res
->event_value
, "power_off"))
3897 bypass_event
= RTE_BYPASS_EVENT_POWER_OFF
;
3899 bypass_event
= RTE_BYPASS_EVENT_NONE
;
3901 if (!strcmp(res
->mode_value
, "bypass"))
3902 bypass_mode
= RTE_BYPASS_MODE_BYPASS
;
3903 else if (!strcmp(res
->mode_value
, "isolate"))
3904 bypass_mode
= RTE_BYPASS_MODE_ISOLATE
;
3906 bypass_mode
= RTE_BYPASS_MODE_NORMAL
;
3908 /* Set the watchdog timeout. */
3909 if (bypass_event
== RTE_BYPASS_EVENT_TIMEOUT
) {
3912 if (!RTE_BYPASS_TMT_VALID(bypass_timeout
) ||
3913 (rc
= rte_eth_dev_wd_timeout_store(port_id
,
3914 bypass_timeout
)) != 0) {
3915 printf("Failed to set timeout value %u "
3916 "for port %d, errto code: %d.\n",
3917 bypass_timeout
, port_id
, rc
);
3921 /* Set the bypass event to transition to bypass mode. */
3922 if (0 != rte_eth_dev_bypass_event_store(port_id
,
3923 bypass_event
, bypass_mode
)) {
3924 printf("\t Failed to set bypass event for port = %d.\n", port_id
);
3929 cmdline_parse_token_string_t cmd_setbypass_event_set
=
3930 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result
,
3932 cmdline_parse_token_string_t cmd_setbypass_event_bypass
=
3933 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result
,
3935 cmdline_parse_token_string_t cmd_setbypass_event_event
=
3936 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result
,
3938 cmdline_parse_token_string_t cmd_setbypass_event_event_value
=
3939 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result
,
3940 event_value
, "none#timeout#os_off#os_on#power_on#power_off");
3941 cmdline_parse_token_string_t cmd_setbypass_event_mode
=
3942 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result
,
3944 cmdline_parse_token_string_t cmd_setbypass_event_mode_value
=
3945 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result
,
3946 mode_value
, "normal#bypass#isolate");
3947 cmdline_parse_token_num_t cmd_setbypass_event_port
=
3948 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result
,
3951 cmdline_parse_inst_t cmd_set_bypass_event
= {
3952 .f
= cmd_set_bypass_event_parsed
,
3953 .help_str
= "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3954 "mode (normal|bypass|isolate) (port_id): "
3955 "Set the NIC bypass event mode for port_id",
3958 (void *)&cmd_setbypass_event_set
,
3959 (void *)&cmd_setbypass_event_bypass
,
3960 (void *)&cmd_setbypass_event_event
,
3961 (void *)&cmd_setbypass_event_event_value
,
3962 (void *)&cmd_setbypass_event_mode
,
3963 (void *)&cmd_setbypass_event_mode_value
,
3964 (void *)&cmd_setbypass_event_port
,
3970 /* *** SET NIC BYPASS TIMEOUT *** */
3971 struct cmd_set_bypass_timeout_result
{
3972 cmdline_fixed_string_t set
;
3973 cmdline_fixed_string_t bypass
;
3974 cmdline_fixed_string_t timeout
;
3975 cmdline_fixed_string_t value
;
3979 cmd_set_bypass_timeout_parsed(void *parsed_result
,
3980 __attribute__((unused
)) struct cmdline
*cl
,
3981 __attribute__((unused
)) void *data
)
3983 struct cmd_set_bypass_timeout_result
*res
= parsed_result
;
3985 if (!strcmp(res
->value
, "1.5"))
3986 bypass_timeout
= RTE_BYPASS_TMT_1_5_SEC
;
3987 else if (!strcmp(res
->value
, "2"))
3988 bypass_timeout
= RTE_BYPASS_TMT_2_SEC
;
3989 else if (!strcmp(res
->value
, "3"))
3990 bypass_timeout
= RTE_BYPASS_TMT_3_SEC
;
3991 else if (!strcmp(res
->value
, "4"))
3992 bypass_timeout
= RTE_BYPASS_TMT_4_SEC
;
3993 else if (!strcmp(res
->value
, "8"))
3994 bypass_timeout
= RTE_BYPASS_TMT_8_SEC
;
3995 else if (!strcmp(res
->value
, "16"))
3996 bypass_timeout
= RTE_BYPASS_TMT_16_SEC
;
3997 else if (!strcmp(res
->value
, "32"))
3998 bypass_timeout
= RTE_BYPASS_TMT_32_SEC
;
4000 bypass_timeout
= RTE_BYPASS_TMT_OFF
;
4003 cmdline_parse_token_string_t cmd_setbypass_timeout_set
=
4004 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result
,
4006 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass
=
4007 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result
,
4009 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout
=
4010 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result
,
4011 timeout
, "timeout");
4012 cmdline_parse_token_string_t cmd_setbypass_timeout_value
=
4013 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result
,
4014 value
, "0#1.5#2#3#4#8#16#32");
4016 cmdline_parse_inst_t cmd_set_bypass_timeout
= {
4017 .f
= cmd_set_bypass_timeout_parsed
,
4018 .help_str
= "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
4019 "Set the NIC bypass watchdog timeout",
4022 (void *)&cmd_setbypass_timeout_set
,
4023 (void *)&cmd_setbypass_timeout_bypass
,
4024 (void *)&cmd_setbypass_timeout_timeout
,
4025 (void *)&cmd_setbypass_timeout_value
,
4030 /* *** SHOW NIC BYPASS MODE *** */
4031 struct cmd_show_bypass_config_result
{
4032 cmdline_fixed_string_t show
;
4033 cmdline_fixed_string_t bypass
;
4034 cmdline_fixed_string_t config
;
4039 cmd_show_bypass_config_parsed(void *parsed_result
,
4040 __attribute__((unused
)) struct cmdline
*cl
,
4041 __attribute__((unused
)) void *data
)
4043 struct cmd_show_bypass_config_result
*res
= parsed_result
;
4044 uint32_t event_mode
;
4045 uint32_t bypass_mode
;
4046 portid_t port_id
= res
->port_id
;
4047 uint32_t timeout
= bypass_timeout
;
4050 static const char * const timeouts
[RTE_BYPASS_TMT_NUM
] =
4051 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4052 static const char * const modes
[RTE_BYPASS_MODE_NUM
] =
4053 {"UNKNOWN", "normal", "bypass", "isolate"};
4054 static const char * const events
[RTE_BYPASS_EVENT_NUM
] = {
4061 int num_events
= (sizeof events
) / (sizeof events
[0]);
4063 /* Display the bypass mode.*/
4064 if (0 != rte_eth_dev_bypass_state_show(port_id
, &bypass_mode
)) {
4065 printf("\tFailed to get bypass mode for port = %d\n", port_id
);
4069 if (!RTE_BYPASS_MODE_VALID(bypass_mode
))
4070 bypass_mode
= RTE_BYPASS_MODE_NONE
;
4072 printf("\tbypass mode = %s\n", modes
[bypass_mode
]);
4075 /* Display the bypass timeout.*/
4076 if (!RTE_BYPASS_TMT_VALID(timeout
))
4077 timeout
= RTE_BYPASS_TMT_OFF
;
4079 printf("\tbypass timeout = %s\n", timeouts
[timeout
]);
4081 /* Display the bypass events and associated modes. */
4082 for (i
= RTE_BYPASS_EVENT_START
; i
< num_events
; i
++) {
4084 if (0 != rte_eth_dev_bypass_event_show(port_id
, i
, &event_mode
)) {
4085 printf("\tFailed to get bypass mode for event = %s\n",
4088 if (!RTE_BYPASS_MODE_VALID(event_mode
))
4089 event_mode
= RTE_BYPASS_MODE_NONE
;
4091 printf("\tbypass event: %-16s = %s\n", events
[i
],
4097 cmdline_parse_token_string_t cmd_showbypass_config_show
=
4098 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result
,
4100 cmdline_parse_token_string_t cmd_showbypass_config_bypass
=
4101 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result
,
4103 cmdline_parse_token_string_t cmd_showbypass_config_config
=
4104 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result
,
4106 cmdline_parse_token_num_t cmd_showbypass_config_port
=
4107 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result
,
4110 cmdline_parse_inst_t cmd_show_bypass_config
= {
4111 .f
= cmd_show_bypass_config_parsed
,
4112 .help_str
= "show bypass config (port_id): "
4113 "Show the NIC bypass config for port_id",
4116 (void *)&cmd_showbypass_config_show
,
4117 (void *)&cmd_showbypass_config_bypass
,
4118 (void *)&cmd_showbypass_config_config
,
4119 (void *)&cmd_showbypass_config_port
,
4125 #ifdef RTE_LIBRTE_PMD_BOND
4126 /* *** SET BONDING MODE *** */
4127 struct cmd_set_bonding_mode_result
{
4128 cmdline_fixed_string_t set
;
4129 cmdline_fixed_string_t bonding
;
4130 cmdline_fixed_string_t mode
;
4135 static void cmd_set_bonding_mode_parsed(void *parsed_result
,
4136 __attribute__((unused
)) struct cmdline
*cl
,
4137 __attribute__((unused
)) void *data
)
4139 struct cmd_set_bonding_mode_result
*res
= parsed_result
;
4140 portid_t port_id
= res
->port_id
;
4142 /* Set the bonding mode for the relevant port. */
4143 if (0 != rte_eth_bond_mode_set(port_id
, res
->value
))
4144 printf("\t Failed to set bonding mode for port = %d.\n", port_id
);
4147 cmdline_parse_token_string_t cmd_setbonding_mode_set
=
4148 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result
,
4150 cmdline_parse_token_string_t cmd_setbonding_mode_bonding
=
4151 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result
,
4152 bonding
, "bonding");
4153 cmdline_parse_token_string_t cmd_setbonding_mode_mode
=
4154 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result
,
4156 cmdline_parse_token_num_t cmd_setbonding_mode_value
=
4157 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result
,
4159 cmdline_parse_token_num_t cmd_setbonding_mode_port
=
4160 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result
,
4163 cmdline_parse_inst_t cmd_set_bonding_mode
= {
4164 .f
= cmd_set_bonding_mode_parsed
,
4165 .help_str
= "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
4168 (void *) &cmd_setbonding_mode_set
,
4169 (void *) &cmd_setbonding_mode_bonding
,
4170 (void *) &cmd_setbonding_mode_mode
,
4171 (void *) &cmd_setbonding_mode_value
,
4172 (void *) &cmd_setbonding_mode_port
,
4177 /* *** SET BALANCE XMIT POLICY *** */
4178 struct cmd_set_bonding_balance_xmit_policy_result
{
4179 cmdline_fixed_string_t set
;
4180 cmdline_fixed_string_t bonding
;
4181 cmdline_fixed_string_t balance_xmit_policy
;
4183 cmdline_fixed_string_t policy
;
4186 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result
,
4187 __attribute__((unused
)) struct cmdline
*cl
,
4188 __attribute__((unused
)) void *data
)
4190 struct cmd_set_bonding_balance_xmit_policy_result
*res
= parsed_result
;
4191 portid_t port_id
= res
->port_id
;
4194 if (!strcmp(res
->policy
, "l2")) {
4195 policy
= BALANCE_XMIT_POLICY_LAYER2
;
4196 } else if (!strcmp(res
->policy
, "l23")) {
4197 policy
= BALANCE_XMIT_POLICY_LAYER23
;
4198 } else if (!strcmp(res
->policy
, "l34")) {
4199 policy
= BALANCE_XMIT_POLICY_LAYER34
;
4201 printf("\t Invalid xmit policy selection");
4205 /* Set the bonding mode for the relevant port. */
4206 if (0 != rte_eth_bond_xmit_policy_set(port_id
, policy
)) {
4207 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4212 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set
=
4213 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result
,
4215 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding
=
4216 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result
,
4217 bonding
, "bonding");
4218 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy
=
4219 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result
,
4220 balance_xmit_policy
, "balance_xmit_policy");
4221 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port
=
4222 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result
,
4224 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy
=
4225 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result
,
4226 policy
, "l2#l23#l34");
4228 cmdline_parse_inst_t cmd_set_balance_xmit_policy
= {
4229 .f
= cmd_set_bonding_balance_xmit_policy_parsed
,
4230 .help_str
= "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
4233 (void *)&cmd_setbonding_balance_xmit_policy_set
,
4234 (void *)&cmd_setbonding_balance_xmit_policy_bonding
,
4235 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy
,
4236 (void *)&cmd_setbonding_balance_xmit_policy_port
,
4237 (void *)&cmd_setbonding_balance_xmit_policy_policy
,
4242 /* *** SHOW NIC BONDING CONFIGURATION *** */
4243 struct cmd_show_bonding_config_result
{
4244 cmdline_fixed_string_t show
;
4245 cmdline_fixed_string_t bonding
;
4246 cmdline_fixed_string_t config
;
4250 static void cmd_show_bonding_config_parsed(void *parsed_result
,
4251 __attribute__((unused
)) struct cmdline
*cl
,
4252 __attribute__((unused
)) void *data
)
4254 struct cmd_show_bonding_config_result
*res
= parsed_result
;
4256 uint8_t slaves
[RTE_MAX_ETHPORTS
];
4257 int num_slaves
, num_active_slaves
;
4260 portid_t port_id
= res
->port_id
;
4262 /* Display the bonding mode.*/
4263 bonding_mode
= rte_eth_bond_mode_get(port_id
);
4264 if (bonding_mode
< 0) {
4265 printf("\tFailed to get bonding mode for port = %d\n", port_id
);
4268 printf("\tBonding mode: %d\n", bonding_mode
);
4270 if (bonding_mode
== BONDING_MODE_BALANCE
) {
4271 int balance_xmit_policy
;
4273 balance_xmit_policy
= rte_eth_bond_xmit_policy_get(port_id
);
4274 if (balance_xmit_policy
< 0) {
4275 printf("\tFailed to get balance xmit policy for port = %d\n",
4279 printf("\tBalance Xmit Policy: ");
4281 switch (balance_xmit_policy
) {
4282 case BALANCE_XMIT_POLICY_LAYER2
:
4283 printf("BALANCE_XMIT_POLICY_LAYER2");
4285 case BALANCE_XMIT_POLICY_LAYER23
:
4286 printf("BALANCE_XMIT_POLICY_LAYER23");
4288 case BALANCE_XMIT_POLICY_LAYER34
:
4289 printf("BALANCE_XMIT_POLICY_LAYER34");
4296 num_slaves
= rte_eth_bond_slaves_get(port_id
, slaves
, RTE_MAX_ETHPORTS
);
4298 if (num_slaves
< 0) {
4299 printf("\tFailed to get slave list for port = %d\n", port_id
);
4302 if (num_slaves
> 0) {
4303 printf("\tSlaves (%d): [", num_slaves
);
4304 for (i
= 0; i
< num_slaves
- 1; i
++)
4305 printf("%d ", slaves
[i
]);
4307 printf("%d]\n", slaves
[num_slaves
- 1]);
4309 printf("\tSlaves: []\n");
4313 num_active_slaves
= rte_eth_bond_active_slaves_get(port_id
, slaves
,
4316 if (num_active_slaves
< 0) {
4317 printf("\tFailed to get active slave list for port = %d\n", port_id
);
4320 if (num_active_slaves
> 0) {
4321 printf("\tActive Slaves (%d): [", num_active_slaves
);
4322 for (i
= 0; i
< num_active_slaves
- 1; i
++)
4323 printf("%d ", slaves
[i
]);
4325 printf("%d]\n", slaves
[num_active_slaves
- 1]);
4328 printf("\tActive Slaves: []\n");
4332 primary_id
= rte_eth_bond_primary_get(port_id
);
4333 if (primary_id
< 0) {
4334 printf("\tFailed to get primary slave for port = %d\n", port_id
);
4337 printf("\tPrimary: [%d]\n", primary_id
);
4341 cmdline_parse_token_string_t cmd_showbonding_config_show
=
4342 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result
,
4344 cmdline_parse_token_string_t cmd_showbonding_config_bonding
=
4345 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result
,
4346 bonding
, "bonding");
4347 cmdline_parse_token_string_t cmd_showbonding_config_config
=
4348 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result
,
4350 cmdline_parse_token_num_t cmd_showbonding_config_port
=
4351 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result
,
4354 cmdline_parse_inst_t cmd_show_bonding_config
= {
4355 .f
= cmd_show_bonding_config_parsed
,
4356 .help_str
= "show bonding config (port_id): Show the bonding config for port_id",
4359 (void *)&cmd_showbonding_config_show
,
4360 (void *)&cmd_showbonding_config_bonding
,
4361 (void *)&cmd_showbonding_config_config
,
4362 (void *)&cmd_showbonding_config_port
,
4367 /* *** SET BONDING PRIMARY *** */
4368 struct cmd_set_bonding_primary_result
{
4369 cmdline_fixed_string_t set
;
4370 cmdline_fixed_string_t bonding
;
4371 cmdline_fixed_string_t primary
;
4376 static void cmd_set_bonding_primary_parsed(void *parsed_result
,
4377 __attribute__((unused
)) struct cmdline
*cl
,
4378 __attribute__((unused
)) void *data
)
4380 struct cmd_set_bonding_primary_result
*res
= parsed_result
;
4381 portid_t master_port_id
= res
->port_id
;
4382 portid_t slave_port_id
= res
->slave_id
;
4384 /* Set the primary slave for a bonded device. */
4385 if (0 != rte_eth_bond_primary_set(master_port_id
, slave_port_id
)) {
4386 printf("\t Failed to set primary slave for port = %d.\n",
4393 cmdline_parse_token_string_t cmd_setbonding_primary_set
=
4394 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result
,
4396 cmdline_parse_token_string_t cmd_setbonding_primary_bonding
=
4397 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result
,
4398 bonding
, "bonding");
4399 cmdline_parse_token_string_t cmd_setbonding_primary_primary
=
4400 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result
,
4401 primary
, "primary");
4402 cmdline_parse_token_num_t cmd_setbonding_primary_slave
=
4403 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result
,
4405 cmdline_parse_token_num_t cmd_setbonding_primary_port
=
4406 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result
,
4409 cmdline_parse_inst_t cmd_set_bonding_primary
= {
4410 .f
= cmd_set_bonding_primary_parsed
,
4411 .help_str
= "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4414 (void *)&cmd_setbonding_primary_set
,
4415 (void *)&cmd_setbonding_primary_bonding
,
4416 (void *)&cmd_setbonding_primary_primary
,
4417 (void *)&cmd_setbonding_primary_slave
,
4418 (void *)&cmd_setbonding_primary_port
,
4423 /* *** ADD SLAVE *** */
4424 struct cmd_add_bonding_slave_result
{
4425 cmdline_fixed_string_t add
;
4426 cmdline_fixed_string_t bonding
;
4427 cmdline_fixed_string_t slave
;
4432 static void cmd_add_bonding_slave_parsed(void *parsed_result
,
4433 __attribute__((unused
)) struct cmdline
*cl
,
4434 __attribute__((unused
)) void *data
)
4436 struct cmd_add_bonding_slave_result
*res
= parsed_result
;
4437 portid_t master_port_id
= res
->port_id
;
4438 portid_t slave_port_id
= res
->slave_id
;
4440 /* Set the primary slave for a bonded device. */
4441 if (0 != rte_eth_bond_slave_add(master_port_id
, slave_port_id
)) {
4442 printf("\t Failed to add slave %d to master port = %d.\n",
4443 slave_port_id
, master_port_id
);
4447 set_port_slave_flag(slave_port_id
);
4450 cmdline_parse_token_string_t cmd_addbonding_slave_add
=
4451 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result
,
4453 cmdline_parse_token_string_t cmd_addbonding_slave_bonding
=
4454 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result
,
4455 bonding
, "bonding");
4456 cmdline_parse_token_string_t cmd_addbonding_slave_slave
=
4457 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result
,
4459 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid
=
4460 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result
,
4462 cmdline_parse_token_num_t cmd_addbonding_slave_port
=
4463 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result
,
4466 cmdline_parse_inst_t cmd_add_bonding_slave
= {
4467 .f
= cmd_add_bonding_slave_parsed
,
4468 .help_str
= "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4471 (void *)&cmd_addbonding_slave_add
,
4472 (void *)&cmd_addbonding_slave_bonding
,
4473 (void *)&cmd_addbonding_slave_slave
,
4474 (void *)&cmd_addbonding_slave_slaveid
,
4475 (void *)&cmd_addbonding_slave_port
,
4480 /* *** REMOVE SLAVE *** */
4481 struct cmd_remove_bonding_slave_result
{
4482 cmdline_fixed_string_t remove
;
4483 cmdline_fixed_string_t bonding
;
4484 cmdline_fixed_string_t slave
;
4489 static void cmd_remove_bonding_slave_parsed(void *parsed_result
,
4490 __attribute__((unused
)) struct cmdline
*cl
,
4491 __attribute__((unused
)) void *data
)
4493 struct cmd_remove_bonding_slave_result
*res
= parsed_result
;
4494 portid_t master_port_id
= res
->port_id
;
4495 portid_t slave_port_id
= res
->slave_id
;
4497 /* Set the primary slave for a bonded device. */
4498 if (0 != rte_eth_bond_slave_remove(master_port_id
, slave_port_id
)) {
4499 printf("\t Failed to remove slave %d from master port = %d.\n",
4500 slave_port_id
, master_port_id
);
4504 clear_port_slave_flag(slave_port_id
);
4507 cmdline_parse_token_string_t cmd_removebonding_slave_remove
=
4508 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result
,
4510 cmdline_parse_token_string_t cmd_removebonding_slave_bonding
=
4511 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result
,
4512 bonding
, "bonding");
4513 cmdline_parse_token_string_t cmd_removebonding_slave_slave
=
4514 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result
,
4516 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid
=
4517 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result
,
4519 cmdline_parse_token_num_t cmd_removebonding_slave_port
=
4520 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result
,
4523 cmdline_parse_inst_t cmd_remove_bonding_slave
= {
4524 .f
= cmd_remove_bonding_slave_parsed
,
4525 .help_str
= "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4528 (void *)&cmd_removebonding_slave_remove
,
4529 (void *)&cmd_removebonding_slave_bonding
,
4530 (void *)&cmd_removebonding_slave_slave
,
4531 (void *)&cmd_removebonding_slave_slaveid
,
4532 (void *)&cmd_removebonding_slave_port
,
4537 /* *** CREATE BONDED DEVICE *** */
4538 struct cmd_create_bonded_device_result
{
4539 cmdline_fixed_string_t create
;
4540 cmdline_fixed_string_t bonded
;
4541 cmdline_fixed_string_t device
;
4546 static int bond_dev_num
= 0;
4548 static void cmd_create_bonded_device_parsed(void *parsed_result
,
4549 __attribute__((unused
)) struct cmdline
*cl
,
4550 __attribute__((unused
)) void *data
)
4552 struct cmd_create_bonded_device_result
*res
= parsed_result
;
4553 char ethdev_name
[RTE_ETH_NAME_MAX_LEN
];
4556 if (test_done
== 0) {
4557 printf("Please stop forwarding first\n");
4561 snprintf(ethdev_name
, RTE_ETH_NAME_MAX_LEN
, "net_bond_testpmd_%d",
4564 /* Create a new bonded device. */
4565 port_id
= rte_eth_bond_create(ethdev_name
, res
->mode
, res
->socket
);
4567 printf("\t Failed to create bonded device.\n");
4570 printf("Created new bonded device %s on (port %d).\n", ethdev_name
,
4573 /* Update number of ports */
4574 nb_ports
= rte_eth_dev_count();
4575 reconfig(port_id
, res
->socket
);
4576 rte_eth_promiscuous_enable(port_id
);
4577 ports
[port_id
].enabled
= 1;
4582 cmdline_parse_token_string_t cmd_createbonded_device_create
=
4583 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result
,
4585 cmdline_parse_token_string_t cmd_createbonded_device_bonded
=
4586 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result
,
4588 cmdline_parse_token_string_t cmd_createbonded_device_device
=
4589 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result
,
4591 cmdline_parse_token_num_t cmd_createbonded_device_mode
=
4592 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result
,
4594 cmdline_parse_token_num_t cmd_createbonded_device_socket
=
4595 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result
,
4598 cmdline_parse_inst_t cmd_create_bonded_device
= {
4599 .f
= cmd_create_bonded_device_parsed
,
4600 .help_str
= "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4603 (void *)&cmd_createbonded_device_create
,
4604 (void *)&cmd_createbonded_device_bonded
,
4605 (void *)&cmd_createbonded_device_device
,
4606 (void *)&cmd_createbonded_device_mode
,
4607 (void *)&cmd_createbonded_device_socket
,
4612 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4613 struct cmd_set_bond_mac_addr_result
{
4614 cmdline_fixed_string_t set
;
4615 cmdline_fixed_string_t bonding
;
4616 cmdline_fixed_string_t mac_addr
;
4618 struct ether_addr address
;
4621 static void cmd_set_bond_mac_addr_parsed(void *parsed_result
,
4622 __attribute__((unused
)) struct cmdline
*cl
,
4623 __attribute__((unused
)) void *data
)
4625 struct cmd_set_bond_mac_addr_result
*res
= parsed_result
;
4628 if (port_id_is_invalid(res
->port_num
, ENABLED_WARN
))
4631 ret
= rte_eth_bond_mac_address_set(res
->port_num
, &res
->address
);
4633 /* check the return value and print it if is < 0 */
4635 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret
));
4638 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set
=
4639 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result
, set
, "set");
4640 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding
=
4641 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result
, bonding
,
4643 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac
=
4644 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result
, mac_addr
,
4646 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum
=
4647 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result
, port_num
, UINT8
);
4648 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr
=
4649 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result
, address
);
4651 cmdline_parse_inst_t cmd_set_bond_mac_addr
= {
4652 .f
= cmd_set_bond_mac_addr_parsed
,
4654 .help_str
= "set bonding mac_addr (port_id) (address): ",
4656 (void *)&cmd_set_bond_mac_addr_set
,
4657 (void *)&cmd_set_bond_mac_addr_bonding
,
4658 (void *)&cmd_set_bond_mac_addr_mac
,
4659 (void *)&cmd_set_bond_mac_addr_portnum
,
4660 (void *)&cmd_set_bond_mac_addr_addr
,
4666 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4667 struct cmd_set_bond_mon_period_result
{
4668 cmdline_fixed_string_t set
;
4669 cmdline_fixed_string_t bonding
;
4670 cmdline_fixed_string_t mon_period
;
4675 static void cmd_set_bond_mon_period_parsed(void *parsed_result
,
4676 __attribute__((unused
)) struct cmdline
*cl
,
4677 __attribute__((unused
)) void *data
)
4679 struct cmd_set_bond_mon_period_result
*res
= parsed_result
;
4682 if (res
->port_num
>= nb_ports
) {
4683 printf("Port id %d must be less than %d\n", res
->port_num
, nb_ports
);
4687 ret
= rte_eth_bond_link_monitoring_set(res
->port_num
, res
->period_ms
);
4689 /* check the return value and print it if is < 0 */
4691 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret
));
4694 cmdline_parse_token_string_t cmd_set_bond_mon_period_set
=
4695 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result
,
4697 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding
=
4698 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result
,
4699 bonding
, "bonding");
4700 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period
=
4701 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result
,
4702 mon_period
, "mon_period");
4703 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum
=
4704 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result
,
4706 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms
=
4707 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result
,
4710 cmdline_parse_inst_t cmd_set_bond_mon_period
= {
4711 .f
= cmd_set_bond_mon_period_parsed
,
4713 .help_str
= "set bonding mon_period (port_id) (period_ms): ",
4715 (void *)&cmd_set_bond_mon_period_set
,
4716 (void *)&cmd_set_bond_mon_period_bonding
,
4717 (void *)&cmd_set_bond_mon_period_mon_period
,
4718 (void *)&cmd_set_bond_mon_period_portnum
,
4719 (void *)&cmd_set_bond_mon_period_period_ms
,
4724 #endif /* RTE_LIBRTE_PMD_BOND */
4726 /* *** SET FORWARDING MODE *** */
4727 struct cmd_set_fwd_mode_result
{
4728 cmdline_fixed_string_t set
;
4729 cmdline_fixed_string_t fwd
;
4730 cmdline_fixed_string_t mode
;
4733 static void cmd_set_fwd_mode_parsed(void *parsed_result
,
4734 __attribute__((unused
)) struct cmdline
*cl
,
4735 __attribute__((unused
)) void *data
)
4737 struct cmd_set_fwd_mode_result
*res
= parsed_result
;
4740 set_pkt_forwarding_mode(res
->mode
);
4743 cmdline_parse_token_string_t cmd_setfwd_set
=
4744 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result
, set
, "set");
4745 cmdline_parse_token_string_t cmd_setfwd_fwd
=
4746 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result
, fwd
, "fwd");
4747 cmdline_parse_token_string_t cmd_setfwd_mode
=
4748 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result
, mode
,
4749 "" /* defined at init */);
4751 cmdline_parse_inst_t cmd_set_fwd_mode
= {
4752 .f
= cmd_set_fwd_mode_parsed
,
4754 .help_str
= NULL
, /* defined at init */
4756 (void *)&cmd_setfwd_set
,
4757 (void *)&cmd_setfwd_fwd
,
4758 (void *)&cmd_setfwd_mode
,
4763 static void cmd_set_fwd_mode_init(void)
4766 static char token
[128];
4767 static char help
[256];
4768 cmdline_parse_token_string_t
*token_struct
;
4770 modes
= list_pkt_forwarding_modes();
4771 snprintf(help
, sizeof help
, "set fwd %s - "
4772 "set packet forwarding mode", modes
);
4773 cmd_set_fwd_mode
.help_str
= help
;
4775 /* string token separator is # */
4776 for (c
= token
; *modes
!= '\0'; modes
++)
4781 token_struct
= (cmdline_parse_token_string_t
*)cmd_set_fwd_mode
.tokens
[2];
4782 token_struct
->string_data
.str
= token
;
4785 /* *** SET RETRY FORWARDING MODE *** */
4786 struct cmd_set_fwd_retry_mode_result
{
4787 cmdline_fixed_string_t set
;
4788 cmdline_fixed_string_t fwd
;
4789 cmdline_fixed_string_t mode
;
4790 cmdline_fixed_string_t retry
;
4793 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result
,
4794 __attribute__((unused
)) struct cmdline
*cl
,
4795 __attribute__((unused
)) void *data
)
4797 struct cmd_set_fwd_retry_mode_result
*res
= parsed_result
;
4800 set_pkt_forwarding_mode(res
->mode
);
4803 cmdline_parse_token_string_t cmd_setfwd_retry_set
=
4804 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result
,
4806 cmdline_parse_token_string_t cmd_setfwd_retry_fwd
=
4807 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result
,
4809 cmdline_parse_token_string_t cmd_setfwd_retry_mode
=
4810 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result
,
4812 "" /* defined at init */);
4813 cmdline_parse_token_string_t cmd_setfwd_retry_retry
=
4814 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result
,
4817 cmdline_parse_inst_t cmd_set_fwd_retry_mode
= {
4818 .f
= cmd_set_fwd_retry_mode_parsed
,
4820 .help_str
= NULL
, /* defined at init */
4822 (void *)&cmd_setfwd_retry_set
,
4823 (void *)&cmd_setfwd_retry_fwd
,
4824 (void *)&cmd_setfwd_retry_mode
,
4825 (void *)&cmd_setfwd_retry_retry
,
4830 static void cmd_set_fwd_retry_mode_init(void)
4833 static char token
[128];
4834 static char help
[256];
4835 cmdline_parse_token_string_t
*token_struct
;
4837 modes
= list_pkt_forwarding_retry_modes();
4838 snprintf(help
, sizeof(help
), "set fwd %s retry - "
4839 "set packet forwarding mode with retry", modes
);
4840 cmd_set_fwd_retry_mode
.help_str
= help
;
4842 /* string token separator is # */
4843 for (c
= token
; *modes
!= '\0'; modes
++)
4848 token_struct
= (cmdline_parse_token_string_t
*)
4849 cmd_set_fwd_retry_mode
.tokens
[2];
4850 token_struct
->string_data
.str
= token
;
4853 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4854 struct cmd_set_burst_tx_retry_result
{
4855 cmdline_fixed_string_t set
;
4856 cmdline_fixed_string_t burst
;
4857 cmdline_fixed_string_t tx
;
4858 cmdline_fixed_string_t delay
;
4860 cmdline_fixed_string_t retry
;
4864 static void cmd_set_burst_tx_retry_parsed(void *parsed_result
,
4865 __attribute__((unused
)) struct cmdline
*cl
,
4866 __attribute__((unused
)) void *data
)
4868 struct cmd_set_burst_tx_retry_result
*res
= parsed_result
;
4870 if (!strcmp(res
->set
, "set") && !strcmp(res
->burst
, "burst")
4871 && !strcmp(res
->tx
, "tx")) {
4872 if (!strcmp(res
->delay
, "delay"))
4873 burst_tx_delay_time
= res
->time
;
4874 if (!strcmp(res
->retry
, "retry"))
4875 burst_tx_retry_num
= res
->retry_num
;
4880 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set
=
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result
, set
, "set");
4882 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst
=
4883 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result
, burst
,
4885 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx
=
4886 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result
, tx
, "tx");
4887 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay
=
4888 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result
, delay
, "delay");
4889 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time
=
4890 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result
, time
, UINT32
);
4891 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry
=
4892 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result
, retry
, "retry");
4893 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num
=
4894 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result
, retry_num
, UINT32
);
4896 cmdline_parse_inst_t cmd_set_burst_tx_retry
= {
4897 .f
= cmd_set_burst_tx_retry_parsed
,
4898 .help_str
= "set burst tx delay (time_by_useconds) retry (retry_num)",
4900 (void *)&cmd_set_burst_tx_retry_set
,
4901 (void *)&cmd_set_burst_tx_retry_burst
,
4902 (void *)&cmd_set_burst_tx_retry_tx
,
4903 (void *)&cmd_set_burst_tx_retry_delay
,
4904 (void *)&cmd_set_burst_tx_retry_time
,
4905 (void *)&cmd_set_burst_tx_retry_retry
,
4906 (void *)&cmd_set_burst_tx_retry_retry_num
,
4911 /* *** SET PROMISC MODE *** */
4912 struct cmd_set_promisc_mode_result
{
4913 cmdline_fixed_string_t set
;
4914 cmdline_fixed_string_t promisc
;
4915 cmdline_fixed_string_t port_all
; /* valid if "allports" argument == 1 */
4916 uint8_t port_num
; /* valid if "allports" argument == 0 */
4917 cmdline_fixed_string_t mode
;
4920 static void cmd_set_promisc_mode_parsed(void *parsed_result
,
4921 __attribute__((unused
)) struct cmdline
*cl
,
4924 struct cmd_set_promisc_mode_result
*res
= parsed_result
;
4928 if (!strcmp(res
->mode
, "on"))
4935 FOREACH_PORT(i
, ports
) {
4937 rte_eth_promiscuous_enable(i
);
4939 rte_eth_promiscuous_disable(i
);
4944 rte_eth_promiscuous_enable(res
->port_num
);
4946 rte_eth_promiscuous_disable(res
->port_num
);
4950 cmdline_parse_token_string_t cmd_setpromisc_set
=
4951 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result
, set
, "set");
4952 cmdline_parse_token_string_t cmd_setpromisc_promisc
=
4953 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result
, promisc
,
4955 cmdline_parse_token_string_t cmd_setpromisc_portall
=
4956 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result
, port_all
,
4958 cmdline_parse_token_num_t cmd_setpromisc_portnum
=
4959 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result
, port_num
,
4961 cmdline_parse_token_string_t cmd_setpromisc_mode
=
4962 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result
, mode
,
4965 cmdline_parse_inst_t cmd_set_promisc_mode_all
= {
4966 .f
= cmd_set_promisc_mode_parsed
,
4968 .help_str
= "set promisc all on|off: set promisc mode for all ports",
4970 (void *)&cmd_setpromisc_set
,
4971 (void *)&cmd_setpromisc_promisc
,
4972 (void *)&cmd_setpromisc_portall
,
4973 (void *)&cmd_setpromisc_mode
,
4978 cmdline_parse_inst_t cmd_set_promisc_mode_one
= {
4979 .f
= cmd_set_promisc_mode_parsed
,
4981 .help_str
= "set promisc X on|off: set promisc mode on port X",
4983 (void *)&cmd_setpromisc_set
,
4984 (void *)&cmd_setpromisc_promisc
,
4985 (void *)&cmd_setpromisc_portnum
,
4986 (void *)&cmd_setpromisc_mode
,
4991 /* *** SET ALLMULTI MODE *** */
4992 struct cmd_set_allmulti_mode_result
{
4993 cmdline_fixed_string_t set
;
4994 cmdline_fixed_string_t allmulti
;
4995 cmdline_fixed_string_t port_all
; /* valid if "allports" argument == 1 */
4996 uint8_t port_num
; /* valid if "allports" argument == 0 */
4997 cmdline_fixed_string_t mode
;
5000 static void cmd_set_allmulti_mode_parsed(void *parsed_result
,
5001 __attribute__((unused
)) struct cmdline
*cl
,
5004 struct cmd_set_allmulti_mode_result
*res
= parsed_result
;
5008 if (!strcmp(res
->mode
, "on"))
5015 FOREACH_PORT(i
, ports
) {
5017 rte_eth_allmulticast_enable(i
);
5019 rte_eth_allmulticast_disable(i
);
5024 rte_eth_allmulticast_enable(res
->port_num
);
5026 rte_eth_allmulticast_disable(res
->port_num
);
5030 cmdline_parse_token_string_t cmd_setallmulti_set
=
5031 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result
, set
, "set");
5032 cmdline_parse_token_string_t cmd_setallmulti_allmulti
=
5033 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result
, allmulti
,
5035 cmdline_parse_token_string_t cmd_setallmulti_portall
=
5036 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result
, port_all
,
5038 cmdline_parse_token_num_t cmd_setallmulti_portnum
=
5039 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result
, port_num
,
5041 cmdline_parse_token_string_t cmd_setallmulti_mode
=
5042 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result
, mode
,
5045 cmdline_parse_inst_t cmd_set_allmulti_mode_all
= {
5046 .f
= cmd_set_allmulti_mode_parsed
,
5048 .help_str
= "set allmulti all on|off: set allmulti mode for all ports",
5050 (void *)&cmd_setallmulti_set
,
5051 (void *)&cmd_setallmulti_allmulti
,
5052 (void *)&cmd_setallmulti_portall
,
5053 (void *)&cmd_setallmulti_mode
,
5058 cmdline_parse_inst_t cmd_set_allmulti_mode_one
= {
5059 .f
= cmd_set_allmulti_mode_parsed
,
5061 .help_str
= "set allmulti X on|off: set allmulti mode on port X",
5063 (void *)&cmd_setallmulti_set
,
5064 (void *)&cmd_setallmulti_allmulti
,
5065 (void *)&cmd_setallmulti_portnum
,
5066 (void *)&cmd_setallmulti_mode
,
5071 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5072 struct cmd_link_flow_ctrl_set_result
{
5073 cmdline_fixed_string_t set
;
5074 cmdline_fixed_string_t flow_ctrl
;
5075 cmdline_fixed_string_t rx
;
5076 cmdline_fixed_string_t rx_lfc_mode
;
5077 cmdline_fixed_string_t tx
;
5078 cmdline_fixed_string_t tx_lfc_mode
;
5079 cmdline_fixed_string_t mac_ctrl_frame_fwd
;
5080 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode
;
5081 cmdline_fixed_string_t autoneg_str
;
5082 cmdline_fixed_string_t autoneg
;
5083 cmdline_fixed_string_t hw_str
;
5084 uint32_t high_water
;
5085 cmdline_fixed_string_t lw_str
;
5087 cmdline_fixed_string_t pt_str
;
5088 uint16_t pause_time
;
5089 cmdline_fixed_string_t xon_str
;
5094 cmdline_parse_token_string_t cmd_lfc_set_set
=
5095 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5097 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl
=
5098 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5099 flow_ctrl
, "flow_ctrl");
5100 cmdline_parse_token_string_t cmd_lfc_set_rx
=
5101 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5103 cmdline_parse_token_string_t cmd_lfc_set_rx_mode
=
5104 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5105 rx_lfc_mode
, "on#off");
5106 cmdline_parse_token_string_t cmd_lfc_set_tx
=
5107 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5109 cmdline_parse_token_string_t cmd_lfc_set_tx_mode
=
5110 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5111 tx_lfc_mode
, "on#off");
5112 cmdline_parse_token_string_t cmd_lfc_set_high_water_str
=
5113 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5114 hw_str
, "high_water");
5115 cmdline_parse_token_num_t cmd_lfc_set_high_water
=
5116 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5117 high_water
, UINT32
);
5118 cmdline_parse_token_string_t cmd_lfc_set_low_water_str
=
5119 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5120 lw_str
, "low_water");
5121 cmdline_parse_token_num_t cmd_lfc_set_low_water
=
5122 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5124 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str
=
5125 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5126 pt_str
, "pause_time");
5127 cmdline_parse_token_num_t cmd_lfc_set_pause_time
=
5128 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5129 pause_time
, UINT16
);
5130 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str
=
5131 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5132 xon_str
, "send_xon");
5133 cmdline_parse_token_num_t cmd_lfc_set_send_xon
=
5134 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5136 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode
=
5137 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5138 mac_ctrl_frame_fwd
, "mac_ctrl_frame_fwd");
5139 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd
=
5140 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5141 mac_ctrl_frame_fwd_mode
, "on#off");
5142 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str
=
5143 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5144 autoneg_str
, "autoneg");
5145 cmdline_parse_token_string_t cmd_lfc_set_autoneg
=
5146 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5148 cmdline_parse_token_num_t cmd_lfc_set_portid
=
5149 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result
,
5152 /* forward declaration */
5154 cmd_link_flow_ctrl_set_parsed(void *parsed_result
, struct cmdline
*cl
,
5157 cmdline_parse_inst_t cmd_link_flow_control_set
= {
5158 .f
= cmd_link_flow_ctrl_set_parsed
,
5160 .help_str
= "Configure the Ethernet flow control: set flow_ctrl rx on|off \
5161 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
5162 autoneg on|off port_id",
5164 (void *)&cmd_lfc_set_set
,
5165 (void *)&cmd_lfc_set_flow_ctrl
,
5166 (void *)&cmd_lfc_set_rx
,
5167 (void *)&cmd_lfc_set_rx_mode
,
5168 (void *)&cmd_lfc_set_tx
,
5169 (void *)&cmd_lfc_set_tx_mode
,
5170 (void *)&cmd_lfc_set_high_water
,
5171 (void *)&cmd_lfc_set_low_water
,
5172 (void *)&cmd_lfc_set_pause_time
,
5173 (void *)&cmd_lfc_set_send_xon
,
5174 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode
,
5175 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd
,
5176 (void *)&cmd_lfc_set_autoneg_str
,
5177 (void *)&cmd_lfc_set_autoneg
,
5178 (void *)&cmd_lfc_set_portid
,
5183 cmdline_parse_inst_t cmd_link_flow_control_set_rx
= {
5184 .f
= cmd_link_flow_ctrl_set_parsed
,
5185 .data
= (void *)&cmd_link_flow_control_set_rx
,
5186 .help_str
= "Change rx flow control parameter: set flow_ctrl "
5187 "rx on|off port_id",
5189 (void *)&cmd_lfc_set_set
,
5190 (void *)&cmd_lfc_set_flow_ctrl
,
5191 (void *)&cmd_lfc_set_rx
,
5192 (void *)&cmd_lfc_set_rx_mode
,
5193 (void *)&cmd_lfc_set_portid
,
5198 cmdline_parse_inst_t cmd_link_flow_control_set_tx
= {
5199 .f
= cmd_link_flow_ctrl_set_parsed
,
5200 .data
= (void *)&cmd_link_flow_control_set_tx
,
5201 .help_str
= "Change tx flow control parameter: set flow_ctrl "
5202 "tx on|off port_id",
5204 (void *)&cmd_lfc_set_set
,
5205 (void *)&cmd_lfc_set_flow_ctrl
,
5206 (void *)&cmd_lfc_set_tx
,
5207 (void *)&cmd_lfc_set_tx_mode
,
5208 (void *)&cmd_lfc_set_portid
,
5213 cmdline_parse_inst_t cmd_link_flow_control_set_hw
= {
5214 .f
= cmd_link_flow_ctrl_set_parsed
,
5215 .data
= (void *)&cmd_link_flow_control_set_hw
,
5216 .help_str
= "Change high water flow control parameter: set flow_ctrl "
5217 "high_water value port_id",
5219 (void *)&cmd_lfc_set_set
,
5220 (void *)&cmd_lfc_set_flow_ctrl
,
5221 (void *)&cmd_lfc_set_high_water_str
,
5222 (void *)&cmd_lfc_set_high_water
,
5223 (void *)&cmd_lfc_set_portid
,
5228 cmdline_parse_inst_t cmd_link_flow_control_set_lw
= {
5229 .f
= cmd_link_flow_ctrl_set_parsed
,
5230 .data
= (void *)&cmd_link_flow_control_set_lw
,
5231 .help_str
= "Change low water flow control parameter: set flow_ctrl "
5232 "low_water value port_id",
5234 (void *)&cmd_lfc_set_set
,
5235 (void *)&cmd_lfc_set_flow_ctrl
,
5236 (void *)&cmd_lfc_set_low_water_str
,
5237 (void *)&cmd_lfc_set_low_water
,
5238 (void *)&cmd_lfc_set_portid
,
5243 cmdline_parse_inst_t cmd_link_flow_control_set_pt
= {
5244 .f
= cmd_link_flow_ctrl_set_parsed
,
5245 .data
= (void *)&cmd_link_flow_control_set_pt
,
5246 .help_str
= "Change pause time flow control parameter: set flow_ctrl "
5247 "pause_time value port_id",
5249 (void *)&cmd_lfc_set_set
,
5250 (void *)&cmd_lfc_set_flow_ctrl
,
5251 (void *)&cmd_lfc_set_pause_time_str
,
5252 (void *)&cmd_lfc_set_pause_time
,
5253 (void *)&cmd_lfc_set_portid
,
5258 cmdline_parse_inst_t cmd_link_flow_control_set_xon
= {
5259 .f
= cmd_link_flow_ctrl_set_parsed
,
5260 .data
= (void *)&cmd_link_flow_control_set_xon
,
5261 .help_str
= "Change send_xon flow control parameter: set flow_ctrl "
5262 "send_xon value port_id",
5264 (void *)&cmd_lfc_set_set
,
5265 (void *)&cmd_lfc_set_flow_ctrl
,
5266 (void *)&cmd_lfc_set_send_xon_str
,
5267 (void *)&cmd_lfc_set_send_xon
,
5268 (void *)&cmd_lfc_set_portid
,
5273 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd
= {
5274 .f
= cmd_link_flow_ctrl_set_parsed
,
5275 .data
= (void *)&cmd_link_flow_control_set_macfwd
,
5276 .help_str
= "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5277 "mac_ctrl_frame_fwd on|off port_id",
5279 (void *)&cmd_lfc_set_set
,
5280 (void *)&cmd_lfc_set_flow_ctrl
,
5281 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode
,
5282 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd
,
5283 (void *)&cmd_lfc_set_portid
,
5288 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg
= {
5289 .f
= cmd_link_flow_ctrl_set_parsed
,
5290 .data
= (void *)&cmd_link_flow_control_set_autoneg
,
5291 .help_str
= "Change autoneg flow control parameter: set flow_ctrl "
5292 "autoneg on|off port_id",
5294 (void *)&cmd_lfc_set_set
,
5295 (void *)&cmd_lfc_set_flow_ctrl
,
5296 (void *)&cmd_lfc_set_autoneg_str
,
5297 (void *)&cmd_lfc_set_autoneg
,
5298 (void *)&cmd_lfc_set_portid
,
5304 cmd_link_flow_ctrl_set_parsed(void *parsed_result
,
5305 __attribute__((unused
)) struct cmdline
*cl
,
5308 struct cmd_link_flow_ctrl_set_result
*res
= parsed_result
;
5309 cmdline_parse_inst_t
*cmd
= data
;
5310 struct rte_eth_fc_conf fc_conf
;
5316 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5317 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5318 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5319 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5321 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode
[2][2] = {
5322 {RTE_FC_NONE
, RTE_FC_TX_PAUSE
}, {RTE_FC_RX_PAUSE
, RTE_FC_FULL
}
5325 /* Partial command line, retrieve current configuration */
5327 ret
= rte_eth_dev_flow_ctrl_get(res
->port_id
, &fc_conf
);
5329 printf("cannot get current flow ctrl parameters, return"
5330 "code = %d\n", ret
);
5334 if ((fc_conf
.mode
== RTE_FC_RX_PAUSE
) ||
5335 (fc_conf
.mode
== RTE_FC_FULL
))
5337 if ((fc_conf
.mode
== RTE_FC_TX_PAUSE
) ||
5338 (fc_conf
.mode
== RTE_FC_FULL
))
5342 if (!cmd
|| cmd
== &cmd_link_flow_control_set_rx
)
5343 rx_fc_en
= (!strcmp(res
->rx_lfc_mode
, "on")) ? 1 : 0;
5345 if (!cmd
|| cmd
== &cmd_link_flow_control_set_tx
)
5346 tx_fc_en
= (!strcmp(res
->tx_lfc_mode
, "on")) ? 1 : 0;
5348 fc_conf
.mode
= rx_tx_onoff_2_lfc_mode
[rx_fc_en
][tx_fc_en
];
5350 if (!cmd
|| cmd
== &cmd_link_flow_control_set_hw
)
5351 fc_conf
.high_water
= res
->high_water
;
5353 if (!cmd
|| cmd
== &cmd_link_flow_control_set_lw
)
5354 fc_conf
.low_water
= res
->low_water
;
5356 if (!cmd
|| cmd
== &cmd_link_flow_control_set_pt
)
5357 fc_conf
.pause_time
= res
->pause_time
;
5359 if (!cmd
|| cmd
== &cmd_link_flow_control_set_xon
)
5360 fc_conf
.send_xon
= res
->send_xon
;
5362 if (!cmd
|| cmd
== &cmd_link_flow_control_set_macfwd
) {
5363 if (!strcmp(res
->mac_ctrl_frame_fwd_mode
, "on"))
5364 fc_conf
.mac_ctrl_frame_fwd
= 1;
5366 fc_conf
.mac_ctrl_frame_fwd
= 0;
5369 if (!cmd
|| cmd
== &cmd_link_flow_control_set_autoneg
)
5370 fc_conf
.autoneg
= (!strcmp(res
->autoneg
, "on")) ? 1 : 0;
5372 ret
= rte_eth_dev_flow_ctrl_set(res
->port_id
, &fc_conf
);
5374 printf("bad flow contrl parameter, return code = %d \n", ret
);
5377 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5378 struct cmd_priority_flow_ctrl_set_result
{
5379 cmdline_fixed_string_t set
;
5380 cmdline_fixed_string_t pfc_ctrl
;
5381 cmdline_fixed_string_t rx
;
5382 cmdline_fixed_string_t rx_pfc_mode
;
5383 cmdline_fixed_string_t tx
;
5384 cmdline_fixed_string_t tx_pfc_mode
;
5385 uint32_t high_water
;
5387 uint16_t pause_time
;
5393 cmd_priority_flow_ctrl_set_parsed(void *parsed_result
,
5394 __attribute__((unused
)) struct cmdline
*cl
,
5395 __attribute__((unused
)) void *data
)
5397 struct cmd_priority_flow_ctrl_set_result
*res
= parsed_result
;
5398 struct rte_eth_pfc_conf pfc_conf
;
5399 int rx_fc_enable
, tx_fc_enable
;
5403 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5404 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5405 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5406 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5408 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode
[2][2] = {
5409 {RTE_FC_NONE
, RTE_FC_RX_PAUSE
}, {RTE_FC_TX_PAUSE
, RTE_FC_FULL
}
5412 rx_fc_enable
= (!strncmp(res
->rx_pfc_mode
, "on",2)) ? 1 : 0;
5413 tx_fc_enable
= (!strncmp(res
->tx_pfc_mode
, "on",2)) ? 1 : 0;
5414 pfc_conf
.fc
.mode
= rx_tx_onoff_2_pfc_mode
[rx_fc_enable
][tx_fc_enable
];
5415 pfc_conf
.fc
.high_water
= res
->high_water
;
5416 pfc_conf
.fc
.low_water
= res
->low_water
;
5417 pfc_conf
.fc
.pause_time
= res
->pause_time
;
5418 pfc_conf
.priority
= res
->priority
;
5420 ret
= rte_eth_dev_priority_flow_ctrl_set(res
->port_id
, &pfc_conf
);
5422 printf("bad priority flow contrl parameter, return code = %d \n", ret
);
5425 cmdline_parse_token_string_t cmd_pfc_set_set
=
5426 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5428 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl
=
5429 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5430 pfc_ctrl
, "pfc_ctrl");
5431 cmdline_parse_token_string_t cmd_pfc_set_rx
=
5432 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5434 cmdline_parse_token_string_t cmd_pfc_set_rx_mode
=
5435 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5436 rx_pfc_mode
, "on#off");
5437 cmdline_parse_token_string_t cmd_pfc_set_tx
=
5438 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5440 cmdline_parse_token_string_t cmd_pfc_set_tx_mode
=
5441 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5442 tx_pfc_mode
, "on#off");
5443 cmdline_parse_token_num_t cmd_pfc_set_high_water
=
5444 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5445 high_water
, UINT32
);
5446 cmdline_parse_token_num_t cmd_pfc_set_low_water
=
5447 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5449 cmdline_parse_token_num_t cmd_pfc_set_pause_time
=
5450 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5451 pause_time
, UINT16
);
5452 cmdline_parse_token_num_t cmd_pfc_set_priority
=
5453 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5455 cmdline_parse_token_num_t cmd_pfc_set_portid
=
5456 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result
,
5459 cmdline_parse_inst_t cmd_priority_flow_control_set
= {
5460 .f
= cmd_priority_flow_ctrl_set_parsed
,
5462 .help_str
= "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5463 tx on|off high_water low_water pause_time priority port_id",
5465 (void *)&cmd_pfc_set_set
,
5466 (void *)&cmd_pfc_set_flow_ctrl
,
5467 (void *)&cmd_pfc_set_rx
,
5468 (void *)&cmd_pfc_set_rx_mode
,
5469 (void *)&cmd_pfc_set_tx
,
5470 (void *)&cmd_pfc_set_tx_mode
,
5471 (void *)&cmd_pfc_set_high_water
,
5472 (void *)&cmd_pfc_set_low_water
,
5473 (void *)&cmd_pfc_set_pause_time
,
5474 (void *)&cmd_pfc_set_priority
,
5475 (void *)&cmd_pfc_set_portid
,
5480 /* *** RESET CONFIGURATION *** */
5481 struct cmd_reset_result
{
5482 cmdline_fixed_string_t reset
;
5483 cmdline_fixed_string_t def
;
5486 static void cmd_reset_parsed(__attribute__((unused
)) void *parsed_result
,
5488 __attribute__((unused
)) void *data
)
5490 cmdline_printf(cl
, "Reset to default forwarding configuration...\n");
5491 set_def_fwd_config();
5494 cmdline_parse_token_string_t cmd_reset_set
=
5495 TOKEN_STRING_INITIALIZER(struct cmd_reset_result
, reset
, "set");
5496 cmdline_parse_token_string_t cmd_reset_def
=
5497 TOKEN_STRING_INITIALIZER(struct cmd_reset_result
, def
,
5500 cmdline_parse_inst_t cmd_reset
= {
5501 .f
= cmd_reset_parsed
,
5503 .help_str
= "set default: reset default forwarding configuration",
5505 (void *)&cmd_reset_set
,
5506 (void *)&cmd_reset_def
,
5511 /* *** START FORWARDING *** */
5512 struct cmd_start_result
{
5513 cmdline_fixed_string_t start
;
5516 cmdline_parse_token_string_t cmd_start_start
=
5517 TOKEN_STRING_INITIALIZER(struct cmd_start_result
, start
, "start");
5519 static void cmd_start_parsed(__attribute__((unused
)) void *parsed_result
,
5520 __attribute__((unused
)) struct cmdline
*cl
,
5521 __attribute__((unused
)) void *data
)
5523 start_packet_forwarding(0);
5526 cmdline_parse_inst_t cmd_start
= {
5527 .f
= cmd_start_parsed
,
5529 .help_str
= "start packet forwarding",
5531 (void *)&cmd_start_start
,
5536 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5537 struct cmd_start_tx_first_result
{
5538 cmdline_fixed_string_t start
;
5539 cmdline_fixed_string_t tx_first
;
5543 cmd_start_tx_first_parsed(__attribute__((unused
)) void *parsed_result
,
5544 __attribute__((unused
)) struct cmdline
*cl
,
5545 __attribute__((unused
)) void *data
)
5547 start_packet_forwarding(1);
5550 cmdline_parse_token_string_t cmd_start_tx_first_start
=
5551 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result
, start
,
5553 cmdline_parse_token_string_t cmd_start_tx_first_tx_first
=
5554 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result
,
5555 tx_first
, "tx_first");
5557 cmdline_parse_inst_t cmd_start_tx_first
= {
5558 .f
= cmd_start_tx_first_parsed
,
5560 .help_str
= "start packet forwarding, after sending 1 burst of packets",
5562 (void *)&cmd_start_tx_first_start
,
5563 (void *)&cmd_start_tx_first_tx_first
,
5568 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5569 struct cmd_start_tx_first_n_result
{
5570 cmdline_fixed_string_t start
;
5571 cmdline_fixed_string_t tx_first
;
5576 cmd_start_tx_first_n_parsed(void *parsed_result
,
5577 __attribute__((unused
)) struct cmdline
*cl
,
5578 __attribute__((unused
)) void *data
)
5580 struct cmd_start_tx_first_n_result
*res
= parsed_result
;
5582 start_packet_forwarding(res
->tx_num
);
5585 cmdline_parse_token_string_t cmd_start_tx_first_n_start
=
5586 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result
,
5588 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first
=
5589 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result
,
5590 tx_first
, "tx_first");
5591 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num
=
5592 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result
,
5595 cmdline_parse_inst_t cmd_start_tx_first_n
= {
5596 .f
= cmd_start_tx_first_n_parsed
,
5598 .help_str
= "start packet forwarding, after sending <num> "
5599 "bursts of packets",
5601 (void *)&cmd_start_tx_first_n_start
,
5602 (void *)&cmd_start_tx_first_n_tx_first
,
5603 (void *)&cmd_start_tx_first_n_tx_num
,
5608 /* *** SET LINK UP *** */
5609 struct cmd_set_link_up_result
{
5610 cmdline_fixed_string_t set
;
5611 cmdline_fixed_string_t link_up
;
5612 cmdline_fixed_string_t port
;
5616 cmdline_parse_token_string_t cmd_set_link_up_set
=
5617 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result
, set
, "set");
5618 cmdline_parse_token_string_t cmd_set_link_up_link_up
=
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result
, link_up
,
5621 cmdline_parse_token_string_t cmd_set_link_up_port
=
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result
, port
, "port");
5623 cmdline_parse_token_num_t cmd_set_link_up_port_id
=
5624 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result
, port_id
, UINT8
);
5626 static void cmd_set_link_up_parsed(__attribute__((unused
)) void *parsed_result
,
5627 __attribute__((unused
)) struct cmdline
*cl
,
5628 __attribute__((unused
)) void *data
)
5630 struct cmd_set_link_up_result
*res
= parsed_result
;
5631 dev_set_link_up(res
->port_id
);
5634 cmdline_parse_inst_t cmd_set_link_up
= {
5635 .f
= cmd_set_link_up_parsed
,
5637 .help_str
= "set link-up port (port id)",
5639 (void *)&cmd_set_link_up_set
,
5640 (void *)&cmd_set_link_up_link_up
,
5641 (void *)&cmd_set_link_up_port
,
5642 (void *)&cmd_set_link_up_port_id
,
5647 /* *** SET LINK DOWN *** */
5648 struct cmd_set_link_down_result
{
5649 cmdline_fixed_string_t set
;
5650 cmdline_fixed_string_t link_down
;
5651 cmdline_fixed_string_t port
;
5655 cmdline_parse_token_string_t cmd_set_link_down_set
=
5656 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result
, set
, "set");
5657 cmdline_parse_token_string_t cmd_set_link_down_link_down
=
5658 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result
, link_down
,
5660 cmdline_parse_token_string_t cmd_set_link_down_port
=
5661 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result
, port
, "port");
5662 cmdline_parse_token_num_t cmd_set_link_down_port_id
=
5663 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result
, port_id
, UINT8
);
5665 static void cmd_set_link_down_parsed(
5666 __attribute__((unused
)) void *parsed_result
,
5667 __attribute__((unused
)) struct cmdline
*cl
,
5668 __attribute__((unused
)) void *data
)
5670 struct cmd_set_link_down_result
*res
= parsed_result
;
5671 dev_set_link_down(res
->port_id
);
5674 cmdline_parse_inst_t cmd_set_link_down
= {
5675 .f
= cmd_set_link_down_parsed
,
5677 .help_str
= "set link-down port (port id)",
5679 (void *)&cmd_set_link_down_set
,
5680 (void *)&cmd_set_link_down_link_down
,
5681 (void *)&cmd_set_link_down_port
,
5682 (void *)&cmd_set_link_down_port_id
,
5687 /* *** SHOW CFG *** */
5688 struct cmd_showcfg_result
{
5689 cmdline_fixed_string_t show
;
5690 cmdline_fixed_string_t cfg
;
5691 cmdline_fixed_string_t what
;
5694 static void cmd_showcfg_parsed(void *parsed_result
,
5695 __attribute__((unused
)) struct cmdline
*cl
,
5696 __attribute__((unused
)) void *data
)
5698 struct cmd_showcfg_result
*res
= parsed_result
;
5699 if (!strcmp(res
->what
, "rxtx"))
5700 rxtx_config_display();
5701 else if (!strcmp(res
->what
, "cores"))
5702 fwd_lcores_config_display();
5703 else if (!strcmp(res
->what
, "fwd"))
5704 pkt_fwd_config_display(&cur_fwd_config
);
5705 else if (!strcmp(res
->what
, "txpkts"))
5706 show_tx_pkt_segments();
5709 cmdline_parse_token_string_t cmd_showcfg_show
=
5710 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result
, show
, "show");
5711 cmdline_parse_token_string_t cmd_showcfg_port
=
5712 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result
, cfg
, "config");
5713 cmdline_parse_token_string_t cmd_showcfg_what
=
5714 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result
, what
,
5715 "rxtx#cores#fwd#txpkts");
5717 cmdline_parse_inst_t cmd_showcfg
= {
5718 .f
= cmd_showcfg_parsed
,
5720 .help_str
= "show config rxtx|cores|fwd|txpkts",
5722 (void *)&cmd_showcfg_show
,
5723 (void *)&cmd_showcfg_port
,
5724 (void *)&cmd_showcfg_what
,
5729 /* *** SHOW ALL PORT INFO *** */
5730 struct cmd_showportall_result
{
5731 cmdline_fixed_string_t show
;
5732 cmdline_fixed_string_t port
;
5733 cmdline_fixed_string_t what
;
5734 cmdline_fixed_string_t all
;
5737 static void cmd_showportall_parsed(void *parsed_result
,
5738 __attribute__((unused
)) struct cmdline
*cl
,
5739 __attribute__((unused
)) void *data
)
5743 struct cmd_showportall_result
*res
= parsed_result
;
5744 if (!strcmp(res
->show
, "clear")) {
5745 if (!strcmp(res
->what
, "stats"))
5746 FOREACH_PORT(i
, ports
)
5748 else if (!strcmp(res
->what
, "xstats"))
5749 FOREACH_PORT(i
, ports
)
5750 nic_xstats_clear(i
);
5751 } else if (!strcmp(res
->what
, "info"))
5752 FOREACH_PORT(i
, ports
)
5753 port_infos_display(i
);
5754 else if (!strcmp(res
->what
, "stats"))
5755 FOREACH_PORT(i
, ports
)
5756 nic_stats_display(i
);
5757 else if (!strcmp(res
->what
, "xstats"))
5758 FOREACH_PORT(i
, ports
)
5759 nic_xstats_display(i
);
5760 else if (!strcmp(res
->what
, "fdir"))
5761 FOREACH_PORT(i
, ports
)
5763 else if (!strcmp(res
->what
, "stat_qmap"))
5764 FOREACH_PORT(i
, ports
)
5765 nic_stats_mapping_display(i
);
5766 else if (!strcmp(res
->what
, "dcb_tc"))
5767 FOREACH_PORT(i
, ports
)
5768 port_dcb_info_display(i
);
5771 cmdline_parse_token_string_t cmd_showportall_show
=
5772 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result
, show
,
5774 cmdline_parse_token_string_t cmd_showportall_port
=
5775 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result
, port
, "port");
5776 cmdline_parse_token_string_t cmd_showportall_what
=
5777 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result
, what
,
5778 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5779 cmdline_parse_token_string_t cmd_showportall_all
=
5780 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result
, all
, "all");
5781 cmdline_parse_inst_t cmd_showportall
= {
5782 .f
= cmd_showportall_parsed
,
5784 .help_str
= "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5786 (void *)&cmd_showportall_show
,
5787 (void *)&cmd_showportall_port
,
5788 (void *)&cmd_showportall_what
,
5789 (void *)&cmd_showportall_all
,
5794 /* *** SHOW PORT INFO *** */
5795 struct cmd_showport_result
{
5796 cmdline_fixed_string_t show
;
5797 cmdline_fixed_string_t port
;
5798 cmdline_fixed_string_t what
;
5802 static void cmd_showport_parsed(void *parsed_result
,
5803 __attribute__((unused
)) struct cmdline
*cl
,
5804 __attribute__((unused
)) void *data
)
5806 struct cmd_showport_result
*res
= parsed_result
;
5807 if (!strcmp(res
->show
, "clear")) {
5808 if (!strcmp(res
->what
, "stats"))
5809 nic_stats_clear(res
->portnum
);
5810 else if (!strcmp(res
->what
, "xstats"))
5811 nic_xstats_clear(res
->portnum
);
5812 } else if (!strcmp(res
->what
, "info"))
5813 port_infos_display(res
->portnum
);
5814 else if (!strcmp(res
->what
, "stats"))
5815 nic_stats_display(res
->portnum
);
5816 else if (!strcmp(res
->what
, "xstats"))
5817 nic_xstats_display(res
->portnum
);
5818 else if (!strcmp(res
->what
, "fdir"))
5819 fdir_get_infos(res
->portnum
);
5820 else if (!strcmp(res
->what
, "stat_qmap"))
5821 nic_stats_mapping_display(res
->portnum
);
5822 else if (!strcmp(res
->what
, "dcb_tc"))
5823 port_dcb_info_display(res
->portnum
);
5826 cmdline_parse_token_string_t cmd_showport_show
=
5827 TOKEN_STRING_INITIALIZER(struct cmd_showport_result
, show
,
5829 cmdline_parse_token_string_t cmd_showport_port
=
5830 TOKEN_STRING_INITIALIZER(struct cmd_showport_result
, port
, "port");
5831 cmdline_parse_token_string_t cmd_showport_what
=
5832 TOKEN_STRING_INITIALIZER(struct cmd_showport_result
, what
,
5833 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5834 cmdline_parse_token_num_t cmd_showport_portnum
=
5835 TOKEN_NUM_INITIALIZER(struct cmd_showport_result
, portnum
, UINT8
);
5837 cmdline_parse_inst_t cmd_showport
= {
5838 .f
= cmd_showport_parsed
,
5840 .help_str
= "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5842 (void *)&cmd_showport_show
,
5843 (void *)&cmd_showport_port
,
5844 (void *)&cmd_showport_what
,
5845 (void *)&cmd_showport_portnum
,
5850 /* *** SHOW QUEUE INFO *** */
5851 struct cmd_showqueue_result
{
5852 cmdline_fixed_string_t show
;
5853 cmdline_fixed_string_t type
;
5854 cmdline_fixed_string_t what
;
5860 cmd_showqueue_parsed(void *parsed_result
,
5861 __attribute__((unused
)) struct cmdline
*cl
,
5862 __attribute__((unused
)) void *data
)
5864 struct cmd_showqueue_result
*res
= parsed_result
;
5866 if (!strcmp(res
->type
, "rxq"))
5867 rx_queue_infos_display(res
->portnum
, res
->queuenum
);
5868 else if (!strcmp(res
->type
, "txq"))
5869 tx_queue_infos_display(res
->portnum
, res
->queuenum
);
5872 cmdline_parse_token_string_t cmd_showqueue_show
=
5873 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result
, show
, "show");
5874 cmdline_parse_token_string_t cmd_showqueue_type
=
5875 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result
, type
, "rxq#txq");
5876 cmdline_parse_token_string_t cmd_showqueue_what
=
5877 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result
, what
, "info");
5878 cmdline_parse_token_num_t cmd_showqueue_portnum
=
5879 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result
, portnum
, UINT8
);
5880 cmdline_parse_token_num_t cmd_showqueue_queuenum
=
5881 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result
, queuenum
, UINT16
);
5883 cmdline_parse_inst_t cmd_showqueue
= {
5884 .f
= cmd_showqueue_parsed
,
5886 .help_str
= "show rxq|txq info <port number> <queue_number>",
5888 (void *)&cmd_showqueue_show
,
5889 (void *)&cmd_showqueue_type
,
5890 (void *)&cmd_showqueue_what
,
5891 (void *)&cmd_showqueue_portnum
,
5892 (void *)&cmd_showqueue_queuenum
,
5897 /* *** READ PORT REGISTER *** */
5898 struct cmd_read_reg_result
{
5899 cmdline_fixed_string_t read
;
5900 cmdline_fixed_string_t reg
;
5906 cmd_read_reg_parsed(void *parsed_result
,
5907 __attribute__((unused
)) struct cmdline
*cl
,
5908 __attribute__((unused
)) void *data
)
5910 struct cmd_read_reg_result
*res
= parsed_result
;
5911 port_reg_display(res
->port_id
, res
->reg_off
);
5914 cmdline_parse_token_string_t cmd_read_reg_read
=
5915 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result
, read
, "read");
5916 cmdline_parse_token_string_t cmd_read_reg_reg
=
5917 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result
, reg
, "reg");
5918 cmdline_parse_token_num_t cmd_read_reg_port_id
=
5919 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result
, port_id
, UINT8
);
5920 cmdline_parse_token_num_t cmd_read_reg_reg_off
=
5921 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result
, reg_off
, UINT32
);
5923 cmdline_parse_inst_t cmd_read_reg
= {
5924 .f
= cmd_read_reg_parsed
,
5926 .help_str
= "read reg port_id reg_off",
5928 (void *)&cmd_read_reg_read
,
5929 (void *)&cmd_read_reg_reg
,
5930 (void *)&cmd_read_reg_port_id
,
5931 (void *)&cmd_read_reg_reg_off
,
5936 /* *** READ PORT REGISTER BIT FIELD *** */
5937 struct cmd_read_reg_bit_field_result
{
5938 cmdline_fixed_string_t read
;
5939 cmdline_fixed_string_t regfield
;
5947 cmd_read_reg_bit_field_parsed(void *parsed_result
,
5948 __attribute__((unused
)) struct cmdline
*cl
,
5949 __attribute__((unused
)) void *data
)
5951 struct cmd_read_reg_bit_field_result
*res
= parsed_result
;
5952 port_reg_bit_field_display(res
->port_id
, res
->reg_off
,
5953 res
->bit1_pos
, res
->bit2_pos
);
5956 cmdline_parse_token_string_t cmd_read_reg_bit_field_read
=
5957 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result
, read
,
5959 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield
=
5960 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result
,
5961 regfield
, "regfield");
5962 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id
=
5963 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result
, port_id
,
5965 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off
=
5966 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result
, reg_off
,
5968 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos
=
5969 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result
, bit1_pos
,
5971 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos
=
5972 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result
, bit2_pos
,
5975 cmdline_parse_inst_t cmd_read_reg_bit_field
= {
5976 .f
= cmd_read_reg_bit_field_parsed
,
5978 .help_str
= "read regfield port_id reg_off bit_x bit_y "
5979 "(read register bit field between bit_x and bit_y included)",
5981 (void *)&cmd_read_reg_bit_field_read
,
5982 (void *)&cmd_read_reg_bit_field_regfield
,
5983 (void *)&cmd_read_reg_bit_field_port_id
,
5984 (void *)&cmd_read_reg_bit_field_reg_off
,
5985 (void *)&cmd_read_reg_bit_field_bit1_pos
,
5986 (void *)&cmd_read_reg_bit_field_bit2_pos
,
5991 /* *** READ PORT REGISTER BIT *** */
5992 struct cmd_read_reg_bit_result
{
5993 cmdline_fixed_string_t read
;
5994 cmdline_fixed_string_t regbit
;
6001 cmd_read_reg_bit_parsed(void *parsed_result
,
6002 __attribute__((unused
)) struct cmdline
*cl
,
6003 __attribute__((unused
)) void *data
)
6005 struct cmd_read_reg_bit_result
*res
= parsed_result
;
6006 port_reg_bit_display(res
->port_id
, res
->reg_off
, res
->bit_pos
);
6009 cmdline_parse_token_string_t cmd_read_reg_bit_read
=
6010 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result
, read
, "read");
6011 cmdline_parse_token_string_t cmd_read_reg_bit_regbit
=
6012 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result
,
6014 cmdline_parse_token_num_t cmd_read_reg_bit_port_id
=
6015 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result
, port_id
, UINT8
);
6016 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off
=
6017 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result
, reg_off
, UINT32
);
6018 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos
=
6019 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result
, bit_pos
, UINT8
);
6021 cmdline_parse_inst_t cmd_read_reg_bit
= {
6022 .f
= cmd_read_reg_bit_parsed
,
6024 .help_str
= "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
6026 (void *)&cmd_read_reg_bit_read
,
6027 (void *)&cmd_read_reg_bit_regbit
,
6028 (void *)&cmd_read_reg_bit_port_id
,
6029 (void *)&cmd_read_reg_bit_reg_off
,
6030 (void *)&cmd_read_reg_bit_bit_pos
,
6035 /* *** WRITE PORT REGISTER *** */
6036 struct cmd_write_reg_result
{
6037 cmdline_fixed_string_t write
;
6038 cmdline_fixed_string_t reg
;
6045 cmd_write_reg_parsed(void *parsed_result
,
6046 __attribute__((unused
)) struct cmdline
*cl
,
6047 __attribute__((unused
)) void *data
)
6049 struct cmd_write_reg_result
*res
= parsed_result
;
6050 port_reg_set(res
->port_id
, res
->reg_off
, res
->value
);
6053 cmdline_parse_token_string_t cmd_write_reg_write
=
6054 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result
, write
, "write");
6055 cmdline_parse_token_string_t cmd_write_reg_reg
=
6056 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result
, reg
, "reg");
6057 cmdline_parse_token_num_t cmd_write_reg_port_id
=
6058 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result
, port_id
, UINT8
);
6059 cmdline_parse_token_num_t cmd_write_reg_reg_off
=
6060 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result
, reg_off
, UINT32
);
6061 cmdline_parse_token_num_t cmd_write_reg_value
=
6062 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result
, value
, UINT32
);
6064 cmdline_parse_inst_t cmd_write_reg
= {
6065 .f
= cmd_write_reg_parsed
,
6067 .help_str
= "write reg port_id reg_off reg_value",
6069 (void *)&cmd_write_reg_write
,
6070 (void *)&cmd_write_reg_reg
,
6071 (void *)&cmd_write_reg_port_id
,
6072 (void *)&cmd_write_reg_reg_off
,
6073 (void *)&cmd_write_reg_value
,
6078 /* *** WRITE PORT REGISTER BIT FIELD *** */
6079 struct cmd_write_reg_bit_field_result
{
6080 cmdline_fixed_string_t write
;
6081 cmdline_fixed_string_t regfield
;
6090 cmd_write_reg_bit_field_parsed(void *parsed_result
,
6091 __attribute__((unused
)) struct cmdline
*cl
,
6092 __attribute__((unused
)) void *data
)
6094 struct cmd_write_reg_bit_field_result
*res
= parsed_result
;
6095 port_reg_bit_field_set(res
->port_id
, res
->reg_off
,
6096 res
->bit1_pos
, res
->bit2_pos
, res
->value
);
6099 cmdline_parse_token_string_t cmd_write_reg_bit_field_write
=
6100 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result
, write
,
6102 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield
=
6103 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result
,
6104 regfield
, "regfield");
6105 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id
=
6106 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result
, port_id
,
6108 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off
=
6109 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result
, reg_off
,
6111 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos
=
6112 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result
, bit1_pos
,
6114 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos
=
6115 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result
, bit2_pos
,
6117 cmdline_parse_token_num_t cmd_write_reg_bit_field_value
=
6118 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result
, value
,
6121 cmdline_parse_inst_t cmd_write_reg_bit_field
= {
6122 .f
= cmd_write_reg_bit_field_parsed
,
6124 .help_str
= "write regfield port_id reg_off bit_x bit_y reg_value"
6125 "(set register bit field between bit_x and bit_y included)",
6127 (void *)&cmd_write_reg_bit_field_write
,
6128 (void *)&cmd_write_reg_bit_field_regfield
,
6129 (void *)&cmd_write_reg_bit_field_port_id
,
6130 (void *)&cmd_write_reg_bit_field_reg_off
,
6131 (void *)&cmd_write_reg_bit_field_bit1_pos
,
6132 (void *)&cmd_write_reg_bit_field_bit2_pos
,
6133 (void *)&cmd_write_reg_bit_field_value
,
6138 /* *** WRITE PORT REGISTER BIT *** */
6139 struct cmd_write_reg_bit_result
{
6140 cmdline_fixed_string_t write
;
6141 cmdline_fixed_string_t regbit
;
6149 cmd_write_reg_bit_parsed(void *parsed_result
,
6150 __attribute__((unused
)) struct cmdline
*cl
,
6151 __attribute__((unused
)) void *data
)
6153 struct cmd_write_reg_bit_result
*res
= parsed_result
;
6154 port_reg_bit_set(res
->port_id
, res
->reg_off
, res
->bit_pos
, res
->value
);
6157 cmdline_parse_token_string_t cmd_write_reg_bit_write
=
6158 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result
, write
,
6160 cmdline_parse_token_string_t cmd_write_reg_bit_regbit
=
6161 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result
,
6163 cmdline_parse_token_num_t cmd_write_reg_bit_port_id
=
6164 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result
, port_id
, UINT8
);
6165 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off
=
6166 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result
, reg_off
, UINT32
);
6167 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos
=
6168 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result
, bit_pos
, UINT8
);
6169 cmdline_parse_token_num_t cmd_write_reg_bit_value
=
6170 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result
, value
, UINT8
);
6172 cmdline_parse_inst_t cmd_write_reg_bit
= {
6173 .f
= cmd_write_reg_bit_parsed
,
6175 .help_str
= "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
6177 (void *)&cmd_write_reg_bit_write
,
6178 (void *)&cmd_write_reg_bit_regbit
,
6179 (void *)&cmd_write_reg_bit_port_id
,
6180 (void *)&cmd_write_reg_bit_reg_off
,
6181 (void *)&cmd_write_reg_bit_bit_pos
,
6182 (void *)&cmd_write_reg_bit_value
,
6187 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6188 struct cmd_read_rxd_txd_result
{
6189 cmdline_fixed_string_t read
;
6190 cmdline_fixed_string_t rxd_txd
;
6197 cmd_read_rxd_txd_parsed(void *parsed_result
,
6198 __attribute__((unused
)) struct cmdline
*cl
,
6199 __attribute__((unused
)) void *data
)
6201 struct cmd_read_rxd_txd_result
*res
= parsed_result
;
6203 if (!strcmp(res
->rxd_txd
, "rxd"))
6204 rx_ring_desc_display(res
->port_id
, res
->queue_id
, res
->desc_id
);
6205 else if (!strcmp(res
->rxd_txd
, "txd"))
6206 tx_ring_desc_display(res
->port_id
, res
->queue_id
, res
->desc_id
);
6209 cmdline_parse_token_string_t cmd_read_rxd_txd_read
=
6210 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result
, read
, "read");
6211 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd
=
6212 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result
, rxd_txd
,
6214 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id
=
6215 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result
, port_id
, UINT8
);
6216 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id
=
6217 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result
, queue_id
, UINT16
);
6218 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id
=
6219 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result
, desc_id
, UINT16
);
6221 cmdline_parse_inst_t cmd_read_rxd_txd
= {
6222 .f
= cmd_read_rxd_txd_parsed
,
6224 .help_str
= "read rxd|txd port_id queue_id rxd_id",
6226 (void *)&cmd_read_rxd_txd_read
,
6227 (void *)&cmd_read_rxd_txd_rxd_txd
,
6228 (void *)&cmd_read_rxd_txd_port_id
,
6229 (void *)&cmd_read_rxd_txd_queue_id
,
6230 (void *)&cmd_read_rxd_txd_desc_id
,
6236 struct cmd_quit_result
{
6237 cmdline_fixed_string_t quit
;
6240 static void cmd_quit_parsed(__attribute__((unused
)) void *parsed_result
,
6242 __attribute__((unused
)) void *data
)
6248 cmdline_parse_token_string_t cmd_quit_quit
=
6249 TOKEN_STRING_INITIALIZER(struct cmd_quit_result
, quit
, "quit");
6251 cmdline_parse_inst_t cmd_quit
= {
6252 .f
= cmd_quit_parsed
,
6254 .help_str
= "exit application",
6256 (void *)&cmd_quit_quit
,
6261 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6262 struct cmd_mac_addr_result
{
6263 cmdline_fixed_string_t mac_addr_cmd
;
6264 cmdline_fixed_string_t what
;
6266 struct ether_addr address
;
6269 static void cmd_mac_addr_parsed(void *parsed_result
,
6270 __attribute__((unused
)) struct cmdline
*cl
,
6271 __attribute__((unused
)) void *data
)
6273 struct cmd_mac_addr_result
*res
= parsed_result
;
6276 if (strcmp(res
->what
, "add") == 0)
6277 ret
= rte_eth_dev_mac_addr_add(res
->port_num
, &res
->address
, 0);
6279 ret
= rte_eth_dev_mac_addr_remove(res
->port_num
, &res
->address
);
6281 /* check the return value and print it if is < 0 */
6283 printf("mac_addr_cmd error: (%s)\n", strerror(-ret
));
6287 cmdline_parse_token_string_t cmd_mac_addr_cmd
=
6288 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result
, mac_addr_cmd
,
6290 cmdline_parse_token_string_t cmd_mac_addr_what
=
6291 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result
, what
,
6293 cmdline_parse_token_num_t cmd_mac_addr_portnum
=
6294 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result
, port_num
, UINT8
);
6295 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr
=
6296 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result
, address
);
6298 cmdline_parse_inst_t cmd_mac_addr
= {
6299 .f
= cmd_mac_addr_parsed
,
6301 .help_str
= "mac_addr add|remove X <address>: "
6302 "add/remove MAC address on port X",
6304 (void *)&cmd_mac_addr_cmd
,
6305 (void *)&cmd_mac_addr_what
,
6306 (void *)&cmd_mac_addr_portnum
,
6307 (void *)&cmd_mac_addr_addr
,
6313 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6314 struct cmd_set_qmap_result
{
6315 cmdline_fixed_string_t set
;
6316 cmdline_fixed_string_t qmap
;
6317 cmdline_fixed_string_t what
;
6324 cmd_set_qmap_parsed(void *parsed_result
,
6325 __attribute__((unused
)) struct cmdline
*cl
,
6326 __attribute__((unused
)) void *data
)
6328 struct cmd_set_qmap_result
*res
= parsed_result
;
6329 int is_rx
= (strcmp(res
->what
, "tx") == 0) ? 0 : 1;
6331 set_qmap(res
->port_id
, (uint8_t)is_rx
, res
->queue_id
, res
->map_value
);
6334 cmdline_parse_token_string_t cmd_setqmap_set
=
6335 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result
,
6337 cmdline_parse_token_string_t cmd_setqmap_qmap
=
6338 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result
,
6340 cmdline_parse_token_string_t cmd_setqmap_what
=
6341 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result
,
6343 cmdline_parse_token_num_t cmd_setqmap_portid
=
6344 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result
,
6346 cmdline_parse_token_num_t cmd_setqmap_queueid
=
6347 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result
,
6349 cmdline_parse_token_num_t cmd_setqmap_mapvalue
=
6350 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result
,
6353 cmdline_parse_inst_t cmd_set_qmap
= {
6354 .f
= cmd_set_qmap_parsed
,
6356 .help_str
= "Set statistics mapping value on tx|rx queue_id of port_id",
6358 (void *)&cmd_setqmap_set
,
6359 (void *)&cmd_setqmap_qmap
,
6360 (void *)&cmd_setqmap_what
,
6361 (void *)&cmd_setqmap_portid
,
6362 (void *)&cmd_setqmap_queueid
,
6363 (void *)&cmd_setqmap_mapvalue
,
6368 /* *** CONFIGURE UNICAST HASH TABLE *** */
6369 struct cmd_set_uc_hash_table
{
6370 cmdline_fixed_string_t set
;
6371 cmdline_fixed_string_t port
;
6373 cmdline_fixed_string_t what
;
6374 struct ether_addr address
;
6375 cmdline_fixed_string_t mode
;
6379 cmd_set_uc_hash_parsed(void *parsed_result
,
6380 __attribute__((unused
)) struct cmdline
*cl
,
6381 __attribute__((unused
)) void *data
)
6384 struct cmd_set_uc_hash_table
*res
= parsed_result
;
6386 int is_on
= (strcmp(res
->mode
, "on") == 0) ? 1 : 0;
6388 if (strcmp(res
->what
, "uta") == 0)
6389 ret
= rte_eth_dev_uc_hash_table_set(res
->port_id
,
6390 &res
->address
,(uint8_t)is_on
);
6392 printf("bad unicast hash table parameter, return code = %d \n", ret
);
6396 cmdline_parse_token_string_t cmd_set_uc_hash_set
=
6397 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table
,
6399 cmdline_parse_token_string_t cmd_set_uc_hash_port
=
6400 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table
,
6402 cmdline_parse_token_num_t cmd_set_uc_hash_portid
=
6403 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table
,
6405 cmdline_parse_token_string_t cmd_set_uc_hash_what
=
6406 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table
,
6408 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac
=
6409 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table
,
6411 cmdline_parse_token_string_t cmd_set_uc_hash_mode
=
6412 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table
,
6415 cmdline_parse_inst_t cmd_set_uc_hash_filter
= {
6416 .f
= cmd_set_uc_hash_parsed
,
6418 .help_str
= "set port X uta Y on|off(X = port number,Y = MAC address)",
6420 (void *)&cmd_set_uc_hash_set
,
6421 (void *)&cmd_set_uc_hash_port
,
6422 (void *)&cmd_set_uc_hash_portid
,
6423 (void *)&cmd_set_uc_hash_what
,
6424 (void *)&cmd_set_uc_hash_mac
,
6425 (void *)&cmd_set_uc_hash_mode
,
6430 struct cmd_set_uc_all_hash_table
{
6431 cmdline_fixed_string_t set
;
6432 cmdline_fixed_string_t port
;
6434 cmdline_fixed_string_t what
;
6435 cmdline_fixed_string_t value
;
6436 cmdline_fixed_string_t mode
;
6440 cmd_set_uc_all_hash_parsed(void *parsed_result
,
6441 __attribute__((unused
)) struct cmdline
*cl
,
6442 __attribute__((unused
)) void *data
)
6445 struct cmd_set_uc_all_hash_table
*res
= parsed_result
;
6447 int is_on
= (strcmp(res
->mode
, "on") == 0) ? 1 : 0;
6449 if ((strcmp(res
->what
, "uta") == 0) &&
6450 (strcmp(res
->value
, "all") == 0))
6451 ret
= rte_eth_dev_uc_all_hash_table_set(res
->port_id
,(uint8_t) is_on
);
6453 printf("bad unicast hash table parameter,"
6454 "return code = %d \n", ret
);
6457 cmdline_parse_token_string_t cmd_set_uc_all_hash_set
=
6458 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table
,
6460 cmdline_parse_token_string_t cmd_set_uc_all_hash_port
=
6461 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table
,
6463 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid
=
6464 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table
,
6466 cmdline_parse_token_string_t cmd_set_uc_all_hash_what
=
6467 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table
,
6469 cmdline_parse_token_string_t cmd_set_uc_all_hash_value
=
6470 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table
,
6472 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode
=
6473 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table
,
6476 cmdline_parse_inst_t cmd_set_uc_all_hash_filter
= {
6477 .f
= cmd_set_uc_all_hash_parsed
,
6479 .help_str
= "set port X uta all on|off (X = port number)",
6481 (void *)&cmd_set_uc_all_hash_set
,
6482 (void *)&cmd_set_uc_all_hash_port
,
6483 (void *)&cmd_set_uc_all_hash_portid
,
6484 (void *)&cmd_set_uc_all_hash_what
,
6485 (void *)&cmd_set_uc_all_hash_value
,
6486 (void *)&cmd_set_uc_all_hash_mode
,
6491 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6492 struct cmd_set_vf_macvlan_filter
{
6493 cmdline_fixed_string_t set
;
6494 cmdline_fixed_string_t port
;
6496 cmdline_fixed_string_t vf
;
6498 struct ether_addr address
;
6499 cmdline_fixed_string_t filter_type
;
6500 cmdline_fixed_string_t mode
;
6504 cmd_set_vf_macvlan_parsed(void *parsed_result
,
6505 __attribute__((unused
)) struct cmdline
*cl
,
6506 __attribute__((unused
)) void *data
)
6509 struct cmd_set_vf_macvlan_filter
*res
= parsed_result
;
6510 struct rte_eth_mac_filter filter
;
6512 memset(&filter
, 0, sizeof(struct rte_eth_mac_filter
));
6514 (void)rte_memcpy(&filter
.mac_addr
, &res
->address
, ETHER_ADDR_LEN
);
6516 /* set VF MAC filter */
6520 filter
.dst_id
= res
->vf_id
;
6522 if (!strcmp(res
->filter_type
, "exact-mac"))
6523 filter
.filter_type
= RTE_MAC_PERFECT_MATCH
;
6524 else if (!strcmp(res
->filter_type
, "exact-mac-vlan"))
6525 filter
.filter_type
= RTE_MACVLAN_PERFECT_MATCH
;
6526 else if (!strcmp(res
->filter_type
, "hashmac"))
6527 filter
.filter_type
= RTE_MAC_HASH_MATCH
;
6528 else if (!strcmp(res
->filter_type
, "hashmac-vlan"))
6529 filter
.filter_type
= RTE_MACVLAN_HASH_MATCH
;
6531 is_on
= (strcmp(res
->mode
, "on") == 0) ? 1 : 0;
6534 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
6535 RTE_ETH_FILTER_MACVLAN
,
6539 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
6540 RTE_ETH_FILTER_MACVLAN
,
6541 RTE_ETH_FILTER_DELETE
,
6545 printf("bad set MAC hash parameter, return code = %d\n", ret
);
6549 cmdline_parse_token_string_t cmd_set_vf_macvlan_set
=
6550 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter
,
6552 cmdline_parse_token_string_t cmd_set_vf_macvlan_port
=
6553 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter
,
6555 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid
=
6556 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter
,
6558 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf
=
6559 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter
,
6561 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id
=
6562 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter
,
6564 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac
=
6565 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter
,
6567 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type
=
6568 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter
,
6569 filter_type
, "exact-mac#exact-mac-vlan"
6570 "#hashmac#hashmac-vlan");
6571 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode
=
6572 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter
,
6575 cmdline_parse_inst_t cmd_set_vf_macvlan_filter
= {
6576 .f
= cmd_set_vf_macvlan_parsed
,
6578 .help_str
= "set port (portid) vf (vfid) (mac-addr) "
6579 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6581 "exact match rule:exact match of MAC or MAC and VLAN; "
6582 "hash match rule: hash match of MAC and exact match "
6585 (void *)&cmd_set_vf_macvlan_set
,
6586 (void *)&cmd_set_vf_macvlan_port
,
6587 (void *)&cmd_set_vf_macvlan_portid
,
6588 (void *)&cmd_set_vf_macvlan_vf
,
6589 (void *)&cmd_set_vf_macvlan_vf_id
,
6590 (void *)&cmd_set_vf_macvlan_mac
,
6591 (void *)&cmd_set_vf_macvlan_filter_type
,
6592 (void *)&cmd_set_vf_macvlan_mode
,
6597 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6598 struct cmd_set_vf_traffic
{
6599 cmdline_fixed_string_t set
;
6600 cmdline_fixed_string_t port
;
6602 cmdline_fixed_string_t vf
;
6604 cmdline_fixed_string_t what
;
6605 cmdline_fixed_string_t mode
;
6609 cmd_set_vf_traffic_parsed(void *parsed_result
,
6610 __attribute__((unused
)) struct cmdline
*cl
,
6611 __attribute__((unused
)) void *data
)
6613 struct cmd_set_vf_traffic
*res
= parsed_result
;
6614 int is_rx
= (strcmp(res
->what
, "rx") == 0) ? 1 : 0;
6615 int is_on
= (strcmp(res
->mode
, "on") == 0) ? 1 : 0;
6617 set_vf_traffic(res
->port_id
, (uint8_t)is_rx
, res
->vf_id
,(uint8_t) is_on
);
6620 cmdline_parse_token_string_t cmd_setvf_traffic_set
=
6621 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic
,
6623 cmdline_parse_token_string_t cmd_setvf_traffic_port
=
6624 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic
,
6626 cmdline_parse_token_num_t cmd_setvf_traffic_portid
=
6627 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic
,
6629 cmdline_parse_token_string_t cmd_setvf_traffic_vf
=
6630 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic
,
6632 cmdline_parse_token_num_t cmd_setvf_traffic_vfid
=
6633 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic
,
6635 cmdline_parse_token_string_t cmd_setvf_traffic_what
=
6636 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic
,
6638 cmdline_parse_token_string_t cmd_setvf_traffic_mode
=
6639 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic
,
6642 cmdline_parse_inst_t cmd_set_vf_traffic
= {
6643 .f
= cmd_set_vf_traffic_parsed
,
6645 .help_str
= "set port X vf Y rx|tx on|off"
6646 "(X = port number,Y = vf id)",
6648 (void *)&cmd_setvf_traffic_set
,
6649 (void *)&cmd_setvf_traffic_port
,
6650 (void *)&cmd_setvf_traffic_portid
,
6651 (void *)&cmd_setvf_traffic_vf
,
6652 (void *)&cmd_setvf_traffic_vfid
,
6653 (void *)&cmd_setvf_traffic_what
,
6654 (void *)&cmd_setvf_traffic_mode
,
6659 /* *** CONFIGURE VF RECEIVE MODE *** */
6660 struct cmd_set_vf_rxmode
{
6661 cmdline_fixed_string_t set
;
6662 cmdline_fixed_string_t port
;
6664 cmdline_fixed_string_t vf
;
6666 cmdline_fixed_string_t what
;
6667 cmdline_fixed_string_t mode
;
6668 cmdline_fixed_string_t on
;
6672 cmd_set_vf_rxmode_parsed(void *parsed_result
,
6673 __attribute__((unused
)) struct cmdline
*cl
,
6674 __attribute__((unused
)) void *data
)
6677 uint16_t rx_mode
= 0;
6678 struct cmd_set_vf_rxmode
*res
= parsed_result
;
6680 int is_on
= (strcmp(res
->on
, "on") == 0) ? 1 : 0;
6681 if (!strcmp(res
->what
,"rxmode")) {
6682 if (!strcmp(res
->mode
, "AUPE"))
6683 rx_mode
|= ETH_VMDQ_ACCEPT_UNTAG
;
6684 else if (!strcmp(res
->mode
, "ROPE"))
6685 rx_mode
|= ETH_VMDQ_ACCEPT_HASH_UC
;
6686 else if (!strcmp(res
->mode
, "BAM"))
6687 rx_mode
|= ETH_VMDQ_ACCEPT_BROADCAST
;
6688 else if (!strncmp(res
->mode
, "MPE",3))
6689 rx_mode
|= ETH_VMDQ_ACCEPT_MULTICAST
;
6692 ret
= rte_eth_dev_set_vf_rxmode(res
->port_id
,res
->vf_id
,rx_mode
,(uint8_t)is_on
);
6694 printf("bad VF receive mode parameter, return code = %d \n",
6698 cmdline_parse_token_string_t cmd_set_vf_rxmode_set
=
6699 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode
,
6701 cmdline_parse_token_string_t cmd_set_vf_rxmode_port
=
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode
,
6704 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid
=
6705 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode
,
6707 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf
=
6708 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode
,
6710 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid
=
6711 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode
,
6713 cmdline_parse_token_string_t cmd_set_vf_rxmode_what
=
6714 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode
,
6716 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode
=
6717 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode
,
6718 mode
, "AUPE#ROPE#BAM#MPE");
6719 cmdline_parse_token_string_t cmd_set_vf_rxmode_on
=
6720 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode
,
6723 cmdline_parse_inst_t cmd_set_vf_rxmode
= {
6724 .f
= cmd_set_vf_rxmode_parsed
,
6726 .help_str
= "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6728 (void *)&cmd_set_vf_rxmode_set
,
6729 (void *)&cmd_set_vf_rxmode_port
,
6730 (void *)&cmd_set_vf_rxmode_portid
,
6731 (void *)&cmd_set_vf_rxmode_vf
,
6732 (void *)&cmd_set_vf_rxmode_vfid
,
6733 (void *)&cmd_set_vf_rxmode_what
,
6734 (void *)&cmd_set_vf_rxmode_mode
,
6735 (void *)&cmd_set_vf_rxmode_on
,
6740 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6741 struct cmd_vf_mac_addr_result
{
6742 cmdline_fixed_string_t mac_addr_cmd
;
6743 cmdline_fixed_string_t what
;
6744 cmdline_fixed_string_t port
;
6746 cmdline_fixed_string_t vf
;
6748 struct ether_addr address
;
6751 static void cmd_vf_mac_addr_parsed(void *parsed_result
,
6752 __attribute__((unused
)) struct cmdline
*cl
,
6753 __attribute__((unused
)) void *data
)
6755 struct cmd_vf_mac_addr_result
*res
= parsed_result
;
6758 if (strcmp(res
->what
, "add") == 0)
6759 ret
= rte_eth_dev_mac_addr_add(res
->port_num
,
6760 &res
->address
, res
->vf_num
);
6762 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret
));
6766 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd
=
6767 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result
,
6768 mac_addr_cmd
,"mac_addr");
6769 cmdline_parse_token_string_t cmd_vf_mac_addr_what
=
6770 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result
,
6772 cmdline_parse_token_string_t cmd_vf_mac_addr_port
=
6773 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result
,
6775 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum
=
6776 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result
,
6778 cmdline_parse_token_string_t cmd_vf_mac_addr_vf
=
6779 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result
,
6781 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum
=
6782 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result
,
6784 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr
=
6785 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result
,
6788 cmdline_parse_inst_t cmd_vf_mac_addr_filter
= {
6789 .f
= cmd_vf_mac_addr_parsed
,
6791 .help_str
= "mac_addr add port X vf Y ethaddr:(X = port number,"
6792 "Y = VF number)add MAC address filtering for a VF on port X",
6794 (void *)&cmd_vf_mac_addr_cmd
,
6795 (void *)&cmd_vf_mac_addr_what
,
6796 (void *)&cmd_vf_mac_addr_port
,
6797 (void *)&cmd_vf_mac_addr_portnum
,
6798 (void *)&cmd_vf_mac_addr_vf
,
6799 (void *)&cmd_vf_mac_addr_vfnum
,
6800 (void *)&cmd_vf_mac_addr_addr
,
6805 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6806 struct cmd_vf_rx_vlan_filter
{
6807 cmdline_fixed_string_t rx_vlan
;
6808 cmdline_fixed_string_t what
;
6810 cmdline_fixed_string_t port
;
6812 cmdline_fixed_string_t vf
;
6817 cmd_vf_rx_vlan_filter_parsed(void *parsed_result
,
6818 __attribute__((unused
)) struct cmdline
*cl
,
6819 __attribute__((unused
)) void *data
)
6821 struct cmd_vf_rx_vlan_filter
*res
= parsed_result
;
6823 if (!strcmp(res
->what
, "add"))
6824 set_vf_rx_vlan(res
->port_id
, res
->vlan_id
,res
->vf_mask
, 1);
6826 set_vf_rx_vlan(res
->port_id
, res
->vlan_id
,res
->vf_mask
, 0);
6829 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan
=
6830 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter
,
6831 rx_vlan
, "rx_vlan");
6832 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what
=
6833 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter
,
6835 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid
=
6836 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter
,
6838 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port
=
6839 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter
,
6841 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid
=
6842 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter
,
6844 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf
=
6845 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter
,
6847 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask
=
6848 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter
,
6851 cmdline_parse_inst_t cmd_vf_rxvlan_filter
= {
6852 .f
= cmd_vf_rx_vlan_filter_parsed
,
6854 .help_str
= "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6855 "Y = port number,Z = hexadecimal VF mask)",
6857 (void *)&cmd_vf_rx_vlan_filter_rx_vlan
,
6858 (void *)&cmd_vf_rx_vlan_filter_what
,
6859 (void *)&cmd_vf_rx_vlan_filter_vlanid
,
6860 (void *)&cmd_vf_rx_vlan_filter_port
,
6861 (void *)&cmd_vf_rx_vlan_filter_portid
,
6862 (void *)&cmd_vf_rx_vlan_filter_vf
,
6863 (void *)&cmd_vf_rx_vlan_filter_vf_mask
,
6868 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6869 struct cmd_queue_rate_limit_result
{
6870 cmdline_fixed_string_t set
;
6871 cmdline_fixed_string_t port
;
6873 cmdline_fixed_string_t queue
;
6875 cmdline_fixed_string_t rate
;
6879 static void cmd_queue_rate_limit_parsed(void *parsed_result
,
6880 __attribute__((unused
)) struct cmdline
*cl
,
6881 __attribute__((unused
)) void *data
)
6883 struct cmd_queue_rate_limit_result
*res
= parsed_result
;
6886 if ((strcmp(res
->set
, "set") == 0) && (strcmp(res
->port
, "port") == 0)
6887 && (strcmp(res
->queue
, "queue") == 0)
6888 && (strcmp(res
->rate
, "rate") == 0))
6889 ret
= set_queue_rate_limit(res
->port_num
, res
->queue_num
,
6892 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret
));
6896 cmdline_parse_token_string_t cmd_queue_rate_limit_set
=
6897 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result
,
6899 cmdline_parse_token_string_t cmd_queue_rate_limit_port
=
6900 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result
,
6902 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum
=
6903 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result
,
6905 cmdline_parse_token_string_t cmd_queue_rate_limit_queue
=
6906 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result
,
6908 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum
=
6909 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result
,
6911 cmdline_parse_token_string_t cmd_queue_rate_limit_rate
=
6912 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result
,
6914 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum
=
6915 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result
,
6918 cmdline_parse_inst_t cmd_queue_rate_limit
= {
6919 .f
= cmd_queue_rate_limit_parsed
,
6921 .help_str
= "set port X queue Y rate Z:(X = port number,"
6922 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6924 (void *)&cmd_queue_rate_limit_set
,
6925 (void *)&cmd_queue_rate_limit_port
,
6926 (void *)&cmd_queue_rate_limit_portnum
,
6927 (void *)&cmd_queue_rate_limit_queue
,
6928 (void *)&cmd_queue_rate_limit_queuenum
,
6929 (void *)&cmd_queue_rate_limit_rate
,
6930 (void *)&cmd_queue_rate_limit_ratenum
,
6935 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6936 struct cmd_vf_rate_limit_result
{
6937 cmdline_fixed_string_t set
;
6938 cmdline_fixed_string_t port
;
6940 cmdline_fixed_string_t vf
;
6942 cmdline_fixed_string_t rate
;
6944 cmdline_fixed_string_t q_msk
;
6948 static void cmd_vf_rate_limit_parsed(void *parsed_result
,
6949 __attribute__((unused
)) struct cmdline
*cl
,
6950 __attribute__((unused
)) void *data
)
6952 struct cmd_vf_rate_limit_result
*res
= parsed_result
;
6955 if ((strcmp(res
->set
, "set") == 0) && (strcmp(res
->port
, "port") == 0)
6956 && (strcmp(res
->vf
, "vf") == 0)
6957 && (strcmp(res
->rate
, "rate") == 0)
6958 && (strcmp(res
->q_msk
, "queue_mask") == 0))
6959 ret
= set_vf_rate_limit(res
->port_num
, res
->vf_num
,
6960 res
->rate_num
, res
->q_msk_val
);
6962 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret
));
6966 cmdline_parse_token_string_t cmd_vf_rate_limit_set
=
6967 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result
,
6969 cmdline_parse_token_string_t cmd_vf_rate_limit_port
=
6970 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result
,
6972 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum
=
6973 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result
,
6975 cmdline_parse_token_string_t cmd_vf_rate_limit_vf
=
6976 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result
,
6978 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum
=
6979 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result
,
6981 cmdline_parse_token_string_t cmd_vf_rate_limit_rate
=
6982 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result
,
6984 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum
=
6985 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result
,
6987 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk
=
6988 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result
,
6989 q_msk
, "queue_mask");
6990 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val
=
6991 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result
,
6994 cmdline_parse_inst_t cmd_vf_rate_limit
= {
6995 .f
= cmd_vf_rate_limit_parsed
,
6997 .help_str
= "set port X vf Y rate Z queue_mask V:(X = port number,"
6998 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6999 "for queues of VF on port X",
7001 (void *)&cmd_vf_rate_limit_set
,
7002 (void *)&cmd_vf_rate_limit_port
,
7003 (void *)&cmd_vf_rate_limit_portnum
,
7004 (void *)&cmd_vf_rate_limit_vf
,
7005 (void *)&cmd_vf_rate_limit_vfnum
,
7006 (void *)&cmd_vf_rate_limit_rate
,
7007 (void *)&cmd_vf_rate_limit_ratenum
,
7008 (void *)&cmd_vf_rate_limit_q_msk
,
7009 (void *)&cmd_vf_rate_limit_q_msk_val
,
7014 /* *** ADD TUNNEL FILTER OF A PORT *** */
7015 struct cmd_tunnel_filter_result
{
7016 cmdline_fixed_string_t cmd
;
7017 cmdline_fixed_string_t what
;
7019 struct ether_addr outer_mac
;
7020 struct ether_addr inner_mac
;
7021 cmdline_ipaddr_t ip_value
;
7022 uint16_t inner_vlan
;
7023 cmdline_fixed_string_t tunnel_type
;
7024 cmdline_fixed_string_t filter_type
;
7030 cmd_tunnel_filter_parsed(void *parsed_result
,
7031 __attribute__((unused
)) struct cmdline
*cl
,
7032 __attribute__((unused
)) void *data
)
7034 struct cmd_tunnel_filter_result
*res
= parsed_result
;
7035 struct rte_eth_tunnel_filter_conf tunnel_filter_conf
;
7038 memset(&tunnel_filter_conf
, 0, sizeof(tunnel_filter_conf
));
7040 ether_addr_copy(&res
->outer_mac
, &tunnel_filter_conf
.outer_mac
);
7041 ether_addr_copy(&res
->inner_mac
, &tunnel_filter_conf
.inner_mac
);
7042 tunnel_filter_conf
.inner_vlan
= res
->inner_vlan
;
7044 if (res
->ip_value
.family
== AF_INET
) {
7045 tunnel_filter_conf
.ip_addr
.ipv4_addr
=
7046 res
->ip_value
.addr
.ipv4
.s_addr
;
7047 tunnel_filter_conf
.ip_type
= RTE_TUNNEL_IPTYPE_IPV4
;
7049 memcpy(&(tunnel_filter_conf
.ip_addr
.ipv6_addr
),
7050 &(res
->ip_value
.addr
.ipv6
),
7051 sizeof(struct in6_addr
));
7052 tunnel_filter_conf
.ip_type
= RTE_TUNNEL_IPTYPE_IPV6
;
7055 if (!strcmp(res
->filter_type
, "imac-ivlan"))
7056 tunnel_filter_conf
.filter_type
= RTE_TUNNEL_FILTER_IMAC_IVLAN
;
7057 else if (!strcmp(res
->filter_type
, "imac-ivlan-tenid"))
7058 tunnel_filter_conf
.filter_type
=
7059 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID
;
7060 else if (!strcmp(res
->filter_type
, "imac-tenid"))
7061 tunnel_filter_conf
.filter_type
= RTE_TUNNEL_FILTER_IMAC_TENID
;
7062 else if (!strcmp(res
->filter_type
, "imac"))
7063 tunnel_filter_conf
.filter_type
= ETH_TUNNEL_FILTER_IMAC
;
7064 else if (!strcmp(res
->filter_type
, "omac-imac-tenid"))
7065 tunnel_filter_conf
.filter_type
=
7066 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC
;
7067 else if (!strcmp(res
->filter_type
, "oip"))
7068 tunnel_filter_conf
.filter_type
= ETH_TUNNEL_FILTER_OIP
;
7069 else if (!strcmp(res
->filter_type
, "iip"))
7070 tunnel_filter_conf
.filter_type
= ETH_TUNNEL_FILTER_IIP
;
7072 printf("The filter type is not supported");
7076 if (!strcmp(res
->tunnel_type
, "vxlan"))
7077 tunnel_filter_conf
.tunnel_type
= RTE_TUNNEL_TYPE_VXLAN
;
7078 else if (!strcmp(res
->tunnel_type
, "nvgre"))
7079 tunnel_filter_conf
.tunnel_type
= RTE_TUNNEL_TYPE_NVGRE
;
7080 else if (!strcmp(res
->tunnel_type
, "ipingre"))
7081 tunnel_filter_conf
.tunnel_type
= RTE_TUNNEL_TYPE_IP_IN_GRE
;
7083 printf("The tunnel type %s not supported.\n", res
->tunnel_type
);
7087 tunnel_filter_conf
.tenant_id
= res
->tenant_id
;
7088 tunnel_filter_conf
.queue_id
= res
->queue_num
;
7089 if (!strcmp(res
->what
, "add"))
7090 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
7091 RTE_ETH_FILTER_TUNNEL
,
7093 &tunnel_filter_conf
);
7095 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
7096 RTE_ETH_FILTER_TUNNEL
,
7097 RTE_ETH_FILTER_DELETE
,
7098 &tunnel_filter_conf
);
7100 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7104 cmdline_parse_token_string_t cmd_tunnel_filter_cmd
=
7105 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result
,
7106 cmd
, "tunnel_filter");
7107 cmdline_parse_token_string_t cmd_tunnel_filter_what
=
7108 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result
,
7110 cmdline_parse_token_num_t cmd_tunnel_filter_port_id
=
7111 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result
,
7113 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac
=
7114 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result
,
7116 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac
=
7117 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result
,
7119 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan
=
7120 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result
,
7121 inner_vlan
, UINT16
);
7122 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value
=
7123 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result
,
7125 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type
=
7126 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result
,
7127 tunnel_type
, "vxlan#nvgre#ipingre");
7129 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type
=
7130 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result
,
7131 filter_type
, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7132 "imac#omac-imac-tenid");
7133 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id
=
7134 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result
,
7136 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num
=
7137 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result
,
7140 cmdline_parse_inst_t cmd_tunnel_filter
= {
7141 .f
= cmd_tunnel_filter_parsed
,
7143 .help_str
= "add/rm tunnel filter of a port: "
7144 "tunnel_filter add port_id outer_mac inner_mac ip "
7145 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
7146 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
7147 "imac|omac-imac-tenid) "
7148 "tenant_id queue_num",
7150 (void *)&cmd_tunnel_filter_cmd
,
7151 (void *)&cmd_tunnel_filter_what
,
7152 (void *)&cmd_tunnel_filter_port_id
,
7153 (void *)&cmd_tunnel_filter_outer_mac
,
7154 (void *)&cmd_tunnel_filter_inner_mac
,
7155 (void *)&cmd_tunnel_filter_ip_value
,
7156 (void *)&cmd_tunnel_filter_innner_vlan
,
7157 (void *)&cmd_tunnel_filter_tunnel_type
,
7158 (void *)&cmd_tunnel_filter_filter_type
,
7159 (void *)&cmd_tunnel_filter_tenant_id
,
7160 (void *)&cmd_tunnel_filter_queue_num
,
7165 /* *** CONFIGURE TUNNEL UDP PORT *** */
7166 struct cmd_tunnel_udp_config
{
7167 cmdline_fixed_string_t cmd
;
7168 cmdline_fixed_string_t what
;
7174 cmd_tunnel_udp_config_parsed(void *parsed_result
,
7175 __attribute__((unused
)) struct cmdline
*cl
,
7176 __attribute__((unused
)) void *data
)
7178 struct cmd_tunnel_udp_config
*res
= parsed_result
;
7179 struct rte_eth_udp_tunnel tunnel_udp
;
7182 tunnel_udp
.udp_port
= res
->udp_port
;
7184 if (!strcmp(res
->cmd
, "rx_vxlan_port"))
7185 tunnel_udp
.prot_type
= RTE_TUNNEL_TYPE_VXLAN
;
7187 if (!strcmp(res
->what
, "add"))
7188 ret
= rte_eth_dev_udp_tunnel_port_add(res
->port_id
,
7191 ret
= rte_eth_dev_udp_tunnel_port_delete(res
->port_id
,
7195 printf("udp tunneling add error: (%s)\n", strerror(-ret
));
7198 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd
=
7199 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config
,
7200 cmd
, "rx_vxlan_port");
7201 cmdline_parse_token_string_t cmd_tunnel_udp_config_what
=
7202 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config
,
7204 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port
=
7205 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config
,
7207 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id
=
7208 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config
,
7211 cmdline_parse_inst_t cmd_tunnel_udp_config
= {
7212 .f
= cmd_tunnel_udp_config_parsed
,
7214 .help_str
= "add/rm an tunneling UDP port filter: "
7215 "rx_vxlan_port add udp_port port_id",
7217 (void *)&cmd_tunnel_udp_config_cmd
,
7218 (void *)&cmd_tunnel_udp_config_what
,
7219 (void *)&cmd_tunnel_udp_config_udp_port
,
7220 (void *)&cmd_tunnel_udp_config_port_id
,
7225 /* *** GLOBAL CONFIG *** */
7226 struct cmd_global_config_result
{
7227 cmdline_fixed_string_t cmd
;
7229 cmdline_fixed_string_t cfg_type
;
7234 cmd_global_config_parsed(void *parsed_result
,
7235 __attribute__((unused
)) struct cmdline
*cl
,
7236 __attribute__((unused
)) void *data
)
7238 struct cmd_global_config_result
*res
= parsed_result
;
7239 struct rte_eth_global_cfg conf
;
7242 memset(&conf
, 0, sizeof(conf
));
7243 conf
.cfg_type
= RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN
;
7244 conf
.cfg
.gre_key_len
= res
->len
;
7245 ret
= rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_NONE
,
7246 RTE_ETH_FILTER_SET
, &conf
);
7248 printf("Global config error\n");
7251 cmdline_parse_token_string_t cmd_global_config_cmd
=
7252 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result
, cmd
,
7254 cmdline_parse_token_num_t cmd_global_config_port_id
=
7255 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result
, port_id
, UINT8
);
7256 cmdline_parse_token_string_t cmd_global_config_type
=
7257 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result
,
7258 cfg_type
, "gre-key-len");
7259 cmdline_parse_token_num_t cmd_global_config_gre_key_len
=
7260 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result
,
7263 cmdline_parse_inst_t cmd_global_config
= {
7264 .f
= cmd_global_config_parsed
,
7265 .data
= (void *)NULL
,
7266 .help_str
= "global_config <port_id> gre-key-len <number>",
7268 (void *)&cmd_global_config_cmd
,
7269 (void *)&cmd_global_config_port_id
,
7270 (void *)&cmd_global_config_type
,
7271 (void *)&cmd_global_config_gre_key_len
,
7276 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7277 struct cmd_set_mirror_mask_result
{
7278 cmdline_fixed_string_t set
;
7279 cmdline_fixed_string_t port
;
7281 cmdline_fixed_string_t mirror
;
7283 cmdline_fixed_string_t what
;
7284 cmdline_fixed_string_t value
;
7285 cmdline_fixed_string_t dstpool
;
7287 cmdline_fixed_string_t on
;
7290 cmdline_parse_token_string_t cmd_mirror_mask_set
=
7291 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result
,
7293 cmdline_parse_token_string_t cmd_mirror_mask_port
=
7294 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result
,
7296 cmdline_parse_token_num_t cmd_mirror_mask_portid
=
7297 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result
,
7299 cmdline_parse_token_string_t cmd_mirror_mask_mirror
=
7300 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result
,
7301 mirror
, "mirror-rule");
7302 cmdline_parse_token_num_t cmd_mirror_mask_ruleid
=
7303 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result
,
7305 cmdline_parse_token_string_t cmd_mirror_mask_what
=
7306 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result
,
7307 what
, "pool-mirror-up#pool-mirror-down"
7309 cmdline_parse_token_string_t cmd_mirror_mask_value
=
7310 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result
,
7312 cmdline_parse_token_string_t cmd_mirror_mask_dstpool
=
7313 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result
,
7314 dstpool
, "dst-pool");
7315 cmdline_parse_token_num_t cmd_mirror_mask_poolid
=
7316 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result
,
7318 cmdline_parse_token_string_t cmd_mirror_mask_on
=
7319 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result
,
7323 cmd_set_mirror_mask_parsed(void *parsed_result
,
7324 __attribute__((unused
)) struct cmdline
*cl
,
7325 __attribute__((unused
)) void *data
)
7328 struct cmd_set_mirror_mask_result
*res
= parsed_result
;
7329 struct rte_eth_mirror_conf mr_conf
;
7331 memset(&mr_conf
, 0, sizeof(struct rte_eth_mirror_conf
));
7333 unsigned int vlan_list
[ETH_MIRROR_MAX_VLANS
];
7335 mr_conf
.dst_pool
= res
->dstpool_id
;
7337 if (!strcmp(res
->what
, "pool-mirror-up")) {
7338 mr_conf
.pool_mask
= strtoull(res
->value
, NULL
, 16);
7339 mr_conf
.rule_type
= ETH_MIRROR_VIRTUAL_POOL_UP
;
7340 } else if (!strcmp(res
->what
, "pool-mirror-down")) {
7341 mr_conf
.pool_mask
= strtoull(res
->value
, NULL
, 16);
7342 mr_conf
.rule_type
= ETH_MIRROR_VIRTUAL_POOL_DOWN
;
7343 } else if (!strcmp(res
->what
, "vlan-mirror")) {
7344 mr_conf
.rule_type
= ETH_MIRROR_VLAN
;
7345 nb_item
= parse_item_list(res
->value
, "vlan",
7346 ETH_MIRROR_MAX_VLANS
, vlan_list
, 1);
7350 for (i
= 0; i
< nb_item
; i
++) {
7351 if (vlan_list
[i
] > ETHER_MAX_VLAN_ID
) {
7352 printf("Invalid vlan_id: must be < 4096\n");
7356 mr_conf
.vlan
.vlan_id
[i
] = (uint16_t)vlan_list
[i
];
7357 mr_conf
.vlan
.vlan_mask
|= 1ULL << i
;
7361 if (!strcmp(res
->on
, "on"))
7362 ret
= rte_eth_mirror_rule_set(res
->port_id
, &mr_conf
,
7365 ret
= rte_eth_mirror_rule_set(res
->port_id
, &mr_conf
,
7368 printf("mirror rule add error: (%s)\n", strerror(-ret
));
7371 cmdline_parse_inst_t cmd_set_mirror_mask
= {
7372 .f
= cmd_set_mirror_mask_parsed
,
7374 .help_str
= "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7375 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7377 (void *)&cmd_mirror_mask_set
,
7378 (void *)&cmd_mirror_mask_port
,
7379 (void *)&cmd_mirror_mask_portid
,
7380 (void *)&cmd_mirror_mask_mirror
,
7381 (void *)&cmd_mirror_mask_ruleid
,
7382 (void *)&cmd_mirror_mask_what
,
7383 (void *)&cmd_mirror_mask_value
,
7384 (void *)&cmd_mirror_mask_dstpool
,
7385 (void *)&cmd_mirror_mask_poolid
,
7386 (void *)&cmd_mirror_mask_on
,
7391 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7392 struct cmd_set_mirror_link_result
{
7393 cmdline_fixed_string_t set
;
7394 cmdline_fixed_string_t port
;
7396 cmdline_fixed_string_t mirror
;
7398 cmdline_fixed_string_t what
;
7399 cmdline_fixed_string_t dstpool
;
7401 cmdline_fixed_string_t on
;
7404 cmdline_parse_token_string_t cmd_mirror_link_set
=
7405 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result
,
7407 cmdline_parse_token_string_t cmd_mirror_link_port
=
7408 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result
,
7410 cmdline_parse_token_num_t cmd_mirror_link_portid
=
7411 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result
,
7413 cmdline_parse_token_string_t cmd_mirror_link_mirror
=
7414 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result
,
7415 mirror
, "mirror-rule");
7416 cmdline_parse_token_num_t cmd_mirror_link_ruleid
=
7417 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result
,
7419 cmdline_parse_token_string_t cmd_mirror_link_what
=
7420 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result
,
7421 what
, "uplink-mirror#downlink-mirror");
7422 cmdline_parse_token_string_t cmd_mirror_link_dstpool
=
7423 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result
,
7424 dstpool
, "dst-pool");
7425 cmdline_parse_token_num_t cmd_mirror_link_poolid
=
7426 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result
,
7428 cmdline_parse_token_string_t cmd_mirror_link_on
=
7429 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result
,
7433 cmd_set_mirror_link_parsed(void *parsed_result
,
7434 __attribute__((unused
)) struct cmdline
*cl
,
7435 __attribute__((unused
)) void *data
)
7438 struct cmd_set_mirror_link_result
*res
= parsed_result
;
7439 struct rte_eth_mirror_conf mr_conf
;
7441 memset(&mr_conf
, 0, sizeof(struct rte_eth_mirror_conf
));
7442 if (!strcmp(res
->what
, "uplink-mirror"))
7443 mr_conf
.rule_type
= ETH_MIRROR_UPLINK_PORT
;
7445 mr_conf
.rule_type
= ETH_MIRROR_DOWNLINK_PORT
;
7447 mr_conf
.dst_pool
= res
->dstpool_id
;
7449 if (!strcmp(res
->on
, "on"))
7450 ret
= rte_eth_mirror_rule_set(res
->port_id
, &mr_conf
,
7453 ret
= rte_eth_mirror_rule_set(res
->port_id
, &mr_conf
,
7456 /* check the return value and print it if is < 0 */
7458 printf("mirror rule add error: (%s)\n", strerror(-ret
));
7462 cmdline_parse_inst_t cmd_set_mirror_link
= {
7463 .f
= cmd_set_mirror_link_parsed
,
7465 .help_str
= "set port X mirror-rule Y uplink-mirror|"
7466 "downlink-mirror dst-pool Z on|off",
7468 (void *)&cmd_mirror_link_set
,
7469 (void *)&cmd_mirror_link_port
,
7470 (void *)&cmd_mirror_link_portid
,
7471 (void *)&cmd_mirror_link_mirror
,
7472 (void *)&cmd_mirror_link_ruleid
,
7473 (void *)&cmd_mirror_link_what
,
7474 (void *)&cmd_mirror_link_dstpool
,
7475 (void *)&cmd_mirror_link_poolid
,
7476 (void *)&cmd_mirror_link_on
,
7481 /* *** RESET VM MIRROR RULE *** */
7482 struct cmd_rm_mirror_rule_result
{
7483 cmdline_fixed_string_t reset
;
7484 cmdline_fixed_string_t port
;
7486 cmdline_fixed_string_t mirror
;
7490 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset
=
7491 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result
,
7493 cmdline_parse_token_string_t cmd_rm_mirror_rule_port
=
7494 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result
,
7496 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid
=
7497 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result
,
7499 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror
=
7500 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result
,
7501 mirror
, "mirror-rule");
7502 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid
=
7503 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result
,
7507 cmd_reset_mirror_rule_parsed(void *parsed_result
,
7508 __attribute__((unused
)) struct cmdline
*cl
,
7509 __attribute__((unused
)) void *data
)
7512 struct cmd_set_mirror_link_result
*res
= parsed_result
;
7514 ret
= rte_eth_mirror_rule_reset(res
->port_id
,res
->rule_id
);
7516 printf("mirror rule remove error: (%s)\n", strerror(-ret
));
7519 cmdline_parse_inst_t cmd_reset_mirror_rule
= {
7520 .f
= cmd_reset_mirror_rule_parsed
,
7522 .help_str
= "reset port X mirror-rule Y",
7524 (void *)&cmd_rm_mirror_rule_reset
,
7525 (void *)&cmd_rm_mirror_rule_port
,
7526 (void *)&cmd_rm_mirror_rule_portid
,
7527 (void *)&cmd_rm_mirror_rule_mirror
,
7528 (void *)&cmd_rm_mirror_rule_ruleid
,
7533 /* ******************************************************************************** */
7535 struct cmd_dump_result
{
7536 cmdline_fixed_string_t dump
;
7540 dump_struct_sizes(void)
7542 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7543 DUMP_SIZE(struct rte_mbuf
);
7544 DUMP_SIZE(struct rte_mempool
);
7545 DUMP_SIZE(struct rte_ring
);
7549 static void cmd_dump_parsed(void *parsed_result
,
7550 __attribute__((unused
)) struct cmdline
*cl
,
7551 __attribute__((unused
)) void *data
)
7553 struct cmd_dump_result
*res
= parsed_result
;
7555 if (!strcmp(res
->dump
, "dump_physmem"))
7556 rte_dump_physmem_layout(stdout
);
7557 else if (!strcmp(res
->dump
, "dump_memzone"))
7558 rte_memzone_dump(stdout
);
7559 else if (!strcmp(res
->dump
, "dump_struct_sizes"))
7560 dump_struct_sizes();
7561 else if (!strcmp(res
->dump
, "dump_ring"))
7562 rte_ring_list_dump(stdout
);
7563 else if (!strcmp(res
->dump
, "dump_mempool"))
7564 rte_mempool_list_dump(stdout
);
7565 else if (!strcmp(res
->dump
, "dump_devargs"))
7566 rte_eal_devargs_dump(stdout
);
7569 cmdline_parse_token_string_t cmd_dump_dump
=
7570 TOKEN_STRING_INITIALIZER(struct cmd_dump_result
, dump
,
7573 "dump_struct_sizes#"
7578 cmdline_parse_inst_t cmd_dump
= {
7579 .f
= cmd_dump_parsed
, /* function to call */
7580 .data
= NULL
, /* 2nd arg of func */
7581 .help_str
= "dump status",
7582 .tokens
= { /* token list, NULL terminated */
7583 (void *)&cmd_dump_dump
,
7588 /* ******************************************************************************** */
7590 struct cmd_dump_one_result
{
7591 cmdline_fixed_string_t dump
;
7592 cmdline_fixed_string_t name
;
7595 static void cmd_dump_one_parsed(void *parsed_result
, struct cmdline
*cl
,
7596 __attribute__((unused
)) void *data
)
7598 struct cmd_dump_one_result
*res
= parsed_result
;
7600 if (!strcmp(res
->dump
, "dump_ring")) {
7602 r
= rte_ring_lookup(res
->name
);
7604 cmdline_printf(cl
, "Cannot find ring\n");
7607 rte_ring_dump(stdout
, r
);
7608 } else if (!strcmp(res
->dump
, "dump_mempool")) {
7609 struct rte_mempool
*mp
;
7610 mp
= rte_mempool_lookup(res
->name
);
7612 cmdline_printf(cl
, "Cannot find mempool\n");
7615 rte_mempool_dump(stdout
, mp
);
7619 cmdline_parse_token_string_t cmd_dump_one_dump
=
7620 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result
, dump
,
7621 "dump_ring#dump_mempool");
7623 cmdline_parse_token_string_t cmd_dump_one_name
=
7624 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result
, name
, NULL
);
7626 cmdline_parse_inst_t cmd_dump_one
= {
7627 .f
= cmd_dump_one_parsed
, /* function to call */
7628 .data
= NULL
, /* 2nd arg of func */
7629 .help_str
= "dump one ring/mempool: dump_ring|dump_mempool <name>",
7630 .tokens
= { /* token list, NULL terminated */
7631 (void *)&cmd_dump_one_dump
,
7632 (void *)&cmd_dump_one_name
,
7637 /* *** Add/Del syn filter *** */
7638 struct cmd_syn_filter_result
{
7639 cmdline_fixed_string_t filter
;
7641 cmdline_fixed_string_t ops
;
7642 cmdline_fixed_string_t priority
;
7643 cmdline_fixed_string_t high
;
7644 cmdline_fixed_string_t queue
;
7649 cmd_syn_filter_parsed(void *parsed_result
,
7650 __attribute__((unused
)) struct cmdline
*cl
,
7651 __attribute__((unused
)) void *data
)
7653 struct cmd_syn_filter_result
*res
= parsed_result
;
7654 struct rte_eth_syn_filter syn_filter
;
7657 ret
= rte_eth_dev_filter_supported(res
->port_id
,
7658 RTE_ETH_FILTER_SYN
);
7660 printf("syn filter is not supported on port %u.\n",
7665 memset(&syn_filter
, 0, sizeof(syn_filter
));
7667 if (!strcmp(res
->ops
, "add")) {
7668 if (!strcmp(res
->high
, "high"))
7669 syn_filter
.hig_pri
= 1;
7671 syn_filter
.hig_pri
= 0;
7673 syn_filter
.queue
= res
->queue_id
;
7674 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
7679 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
7681 RTE_ETH_FILTER_DELETE
,
7685 printf("syn filter programming error: (%s)\n",
7689 cmdline_parse_token_string_t cmd_syn_filter_filter
=
7690 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result
,
7691 filter
, "syn_filter");
7692 cmdline_parse_token_num_t cmd_syn_filter_port_id
=
7693 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result
,
7695 cmdline_parse_token_string_t cmd_syn_filter_ops
=
7696 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result
,
7698 cmdline_parse_token_string_t cmd_syn_filter_priority
=
7699 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result
,
7700 priority
, "priority");
7701 cmdline_parse_token_string_t cmd_syn_filter_high
=
7702 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result
,
7704 cmdline_parse_token_string_t cmd_syn_filter_queue
=
7705 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result
,
7707 cmdline_parse_token_num_t cmd_syn_filter_queue_id
=
7708 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result
,
7711 cmdline_parse_inst_t cmd_syn_filter
= {
7712 .f
= cmd_syn_filter_parsed
,
7714 .help_str
= "add/delete syn filter",
7716 (void *)&cmd_syn_filter_filter
,
7717 (void *)&cmd_syn_filter_port_id
,
7718 (void *)&cmd_syn_filter_ops
,
7719 (void *)&cmd_syn_filter_priority
,
7720 (void *)&cmd_syn_filter_high
,
7721 (void *)&cmd_syn_filter_queue
,
7722 (void *)&cmd_syn_filter_queue_id
,
7727 /* *** ADD/REMOVE A 2tuple FILTER *** */
7728 struct cmd_2tuple_filter_result
{
7729 cmdline_fixed_string_t filter
;
7731 cmdline_fixed_string_t ops
;
7732 cmdline_fixed_string_t dst_port
;
7733 uint16_t dst_port_value
;
7734 cmdline_fixed_string_t protocol
;
7735 uint8_t protocol_value
;
7736 cmdline_fixed_string_t mask
;
7738 cmdline_fixed_string_t tcp_flags
;
7739 uint8_t tcp_flags_value
;
7740 cmdline_fixed_string_t priority
;
7741 uint8_t priority_value
;
7742 cmdline_fixed_string_t queue
;
7747 cmd_2tuple_filter_parsed(void *parsed_result
,
7748 __attribute__((unused
)) struct cmdline
*cl
,
7749 __attribute__((unused
)) void *data
)
7751 struct rte_eth_ntuple_filter filter
;
7752 struct cmd_2tuple_filter_result
*res
= parsed_result
;
7755 ret
= rte_eth_dev_filter_supported(res
->port_id
, RTE_ETH_FILTER_NTUPLE
);
7757 printf("ntuple filter is not supported on port %u.\n",
7762 memset(&filter
, 0, sizeof(struct rte_eth_ntuple_filter
));
7764 filter
.flags
= RTE_2TUPLE_FLAGS
;
7765 filter
.dst_port_mask
= (res
->mask_value
& 0x02) ? UINT16_MAX
: 0;
7766 filter
.proto_mask
= (res
->mask_value
& 0x01) ? UINT8_MAX
: 0;
7767 filter
.proto
= res
->protocol_value
;
7768 filter
.priority
= res
->priority_value
;
7769 if (res
->tcp_flags_value
!= 0 && filter
.proto
!= IPPROTO_TCP
) {
7770 printf("nonzero tcp_flags is only meaningful"
7771 " when protocol is TCP.\n");
7774 if (res
->tcp_flags_value
> TCP_FLAG_ALL
) {
7775 printf("invalid TCP flags.\n");
7779 if (res
->tcp_flags_value
!= 0) {
7780 filter
.flags
|= RTE_NTUPLE_FLAGS_TCP_FLAG
;
7781 filter
.tcp_flags
= res
->tcp_flags_value
;
7784 /* need convert to big endian. */
7785 filter
.dst_port
= rte_cpu_to_be_16(res
->dst_port_value
);
7786 filter
.queue
= res
->queue_id
;
7788 if (!strcmp(res
->ops
, "add"))
7789 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
7790 RTE_ETH_FILTER_NTUPLE
,
7794 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
7795 RTE_ETH_FILTER_NTUPLE
,
7796 RTE_ETH_FILTER_DELETE
,
7799 printf("2tuple filter programming error: (%s)\n",
7804 cmdline_parse_token_string_t cmd_2tuple_filter_filter
=
7805 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result
,
7806 filter
, "2tuple_filter");
7807 cmdline_parse_token_num_t cmd_2tuple_filter_port_id
=
7808 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result
,
7810 cmdline_parse_token_string_t cmd_2tuple_filter_ops
=
7811 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result
,
7813 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port
=
7814 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result
,
7815 dst_port
, "dst_port");
7816 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value
=
7817 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result
,
7818 dst_port_value
, UINT16
);
7819 cmdline_parse_token_string_t cmd_2tuple_filter_protocol
=
7820 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result
,
7821 protocol
, "protocol");
7822 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value
=
7823 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result
,
7824 protocol_value
, UINT8
);
7825 cmdline_parse_token_string_t cmd_2tuple_filter_mask
=
7826 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result
,
7828 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value
=
7829 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result
,
7831 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags
=
7832 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result
,
7833 tcp_flags
, "tcp_flags");
7834 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value
=
7835 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result
,
7836 tcp_flags_value
, UINT8
);
7837 cmdline_parse_token_string_t cmd_2tuple_filter_priority
=
7838 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result
,
7839 priority
, "priority");
7840 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value
=
7841 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result
,
7842 priority_value
, UINT8
);
7843 cmdline_parse_token_string_t cmd_2tuple_filter_queue
=
7844 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result
,
7846 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id
=
7847 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result
,
7850 cmdline_parse_inst_t cmd_2tuple_filter
= {
7851 .f
= cmd_2tuple_filter_parsed
,
7853 .help_str
= "add a 2tuple filter",
7855 (void *)&cmd_2tuple_filter_filter
,
7856 (void *)&cmd_2tuple_filter_port_id
,
7857 (void *)&cmd_2tuple_filter_ops
,
7858 (void *)&cmd_2tuple_filter_dst_port
,
7859 (void *)&cmd_2tuple_filter_dst_port_value
,
7860 (void *)&cmd_2tuple_filter_protocol
,
7861 (void *)&cmd_2tuple_filter_protocol_value
,
7862 (void *)&cmd_2tuple_filter_mask
,
7863 (void *)&cmd_2tuple_filter_mask_value
,
7864 (void *)&cmd_2tuple_filter_tcp_flags
,
7865 (void *)&cmd_2tuple_filter_tcp_flags_value
,
7866 (void *)&cmd_2tuple_filter_priority
,
7867 (void *)&cmd_2tuple_filter_priority_value
,
7868 (void *)&cmd_2tuple_filter_queue
,
7869 (void *)&cmd_2tuple_filter_queue_id
,
7874 /* *** ADD/REMOVE A 5tuple FILTER *** */
7875 struct cmd_5tuple_filter_result
{
7876 cmdline_fixed_string_t filter
;
7878 cmdline_fixed_string_t ops
;
7879 cmdline_fixed_string_t dst_ip
;
7880 cmdline_ipaddr_t dst_ip_value
;
7881 cmdline_fixed_string_t src_ip
;
7882 cmdline_ipaddr_t src_ip_value
;
7883 cmdline_fixed_string_t dst_port
;
7884 uint16_t dst_port_value
;
7885 cmdline_fixed_string_t src_port
;
7886 uint16_t src_port_value
;
7887 cmdline_fixed_string_t protocol
;
7888 uint8_t protocol_value
;
7889 cmdline_fixed_string_t mask
;
7891 cmdline_fixed_string_t tcp_flags
;
7892 uint8_t tcp_flags_value
;
7893 cmdline_fixed_string_t priority
;
7894 uint8_t priority_value
;
7895 cmdline_fixed_string_t queue
;
7900 cmd_5tuple_filter_parsed(void *parsed_result
,
7901 __attribute__((unused
)) struct cmdline
*cl
,
7902 __attribute__((unused
)) void *data
)
7904 struct rte_eth_ntuple_filter filter
;
7905 struct cmd_5tuple_filter_result
*res
= parsed_result
;
7908 ret
= rte_eth_dev_filter_supported(res
->port_id
, RTE_ETH_FILTER_NTUPLE
);
7910 printf("ntuple filter is not supported on port %u.\n",
7915 memset(&filter
, 0, sizeof(struct rte_eth_ntuple_filter
));
7917 filter
.flags
= RTE_5TUPLE_FLAGS
;
7918 filter
.dst_ip_mask
= (res
->mask_value
& 0x10) ? UINT32_MAX
: 0;
7919 filter
.src_ip_mask
= (res
->mask_value
& 0x08) ? UINT32_MAX
: 0;
7920 filter
.dst_port_mask
= (res
->mask_value
& 0x04) ? UINT16_MAX
: 0;
7921 filter
.src_port_mask
= (res
->mask_value
& 0x02) ? UINT16_MAX
: 0;
7922 filter
.proto_mask
= (res
->mask_value
& 0x01) ? UINT8_MAX
: 0;
7923 filter
.proto
= res
->protocol_value
;
7924 filter
.priority
= res
->priority_value
;
7925 if (res
->tcp_flags_value
!= 0 && filter
.proto
!= IPPROTO_TCP
) {
7926 printf("nonzero tcp_flags is only meaningful"
7927 " when protocol is TCP.\n");
7930 if (res
->tcp_flags_value
> TCP_FLAG_ALL
) {
7931 printf("invalid TCP flags.\n");
7935 if (res
->tcp_flags_value
!= 0) {
7936 filter
.flags
|= RTE_NTUPLE_FLAGS_TCP_FLAG
;
7937 filter
.tcp_flags
= res
->tcp_flags_value
;
7940 if (res
->dst_ip_value
.family
== AF_INET
)
7941 /* no need to convert, already big endian. */
7942 filter
.dst_ip
= res
->dst_ip_value
.addr
.ipv4
.s_addr
;
7944 if (filter
.dst_ip_mask
== 0) {
7945 printf("can not support ipv6 involved compare.\n");
7951 if (res
->src_ip_value
.family
== AF_INET
)
7952 /* no need to convert, already big endian. */
7953 filter
.src_ip
= res
->src_ip_value
.addr
.ipv4
.s_addr
;
7955 if (filter
.src_ip_mask
== 0) {
7956 printf("can not support ipv6 involved compare.\n");
7961 /* need convert to big endian. */
7962 filter
.dst_port
= rte_cpu_to_be_16(res
->dst_port_value
);
7963 filter
.src_port
= rte_cpu_to_be_16(res
->src_port_value
);
7964 filter
.queue
= res
->queue_id
;
7966 if (!strcmp(res
->ops
, "add"))
7967 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
7968 RTE_ETH_FILTER_NTUPLE
,
7972 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
7973 RTE_ETH_FILTER_NTUPLE
,
7974 RTE_ETH_FILTER_DELETE
,
7977 printf("5tuple filter programming error: (%s)\n",
7981 cmdline_parse_token_string_t cmd_5tuple_filter_filter
=
7982 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
7983 filter
, "5tuple_filter");
7984 cmdline_parse_token_num_t cmd_5tuple_filter_port_id
=
7985 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result
,
7987 cmdline_parse_token_string_t cmd_5tuple_filter_ops
=
7988 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
7990 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip
=
7991 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
7993 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value
=
7994 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result
,
7996 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip
=
7997 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
7999 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value
=
8000 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result
,
8002 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port
=
8003 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
8004 dst_port
, "dst_port");
8005 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value
=
8006 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result
,
8007 dst_port_value
, UINT16
);
8008 cmdline_parse_token_string_t cmd_5tuple_filter_src_port
=
8009 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
8010 src_port
, "src_port");
8011 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value
=
8012 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result
,
8013 src_port_value
, UINT16
);
8014 cmdline_parse_token_string_t cmd_5tuple_filter_protocol
=
8015 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
8016 protocol
, "protocol");
8017 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value
=
8018 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result
,
8019 protocol_value
, UINT8
);
8020 cmdline_parse_token_string_t cmd_5tuple_filter_mask
=
8021 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
8023 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value
=
8024 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result
,
8026 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags
=
8027 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
8028 tcp_flags
, "tcp_flags");
8029 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value
=
8030 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result
,
8031 tcp_flags_value
, UINT8
);
8032 cmdline_parse_token_string_t cmd_5tuple_filter_priority
=
8033 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
8034 priority
, "priority");
8035 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value
=
8036 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result
,
8037 priority_value
, UINT8
);
8038 cmdline_parse_token_string_t cmd_5tuple_filter_queue
=
8039 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result
,
8041 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id
=
8042 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result
,
8045 cmdline_parse_inst_t cmd_5tuple_filter
= {
8046 .f
= cmd_5tuple_filter_parsed
,
8048 .help_str
= "add/del a 5tuple filter",
8050 (void *)&cmd_5tuple_filter_filter
,
8051 (void *)&cmd_5tuple_filter_port_id
,
8052 (void *)&cmd_5tuple_filter_ops
,
8053 (void *)&cmd_5tuple_filter_dst_ip
,
8054 (void *)&cmd_5tuple_filter_dst_ip_value
,
8055 (void *)&cmd_5tuple_filter_src_ip
,
8056 (void *)&cmd_5tuple_filter_src_ip_value
,
8057 (void *)&cmd_5tuple_filter_dst_port
,
8058 (void *)&cmd_5tuple_filter_dst_port_value
,
8059 (void *)&cmd_5tuple_filter_src_port
,
8060 (void *)&cmd_5tuple_filter_src_port_value
,
8061 (void *)&cmd_5tuple_filter_protocol
,
8062 (void *)&cmd_5tuple_filter_protocol_value
,
8063 (void *)&cmd_5tuple_filter_mask
,
8064 (void *)&cmd_5tuple_filter_mask_value
,
8065 (void *)&cmd_5tuple_filter_tcp_flags
,
8066 (void *)&cmd_5tuple_filter_tcp_flags_value
,
8067 (void *)&cmd_5tuple_filter_priority
,
8068 (void *)&cmd_5tuple_filter_priority_value
,
8069 (void *)&cmd_5tuple_filter_queue
,
8070 (void *)&cmd_5tuple_filter_queue_id
,
8075 /* *** ADD/REMOVE A flex FILTER *** */
8076 struct cmd_flex_filter_result
{
8077 cmdline_fixed_string_t filter
;
8078 cmdline_fixed_string_t ops
;
8080 cmdline_fixed_string_t len
;
8082 cmdline_fixed_string_t bytes
;
8083 cmdline_fixed_string_t bytes_value
;
8084 cmdline_fixed_string_t mask
;
8085 cmdline_fixed_string_t mask_value
;
8086 cmdline_fixed_string_t priority
;
8087 uint8_t priority_value
;
8088 cmdline_fixed_string_t queue
;
8092 static int xdigit2val(unsigned char c
)
8097 else if (isupper(c
))
8105 cmd_flex_filter_parsed(void *parsed_result
,
8106 __attribute__((unused
)) struct cmdline
*cl
,
8107 __attribute__((unused
)) void *data
)
8110 struct rte_eth_flex_filter filter
;
8111 struct cmd_flex_filter_result
*res
= parsed_result
;
8112 char *bytes_ptr
, *mask_ptr
;
8113 uint16_t len
, i
, j
= 0;
8118 if (res
->len_value
> RTE_FLEX_FILTER_MAXLEN
) {
8119 printf("the len exceed the max length 128\n");
8122 memset(&filter
, 0, sizeof(struct rte_eth_flex_filter
));
8123 filter
.len
= res
->len_value
;
8124 filter
.priority
= res
->priority_value
;
8125 filter
.queue
= res
->queue_id
;
8126 bytes_ptr
= res
->bytes_value
;
8127 mask_ptr
= res
->mask_value
;
8129 /* translate bytes string to array. */
8130 if (bytes_ptr
[0] == '0' && ((bytes_ptr
[1] == 'x') ||
8131 (bytes_ptr
[1] == 'X')))
8133 len
= strnlen(bytes_ptr
, res
->len_value
* 2);
8134 if (len
== 0 || (len
% 8 != 0)) {
8135 printf("please check len and bytes input\n");
8138 for (i
= 0; i
< len
; i
++) {
8140 if (isxdigit(c
) == 0) {
8141 /* invalid characters. */
8142 printf("invalid input\n");
8145 val
= xdigit2val(c
);
8148 filter
.bytes
[j
] = byte
;
8149 printf("bytes[%d]:%02x ", j
, filter
.bytes
[j
]);
8156 /* translate mask string to uint8_t array. */
8157 if (mask_ptr
[0] == '0' && ((mask_ptr
[1] == 'x') ||
8158 (mask_ptr
[1] == 'X')))
8160 len
= strnlen(mask_ptr
, (res
->len_value
+ 3) / 4);
8162 printf("invalid input\n");
8167 for (i
= 0; i
< len
; i
++) {
8169 if (isxdigit(c
) == 0) {
8170 /* invalid characters. */
8171 printf("invalid input\n");
8174 val
= xdigit2val(c
);
8177 filter
.mask
[j
] = byte
;
8178 printf("mask[%d]:%02x ", j
, filter
.mask
[j
]);
8186 if (!strcmp(res
->ops
, "add"))
8187 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
8188 RTE_ETH_FILTER_FLEXIBLE
,
8192 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
8193 RTE_ETH_FILTER_FLEXIBLE
,
8194 RTE_ETH_FILTER_DELETE
,
8198 printf("flex filter setting error: (%s)\n", strerror(-ret
));
8201 cmdline_parse_token_string_t cmd_flex_filter_filter
=
8202 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result
,
8203 filter
, "flex_filter");
8204 cmdline_parse_token_num_t cmd_flex_filter_port_id
=
8205 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result
,
8207 cmdline_parse_token_string_t cmd_flex_filter_ops
=
8208 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result
,
8210 cmdline_parse_token_string_t cmd_flex_filter_len
=
8211 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result
,
8213 cmdline_parse_token_num_t cmd_flex_filter_len_value
=
8214 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result
,
8216 cmdline_parse_token_string_t cmd_flex_filter_bytes
=
8217 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result
,
8219 cmdline_parse_token_string_t cmd_flex_filter_bytes_value
=
8220 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result
,
8222 cmdline_parse_token_string_t cmd_flex_filter_mask
=
8223 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result
,
8225 cmdline_parse_token_string_t cmd_flex_filter_mask_value
=
8226 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result
,
8228 cmdline_parse_token_string_t cmd_flex_filter_priority
=
8229 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result
,
8230 priority
, "priority");
8231 cmdline_parse_token_num_t cmd_flex_filter_priority_value
=
8232 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result
,
8233 priority_value
, UINT8
);
8234 cmdline_parse_token_string_t cmd_flex_filter_queue
=
8235 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result
,
8237 cmdline_parse_token_num_t cmd_flex_filter_queue_id
=
8238 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result
,
8240 cmdline_parse_inst_t cmd_flex_filter
= {
8241 .f
= cmd_flex_filter_parsed
,
8243 .help_str
= "add/del a flex filter",
8245 (void *)&cmd_flex_filter_filter
,
8246 (void *)&cmd_flex_filter_port_id
,
8247 (void *)&cmd_flex_filter_ops
,
8248 (void *)&cmd_flex_filter_len
,
8249 (void *)&cmd_flex_filter_len_value
,
8250 (void *)&cmd_flex_filter_bytes
,
8251 (void *)&cmd_flex_filter_bytes_value
,
8252 (void *)&cmd_flex_filter_mask
,
8253 (void *)&cmd_flex_filter_mask_value
,
8254 (void *)&cmd_flex_filter_priority
,
8255 (void *)&cmd_flex_filter_priority_value
,
8256 (void *)&cmd_flex_filter_queue
,
8257 (void *)&cmd_flex_filter_queue_id
,
8262 /* *** Filters Control *** */
8264 /* *** deal with ethertype filter *** */
8265 struct cmd_ethertype_filter_result
{
8266 cmdline_fixed_string_t filter
;
8268 cmdline_fixed_string_t ops
;
8269 cmdline_fixed_string_t mac
;
8270 struct ether_addr mac_addr
;
8271 cmdline_fixed_string_t ethertype
;
8272 uint16_t ethertype_value
;
8273 cmdline_fixed_string_t drop
;
8274 cmdline_fixed_string_t queue
;
8278 cmdline_parse_token_string_t cmd_ethertype_filter_filter
=
8279 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result
,
8280 filter
, "ethertype_filter");
8281 cmdline_parse_token_num_t cmd_ethertype_filter_port_id
=
8282 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result
,
8284 cmdline_parse_token_string_t cmd_ethertype_filter_ops
=
8285 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result
,
8287 cmdline_parse_token_string_t cmd_ethertype_filter_mac
=
8288 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result
,
8289 mac
, "mac_addr#mac_ignr");
8290 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr
=
8291 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result
,
8293 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype
=
8294 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result
,
8295 ethertype
, "ethertype");
8296 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value
=
8297 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result
,
8298 ethertype_value
, UINT16
);
8299 cmdline_parse_token_string_t cmd_ethertype_filter_drop
=
8300 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result
,
8302 cmdline_parse_token_string_t cmd_ethertype_filter_queue
=
8303 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result
,
8305 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id
=
8306 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result
,
8310 cmd_ethertype_filter_parsed(void *parsed_result
,
8311 __attribute__((unused
)) struct cmdline
*cl
,
8312 __attribute__((unused
)) void *data
)
8314 struct cmd_ethertype_filter_result
*res
= parsed_result
;
8315 struct rte_eth_ethertype_filter filter
;
8318 ret
= rte_eth_dev_filter_supported(res
->port_id
,
8319 RTE_ETH_FILTER_ETHERTYPE
);
8321 printf("ethertype filter is not supported on port %u.\n",
8326 memset(&filter
, 0, sizeof(filter
));
8327 if (!strcmp(res
->mac
, "mac_addr")) {
8328 filter
.flags
|= RTE_ETHTYPE_FLAGS_MAC
;
8329 (void)rte_memcpy(&filter
.mac_addr
, &res
->mac_addr
,
8330 sizeof(struct ether_addr
));
8332 if (!strcmp(res
->drop
, "drop"))
8333 filter
.flags
|= RTE_ETHTYPE_FLAGS_DROP
;
8334 filter
.ether_type
= res
->ethertype_value
;
8335 filter
.queue
= res
->queue_id
;
8337 if (!strcmp(res
->ops
, "add"))
8338 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
8339 RTE_ETH_FILTER_ETHERTYPE
,
8343 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
8344 RTE_ETH_FILTER_ETHERTYPE
,
8345 RTE_ETH_FILTER_DELETE
,
8348 printf("ethertype filter programming error: (%s)\n",
8352 cmdline_parse_inst_t cmd_ethertype_filter
= {
8353 .f
= cmd_ethertype_filter_parsed
,
8355 .help_str
= "add or delete an ethertype filter entry",
8357 (void *)&cmd_ethertype_filter_filter
,
8358 (void *)&cmd_ethertype_filter_port_id
,
8359 (void *)&cmd_ethertype_filter_ops
,
8360 (void *)&cmd_ethertype_filter_mac
,
8361 (void *)&cmd_ethertype_filter_mac_addr
,
8362 (void *)&cmd_ethertype_filter_ethertype
,
8363 (void *)&cmd_ethertype_filter_ethertype_value
,
8364 (void *)&cmd_ethertype_filter_drop
,
8365 (void *)&cmd_ethertype_filter_queue
,
8366 (void *)&cmd_ethertype_filter_queue_id
,
8371 /* *** deal with flow director filter *** */
8372 struct cmd_flow_director_result
{
8373 cmdline_fixed_string_t flow_director_filter
;
8375 cmdline_fixed_string_t mode
;
8376 cmdline_fixed_string_t mode_value
;
8377 cmdline_fixed_string_t ops
;
8378 cmdline_fixed_string_t flow
;
8379 cmdline_fixed_string_t flow_type
;
8380 cmdline_fixed_string_t ether
;
8381 uint16_t ether_type
;
8382 cmdline_fixed_string_t src
;
8383 cmdline_ipaddr_t ip_src
;
8385 cmdline_fixed_string_t dst
;
8386 cmdline_ipaddr_t ip_dst
;
8388 cmdline_fixed_string_t verify_tag
;
8389 uint32_t verify_tag_value
;
8390 cmdline_ipaddr_t tos
;
8392 cmdline_ipaddr_t proto
;
8393 uint8_t proto_value
;
8394 cmdline_ipaddr_t ttl
;
8396 cmdline_fixed_string_t vlan
;
8397 uint16_t vlan_value
;
8398 cmdline_fixed_string_t flexbytes
;
8399 cmdline_fixed_string_t flexbytes_value
;
8400 cmdline_fixed_string_t pf_vf
;
8401 cmdline_fixed_string_t drop
;
8402 cmdline_fixed_string_t queue
;
8404 cmdline_fixed_string_t fd_id
;
8405 uint32_t fd_id_value
;
8406 cmdline_fixed_string_t mac
;
8407 struct ether_addr mac_addr
;
8408 cmdline_fixed_string_t tunnel
;
8409 cmdline_fixed_string_t tunnel_type
;
8410 cmdline_fixed_string_t tunnel_id
;
8411 uint32_t tunnel_id_value
;
8415 parse_flexbytes(const char *q_arg
, uint8_t *flexbytes
, uint16_t max_num
)
8418 const char *p
, *p0
= q_arg
;
8420 unsigned long int_fld
;
8421 char *str_fld
[max_num
];
8426 p
= strchr(p0
, '(');
8430 p0
= strchr(p
, ')');
8435 if (size
>= sizeof(s
))
8438 snprintf(s
, sizeof(s
), "%.*s", size
, p
);
8439 ret
= rte_strsplit(s
, sizeof(s
), str_fld
, max_num
, ',');
8440 if (ret
< 0 || ret
> max_num
)
8442 for (i
= 0; i
< ret
; i
++) {
8444 int_fld
= strtoul(str_fld
[i
], &end
, 0);
8445 if (errno
!= 0 || *end
!= '\0' || int_fld
> UINT8_MAX
)
8447 flexbytes
[i
] = (uint8_t)int_fld
;
8453 str2flowtype(char *string
)
8456 static const struct {
8459 } flowtype_str
[] = {
8460 {"raw", RTE_ETH_FLOW_RAW
},
8461 {"ipv4", RTE_ETH_FLOW_IPV4
},
8462 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4
},
8463 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP
},
8464 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP
},
8465 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP
},
8466 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER
},
8467 {"ipv6", RTE_ETH_FLOW_IPV6
},
8468 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6
},
8469 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP
},
8470 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP
},
8471 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP
},
8472 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER
},
8473 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD
},
8476 for (i
= 0; i
< RTE_DIM(flowtype_str
); i
++) {
8477 if (!strcmp(flowtype_str
[i
].str
, string
))
8478 return flowtype_str
[i
].type
;
8480 return RTE_ETH_FLOW_UNKNOWN
;
8483 static enum rte_eth_fdir_tunnel_type
8484 str2fdir_tunneltype(char *string
)
8488 static const struct {
8490 enum rte_eth_fdir_tunnel_type type
;
8491 } tunneltype_str
[] = {
8492 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE
},
8493 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN
},
8496 for (i
= 0; i
< RTE_DIM(tunneltype_str
); i
++) {
8497 if (!strcmp(tunneltype_str
[i
].str
, string
))
8498 return tunneltype_str
[i
].type
;
8500 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN
;
8503 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8505 if ((ip_addr).family == AF_INET) \
8506 (ip) = (ip_addr).addr.ipv4.s_addr; \
8508 printf("invalid parameter.\n"); \
8513 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8515 if ((ip_addr).family == AF_INET6) \
8516 (void)rte_memcpy(&(ip), \
8517 &((ip_addr).addr.ipv6), \
8518 sizeof(struct in6_addr)); \
8520 printf("invalid parameter.\n"); \
8526 cmd_flow_director_filter_parsed(void *parsed_result
,
8527 __attribute__((unused
)) struct cmdline
*cl
,
8528 __attribute__((unused
)) void *data
)
8530 struct cmd_flow_director_result
*res
= parsed_result
;
8531 struct rte_eth_fdir_filter entry
;
8532 uint8_t flexbytes
[RTE_ETH_FDIR_MAX_FLEXLEN
];
8534 unsigned long vf_id
;
8537 ret
= rte_eth_dev_filter_supported(res
->port_id
, RTE_ETH_FILTER_FDIR
);
8539 printf("flow director is not supported on port %u.\n",
8543 memset(flexbytes
, 0, sizeof(flexbytes
));
8544 memset(&entry
, 0, sizeof(struct rte_eth_fdir_filter
));
8546 if (fdir_conf
.mode
== RTE_FDIR_MODE_PERFECT_MAC_VLAN
) {
8547 if (strcmp(res
->mode_value
, "MAC-VLAN")) {
8548 printf("Please set mode to MAC-VLAN.\n");
8551 } else if (fdir_conf
.mode
== RTE_FDIR_MODE_PERFECT_TUNNEL
) {
8552 if (strcmp(res
->mode_value
, "Tunnel")) {
8553 printf("Please set mode to Tunnel.\n");
8557 if (strcmp(res
->mode_value
, "IP")) {
8558 printf("Please set mode to IP.\n");
8561 entry
.input
.flow_type
= str2flowtype(res
->flow_type
);
8564 ret
= parse_flexbytes(res
->flexbytes_value
,
8566 RTE_ETH_FDIR_MAX_FLEXLEN
);
8568 printf("error: Cannot parse flexbytes input.\n");
8572 switch (entry
.input
.flow_type
) {
8573 case RTE_ETH_FLOW_FRAG_IPV4
:
8574 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER
:
8575 entry
.input
.flow
.ip4_flow
.proto
= res
->proto_value
;
8576 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP
:
8577 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP
:
8578 IPV4_ADDR_TO_UINT(res
->ip_dst
,
8579 entry
.input
.flow
.ip4_flow
.dst_ip
);
8580 IPV4_ADDR_TO_UINT(res
->ip_src
,
8581 entry
.input
.flow
.ip4_flow
.src_ip
);
8582 entry
.input
.flow
.ip4_flow
.tos
= res
->tos_value
;
8583 entry
.input
.flow
.ip4_flow
.ttl
= res
->ttl_value
;
8584 /* need convert to big endian. */
8585 entry
.input
.flow
.udp4_flow
.dst_port
=
8586 rte_cpu_to_be_16(res
->port_dst
);
8587 entry
.input
.flow
.udp4_flow
.src_port
=
8588 rte_cpu_to_be_16(res
->port_src
);
8590 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP
:
8591 IPV4_ADDR_TO_UINT(res
->ip_dst
,
8592 entry
.input
.flow
.sctp4_flow
.ip
.dst_ip
);
8593 IPV4_ADDR_TO_UINT(res
->ip_src
,
8594 entry
.input
.flow
.sctp4_flow
.ip
.src_ip
);
8595 entry
.input
.flow
.ip4_flow
.tos
= res
->tos_value
;
8596 entry
.input
.flow
.ip4_flow
.ttl
= res
->ttl_value
;
8597 /* need convert to big endian. */
8598 entry
.input
.flow
.sctp4_flow
.dst_port
=
8599 rte_cpu_to_be_16(res
->port_dst
);
8600 entry
.input
.flow
.sctp4_flow
.src_port
=
8601 rte_cpu_to_be_16(res
->port_src
);
8602 entry
.input
.flow
.sctp4_flow
.verify_tag
=
8603 rte_cpu_to_be_32(res
->verify_tag_value
);
8605 case RTE_ETH_FLOW_FRAG_IPV6
:
8606 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER
:
8607 entry
.input
.flow
.ipv6_flow
.proto
= res
->proto_value
;
8608 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP
:
8609 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP
:
8610 IPV6_ADDR_TO_ARRAY(res
->ip_dst
,
8611 entry
.input
.flow
.ipv6_flow
.dst_ip
);
8612 IPV6_ADDR_TO_ARRAY(res
->ip_src
,
8613 entry
.input
.flow
.ipv6_flow
.src_ip
);
8614 entry
.input
.flow
.ipv6_flow
.tc
= res
->tos_value
;
8615 entry
.input
.flow
.ipv6_flow
.hop_limits
= res
->ttl_value
;
8616 /* need convert to big endian. */
8617 entry
.input
.flow
.udp6_flow
.dst_port
=
8618 rte_cpu_to_be_16(res
->port_dst
);
8619 entry
.input
.flow
.udp6_flow
.src_port
=
8620 rte_cpu_to_be_16(res
->port_src
);
8622 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP
:
8623 IPV6_ADDR_TO_ARRAY(res
->ip_dst
,
8624 entry
.input
.flow
.sctp6_flow
.ip
.dst_ip
);
8625 IPV6_ADDR_TO_ARRAY(res
->ip_src
,
8626 entry
.input
.flow
.sctp6_flow
.ip
.src_ip
);
8627 entry
.input
.flow
.ipv6_flow
.tc
= res
->tos_value
;
8628 entry
.input
.flow
.ipv6_flow
.hop_limits
= res
->ttl_value
;
8629 /* need convert to big endian. */
8630 entry
.input
.flow
.sctp6_flow
.dst_port
=
8631 rte_cpu_to_be_16(res
->port_dst
);
8632 entry
.input
.flow
.sctp6_flow
.src_port
=
8633 rte_cpu_to_be_16(res
->port_src
);
8634 entry
.input
.flow
.sctp6_flow
.verify_tag
=
8635 rte_cpu_to_be_32(res
->verify_tag_value
);
8637 case RTE_ETH_FLOW_L2_PAYLOAD
:
8638 entry
.input
.flow
.l2_flow
.ether_type
=
8639 rte_cpu_to_be_16(res
->ether_type
);
8645 if (fdir_conf
.mode
== RTE_FDIR_MODE_PERFECT_MAC_VLAN
)
8646 (void)rte_memcpy(&entry
.input
.flow
.mac_vlan_flow
.mac_addr
,
8648 sizeof(struct ether_addr
));
8650 if (fdir_conf
.mode
== RTE_FDIR_MODE_PERFECT_TUNNEL
) {
8651 (void)rte_memcpy(&entry
.input
.flow
.tunnel_flow
.mac_addr
,
8653 sizeof(struct ether_addr
));
8654 entry
.input
.flow
.tunnel_flow
.tunnel_type
=
8655 str2fdir_tunneltype(res
->tunnel_type
);
8656 entry
.input
.flow
.tunnel_flow
.tunnel_id
=
8657 rte_cpu_to_be_32(res
->tunnel_id_value
);
8660 (void)rte_memcpy(entry
.input
.flow_ext
.flexbytes
,
8662 RTE_ETH_FDIR_MAX_FLEXLEN
);
8664 entry
.input
.flow_ext
.vlan_tci
= rte_cpu_to_be_16(res
->vlan_value
);
8666 entry
.action
.flex_off
= 0; /*use 0 by default */
8667 if (!strcmp(res
->drop
, "drop"))
8668 entry
.action
.behavior
= RTE_ETH_FDIR_REJECT
;
8670 entry
.action
.behavior
= RTE_ETH_FDIR_ACCEPT
;
8672 if (fdir_conf
.mode
!= RTE_FDIR_MODE_PERFECT_MAC_VLAN
&&
8673 fdir_conf
.mode
!= RTE_FDIR_MODE_PERFECT_TUNNEL
) {
8674 if (!strcmp(res
->pf_vf
, "pf"))
8675 entry
.input
.flow_ext
.is_vf
= 0;
8676 else if (!strncmp(res
->pf_vf
, "vf", 2)) {
8677 struct rte_eth_dev_info dev_info
;
8679 memset(&dev_info
, 0, sizeof(dev_info
));
8680 rte_eth_dev_info_get(res
->port_id
, &dev_info
);
8682 vf_id
= strtoul(res
->pf_vf
+ 2, &end
, 10);
8683 if (errno
!= 0 || *end
!= '\0' ||
8684 vf_id
>= dev_info
.max_vfs
) {
8685 printf("invalid parameter %s.\n", res
->pf_vf
);
8688 entry
.input
.flow_ext
.is_vf
= 1;
8689 entry
.input
.flow_ext
.dst_id
= (uint16_t)vf_id
;
8691 printf("invalid parameter %s.\n", res
->pf_vf
);
8696 /* set to report FD ID by default */
8697 entry
.action
.report_status
= RTE_ETH_FDIR_REPORT_ID
;
8698 entry
.action
.rx_queue
= res
->queue_id
;
8699 entry
.soft_id
= res
->fd_id_value
;
8700 if (!strcmp(res
->ops
, "add"))
8701 ret
= rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_FDIR
,
8702 RTE_ETH_FILTER_ADD
, &entry
);
8703 else if (!strcmp(res
->ops
, "del"))
8704 ret
= rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_FDIR
,
8705 RTE_ETH_FILTER_DELETE
, &entry
);
8707 ret
= rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_FDIR
,
8708 RTE_ETH_FILTER_UPDATE
, &entry
);
8710 printf("flow director programming error: (%s)\n",
8714 cmdline_parse_token_string_t cmd_flow_director_filter
=
8715 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8716 flow_director_filter
, "flow_director_filter");
8717 cmdline_parse_token_num_t cmd_flow_director_port_id
=
8718 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8720 cmdline_parse_token_string_t cmd_flow_director_ops
=
8721 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8722 ops
, "add#del#update");
8723 cmdline_parse_token_string_t cmd_flow_director_flow
=
8724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8726 cmdline_parse_token_string_t cmd_flow_director_flow_type
=
8727 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8728 flow_type
, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8729 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8730 cmdline_parse_token_string_t cmd_flow_director_ether
=
8731 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8733 cmdline_parse_token_num_t cmd_flow_director_ether_type
=
8734 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8735 ether_type
, UINT16
);
8736 cmdline_parse_token_string_t cmd_flow_director_src
=
8737 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8739 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src
=
8740 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result
,
8742 cmdline_parse_token_num_t cmd_flow_director_port_src
=
8743 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8745 cmdline_parse_token_string_t cmd_flow_director_dst
=
8746 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8748 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst
=
8749 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result
,
8751 cmdline_parse_token_num_t cmd_flow_director_port_dst
=
8752 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8754 cmdline_parse_token_string_t cmd_flow_director_verify_tag
=
8755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8756 verify_tag
, "verify_tag");
8757 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value
=
8758 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8759 verify_tag_value
, UINT32
);
8760 cmdline_parse_token_string_t cmd_flow_director_tos
=
8761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8763 cmdline_parse_token_num_t cmd_flow_director_tos_value
=
8764 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8766 cmdline_parse_token_string_t cmd_flow_director_proto
=
8767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8769 cmdline_parse_token_num_t cmd_flow_director_proto_value
=
8770 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8771 proto_value
, UINT8
);
8772 cmdline_parse_token_string_t cmd_flow_director_ttl
=
8773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8775 cmdline_parse_token_num_t cmd_flow_director_ttl_value
=
8776 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8778 cmdline_parse_token_string_t cmd_flow_director_vlan
=
8779 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8781 cmdline_parse_token_num_t cmd_flow_director_vlan_value
=
8782 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8783 vlan_value
, UINT16
);
8784 cmdline_parse_token_string_t cmd_flow_director_flexbytes
=
8785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8786 flexbytes
, "flexbytes");
8787 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value
=
8788 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8789 flexbytes_value
, NULL
);
8790 cmdline_parse_token_string_t cmd_flow_director_drop
=
8791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8793 cmdline_parse_token_string_t cmd_flow_director_pf_vf
=
8794 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8796 cmdline_parse_token_string_t cmd_flow_director_queue
=
8797 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8799 cmdline_parse_token_num_t cmd_flow_director_queue_id
=
8800 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8802 cmdline_parse_token_string_t cmd_flow_director_fd_id
=
8803 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8805 cmdline_parse_token_num_t cmd_flow_director_fd_id_value
=
8806 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8807 fd_id_value
, UINT32
);
8809 cmdline_parse_token_string_t cmd_flow_director_mode
=
8810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8812 cmdline_parse_token_string_t cmd_flow_director_mode_ip
=
8813 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8815 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan
=
8816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8817 mode_value
, "MAC-VLAN");
8818 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel
=
8819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8820 mode_value
, "Tunnel");
8821 cmdline_parse_token_string_t cmd_flow_director_mac
=
8822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8824 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr
=
8825 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result
,
8827 cmdline_parse_token_string_t cmd_flow_director_tunnel
=
8828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8830 cmdline_parse_token_string_t cmd_flow_director_tunnel_type
=
8831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8832 tunnel_type
, "NVGRE#VxLAN");
8833 cmdline_parse_token_string_t cmd_flow_director_tunnel_id
=
8834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result
,
8835 tunnel_id
, "tunnel-id");
8836 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value
=
8837 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result
,
8838 tunnel_id_value
, UINT32
);
8840 cmdline_parse_inst_t cmd_add_del_ip_flow_director
= {
8841 .f
= cmd_flow_director_filter_parsed
,
8843 .help_str
= "add or delete an ip flow director entry on NIC",
8845 (void *)&cmd_flow_director_filter
,
8846 (void *)&cmd_flow_director_port_id
,
8847 (void *)&cmd_flow_director_mode
,
8848 (void *)&cmd_flow_director_mode_ip
,
8849 (void *)&cmd_flow_director_ops
,
8850 (void *)&cmd_flow_director_flow
,
8851 (void *)&cmd_flow_director_flow_type
,
8852 (void *)&cmd_flow_director_src
,
8853 (void *)&cmd_flow_director_ip_src
,
8854 (void *)&cmd_flow_director_dst
,
8855 (void *)&cmd_flow_director_ip_dst
,
8856 (void *)&cmd_flow_director_tos
,
8857 (void *)&cmd_flow_director_tos_value
,
8858 (void *)&cmd_flow_director_proto
,
8859 (void *)&cmd_flow_director_proto_value
,
8860 (void *)&cmd_flow_director_ttl
,
8861 (void *)&cmd_flow_director_ttl_value
,
8862 (void *)&cmd_flow_director_vlan
,
8863 (void *)&cmd_flow_director_vlan_value
,
8864 (void *)&cmd_flow_director_flexbytes
,
8865 (void *)&cmd_flow_director_flexbytes_value
,
8866 (void *)&cmd_flow_director_drop
,
8867 (void *)&cmd_flow_director_pf_vf
,
8868 (void *)&cmd_flow_director_queue
,
8869 (void *)&cmd_flow_director_queue_id
,
8870 (void *)&cmd_flow_director_fd_id
,
8871 (void *)&cmd_flow_director_fd_id_value
,
8876 cmdline_parse_inst_t cmd_add_del_udp_flow_director
= {
8877 .f
= cmd_flow_director_filter_parsed
,
8879 .help_str
= "add or delete an udp/tcp flow director entry on NIC",
8881 (void *)&cmd_flow_director_filter
,
8882 (void *)&cmd_flow_director_port_id
,
8883 (void *)&cmd_flow_director_mode
,
8884 (void *)&cmd_flow_director_mode_ip
,
8885 (void *)&cmd_flow_director_ops
,
8886 (void *)&cmd_flow_director_flow
,
8887 (void *)&cmd_flow_director_flow_type
,
8888 (void *)&cmd_flow_director_src
,
8889 (void *)&cmd_flow_director_ip_src
,
8890 (void *)&cmd_flow_director_port_src
,
8891 (void *)&cmd_flow_director_dst
,
8892 (void *)&cmd_flow_director_ip_dst
,
8893 (void *)&cmd_flow_director_port_dst
,
8894 (void *)&cmd_flow_director_tos
,
8895 (void *)&cmd_flow_director_tos_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_sctp_flow_director
= {
8913 .f
= cmd_flow_director_filter_parsed
,
8915 .help_str
= "add or delete a sctp flow director entry on NIC",
8917 (void *)&cmd_flow_director_filter
,
8918 (void *)&cmd_flow_director_port_id
,
8919 (void *)&cmd_flow_director_mode
,
8920 (void *)&cmd_flow_director_mode_ip
,
8921 (void *)&cmd_flow_director_ops
,
8922 (void *)&cmd_flow_director_flow
,
8923 (void *)&cmd_flow_director_flow_type
,
8924 (void *)&cmd_flow_director_src
,
8925 (void *)&cmd_flow_director_ip_src
,
8926 (void *)&cmd_flow_director_port_dst
,
8927 (void *)&cmd_flow_director_dst
,
8928 (void *)&cmd_flow_director_ip_dst
,
8929 (void *)&cmd_flow_director_port_dst
,
8930 (void *)&cmd_flow_director_verify_tag
,
8931 (void *)&cmd_flow_director_verify_tag_value
,
8932 (void *)&cmd_flow_director_tos
,
8933 (void *)&cmd_flow_director_tos_value
,
8934 (void *)&cmd_flow_director_ttl
,
8935 (void *)&cmd_flow_director_ttl_value
,
8936 (void *)&cmd_flow_director_vlan
,
8937 (void *)&cmd_flow_director_vlan_value
,
8938 (void *)&cmd_flow_director_flexbytes
,
8939 (void *)&cmd_flow_director_flexbytes_value
,
8940 (void *)&cmd_flow_director_drop
,
8941 (void *)&cmd_flow_director_pf_vf
,
8942 (void *)&cmd_flow_director_queue
,
8943 (void *)&cmd_flow_director_queue_id
,
8944 (void *)&cmd_flow_director_fd_id
,
8945 (void *)&cmd_flow_director_fd_id_value
,
8950 cmdline_parse_inst_t cmd_add_del_l2_flow_director
= {
8951 .f
= cmd_flow_director_filter_parsed
,
8953 .help_str
= "add or delete a L2 flow 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_ether
,
8963 (void *)&cmd_flow_director_ether_type
,
8964 (void *)&cmd_flow_director_flexbytes
,
8965 (void *)&cmd_flow_director_flexbytes_value
,
8966 (void *)&cmd_flow_director_drop
,
8967 (void *)&cmd_flow_director_pf_vf
,
8968 (void *)&cmd_flow_director_queue
,
8969 (void *)&cmd_flow_director_queue_id
,
8970 (void *)&cmd_flow_director_fd_id
,
8971 (void *)&cmd_flow_director_fd_id_value
,
8976 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director
= {
8977 .f
= cmd_flow_director_filter_parsed
,
8979 .help_str
= "add or delete a MAC VLAN flow director entry on NIC",
8981 (void *)&cmd_flow_director_filter
,
8982 (void *)&cmd_flow_director_port_id
,
8983 (void *)&cmd_flow_director_mode
,
8984 (void *)&cmd_flow_director_mode_mac_vlan
,
8985 (void *)&cmd_flow_director_ops
,
8986 (void *)&cmd_flow_director_mac
,
8987 (void *)&cmd_flow_director_mac_addr
,
8988 (void *)&cmd_flow_director_vlan
,
8989 (void *)&cmd_flow_director_vlan_value
,
8990 (void *)&cmd_flow_director_flexbytes
,
8991 (void *)&cmd_flow_director_flexbytes_value
,
8992 (void *)&cmd_flow_director_drop
,
8993 (void *)&cmd_flow_director_queue
,
8994 (void *)&cmd_flow_director_queue_id
,
8995 (void *)&cmd_flow_director_fd_id
,
8996 (void *)&cmd_flow_director_fd_id_value
,
9001 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director
= {
9002 .f
= cmd_flow_director_filter_parsed
,
9004 .help_str
= "add or delete a tunnel flow director entry on NIC",
9006 (void *)&cmd_flow_director_filter
,
9007 (void *)&cmd_flow_director_port_id
,
9008 (void *)&cmd_flow_director_mode
,
9009 (void *)&cmd_flow_director_mode_tunnel
,
9010 (void *)&cmd_flow_director_ops
,
9011 (void *)&cmd_flow_director_mac
,
9012 (void *)&cmd_flow_director_mac_addr
,
9013 (void *)&cmd_flow_director_vlan
,
9014 (void *)&cmd_flow_director_vlan_value
,
9015 (void *)&cmd_flow_director_tunnel
,
9016 (void *)&cmd_flow_director_tunnel_type
,
9017 (void *)&cmd_flow_director_tunnel_id
,
9018 (void *)&cmd_flow_director_tunnel_id_value
,
9019 (void *)&cmd_flow_director_flexbytes
,
9020 (void *)&cmd_flow_director_flexbytes_value
,
9021 (void *)&cmd_flow_director_drop
,
9022 (void *)&cmd_flow_director_queue
,
9023 (void *)&cmd_flow_director_queue_id
,
9024 (void *)&cmd_flow_director_fd_id
,
9025 (void *)&cmd_flow_director_fd_id_value
,
9030 struct cmd_flush_flow_director_result
{
9031 cmdline_fixed_string_t flush_flow_director
;
9035 cmdline_parse_token_string_t cmd_flush_flow_director_flush
=
9036 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result
,
9037 flush_flow_director
, "flush_flow_director");
9038 cmdline_parse_token_num_t cmd_flush_flow_director_port_id
=
9039 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result
,
9043 cmd_flush_flow_director_parsed(void *parsed_result
,
9044 __attribute__((unused
)) struct cmdline
*cl
,
9045 __attribute__((unused
)) void *data
)
9047 struct cmd_flow_director_result
*res
= parsed_result
;
9050 ret
= rte_eth_dev_filter_supported(res
->port_id
, RTE_ETH_FILTER_FDIR
);
9052 printf("flow director is not supported on port %u.\n",
9057 ret
= rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_FDIR
,
9058 RTE_ETH_FILTER_FLUSH
, NULL
);
9060 printf("flow director table flushing error: (%s)\n",
9064 cmdline_parse_inst_t cmd_flush_flow_director
= {
9065 .f
= cmd_flush_flow_director_parsed
,
9067 .help_str
= "flush all flow director entries of a device on NIC",
9069 (void *)&cmd_flush_flow_director_flush
,
9070 (void *)&cmd_flush_flow_director_port_id
,
9075 /* *** deal with flow director mask *** */
9076 struct cmd_flow_director_mask_result
{
9077 cmdline_fixed_string_t flow_director_mask
;
9079 cmdline_fixed_string_t mode
;
9080 cmdline_fixed_string_t mode_value
;
9081 cmdline_fixed_string_t vlan
;
9083 cmdline_fixed_string_t src_mask
;
9084 cmdline_ipaddr_t ipv4_src
;
9085 cmdline_ipaddr_t ipv6_src
;
9087 cmdline_fixed_string_t dst_mask
;
9088 cmdline_ipaddr_t ipv4_dst
;
9089 cmdline_ipaddr_t ipv6_dst
;
9091 cmdline_fixed_string_t mac
;
9092 uint8_t mac_addr_byte_mask
;
9093 cmdline_fixed_string_t tunnel_id
;
9094 uint32_t tunnel_id_mask
;
9095 cmdline_fixed_string_t tunnel_type
;
9096 uint8_t tunnel_type_mask
;
9100 cmd_flow_director_mask_parsed(void *parsed_result
,
9101 __attribute__((unused
)) struct cmdline
*cl
,
9102 __attribute__((unused
)) void *data
)
9104 struct cmd_flow_director_mask_result
*res
= parsed_result
;
9105 struct rte_eth_fdir_masks
*mask
;
9106 struct rte_port
*port
;
9108 if (res
->port_id
> nb_ports
) {
9109 printf("Invalid port, range is [0, %d]\n", nb_ports
- 1);
9113 port
= &ports
[res
->port_id
];
9114 /** Check if the port is not started **/
9115 if (port
->port_status
!= RTE_PORT_STOPPED
) {
9116 printf("Please stop port %d first\n", res
->port_id
);
9120 mask
= &port
->dev_conf
.fdir_conf
.mask
;
9122 if (fdir_conf
.mode
== RTE_FDIR_MODE_PERFECT_MAC_VLAN
) {
9123 if (strcmp(res
->mode_value
, "MAC-VLAN")) {
9124 printf("Please set mode to MAC-VLAN.\n");
9128 mask
->vlan_tci_mask
= rte_cpu_to_be_16(res
->vlan_mask
);
9129 } else if (fdir_conf
.mode
== RTE_FDIR_MODE_PERFECT_TUNNEL
) {
9130 if (strcmp(res
->mode_value
, "Tunnel")) {
9131 printf("Please set mode to Tunnel.\n");
9135 mask
->vlan_tci_mask
= rte_cpu_to_be_16(res
->vlan_mask
);
9136 mask
->mac_addr_byte_mask
= res
->mac_addr_byte_mask
;
9137 mask
->tunnel_id_mask
= rte_cpu_to_be_32(res
->tunnel_id_mask
);
9138 mask
->tunnel_type_mask
= res
->tunnel_type_mask
;
9140 if (strcmp(res
->mode_value
, "IP")) {
9141 printf("Please set mode to IP.\n");
9145 mask
->vlan_tci_mask
= rte_cpu_to_be_16(res
->vlan_mask
);
9146 IPV4_ADDR_TO_UINT(res
->ipv4_src
, mask
->ipv4_mask
.src_ip
);
9147 IPV4_ADDR_TO_UINT(res
->ipv4_dst
, mask
->ipv4_mask
.dst_ip
);
9148 IPV6_ADDR_TO_ARRAY(res
->ipv6_src
, mask
->ipv6_mask
.src_ip
);
9149 IPV6_ADDR_TO_ARRAY(res
->ipv6_dst
, mask
->ipv6_mask
.dst_ip
);
9150 mask
->src_port_mask
= rte_cpu_to_be_16(res
->port_src
);
9151 mask
->dst_port_mask
= rte_cpu_to_be_16(res
->port_dst
);
9154 cmd_reconfig_device_queue(res
->port_id
, 1, 1);
9157 cmdline_parse_token_string_t cmd_flow_director_mask
=
9158 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9159 flow_director_mask
, "flow_director_mask");
9160 cmdline_parse_token_num_t cmd_flow_director_mask_port_id
=
9161 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result
,
9163 cmdline_parse_token_string_t cmd_flow_director_mask_vlan
=
9164 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9166 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value
=
9167 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result
,
9169 cmdline_parse_token_string_t cmd_flow_director_mask_src
=
9170 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9171 src_mask
, "src_mask");
9172 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src
=
9173 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result
,
9175 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src
=
9176 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result
,
9178 cmdline_parse_token_num_t cmd_flow_director_mask_port_src
=
9179 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result
,
9181 cmdline_parse_token_string_t cmd_flow_director_mask_dst
=
9182 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9183 dst_mask
, "dst_mask");
9184 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst
=
9185 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result
,
9187 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst
=
9188 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result
,
9190 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst
=
9191 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result
,
9194 cmdline_parse_token_string_t cmd_flow_director_mask_mode
=
9195 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9197 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip
=
9198 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9200 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan
=
9201 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9202 mode_value
, "MAC-VLAN");
9203 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel
=
9204 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9205 mode_value
, "Tunnel");
9206 cmdline_parse_token_string_t cmd_flow_director_mask_mac
=
9207 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9209 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value
=
9210 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result
,
9211 mac_addr_byte_mask
, UINT8
);
9212 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type
=
9213 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9214 tunnel_type
, "tunnel-type");
9215 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value
=
9216 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result
,
9217 tunnel_type_mask
, UINT8
);
9218 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id
=
9219 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result
,
9220 tunnel_id
, "tunnel-id");
9221 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value
=
9222 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result
,
9223 tunnel_id_mask
, UINT32
);
9225 cmdline_parse_inst_t cmd_set_flow_director_ip_mask
= {
9226 .f
= cmd_flow_director_mask_parsed
,
9228 .help_str
= "set IP mode flow director's mask on NIC",
9230 (void *)&cmd_flow_director_mask
,
9231 (void *)&cmd_flow_director_mask_port_id
,
9232 (void *)&cmd_flow_director_mask_mode
,
9233 (void *)&cmd_flow_director_mask_mode_ip
,
9234 (void *)&cmd_flow_director_mask_vlan
,
9235 (void *)&cmd_flow_director_mask_vlan_value
,
9236 (void *)&cmd_flow_director_mask_src
,
9237 (void *)&cmd_flow_director_mask_ipv4_src
,
9238 (void *)&cmd_flow_director_mask_ipv6_src
,
9239 (void *)&cmd_flow_director_mask_port_src
,
9240 (void *)&cmd_flow_director_mask_dst
,
9241 (void *)&cmd_flow_director_mask_ipv4_dst
,
9242 (void *)&cmd_flow_director_mask_ipv6_dst
,
9243 (void *)&cmd_flow_director_mask_port_dst
,
9248 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask
= {
9249 .f
= cmd_flow_director_mask_parsed
,
9251 .help_str
= "set MAC VLAN mode flow director's mask on NIC",
9253 (void *)&cmd_flow_director_mask
,
9254 (void *)&cmd_flow_director_mask_port_id
,
9255 (void *)&cmd_flow_director_mask_mode
,
9256 (void *)&cmd_flow_director_mask_mode_mac_vlan
,
9257 (void *)&cmd_flow_director_mask_vlan
,
9258 (void *)&cmd_flow_director_mask_vlan_value
,
9263 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask
= {
9264 .f
= cmd_flow_director_mask_parsed
,
9266 .help_str
= "set tunnel mode flow director's mask on NIC",
9268 (void *)&cmd_flow_director_mask
,
9269 (void *)&cmd_flow_director_mask_port_id
,
9270 (void *)&cmd_flow_director_mask_mode
,
9271 (void *)&cmd_flow_director_mask_mode_tunnel
,
9272 (void *)&cmd_flow_director_mask_vlan
,
9273 (void *)&cmd_flow_director_mask_vlan_value
,
9274 (void *)&cmd_flow_director_mask_mac
,
9275 (void *)&cmd_flow_director_mask_mac_value
,
9276 (void *)&cmd_flow_director_mask_tunnel_type
,
9277 (void *)&cmd_flow_director_mask_tunnel_type_value
,
9278 (void *)&cmd_flow_director_mask_tunnel_id
,
9279 (void *)&cmd_flow_director_mask_tunnel_id_value
,
9284 /* *** deal with flow director mask on flexible payload *** */
9285 struct cmd_flow_director_flex_mask_result
{
9286 cmdline_fixed_string_t flow_director_flexmask
;
9288 cmdline_fixed_string_t flow
;
9289 cmdline_fixed_string_t flow_type
;
9290 cmdline_fixed_string_t mask
;
9294 cmd_flow_director_flex_mask_parsed(void *parsed_result
,
9295 __attribute__((unused
)) struct cmdline
*cl
,
9296 __attribute__((unused
)) void *data
)
9298 struct cmd_flow_director_flex_mask_result
*res
= parsed_result
;
9299 struct rte_eth_fdir_info fdir_info
;
9300 struct rte_eth_fdir_flex_mask flex_mask
;
9301 struct rte_port
*port
;
9302 uint32_t flow_type_mask
;
9306 if (res
->port_id
> nb_ports
) {
9307 printf("Invalid port, range is [0, %d]\n", nb_ports
- 1);
9311 port
= &ports
[res
->port_id
];
9312 /** Check if the port is not started **/
9313 if (port
->port_status
!= RTE_PORT_STOPPED
) {
9314 printf("Please stop port %d first\n", res
->port_id
);
9318 memset(&flex_mask
, 0, sizeof(struct rte_eth_fdir_flex_mask
));
9319 ret
= parse_flexbytes(res
->mask
,
9321 RTE_ETH_FDIR_MAX_FLEXLEN
);
9323 printf("error: Cannot parse mask input.\n");
9327 memset(&fdir_info
, 0, sizeof(fdir_info
));
9328 ret
= rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_FDIR
,
9329 RTE_ETH_FILTER_INFO
, &fdir_info
);
9331 printf("Cannot get FDir filter info\n");
9335 if (!strcmp(res
->flow_type
, "none")) {
9336 /* means don't specify the flow type */
9337 flex_mask
.flow_type
= RTE_ETH_FLOW_UNKNOWN
;
9338 for (i
= 0; i
< RTE_ETH_FLOW_MAX
; i
++)
9339 memset(&port
->dev_conf
.fdir_conf
.flex_conf
.flex_mask
[i
],
9340 0, sizeof(struct rte_eth_fdir_flex_mask
));
9341 port
->dev_conf
.fdir_conf
.flex_conf
.nb_flexmasks
= 1;
9342 (void)rte_memcpy(&port
->dev_conf
.fdir_conf
.flex_conf
.flex_mask
[0],
9344 sizeof(struct rte_eth_fdir_flex_mask
));
9345 cmd_reconfig_device_queue(res
->port_id
, 1, 1);
9348 flow_type_mask
= fdir_info
.flow_types_mask
[0];
9349 if (!strcmp(res
->flow_type
, "all")) {
9350 if (!flow_type_mask
) {
9351 printf("No flow type supported\n");
9354 for (i
= RTE_ETH_FLOW_UNKNOWN
; i
< RTE_ETH_FLOW_MAX
; i
++) {
9355 if (flow_type_mask
& (1 << i
)) {
9356 flex_mask
.flow_type
= i
;
9357 fdir_set_flex_mask(res
->port_id
, &flex_mask
);
9360 cmd_reconfig_device_queue(res
->port_id
, 1, 1);
9363 flex_mask
.flow_type
= str2flowtype(res
->flow_type
);
9364 if (!(flow_type_mask
& (1 << flex_mask
.flow_type
))) {
9365 printf("Flow type %s not supported on port %d\n",
9366 res
->flow_type
, res
->port_id
);
9369 fdir_set_flex_mask(res
->port_id
, &flex_mask
);
9370 cmd_reconfig_device_queue(res
->port_id
, 1, 1);
9373 cmdline_parse_token_string_t cmd_flow_director_flexmask
=
9374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result
,
9375 flow_director_flexmask
,
9376 "flow_director_flex_mask");
9377 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id
=
9378 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result
,
9380 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow
=
9381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result
,
9383 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type
=
9384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result
,
9385 flow_type
, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9386 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9387 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask
=
9388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result
,
9391 cmdline_parse_inst_t cmd_set_flow_director_flex_mask
= {
9392 .f
= cmd_flow_director_flex_mask_parsed
,
9394 .help_str
= "set flow director's flex mask on NIC",
9396 (void *)&cmd_flow_director_flexmask
,
9397 (void *)&cmd_flow_director_flexmask_port_id
,
9398 (void *)&cmd_flow_director_flexmask_flow
,
9399 (void *)&cmd_flow_director_flexmask_flow_type
,
9400 (void *)&cmd_flow_director_flexmask_mask
,
9405 /* *** deal with flow director flexible payload configuration *** */
9406 struct cmd_flow_director_flexpayload_result
{
9407 cmdline_fixed_string_t flow_director_flexpayload
;
9409 cmdline_fixed_string_t payload_layer
;
9410 cmdline_fixed_string_t payload_cfg
;
9414 parse_offsets(const char *q_arg
, uint16_t *offsets
, uint16_t max_num
)
9417 const char *p
, *p0
= q_arg
;
9419 unsigned long int_fld
;
9420 char *str_fld
[max_num
];
9425 p
= strchr(p0
, '(');
9429 p0
= strchr(p
, ')');
9434 if (size
>= sizeof(s
))
9437 snprintf(s
, sizeof(s
), "%.*s", size
, p
);
9438 ret
= rte_strsplit(s
, sizeof(s
), str_fld
, max_num
, ',');
9439 if (ret
< 0 || ret
> max_num
)
9441 for (i
= 0; i
< ret
; i
++) {
9443 int_fld
= strtoul(str_fld
[i
], &end
, 0);
9444 if (errno
!= 0 || *end
!= '\0' || int_fld
> UINT16_MAX
)
9446 offsets
[i
] = (uint16_t)int_fld
;
9452 cmd_flow_director_flxpld_parsed(void *parsed_result
,
9453 __attribute__((unused
)) struct cmdline
*cl
,
9454 __attribute__((unused
)) void *data
)
9456 struct cmd_flow_director_flexpayload_result
*res
= parsed_result
;
9457 struct rte_eth_flex_payload_cfg flex_cfg
;
9458 struct rte_port
*port
;
9461 if (res
->port_id
> nb_ports
) {
9462 printf("Invalid port, range is [0, %d]\n", nb_ports
- 1);
9466 port
= &ports
[res
->port_id
];
9467 /** Check if the port is not started **/
9468 if (port
->port_status
!= RTE_PORT_STOPPED
) {
9469 printf("Please stop port %d first\n", res
->port_id
);
9473 memset(&flex_cfg
, 0, sizeof(struct rte_eth_flex_payload_cfg
));
9475 if (!strcmp(res
->payload_layer
, "raw"))
9476 flex_cfg
.type
= RTE_ETH_RAW_PAYLOAD
;
9477 else if (!strcmp(res
->payload_layer
, "l2"))
9478 flex_cfg
.type
= RTE_ETH_L2_PAYLOAD
;
9479 else if (!strcmp(res
->payload_layer
, "l3"))
9480 flex_cfg
.type
= RTE_ETH_L3_PAYLOAD
;
9481 else if (!strcmp(res
->payload_layer
, "l4"))
9482 flex_cfg
.type
= RTE_ETH_L4_PAYLOAD
;
9484 ret
= parse_offsets(res
->payload_cfg
, flex_cfg
.src_offset
,
9485 RTE_ETH_FDIR_MAX_FLEXLEN
);
9487 printf("error: Cannot parse flex payload input.\n");
9491 fdir_set_flex_payload(res
->port_id
, &flex_cfg
);
9492 cmd_reconfig_device_queue(res
->port_id
, 1, 1);
9495 cmdline_parse_token_string_t cmd_flow_director_flexpayload
=
9496 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result
,
9497 flow_director_flexpayload
,
9498 "flow_director_flex_payload");
9499 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id
=
9500 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result
,
9502 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer
=
9503 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result
,
9504 payload_layer
, "raw#l2#l3#l4");
9505 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg
=
9506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result
,
9509 cmdline_parse_inst_t cmd_set_flow_director_flex_payload
= {
9510 .f
= cmd_flow_director_flxpld_parsed
,
9512 .help_str
= "set flow director's flex payload on NIC",
9514 (void *)&cmd_flow_director_flexpayload
,
9515 (void *)&cmd_flow_director_flexpayload_port_id
,
9516 (void *)&cmd_flow_director_flexpayload_payload_layer
,
9517 (void *)&cmd_flow_director_flexpayload_payload_cfg
,
9522 /* *** Classification Filters Control *** */
9523 /* *** Get symmetric hash enable per port *** */
9524 struct cmd_get_sym_hash_ena_per_port_result
{
9525 cmdline_fixed_string_t get_sym_hash_ena_per_port
;
9530 cmd_get_sym_hash_per_port_parsed(void *parsed_result
,
9531 __rte_unused
struct cmdline
*cl
,
9532 __rte_unused
void *data
)
9534 struct cmd_get_sym_hash_ena_per_port_result
*res
= parsed_result
;
9535 struct rte_eth_hash_filter_info info
;
9538 if (rte_eth_dev_filter_supported(res
->port_id
,
9539 RTE_ETH_FILTER_HASH
) < 0) {
9540 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9545 memset(&info
, 0, sizeof(info
));
9546 info
.info_type
= RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT
;
9547 ret
= rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_HASH
,
9548 RTE_ETH_FILTER_GET
, &info
);
9551 printf("Cannot get symmetric hash enable per port "
9552 "on port %u\n", res
->port_id
);
9556 printf("Symmetric hash is %s on port %u\n", info
.info
.enable
?
9557 "enabled" : "disabled", res
->port_id
);
9560 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all
=
9561 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result
,
9562 get_sym_hash_ena_per_port
, "get_sym_hash_ena_per_port");
9563 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id
=
9564 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result
,
9567 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port
= {
9568 .f
= cmd_get_sym_hash_per_port_parsed
,
9570 .help_str
= "get_sym_hash_ena_per_port port_id",
9572 (void *)&cmd_get_sym_hash_ena_per_port_all
,
9573 (void *)&cmd_get_sym_hash_ena_per_port_port_id
,
9578 /* *** Set symmetric hash enable per port *** */
9579 struct cmd_set_sym_hash_ena_per_port_result
{
9580 cmdline_fixed_string_t set_sym_hash_ena_per_port
;
9581 cmdline_fixed_string_t enable
;
9586 cmd_set_sym_hash_per_port_parsed(void *parsed_result
,
9587 __rte_unused
struct cmdline
*cl
,
9588 __rte_unused
void *data
)
9590 struct cmd_set_sym_hash_ena_per_port_result
*res
= parsed_result
;
9591 struct rte_eth_hash_filter_info info
;
9594 if (rte_eth_dev_filter_supported(res
->port_id
,
9595 RTE_ETH_FILTER_HASH
) < 0) {
9596 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9601 memset(&info
, 0, sizeof(info
));
9602 info
.info_type
= RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT
;
9603 if (!strcmp(res
->enable
, "enable"))
9604 info
.info
.enable
= 1;
9605 ret
= rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_HASH
,
9606 RTE_ETH_FILTER_SET
, &info
);
9608 printf("Cannot set symmetric hash enable per port on "
9609 "port %u\n", res
->port_id
);
9612 printf("Symmetric hash has been set to %s on port %u\n",
9613 res
->enable
, res
->port_id
);
9616 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all
=
9617 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result
,
9618 set_sym_hash_ena_per_port
, "set_sym_hash_ena_per_port");
9619 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id
=
9620 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result
,
9622 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable
=
9623 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result
,
9624 enable
, "enable#disable");
9626 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port
= {
9627 .f
= cmd_set_sym_hash_per_port_parsed
,
9629 .help_str
= "set_sym_hash_ena_per_port port_id enable|disable",
9631 (void *)&cmd_set_sym_hash_ena_per_port_all
,
9632 (void *)&cmd_set_sym_hash_ena_per_port_port_id
,
9633 (void *)&cmd_set_sym_hash_ena_per_port_enable
,
9638 /* Get global config of hash function */
9639 struct cmd_get_hash_global_config_result
{
9640 cmdline_fixed_string_t get_hash_global_config
;
9645 flowtype_to_str(uint16_t ftype
)
9652 {"ipv4", RTE_ETH_FLOW_IPV4
},
9653 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4
},
9654 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP
},
9655 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP
},
9656 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP
},
9657 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER
},
9658 {"ipv6", RTE_ETH_FLOW_IPV6
},
9659 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6
},
9660 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP
},
9661 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP
},
9662 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP
},
9663 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER
},
9664 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD
},
9665 {"port", RTE_ETH_FLOW_PORT
},
9666 {"vxlan", RTE_ETH_FLOW_VXLAN
},
9667 {"geneve", RTE_ETH_FLOW_GENEVE
},
9668 {"nvgre", RTE_ETH_FLOW_NVGRE
},
9671 for (i
= 0; i
< RTE_DIM(ftype_table
); i
++) {
9672 if (ftype_table
[i
].ftype
== ftype
)
9673 return ftype_table
[i
].str
;
9680 cmd_get_hash_global_config_parsed(void *parsed_result
,
9681 __rte_unused
struct cmdline
*cl
,
9682 __rte_unused
void *data
)
9684 struct cmd_get_hash_global_config_result
*res
= parsed_result
;
9685 struct rte_eth_hash_filter_info info
;
9686 uint32_t idx
, offset
;
9691 if (rte_eth_dev_filter_supported(res
->port_id
,
9692 RTE_ETH_FILTER_HASH
) < 0) {
9693 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9698 memset(&info
, 0, sizeof(info
));
9699 info
.info_type
= RTE_ETH_HASH_FILTER_GLOBAL_CONFIG
;
9700 ret
= rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_HASH
,
9701 RTE_ETH_FILTER_GET
, &info
);
9703 printf("Cannot get hash global configurations by port %d\n",
9708 switch (info
.info
.global_conf
.hash_func
) {
9709 case RTE_ETH_HASH_FUNCTION_TOEPLITZ
:
9710 printf("Hash function is Toeplitz\n");
9712 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR
:
9713 printf("Hash function is Simple XOR\n");
9716 printf("Unknown hash function\n");
9720 for (i
= 0; i
< RTE_ETH_FLOW_MAX
; i
++) {
9721 idx
= i
/ UINT32_BIT
;
9722 offset
= i
% UINT32_BIT
;
9723 if (!(info
.info
.global_conf
.valid_bit_mask
[idx
] &
9726 str
= flowtype_to_str(i
);
9729 printf("Symmetric hash is %s globally for flow type %s "
9731 ((info
.info
.global_conf
.sym_hash_enable_mask
[idx
] &
9732 (1UL << offset
)) ? "enabled" : "disabled"), str
,
9737 cmdline_parse_token_string_t cmd_get_hash_global_config_all
=
9738 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result
,
9739 get_hash_global_config
, "get_hash_global_config");
9740 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id
=
9741 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result
,
9744 cmdline_parse_inst_t cmd_get_hash_global_config
= {
9745 .f
= cmd_get_hash_global_config_parsed
,
9747 .help_str
= "get_hash_global_config port_id",
9749 (void *)&cmd_get_hash_global_config_all
,
9750 (void *)&cmd_get_hash_global_config_port_id
,
9755 /* Set global config of hash function */
9756 struct cmd_set_hash_global_config_result
{
9757 cmdline_fixed_string_t set_hash_global_config
;
9759 cmdline_fixed_string_t hash_func
;
9760 cmdline_fixed_string_t flow_type
;
9761 cmdline_fixed_string_t enable
;
9765 cmd_set_hash_global_config_parsed(void *parsed_result
,
9766 __rte_unused
struct cmdline
*cl
,
9767 __rte_unused
void *data
)
9769 struct cmd_set_hash_global_config_result
*res
= parsed_result
;
9770 struct rte_eth_hash_filter_info info
;
9771 uint32_t ftype
, idx
, offset
;
9774 if (rte_eth_dev_filter_supported(res
->port_id
,
9775 RTE_ETH_FILTER_HASH
) < 0) {
9776 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9780 memset(&info
, 0, sizeof(info
));
9781 info
.info_type
= RTE_ETH_HASH_FILTER_GLOBAL_CONFIG
;
9782 if (!strcmp(res
->hash_func
, "toeplitz"))
9783 info
.info
.global_conf
.hash_func
=
9784 RTE_ETH_HASH_FUNCTION_TOEPLITZ
;
9785 else if (!strcmp(res
->hash_func
, "simple_xor"))
9786 info
.info
.global_conf
.hash_func
=
9787 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR
;
9788 else if (!strcmp(res
->hash_func
, "default"))
9789 info
.info
.global_conf
.hash_func
=
9790 RTE_ETH_HASH_FUNCTION_DEFAULT
;
9792 ftype
= str2flowtype(res
->flow_type
);
9793 idx
= ftype
/ (CHAR_BIT
* sizeof(uint32_t));
9794 offset
= ftype
% (CHAR_BIT
* sizeof(uint32_t));
9795 info
.info
.global_conf
.valid_bit_mask
[idx
] |= (1UL << offset
);
9796 if (!strcmp(res
->enable
, "enable"))
9797 info
.info
.global_conf
.sym_hash_enable_mask
[idx
] |=
9799 ret
= rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_HASH
,
9800 RTE_ETH_FILTER_SET
, &info
);
9802 printf("Cannot set global hash configurations by port %d\n",
9805 printf("Global hash configurations have been set "
9806 "succcessfully by port %d\n", res
->port_id
);
9809 cmdline_parse_token_string_t cmd_set_hash_global_config_all
=
9810 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result
,
9811 set_hash_global_config
, "set_hash_global_config");
9812 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id
=
9813 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result
,
9815 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func
=
9816 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result
,
9817 hash_func
, "toeplitz#simple_xor#default");
9818 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type
=
9819 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result
,
9821 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9822 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9823 cmdline_parse_token_string_t cmd_set_hash_global_config_enable
=
9824 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result
,
9825 enable
, "enable#disable");
9827 cmdline_parse_inst_t cmd_set_hash_global_config
= {
9828 .f
= cmd_set_hash_global_config_parsed
,
9830 .help_str
= "set_hash_global_config port_id "
9831 "toeplitz|simple_xor|default "
9832 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9833 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9836 (void *)&cmd_set_hash_global_config_all
,
9837 (void *)&cmd_set_hash_global_config_port_id
,
9838 (void *)&cmd_set_hash_global_config_hash_func
,
9839 (void *)&cmd_set_hash_global_config_flow_type
,
9840 (void *)&cmd_set_hash_global_config_enable
,
9845 /* Set hash input set */
9846 struct cmd_set_hash_input_set_result
{
9847 cmdline_fixed_string_t set_hash_input_set
;
9849 cmdline_fixed_string_t flow_type
;
9850 cmdline_fixed_string_t inset_field
;
9851 cmdline_fixed_string_t select
;
9854 static enum rte_eth_input_set_field
9855 str2inset(char *string
)
9859 static const struct {
9861 enum rte_eth_input_set_field inset
;
9863 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE
},
9864 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN
},
9865 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN
},
9866 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4
},
9867 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4
},
9868 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS
},
9869 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO
},
9870 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL
},
9871 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6
},
9872 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6
},
9873 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC
},
9874 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER
},
9875 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS
},
9876 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT
},
9877 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT
},
9878 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT
},
9879 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT
},
9880 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT
},
9881 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT
},
9882 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG
},
9883 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY
},
9884 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY
},
9885 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD
},
9886 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD
},
9887 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD
},
9888 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD
},
9889 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD
},
9890 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD
},
9891 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD
},
9892 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD
},
9893 {"none", RTE_ETH_INPUT_SET_NONE
},
9896 for (i
= 0; i
< RTE_DIM(inset_table
); i
++) {
9897 if (!strcmp(string
, inset_table
[i
].str
))
9898 return inset_table
[i
].inset
;
9901 return RTE_ETH_INPUT_SET_UNKNOWN
;
9905 cmd_set_hash_input_set_parsed(void *parsed_result
,
9906 __rte_unused
struct cmdline
*cl
,
9907 __rte_unused
void *data
)
9909 struct cmd_set_hash_input_set_result
*res
= parsed_result
;
9910 struct rte_eth_hash_filter_info info
;
9912 memset(&info
, 0, sizeof(info
));
9913 info
.info_type
= RTE_ETH_HASH_FILTER_INPUT_SET_SELECT
;
9914 info
.info
.input_set_conf
.flow_type
= str2flowtype(res
->flow_type
);
9915 info
.info
.input_set_conf
.field
[0] = str2inset(res
->inset_field
);
9916 info
.info
.input_set_conf
.inset_size
= 1;
9917 if (!strcmp(res
->select
, "select"))
9918 info
.info
.input_set_conf
.op
= RTE_ETH_INPUT_SET_SELECT
;
9919 else if (!strcmp(res
->select
, "add"))
9920 info
.info
.input_set_conf
.op
= RTE_ETH_INPUT_SET_ADD
;
9921 rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_HASH
,
9922 RTE_ETH_FILTER_SET
, &info
);
9925 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd
=
9926 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result
,
9927 set_hash_input_set
, "set_hash_input_set");
9928 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id
=
9929 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result
,
9931 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type
=
9932 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result
,
9934 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9935 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9936 cmdline_parse_token_string_t cmd_set_hash_input_set_field
=
9937 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result
,
9939 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9940 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9941 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9942 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9943 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9945 cmdline_parse_token_string_t cmd_set_hash_input_set_select
=
9946 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result
,
9947 select
, "select#add");
9949 cmdline_parse_inst_t cmd_set_hash_input_set
= {
9950 .f
= cmd_set_hash_input_set_parsed
,
9952 .help_str
= "set_hash_input_set <port_id> "
9953 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9954 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9955 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9956 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9957 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9958 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9959 "fld-7th|fld-8th|none select|add",
9961 (void *)&cmd_set_hash_input_set_cmd
,
9962 (void *)&cmd_set_hash_input_set_port_id
,
9963 (void *)&cmd_set_hash_input_set_flow_type
,
9964 (void *)&cmd_set_hash_input_set_field
,
9965 (void *)&cmd_set_hash_input_set_select
,
9970 /* Set flow director input set */
9971 struct cmd_set_fdir_input_set_result
{
9972 cmdline_fixed_string_t set_fdir_input_set
;
9974 cmdline_fixed_string_t flow_type
;
9975 cmdline_fixed_string_t inset_field
;
9976 cmdline_fixed_string_t select
;
9980 cmd_set_fdir_input_set_parsed(void *parsed_result
,
9981 __rte_unused
struct cmdline
*cl
,
9982 __rte_unused
void *data
)
9984 struct cmd_set_fdir_input_set_result
*res
= parsed_result
;
9985 struct rte_eth_fdir_filter_info info
;
9987 memset(&info
, 0, sizeof(info
));
9988 info
.info_type
= RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT
;
9989 info
.info
.input_set_conf
.flow_type
= str2flowtype(res
->flow_type
);
9990 info
.info
.input_set_conf
.field
[0] = str2inset(res
->inset_field
);
9991 info
.info
.input_set_conf
.inset_size
= 1;
9992 if (!strcmp(res
->select
, "select"))
9993 info
.info
.input_set_conf
.op
= RTE_ETH_INPUT_SET_SELECT
;
9994 else if (!strcmp(res
->select
, "add"))
9995 info
.info
.input_set_conf
.op
= RTE_ETH_INPUT_SET_ADD
;
9996 rte_eth_dev_filter_ctrl(res
->port_id
, RTE_ETH_FILTER_FDIR
,
9997 RTE_ETH_FILTER_SET
, &info
);
10000 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd
=
10001 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result
,
10002 set_fdir_input_set
, "set_fdir_input_set");
10003 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id
=
10004 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result
,
10006 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type
=
10007 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result
,
10009 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10010 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10011 cmdline_parse_token_string_t cmd_set_fdir_input_set_field
=
10012 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result
,
10014 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10015 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10016 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10017 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10018 "sctp-veri-tag#none");
10019 cmdline_parse_token_string_t cmd_set_fdir_input_set_select
=
10020 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result
,
10021 select
, "select#add");
10023 cmdline_parse_inst_t cmd_set_fdir_input_set
= {
10024 .f
= cmd_set_fdir_input_set_parsed
,
10026 .help_str
= "set_fdir_input_set <port_id> "
10027 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10028 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10029 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10030 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10031 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10032 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10033 "sctp-veri-tag|none select|add",
10035 (void *)&cmd_set_fdir_input_set_cmd
,
10036 (void *)&cmd_set_fdir_input_set_port_id
,
10037 (void *)&cmd_set_fdir_input_set_flow_type
,
10038 (void *)&cmd_set_fdir_input_set_field
,
10039 (void *)&cmd_set_fdir_input_set_select
,
10044 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10045 struct cmd_mcast_addr_result
{
10046 cmdline_fixed_string_t mcast_addr_cmd
;
10047 cmdline_fixed_string_t what
;
10049 struct ether_addr mc_addr
;
10052 static void cmd_mcast_addr_parsed(void *parsed_result
,
10053 __attribute__((unused
)) struct cmdline
*cl
,
10054 __attribute__((unused
)) void *data
)
10056 struct cmd_mcast_addr_result
*res
= parsed_result
;
10058 if (!is_multicast_ether_addr(&res
->mc_addr
)) {
10059 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10060 res
->mc_addr
.addr_bytes
[0], res
->mc_addr
.addr_bytes
[1],
10061 res
->mc_addr
.addr_bytes
[2], res
->mc_addr
.addr_bytes
[3],
10062 res
->mc_addr
.addr_bytes
[4], res
->mc_addr
.addr_bytes
[5]);
10065 if (strcmp(res
->what
, "add") == 0)
10066 mcast_addr_add(res
->port_num
, &res
->mc_addr
);
10068 mcast_addr_remove(res
->port_num
, &res
->mc_addr
);
10071 cmdline_parse_token_string_t cmd_mcast_addr_cmd
=
10072 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result
,
10073 mcast_addr_cmd
, "mcast_addr");
10074 cmdline_parse_token_string_t cmd_mcast_addr_what
=
10075 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result
, what
,
10077 cmdline_parse_token_num_t cmd_mcast_addr_portnum
=
10078 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result
, port_num
, UINT8
);
10079 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr
=
10080 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result
, address
);
10082 cmdline_parse_inst_t cmd_mcast_addr
= {
10083 .f
= cmd_mcast_addr_parsed
,
10085 .help_str
= "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
10087 (void *)&cmd_mcast_addr_cmd
,
10088 (void *)&cmd_mcast_addr_what
,
10089 (void *)&cmd_mcast_addr_portnum
,
10090 (void *)&cmd_mcast_addr_addr
,
10095 /* l2 tunnel config
10096 * only support E-tag now.
10099 /* Ether type config */
10100 struct cmd_config_l2_tunnel_eth_type_result
{
10101 cmdline_fixed_string_t port
;
10102 cmdline_fixed_string_t config
;
10103 cmdline_fixed_string_t all
;
10105 cmdline_fixed_string_t l2_tunnel
;
10106 cmdline_fixed_string_t l2_tunnel_type
;
10107 cmdline_fixed_string_t eth_type
;
10108 uint16_t eth_type_val
;
10111 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port
=
10112 TOKEN_STRING_INITIALIZER
10113 (struct cmd_config_l2_tunnel_eth_type_result
,
10115 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config
=
10116 TOKEN_STRING_INITIALIZER
10117 (struct cmd_config_l2_tunnel_eth_type_result
,
10119 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str
=
10120 TOKEN_STRING_INITIALIZER
10121 (struct cmd_config_l2_tunnel_eth_type_result
,
10123 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id
=
10124 TOKEN_NUM_INITIALIZER
10125 (struct cmd_config_l2_tunnel_eth_type_result
,
10127 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel
=
10128 TOKEN_STRING_INITIALIZER
10129 (struct cmd_config_l2_tunnel_eth_type_result
,
10130 l2_tunnel
, "l2-tunnel");
10131 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type
=
10132 TOKEN_STRING_INITIALIZER
10133 (struct cmd_config_l2_tunnel_eth_type_result
,
10134 l2_tunnel_type
, "E-tag");
10135 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type
=
10136 TOKEN_STRING_INITIALIZER
10137 (struct cmd_config_l2_tunnel_eth_type_result
,
10138 eth_type
, "ether-type");
10139 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val
=
10140 TOKEN_NUM_INITIALIZER
10141 (struct cmd_config_l2_tunnel_eth_type_result
,
10142 eth_type_val
, UINT16
);
10144 static enum rte_eth_tunnel_type
10145 str2fdir_l2_tunnel_type(char *string
)
10149 static const struct {
10151 enum rte_eth_tunnel_type type
;
10152 } l2_tunnel_type_str
[] = {
10153 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG
},
10156 for (i
= 0; i
< RTE_DIM(l2_tunnel_type_str
); i
++) {
10157 if (!strcmp(l2_tunnel_type_str
[i
].str
, string
))
10158 return l2_tunnel_type_str
[i
].type
;
10160 return RTE_TUNNEL_TYPE_NONE
;
10163 /* ether type config for all ports */
10165 cmd_config_l2_tunnel_eth_type_all_parsed
10166 (void *parsed_result
,
10167 __attribute__((unused
)) struct cmdline
*cl
,
10168 __attribute__((unused
)) void *data
)
10170 struct cmd_config_l2_tunnel_eth_type_result
*res
= parsed_result
;
10171 struct rte_eth_l2_tunnel_conf entry
;
10174 entry
.l2_tunnel_type
= str2fdir_l2_tunnel_type(res
->l2_tunnel_type
);
10175 entry
.ether_type
= res
->eth_type_val
;
10177 FOREACH_PORT(pid
, ports
) {
10178 rte_eth_dev_l2_tunnel_eth_type_conf(pid
, &entry
);
10182 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all
= {
10183 .f
= cmd_config_l2_tunnel_eth_type_all_parsed
,
10185 .help_str
= "port config all l2-tunnel ether-type",
10187 (void *)&cmd_config_l2_tunnel_eth_type_port
,
10188 (void *)&cmd_config_l2_tunnel_eth_type_config
,
10189 (void *)&cmd_config_l2_tunnel_eth_type_all_str
,
10190 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel
,
10191 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type
,
10192 (void *)&cmd_config_l2_tunnel_eth_type_eth_type
,
10193 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val
,
10198 /* ether type config for a specific port */
10200 cmd_config_l2_tunnel_eth_type_specific_parsed(
10201 void *parsed_result
,
10202 __attribute__((unused
)) struct cmdline
*cl
,
10203 __attribute__((unused
)) void *data
)
10205 struct cmd_config_l2_tunnel_eth_type_result
*res
=
10207 struct rte_eth_l2_tunnel_conf entry
;
10209 if (port_id_is_invalid(res
->id
, ENABLED_WARN
))
10212 entry
.l2_tunnel_type
= str2fdir_l2_tunnel_type(res
->l2_tunnel_type
);
10213 entry
.ether_type
= res
->eth_type_val
;
10215 rte_eth_dev_l2_tunnel_eth_type_conf(res
->id
, &entry
);
10218 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific
= {
10219 .f
= cmd_config_l2_tunnel_eth_type_specific_parsed
,
10221 .help_str
= "port config l2-tunnel ether-type",
10223 (void *)&cmd_config_l2_tunnel_eth_type_port
,
10224 (void *)&cmd_config_l2_tunnel_eth_type_config
,
10225 (void *)&cmd_config_l2_tunnel_eth_type_id
,
10226 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel
,
10227 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type
,
10228 (void *)&cmd_config_l2_tunnel_eth_type_eth_type
,
10229 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val
,
10234 /* Enable/disable l2 tunnel */
10235 struct cmd_config_l2_tunnel_en_dis_result
{
10236 cmdline_fixed_string_t port
;
10237 cmdline_fixed_string_t config
;
10238 cmdline_fixed_string_t all
;
10240 cmdline_fixed_string_t l2_tunnel
;
10241 cmdline_fixed_string_t l2_tunnel_type
;
10242 cmdline_fixed_string_t en_dis
;
10245 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port
=
10246 TOKEN_STRING_INITIALIZER
10247 (struct cmd_config_l2_tunnel_en_dis_result
,
10249 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config
=
10250 TOKEN_STRING_INITIALIZER
10251 (struct cmd_config_l2_tunnel_en_dis_result
,
10253 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str
=
10254 TOKEN_STRING_INITIALIZER
10255 (struct cmd_config_l2_tunnel_en_dis_result
,
10257 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id
=
10258 TOKEN_NUM_INITIALIZER
10259 (struct cmd_config_l2_tunnel_en_dis_result
,
10261 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel
=
10262 TOKEN_STRING_INITIALIZER
10263 (struct cmd_config_l2_tunnel_en_dis_result
,
10264 l2_tunnel
, "l2-tunnel");
10265 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type
=
10266 TOKEN_STRING_INITIALIZER
10267 (struct cmd_config_l2_tunnel_en_dis_result
,
10268 l2_tunnel_type
, "E-tag");
10269 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis
=
10270 TOKEN_STRING_INITIALIZER
10271 (struct cmd_config_l2_tunnel_en_dis_result
,
10272 en_dis
, "enable#disable");
10274 /* enable/disable l2 tunnel for all ports */
10276 cmd_config_l2_tunnel_en_dis_all_parsed(
10277 void *parsed_result
,
10278 __attribute__((unused
)) struct cmdline
*cl
,
10279 __attribute__((unused
)) void *data
)
10281 struct cmd_config_l2_tunnel_en_dis_result
*res
= parsed_result
;
10282 struct rte_eth_l2_tunnel_conf entry
;
10286 entry
.l2_tunnel_type
= str2fdir_l2_tunnel_type(res
->l2_tunnel_type
);
10288 if (!strcmp("enable", res
->en_dis
))
10293 FOREACH_PORT(pid
, ports
) {
10294 rte_eth_dev_l2_tunnel_offload_set(pid
,
10296 ETH_L2_TUNNEL_ENABLE_MASK
,
10301 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all
= {
10302 .f
= cmd_config_l2_tunnel_en_dis_all_parsed
,
10304 .help_str
= "port config all l2-tunnel enable/disable",
10306 (void *)&cmd_config_l2_tunnel_en_dis_port
,
10307 (void *)&cmd_config_l2_tunnel_en_dis_config
,
10308 (void *)&cmd_config_l2_tunnel_en_dis_all_str
,
10309 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel
,
10310 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type
,
10311 (void *)&cmd_config_l2_tunnel_en_dis_en_dis
,
10316 /* enable/disable l2 tunnel for a port */
10318 cmd_config_l2_tunnel_en_dis_specific_parsed(
10319 void *parsed_result
,
10320 __attribute__((unused
)) struct cmdline
*cl
,
10321 __attribute__((unused
)) void *data
)
10323 struct cmd_config_l2_tunnel_en_dis_result
*res
=
10325 struct rte_eth_l2_tunnel_conf entry
;
10327 if (port_id_is_invalid(res
->id
, ENABLED_WARN
))
10330 entry
.l2_tunnel_type
= str2fdir_l2_tunnel_type(res
->l2_tunnel_type
);
10332 if (!strcmp("enable", res
->en_dis
))
10333 rte_eth_dev_l2_tunnel_offload_set(res
->id
,
10335 ETH_L2_TUNNEL_ENABLE_MASK
,
10338 rte_eth_dev_l2_tunnel_offload_set(res
->id
,
10340 ETH_L2_TUNNEL_ENABLE_MASK
,
10344 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific
= {
10345 .f
= cmd_config_l2_tunnel_en_dis_specific_parsed
,
10347 .help_str
= "port config l2-tunnel enable/disable",
10349 (void *)&cmd_config_l2_tunnel_en_dis_port
,
10350 (void *)&cmd_config_l2_tunnel_en_dis_config
,
10351 (void *)&cmd_config_l2_tunnel_en_dis_id
,
10352 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel
,
10353 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type
,
10354 (void *)&cmd_config_l2_tunnel_en_dis_en_dis
,
10359 /* E-tag configuration */
10361 /* Common result structure for all E-tag configuration */
10362 struct cmd_config_e_tag_result
{
10363 cmdline_fixed_string_t e_tag
;
10364 cmdline_fixed_string_t set
;
10365 cmdline_fixed_string_t insertion
;
10366 cmdline_fixed_string_t stripping
;
10367 cmdline_fixed_string_t forwarding
;
10368 cmdline_fixed_string_t filter
;
10369 cmdline_fixed_string_t add
;
10370 cmdline_fixed_string_t del
;
10371 cmdline_fixed_string_t on
;
10372 cmdline_fixed_string_t off
;
10373 cmdline_fixed_string_t on_off
;
10374 cmdline_fixed_string_t port_tag_id
;
10375 uint32_t port_tag_id_val
;
10376 cmdline_fixed_string_t e_tag_id
;
10377 uint16_t e_tag_id_val
;
10378 cmdline_fixed_string_t dst_pool
;
10379 uint8_t dst_pool_val
;
10380 cmdline_fixed_string_t port
;
10382 cmdline_fixed_string_t vf
;
10386 /* Common CLI fields for all E-tag configuration */
10387 cmdline_parse_token_string_t cmd_config_e_tag_e_tag
=
10388 TOKEN_STRING_INITIALIZER
10389 (struct cmd_config_e_tag_result
,
10391 cmdline_parse_token_string_t cmd_config_e_tag_set
=
10392 TOKEN_STRING_INITIALIZER
10393 (struct cmd_config_e_tag_result
,
10395 cmdline_parse_token_string_t cmd_config_e_tag_insertion
=
10396 TOKEN_STRING_INITIALIZER
10397 (struct cmd_config_e_tag_result
,
10398 insertion
, "insertion");
10399 cmdline_parse_token_string_t cmd_config_e_tag_stripping
=
10400 TOKEN_STRING_INITIALIZER
10401 (struct cmd_config_e_tag_result
,
10402 stripping
, "stripping");
10403 cmdline_parse_token_string_t cmd_config_e_tag_forwarding
=
10404 TOKEN_STRING_INITIALIZER
10405 (struct cmd_config_e_tag_result
,
10406 forwarding
, "forwarding");
10407 cmdline_parse_token_string_t cmd_config_e_tag_filter
=
10408 TOKEN_STRING_INITIALIZER
10409 (struct cmd_config_e_tag_result
,
10411 cmdline_parse_token_string_t cmd_config_e_tag_add
=
10412 TOKEN_STRING_INITIALIZER
10413 (struct cmd_config_e_tag_result
,
10415 cmdline_parse_token_string_t cmd_config_e_tag_del
=
10416 TOKEN_STRING_INITIALIZER
10417 (struct cmd_config_e_tag_result
,
10419 cmdline_parse_token_string_t cmd_config_e_tag_on
=
10420 TOKEN_STRING_INITIALIZER
10421 (struct cmd_config_e_tag_result
,
10423 cmdline_parse_token_string_t cmd_config_e_tag_off
=
10424 TOKEN_STRING_INITIALIZER
10425 (struct cmd_config_e_tag_result
,
10427 cmdline_parse_token_string_t cmd_config_e_tag_on_off
=
10428 TOKEN_STRING_INITIALIZER
10429 (struct cmd_config_e_tag_result
,
10431 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id
=
10432 TOKEN_STRING_INITIALIZER
10433 (struct cmd_config_e_tag_result
,
10434 port_tag_id
, "port-tag-id");
10435 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val
=
10436 TOKEN_NUM_INITIALIZER
10437 (struct cmd_config_e_tag_result
,
10438 port_tag_id_val
, UINT32
);
10439 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id
=
10440 TOKEN_STRING_INITIALIZER
10441 (struct cmd_config_e_tag_result
,
10442 e_tag_id
, "e-tag-id");
10443 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val
=
10444 TOKEN_NUM_INITIALIZER
10445 (struct cmd_config_e_tag_result
,
10446 e_tag_id_val
, UINT16
);
10447 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool
=
10448 TOKEN_STRING_INITIALIZER
10449 (struct cmd_config_e_tag_result
,
10450 dst_pool
, "dst-pool");
10451 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val
=
10452 TOKEN_NUM_INITIALIZER
10453 (struct cmd_config_e_tag_result
,
10454 dst_pool_val
, UINT8
);
10455 cmdline_parse_token_string_t cmd_config_e_tag_port
=
10456 TOKEN_STRING_INITIALIZER
10457 (struct cmd_config_e_tag_result
,
10459 cmdline_parse_token_num_t cmd_config_e_tag_port_id
=
10460 TOKEN_NUM_INITIALIZER
10461 (struct cmd_config_e_tag_result
,
10463 cmdline_parse_token_string_t cmd_config_e_tag_vf
=
10464 TOKEN_STRING_INITIALIZER
10465 (struct cmd_config_e_tag_result
,
10467 cmdline_parse_token_num_t cmd_config_e_tag_vf_id
=
10468 TOKEN_NUM_INITIALIZER
10469 (struct cmd_config_e_tag_result
,
10472 /* E-tag insertion configuration */
10474 cmd_config_e_tag_insertion_en_parsed(
10475 void *parsed_result
,
10476 __attribute__((unused
)) struct cmdline
*cl
,
10477 __attribute__((unused
)) void *data
)
10479 struct cmd_config_e_tag_result
*res
=
10481 struct rte_eth_l2_tunnel_conf entry
;
10483 if (port_id_is_invalid(res
->port_id
, ENABLED_WARN
))
10486 entry
.l2_tunnel_type
= RTE_L2_TUNNEL_TYPE_E_TAG
;
10487 entry
.tunnel_id
= res
->port_tag_id_val
;
10488 entry
.vf_id
= res
->vf_id
;
10489 rte_eth_dev_l2_tunnel_offload_set(res
->port_id
,
10491 ETH_L2_TUNNEL_INSERTION_MASK
,
10496 cmd_config_e_tag_insertion_dis_parsed(
10497 void *parsed_result
,
10498 __attribute__((unused
)) struct cmdline
*cl
,
10499 __attribute__((unused
)) void *data
)
10501 struct cmd_config_e_tag_result
*res
=
10503 struct rte_eth_l2_tunnel_conf entry
;
10505 if (port_id_is_invalid(res
->port_id
, ENABLED_WARN
))
10508 entry
.l2_tunnel_type
= RTE_L2_TUNNEL_TYPE_E_TAG
;
10509 entry
.vf_id
= res
->vf_id
;
10511 rte_eth_dev_l2_tunnel_offload_set(res
->port_id
,
10513 ETH_L2_TUNNEL_INSERTION_MASK
,
10517 cmdline_parse_inst_t cmd_config_e_tag_insertion_en
= {
10518 .f
= cmd_config_e_tag_insertion_en_parsed
,
10520 .help_str
= "E-tag insertion enable",
10522 (void *)&cmd_config_e_tag_e_tag
,
10523 (void *)&cmd_config_e_tag_set
,
10524 (void *)&cmd_config_e_tag_insertion
,
10525 (void *)&cmd_config_e_tag_on
,
10526 (void *)&cmd_config_e_tag_port_tag_id
,
10527 (void *)&cmd_config_e_tag_port_tag_id_val
,
10528 (void *)&cmd_config_e_tag_port
,
10529 (void *)&cmd_config_e_tag_port_id
,
10530 (void *)&cmd_config_e_tag_vf
,
10531 (void *)&cmd_config_e_tag_vf_id
,
10536 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis
= {
10537 .f
= cmd_config_e_tag_insertion_dis_parsed
,
10539 .help_str
= "E-tag insertion disable",
10541 (void *)&cmd_config_e_tag_e_tag
,
10542 (void *)&cmd_config_e_tag_set
,
10543 (void *)&cmd_config_e_tag_insertion
,
10544 (void *)&cmd_config_e_tag_off
,
10545 (void *)&cmd_config_e_tag_port
,
10546 (void *)&cmd_config_e_tag_port_id
,
10547 (void *)&cmd_config_e_tag_vf
,
10548 (void *)&cmd_config_e_tag_vf_id
,
10553 /* E-tag stripping configuration */
10555 cmd_config_e_tag_stripping_parsed(
10556 void *parsed_result
,
10557 __attribute__((unused
)) struct cmdline
*cl
,
10558 __attribute__((unused
)) void *data
)
10560 struct cmd_config_e_tag_result
*res
=
10562 struct rte_eth_l2_tunnel_conf entry
;
10564 if (port_id_is_invalid(res
->port_id
, ENABLED_WARN
))
10567 entry
.l2_tunnel_type
= RTE_L2_TUNNEL_TYPE_E_TAG
;
10569 if (!strcmp(res
->on_off
, "on"))
10570 rte_eth_dev_l2_tunnel_offload_set
10573 ETH_L2_TUNNEL_STRIPPING_MASK
,
10576 rte_eth_dev_l2_tunnel_offload_set
10579 ETH_L2_TUNNEL_STRIPPING_MASK
,
10583 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis
= {
10584 .f
= cmd_config_e_tag_stripping_parsed
,
10586 .help_str
= "E-tag stripping enable/disable",
10588 (void *)&cmd_config_e_tag_e_tag
,
10589 (void *)&cmd_config_e_tag_set
,
10590 (void *)&cmd_config_e_tag_stripping
,
10591 (void *)&cmd_config_e_tag_on_off
,
10592 (void *)&cmd_config_e_tag_port
,
10593 (void *)&cmd_config_e_tag_port_id
,
10598 /* E-tag forwarding configuration */
10600 cmd_config_e_tag_forwarding_parsed(
10601 void *parsed_result
,
10602 __attribute__((unused
)) struct cmdline
*cl
,
10603 __attribute__((unused
)) void *data
)
10605 struct cmd_config_e_tag_result
*res
= parsed_result
;
10606 struct rte_eth_l2_tunnel_conf entry
;
10608 if (port_id_is_invalid(res
->port_id
, ENABLED_WARN
))
10611 entry
.l2_tunnel_type
= RTE_L2_TUNNEL_TYPE_E_TAG
;
10613 if (!strcmp(res
->on_off
, "on"))
10614 rte_eth_dev_l2_tunnel_offload_set
10617 ETH_L2_TUNNEL_FORWARDING_MASK
,
10620 rte_eth_dev_l2_tunnel_offload_set
10623 ETH_L2_TUNNEL_FORWARDING_MASK
,
10627 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis
= {
10628 .f
= cmd_config_e_tag_forwarding_parsed
,
10630 .help_str
= "E-tag forwarding enable/disable",
10632 (void *)&cmd_config_e_tag_e_tag
,
10633 (void *)&cmd_config_e_tag_set
,
10634 (void *)&cmd_config_e_tag_forwarding
,
10635 (void *)&cmd_config_e_tag_on_off
,
10636 (void *)&cmd_config_e_tag_port
,
10637 (void *)&cmd_config_e_tag_port_id
,
10642 /* E-tag filter configuration */
10644 cmd_config_e_tag_filter_add_parsed(
10645 void *parsed_result
,
10646 __attribute__((unused
)) struct cmdline
*cl
,
10647 __attribute__((unused
)) void *data
)
10649 struct cmd_config_e_tag_result
*res
= parsed_result
;
10650 struct rte_eth_l2_tunnel_conf entry
;
10653 if (port_id_is_invalid(res
->port_id
, ENABLED_WARN
))
10656 if (res
->e_tag_id_val
> 0x3fff) {
10657 printf("e-tag-id must be equal or less than 0x3fff.\n");
10661 ret
= rte_eth_dev_filter_supported(res
->port_id
,
10662 RTE_ETH_FILTER_L2_TUNNEL
);
10664 printf("E-tag filter is not supported on port %u.\n",
10669 entry
.l2_tunnel_type
= RTE_L2_TUNNEL_TYPE_E_TAG
;
10670 entry
.tunnel_id
= res
->e_tag_id_val
;
10671 entry
.pool
= res
->dst_pool_val
;
10673 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
10674 RTE_ETH_FILTER_L2_TUNNEL
,
10675 RTE_ETH_FILTER_ADD
,
10678 printf("E-tag filter programming error: (%s)\n",
10682 cmdline_parse_inst_t cmd_config_e_tag_filter_add
= {
10683 .f
= cmd_config_e_tag_filter_add_parsed
,
10685 .help_str
= "E-tag filter add",
10687 (void *)&cmd_config_e_tag_e_tag
,
10688 (void *)&cmd_config_e_tag_set
,
10689 (void *)&cmd_config_e_tag_filter
,
10690 (void *)&cmd_config_e_tag_add
,
10691 (void *)&cmd_config_e_tag_e_tag_id
,
10692 (void *)&cmd_config_e_tag_e_tag_id_val
,
10693 (void *)&cmd_config_e_tag_dst_pool
,
10694 (void *)&cmd_config_e_tag_dst_pool_val
,
10695 (void *)&cmd_config_e_tag_port
,
10696 (void *)&cmd_config_e_tag_port_id
,
10702 cmd_config_e_tag_filter_del_parsed(
10703 void *parsed_result
,
10704 __attribute__((unused
)) struct cmdline
*cl
,
10705 __attribute__((unused
)) void *data
)
10707 struct cmd_config_e_tag_result
*res
= parsed_result
;
10708 struct rte_eth_l2_tunnel_conf entry
;
10711 if (port_id_is_invalid(res
->port_id
, ENABLED_WARN
))
10714 if (res
->e_tag_id_val
> 0x3fff) {
10715 printf("e-tag-id must be less than 0x3fff.\n");
10719 ret
= rte_eth_dev_filter_supported(res
->port_id
,
10720 RTE_ETH_FILTER_L2_TUNNEL
);
10722 printf("E-tag filter is not supported on port %u.\n",
10727 entry
.l2_tunnel_type
= RTE_L2_TUNNEL_TYPE_E_TAG
;
10728 entry
.tunnel_id
= res
->e_tag_id_val
;
10730 ret
= rte_eth_dev_filter_ctrl(res
->port_id
,
10731 RTE_ETH_FILTER_L2_TUNNEL
,
10732 RTE_ETH_FILTER_DELETE
,
10735 printf("E-tag filter programming error: (%s)\n",
10739 cmdline_parse_inst_t cmd_config_e_tag_filter_del
= {
10740 .f
= cmd_config_e_tag_filter_del_parsed
,
10742 .help_str
= "E-tag filter delete",
10744 (void *)&cmd_config_e_tag_e_tag
,
10745 (void *)&cmd_config_e_tag_set
,
10746 (void *)&cmd_config_e_tag_filter
,
10747 (void *)&cmd_config_e_tag_del
,
10748 (void *)&cmd_config_e_tag_e_tag_id
,
10749 (void *)&cmd_config_e_tag_e_tag_id_val
,
10750 (void *)&cmd_config_e_tag_port
,
10751 (void *)&cmd_config_e_tag_port_id
,
10755 #ifdef RTE_LIBRTE_IXGBE_PMD
10757 /* vf vlan anti spoof configuration */
10759 /* Common result structure for vf vlan anti spoof */
10760 struct cmd_vf_vlan_anti_spoof_result
{
10761 cmdline_fixed_string_t set
;
10762 cmdline_fixed_string_t vf
;
10763 cmdline_fixed_string_t vlan
;
10764 cmdline_fixed_string_t antispoof
;
10767 cmdline_fixed_string_t on_off
;
10770 /* Common CLI fields for vf vlan anti spoof enable disable */
10771 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set
=
10772 TOKEN_STRING_INITIALIZER
10773 (struct cmd_vf_vlan_anti_spoof_result
,
10775 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf
=
10776 TOKEN_STRING_INITIALIZER
10777 (struct cmd_vf_vlan_anti_spoof_result
,
10779 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan
=
10780 TOKEN_STRING_INITIALIZER
10781 (struct cmd_vf_vlan_anti_spoof_result
,
10783 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof
=
10784 TOKEN_STRING_INITIALIZER
10785 (struct cmd_vf_vlan_anti_spoof_result
,
10786 antispoof
, "antispoof");
10787 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id
=
10788 TOKEN_NUM_INITIALIZER
10789 (struct cmd_vf_vlan_anti_spoof_result
,
10791 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id
=
10792 TOKEN_NUM_INITIALIZER
10793 (struct cmd_vf_vlan_anti_spoof_result
,
10795 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off
=
10796 TOKEN_STRING_INITIALIZER
10797 (struct cmd_vf_vlan_anti_spoof_result
,
10801 cmd_set_vf_vlan_anti_spoof_parsed(
10802 void *parsed_result
,
10803 __attribute__((unused
)) struct cmdline
*cl
,
10804 __attribute__((unused
)) void *data
)
10806 struct cmd_vf_vlan_anti_spoof_result
*res
= parsed_result
;
10808 int is_on
= (strcmp(res
->on_off
, "on") == 0) ? 1 : 0;
10810 ret
= rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res
->port_id
, res
->vf_id
,
10816 printf("invalid vf_id %d\n", res
->vf_id
);
10819 printf("invalid port_id %d\n", res
->port_id
);
10822 printf("programming error: (%s)\n", strerror(-ret
));
10826 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof
= {
10827 .f
= cmd_set_vf_vlan_anti_spoof_parsed
,
10829 .help_str
= "set vf vlan antispoof port_id vf_id on|off",
10831 (void *)&cmd_vf_vlan_anti_spoof_set
,
10832 (void *)&cmd_vf_vlan_anti_spoof_vf
,
10833 (void *)&cmd_vf_vlan_anti_spoof_vlan
,
10834 (void *)&cmd_vf_vlan_anti_spoof_antispoof
,
10835 (void *)&cmd_vf_vlan_anti_spoof_port_id
,
10836 (void *)&cmd_vf_vlan_anti_spoof_vf_id
,
10837 (void *)&cmd_vf_vlan_anti_spoof_on_off
,
10842 /* vf mac anti spoof configuration */
10844 /* Common result structure for vf mac anti spoof */
10845 struct cmd_vf_mac_anti_spoof_result
{
10846 cmdline_fixed_string_t set
;
10847 cmdline_fixed_string_t vf
;
10848 cmdline_fixed_string_t mac
;
10849 cmdline_fixed_string_t antispoof
;
10852 cmdline_fixed_string_t on_off
;
10855 /* Common CLI fields for vf mac anti spoof enable disable */
10856 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set
=
10857 TOKEN_STRING_INITIALIZER
10858 (struct cmd_vf_mac_anti_spoof_result
,
10860 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf
=
10861 TOKEN_STRING_INITIALIZER
10862 (struct cmd_vf_mac_anti_spoof_result
,
10864 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac
=
10865 TOKEN_STRING_INITIALIZER
10866 (struct cmd_vf_mac_anti_spoof_result
,
10868 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof
=
10869 TOKEN_STRING_INITIALIZER
10870 (struct cmd_vf_mac_anti_spoof_result
,
10871 antispoof
, "antispoof");
10872 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id
=
10873 TOKEN_NUM_INITIALIZER
10874 (struct cmd_vf_mac_anti_spoof_result
,
10876 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id
=
10877 TOKEN_NUM_INITIALIZER
10878 (struct cmd_vf_mac_anti_spoof_result
,
10880 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off
=
10881 TOKEN_STRING_INITIALIZER
10882 (struct cmd_vf_mac_anti_spoof_result
,
10886 cmd_set_vf_mac_anti_spoof_parsed(
10887 void *parsed_result
,
10888 __attribute__((unused
)) struct cmdline
*cl
,
10889 __attribute__((unused
)) void *data
)
10891 struct cmd_vf_mac_anti_spoof_result
*res
= parsed_result
;
10893 int is_on
= (strcmp(res
->on_off
, "on") == 0) ? 1 : 0;
10895 ret
= rte_pmd_ixgbe_set_vf_mac_anti_spoof(res
->port_id
, res
->vf_id
,
10901 printf("invalid vf_id %d or is_on %d\n", res
->vf_id
, is_on
);
10904 printf("invalid port_id %d\n", res
->port_id
);
10907 printf("programming error: (%s)\n", strerror(-ret
));
10911 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof
= {
10912 .f
= cmd_set_vf_mac_anti_spoof_parsed
,
10914 .help_str
= "set vf mac antispoof port_id vf_id on|off",
10916 (void *)&cmd_vf_mac_anti_spoof_set
,
10917 (void *)&cmd_vf_mac_anti_spoof_vf
,
10918 (void *)&cmd_vf_mac_anti_spoof_mac
,
10919 (void *)&cmd_vf_mac_anti_spoof_antispoof
,
10920 (void *)&cmd_vf_mac_anti_spoof_port_id
,
10921 (void *)&cmd_vf_mac_anti_spoof_vf_id
,
10922 (void *)&cmd_vf_mac_anti_spoof_on_off
,
10927 /* vf vlan strip queue configuration */
10929 /* Common result structure for vf mac anti spoof */
10930 struct cmd_vf_vlan_stripq_result
{
10931 cmdline_fixed_string_t set
;
10932 cmdline_fixed_string_t vf
;
10933 cmdline_fixed_string_t vlan
;
10934 cmdline_fixed_string_t stripq
;
10937 cmdline_fixed_string_t on_off
;
10940 /* Common CLI fields for vf vlan strip enable disable */
10941 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set
=
10942 TOKEN_STRING_INITIALIZER
10943 (struct cmd_vf_vlan_stripq_result
,
10945 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf
=
10946 TOKEN_STRING_INITIALIZER
10947 (struct cmd_vf_vlan_stripq_result
,
10949 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan
=
10950 TOKEN_STRING_INITIALIZER
10951 (struct cmd_vf_vlan_stripq_result
,
10953 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq
=
10954 TOKEN_STRING_INITIALIZER
10955 (struct cmd_vf_vlan_stripq_result
,
10957 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id
=
10958 TOKEN_NUM_INITIALIZER
10959 (struct cmd_vf_vlan_stripq_result
,
10961 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id
=
10962 TOKEN_NUM_INITIALIZER
10963 (struct cmd_vf_vlan_stripq_result
,
10965 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off
=
10966 TOKEN_STRING_INITIALIZER
10967 (struct cmd_vf_vlan_stripq_result
,
10971 cmd_set_vf_vlan_stripq_parsed(
10972 void *parsed_result
,
10973 __attribute__((unused
)) struct cmdline
*cl
,
10974 __attribute__((unused
)) void *data
)
10976 struct cmd_vf_vlan_stripq_result
*res
= parsed_result
;
10978 int is_on
= (strcmp(res
->on_off
, "on") == 0) ? 1 : 0;
10980 ret
= rte_pmd_ixgbe_set_vf_vlan_stripq(res
->port_id
, res
->vf_id
, is_on
);
10985 printf("invalid vf_id %d or is_on %d\n", res
->vf_id
, is_on
);
10988 printf("invalid port_id %d\n", res
->port_id
);
10991 printf("programming error: (%s)\n", strerror(-ret
));
10995 cmdline_parse_inst_t cmd_set_vf_vlan_stripq
= {
10996 .f
= cmd_set_vf_vlan_stripq_parsed
,
10998 .help_str
= "set vf vlan stripq port_id vf_id on|off",
11000 (void *)&cmd_vf_vlan_stripq_set
,
11001 (void *)&cmd_vf_vlan_stripq_vf
,
11002 (void *)&cmd_vf_vlan_stripq_vlan
,
11003 (void *)&cmd_vf_vlan_stripq_stripq
,
11004 (void *)&cmd_vf_vlan_stripq_port_id
,
11005 (void *)&cmd_vf_vlan_stripq_vf_id
,
11006 (void *)&cmd_vf_vlan_stripq_on_off
,
11011 /* vf vlan insert configuration */
11013 /* Common result structure for vf vlan insert */
11014 struct cmd_vf_vlan_insert_result
{
11015 cmdline_fixed_string_t set
;
11016 cmdline_fixed_string_t vf
;
11017 cmdline_fixed_string_t vlan
;
11018 cmdline_fixed_string_t insert
;
11024 /* Common CLI fields for vf vlan insert enable disable */
11025 cmdline_parse_token_string_t cmd_vf_vlan_insert_set
=
11026 TOKEN_STRING_INITIALIZER
11027 (struct cmd_vf_vlan_insert_result
,
11029 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf
=
11030 TOKEN_STRING_INITIALIZER
11031 (struct cmd_vf_vlan_insert_result
,
11033 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan
=
11034 TOKEN_STRING_INITIALIZER
11035 (struct cmd_vf_vlan_insert_result
,
11037 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert
=
11038 TOKEN_STRING_INITIALIZER
11039 (struct cmd_vf_vlan_insert_result
,
11041 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id
=
11042 TOKEN_NUM_INITIALIZER
11043 (struct cmd_vf_vlan_insert_result
,
11045 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id
=
11046 TOKEN_NUM_INITIALIZER
11047 (struct cmd_vf_vlan_insert_result
,
11049 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id
=
11050 TOKEN_NUM_INITIALIZER
11051 (struct cmd_vf_vlan_insert_result
,
11055 cmd_set_vf_vlan_insert_parsed(
11056 void *parsed_result
,
11057 __attribute__((unused
)) struct cmdline
*cl
,
11058 __attribute__((unused
)) void *data
)
11060 struct cmd_vf_vlan_insert_result
*res
= parsed_result
;
11063 ret
= rte_pmd_ixgbe_set_vf_vlan_insert(res
->port_id
, res
->vf_id
, res
->vlan_id
);
11068 printf("invalid vf_id %d or vlan_id %d\n", res
->vf_id
, res
->vlan_id
);
11071 printf("invalid port_id %d\n", res
->port_id
);
11074 printf("programming error: (%s)\n", strerror(-ret
));
11078 cmdline_parse_inst_t cmd_set_vf_vlan_insert
= {
11079 .f
= cmd_set_vf_vlan_insert_parsed
,
11081 .help_str
= "set vf vlan insert port_id vf_id vlan_id",
11083 (void *)&cmd_vf_vlan_insert_set
,
11084 (void *)&cmd_vf_vlan_insert_vf
,
11085 (void *)&cmd_vf_vlan_insert_vlan
,
11086 (void *)&cmd_vf_vlan_insert_insert
,
11087 (void *)&cmd_vf_vlan_insert_port_id
,
11088 (void *)&cmd_vf_vlan_insert_vf_id
,
11089 (void *)&cmd_vf_vlan_insert_vlan_id
,
11094 /* tx loopback configuration */
11096 /* Common result structure for tx loopback */
11097 struct cmd_tx_loopback_result
{
11098 cmdline_fixed_string_t set
;
11099 cmdline_fixed_string_t tx
;
11100 cmdline_fixed_string_t loopback
;
11102 cmdline_fixed_string_t on_off
;
11105 /* Common CLI fields for tx loopback enable disable */
11106 cmdline_parse_token_string_t cmd_tx_loopback_set
=
11107 TOKEN_STRING_INITIALIZER
11108 (struct cmd_tx_loopback_result
,
11110 cmdline_parse_token_string_t cmd_tx_loopback_tx
=
11111 TOKEN_STRING_INITIALIZER
11112 (struct cmd_tx_loopback_result
,
11114 cmdline_parse_token_string_t cmd_tx_loopback_loopback
=
11115 TOKEN_STRING_INITIALIZER
11116 (struct cmd_tx_loopback_result
,
11117 loopback
, "loopback");
11118 cmdline_parse_token_num_t cmd_tx_loopback_port_id
=
11119 TOKEN_NUM_INITIALIZER
11120 (struct cmd_tx_loopback_result
,
11122 cmdline_parse_token_string_t cmd_tx_loopback_on_off
=
11123 TOKEN_STRING_INITIALIZER
11124 (struct cmd_tx_loopback_result
,
11128 cmd_set_tx_loopback_parsed(
11129 void *parsed_result
,
11130 __attribute__((unused
)) struct cmdline
*cl
,
11131 __attribute__((unused
)) void *data
)
11133 struct cmd_tx_loopback_result
*res
= parsed_result
;
11135 int is_on
= (strcmp(res
->on_off
, "on") == 0) ? 1 : 0;
11137 ret
= rte_pmd_ixgbe_set_tx_loopback(res
->port_id
, is_on
);
11142 printf("invalid is_on %d\n", is_on
);
11145 printf("invalid port_id %d\n", res
->port_id
);
11148 printf("programming error: (%s)\n", strerror(-ret
));
11152 cmdline_parse_inst_t cmd_set_tx_loopback
= {
11153 .f
= cmd_set_tx_loopback_parsed
,
11155 .help_str
= "set tx loopback port_id on|off",
11157 (void *)&cmd_tx_loopback_set
,
11158 (void *)&cmd_tx_loopback_tx
,
11159 (void *)&cmd_tx_loopback_loopback
,
11160 (void *)&cmd_tx_loopback_port_id
,
11161 (void *)&cmd_tx_loopback_on_off
,
11166 /* all queues drop enable configuration */
11168 /* Common result structure for all queues drop enable */
11169 struct cmd_all_queues_drop_en_result
{
11170 cmdline_fixed_string_t set
;
11171 cmdline_fixed_string_t all
;
11172 cmdline_fixed_string_t queues
;
11173 cmdline_fixed_string_t drop
;
11175 cmdline_fixed_string_t on_off
;
11178 /* Common CLI fields for tx loopback enable disable */
11179 cmdline_parse_token_string_t cmd_all_queues_drop_en_set
=
11180 TOKEN_STRING_INITIALIZER
11181 (struct cmd_all_queues_drop_en_result
,
11183 cmdline_parse_token_string_t cmd_all_queues_drop_en_all
=
11184 TOKEN_STRING_INITIALIZER
11185 (struct cmd_all_queues_drop_en_result
,
11187 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues
=
11188 TOKEN_STRING_INITIALIZER
11189 (struct cmd_all_queues_drop_en_result
,
11191 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop
=
11192 TOKEN_STRING_INITIALIZER
11193 (struct cmd_all_queues_drop_en_result
,
11195 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id
=
11196 TOKEN_NUM_INITIALIZER
11197 (struct cmd_all_queues_drop_en_result
,
11199 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off
=
11200 TOKEN_STRING_INITIALIZER
11201 (struct cmd_all_queues_drop_en_result
,
11205 cmd_set_all_queues_drop_en_parsed(
11206 void *parsed_result
,
11207 __attribute__((unused
)) struct cmdline
*cl
,
11208 __attribute__((unused
)) void *data
)
11210 struct cmd_all_queues_drop_en_result
*res
= parsed_result
;
11212 int is_on
= (strcmp(res
->on_off
, "on") == 0) ? 1 : 0;
11214 ret
= rte_pmd_ixgbe_set_all_queues_drop_en(res
->port_id
, is_on
);
11219 printf("invalid is_on %d\n", is_on
);
11222 printf("invalid port_id %d\n", res
->port_id
);
11225 printf("programming error: (%s)\n", strerror(-ret
));
11229 cmdline_parse_inst_t cmd_set_all_queues_drop_en
= {
11230 .f
= cmd_set_all_queues_drop_en_parsed
,
11232 .help_str
= "set all queues drop port_id on|off",
11234 (void *)&cmd_all_queues_drop_en_set
,
11235 (void *)&cmd_all_queues_drop_en_all
,
11236 (void *)&cmd_all_queues_drop_en_queues
,
11237 (void *)&cmd_all_queues_drop_en_drop
,
11238 (void *)&cmd_all_queues_drop_en_port_id
,
11239 (void *)&cmd_all_queues_drop_en_on_off
,
11244 /* vf split drop enable configuration */
11246 /* Common result structure for vf split drop enable */
11247 struct cmd_vf_split_drop_en_result
{
11248 cmdline_fixed_string_t set
;
11249 cmdline_fixed_string_t vf
;
11250 cmdline_fixed_string_t split
;
11251 cmdline_fixed_string_t drop
;
11254 cmdline_fixed_string_t on_off
;
11257 /* Common CLI fields for vf split drop enable disable */
11258 cmdline_parse_token_string_t cmd_vf_split_drop_en_set
=
11259 TOKEN_STRING_INITIALIZER
11260 (struct cmd_vf_split_drop_en_result
,
11262 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf
=
11263 TOKEN_STRING_INITIALIZER
11264 (struct cmd_vf_split_drop_en_result
,
11266 cmdline_parse_token_string_t cmd_vf_split_drop_en_split
=
11267 TOKEN_STRING_INITIALIZER
11268 (struct cmd_vf_split_drop_en_result
,
11270 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop
=
11271 TOKEN_STRING_INITIALIZER
11272 (struct cmd_vf_split_drop_en_result
,
11274 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id
=
11275 TOKEN_NUM_INITIALIZER
11276 (struct cmd_vf_split_drop_en_result
,
11278 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id
=
11279 TOKEN_NUM_INITIALIZER
11280 (struct cmd_vf_split_drop_en_result
,
11282 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off
=
11283 TOKEN_STRING_INITIALIZER
11284 (struct cmd_vf_split_drop_en_result
,
11288 cmd_set_vf_split_drop_en_parsed(
11289 void *parsed_result
,
11290 __attribute__((unused
)) struct cmdline
*cl
,
11291 __attribute__((unused
)) void *data
)
11293 struct cmd_vf_split_drop_en_result
*res
= parsed_result
;
11295 int is_on
= (strcmp(res
->on_off
, "on") == 0) ? 1 : 0;
11297 ret
= rte_pmd_ixgbe_set_vf_split_drop_en(res
->port_id
, res
->vf_id
,
11303 printf("invalid vf_id %d or is_on %d\n", res
->vf_id
, is_on
);
11306 printf("invalid port_id %d\n", res
->port_id
);
11309 printf("programming error: (%s)\n", strerror(-ret
));
11313 cmdline_parse_inst_t cmd_set_vf_split_drop_en
= {
11314 .f
= cmd_set_vf_split_drop_en_parsed
,
11316 .help_str
= "set vf split drop port_id vf_id on|off",
11318 (void *)&cmd_vf_split_drop_en_set
,
11319 (void *)&cmd_vf_split_drop_en_vf
,
11320 (void *)&cmd_vf_split_drop_en_split
,
11321 (void *)&cmd_vf_split_drop_en_drop
,
11322 (void *)&cmd_vf_split_drop_en_port_id
,
11323 (void *)&cmd_vf_split_drop_en_vf_id
,
11324 (void *)&cmd_vf_split_drop_en_on_off
,
11329 /* vf mac address configuration */
11331 /* Common result structure for vf mac address */
11332 struct cmd_set_vf_mac_addr_result
{
11333 cmdline_fixed_string_t set
;
11334 cmdline_fixed_string_t vf
;
11335 cmdline_fixed_string_t mac
;
11336 cmdline_fixed_string_t addr
;
11339 struct ether_addr mac_addr
;
11343 /* Common CLI fields for vf split drop enable disable */
11344 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set
=
11345 TOKEN_STRING_INITIALIZER
11346 (struct cmd_set_vf_mac_addr_result
,
11348 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf
=
11349 TOKEN_STRING_INITIALIZER
11350 (struct cmd_set_vf_mac_addr_result
,
11352 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac
=
11353 TOKEN_STRING_INITIALIZER
11354 (struct cmd_set_vf_mac_addr_result
,
11356 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr
=
11357 TOKEN_STRING_INITIALIZER
11358 (struct cmd_set_vf_mac_addr_result
,
11360 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id
=
11361 TOKEN_NUM_INITIALIZER
11362 (struct cmd_set_vf_mac_addr_result
,
11364 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id
=
11365 TOKEN_NUM_INITIALIZER
11366 (struct cmd_set_vf_mac_addr_result
,
11368 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr
=
11369 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result
,
11373 cmd_set_vf_mac_addr_parsed(
11374 void *parsed_result
,
11375 __attribute__((unused
)) struct cmdline
*cl
,
11376 __attribute__((unused
)) void *data
)
11378 struct cmd_set_vf_mac_addr_result
*res
= parsed_result
;
11381 ret
= rte_pmd_ixgbe_set_vf_mac_addr(res
->port_id
, res
->vf_id
,
11387 printf("invalid vf_id %d or mac_addr\n", res
->vf_id
);
11390 printf("invalid port_id %d\n", res
->port_id
);
11393 printf("programming error: (%s)\n", strerror(-ret
));
11397 cmdline_parse_inst_t cmd_set_vf_mac_addr
= {
11398 .f
= cmd_set_vf_mac_addr_parsed
,
11400 .help_str
= "set vf mac addr port_id vf_id xx:xx:xx:xx:xx:xx",
11402 (void *)&cmd_set_vf_mac_addr_set
,
11403 (void *)&cmd_set_vf_mac_addr_vf
,
11404 (void *)&cmd_set_vf_mac_addr_mac
,
11405 (void *)&cmd_set_vf_mac_addr_addr
,
11406 (void *)&cmd_set_vf_mac_addr_port_id
,
11407 (void *)&cmd_set_vf_mac_addr_vf_id
,
11408 (void *)&cmd_set_vf_mac_addr_mac_addr
,
11414 /* ******************************************************************************** */
11416 /* list of instructions */
11417 cmdline_parse_ctx_t main_ctx
[] = {
11418 (cmdline_parse_inst_t
*)&cmd_help_brief
,
11419 (cmdline_parse_inst_t
*)&cmd_help_long
,
11420 (cmdline_parse_inst_t
*)&cmd_quit
,
11421 (cmdline_parse_inst_t
*)&cmd_showport
,
11422 (cmdline_parse_inst_t
*)&cmd_showqueue
,
11423 (cmdline_parse_inst_t
*)&cmd_showportall
,
11424 (cmdline_parse_inst_t
*)&cmd_showcfg
,
11425 (cmdline_parse_inst_t
*)&cmd_start
,
11426 (cmdline_parse_inst_t
*)&cmd_start_tx_first
,
11427 (cmdline_parse_inst_t
*)&cmd_start_tx_first_n
,
11428 (cmdline_parse_inst_t
*)&cmd_set_link_up
,
11429 (cmdline_parse_inst_t
*)&cmd_set_link_down
,
11430 (cmdline_parse_inst_t
*)&cmd_reset
,
11431 (cmdline_parse_inst_t
*)&cmd_set_numbers
,
11432 (cmdline_parse_inst_t
*)&cmd_set_txpkts
,
11433 (cmdline_parse_inst_t
*)&cmd_set_txsplit
,
11434 (cmdline_parse_inst_t
*)&cmd_set_fwd_list
,
11435 (cmdline_parse_inst_t
*)&cmd_set_fwd_mask
,
11436 (cmdline_parse_inst_t
*)&cmd_set_fwd_mode
,
11437 (cmdline_parse_inst_t
*)&cmd_set_fwd_retry_mode
,
11438 (cmdline_parse_inst_t
*)&cmd_set_burst_tx_retry
,
11439 (cmdline_parse_inst_t
*)&cmd_set_promisc_mode_one
,
11440 (cmdline_parse_inst_t
*)&cmd_set_promisc_mode_all
,
11441 (cmdline_parse_inst_t
*)&cmd_set_allmulti_mode_one
,
11442 (cmdline_parse_inst_t
*)&cmd_set_allmulti_mode_all
,
11443 (cmdline_parse_inst_t
*)&cmd_set_flush_rx
,
11444 (cmdline_parse_inst_t
*)&cmd_set_link_check
,
11445 #ifdef RTE_NIC_BYPASS
11446 (cmdline_parse_inst_t
*)&cmd_set_bypass_mode
,
11447 (cmdline_parse_inst_t
*)&cmd_set_bypass_event
,
11448 (cmdline_parse_inst_t
*)&cmd_set_bypass_timeout
,
11449 (cmdline_parse_inst_t
*)&cmd_show_bypass_config
,
11451 #ifdef RTE_LIBRTE_PMD_BOND
11452 (cmdline_parse_inst_t
*) &cmd_set_bonding_mode
,
11453 (cmdline_parse_inst_t
*) &cmd_show_bonding_config
,
11454 (cmdline_parse_inst_t
*) &cmd_set_bonding_primary
,
11455 (cmdline_parse_inst_t
*) &cmd_add_bonding_slave
,
11456 (cmdline_parse_inst_t
*) &cmd_remove_bonding_slave
,
11457 (cmdline_parse_inst_t
*) &cmd_create_bonded_device
,
11458 (cmdline_parse_inst_t
*) &cmd_set_bond_mac_addr
,
11459 (cmdline_parse_inst_t
*) &cmd_set_balance_xmit_policy
,
11460 (cmdline_parse_inst_t
*) &cmd_set_bond_mon_period
,
11462 (cmdline_parse_inst_t
*)&cmd_vlan_offload
,
11463 (cmdline_parse_inst_t
*)&cmd_vlan_tpid
,
11464 (cmdline_parse_inst_t
*)&cmd_rx_vlan_filter_all
,
11465 (cmdline_parse_inst_t
*)&cmd_rx_vlan_filter
,
11466 (cmdline_parse_inst_t
*)&cmd_tx_vlan_set
,
11467 (cmdline_parse_inst_t
*)&cmd_tx_vlan_set_qinq
,
11468 (cmdline_parse_inst_t
*)&cmd_tx_vlan_reset
,
11469 (cmdline_parse_inst_t
*)&cmd_tx_vlan_set_pvid
,
11470 (cmdline_parse_inst_t
*)&cmd_csum_set
,
11471 (cmdline_parse_inst_t
*)&cmd_csum_show
,
11472 (cmdline_parse_inst_t
*)&cmd_csum_tunnel
,
11473 (cmdline_parse_inst_t
*)&cmd_tso_set
,
11474 (cmdline_parse_inst_t
*)&cmd_tso_show
,
11475 (cmdline_parse_inst_t
*)&cmd_tunnel_tso_set
,
11476 (cmdline_parse_inst_t
*)&cmd_tunnel_tso_show
,
11477 (cmdline_parse_inst_t
*)&cmd_link_flow_control_set
,
11478 (cmdline_parse_inst_t
*)&cmd_link_flow_control_set_rx
,
11479 (cmdline_parse_inst_t
*)&cmd_link_flow_control_set_tx
,
11480 (cmdline_parse_inst_t
*)&cmd_link_flow_control_set_hw
,
11481 (cmdline_parse_inst_t
*)&cmd_link_flow_control_set_lw
,
11482 (cmdline_parse_inst_t
*)&cmd_link_flow_control_set_pt
,
11483 (cmdline_parse_inst_t
*)&cmd_link_flow_control_set_xon
,
11484 (cmdline_parse_inst_t
*)&cmd_link_flow_control_set_macfwd
,
11485 (cmdline_parse_inst_t
*)&cmd_link_flow_control_set_autoneg
,
11486 (cmdline_parse_inst_t
*)&cmd_priority_flow_control_set
,
11487 (cmdline_parse_inst_t
*)&cmd_config_dcb
,
11488 (cmdline_parse_inst_t
*)&cmd_read_reg
,
11489 (cmdline_parse_inst_t
*)&cmd_read_reg_bit_field
,
11490 (cmdline_parse_inst_t
*)&cmd_read_reg_bit
,
11491 (cmdline_parse_inst_t
*)&cmd_write_reg
,
11492 (cmdline_parse_inst_t
*)&cmd_write_reg_bit_field
,
11493 (cmdline_parse_inst_t
*)&cmd_write_reg_bit
,
11494 (cmdline_parse_inst_t
*)&cmd_read_rxd_txd
,
11495 (cmdline_parse_inst_t
*)&cmd_stop
,
11496 (cmdline_parse_inst_t
*)&cmd_mac_addr
,
11497 (cmdline_parse_inst_t
*)&cmd_set_qmap
,
11498 (cmdline_parse_inst_t
*)&cmd_operate_port
,
11499 (cmdline_parse_inst_t
*)&cmd_operate_specific_port
,
11500 (cmdline_parse_inst_t
*)&cmd_operate_attach_port
,
11501 (cmdline_parse_inst_t
*)&cmd_operate_detach_port
,
11502 (cmdline_parse_inst_t
*)&cmd_config_speed_all
,
11503 (cmdline_parse_inst_t
*)&cmd_config_speed_specific
,
11504 (cmdline_parse_inst_t
*)&cmd_config_rx_tx
,
11505 (cmdline_parse_inst_t
*)&cmd_config_mtu
,
11506 (cmdline_parse_inst_t
*)&cmd_config_max_pkt_len
,
11507 (cmdline_parse_inst_t
*)&cmd_config_rx_mode_flag
,
11508 (cmdline_parse_inst_t
*)&cmd_config_rss
,
11509 (cmdline_parse_inst_t
*)&cmd_config_rxtx_queue
,
11510 (cmdline_parse_inst_t
*)&cmd_config_txqflags
,
11511 (cmdline_parse_inst_t
*)&cmd_config_rss_reta
,
11512 (cmdline_parse_inst_t
*)&cmd_showport_reta
,
11513 (cmdline_parse_inst_t
*)&cmd_config_burst
,
11514 (cmdline_parse_inst_t
*)&cmd_config_thresh
,
11515 (cmdline_parse_inst_t
*)&cmd_config_threshold
,
11516 (cmdline_parse_inst_t
*)&cmd_set_vf_rxmode
,
11517 (cmdline_parse_inst_t
*)&cmd_set_uc_hash_filter
,
11518 (cmdline_parse_inst_t
*)&cmd_set_uc_all_hash_filter
,
11519 (cmdline_parse_inst_t
*)&cmd_vf_mac_addr_filter
,
11520 (cmdline_parse_inst_t
*)&cmd_set_vf_macvlan_filter
,
11521 (cmdline_parse_inst_t
*)&cmd_set_vf_traffic
,
11522 (cmdline_parse_inst_t
*)&cmd_vf_rxvlan_filter
,
11523 (cmdline_parse_inst_t
*)&cmd_queue_rate_limit
,
11524 (cmdline_parse_inst_t
*)&cmd_vf_rate_limit
,
11525 (cmdline_parse_inst_t
*)&cmd_tunnel_filter
,
11526 (cmdline_parse_inst_t
*)&cmd_tunnel_udp_config
,
11527 (cmdline_parse_inst_t
*)&cmd_global_config
,
11528 (cmdline_parse_inst_t
*)&cmd_set_mirror_mask
,
11529 (cmdline_parse_inst_t
*)&cmd_set_mirror_link
,
11530 (cmdline_parse_inst_t
*)&cmd_reset_mirror_rule
,
11531 (cmdline_parse_inst_t
*)&cmd_showport_rss_hash
,
11532 (cmdline_parse_inst_t
*)&cmd_showport_rss_hash_key
,
11533 (cmdline_parse_inst_t
*)&cmd_config_rss_hash_key
,
11534 (cmdline_parse_inst_t
*)&cmd_dump
,
11535 (cmdline_parse_inst_t
*)&cmd_dump_one
,
11536 (cmdline_parse_inst_t
*)&cmd_ethertype_filter
,
11537 (cmdline_parse_inst_t
*)&cmd_syn_filter
,
11538 (cmdline_parse_inst_t
*)&cmd_2tuple_filter
,
11539 (cmdline_parse_inst_t
*)&cmd_5tuple_filter
,
11540 (cmdline_parse_inst_t
*)&cmd_flex_filter
,
11541 (cmdline_parse_inst_t
*)&cmd_add_del_ip_flow_director
,
11542 (cmdline_parse_inst_t
*)&cmd_add_del_udp_flow_director
,
11543 (cmdline_parse_inst_t
*)&cmd_add_del_sctp_flow_director
,
11544 (cmdline_parse_inst_t
*)&cmd_add_del_l2_flow_director
,
11545 (cmdline_parse_inst_t
*)&cmd_add_del_mac_vlan_flow_director
,
11546 (cmdline_parse_inst_t
*)&cmd_add_del_tunnel_flow_director
,
11547 (cmdline_parse_inst_t
*)&cmd_flush_flow_director
,
11548 (cmdline_parse_inst_t
*)&cmd_set_flow_director_ip_mask
,
11549 (cmdline_parse_inst_t
*)&cmd_set_flow_director_mac_vlan_mask
,
11550 (cmdline_parse_inst_t
*)&cmd_set_flow_director_tunnel_mask
,
11551 (cmdline_parse_inst_t
*)&cmd_set_flow_director_flex_mask
,
11552 (cmdline_parse_inst_t
*)&cmd_set_flow_director_flex_payload
,
11553 (cmdline_parse_inst_t
*)&cmd_get_sym_hash_ena_per_port
,
11554 (cmdline_parse_inst_t
*)&cmd_set_sym_hash_ena_per_port
,
11555 (cmdline_parse_inst_t
*)&cmd_get_hash_global_config
,
11556 (cmdline_parse_inst_t
*)&cmd_set_hash_global_config
,
11557 (cmdline_parse_inst_t
*)&cmd_set_hash_input_set
,
11558 (cmdline_parse_inst_t
*)&cmd_set_fdir_input_set
,
11559 (cmdline_parse_inst_t
*)&cmd_mcast_addr
,
11560 (cmdline_parse_inst_t
*)&cmd_config_l2_tunnel_eth_type_all
,
11561 (cmdline_parse_inst_t
*)&cmd_config_l2_tunnel_eth_type_specific
,
11562 (cmdline_parse_inst_t
*)&cmd_config_l2_tunnel_en_dis_all
,
11563 (cmdline_parse_inst_t
*)&cmd_config_l2_tunnel_en_dis_specific
,
11564 (cmdline_parse_inst_t
*)&cmd_config_e_tag_insertion_en
,
11565 (cmdline_parse_inst_t
*)&cmd_config_e_tag_insertion_dis
,
11566 (cmdline_parse_inst_t
*)&cmd_config_e_tag_stripping_en_dis
,
11567 (cmdline_parse_inst_t
*)&cmd_config_e_tag_forwarding_en_dis
,
11568 (cmdline_parse_inst_t
*)&cmd_config_e_tag_filter_add
,
11569 (cmdline_parse_inst_t
*)&cmd_config_e_tag_filter_del
,
11570 #ifdef RTE_LIBRTE_IXGBE_PMD
11571 (cmdline_parse_inst_t
*)&cmd_set_vf_vlan_anti_spoof
,
11572 (cmdline_parse_inst_t
*)&cmd_set_vf_mac_anti_spoof
,
11573 (cmdline_parse_inst_t
*)&cmd_set_vf_vlan_stripq
,
11574 (cmdline_parse_inst_t
*)&cmd_set_vf_vlan_insert
,
11575 (cmdline_parse_inst_t
*)&cmd_set_tx_loopback
,
11576 (cmdline_parse_inst_t
*)&cmd_set_all_queues_drop_en
,
11577 (cmdline_parse_inst_t
*)&cmd_set_vf_split_drop_en
,
11578 (cmdline_parse_inst_t
*)&cmd_set_vf_mac_addr
,
11583 /* prompt function, called from main on MASTER lcore */
11587 /* initialize non-constant commands */
11588 cmd_set_fwd_mode_init();
11589 cmd_set_fwd_retry_mode_init();
11591 testpmd_cl
= cmdline_stdin_new(main_ctx
, "testpmd> ");
11592 if (testpmd_cl
== NULL
)
11594 cmdline_interact(testpmd_cl
);
11595 cmdline_stdin_exit(testpmd_cl
);
11601 if (testpmd_cl
!= NULL
)
11602 cmdline_quit(testpmd_cl
);
11606 cmd_reconfig_device_queue(portid_t id
, uint8_t dev
, uint8_t queue
)
11608 if (id
== (portid_t
)RTE_PORT_ALL
) {
11611 FOREACH_PORT(pid
, ports
) {
11612 /* check if need_reconfig has been set to 1 */
11613 if (ports
[pid
].need_reconfig
== 0)
11614 ports
[pid
].need_reconfig
= dev
;
11615 /* check if need_reconfig_queues has been set to 1 */
11616 if (ports
[pid
].need_reconfig_queues
== 0)
11617 ports
[pid
].need_reconfig_queues
= queue
;
11619 } else if (!port_id_is_invalid(id
, DISABLED_WARN
)) {
11620 /* check if need_reconfig has been set to 1 */
11621 if (ports
[id
].need_reconfig
== 0)
11622 ports
[id
].need_reconfig
= dev
;
11623 /* check if need_reconfig_queues has been set to 1 */
11624 if (ports
[id
].need_reconfig_queues
== 0)
11625 ports
[id
].need_reconfig_queues
= queue
;