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>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
91 #ifdef RTE_LIBRTE_IXGBE_PMD
92 #include <rte_pmd_ixgbe.h>
94 #ifdef RTE_LIBRTE_I40E_PMD
95 #include <rte_pmd_i40e.h>
99 static struct cmdline *testpmd_cl;
101 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
103 /* *** Help command with introduction. *** */
104 struct cmd_help_brief_result {
105 cmdline_fixed_string_t help;
108 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
110 __attribute__((unused)) void *data)
115 "Help is available for the following sections:\n\n"
116 " help control : Start and stop forwarding.\n"
117 " help display : Displaying port, stats and config "
119 " help config : Configuration information.\n"
120 " help ports : Configuring ports.\n"
121 " help registers : Reading and setting port registers.\n"
122 " help filters : Filters configuration help.\n"
123 " help all : All of the above sections.\n\n"
128 cmdline_parse_token_string_t cmd_help_brief_help =
129 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
131 cmdline_parse_inst_t cmd_help_brief = {
132 .f = cmd_help_brief_parsed,
134 .help_str = "help: Show help",
136 (void *)&cmd_help_brief_help,
141 /* *** Help command with help sections. *** */
142 struct cmd_help_long_result {
143 cmdline_fixed_string_t help;
144 cmdline_fixed_string_t section;
147 static void cmd_help_long_parsed(void *parsed_result,
149 __attribute__((unused)) void *data)
152 struct cmd_help_long_result *res = parsed_result;
154 if (!strcmp(res->section, "all"))
157 if (show_all || !strcmp(res->section, "control")) {
162 "Control forwarding:\n"
163 "-------------------\n\n"
166 " Start packet forwarding with current configuration.\n\n"
169 " Start packet forwarding with current config"
170 " after sending one burst of packets.\n\n"
173 " Stop packet forwarding, and display accumulated"
177 " Quit to prompt.\n\n"
181 if (show_all || !strcmp(res->section, "display")) {
189 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
190 " Display information for port_id, or all.\n\n"
192 "show port X rss reta (size) (mask0,mask1,...)\n"
193 " Display the rss redirection table entry indicated"
194 " by masks on port X. size is used to indicate the"
195 " hardware supported reta size\n\n"
197 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
198 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
199 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
200 " Display the RSS hash functions and RSS hash key"
203 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
204 " Clear information for port_id, or all.\n\n"
206 "show (rxq|txq) info (port_id) (queue_id)\n"
207 " Display information for configured RX/TX queue.\n\n"
209 "show config (rxtx|cores|fwd|txpkts)\n"
210 " Display the given configuration.\n\n"
212 "read rxd (port_id) (queue_id) (rxd_id)\n"
213 " Display an RX descriptor of a port RX queue.\n\n"
215 "read txd (port_id) (queue_id) (txd_id)\n"
216 " Display a TX descriptor of a port TX queue.\n\n"
220 if (show_all || !strcmp(res->section, "config")) {
226 "Configuration changes only become active when"
227 " forwarding is started/restarted.\n\n"
230 " Reset forwarding to the default configuration.\n\n"
232 "set verbose (level)\n"
233 " Set the debug verbosity level X.\n\n"
236 " Set number of ports.\n\n"
239 " Set number of cores.\n\n"
241 "set coremask (mask)\n"
242 " Set the forwarding cores hexadecimal mask.\n\n"
244 "set portmask (mask)\n"
245 " Set the forwarding ports hexadecimal mask.\n\n"
248 " Set number of packets per burst.\n\n"
250 "set burst tx delay (microseconds) retry (num)\n"
251 " Set the transmit delay time and number of retries,"
252 " effective when retry is enabled.\n\n"
254 "set txpkts (x[,y]*)\n"
255 " Set the length of each segment of TXONLY"
256 " and optionally CSUM packets.\n\n"
258 "set txsplit (off|on|rand)\n"
259 " Set the split policy for the TX packets."
260 " Right now only applicable for CSUM and TXONLY"
263 "set corelist (x[,y]*)\n"
264 " Set the list of forwarding cores.\n\n"
266 "set portlist (x[,y]*)\n"
267 " Set the list of forwarding ports.\n\n"
269 "set tx loopback (port_id) (on|off)\n"
270 " Enable or disable tx loopback.\n\n"
272 #ifdef RTE_LIBRTE_IXGBE_PMD
273 "set all queues drop (port_id) (on|off)\n"
274 " Set drop enable bit for all queues.\n\n"
276 "set vf split drop (port_id) (vf_id) (on|off)\n"
277 " Set split drop enable bit for a VF from the PF.\n\n"
280 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
281 " Set MAC antispoof for a VF from the PF.\n\n"
283 #ifdef RTE_LIBRTE_IXGBE_PMD
284 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
285 " Enable MACsec offload.\n\n"
287 "set macsec offload (port_id) off\n"
288 " Disable MACsec offload.\n\n"
290 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
291 " Configure MACsec secure connection (SC).\n\n"
293 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
294 " Configure MACsec secure association (SA).\n\n"
297 "set vf broadcast (port_id) (vf_id) (on|off)\n"
298 " Set VF broadcast for a VF from the PF.\n\n"
300 "vlan set strip (on|off) (port_id)\n"
301 " Set the VLAN strip on a port.\n\n"
303 "vlan set stripq (on|off) (port_id,queue_id)\n"
304 " Set the VLAN strip for a queue on a port.\n\n"
306 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
307 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
309 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
310 " Set VLAN insert for a VF from the PF.\n\n"
312 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
313 " Set VLAN antispoof for a VF from the PF.\n\n"
315 "vlan set filter (on|off) (port_id)\n"
316 " Set the VLAN filter on a port.\n\n"
318 "vlan set qinq (on|off) (port_id)\n"
319 " Set the VLAN QinQ (extended queue in queue)"
322 "vlan set (inner|outer) tpid (value) (port_id)\n"
323 " Set the VLAN TPID for Packet Filtering on"
326 "rx_vlan add (vlan_id|all) (port_id)\n"
327 " Add a vlan_id, or all identifiers, to the set"
328 " of VLAN identifiers filtered by port_id.\n\n"
330 "rx_vlan rm (vlan_id|all) (port_id)\n"
331 " Remove a vlan_id, or all identifiers, from the set"
332 " of VLAN identifiers filtered by port_id.\n\n"
334 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
335 " Add a vlan_id, to the set of VLAN identifiers"
336 "filtered for VF(s) from port_id.\n\n"
338 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
339 " Remove a vlan_id, to the set of VLAN identifiers"
340 "filtered for VF(s) from port_id.\n\n"
342 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
343 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
344 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
345 " add a tunnel filter of a port.\n\n"
347 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
348 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
349 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
350 " remove a tunnel filter of a port.\n\n"
352 "rx_vxlan_port add (udp_port) (port_id)\n"
353 " Add an UDP port for VXLAN packet filter on a port\n\n"
355 "rx_vxlan_port rm (udp_port) (port_id)\n"
356 " Remove an UDP port for VXLAN packet filter on a port\n\n"
358 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
359 " Set hardware insertion of VLAN IDs (single or double VLAN "
360 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
362 "tx_vlan set pvid port_id vlan_id (on|off)\n"
363 " Set port based TX VLAN insertion.\n\n"
365 "tx_vlan reset (port_id)\n"
366 " Disable hardware insertion of a VLAN header in"
367 " packets sent on a port.\n\n"
369 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
370 " Select hardware or software calculation of the"
371 " checksum when transmitting a packet using the"
372 " csum forward engine.\n"
373 " ip|udp|tcp|sctp always concern the inner layer.\n"
374 " outer-ip concerns the outer IP layer in"
375 " case the packet is recognized as a tunnel packet by"
376 " the forward engine (vxlan, gre and ipip are supported)\n"
377 " Please check the NIC datasheet for HW limits.\n\n"
379 "csum parse-tunnel (on|off) (tx_port_id)\n"
380 " If disabled, treat tunnel packets as non-tunneled"
381 " packets (treat inner headers as payload). The port\n"
382 " argument is the port used for TX in csum forward"
385 "csum show (port_id)\n"
386 " Display tx checksum offload configuration\n\n"
388 "tso set (segsize) (portid)\n"
389 " Enable TCP Segmentation Offload in csum forward"
391 " Please check the NIC datasheet for HW limits.\n\n"
394 " Display the status of TCP Segmentation Offload.\n\n"
397 " Set packet forwarding mode.\n\n"
399 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
400 " Add a MAC address on port_id.\n\n"
402 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
403 " Remove a MAC address from port_id.\n\n"
405 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
406 " Add a MAC address for a VF on the port.\n\n"
408 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
409 " Set the MAC address for a VF from the PF.\n\n"
411 "set port (port_id) uta (mac_address|all) (on|off)\n"
412 " Add/Remove a or all unicast hash filter(s)"
415 "set promisc (port_id|all) (on|off)\n"
416 " Set the promiscuous mode on port_id, or all.\n\n"
418 "set allmulti (port_id|all) (on|off)\n"
419 " Set the allmulti mode on port_id, or all.\n\n"
421 "set vf promisc (port_id) (vf_id) (on|off)\n"
422 " Set unicast promiscuous mode for a VF from the PF.\n\n"
424 "set vf allmulti (port_id) (vf_id) (on|off)\n"
425 " Set multicast promiscuous mode for a VF from the PF.\n\n"
427 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
428 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
429 " (on|off) autoneg (on|off) (port_id)\n"
430 "set flow_ctrl rx (on|off) (portid)\n"
431 "set flow_ctrl tx (on|off) (portid)\n"
432 "set flow_ctrl high_water (high_water) (portid)\n"
433 "set flow_ctrl low_water (low_water) (portid)\n"
434 "set flow_ctrl pause_time (pause_time) (portid)\n"
435 "set flow_ctrl send_xon (send_xon) (portid)\n"
436 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
437 "set flow_ctrl autoneg (on|off) (port_id)\n"
438 " Set the link flow control parameter on a port.\n\n"
440 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
441 " (low_water) (pause_time) (priority) (port_id)\n"
442 " Set the priority flow control parameter on a"
445 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
446 " Set statistics mapping (qmapping 0..15) for RX/TX"
448 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
449 " on port 0 to mapping 5.\n\n"
451 "set port (port_id) vf (vf_id) rx|tx on|off\n"
452 " Enable/Disable a VF receive/tranmit from a port\n\n"
454 "set port (port_id) vf (vf_id) (mac_addr)"
455 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
456 " Add/Remove unicast or multicast MAC addr filter"
459 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
461 " AUPE:accepts untagged VLAN;"
462 "ROPE:accept unicast hash\n\n"
463 " BAM:accepts broadcast packets;"
464 "MPE:accepts all multicast packets\n\n"
465 " Enable/Disable a VF receive mode of a port\n\n"
467 "set port (port_id) queue (queue_id) rate (rate_num)\n"
468 " Set rate limit for a queue of a port\n\n"
470 "set port (port_id) vf (vf_id) rate (rate_num) "
471 "queue_mask (queue_mask_value)\n"
472 " Set rate limit for queues in VF of a port\n\n"
474 "set port (port_id) mirror-rule (rule_id)"
475 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
476 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
477 " Set pool or vlan type mirror rule on a port.\n"
478 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
479 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
482 "set port (port_id) mirror-rule (rule_id)"
483 " (uplink-mirror|downlink-mirror) dst-pool"
484 " (pool_id) (on|off)\n"
485 " Set uplink or downlink type mirror rule on a port.\n"
486 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
487 " 0 on' enable mirror income traffic to pool 0.\n\n"
489 "reset port (port_id) mirror-rule (rule_id)\n"
490 " Reset a mirror rule.\n\n"
492 "set flush_rx (on|off)\n"
493 " Flush (default) or don't flush RX streams before"
494 " forwarding. Mainly used with PCAP drivers.\n\n"
496 #ifdef RTE_NIC_BYPASS
497 "set bypass mode (normal|bypass|isolate) (port_id)\n"
498 " Set the bypass mode for the lowest port on bypass enabled"
501 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
502 "mode (normal|bypass|isolate) (port_id)\n"
503 " Set the event required to initiate specified bypass mode for"
504 " the lowest port on a bypass enabled NIC where:\n"
505 " timeout = enable bypass after watchdog timeout.\n"
506 " os_on = enable bypass when OS/board is powered on.\n"
507 " os_off = enable bypass when OS/board is powered off.\n"
508 " power_on = enable bypass when power supply is turned on.\n"
509 " power_off = enable bypass when power supply is turned off."
512 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
513 " Set the bypass watchdog timeout to 'n' seconds"
514 " where 0 = instant.\n\n"
516 "show bypass config (port_id)\n"
517 " Show the bypass configuration for a bypass enabled NIC"
518 " using the lowest port on the NIC.\n\n"
520 #ifdef RTE_LIBRTE_PMD_BOND
521 "create bonded device (mode) (socket)\n"
522 " Create a new bonded device with specific bonding mode and socket.\n\n"
524 "add bonding slave (slave_id) (port_id)\n"
525 " Add a slave device to a bonded device.\n\n"
527 "remove bonding slave (slave_id) (port_id)\n"
528 " Remove a slave device from a bonded device.\n\n"
530 "set bonding mode (value) (port_id)\n"
531 " Set the bonding mode on a bonded device.\n\n"
533 "set bonding primary (slave_id) (port_id)\n"
534 " Set the primary slave for a bonded device.\n\n"
536 "show bonding config (port_id)\n"
537 " Show the bonding config for port_id.\n\n"
539 "set bonding mac_addr (port_id) (address)\n"
540 " Set the MAC address of a bonded device.\n\n"
542 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
543 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
545 "set bonding mon_period (port_id) (value)\n"
546 " Set the bonding link status monitoring polling period in ms.\n\n"
548 "set link-up port (port_id)\n"
549 " Set link up for a port.\n\n"
551 "set link-down port (port_id)\n"
552 " Set link down for a port.\n\n"
554 "E-tag set insertion on port-tag-id (value)"
555 " port (port_id) vf (vf_id)\n"
556 " Enable E-tag insertion for a VF on a port\n\n"
558 "E-tag set insertion off port (port_id) vf (vf_id)\n"
559 " Disable E-tag insertion for a VF on a port\n\n"
561 "E-tag set stripping (on|off) port (port_id)\n"
562 " Enable/disable E-tag stripping on a port\n\n"
564 "E-tag set forwarding (on|off) port (port_id)\n"
565 " Enable/disable E-tag based forwarding"
568 "E-tag set filter add e-tag-id (value) dst-pool"
569 " (pool_id) port (port_id)\n"
570 " Add an E-tag forwarding filter on a port\n\n"
572 "E-tag set filter del e-tag-id (value) port (port_id)\n"
573 " Delete an E-tag forwarding filter on a port\n\n"
575 , list_pkt_forwarding_modes()
579 if (show_all || !strcmp(res->section, "ports")) {
585 "----------------\n\n"
587 "port start (port_id|all)\n"
588 " Start all ports or port_id.\n\n"
590 "port stop (port_id|all)\n"
591 " Stop all ports or port_id.\n\n"
593 "port close (port_id|all)\n"
594 " Close all ports or port_id.\n\n"
596 "port attach (ident)\n"
597 " Attach physical or virtual dev by pci address or virtual device name\n\n"
599 "port detach (port_id)\n"
600 " Detach physical or virtual dev by port_id\n\n"
602 "port config (port_id|all)"
603 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
604 " duplex (half|full|auto)\n"
605 " Set speed and duplex for all ports or port_id\n\n"
607 "port config all (rxq|txq|rxd|txd) (value)\n"
608 " Set number for rxq/txq/rxd/txd.\n\n"
610 "port config all max-pkt-len (value)\n"
611 " Set the max packet length.\n\n"
613 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
614 "hw-vlan-strip|hw-vlan-extend|drop-en)"
616 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
619 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
620 " Set the RSS mode.\n\n"
622 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
623 " Set the RSS redirection table.\n\n"
625 "port config (port_id) dcb vt (on|off) (traffic_class)"
627 " Set the DCB mode.\n\n"
629 "port config all burst (value)\n"
630 " Set the number of packets per burst.\n\n"
632 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
634 " Set the ring prefetch/host/writeback threshold"
635 " for tx/rx queue.\n\n"
637 "port config all (txfreet|txrst|rxfreet) (value)\n"
638 " Set free threshold for rx/tx, or set"
639 " tx rs bit threshold.\n\n"
640 "port config mtu X value\n"
641 " Set the MTU of port X to a given value\n\n"
643 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
644 " Start/stop a rx/tx queue of port X. Only take effect"
645 " when port X is started\n\n"
647 "port config (port_id|all) l2-tunnel E-tag ether-type"
649 " Set the value of E-tag ether-type.\n\n"
651 "port config (port_id|all) l2-tunnel E-tag"
652 " (enable|disable)\n"
653 " Enable/disable the E-tag support.\n\n"
657 if (show_all || !strcmp(res->section, "registers")) {
665 "read reg (port_id) (address)\n"
666 " Display value of a port register.\n\n"
668 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
669 " Display a port register bit field.\n\n"
671 "read regbit (port_id) (address) (bit_x)\n"
672 " Display a single port register bit.\n\n"
674 "write reg (port_id) (address) (value)\n"
675 " Set value of a port register.\n\n"
677 "write regfield (port_id) (address) (bit_x) (bit_y)"
679 " Set bit field of a port register.\n\n"
681 "write regbit (port_id) (address) (bit_x) (value)\n"
682 " Set single bit value of a port register.\n\n"
685 if (show_all || !strcmp(res->section, "filters")) {
693 "ethertype_filter (port_id) (add|del)"
694 " (mac_addr|mac_ignr) (mac_address) ethertype"
695 " (ether_type) (drop|fwd) queue (queue_id)\n"
696 " Add/Del an ethertype filter.\n\n"
698 "2tuple_filter (port_id) (add|del)"
699 " dst_port (dst_port_value) protocol (protocol_value)"
700 " mask (mask_value) tcp_flags (tcp_flags_value)"
701 " priority (prio_value) queue (queue_id)\n"
702 " Add/Del a 2tuple filter.\n\n"
704 "5tuple_filter (port_id) (add|del)"
705 " dst_ip (dst_address) src_ip (src_address)"
706 " dst_port (dst_port_value) src_port (src_port_value)"
707 " protocol (protocol_value)"
708 " mask (mask_value) tcp_flags (tcp_flags_value)"
709 " priority (prio_value) queue (queue_id)\n"
710 " Add/Del a 5tuple filter.\n\n"
712 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
713 " Add/Del syn filter.\n\n"
715 "flex_filter (port_id) (add|del) len (len_value)"
716 " bytes (bytes_value) mask (mask_value)"
717 " priority (prio_value) queue (queue_id)\n"
718 " Add/Del a flex filter.\n\n"
720 "flow_director_filter (port_id) mode IP (add|del|update)"
721 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
722 " src (src_ip_address) dst (dst_ip_address)"
723 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
724 " vlan (vlan_value) flexbytes (flexbytes_value)"
725 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
726 " fd_id (fd_id_value)\n"
727 " Add/Del an IP type flow director filter.\n\n"
729 "flow_director_filter (port_id) mode IP (add|del|update)"
730 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
731 " src (src_ip_address) (src_port)"
732 " dst (dst_ip_address) (dst_port)"
733 " tos (tos_value) ttl (ttl_value)"
734 " vlan (vlan_value) flexbytes (flexbytes_value)"
735 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
736 " fd_id (fd_id_value)\n"
737 " Add/Del an UDP/TCP type flow director filter.\n\n"
739 "flow_director_filter (port_id) mode IP (add|del|update)"
740 " flow (ipv4-sctp|ipv6-sctp)"
741 " src (src_ip_address) (src_port)"
742 " dst (dst_ip_address) (dst_port)"
743 " tag (verification_tag) "
744 " tos (tos_value) ttl (ttl_value)"
746 " flexbytes (flexbytes_value) (drop|fwd)"
747 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
748 " Add/Del a SCTP type flow director filter.\n\n"
750 "flow_director_filter (port_id) mode IP (add|del|update)"
751 " flow l2_payload ether (ethertype)"
752 " flexbytes (flexbytes_value) (drop|fwd)"
753 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
754 " Add/Del a l2 payload type flow director filter.\n\n"
756 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
757 " mac (mac_address) vlan (vlan_value)"
758 " flexbytes (flexbytes_value) (drop|fwd)"
759 " queue (queue_id) fd_id (fd_id_value)\n"
760 " Add/Del a MAC-VLAN flow director filter.\n\n"
762 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
763 " mac (mac_address) vlan (vlan_value)"
764 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
765 " flexbytes (flexbytes_value) (drop|fwd)"
766 " queue (queue_id) fd_id (fd_id_value)\n"
767 " Add/Del a Tunnel flow director filter.\n\n"
769 "flush_flow_director (port_id)\n"
770 " Flush all flow director entries of a device.\n\n"
772 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
773 " src_mask (ipv4_src) (ipv6_src) (src_port)"
774 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
775 " Set flow director IP mask.\n\n"
777 "flow_director_mask (port_id) mode MAC-VLAN"
778 " vlan (vlan_value)\n"
779 " Set flow director MAC-VLAN mask.\n\n"
781 "flow_director_mask (port_id) mode Tunnel"
782 " vlan (vlan_value) mac (mac_value)"
783 " tunnel-type (tunnel_type_value)"
784 " tunnel-id (tunnel_id_value)\n"
785 " Set flow director Tunnel mask.\n\n"
787 "flow_director_flex_mask (port_id)"
788 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
789 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
791 " Configure mask of flex payload.\n\n"
793 "flow_director_flex_payload (port_id)"
794 " (raw|l2|l3|l4) (config)\n"
795 " Configure flex payload selection.\n\n"
797 "get_sym_hash_ena_per_port (port_id)\n"
798 " get symmetric hash enable configuration per port.\n\n"
800 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
801 " set symmetric hash enable configuration per port"
802 " to enable or disable.\n\n"
804 "get_hash_global_config (port_id)\n"
805 " Get the global configurations of hash filters.\n\n"
807 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
808 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
809 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
810 " (enable|disable)\n"
811 " Set the global configurations of hash filters.\n\n"
813 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
814 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
815 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
816 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
817 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
818 "ipv6-next-header|udp-src-port|udp-dst-port|"
819 "tcp-src-port|tcp-dst-port|sctp-src-port|"
820 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
821 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
822 "fld-8th|none) (select|add)\n"
823 " Set the input set for hash.\n\n"
825 "set_fdir_input_set (port_id) "
826 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
827 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
828 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
829 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
830 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
831 "udp-dst-port|tcp-src-port|tcp-dst-port|"
832 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
834 " Set the input set for FDir.\n\n"
836 "flow validate {port_id}"
837 " [group {group_id}] [priority {level}]"
838 " [ingress] [egress]"
839 " pattern {item} [/ {item} [...]] / end"
840 " actions {action} [/ {action} [...]] / end\n"
841 " Check whether a flow rule can be created.\n\n"
843 "flow create {port_id}"
844 " [group {group_id}] [priority {level}]"
845 " [ingress] [egress]"
846 " pattern {item} [/ {item} [...]] / end"
847 " actions {action} [/ {action} [...]] / end\n"
848 " Create a flow rule.\n\n"
850 "flow destroy {port_id} rule {rule_id} [...]\n"
851 " Destroy specific flow rules.\n\n"
853 "flow flush {port_id}\n"
854 " Destroy all flow rules.\n\n"
856 "flow query {port_id} {rule_id} {action}\n"
857 " Query an existing flow rule.\n\n"
859 "flow list {port_id} [group {group_id}] [...]\n"
860 " List existing flow rules sorted by priority,"
861 " filtered by group identifiers.\n\n"
866 cmdline_parse_token_string_t cmd_help_long_help =
867 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
869 cmdline_parse_token_string_t cmd_help_long_section =
870 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
871 "all#control#display#config#"
872 "ports#registers#filters");
874 cmdline_parse_inst_t cmd_help_long = {
875 .f = cmd_help_long_parsed,
877 .help_str = "help all|control|display|config|ports|register|filters: "
880 (void *)&cmd_help_long_help,
881 (void *)&cmd_help_long_section,
887 /* *** start/stop/close all ports *** */
888 struct cmd_operate_port_result {
889 cmdline_fixed_string_t keyword;
890 cmdline_fixed_string_t name;
891 cmdline_fixed_string_t value;
894 static void cmd_operate_port_parsed(void *parsed_result,
895 __attribute__((unused)) struct cmdline *cl,
896 __attribute__((unused)) void *data)
898 struct cmd_operate_port_result *res = parsed_result;
900 if (!strcmp(res->name, "start"))
901 start_port(RTE_PORT_ALL);
902 else if (!strcmp(res->name, "stop"))
903 stop_port(RTE_PORT_ALL);
904 else if (!strcmp(res->name, "close"))
905 close_port(RTE_PORT_ALL);
907 printf("Unknown parameter\n");
910 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
911 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
913 cmdline_parse_token_string_t cmd_operate_port_all_port =
914 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
916 cmdline_parse_token_string_t cmd_operate_port_all_all =
917 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
919 cmdline_parse_inst_t cmd_operate_port = {
920 .f = cmd_operate_port_parsed,
922 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
924 (void *)&cmd_operate_port_all_cmd,
925 (void *)&cmd_operate_port_all_port,
926 (void *)&cmd_operate_port_all_all,
931 /* *** start/stop/close specific port *** */
932 struct cmd_operate_specific_port_result {
933 cmdline_fixed_string_t keyword;
934 cmdline_fixed_string_t name;
938 static void cmd_operate_specific_port_parsed(void *parsed_result,
939 __attribute__((unused)) struct cmdline *cl,
940 __attribute__((unused)) void *data)
942 struct cmd_operate_specific_port_result *res = parsed_result;
944 if (!strcmp(res->name, "start"))
945 start_port(res->value);
946 else if (!strcmp(res->name, "stop"))
947 stop_port(res->value);
948 else if (!strcmp(res->name, "close"))
949 close_port(res->value);
951 printf("Unknown parameter\n");
954 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
955 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
957 cmdline_parse_token_string_t cmd_operate_specific_port_port =
958 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
959 name, "start#stop#close");
960 cmdline_parse_token_num_t cmd_operate_specific_port_id =
961 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
964 cmdline_parse_inst_t cmd_operate_specific_port = {
965 .f = cmd_operate_specific_port_parsed,
967 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
969 (void *)&cmd_operate_specific_port_cmd,
970 (void *)&cmd_operate_specific_port_port,
971 (void *)&cmd_operate_specific_port_id,
976 /* *** attach a specified port *** */
977 struct cmd_operate_attach_port_result {
978 cmdline_fixed_string_t port;
979 cmdline_fixed_string_t keyword;
980 cmdline_fixed_string_t identifier;
983 static void cmd_operate_attach_port_parsed(void *parsed_result,
984 __attribute__((unused)) struct cmdline *cl,
985 __attribute__((unused)) void *data)
987 struct cmd_operate_attach_port_result *res = parsed_result;
989 if (!strcmp(res->keyword, "attach"))
990 attach_port(res->identifier);
992 printf("Unknown parameter\n");
995 cmdline_parse_token_string_t cmd_operate_attach_port_port =
996 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
998 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
999 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1001 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1002 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1005 cmdline_parse_inst_t cmd_operate_attach_port = {
1006 .f = cmd_operate_attach_port_parsed,
1008 .help_str = "port attach <identifier>: "
1009 "(identifier: pci address or virtual dev name)",
1011 (void *)&cmd_operate_attach_port_port,
1012 (void *)&cmd_operate_attach_port_keyword,
1013 (void *)&cmd_operate_attach_port_identifier,
1018 /* *** detach a specified port *** */
1019 struct cmd_operate_detach_port_result {
1020 cmdline_fixed_string_t port;
1021 cmdline_fixed_string_t keyword;
1025 static void cmd_operate_detach_port_parsed(void *parsed_result,
1026 __attribute__((unused)) struct cmdline *cl,
1027 __attribute__((unused)) void *data)
1029 struct cmd_operate_detach_port_result *res = parsed_result;
1031 if (!strcmp(res->keyword, "detach"))
1032 detach_port(res->port_id);
1034 printf("Unknown parameter\n");
1037 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1038 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1040 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1041 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1043 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1044 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1047 cmdline_parse_inst_t cmd_operate_detach_port = {
1048 .f = cmd_operate_detach_port_parsed,
1050 .help_str = "port detach <port_id>",
1052 (void *)&cmd_operate_detach_port_port,
1053 (void *)&cmd_operate_detach_port_keyword,
1054 (void *)&cmd_operate_detach_port_port_id,
1059 /* *** configure speed for all ports *** */
1060 struct cmd_config_speed_all {
1061 cmdline_fixed_string_t port;
1062 cmdline_fixed_string_t keyword;
1063 cmdline_fixed_string_t all;
1064 cmdline_fixed_string_t item1;
1065 cmdline_fixed_string_t item2;
1066 cmdline_fixed_string_t value1;
1067 cmdline_fixed_string_t value2;
1071 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1076 if (!strcmp(duplexstr, "half")) {
1077 duplex = ETH_LINK_HALF_DUPLEX;
1078 } else if (!strcmp(duplexstr, "full")) {
1079 duplex = ETH_LINK_FULL_DUPLEX;
1080 } else if (!strcmp(duplexstr, "auto")) {
1081 duplex = ETH_LINK_FULL_DUPLEX;
1083 printf("Unknown duplex parameter\n");
1087 if (!strcmp(speedstr, "10")) {
1088 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1089 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1090 } else if (!strcmp(speedstr, "100")) {
1091 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1092 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1094 if (duplex != ETH_LINK_FULL_DUPLEX) {
1095 printf("Invalid speed/duplex parameters\n");
1098 if (!strcmp(speedstr, "1000")) {
1099 *speed = ETH_LINK_SPEED_1G;
1100 } else if (!strcmp(speedstr, "10000")) {
1101 *speed = ETH_LINK_SPEED_10G;
1102 } else if (!strcmp(speedstr, "25000")) {
1103 *speed = ETH_LINK_SPEED_25G;
1104 } else if (!strcmp(speedstr, "40000")) {
1105 *speed = ETH_LINK_SPEED_40G;
1106 } else if (!strcmp(speedstr, "50000")) {
1107 *speed = ETH_LINK_SPEED_50G;
1108 } else if (!strcmp(speedstr, "100000")) {
1109 *speed = ETH_LINK_SPEED_100G;
1110 } else if (!strcmp(speedstr, "auto")) {
1111 *speed = ETH_LINK_SPEED_AUTONEG;
1113 printf("Unknown speed parameter\n");
1122 cmd_config_speed_all_parsed(void *parsed_result,
1123 __attribute__((unused)) struct cmdline *cl,
1124 __attribute__((unused)) void *data)
1126 struct cmd_config_speed_all *res = parsed_result;
1127 uint32_t link_speed;
1130 if (!all_ports_stopped()) {
1131 printf("Please stop all ports first\n");
1135 if (parse_and_check_speed_duplex(res->value1, res->value2,
1139 FOREACH_PORT(pid, ports) {
1140 ports[pid].dev_conf.link_speeds = link_speed;
1143 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1146 cmdline_parse_token_string_t cmd_config_speed_all_port =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1148 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1151 cmdline_parse_token_string_t cmd_config_speed_all_all =
1152 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1153 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1154 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1155 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1156 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1157 "10#100#1000#10000#25000#40000#50000#100000#auto");
1158 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1159 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1160 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1161 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1164 cmdline_parse_inst_t cmd_config_speed_all = {
1165 .f = cmd_config_speed_all_parsed,
1167 .help_str = "port config all speed "
1168 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1171 (void *)&cmd_config_speed_all_port,
1172 (void *)&cmd_config_speed_all_keyword,
1173 (void *)&cmd_config_speed_all_all,
1174 (void *)&cmd_config_speed_all_item1,
1175 (void *)&cmd_config_speed_all_value1,
1176 (void *)&cmd_config_speed_all_item2,
1177 (void *)&cmd_config_speed_all_value2,
1182 /* *** configure speed for specific port *** */
1183 struct cmd_config_speed_specific {
1184 cmdline_fixed_string_t port;
1185 cmdline_fixed_string_t keyword;
1187 cmdline_fixed_string_t item1;
1188 cmdline_fixed_string_t item2;
1189 cmdline_fixed_string_t value1;
1190 cmdline_fixed_string_t value2;
1194 cmd_config_speed_specific_parsed(void *parsed_result,
1195 __attribute__((unused)) struct cmdline *cl,
1196 __attribute__((unused)) void *data)
1198 struct cmd_config_speed_specific *res = parsed_result;
1199 uint32_t link_speed;
1201 if (!all_ports_stopped()) {
1202 printf("Please stop all ports first\n");
1206 if (port_id_is_invalid(res->id, ENABLED_WARN))
1209 if (parse_and_check_speed_duplex(res->value1, res->value2,
1213 ports[res->id].dev_conf.link_speeds = link_speed;
1215 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1219 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1220 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1222 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1223 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1225 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1226 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1227 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1228 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1230 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1231 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1232 "10#100#1000#10000#25000#40000#50000#100000#auto");
1233 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1234 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1236 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1237 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1240 cmdline_parse_inst_t cmd_config_speed_specific = {
1241 .f = cmd_config_speed_specific_parsed,
1243 .help_str = "port config <port_id> speed "
1244 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1247 (void *)&cmd_config_speed_specific_port,
1248 (void *)&cmd_config_speed_specific_keyword,
1249 (void *)&cmd_config_speed_specific_id,
1250 (void *)&cmd_config_speed_specific_item1,
1251 (void *)&cmd_config_speed_specific_value1,
1252 (void *)&cmd_config_speed_specific_item2,
1253 (void *)&cmd_config_speed_specific_value2,
1258 /* *** configure txq/rxq, txd/rxd *** */
1259 struct cmd_config_rx_tx {
1260 cmdline_fixed_string_t port;
1261 cmdline_fixed_string_t keyword;
1262 cmdline_fixed_string_t all;
1263 cmdline_fixed_string_t name;
1268 cmd_config_rx_tx_parsed(void *parsed_result,
1269 __attribute__((unused)) struct cmdline *cl,
1270 __attribute__((unused)) void *data)
1272 struct cmd_config_rx_tx *res = parsed_result;
1274 if (!all_ports_stopped()) {
1275 printf("Please stop all ports first\n");
1278 if (!strcmp(res->name, "rxq")) {
1279 if (!res->value && !nb_txq) {
1280 printf("Warning: Either rx or tx queues should be non zero\n");
1283 nb_rxq = res->value;
1285 else if (!strcmp(res->name, "txq")) {
1286 if (!res->value && !nb_rxq) {
1287 printf("Warning: Either rx or tx queues should be non zero\n");
1290 nb_txq = res->value;
1292 else if (!strcmp(res->name, "rxd")) {
1293 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1294 printf("rxd %d invalid - must be > 0 && <= %d\n",
1295 res->value, RTE_TEST_RX_DESC_MAX);
1298 nb_rxd = res->value;
1299 } else if (!strcmp(res->name, "txd")) {
1300 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1301 printf("txd %d invalid - must be > 0 && <= %d\n",
1302 res->value, RTE_TEST_TX_DESC_MAX);
1305 nb_txd = res->value;
1307 printf("Unknown parameter\n");
1315 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1318 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1319 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1320 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1321 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1322 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1323 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1324 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1325 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1327 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1328 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1330 cmdline_parse_inst_t cmd_config_rx_tx = {
1331 .f = cmd_config_rx_tx_parsed,
1333 .help_str = "port config all rxq|txq|rxd|txd <value>",
1335 (void *)&cmd_config_rx_tx_port,
1336 (void *)&cmd_config_rx_tx_keyword,
1337 (void *)&cmd_config_rx_tx_all,
1338 (void *)&cmd_config_rx_tx_name,
1339 (void *)&cmd_config_rx_tx_value,
1344 /* *** config max packet length *** */
1345 struct cmd_config_max_pkt_len_result {
1346 cmdline_fixed_string_t port;
1347 cmdline_fixed_string_t keyword;
1348 cmdline_fixed_string_t all;
1349 cmdline_fixed_string_t name;
1354 cmd_config_max_pkt_len_parsed(void *parsed_result,
1355 __attribute__((unused)) struct cmdline *cl,
1356 __attribute__((unused)) void *data)
1358 struct cmd_config_max_pkt_len_result *res = parsed_result;
1360 if (!all_ports_stopped()) {
1361 printf("Please stop all ports first\n");
1365 if (!strcmp(res->name, "max-pkt-len")) {
1366 if (res->value < ETHER_MIN_LEN) {
1367 printf("max-pkt-len can not be less than %d\n",
1371 if (res->value == rx_mode.max_rx_pkt_len)
1374 rx_mode.max_rx_pkt_len = res->value;
1375 if (res->value > ETHER_MAX_LEN)
1376 rx_mode.jumbo_frame = 1;
1378 rx_mode.jumbo_frame = 0;
1380 printf("Unknown parameter\n");
1386 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1389 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1392 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1393 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1395 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1398 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1401 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1402 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1405 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1406 .f = cmd_config_max_pkt_len_parsed,
1408 .help_str = "port config all max-pkt-len <value>",
1410 (void *)&cmd_config_max_pkt_len_port,
1411 (void *)&cmd_config_max_pkt_len_keyword,
1412 (void *)&cmd_config_max_pkt_len_all,
1413 (void *)&cmd_config_max_pkt_len_name,
1414 (void *)&cmd_config_max_pkt_len_value,
1419 /* *** configure port MTU *** */
1420 struct cmd_config_mtu_result {
1421 cmdline_fixed_string_t port;
1422 cmdline_fixed_string_t keyword;
1423 cmdline_fixed_string_t mtu;
1429 cmd_config_mtu_parsed(void *parsed_result,
1430 __attribute__((unused)) struct cmdline *cl,
1431 __attribute__((unused)) void *data)
1433 struct cmd_config_mtu_result *res = parsed_result;
1435 if (res->value < ETHER_MIN_LEN) {
1436 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1439 port_mtu_set(res->port_id, res->value);
1442 cmdline_parse_token_string_t cmd_config_mtu_port =
1443 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1445 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1446 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1448 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1449 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1451 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1452 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1453 cmdline_parse_token_num_t cmd_config_mtu_value =
1454 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1456 cmdline_parse_inst_t cmd_config_mtu = {
1457 .f = cmd_config_mtu_parsed,
1459 .help_str = "port config mtu <port_id> <value>",
1461 (void *)&cmd_config_mtu_port,
1462 (void *)&cmd_config_mtu_keyword,
1463 (void *)&cmd_config_mtu_mtu,
1464 (void *)&cmd_config_mtu_port_id,
1465 (void *)&cmd_config_mtu_value,
1470 /* *** configure rx mode *** */
1471 struct cmd_config_rx_mode_flag {
1472 cmdline_fixed_string_t port;
1473 cmdline_fixed_string_t keyword;
1474 cmdline_fixed_string_t all;
1475 cmdline_fixed_string_t name;
1476 cmdline_fixed_string_t value;
1480 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1481 __attribute__((unused)) struct cmdline *cl,
1482 __attribute__((unused)) void *data)
1484 struct cmd_config_rx_mode_flag *res = parsed_result;
1486 if (!all_ports_stopped()) {
1487 printf("Please stop all ports first\n");
1491 if (!strcmp(res->name, "crc-strip")) {
1492 if (!strcmp(res->value, "on"))
1493 rx_mode.hw_strip_crc = 1;
1494 else if (!strcmp(res->value, "off"))
1495 rx_mode.hw_strip_crc = 0;
1497 printf("Unknown parameter\n");
1500 } else if (!strcmp(res->name, "scatter")) {
1501 if (!strcmp(res->value, "on"))
1502 rx_mode.enable_scatter = 1;
1503 else if (!strcmp(res->value, "off"))
1504 rx_mode.enable_scatter = 0;
1506 printf("Unknown parameter\n");
1509 } else if (!strcmp(res->name, "rx-cksum")) {
1510 if (!strcmp(res->value, "on"))
1511 rx_mode.hw_ip_checksum = 1;
1512 else if (!strcmp(res->value, "off"))
1513 rx_mode.hw_ip_checksum = 0;
1515 printf("Unknown parameter\n");
1518 } else if (!strcmp(res->name, "hw-vlan")) {
1519 if (!strcmp(res->value, "on")) {
1520 rx_mode.hw_vlan_filter = 1;
1521 rx_mode.hw_vlan_strip = 1;
1523 else if (!strcmp(res->value, "off")) {
1524 rx_mode.hw_vlan_filter = 0;
1525 rx_mode.hw_vlan_strip = 0;
1528 printf("Unknown parameter\n");
1531 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1532 if (!strcmp(res->value, "on"))
1533 rx_mode.hw_vlan_filter = 1;
1534 else if (!strcmp(res->value, "off"))
1535 rx_mode.hw_vlan_filter = 0;
1537 printf("Unknown parameter\n");
1540 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1541 if (!strcmp(res->value, "on"))
1542 rx_mode.hw_vlan_strip = 1;
1543 else if (!strcmp(res->value, "off"))
1544 rx_mode.hw_vlan_strip = 0;
1546 printf("Unknown parameter\n");
1549 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1550 if (!strcmp(res->value, "on"))
1551 rx_mode.hw_vlan_extend = 1;
1552 else if (!strcmp(res->value, "off"))
1553 rx_mode.hw_vlan_extend = 0;
1555 printf("Unknown parameter\n");
1558 } else if (!strcmp(res->name, "drop-en")) {
1559 if (!strcmp(res->value, "on"))
1561 else if (!strcmp(res->value, "off"))
1564 printf("Unknown parameter\n");
1568 printf("Unknown parameter\n");
1574 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1577 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1579 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1582 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1584 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1585 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1586 "crc-strip#scatter#rx-cksum#hw-vlan#"
1587 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1588 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1589 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1592 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1593 .f = cmd_config_rx_mode_flag_parsed,
1595 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1596 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1598 (void *)&cmd_config_rx_mode_flag_port,
1599 (void *)&cmd_config_rx_mode_flag_keyword,
1600 (void *)&cmd_config_rx_mode_flag_all,
1601 (void *)&cmd_config_rx_mode_flag_name,
1602 (void *)&cmd_config_rx_mode_flag_value,
1607 /* *** configure rss *** */
1608 struct cmd_config_rss {
1609 cmdline_fixed_string_t port;
1610 cmdline_fixed_string_t keyword;
1611 cmdline_fixed_string_t all;
1612 cmdline_fixed_string_t name;
1613 cmdline_fixed_string_t value;
1617 cmd_config_rss_parsed(void *parsed_result,
1618 __attribute__((unused)) struct cmdline *cl,
1619 __attribute__((unused)) void *data)
1621 struct cmd_config_rss *res = parsed_result;
1622 struct rte_eth_rss_conf rss_conf;
1626 if (!strcmp(res->value, "all"))
1627 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1628 ETH_RSS_UDP | ETH_RSS_SCTP |
1630 else if (!strcmp(res->value, "ip"))
1631 rss_conf.rss_hf = ETH_RSS_IP;
1632 else if (!strcmp(res->value, "udp"))
1633 rss_conf.rss_hf = ETH_RSS_UDP;
1634 else if (!strcmp(res->value, "tcp"))
1635 rss_conf.rss_hf = ETH_RSS_TCP;
1636 else if (!strcmp(res->value, "sctp"))
1637 rss_conf.rss_hf = ETH_RSS_SCTP;
1638 else if (!strcmp(res->value, "ether"))
1639 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1640 else if (!strcmp(res->value, "port"))
1641 rss_conf.rss_hf = ETH_RSS_PORT;
1642 else if (!strcmp(res->value, "vxlan"))
1643 rss_conf.rss_hf = ETH_RSS_VXLAN;
1644 else if (!strcmp(res->value, "geneve"))
1645 rss_conf.rss_hf = ETH_RSS_GENEVE;
1646 else if (!strcmp(res->value, "nvgre"))
1647 rss_conf.rss_hf = ETH_RSS_NVGRE;
1648 else if (!strcmp(res->value, "none"))
1649 rss_conf.rss_hf = 0;
1651 printf("Unknown parameter\n");
1654 rss_conf.rss_key = NULL;
1655 for (i = 0; i < rte_eth_dev_count(); i++) {
1656 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1658 printf("Configuration of RSS hash at ethernet port %d "
1659 "failed with error (%d): %s.\n",
1660 i, -diag, strerror(-diag));
1664 cmdline_parse_token_string_t cmd_config_rss_port =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1666 cmdline_parse_token_string_t cmd_config_rss_keyword =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1668 cmdline_parse_token_string_t cmd_config_rss_all =
1669 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1670 cmdline_parse_token_string_t cmd_config_rss_name =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1672 cmdline_parse_token_string_t cmd_config_rss_value =
1673 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1674 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1676 cmdline_parse_inst_t cmd_config_rss = {
1677 .f = cmd_config_rss_parsed,
1679 .help_str = "port config all rss "
1680 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1682 (void *)&cmd_config_rss_port,
1683 (void *)&cmd_config_rss_keyword,
1684 (void *)&cmd_config_rss_all,
1685 (void *)&cmd_config_rss_name,
1686 (void *)&cmd_config_rss_value,
1691 /* *** configure rss hash key *** */
1692 struct cmd_config_rss_hash_key {
1693 cmdline_fixed_string_t port;
1694 cmdline_fixed_string_t config;
1696 cmdline_fixed_string_t rss_hash_key;
1697 cmdline_fixed_string_t rss_type;
1698 cmdline_fixed_string_t key;
1702 hexa_digit_to_value(char hexa_digit)
1704 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1705 return (uint8_t) (hexa_digit - '0');
1706 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1707 return (uint8_t) ((hexa_digit - 'a') + 10);
1708 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1709 return (uint8_t) ((hexa_digit - 'A') + 10);
1710 /* Invalid hexa digit */
1715 parse_and_check_key_hexa_digit(char *key, int idx)
1719 hexa_v = hexa_digit_to_value(key[idx]);
1721 printf("invalid key: character %c at position %d is not a "
1722 "valid hexa digit\n", key[idx], idx);
1727 cmd_config_rss_hash_key_parsed(void *parsed_result,
1728 __attribute__((unused)) struct cmdline *cl,
1729 __attribute__((unused)) void *data)
1731 struct cmd_config_rss_hash_key *res = parsed_result;
1732 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1736 struct rte_eth_dev_info dev_info;
1737 uint8_t hash_key_size;
1740 memset(&dev_info, 0, sizeof(dev_info));
1741 rte_eth_dev_info_get(res->port_id, &dev_info);
1742 if (dev_info.hash_key_size > 0 &&
1743 dev_info.hash_key_size <= sizeof(hash_key))
1744 hash_key_size = dev_info.hash_key_size;
1746 printf("dev_info did not provide a valid hash key size\n");
1749 /* Check the length of the RSS hash key */
1750 key_len = strlen(res->key);
1751 if (key_len != (hash_key_size * 2)) {
1752 printf("key length: %d invalid - key must be a string of %d"
1753 " hexa-decimal numbers\n",
1754 (int) key_len, hash_key_size * 2);
1757 /* Translate RSS hash key into binary representation */
1758 for (i = 0; i < hash_key_size; i++) {
1759 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1762 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1765 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1767 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1771 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1772 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1773 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1774 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1776 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1777 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1778 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1779 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1780 rss_hash_key, "rss-hash-key");
1781 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1783 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1784 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1785 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1786 "ipv6-tcp-ex#ipv6-udp-ex");
1787 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1790 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1791 .f = cmd_config_rss_hash_key_parsed,
1793 .help_str = "port config <port_id> rss-hash-key "
1794 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1795 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1796 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1797 "<string of hex digits (variable length, NIC dependent)>",
1799 (void *)&cmd_config_rss_hash_key_port,
1800 (void *)&cmd_config_rss_hash_key_config,
1801 (void *)&cmd_config_rss_hash_key_port_id,
1802 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1803 (void *)&cmd_config_rss_hash_key_rss_type,
1804 (void *)&cmd_config_rss_hash_key_value,
1809 /* *** configure port rxq/txq start/stop *** */
1810 struct cmd_config_rxtx_queue {
1811 cmdline_fixed_string_t port;
1813 cmdline_fixed_string_t rxtxq;
1815 cmdline_fixed_string_t opname;
1819 cmd_config_rxtx_queue_parsed(void *parsed_result,
1820 __attribute__((unused)) struct cmdline *cl,
1821 __attribute__((unused)) void *data)
1823 struct cmd_config_rxtx_queue *res = parsed_result;
1828 if (test_done == 0) {
1829 printf("Please stop forwarding first\n");
1833 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1836 if (port_is_started(res->portid) != 1) {
1837 printf("Please start port %u first\n", res->portid);
1841 if (!strcmp(res->rxtxq, "rxq"))
1843 else if (!strcmp(res->rxtxq, "txq"))
1846 printf("Unknown parameter\n");
1850 if (isrx && rx_queue_id_is_invalid(res->qid))
1852 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1855 if (!strcmp(res->opname, "start"))
1857 else if (!strcmp(res->opname, "stop"))
1860 printf("Unknown parameter\n");
1864 if (isstart && isrx)
1865 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1866 else if (!isstart && isrx)
1867 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1868 else if (isstart && !isrx)
1869 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1871 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1873 if (ret == -ENOTSUP)
1874 printf("Function not supported in PMD driver\n");
1877 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1878 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1879 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1880 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1881 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1882 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1883 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1884 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1885 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1886 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1889 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1890 .f = cmd_config_rxtx_queue_parsed,
1892 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1894 (void *)&cmd_config_speed_all_port,
1895 (void *)&cmd_config_rxtx_queue_portid,
1896 (void *)&cmd_config_rxtx_queue_rxtxq,
1897 (void *)&cmd_config_rxtx_queue_qid,
1898 (void *)&cmd_config_rxtx_queue_opname,
1903 /* *** Configure RSS RETA *** */
1904 struct cmd_config_rss_reta {
1905 cmdline_fixed_string_t port;
1906 cmdline_fixed_string_t keyword;
1908 cmdline_fixed_string_t name;
1909 cmdline_fixed_string_t list_name;
1910 cmdline_fixed_string_t list_of_items;
1914 parse_reta_config(const char *str,
1915 struct rte_eth_rss_reta_entry64 *reta_conf,
1916 uint16_t nb_entries)
1920 uint16_t hash_index, idx, shift;
1923 const char *p, *p0 = str;
1930 unsigned long int_fld[_NUM_FLD];
1931 char *str_fld[_NUM_FLD];
1933 while ((p = strchr(p0,'(')) != NULL) {
1935 if((p0 = strchr(p,')')) == NULL)
1939 if(size >= sizeof(s))
1942 snprintf(s, sizeof(s), "%.*s", size, p);
1943 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1945 for (i = 0; i < _NUM_FLD; i++) {
1947 int_fld[i] = strtoul(str_fld[i], &end, 0);
1948 if (errno != 0 || end == str_fld[i] ||
1953 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1954 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1956 if (hash_index >= nb_entries) {
1957 printf("Invalid RETA hash index=%d\n", hash_index);
1961 idx = hash_index / RTE_RETA_GROUP_SIZE;
1962 shift = hash_index % RTE_RETA_GROUP_SIZE;
1963 reta_conf[idx].mask |= (1ULL << shift);
1964 reta_conf[idx].reta[shift] = nb_queue;
1971 cmd_set_rss_reta_parsed(void *parsed_result,
1972 __attribute__((unused)) struct cmdline *cl,
1973 __attribute__((unused)) void *data)
1976 struct rte_eth_dev_info dev_info;
1977 struct rte_eth_rss_reta_entry64 reta_conf[8];
1978 struct cmd_config_rss_reta *res = parsed_result;
1980 memset(&dev_info, 0, sizeof(dev_info));
1981 rte_eth_dev_info_get(res->port_id, &dev_info);
1982 if (dev_info.reta_size == 0) {
1983 printf("Redirection table size is 0 which is "
1984 "invalid for RSS\n");
1987 printf("The reta size of port %d is %u\n",
1988 res->port_id, dev_info.reta_size);
1989 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1990 printf("Currently do not support more than %u entries of "
1991 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1995 memset(reta_conf, 0, sizeof(reta_conf));
1996 if (!strcmp(res->list_name, "reta")) {
1997 if (parse_reta_config(res->list_of_items, reta_conf,
1998 dev_info.reta_size)) {
1999 printf("Invalid RSS Redirection Table "
2000 "config entered\n");
2003 ret = rte_eth_dev_rss_reta_update(res->port_id,
2004 reta_conf, dev_info.reta_size);
2006 printf("Bad redirection table parameter, "
2007 "return code = %d \n", ret);
2011 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2012 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2013 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2015 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2016 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2017 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2018 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2019 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2021 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2022 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2024 cmdline_parse_inst_t cmd_config_rss_reta = {
2025 .f = cmd_set_rss_reta_parsed,
2027 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2029 (void *)&cmd_config_rss_reta_port,
2030 (void *)&cmd_config_rss_reta_keyword,
2031 (void *)&cmd_config_rss_reta_port_id,
2032 (void *)&cmd_config_rss_reta_name,
2033 (void *)&cmd_config_rss_reta_list_name,
2034 (void *)&cmd_config_rss_reta_list_of_items,
2039 /* *** SHOW PORT RETA INFO *** */
2040 struct cmd_showport_reta {
2041 cmdline_fixed_string_t show;
2042 cmdline_fixed_string_t port;
2044 cmdline_fixed_string_t rss;
2045 cmdline_fixed_string_t reta;
2047 cmdline_fixed_string_t list_of_items;
2051 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2052 uint16_t nb_entries,
2056 const char *p, *p0 = str;
2060 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2063 p = strchr(p0, '(');
2067 p0 = strchr(p, ')');
2071 if (size >= sizeof(s)) {
2072 printf("The string size exceeds the internal buffer size\n");
2075 snprintf(s, sizeof(s), "%.*s", size, p);
2076 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2077 if (ret <= 0 || ret != num) {
2078 printf("The bits of masks do not match the number of "
2079 "reta entries: %u\n", num);
2082 for (i = 0; i < ret; i++)
2083 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2089 cmd_showport_reta_parsed(void *parsed_result,
2090 __attribute__((unused)) struct cmdline *cl,
2091 __attribute__((unused)) void *data)
2093 struct cmd_showport_reta *res = parsed_result;
2094 struct rte_eth_rss_reta_entry64 reta_conf[8];
2095 struct rte_eth_dev_info dev_info;
2097 memset(&dev_info, 0, sizeof(dev_info));
2098 rte_eth_dev_info_get(res->port_id, &dev_info);
2099 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2100 res->size > ETH_RSS_RETA_SIZE_512) {
2101 printf("Invalid redirection table size: %u\n", res->size);
2105 memset(reta_conf, 0, sizeof(reta_conf));
2106 if (showport_parse_reta_config(reta_conf, res->size,
2107 res->list_of_items) < 0) {
2108 printf("Invalid string: %s for reta masks\n",
2109 res->list_of_items);
2112 port_rss_reta_info(res->port_id, reta_conf, res->size);
2115 cmdline_parse_token_string_t cmd_showport_reta_show =
2116 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2117 cmdline_parse_token_string_t cmd_showport_reta_port =
2118 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2119 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2120 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2121 cmdline_parse_token_string_t cmd_showport_reta_rss =
2122 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2123 cmdline_parse_token_string_t cmd_showport_reta_reta =
2124 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2125 cmdline_parse_token_num_t cmd_showport_reta_size =
2126 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2127 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2128 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2129 list_of_items, NULL);
2131 cmdline_parse_inst_t cmd_showport_reta = {
2132 .f = cmd_showport_reta_parsed,
2134 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2136 (void *)&cmd_showport_reta_show,
2137 (void *)&cmd_showport_reta_port,
2138 (void *)&cmd_showport_reta_port_id,
2139 (void *)&cmd_showport_reta_rss,
2140 (void *)&cmd_showport_reta_reta,
2141 (void *)&cmd_showport_reta_size,
2142 (void *)&cmd_showport_reta_list_of_items,
2147 /* *** Show RSS hash configuration *** */
2148 struct cmd_showport_rss_hash {
2149 cmdline_fixed_string_t show;
2150 cmdline_fixed_string_t port;
2152 cmdline_fixed_string_t rss_hash;
2153 cmdline_fixed_string_t rss_type;
2154 cmdline_fixed_string_t key; /* optional argument */
2157 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2158 __attribute__((unused)) struct cmdline *cl,
2161 struct cmd_showport_rss_hash *res = parsed_result;
2163 port_rss_hash_conf_show(res->port_id, res->rss_type,
2164 show_rss_key != NULL);
2167 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2168 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2169 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2170 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2171 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2172 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2173 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2174 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2176 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2177 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2178 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2179 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2180 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2181 "ipv6-tcp-ex#ipv6-udp-ex");
2182 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2183 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2185 cmdline_parse_inst_t cmd_showport_rss_hash = {
2186 .f = cmd_showport_rss_hash_parsed,
2188 .help_str = "show port <port_id> rss-hash "
2189 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2190 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2191 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2193 (void *)&cmd_showport_rss_hash_show,
2194 (void *)&cmd_showport_rss_hash_port,
2195 (void *)&cmd_showport_rss_hash_port_id,
2196 (void *)&cmd_showport_rss_hash_rss_hash,
2197 (void *)&cmd_showport_rss_hash_rss_hash_info,
2202 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2203 .f = cmd_showport_rss_hash_parsed,
2205 .help_str = "show port <port_id> rss-hash "
2206 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2207 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2208 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2210 (void *)&cmd_showport_rss_hash_show,
2211 (void *)&cmd_showport_rss_hash_port,
2212 (void *)&cmd_showport_rss_hash_port_id,
2213 (void *)&cmd_showport_rss_hash_rss_hash,
2214 (void *)&cmd_showport_rss_hash_rss_hash_info,
2215 (void *)&cmd_showport_rss_hash_rss_key,
2220 /* *** Configure DCB *** */
2221 struct cmd_config_dcb {
2222 cmdline_fixed_string_t port;
2223 cmdline_fixed_string_t config;
2225 cmdline_fixed_string_t dcb;
2226 cmdline_fixed_string_t vt;
2227 cmdline_fixed_string_t vt_en;
2229 cmdline_fixed_string_t pfc;
2230 cmdline_fixed_string_t pfc_en;
2234 cmd_config_dcb_parsed(void *parsed_result,
2235 __attribute__((unused)) struct cmdline *cl,
2236 __attribute__((unused)) void *data)
2238 struct cmd_config_dcb *res = parsed_result;
2239 portid_t port_id = res->port_id;
2240 struct rte_port *port;
2244 port = &ports[port_id];
2245 /** Check if the port is not started **/
2246 if (port->port_status != RTE_PORT_STOPPED) {
2247 printf("Please stop port %d first\n", port_id);
2251 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2252 printf("The invalid number of traffic class,"
2253 " only 4 or 8 allowed.\n");
2257 if (nb_fwd_lcores < res->num_tcs) {
2258 printf("nb_cores shouldn't be less than number of TCs.\n");
2261 if (!strncmp(res->pfc_en, "on", 2))
2266 /* DCB in VT mode */
2267 if (!strncmp(res->vt_en, "on", 2))
2268 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2269 (enum rte_eth_nb_tcs)res->num_tcs,
2272 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2273 (enum rte_eth_nb_tcs)res->num_tcs,
2278 printf("Cannot initialize network ports.\n");
2282 cmd_reconfig_device_queue(port_id, 1, 1);
2285 cmdline_parse_token_string_t cmd_config_dcb_port =
2286 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2287 cmdline_parse_token_string_t cmd_config_dcb_config =
2288 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2289 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2290 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2291 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2292 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2293 cmdline_parse_token_string_t cmd_config_dcb_vt =
2294 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2295 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2296 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2297 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2298 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2299 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2300 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2301 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2302 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2304 cmdline_parse_inst_t cmd_config_dcb = {
2305 .f = cmd_config_dcb_parsed,
2307 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2309 (void *)&cmd_config_dcb_port,
2310 (void *)&cmd_config_dcb_config,
2311 (void *)&cmd_config_dcb_port_id,
2312 (void *)&cmd_config_dcb_dcb,
2313 (void *)&cmd_config_dcb_vt,
2314 (void *)&cmd_config_dcb_vt_en,
2315 (void *)&cmd_config_dcb_num_tcs,
2316 (void *)&cmd_config_dcb_pfc,
2317 (void *)&cmd_config_dcb_pfc_en,
2322 /* *** configure number of packets per burst *** */
2323 struct cmd_config_burst {
2324 cmdline_fixed_string_t port;
2325 cmdline_fixed_string_t keyword;
2326 cmdline_fixed_string_t all;
2327 cmdline_fixed_string_t name;
2332 cmd_config_burst_parsed(void *parsed_result,
2333 __attribute__((unused)) struct cmdline *cl,
2334 __attribute__((unused)) void *data)
2336 struct cmd_config_burst *res = parsed_result;
2338 if (!all_ports_stopped()) {
2339 printf("Please stop all ports first\n");
2343 if (!strcmp(res->name, "burst")) {
2344 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2345 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2348 nb_pkt_per_burst = res->value;
2350 printf("Unknown parameter\n");
2356 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2359 cmdline_parse_token_string_t cmd_config_burst_port =
2360 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2361 cmdline_parse_token_string_t cmd_config_burst_keyword =
2362 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2363 cmdline_parse_token_string_t cmd_config_burst_all =
2364 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2365 cmdline_parse_token_string_t cmd_config_burst_name =
2366 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2367 cmdline_parse_token_num_t cmd_config_burst_value =
2368 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2370 cmdline_parse_inst_t cmd_config_burst = {
2371 .f = cmd_config_burst_parsed,
2373 .help_str = "port config all burst <value>",
2375 (void *)&cmd_config_burst_port,
2376 (void *)&cmd_config_burst_keyword,
2377 (void *)&cmd_config_burst_all,
2378 (void *)&cmd_config_burst_name,
2379 (void *)&cmd_config_burst_value,
2384 /* *** configure rx/tx queues *** */
2385 struct cmd_config_thresh {
2386 cmdline_fixed_string_t port;
2387 cmdline_fixed_string_t keyword;
2388 cmdline_fixed_string_t all;
2389 cmdline_fixed_string_t name;
2394 cmd_config_thresh_parsed(void *parsed_result,
2395 __attribute__((unused)) struct cmdline *cl,
2396 __attribute__((unused)) void *data)
2398 struct cmd_config_thresh *res = parsed_result;
2400 if (!all_ports_stopped()) {
2401 printf("Please stop all ports first\n");
2405 if (!strcmp(res->name, "txpt"))
2406 tx_pthresh = res->value;
2407 else if(!strcmp(res->name, "txht"))
2408 tx_hthresh = res->value;
2409 else if(!strcmp(res->name, "txwt"))
2410 tx_wthresh = res->value;
2411 else if(!strcmp(res->name, "rxpt"))
2412 rx_pthresh = res->value;
2413 else if(!strcmp(res->name, "rxht"))
2414 rx_hthresh = res->value;
2415 else if(!strcmp(res->name, "rxwt"))
2416 rx_wthresh = res->value;
2418 printf("Unknown parameter\n");
2424 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2427 cmdline_parse_token_string_t cmd_config_thresh_port =
2428 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2429 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2430 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2431 cmdline_parse_token_string_t cmd_config_thresh_all =
2432 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2433 cmdline_parse_token_string_t cmd_config_thresh_name =
2434 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2435 "txpt#txht#txwt#rxpt#rxht#rxwt");
2436 cmdline_parse_token_num_t cmd_config_thresh_value =
2437 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2439 cmdline_parse_inst_t cmd_config_thresh = {
2440 .f = cmd_config_thresh_parsed,
2442 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2444 (void *)&cmd_config_thresh_port,
2445 (void *)&cmd_config_thresh_keyword,
2446 (void *)&cmd_config_thresh_all,
2447 (void *)&cmd_config_thresh_name,
2448 (void *)&cmd_config_thresh_value,
2453 /* *** configure free/rs threshold *** */
2454 struct cmd_config_threshold {
2455 cmdline_fixed_string_t port;
2456 cmdline_fixed_string_t keyword;
2457 cmdline_fixed_string_t all;
2458 cmdline_fixed_string_t name;
2463 cmd_config_threshold_parsed(void *parsed_result,
2464 __attribute__((unused)) struct cmdline *cl,
2465 __attribute__((unused)) void *data)
2467 struct cmd_config_threshold *res = parsed_result;
2469 if (!all_ports_stopped()) {
2470 printf("Please stop all ports first\n");
2474 if (!strcmp(res->name, "txfreet"))
2475 tx_free_thresh = res->value;
2476 else if (!strcmp(res->name, "txrst"))
2477 tx_rs_thresh = res->value;
2478 else if (!strcmp(res->name, "rxfreet"))
2479 rx_free_thresh = res->value;
2481 printf("Unknown parameter\n");
2487 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2490 cmdline_parse_token_string_t cmd_config_threshold_port =
2491 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2492 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2493 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2495 cmdline_parse_token_string_t cmd_config_threshold_all =
2496 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2497 cmdline_parse_token_string_t cmd_config_threshold_name =
2498 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2499 "txfreet#txrst#rxfreet");
2500 cmdline_parse_token_num_t cmd_config_threshold_value =
2501 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2503 cmdline_parse_inst_t cmd_config_threshold = {
2504 .f = cmd_config_threshold_parsed,
2506 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2508 (void *)&cmd_config_threshold_port,
2509 (void *)&cmd_config_threshold_keyword,
2510 (void *)&cmd_config_threshold_all,
2511 (void *)&cmd_config_threshold_name,
2512 (void *)&cmd_config_threshold_value,
2518 struct cmd_stop_result {
2519 cmdline_fixed_string_t stop;
2522 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2523 __attribute__((unused)) struct cmdline *cl,
2524 __attribute__((unused)) void *data)
2526 stop_packet_forwarding();
2529 cmdline_parse_token_string_t cmd_stop_stop =
2530 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2532 cmdline_parse_inst_t cmd_stop = {
2533 .f = cmd_stop_parsed,
2535 .help_str = "stop: Stop packet forwarding",
2537 (void *)&cmd_stop_stop,
2542 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2545 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2546 unsigned int *parsed_items, int check_unique_values)
2548 unsigned int nb_item;
2556 * First parse all items in the list and store their value.
2561 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2563 if ((c >= '0') && (c <= '9')) {
2564 value = (unsigned int) (value * 10 + (c - '0'));
2569 printf("character %c is not a decimal digit\n", c);
2573 printf("No valid value before comma\n");
2576 if (nb_item < max_items) {
2577 parsed_items[nb_item] = value;
2583 if (nb_item >= max_items) {
2584 printf("Number of %s = %u > %u (maximum items)\n",
2585 item_name, nb_item + 1, max_items);
2588 parsed_items[nb_item++] = value;
2589 if (! check_unique_values)
2593 * Then, check that all values in the list are differents.
2594 * No optimization here...
2596 for (i = 0; i < nb_item; i++) {
2597 for (j = i + 1; j < nb_item; j++) {
2598 if (parsed_items[j] == parsed_items[i]) {
2599 printf("duplicated %s %u at index %u and %u\n",
2600 item_name, parsed_items[i], i, j);
2608 struct cmd_set_list_result {
2609 cmdline_fixed_string_t cmd_keyword;
2610 cmdline_fixed_string_t list_name;
2611 cmdline_fixed_string_t list_of_items;
2614 static void cmd_set_list_parsed(void *parsed_result,
2615 __attribute__((unused)) struct cmdline *cl,
2616 __attribute__((unused)) void *data)
2618 struct cmd_set_list_result *res;
2620 unsigned int lcorelist[RTE_MAX_LCORE];
2621 unsigned int portlist[RTE_MAX_ETHPORTS];
2623 unsigned int nb_item;
2625 if (test_done == 0) {
2626 printf("Please stop forwarding first\n");
2630 res = parsed_result;
2631 if (!strcmp(res->list_name, "corelist")) {
2632 nb_item = parse_item_list(res->list_of_items, "core",
2634 parsed_items.lcorelist, 1);
2636 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2641 if (!strcmp(res->list_name, "portlist")) {
2642 nb_item = parse_item_list(res->list_of_items, "port",
2644 parsed_items.portlist, 1);
2646 set_fwd_ports_list(parsed_items.portlist, nb_item);
2652 cmdline_parse_token_string_t cmd_set_list_keyword =
2653 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2655 cmdline_parse_token_string_t cmd_set_list_name =
2656 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2657 "corelist#portlist");
2658 cmdline_parse_token_string_t cmd_set_list_of_items =
2659 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2662 cmdline_parse_inst_t cmd_set_fwd_list = {
2663 .f = cmd_set_list_parsed,
2665 .help_str = "set corelist|portlist <list0[,list1]*>",
2667 (void *)&cmd_set_list_keyword,
2668 (void *)&cmd_set_list_name,
2669 (void *)&cmd_set_list_of_items,
2674 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2676 struct cmd_setmask_result {
2677 cmdline_fixed_string_t set;
2678 cmdline_fixed_string_t mask;
2682 static void cmd_set_mask_parsed(void *parsed_result,
2683 __attribute__((unused)) struct cmdline *cl,
2684 __attribute__((unused)) void *data)
2686 struct cmd_setmask_result *res = parsed_result;
2688 if (test_done == 0) {
2689 printf("Please stop forwarding first\n");
2692 if (!strcmp(res->mask, "coremask")) {
2693 set_fwd_lcores_mask(res->hexavalue);
2695 } else if (!strcmp(res->mask, "portmask")) {
2696 set_fwd_ports_mask(res->hexavalue);
2701 cmdline_parse_token_string_t cmd_setmask_set =
2702 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2703 cmdline_parse_token_string_t cmd_setmask_mask =
2704 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2705 "coremask#portmask");
2706 cmdline_parse_token_num_t cmd_setmask_value =
2707 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2709 cmdline_parse_inst_t cmd_set_fwd_mask = {
2710 .f = cmd_set_mask_parsed,
2712 .help_str = "set coremask|portmask <hexadecimal value>",
2714 (void *)&cmd_setmask_set,
2715 (void *)&cmd_setmask_mask,
2716 (void *)&cmd_setmask_value,
2722 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2724 struct cmd_set_result {
2725 cmdline_fixed_string_t set;
2726 cmdline_fixed_string_t what;
2730 static void cmd_set_parsed(void *parsed_result,
2731 __attribute__((unused)) struct cmdline *cl,
2732 __attribute__((unused)) void *data)
2734 struct cmd_set_result *res = parsed_result;
2735 if (!strcmp(res->what, "nbport")) {
2736 set_fwd_ports_number(res->value);
2738 } else if (!strcmp(res->what, "nbcore")) {
2739 set_fwd_lcores_number(res->value);
2741 } else if (!strcmp(res->what, "burst"))
2742 set_nb_pkt_per_burst(res->value);
2743 else if (!strcmp(res->what, "verbose"))
2744 set_verbose_level(res->value);
2747 cmdline_parse_token_string_t cmd_set_set =
2748 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2749 cmdline_parse_token_string_t cmd_set_what =
2750 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2751 "nbport#nbcore#burst#verbose");
2752 cmdline_parse_token_num_t cmd_set_value =
2753 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2755 cmdline_parse_inst_t cmd_set_numbers = {
2756 .f = cmd_set_parsed,
2758 .help_str = "set nbport|nbcore|burst|verbose <value>",
2760 (void *)&cmd_set_set,
2761 (void *)&cmd_set_what,
2762 (void *)&cmd_set_value,
2767 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2769 struct cmd_set_txpkts_result {
2770 cmdline_fixed_string_t cmd_keyword;
2771 cmdline_fixed_string_t txpkts;
2772 cmdline_fixed_string_t seg_lengths;
2776 cmd_set_txpkts_parsed(void *parsed_result,
2777 __attribute__((unused)) struct cmdline *cl,
2778 __attribute__((unused)) void *data)
2780 struct cmd_set_txpkts_result *res;
2781 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2782 unsigned int nb_segs;
2784 res = parsed_result;
2785 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2786 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2788 set_tx_pkt_segments(seg_lengths, nb_segs);
2791 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2792 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2793 cmd_keyword, "set");
2794 cmdline_parse_token_string_t cmd_set_txpkts_name =
2795 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2797 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2798 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2801 cmdline_parse_inst_t cmd_set_txpkts = {
2802 .f = cmd_set_txpkts_parsed,
2804 .help_str = "set txpkts <len0[,len1]*>",
2806 (void *)&cmd_set_txpkts_keyword,
2807 (void *)&cmd_set_txpkts_name,
2808 (void *)&cmd_set_txpkts_lengths,
2813 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2815 struct cmd_set_txsplit_result {
2816 cmdline_fixed_string_t cmd_keyword;
2817 cmdline_fixed_string_t txsplit;
2818 cmdline_fixed_string_t mode;
2822 cmd_set_txsplit_parsed(void *parsed_result,
2823 __attribute__((unused)) struct cmdline *cl,
2824 __attribute__((unused)) void *data)
2826 struct cmd_set_txsplit_result *res;
2828 res = parsed_result;
2829 set_tx_pkt_split(res->mode);
2832 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2833 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2834 cmd_keyword, "set");
2835 cmdline_parse_token_string_t cmd_set_txsplit_name =
2836 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2837 txsplit, "txsplit");
2838 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2839 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2842 cmdline_parse_inst_t cmd_set_txsplit = {
2843 .f = cmd_set_txsplit_parsed,
2845 .help_str = "set txsplit on|off|rand",
2847 (void *)&cmd_set_txsplit_keyword,
2848 (void *)&cmd_set_txsplit_name,
2849 (void *)&cmd_set_txsplit_mode,
2854 /* *** CONFIG TX QUEUE FLAGS *** */
2856 struct cmd_config_txqflags_result {
2857 cmdline_fixed_string_t port;
2858 cmdline_fixed_string_t config;
2859 cmdline_fixed_string_t all;
2860 cmdline_fixed_string_t what;
2864 static void cmd_config_txqflags_parsed(void *parsed_result,
2865 __attribute__((unused)) struct cmdline *cl,
2866 __attribute__((unused)) void *data)
2868 struct cmd_config_txqflags_result *res = parsed_result;
2870 if (!all_ports_stopped()) {
2871 printf("Please stop all ports first\n");
2875 if (strcmp(res->what, "txqflags")) {
2876 printf("Unknown parameter\n");
2880 if (res->hexvalue >= 0) {
2881 txq_flags = res->hexvalue;
2883 printf("txqflags must be >= 0\n");
2889 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2892 cmdline_parse_token_string_t cmd_config_txqflags_port =
2893 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2895 cmdline_parse_token_string_t cmd_config_txqflags_config =
2896 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2898 cmdline_parse_token_string_t cmd_config_txqflags_all =
2899 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2901 cmdline_parse_token_string_t cmd_config_txqflags_what =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2904 cmdline_parse_token_num_t cmd_config_txqflags_value =
2905 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2908 cmdline_parse_inst_t cmd_config_txqflags = {
2909 .f = cmd_config_txqflags_parsed,
2911 .help_str = "port config all txqflags <value>",
2913 (void *)&cmd_config_txqflags_port,
2914 (void *)&cmd_config_txqflags_config,
2915 (void *)&cmd_config_txqflags_all,
2916 (void *)&cmd_config_txqflags_what,
2917 (void *)&cmd_config_txqflags_value,
2922 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2923 struct cmd_rx_vlan_filter_all_result {
2924 cmdline_fixed_string_t rx_vlan;
2925 cmdline_fixed_string_t what;
2926 cmdline_fixed_string_t all;
2931 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2932 __attribute__((unused)) struct cmdline *cl,
2933 __attribute__((unused)) void *data)
2935 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2937 if (!strcmp(res->what, "add"))
2938 rx_vlan_all_filter_set(res->port_id, 1);
2940 rx_vlan_all_filter_set(res->port_id, 0);
2943 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2944 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2945 rx_vlan, "rx_vlan");
2946 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2947 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2949 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2950 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2952 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2953 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2956 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2957 .f = cmd_rx_vlan_filter_all_parsed,
2959 .help_str = "rx_vlan add|rm all <port_id>: "
2960 "Add/Remove all identifiers to/from the set of VLAN "
2961 "identifiers filtered by a port",
2963 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2964 (void *)&cmd_rx_vlan_filter_all_what,
2965 (void *)&cmd_rx_vlan_filter_all_all,
2966 (void *)&cmd_rx_vlan_filter_all_portid,
2971 /* *** VLAN OFFLOAD SET ON A PORT *** */
2972 struct cmd_vlan_offload_result {
2973 cmdline_fixed_string_t vlan;
2974 cmdline_fixed_string_t set;
2975 cmdline_fixed_string_t vlan_type;
2976 cmdline_fixed_string_t what;
2977 cmdline_fixed_string_t on;
2978 cmdline_fixed_string_t port_id;
2982 cmd_vlan_offload_parsed(void *parsed_result,
2983 __attribute__((unused)) struct cmdline *cl,
2984 __attribute__((unused)) void *data)
2987 struct cmd_vlan_offload_result *res = parsed_result;
2990 portid_t port_id = 0;
2994 len = strnlen(str, STR_TOKEN_SIZE);
2996 /* Get port_id first */
3004 tmp = strtoul(str, NULL, 0);
3005 /* If port_id greater that what portid_t can represent, return */
3006 if(tmp >= RTE_MAX_ETHPORTS)
3008 port_id = (portid_t)tmp;
3010 if (!strcmp(res->on, "on"))
3015 if (!strcmp(res->what, "strip"))
3016 rx_vlan_strip_set(port_id, on);
3017 else if(!strcmp(res->what, "stripq")){
3018 uint16_t queue_id = 0;
3020 /* No queue_id, return */
3022 printf("must specify (port,queue_id)\n");
3025 tmp = strtoul(str + i + 1, NULL, 0);
3026 /* If queue_id greater that what 16-bits can represent, return */
3030 queue_id = (uint16_t)tmp;
3031 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3033 else if (!strcmp(res->what, "filter"))
3034 rx_vlan_filter_set(port_id, on);
3036 vlan_extend_set(port_id, on);
3041 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3042 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3044 cmdline_parse_token_string_t cmd_vlan_offload_set =
3045 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3047 cmdline_parse_token_string_t cmd_vlan_offload_what =
3048 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3049 what, "strip#filter#qinq#stripq");
3050 cmdline_parse_token_string_t cmd_vlan_offload_on =
3051 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3053 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3054 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3057 cmdline_parse_inst_t cmd_vlan_offload = {
3058 .f = cmd_vlan_offload_parsed,
3060 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3061 "<port_id[,queue_id]>: "
3062 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3064 (void *)&cmd_vlan_offload_vlan,
3065 (void *)&cmd_vlan_offload_set,
3066 (void *)&cmd_vlan_offload_what,
3067 (void *)&cmd_vlan_offload_on,
3068 (void *)&cmd_vlan_offload_portid,
3073 /* *** VLAN TPID SET ON A PORT *** */
3074 struct cmd_vlan_tpid_result {
3075 cmdline_fixed_string_t vlan;
3076 cmdline_fixed_string_t set;
3077 cmdline_fixed_string_t vlan_type;
3078 cmdline_fixed_string_t what;
3084 cmd_vlan_tpid_parsed(void *parsed_result,
3085 __attribute__((unused)) struct cmdline *cl,
3086 __attribute__((unused)) void *data)
3088 struct cmd_vlan_tpid_result *res = parsed_result;
3089 enum rte_vlan_type vlan_type;
3091 if (!strcmp(res->vlan_type, "inner"))
3092 vlan_type = ETH_VLAN_TYPE_INNER;
3093 else if (!strcmp(res->vlan_type, "outer"))
3094 vlan_type = ETH_VLAN_TYPE_OUTER;
3096 printf("Unknown vlan type\n");
3099 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3102 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3103 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3105 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3106 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3108 cmdline_parse_token_string_t cmd_vlan_type =
3109 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3110 vlan_type, "inner#outer");
3111 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3112 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3114 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3115 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3117 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3118 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3121 cmdline_parse_inst_t cmd_vlan_tpid = {
3122 .f = cmd_vlan_tpid_parsed,
3124 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3125 "Set the VLAN Ether type",
3127 (void *)&cmd_vlan_tpid_vlan,
3128 (void *)&cmd_vlan_tpid_set,
3129 (void *)&cmd_vlan_type,
3130 (void *)&cmd_vlan_tpid_what,
3131 (void *)&cmd_vlan_tpid_tpid,
3132 (void *)&cmd_vlan_tpid_portid,
3137 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3138 struct cmd_rx_vlan_filter_result {
3139 cmdline_fixed_string_t rx_vlan;
3140 cmdline_fixed_string_t what;
3146 cmd_rx_vlan_filter_parsed(void *parsed_result,
3147 __attribute__((unused)) struct cmdline *cl,
3148 __attribute__((unused)) void *data)
3150 struct cmd_rx_vlan_filter_result *res = parsed_result;
3152 if (!strcmp(res->what, "add"))
3153 rx_vft_set(res->port_id, res->vlan_id, 1);
3155 rx_vft_set(res->port_id, res->vlan_id, 0);
3158 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3159 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3160 rx_vlan, "rx_vlan");
3161 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3162 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3164 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3165 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3167 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3168 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3171 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3172 .f = cmd_rx_vlan_filter_parsed,
3174 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3175 "Add/Remove a VLAN identifier to/from the set of VLAN "
3176 "identifiers filtered by a port",
3178 (void *)&cmd_rx_vlan_filter_rx_vlan,
3179 (void *)&cmd_rx_vlan_filter_what,
3180 (void *)&cmd_rx_vlan_filter_vlanid,
3181 (void *)&cmd_rx_vlan_filter_portid,
3186 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3187 struct cmd_tx_vlan_set_result {
3188 cmdline_fixed_string_t tx_vlan;
3189 cmdline_fixed_string_t set;
3195 cmd_tx_vlan_set_parsed(void *parsed_result,
3196 __attribute__((unused)) struct cmdline *cl,
3197 __attribute__((unused)) void *data)
3199 struct cmd_tx_vlan_set_result *res = parsed_result;
3201 tx_vlan_set(res->port_id, res->vlan_id);
3204 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3205 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3206 tx_vlan, "tx_vlan");
3207 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3208 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3210 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3211 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3213 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3214 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3217 cmdline_parse_inst_t cmd_tx_vlan_set = {
3218 .f = cmd_tx_vlan_set_parsed,
3220 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3221 "Enable hardware insertion of a single VLAN header "
3222 "with a given TAG Identifier in packets sent on a port",
3224 (void *)&cmd_tx_vlan_set_tx_vlan,
3225 (void *)&cmd_tx_vlan_set_set,
3226 (void *)&cmd_tx_vlan_set_portid,
3227 (void *)&cmd_tx_vlan_set_vlanid,
3232 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3233 struct cmd_tx_vlan_set_qinq_result {
3234 cmdline_fixed_string_t tx_vlan;
3235 cmdline_fixed_string_t set;
3238 uint16_t vlan_id_outer;
3242 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3243 __attribute__((unused)) struct cmdline *cl,
3244 __attribute__((unused)) void *data)
3246 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3248 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3251 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3252 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3253 tx_vlan, "tx_vlan");
3254 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3255 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3257 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3258 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3260 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3261 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3263 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3264 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3265 vlan_id_outer, UINT16);
3267 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3268 .f = cmd_tx_vlan_set_qinq_parsed,
3270 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3271 "Enable hardware insertion of double VLAN header "
3272 "with given TAG Identifiers in packets sent on a port",
3274 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3275 (void *)&cmd_tx_vlan_set_qinq_set,
3276 (void *)&cmd_tx_vlan_set_qinq_portid,
3277 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3278 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3283 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3284 struct cmd_tx_vlan_set_pvid_result {
3285 cmdline_fixed_string_t tx_vlan;
3286 cmdline_fixed_string_t set;
3287 cmdline_fixed_string_t pvid;
3290 cmdline_fixed_string_t mode;
3294 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3295 __attribute__((unused)) struct cmdline *cl,
3296 __attribute__((unused)) void *data)
3298 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3300 if (strcmp(res->mode, "on") == 0)
3301 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3303 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3306 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3307 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3308 tx_vlan, "tx_vlan");
3309 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3310 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3312 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3313 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3315 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3316 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3318 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3319 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3321 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3322 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3325 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3326 .f = cmd_tx_vlan_set_pvid_parsed,
3328 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3330 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3331 (void *)&cmd_tx_vlan_set_pvid_set,
3332 (void *)&cmd_tx_vlan_set_pvid_pvid,
3333 (void *)&cmd_tx_vlan_set_pvid_port_id,
3334 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3335 (void *)&cmd_tx_vlan_set_pvid_mode,
3340 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3341 struct cmd_tx_vlan_reset_result {
3342 cmdline_fixed_string_t tx_vlan;
3343 cmdline_fixed_string_t reset;
3348 cmd_tx_vlan_reset_parsed(void *parsed_result,
3349 __attribute__((unused)) struct cmdline *cl,
3350 __attribute__((unused)) void *data)
3352 struct cmd_tx_vlan_reset_result *res = parsed_result;
3354 tx_vlan_reset(res->port_id);
3357 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3358 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3359 tx_vlan, "tx_vlan");
3360 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3361 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3363 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3364 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3367 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3368 .f = cmd_tx_vlan_reset_parsed,
3370 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3371 "VLAN header in packets sent on a port",
3373 (void *)&cmd_tx_vlan_reset_tx_vlan,
3374 (void *)&cmd_tx_vlan_reset_reset,
3375 (void *)&cmd_tx_vlan_reset_portid,
3381 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3382 struct cmd_csum_result {
3383 cmdline_fixed_string_t csum;
3384 cmdline_fixed_string_t mode;
3385 cmdline_fixed_string_t proto;
3386 cmdline_fixed_string_t hwsw;
3391 csum_show(int port_id)
3393 struct rte_eth_dev_info dev_info;
3396 ol_flags = ports[port_id].tx_ol_flags;
3397 printf("Parse tunnel is %s\n",
3398 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3399 printf("IP checksum offload is %s\n",
3400 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3401 printf("UDP checksum offload is %s\n",
3402 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3403 printf("TCP checksum offload is %s\n",
3404 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3405 printf("SCTP checksum offload is %s\n",
3406 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3407 printf("Outer-Ip checksum offload is %s\n",
3408 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3410 /* display warnings if configuration is not supported by the NIC */
3411 rte_eth_dev_info_get(port_id, &dev_info);
3412 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3413 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3414 printf("Warning: hardware IP checksum enabled but not "
3415 "supported by port %d\n", port_id);
3417 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3418 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3419 printf("Warning: hardware UDP checksum enabled but not "
3420 "supported by port %d\n", port_id);
3422 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3423 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3424 printf("Warning: hardware TCP checksum enabled but not "
3425 "supported by port %d\n", port_id);
3427 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3428 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3429 printf("Warning: hardware SCTP checksum enabled but not "
3430 "supported by port %d\n", port_id);
3432 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3433 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3434 printf("Warning: hardware outer IP checksum enabled but not "
3435 "supported by port %d\n", port_id);
3440 cmd_csum_parsed(void *parsed_result,
3441 __attribute__((unused)) struct cmdline *cl,
3442 __attribute__((unused)) void *data)
3444 struct cmd_csum_result *res = parsed_result;
3448 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3449 printf("invalid port %d\n", res->port_id);
3453 if (!strcmp(res->mode, "set")) {
3455 if (!strcmp(res->hwsw, "hw"))
3458 if (!strcmp(res->proto, "ip")) {
3459 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3460 } else if (!strcmp(res->proto, "udp")) {
3461 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3462 } else if (!strcmp(res->proto, "tcp")) {
3463 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3464 } else if (!strcmp(res->proto, "sctp")) {
3465 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3466 } else if (!strcmp(res->proto, "outer-ip")) {
3467 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3471 ports[res->port_id].tx_ol_flags |= mask;
3473 ports[res->port_id].tx_ol_flags &= (~mask);
3475 csum_show(res->port_id);
3478 cmdline_parse_token_string_t cmd_csum_csum =
3479 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3481 cmdline_parse_token_string_t cmd_csum_mode =
3482 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3484 cmdline_parse_token_string_t cmd_csum_proto =
3485 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3486 proto, "ip#tcp#udp#sctp#outer-ip");
3487 cmdline_parse_token_string_t cmd_csum_hwsw =
3488 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3490 cmdline_parse_token_num_t cmd_csum_portid =
3491 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3494 cmdline_parse_inst_t cmd_csum_set = {
3495 .f = cmd_csum_parsed,
3497 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3498 "Enable/Disable hardware calculation of L3/L4 checksum when "
3499 "using csum forward engine",
3501 (void *)&cmd_csum_csum,
3502 (void *)&cmd_csum_mode,
3503 (void *)&cmd_csum_proto,
3504 (void *)&cmd_csum_hwsw,
3505 (void *)&cmd_csum_portid,
3510 cmdline_parse_token_string_t cmd_csum_mode_show =
3511 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3514 cmdline_parse_inst_t cmd_csum_show = {
3515 .f = cmd_csum_parsed,
3517 .help_str = "csum show <port_id>: Show checksum offload configuration",
3519 (void *)&cmd_csum_csum,
3520 (void *)&cmd_csum_mode_show,
3521 (void *)&cmd_csum_portid,
3526 /* Enable/disable tunnel parsing */
3527 struct cmd_csum_tunnel_result {
3528 cmdline_fixed_string_t csum;
3529 cmdline_fixed_string_t parse;
3530 cmdline_fixed_string_t onoff;
3535 cmd_csum_tunnel_parsed(void *parsed_result,
3536 __attribute__((unused)) struct cmdline *cl,
3537 __attribute__((unused)) void *data)
3539 struct cmd_csum_tunnel_result *res = parsed_result;
3541 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3544 if (!strcmp(res->onoff, "on"))
3545 ports[res->port_id].tx_ol_flags |=
3546 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3548 ports[res->port_id].tx_ol_flags &=
3549 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3551 csum_show(res->port_id);
3554 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3555 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3557 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3558 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3559 parse, "parse_tunnel");
3560 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3561 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3563 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3564 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3567 cmdline_parse_inst_t cmd_csum_tunnel = {
3568 .f = cmd_csum_tunnel_parsed,
3570 .help_str = "csum parse_tunnel on|off <port_id>: "
3571 "Enable/Disable parsing of tunnels for csum engine",
3573 (void *)&cmd_csum_tunnel_csum,
3574 (void *)&cmd_csum_tunnel_parse,
3575 (void *)&cmd_csum_tunnel_onoff,
3576 (void *)&cmd_csum_tunnel_portid,
3581 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3582 struct cmd_tso_set_result {
3583 cmdline_fixed_string_t tso;
3584 cmdline_fixed_string_t mode;
3590 cmd_tso_set_parsed(void *parsed_result,
3591 __attribute__((unused)) struct cmdline *cl,
3592 __attribute__((unused)) void *data)
3594 struct cmd_tso_set_result *res = parsed_result;
3595 struct rte_eth_dev_info dev_info;
3597 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3600 if (!strcmp(res->mode, "set"))
3601 ports[res->port_id].tso_segsz = res->tso_segsz;
3603 if (ports[res->port_id].tso_segsz == 0)
3604 printf("TSO for non-tunneled packets is disabled\n");
3606 printf("TSO segment size for non-tunneled packets is %d\n",
3607 ports[res->port_id].tso_segsz);
3609 /* display warnings if configuration is not supported by the NIC */
3610 rte_eth_dev_info_get(res->port_id, &dev_info);
3611 if ((ports[res->port_id].tso_segsz != 0) &&
3612 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3613 printf("Warning: TSO enabled but not "
3614 "supported by port %d\n", res->port_id);
3618 cmdline_parse_token_string_t cmd_tso_set_tso =
3619 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3621 cmdline_parse_token_string_t cmd_tso_set_mode =
3622 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3624 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3625 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3627 cmdline_parse_token_num_t cmd_tso_set_portid =
3628 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3631 cmdline_parse_inst_t cmd_tso_set = {
3632 .f = cmd_tso_set_parsed,
3634 .help_str = "tso set <tso_segsz> <port_id>: "
3635 "Set TSO segment size of non-tunneled packets for csum engine "
3638 (void *)&cmd_tso_set_tso,
3639 (void *)&cmd_tso_set_mode,
3640 (void *)&cmd_tso_set_tso_segsz,
3641 (void *)&cmd_tso_set_portid,
3646 cmdline_parse_token_string_t cmd_tso_show_mode =
3647 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3651 cmdline_parse_inst_t cmd_tso_show = {
3652 .f = cmd_tso_set_parsed,
3654 .help_str = "tso show <port_id>: "
3655 "Show TSO segment size of non-tunneled packets for csum engine",
3657 (void *)&cmd_tso_set_tso,
3658 (void *)&cmd_tso_show_mode,
3659 (void *)&cmd_tso_set_portid,
3664 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3665 struct cmd_tunnel_tso_set_result {
3666 cmdline_fixed_string_t tso;
3667 cmdline_fixed_string_t mode;
3673 check_tunnel_tso_nic_support(uint8_t port_id)
3675 struct rte_eth_dev_info dev_info;
3677 rte_eth_dev_info_get(port_id, &dev_info);
3678 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3679 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3680 "supported by port %d\n", port_id);
3681 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3682 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3683 "supported by port %d\n", port_id);
3684 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3685 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3686 "supported by port %d\n", port_id);
3687 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3688 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3689 "supported by port %d\n", port_id);
3693 cmd_tunnel_tso_set_parsed(void *parsed_result,
3694 __attribute__((unused)) struct cmdline *cl,
3695 __attribute__((unused)) void *data)
3697 struct cmd_tunnel_tso_set_result *res = parsed_result;
3699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3702 if (!strcmp(res->mode, "set"))
3703 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3705 if (ports[res->port_id].tunnel_tso_segsz == 0)
3706 printf("TSO for tunneled packets is disabled\n");
3708 printf("TSO segment size for tunneled packets is %d\n",
3709 ports[res->port_id].tunnel_tso_segsz);
3711 /* Below conditions are needed to make it work:
3712 * (1) tunnel TSO is supported by the NIC;
3713 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3715 * (3) for tunneled pkts with outer L3 of IPv4,
3716 * "csum set outer-ip" must be set to hw, because after tso,
3717 * total_len of outer IP header is changed, and the checksum
3718 * of outer IP header calculated by sw should be wrong; that
3719 * is not necessary for IPv6 tunneled pkts because there's no
3720 * checksum in IP header anymore.
3722 check_tunnel_tso_nic_support(res->port_id);
3724 if (!(ports[res->port_id].tx_ol_flags &
3725 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3726 printf("Warning: csum parse_tunnel must be set "
3727 "so that tunneled packets are recognized\n");
3728 if (!(ports[res->port_id].tx_ol_flags &
3729 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3730 printf("Warning: csum set outer-ip must be set to hw "
3731 "if outer L3 is IPv4; not necessary for IPv6\n");
3735 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3736 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3738 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3739 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3741 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3742 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3744 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3745 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3748 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3749 .f = cmd_tunnel_tso_set_parsed,
3751 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3752 "Set TSO segment size of tunneled packets for csum engine "
3755 (void *)&cmd_tunnel_tso_set_tso,
3756 (void *)&cmd_tunnel_tso_set_mode,
3757 (void *)&cmd_tunnel_tso_set_tso_segsz,
3758 (void *)&cmd_tunnel_tso_set_portid,
3763 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3764 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3768 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3769 .f = cmd_tunnel_tso_set_parsed,
3771 .help_str = "tunnel_tso show <port_id> "
3772 "Show TSO segment size of tunneled packets for csum engine",
3774 (void *)&cmd_tunnel_tso_set_tso,
3775 (void *)&cmd_tunnel_tso_show_mode,
3776 (void *)&cmd_tunnel_tso_set_portid,
3781 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3782 struct cmd_set_flush_rx {
3783 cmdline_fixed_string_t set;
3784 cmdline_fixed_string_t flush_rx;
3785 cmdline_fixed_string_t mode;
3789 cmd_set_flush_rx_parsed(void *parsed_result,
3790 __attribute__((unused)) struct cmdline *cl,
3791 __attribute__((unused)) void *data)
3793 struct cmd_set_flush_rx *res = parsed_result;
3794 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3797 cmdline_parse_token_string_t cmd_setflushrx_set =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3800 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3801 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3802 flush_rx, "flush_rx");
3803 cmdline_parse_token_string_t cmd_setflushrx_mode =
3804 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3808 cmdline_parse_inst_t cmd_set_flush_rx = {
3809 .f = cmd_set_flush_rx_parsed,
3810 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3813 (void *)&cmd_setflushrx_set,
3814 (void *)&cmd_setflushrx_flush_rx,
3815 (void *)&cmd_setflushrx_mode,
3820 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3821 struct cmd_set_link_check {
3822 cmdline_fixed_string_t set;
3823 cmdline_fixed_string_t link_check;
3824 cmdline_fixed_string_t mode;
3828 cmd_set_link_check_parsed(void *parsed_result,
3829 __attribute__((unused)) struct cmdline *cl,
3830 __attribute__((unused)) void *data)
3832 struct cmd_set_link_check *res = parsed_result;
3833 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3836 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3837 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3839 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3840 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3841 link_check, "link_check");
3842 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3843 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3847 cmdline_parse_inst_t cmd_set_link_check = {
3848 .f = cmd_set_link_check_parsed,
3849 .help_str = "set link_check on|off: Enable/Disable link status check "
3850 "when starting/stopping a port",
3853 (void *)&cmd_setlinkcheck_set,
3854 (void *)&cmd_setlinkcheck_link_check,
3855 (void *)&cmd_setlinkcheck_mode,
3860 #ifdef RTE_NIC_BYPASS
3861 /* *** SET NIC BYPASS MODE *** */
3862 struct cmd_set_bypass_mode_result {
3863 cmdline_fixed_string_t set;
3864 cmdline_fixed_string_t bypass;
3865 cmdline_fixed_string_t mode;
3866 cmdline_fixed_string_t value;
3871 cmd_set_bypass_mode_parsed(void *parsed_result,
3872 __attribute__((unused)) struct cmdline *cl,
3873 __attribute__((unused)) void *data)
3875 struct cmd_set_bypass_mode_result *res = parsed_result;
3876 portid_t port_id = res->port_id;
3877 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3879 if (!strcmp(res->value, "bypass"))
3880 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3881 else if (!strcmp(res->value, "isolate"))
3882 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3884 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3886 /* Set the bypass mode for the relevant port. */
3887 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3888 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3892 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3893 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3895 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3896 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3898 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3899 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3901 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3902 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3903 value, "normal#bypass#isolate");
3904 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3905 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3908 cmdline_parse_inst_t cmd_set_bypass_mode = {
3909 .f = cmd_set_bypass_mode_parsed,
3910 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3911 "Set the NIC bypass mode for port_id",
3914 (void *)&cmd_setbypass_mode_set,
3915 (void *)&cmd_setbypass_mode_bypass,
3916 (void *)&cmd_setbypass_mode_mode,
3917 (void *)&cmd_setbypass_mode_value,
3918 (void *)&cmd_setbypass_mode_port,
3923 /* *** SET NIC BYPASS EVENT *** */
3924 struct cmd_set_bypass_event_result {
3925 cmdline_fixed_string_t set;
3926 cmdline_fixed_string_t bypass;
3927 cmdline_fixed_string_t event;
3928 cmdline_fixed_string_t event_value;
3929 cmdline_fixed_string_t mode;
3930 cmdline_fixed_string_t mode_value;
3935 cmd_set_bypass_event_parsed(void *parsed_result,
3936 __attribute__((unused)) struct cmdline *cl,
3937 __attribute__((unused)) void *data)
3940 struct cmd_set_bypass_event_result *res = parsed_result;
3941 portid_t port_id = res->port_id;
3942 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3943 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3945 if (!strcmp(res->event_value, "timeout"))
3946 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3947 else if (!strcmp(res->event_value, "os_on"))
3948 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3949 else if (!strcmp(res->event_value, "os_off"))
3950 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3951 else if (!strcmp(res->event_value, "power_on"))
3952 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3953 else if (!strcmp(res->event_value, "power_off"))
3954 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3956 bypass_event = RTE_BYPASS_EVENT_NONE;
3958 if (!strcmp(res->mode_value, "bypass"))
3959 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3960 else if (!strcmp(res->mode_value, "isolate"))
3961 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3963 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3965 /* Set the watchdog timeout. */
3966 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3969 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3970 (rc = rte_eth_dev_wd_timeout_store(port_id,
3971 bypass_timeout)) != 0) {
3972 printf("Failed to set timeout value %u "
3973 "for port %d, errto code: %d.\n",
3974 bypass_timeout, port_id, rc);
3978 /* Set the bypass event to transition to bypass mode. */
3979 if (0 != rte_eth_dev_bypass_event_store(port_id,
3980 bypass_event, bypass_mode)) {
3981 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3986 cmdline_parse_token_string_t cmd_setbypass_event_set =
3987 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3989 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3992 cmdline_parse_token_string_t cmd_setbypass_event_event =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3995 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3996 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3997 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3998 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3999 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4001 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4003 mode_value, "normal#bypass#isolate");
4004 cmdline_parse_token_num_t cmd_setbypass_event_port =
4005 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4008 cmdline_parse_inst_t cmd_set_bypass_event = {
4009 .f = cmd_set_bypass_event_parsed,
4010 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4011 "power_off mode normal|bypass|isolate <port_id>: "
4012 "Set the NIC bypass event mode for port_id",
4015 (void *)&cmd_setbypass_event_set,
4016 (void *)&cmd_setbypass_event_bypass,
4017 (void *)&cmd_setbypass_event_event,
4018 (void *)&cmd_setbypass_event_event_value,
4019 (void *)&cmd_setbypass_event_mode,
4020 (void *)&cmd_setbypass_event_mode_value,
4021 (void *)&cmd_setbypass_event_port,
4027 /* *** SET NIC BYPASS TIMEOUT *** */
4028 struct cmd_set_bypass_timeout_result {
4029 cmdline_fixed_string_t set;
4030 cmdline_fixed_string_t bypass;
4031 cmdline_fixed_string_t timeout;
4032 cmdline_fixed_string_t value;
4036 cmd_set_bypass_timeout_parsed(void *parsed_result,
4037 __attribute__((unused)) struct cmdline *cl,
4038 __attribute__((unused)) void *data)
4040 struct cmd_set_bypass_timeout_result *res = parsed_result;
4042 if (!strcmp(res->value, "1.5"))
4043 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4044 else if (!strcmp(res->value, "2"))
4045 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4046 else if (!strcmp(res->value, "3"))
4047 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4048 else if (!strcmp(res->value, "4"))
4049 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4050 else if (!strcmp(res->value, "8"))
4051 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4052 else if (!strcmp(res->value, "16"))
4053 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4054 else if (!strcmp(res->value, "32"))
4055 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4057 bypass_timeout = RTE_BYPASS_TMT_OFF;
4060 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4061 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4063 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4064 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4066 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4067 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4068 timeout, "timeout");
4069 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4070 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4071 value, "0#1.5#2#3#4#8#16#32");
4073 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4074 .f = cmd_set_bypass_timeout_parsed,
4075 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4076 "Set the NIC bypass watchdog timeout in seconds",
4079 (void *)&cmd_setbypass_timeout_set,
4080 (void *)&cmd_setbypass_timeout_bypass,
4081 (void *)&cmd_setbypass_timeout_timeout,
4082 (void *)&cmd_setbypass_timeout_value,
4087 /* *** SHOW NIC BYPASS MODE *** */
4088 struct cmd_show_bypass_config_result {
4089 cmdline_fixed_string_t show;
4090 cmdline_fixed_string_t bypass;
4091 cmdline_fixed_string_t config;
4096 cmd_show_bypass_config_parsed(void *parsed_result,
4097 __attribute__((unused)) struct cmdline *cl,
4098 __attribute__((unused)) void *data)
4100 struct cmd_show_bypass_config_result *res = parsed_result;
4101 uint32_t event_mode;
4102 uint32_t bypass_mode;
4103 portid_t port_id = res->port_id;
4104 uint32_t timeout = bypass_timeout;
4107 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4108 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4109 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4110 {"UNKNOWN", "normal", "bypass", "isolate"};
4111 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4118 int num_events = (sizeof events) / (sizeof events[0]);
4120 /* Display the bypass mode.*/
4121 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4122 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4126 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4127 bypass_mode = RTE_BYPASS_MODE_NONE;
4129 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4132 /* Display the bypass timeout.*/
4133 if (!RTE_BYPASS_TMT_VALID(timeout))
4134 timeout = RTE_BYPASS_TMT_OFF;
4136 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4138 /* Display the bypass events and associated modes. */
4139 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4141 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4142 printf("\tFailed to get bypass mode for event = %s\n",
4145 if (!RTE_BYPASS_MODE_VALID(event_mode))
4146 event_mode = RTE_BYPASS_MODE_NONE;
4148 printf("\tbypass event: %-16s = %s\n", events[i],
4154 cmdline_parse_token_string_t cmd_showbypass_config_show =
4155 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4157 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4158 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4160 cmdline_parse_token_string_t cmd_showbypass_config_config =
4161 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4163 cmdline_parse_token_num_t cmd_showbypass_config_port =
4164 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4167 cmdline_parse_inst_t cmd_show_bypass_config = {
4168 .f = cmd_show_bypass_config_parsed,
4169 .help_str = "show bypass config <port_id>: "
4170 "Show the NIC bypass config for port_id",
4173 (void *)&cmd_showbypass_config_show,
4174 (void *)&cmd_showbypass_config_bypass,
4175 (void *)&cmd_showbypass_config_config,
4176 (void *)&cmd_showbypass_config_port,
4182 #ifdef RTE_LIBRTE_PMD_BOND
4183 /* *** SET BONDING MODE *** */
4184 struct cmd_set_bonding_mode_result {
4185 cmdline_fixed_string_t set;
4186 cmdline_fixed_string_t bonding;
4187 cmdline_fixed_string_t mode;
4192 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4193 __attribute__((unused)) struct cmdline *cl,
4194 __attribute__((unused)) void *data)
4196 struct cmd_set_bonding_mode_result *res = parsed_result;
4197 portid_t port_id = res->port_id;
4199 /* Set the bonding mode for the relevant port. */
4200 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4201 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4204 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4205 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4207 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4208 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4209 bonding, "bonding");
4210 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4211 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4213 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4214 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4216 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4217 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4220 cmdline_parse_inst_t cmd_set_bonding_mode = {
4221 .f = cmd_set_bonding_mode_parsed,
4222 .help_str = "set bonding mode <mode_value> <port_id>: "
4223 "Set the bonding mode for port_id",
4226 (void *) &cmd_setbonding_mode_set,
4227 (void *) &cmd_setbonding_mode_bonding,
4228 (void *) &cmd_setbonding_mode_mode,
4229 (void *) &cmd_setbonding_mode_value,
4230 (void *) &cmd_setbonding_mode_port,
4235 /* *** SET BALANCE XMIT POLICY *** */
4236 struct cmd_set_bonding_balance_xmit_policy_result {
4237 cmdline_fixed_string_t set;
4238 cmdline_fixed_string_t bonding;
4239 cmdline_fixed_string_t balance_xmit_policy;
4241 cmdline_fixed_string_t policy;
4244 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4245 __attribute__((unused)) struct cmdline *cl,
4246 __attribute__((unused)) void *data)
4248 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4249 portid_t port_id = res->port_id;
4252 if (!strcmp(res->policy, "l2")) {
4253 policy = BALANCE_XMIT_POLICY_LAYER2;
4254 } else if (!strcmp(res->policy, "l23")) {
4255 policy = BALANCE_XMIT_POLICY_LAYER23;
4256 } else if (!strcmp(res->policy, "l34")) {
4257 policy = BALANCE_XMIT_POLICY_LAYER34;
4259 printf("\t Invalid xmit policy selection");
4263 /* Set the bonding mode for the relevant port. */
4264 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4265 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4270 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4271 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4273 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4274 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4275 bonding, "bonding");
4276 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4277 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4278 balance_xmit_policy, "balance_xmit_policy");
4279 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4280 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4282 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4283 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4284 policy, "l2#l23#l34");
4286 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4287 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4288 .help_str = "set bonding balance_xmit_policy <port_id> "
4290 "Set the bonding balance_xmit_policy for port_id",
4293 (void *)&cmd_setbonding_balance_xmit_policy_set,
4294 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4295 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4296 (void *)&cmd_setbonding_balance_xmit_policy_port,
4297 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4302 /* *** SHOW NIC BONDING CONFIGURATION *** */
4303 struct cmd_show_bonding_config_result {
4304 cmdline_fixed_string_t show;
4305 cmdline_fixed_string_t bonding;
4306 cmdline_fixed_string_t config;
4310 static void cmd_show_bonding_config_parsed(void *parsed_result,
4311 __attribute__((unused)) struct cmdline *cl,
4312 __attribute__((unused)) void *data)
4314 struct cmd_show_bonding_config_result *res = parsed_result;
4316 uint8_t slaves[RTE_MAX_ETHPORTS];
4317 int num_slaves, num_active_slaves;
4320 portid_t port_id = res->port_id;
4322 /* Display the bonding mode.*/
4323 bonding_mode = rte_eth_bond_mode_get(port_id);
4324 if (bonding_mode < 0) {
4325 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4328 printf("\tBonding mode: %d\n", bonding_mode);
4330 if (bonding_mode == BONDING_MODE_BALANCE) {
4331 int balance_xmit_policy;
4333 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4334 if (balance_xmit_policy < 0) {
4335 printf("\tFailed to get balance xmit policy for port = %d\n",
4339 printf("\tBalance Xmit Policy: ");
4341 switch (balance_xmit_policy) {
4342 case BALANCE_XMIT_POLICY_LAYER2:
4343 printf("BALANCE_XMIT_POLICY_LAYER2");
4345 case BALANCE_XMIT_POLICY_LAYER23:
4346 printf("BALANCE_XMIT_POLICY_LAYER23");
4348 case BALANCE_XMIT_POLICY_LAYER34:
4349 printf("BALANCE_XMIT_POLICY_LAYER34");
4356 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4358 if (num_slaves < 0) {
4359 printf("\tFailed to get slave list for port = %d\n", port_id);
4362 if (num_slaves > 0) {
4363 printf("\tSlaves (%d): [", num_slaves);
4364 for (i = 0; i < num_slaves - 1; i++)
4365 printf("%d ", slaves[i]);
4367 printf("%d]\n", slaves[num_slaves - 1]);
4369 printf("\tSlaves: []\n");
4373 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4376 if (num_active_slaves < 0) {
4377 printf("\tFailed to get active slave list for port = %d\n", port_id);
4380 if (num_active_slaves > 0) {
4381 printf("\tActive Slaves (%d): [", num_active_slaves);
4382 for (i = 0; i < num_active_slaves - 1; i++)
4383 printf("%d ", slaves[i]);
4385 printf("%d]\n", slaves[num_active_slaves - 1]);
4388 printf("\tActive Slaves: []\n");
4392 primary_id = rte_eth_bond_primary_get(port_id);
4393 if (primary_id < 0) {
4394 printf("\tFailed to get primary slave for port = %d\n", port_id);
4397 printf("\tPrimary: [%d]\n", primary_id);
4401 cmdline_parse_token_string_t cmd_showbonding_config_show =
4402 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4404 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4405 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4406 bonding, "bonding");
4407 cmdline_parse_token_string_t cmd_showbonding_config_config =
4408 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4410 cmdline_parse_token_num_t cmd_showbonding_config_port =
4411 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4414 cmdline_parse_inst_t cmd_show_bonding_config = {
4415 .f = cmd_show_bonding_config_parsed,
4416 .help_str = "show bonding config <port_id>: "
4417 "Show the bonding config for port_id",
4420 (void *)&cmd_showbonding_config_show,
4421 (void *)&cmd_showbonding_config_bonding,
4422 (void *)&cmd_showbonding_config_config,
4423 (void *)&cmd_showbonding_config_port,
4428 /* *** SET BONDING PRIMARY *** */
4429 struct cmd_set_bonding_primary_result {
4430 cmdline_fixed_string_t set;
4431 cmdline_fixed_string_t bonding;
4432 cmdline_fixed_string_t primary;
4437 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4438 __attribute__((unused)) struct cmdline *cl,
4439 __attribute__((unused)) void *data)
4441 struct cmd_set_bonding_primary_result *res = parsed_result;
4442 portid_t master_port_id = res->port_id;
4443 portid_t slave_port_id = res->slave_id;
4445 /* Set the primary slave for a bonded device. */
4446 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4447 printf("\t Failed to set primary slave for port = %d.\n",
4454 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4455 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4457 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4458 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4459 bonding, "bonding");
4460 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4461 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4462 primary, "primary");
4463 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4464 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4466 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4467 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4470 cmdline_parse_inst_t cmd_set_bonding_primary = {
4471 .f = cmd_set_bonding_primary_parsed,
4472 .help_str = "set bonding primary <slave_id> <port_id>: "
4473 "Set the primary slave for port_id",
4476 (void *)&cmd_setbonding_primary_set,
4477 (void *)&cmd_setbonding_primary_bonding,
4478 (void *)&cmd_setbonding_primary_primary,
4479 (void *)&cmd_setbonding_primary_slave,
4480 (void *)&cmd_setbonding_primary_port,
4485 /* *** ADD SLAVE *** */
4486 struct cmd_add_bonding_slave_result {
4487 cmdline_fixed_string_t add;
4488 cmdline_fixed_string_t bonding;
4489 cmdline_fixed_string_t slave;
4494 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4495 __attribute__((unused)) struct cmdline *cl,
4496 __attribute__((unused)) void *data)
4498 struct cmd_add_bonding_slave_result *res = parsed_result;
4499 portid_t master_port_id = res->port_id;
4500 portid_t slave_port_id = res->slave_id;
4502 /* Set the primary slave for a bonded device. */
4503 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4504 printf("\t Failed to add slave %d to master port = %d.\n",
4505 slave_port_id, master_port_id);
4509 set_port_slave_flag(slave_port_id);
4512 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4513 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4515 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4516 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4517 bonding, "bonding");
4518 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4519 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4521 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4522 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4524 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4525 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4528 cmdline_parse_inst_t cmd_add_bonding_slave = {
4529 .f = cmd_add_bonding_slave_parsed,
4530 .help_str = "add bonding slave <slave_id> <port_id>: "
4531 "Add a slave device to a bonded device",
4534 (void *)&cmd_addbonding_slave_add,
4535 (void *)&cmd_addbonding_slave_bonding,
4536 (void *)&cmd_addbonding_slave_slave,
4537 (void *)&cmd_addbonding_slave_slaveid,
4538 (void *)&cmd_addbonding_slave_port,
4543 /* *** REMOVE SLAVE *** */
4544 struct cmd_remove_bonding_slave_result {
4545 cmdline_fixed_string_t remove;
4546 cmdline_fixed_string_t bonding;
4547 cmdline_fixed_string_t slave;
4552 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4553 __attribute__((unused)) struct cmdline *cl,
4554 __attribute__((unused)) void *data)
4556 struct cmd_remove_bonding_slave_result *res = parsed_result;
4557 portid_t master_port_id = res->port_id;
4558 portid_t slave_port_id = res->slave_id;
4560 /* Set the primary slave for a bonded device. */
4561 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4562 printf("\t Failed to remove slave %d from master port = %d.\n",
4563 slave_port_id, master_port_id);
4567 clear_port_slave_flag(slave_port_id);
4570 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4571 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4573 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4574 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4575 bonding, "bonding");
4576 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4577 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4579 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4580 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4582 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4583 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4586 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4587 .f = cmd_remove_bonding_slave_parsed,
4588 .help_str = "remove bonding slave <slave_id> <port_id>: "
4589 "Remove a slave device from a bonded device",
4592 (void *)&cmd_removebonding_slave_remove,
4593 (void *)&cmd_removebonding_slave_bonding,
4594 (void *)&cmd_removebonding_slave_slave,
4595 (void *)&cmd_removebonding_slave_slaveid,
4596 (void *)&cmd_removebonding_slave_port,
4601 /* *** CREATE BONDED DEVICE *** */
4602 struct cmd_create_bonded_device_result {
4603 cmdline_fixed_string_t create;
4604 cmdline_fixed_string_t bonded;
4605 cmdline_fixed_string_t device;
4610 static int bond_dev_num = 0;
4612 static void cmd_create_bonded_device_parsed(void *parsed_result,
4613 __attribute__((unused)) struct cmdline *cl,
4614 __attribute__((unused)) void *data)
4616 struct cmd_create_bonded_device_result *res = parsed_result;
4617 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4620 if (test_done == 0) {
4621 printf("Please stop forwarding first\n");
4625 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4628 /* Create a new bonded device. */
4629 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4631 printf("\t Failed to create bonded device.\n");
4634 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4637 /* Update number of ports */
4638 nb_ports = rte_eth_dev_count();
4639 reconfig(port_id, res->socket);
4640 rte_eth_promiscuous_enable(port_id);
4641 ports[port_id].enabled = 1;
4646 cmdline_parse_token_string_t cmd_createbonded_device_create =
4647 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4649 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4650 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4652 cmdline_parse_token_string_t cmd_createbonded_device_device =
4653 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4655 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4656 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4658 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4659 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4662 cmdline_parse_inst_t cmd_create_bonded_device = {
4663 .f = cmd_create_bonded_device_parsed,
4664 .help_str = "create bonded device <mode> <socket>: "
4665 "Create a new bonded device with specific bonding mode and socket",
4668 (void *)&cmd_createbonded_device_create,
4669 (void *)&cmd_createbonded_device_bonded,
4670 (void *)&cmd_createbonded_device_device,
4671 (void *)&cmd_createbonded_device_mode,
4672 (void *)&cmd_createbonded_device_socket,
4677 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4678 struct cmd_set_bond_mac_addr_result {
4679 cmdline_fixed_string_t set;
4680 cmdline_fixed_string_t bonding;
4681 cmdline_fixed_string_t mac_addr;
4683 struct ether_addr address;
4686 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4687 __attribute__((unused)) struct cmdline *cl,
4688 __attribute__((unused)) void *data)
4690 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4693 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4696 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4698 /* check the return value and print it if is < 0 */
4700 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4703 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4704 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4705 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4706 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4708 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4709 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4711 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4712 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4713 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4714 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4716 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4717 .f = cmd_set_bond_mac_addr_parsed,
4719 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4721 (void *)&cmd_set_bond_mac_addr_set,
4722 (void *)&cmd_set_bond_mac_addr_bonding,
4723 (void *)&cmd_set_bond_mac_addr_mac,
4724 (void *)&cmd_set_bond_mac_addr_portnum,
4725 (void *)&cmd_set_bond_mac_addr_addr,
4731 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4732 struct cmd_set_bond_mon_period_result {
4733 cmdline_fixed_string_t set;
4734 cmdline_fixed_string_t bonding;
4735 cmdline_fixed_string_t mon_period;
4740 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4741 __attribute__((unused)) struct cmdline *cl,
4742 __attribute__((unused)) void *data)
4744 struct cmd_set_bond_mon_period_result *res = parsed_result;
4747 if (res->port_num >= nb_ports) {
4748 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4752 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4754 /* check the return value and print it if is < 0 */
4756 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4759 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4760 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4762 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4763 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4764 bonding, "bonding");
4765 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4766 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4767 mon_period, "mon_period");
4768 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4769 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4771 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4772 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4775 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4776 .f = cmd_set_bond_mon_period_parsed,
4778 .help_str = "set bonding mon_period <port_id> <period_ms>",
4780 (void *)&cmd_set_bond_mon_period_set,
4781 (void *)&cmd_set_bond_mon_period_bonding,
4782 (void *)&cmd_set_bond_mon_period_mon_period,
4783 (void *)&cmd_set_bond_mon_period_portnum,
4784 (void *)&cmd_set_bond_mon_period_period_ms,
4789 #endif /* RTE_LIBRTE_PMD_BOND */
4791 /* *** SET FORWARDING MODE *** */
4792 struct cmd_set_fwd_mode_result {
4793 cmdline_fixed_string_t set;
4794 cmdline_fixed_string_t fwd;
4795 cmdline_fixed_string_t mode;
4798 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4799 __attribute__((unused)) struct cmdline *cl,
4800 __attribute__((unused)) void *data)
4802 struct cmd_set_fwd_mode_result *res = parsed_result;
4805 set_pkt_forwarding_mode(res->mode);
4808 cmdline_parse_token_string_t cmd_setfwd_set =
4809 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4810 cmdline_parse_token_string_t cmd_setfwd_fwd =
4811 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4812 cmdline_parse_token_string_t cmd_setfwd_mode =
4813 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4814 "" /* defined at init */);
4816 cmdline_parse_inst_t cmd_set_fwd_mode = {
4817 .f = cmd_set_fwd_mode_parsed,
4819 .help_str = NULL, /* defined at init */
4821 (void *)&cmd_setfwd_set,
4822 (void *)&cmd_setfwd_fwd,
4823 (void *)&cmd_setfwd_mode,
4828 static void cmd_set_fwd_mode_init(void)
4831 static char token[128];
4832 static char help[256];
4833 cmdline_parse_token_string_t *token_struct;
4835 modes = list_pkt_forwarding_modes();
4836 snprintf(help, sizeof(help), "set fwd %s: "
4837 "Set packet forwarding mode", modes);
4838 cmd_set_fwd_mode.help_str = help;
4840 /* string token separator is # */
4841 for (c = token; *modes != '\0'; modes++)
4846 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4847 token_struct->string_data.str = token;
4850 /* *** SET RETRY FORWARDING MODE *** */
4851 struct cmd_set_fwd_retry_mode_result {
4852 cmdline_fixed_string_t set;
4853 cmdline_fixed_string_t fwd;
4854 cmdline_fixed_string_t mode;
4855 cmdline_fixed_string_t retry;
4858 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4859 __attribute__((unused)) struct cmdline *cl,
4860 __attribute__((unused)) void *data)
4862 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4865 set_pkt_forwarding_mode(res->mode);
4868 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4869 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4871 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4872 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4874 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4875 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4877 "" /* defined at init */);
4878 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4879 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4882 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4883 .f = cmd_set_fwd_retry_mode_parsed,
4885 .help_str = NULL, /* defined at init */
4887 (void *)&cmd_setfwd_retry_set,
4888 (void *)&cmd_setfwd_retry_fwd,
4889 (void *)&cmd_setfwd_retry_mode,
4890 (void *)&cmd_setfwd_retry_retry,
4895 static void cmd_set_fwd_retry_mode_init(void)
4898 static char token[128];
4899 static char help[256];
4900 cmdline_parse_token_string_t *token_struct;
4902 modes = list_pkt_forwarding_retry_modes();
4903 snprintf(help, sizeof(help), "set fwd %s retry: "
4904 "Set packet forwarding mode with retry", modes);
4905 cmd_set_fwd_retry_mode.help_str = help;
4907 /* string token separator is # */
4908 for (c = token; *modes != '\0'; modes++)
4913 token_struct = (cmdline_parse_token_string_t *)
4914 cmd_set_fwd_retry_mode.tokens[2];
4915 token_struct->string_data.str = token;
4918 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4919 struct cmd_set_burst_tx_retry_result {
4920 cmdline_fixed_string_t set;
4921 cmdline_fixed_string_t burst;
4922 cmdline_fixed_string_t tx;
4923 cmdline_fixed_string_t delay;
4925 cmdline_fixed_string_t retry;
4929 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4930 __attribute__((unused)) struct cmdline *cl,
4931 __attribute__((unused)) void *data)
4933 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4935 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4936 && !strcmp(res->tx, "tx")) {
4937 if (!strcmp(res->delay, "delay"))
4938 burst_tx_delay_time = res->time;
4939 if (!strcmp(res->retry, "retry"))
4940 burst_tx_retry_num = res->retry_num;
4945 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4946 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4947 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4948 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4950 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4951 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4952 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4953 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4954 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4955 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4956 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4957 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4958 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4959 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4961 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4962 .f = cmd_set_burst_tx_retry_parsed,
4963 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4965 (void *)&cmd_set_burst_tx_retry_set,
4966 (void *)&cmd_set_burst_tx_retry_burst,
4967 (void *)&cmd_set_burst_tx_retry_tx,
4968 (void *)&cmd_set_burst_tx_retry_delay,
4969 (void *)&cmd_set_burst_tx_retry_time,
4970 (void *)&cmd_set_burst_tx_retry_retry,
4971 (void *)&cmd_set_burst_tx_retry_retry_num,
4976 /* *** SET PROMISC MODE *** */
4977 struct cmd_set_promisc_mode_result {
4978 cmdline_fixed_string_t set;
4979 cmdline_fixed_string_t promisc;
4980 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4981 uint8_t port_num; /* valid if "allports" argument == 0 */
4982 cmdline_fixed_string_t mode;
4985 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4986 __attribute__((unused)) struct cmdline *cl,
4989 struct cmd_set_promisc_mode_result *res = parsed_result;
4993 if (!strcmp(res->mode, "on"))
5000 FOREACH_PORT(i, ports) {
5002 rte_eth_promiscuous_enable(i);
5004 rte_eth_promiscuous_disable(i);
5009 rte_eth_promiscuous_enable(res->port_num);
5011 rte_eth_promiscuous_disable(res->port_num);
5015 cmdline_parse_token_string_t cmd_setpromisc_set =
5016 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5017 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5018 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5020 cmdline_parse_token_string_t cmd_setpromisc_portall =
5021 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5023 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5024 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5026 cmdline_parse_token_string_t cmd_setpromisc_mode =
5027 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5030 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5031 .f = cmd_set_promisc_mode_parsed,
5033 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5035 (void *)&cmd_setpromisc_set,
5036 (void *)&cmd_setpromisc_promisc,
5037 (void *)&cmd_setpromisc_portall,
5038 (void *)&cmd_setpromisc_mode,
5043 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5044 .f = cmd_set_promisc_mode_parsed,
5046 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5048 (void *)&cmd_setpromisc_set,
5049 (void *)&cmd_setpromisc_promisc,
5050 (void *)&cmd_setpromisc_portnum,
5051 (void *)&cmd_setpromisc_mode,
5056 /* *** SET ALLMULTI MODE *** */
5057 struct cmd_set_allmulti_mode_result {
5058 cmdline_fixed_string_t set;
5059 cmdline_fixed_string_t allmulti;
5060 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5061 uint8_t port_num; /* valid if "allports" argument == 0 */
5062 cmdline_fixed_string_t mode;
5065 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5066 __attribute__((unused)) struct cmdline *cl,
5069 struct cmd_set_allmulti_mode_result *res = parsed_result;
5073 if (!strcmp(res->mode, "on"))
5080 FOREACH_PORT(i, ports) {
5082 rte_eth_allmulticast_enable(i);
5084 rte_eth_allmulticast_disable(i);
5089 rte_eth_allmulticast_enable(res->port_num);
5091 rte_eth_allmulticast_disable(res->port_num);
5095 cmdline_parse_token_string_t cmd_setallmulti_set =
5096 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5097 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5098 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5100 cmdline_parse_token_string_t cmd_setallmulti_portall =
5101 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5103 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5104 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5106 cmdline_parse_token_string_t cmd_setallmulti_mode =
5107 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5110 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5111 .f = cmd_set_allmulti_mode_parsed,
5113 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5115 (void *)&cmd_setallmulti_set,
5116 (void *)&cmd_setallmulti_allmulti,
5117 (void *)&cmd_setallmulti_portall,
5118 (void *)&cmd_setallmulti_mode,
5123 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5124 .f = cmd_set_allmulti_mode_parsed,
5126 .help_str = "set allmulti <port_id> on|off: "
5127 "Set allmulti mode on port_id",
5129 (void *)&cmd_setallmulti_set,
5130 (void *)&cmd_setallmulti_allmulti,
5131 (void *)&cmd_setallmulti_portnum,
5132 (void *)&cmd_setallmulti_mode,
5137 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5138 struct cmd_link_flow_ctrl_set_result {
5139 cmdline_fixed_string_t set;
5140 cmdline_fixed_string_t flow_ctrl;
5141 cmdline_fixed_string_t rx;
5142 cmdline_fixed_string_t rx_lfc_mode;
5143 cmdline_fixed_string_t tx;
5144 cmdline_fixed_string_t tx_lfc_mode;
5145 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5146 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5147 cmdline_fixed_string_t autoneg_str;
5148 cmdline_fixed_string_t autoneg;
5149 cmdline_fixed_string_t hw_str;
5150 uint32_t high_water;
5151 cmdline_fixed_string_t lw_str;
5153 cmdline_fixed_string_t pt_str;
5154 uint16_t pause_time;
5155 cmdline_fixed_string_t xon_str;
5160 cmdline_parse_token_string_t cmd_lfc_set_set =
5161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5163 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5165 flow_ctrl, "flow_ctrl");
5166 cmdline_parse_token_string_t cmd_lfc_set_rx =
5167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5169 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5171 rx_lfc_mode, "on#off");
5172 cmdline_parse_token_string_t cmd_lfc_set_tx =
5173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5175 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5177 tx_lfc_mode, "on#off");
5178 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5179 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5180 hw_str, "high_water");
5181 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5182 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5183 high_water, UINT32);
5184 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5186 lw_str, "low_water");
5187 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5188 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5190 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5191 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 pt_str, "pause_time");
5193 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5194 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5195 pause_time, UINT16);
5196 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5197 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5198 xon_str, "send_xon");
5199 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5200 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5202 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5203 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5205 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5206 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5207 mac_ctrl_frame_fwd_mode, "on#off");
5208 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5209 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5210 autoneg_str, "autoneg");
5211 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5212 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5214 cmdline_parse_token_num_t cmd_lfc_set_portid =
5215 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5218 /* forward declaration */
5220 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5223 cmdline_parse_inst_t cmd_link_flow_control_set = {
5224 .f = cmd_link_flow_ctrl_set_parsed,
5226 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5227 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5228 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5230 (void *)&cmd_lfc_set_set,
5231 (void *)&cmd_lfc_set_flow_ctrl,
5232 (void *)&cmd_lfc_set_rx,
5233 (void *)&cmd_lfc_set_rx_mode,
5234 (void *)&cmd_lfc_set_tx,
5235 (void *)&cmd_lfc_set_tx_mode,
5236 (void *)&cmd_lfc_set_high_water,
5237 (void *)&cmd_lfc_set_low_water,
5238 (void *)&cmd_lfc_set_pause_time,
5239 (void *)&cmd_lfc_set_send_xon,
5240 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5241 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5242 (void *)&cmd_lfc_set_autoneg_str,
5243 (void *)&cmd_lfc_set_autoneg,
5244 (void *)&cmd_lfc_set_portid,
5249 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5250 .f = cmd_link_flow_ctrl_set_parsed,
5251 .data = (void *)&cmd_link_flow_control_set_rx,
5252 .help_str = "set flow_ctrl rx on|off <port_id>: "
5253 "Change rx flow control parameter",
5255 (void *)&cmd_lfc_set_set,
5256 (void *)&cmd_lfc_set_flow_ctrl,
5257 (void *)&cmd_lfc_set_rx,
5258 (void *)&cmd_lfc_set_rx_mode,
5259 (void *)&cmd_lfc_set_portid,
5264 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5265 .f = cmd_link_flow_ctrl_set_parsed,
5266 .data = (void *)&cmd_link_flow_control_set_tx,
5267 .help_str = "set flow_ctrl tx on|off <port_id>: "
5268 "Change tx flow control parameter",
5270 (void *)&cmd_lfc_set_set,
5271 (void *)&cmd_lfc_set_flow_ctrl,
5272 (void *)&cmd_lfc_set_tx,
5273 (void *)&cmd_lfc_set_tx_mode,
5274 (void *)&cmd_lfc_set_portid,
5279 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5280 .f = cmd_link_flow_ctrl_set_parsed,
5281 .data = (void *)&cmd_link_flow_control_set_hw,
5282 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5283 "Change high water flow control parameter",
5285 (void *)&cmd_lfc_set_set,
5286 (void *)&cmd_lfc_set_flow_ctrl,
5287 (void *)&cmd_lfc_set_high_water_str,
5288 (void *)&cmd_lfc_set_high_water,
5289 (void *)&cmd_lfc_set_portid,
5294 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5295 .f = cmd_link_flow_ctrl_set_parsed,
5296 .data = (void *)&cmd_link_flow_control_set_lw,
5297 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5298 "Change low water flow control parameter",
5300 (void *)&cmd_lfc_set_set,
5301 (void *)&cmd_lfc_set_flow_ctrl,
5302 (void *)&cmd_lfc_set_low_water_str,
5303 (void *)&cmd_lfc_set_low_water,
5304 (void *)&cmd_lfc_set_portid,
5309 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5310 .f = cmd_link_flow_ctrl_set_parsed,
5311 .data = (void *)&cmd_link_flow_control_set_pt,
5312 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5313 "Change pause time flow control parameter",
5315 (void *)&cmd_lfc_set_set,
5316 (void *)&cmd_lfc_set_flow_ctrl,
5317 (void *)&cmd_lfc_set_pause_time_str,
5318 (void *)&cmd_lfc_set_pause_time,
5319 (void *)&cmd_lfc_set_portid,
5324 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5325 .f = cmd_link_flow_ctrl_set_parsed,
5326 .data = (void *)&cmd_link_flow_control_set_xon,
5327 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5328 "Change send_xon flow control parameter",
5330 (void *)&cmd_lfc_set_set,
5331 (void *)&cmd_lfc_set_flow_ctrl,
5332 (void *)&cmd_lfc_set_send_xon_str,
5333 (void *)&cmd_lfc_set_send_xon,
5334 (void *)&cmd_lfc_set_portid,
5339 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5340 .f = cmd_link_flow_ctrl_set_parsed,
5341 .data = (void *)&cmd_link_flow_control_set_macfwd,
5342 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5343 "Change mac ctrl fwd flow control parameter",
5345 (void *)&cmd_lfc_set_set,
5346 (void *)&cmd_lfc_set_flow_ctrl,
5347 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5348 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5349 (void *)&cmd_lfc_set_portid,
5354 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5355 .f = cmd_link_flow_ctrl_set_parsed,
5356 .data = (void *)&cmd_link_flow_control_set_autoneg,
5357 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5358 "Change autoneg flow control parameter",
5360 (void *)&cmd_lfc_set_set,
5361 (void *)&cmd_lfc_set_flow_ctrl,
5362 (void *)&cmd_lfc_set_autoneg_str,
5363 (void *)&cmd_lfc_set_autoneg,
5364 (void *)&cmd_lfc_set_portid,
5370 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5371 __attribute__((unused)) struct cmdline *cl,
5374 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5375 cmdline_parse_inst_t *cmd = data;
5376 struct rte_eth_fc_conf fc_conf;
5382 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5383 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5384 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5385 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5387 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5388 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5391 /* Partial command line, retrieve current configuration */
5393 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5395 printf("cannot get current flow ctrl parameters, return"
5396 "code = %d\n", ret);
5400 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5401 (fc_conf.mode == RTE_FC_FULL))
5403 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5404 (fc_conf.mode == RTE_FC_FULL))
5408 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5409 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5411 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5412 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5414 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5416 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5417 fc_conf.high_water = res->high_water;
5419 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5420 fc_conf.low_water = res->low_water;
5422 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5423 fc_conf.pause_time = res->pause_time;
5425 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5426 fc_conf.send_xon = res->send_xon;
5428 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5429 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5430 fc_conf.mac_ctrl_frame_fwd = 1;
5432 fc_conf.mac_ctrl_frame_fwd = 0;
5435 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5436 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5438 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5440 printf("bad flow contrl parameter, return code = %d \n", ret);
5443 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5444 struct cmd_priority_flow_ctrl_set_result {
5445 cmdline_fixed_string_t set;
5446 cmdline_fixed_string_t pfc_ctrl;
5447 cmdline_fixed_string_t rx;
5448 cmdline_fixed_string_t rx_pfc_mode;
5449 cmdline_fixed_string_t tx;
5450 cmdline_fixed_string_t tx_pfc_mode;
5451 uint32_t high_water;
5453 uint16_t pause_time;
5459 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5460 __attribute__((unused)) struct cmdline *cl,
5461 __attribute__((unused)) void *data)
5463 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5464 struct rte_eth_pfc_conf pfc_conf;
5465 int rx_fc_enable, tx_fc_enable;
5469 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5470 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5471 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5472 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5474 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5475 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5478 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5479 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5480 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5481 pfc_conf.fc.high_water = res->high_water;
5482 pfc_conf.fc.low_water = res->low_water;
5483 pfc_conf.fc.pause_time = res->pause_time;
5484 pfc_conf.priority = res->priority;
5486 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5488 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5491 cmdline_parse_token_string_t cmd_pfc_set_set =
5492 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5494 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5495 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5496 pfc_ctrl, "pfc_ctrl");
5497 cmdline_parse_token_string_t cmd_pfc_set_rx =
5498 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5500 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5501 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5502 rx_pfc_mode, "on#off");
5503 cmdline_parse_token_string_t cmd_pfc_set_tx =
5504 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5506 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5507 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5508 tx_pfc_mode, "on#off");
5509 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5510 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5511 high_water, UINT32);
5512 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5513 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5515 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5516 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5517 pause_time, UINT16);
5518 cmdline_parse_token_num_t cmd_pfc_set_priority =
5519 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5521 cmdline_parse_token_num_t cmd_pfc_set_portid =
5522 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5525 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5526 .f = cmd_priority_flow_ctrl_set_parsed,
5528 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5529 "<pause_time> <priority> <port_id>: "
5530 "Configure the Ethernet priority flow control",
5532 (void *)&cmd_pfc_set_set,
5533 (void *)&cmd_pfc_set_flow_ctrl,
5534 (void *)&cmd_pfc_set_rx,
5535 (void *)&cmd_pfc_set_rx_mode,
5536 (void *)&cmd_pfc_set_tx,
5537 (void *)&cmd_pfc_set_tx_mode,
5538 (void *)&cmd_pfc_set_high_water,
5539 (void *)&cmd_pfc_set_low_water,
5540 (void *)&cmd_pfc_set_pause_time,
5541 (void *)&cmd_pfc_set_priority,
5542 (void *)&cmd_pfc_set_portid,
5547 /* *** RESET CONFIGURATION *** */
5548 struct cmd_reset_result {
5549 cmdline_fixed_string_t reset;
5550 cmdline_fixed_string_t def;
5553 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5555 __attribute__((unused)) void *data)
5557 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5558 set_def_fwd_config();
5561 cmdline_parse_token_string_t cmd_reset_set =
5562 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5563 cmdline_parse_token_string_t cmd_reset_def =
5564 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5567 cmdline_parse_inst_t cmd_reset = {
5568 .f = cmd_reset_parsed,
5570 .help_str = "set default: Reset default forwarding configuration",
5572 (void *)&cmd_reset_set,
5573 (void *)&cmd_reset_def,
5578 /* *** START FORWARDING *** */
5579 struct cmd_start_result {
5580 cmdline_fixed_string_t start;
5583 cmdline_parse_token_string_t cmd_start_start =
5584 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5586 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5587 __attribute__((unused)) struct cmdline *cl,
5588 __attribute__((unused)) void *data)
5590 start_packet_forwarding(0);
5593 cmdline_parse_inst_t cmd_start = {
5594 .f = cmd_start_parsed,
5596 .help_str = "start: Start packet forwarding",
5598 (void *)&cmd_start_start,
5603 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5604 struct cmd_start_tx_first_result {
5605 cmdline_fixed_string_t start;
5606 cmdline_fixed_string_t tx_first;
5610 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5611 __attribute__((unused)) struct cmdline *cl,
5612 __attribute__((unused)) void *data)
5614 start_packet_forwarding(1);
5617 cmdline_parse_token_string_t cmd_start_tx_first_start =
5618 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5620 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5621 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5622 tx_first, "tx_first");
5624 cmdline_parse_inst_t cmd_start_tx_first = {
5625 .f = cmd_start_tx_first_parsed,
5627 .help_str = "start tx_first: Start packet forwarding, "
5628 "after sending 1 burst of packets",
5630 (void *)&cmd_start_tx_first_start,
5631 (void *)&cmd_start_tx_first_tx_first,
5636 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5637 struct cmd_start_tx_first_n_result {
5638 cmdline_fixed_string_t start;
5639 cmdline_fixed_string_t tx_first;
5644 cmd_start_tx_first_n_parsed(void *parsed_result,
5645 __attribute__((unused)) struct cmdline *cl,
5646 __attribute__((unused)) void *data)
5648 struct cmd_start_tx_first_n_result *res = parsed_result;
5650 start_packet_forwarding(res->tx_num);
5653 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5654 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5656 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5657 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5658 tx_first, "tx_first");
5659 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5660 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5663 cmdline_parse_inst_t cmd_start_tx_first_n = {
5664 .f = cmd_start_tx_first_n_parsed,
5666 .help_str = "start tx_first <num>: "
5667 "packet forwarding, after sending <num> bursts of packets",
5669 (void *)&cmd_start_tx_first_n_start,
5670 (void *)&cmd_start_tx_first_n_tx_first,
5671 (void *)&cmd_start_tx_first_n_tx_num,
5676 /* *** SET LINK UP *** */
5677 struct cmd_set_link_up_result {
5678 cmdline_fixed_string_t set;
5679 cmdline_fixed_string_t link_up;
5680 cmdline_fixed_string_t port;
5684 cmdline_parse_token_string_t cmd_set_link_up_set =
5685 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5686 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5689 cmdline_parse_token_string_t cmd_set_link_up_port =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5691 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5692 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5694 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5695 __attribute__((unused)) struct cmdline *cl,
5696 __attribute__((unused)) void *data)
5698 struct cmd_set_link_up_result *res = parsed_result;
5699 dev_set_link_up(res->port_id);
5702 cmdline_parse_inst_t cmd_set_link_up = {
5703 .f = cmd_set_link_up_parsed,
5705 .help_str = "set link-up port <port id>",
5707 (void *)&cmd_set_link_up_set,
5708 (void *)&cmd_set_link_up_link_up,
5709 (void *)&cmd_set_link_up_port,
5710 (void *)&cmd_set_link_up_port_id,
5715 /* *** SET LINK DOWN *** */
5716 struct cmd_set_link_down_result {
5717 cmdline_fixed_string_t set;
5718 cmdline_fixed_string_t link_down;
5719 cmdline_fixed_string_t port;
5723 cmdline_parse_token_string_t cmd_set_link_down_set =
5724 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5725 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5726 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5728 cmdline_parse_token_string_t cmd_set_link_down_port =
5729 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5730 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5731 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5733 static void cmd_set_link_down_parsed(
5734 __attribute__((unused)) void *parsed_result,
5735 __attribute__((unused)) struct cmdline *cl,
5736 __attribute__((unused)) void *data)
5738 struct cmd_set_link_down_result *res = parsed_result;
5739 dev_set_link_down(res->port_id);
5742 cmdline_parse_inst_t cmd_set_link_down = {
5743 .f = cmd_set_link_down_parsed,
5745 .help_str = "set link-down port <port id>",
5747 (void *)&cmd_set_link_down_set,
5748 (void *)&cmd_set_link_down_link_down,
5749 (void *)&cmd_set_link_down_port,
5750 (void *)&cmd_set_link_down_port_id,
5755 /* *** SHOW CFG *** */
5756 struct cmd_showcfg_result {
5757 cmdline_fixed_string_t show;
5758 cmdline_fixed_string_t cfg;
5759 cmdline_fixed_string_t what;
5762 static void cmd_showcfg_parsed(void *parsed_result,
5763 __attribute__((unused)) struct cmdline *cl,
5764 __attribute__((unused)) void *data)
5766 struct cmd_showcfg_result *res = parsed_result;
5767 if (!strcmp(res->what, "rxtx"))
5768 rxtx_config_display();
5769 else if (!strcmp(res->what, "cores"))
5770 fwd_lcores_config_display();
5771 else if (!strcmp(res->what, "fwd"))
5772 pkt_fwd_config_display(&cur_fwd_config);
5773 else if (!strcmp(res->what, "txpkts"))
5774 show_tx_pkt_segments();
5777 cmdline_parse_token_string_t cmd_showcfg_show =
5778 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5779 cmdline_parse_token_string_t cmd_showcfg_port =
5780 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5781 cmdline_parse_token_string_t cmd_showcfg_what =
5782 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5783 "rxtx#cores#fwd#txpkts");
5785 cmdline_parse_inst_t cmd_showcfg = {
5786 .f = cmd_showcfg_parsed,
5788 .help_str = "show config rxtx|cores|fwd|txpkts",
5790 (void *)&cmd_showcfg_show,
5791 (void *)&cmd_showcfg_port,
5792 (void *)&cmd_showcfg_what,
5797 /* *** SHOW ALL PORT INFO *** */
5798 struct cmd_showportall_result {
5799 cmdline_fixed_string_t show;
5800 cmdline_fixed_string_t port;
5801 cmdline_fixed_string_t what;
5802 cmdline_fixed_string_t all;
5805 static void cmd_showportall_parsed(void *parsed_result,
5806 __attribute__((unused)) struct cmdline *cl,
5807 __attribute__((unused)) void *data)
5811 struct cmd_showportall_result *res = parsed_result;
5812 if (!strcmp(res->show, "clear")) {
5813 if (!strcmp(res->what, "stats"))
5814 FOREACH_PORT(i, ports)
5816 else if (!strcmp(res->what, "xstats"))
5817 FOREACH_PORT(i, ports)
5818 nic_xstats_clear(i);
5819 } else if (!strcmp(res->what, "info"))
5820 FOREACH_PORT(i, ports)
5821 port_infos_display(i);
5822 else if (!strcmp(res->what, "stats"))
5823 FOREACH_PORT(i, ports)
5824 nic_stats_display(i);
5825 else if (!strcmp(res->what, "xstats"))
5826 FOREACH_PORT(i, ports)
5827 nic_xstats_display(i);
5828 else if (!strcmp(res->what, "fdir"))
5829 FOREACH_PORT(i, ports)
5831 else if (!strcmp(res->what, "stat_qmap"))
5832 FOREACH_PORT(i, ports)
5833 nic_stats_mapping_display(i);
5834 else if (!strcmp(res->what, "dcb_tc"))
5835 FOREACH_PORT(i, ports)
5836 port_dcb_info_display(i);
5839 cmdline_parse_token_string_t cmd_showportall_show =
5840 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5842 cmdline_parse_token_string_t cmd_showportall_port =
5843 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5844 cmdline_parse_token_string_t cmd_showportall_what =
5845 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5846 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5847 cmdline_parse_token_string_t cmd_showportall_all =
5848 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5849 cmdline_parse_inst_t cmd_showportall = {
5850 .f = cmd_showportall_parsed,
5852 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5854 (void *)&cmd_showportall_show,
5855 (void *)&cmd_showportall_port,
5856 (void *)&cmd_showportall_what,
5857 (void *)&cmd_showportall_all,
5862 /* *** SHOW PORT INFO *** */
5863 struct cmd_showport_result {
5864 cmdline_fixed_string_t show;
5865 cmdline_fixed_string_t port;
5866 cmdline_fixed_string_t what;
5870 static void cmd_showport_parsed(void *parsed_result,
5871 __attribute__((unused)) struct cmdline *cl,
5872 __attribute__((unused)) void *data)
5874 struct cmd_showport_result *res = parsed_result;
5875 if (!strcmp(res->show, "clear")) {
5876 if (!strcmp(res->what, "stats"))
5877 nic_stats_clear(res->portnum);
5878 else if (!strcmp(res->what, "xstats"))
5879 nic_xstats_clear(res->portnum);
5880 } else if (!strcmp(res->what, "info"))
5881 port_infos_display(res->portnum);
5882 else if (!strcmp(res->what, "stats"))
5883 nic_stats_display(res->portnum);
5884 else if (!strcmp(res->what, "xstats"))
5885 nic_xstats_display(res->portnum);
5886 else if (!strcmp(res->what, "fdir"))
5887 fdir_get_infos(res->portnum);
5888 else if (!strcmp(res->what, "stat_qmap"))
5889 nic_stats_mapping_display(res->portnum);
5890 else if (!strcmp(res->what, "dcb_tc"))
5891 port_dcb_info_display(res->portnum);
5894 cmdline_parse_token_string_t cmd_showport_show =
5895 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5897 cmdline_parse_token_string_t cmd_showport_port =
5898 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5899 cmdline_parse_token_string_t cmd_showport_what =
5900 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5901 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5902 cmdline_parse_token_num_t cmd_showport_portnum =
5903 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5905 cmdline_parse_inst_t cmd_showport = {
5906 .f = cmd_showport_parsed,
5908 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5911 (void *)&cmd_showport_show,
5912 (void *)&cmd_showport_port,
5913 (void *)&cmd_showport_what,
5914 (void *)&cmd_showport_portnum,
5919 /* *** SHOW QUEUE INFO *** */
5920 struct cmd_showqueue_result {
5921 cmdline_fixed_string_t show;
5922 cmdline_fixed_string_t type;
5923 cmdline_fixed_string_t what;
5929 cmd_showqueue_parsed(void *parsed_result,
5930 __attribute__((unused)) struct cmdline *cl,
5931 __attribute__((unused)) void *data)
5933 struct cmd_showqueue_result *res = parsed_result;
5935 if (!strcmp(res->type, "rxq"))
5936 rx_queue_infos_display(res->portnum, res->queuenum);
5937 else if (!strcmp(res->type, "txq"))
5938 tx_queue_infos_display(res->portnum, res->queuenum);
5941 cmdline_parse_token_string_t cmd_showqueue_show =
5942 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5943 cmdline_parse_token_string_t cmd_showqueue_type =
5944 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5945 cmdline_parse_token_string_t cmd_showqueue_what =
5946 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5947 cmdline_parse_token_num_t cmd_showqueue_portnum =
5948 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5949 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5950 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5952 cmdline_parse_inst_t cmd_showqueue = {
5953 .f = cmd_showqueue_parsed,
5955 .help_str = "show rxq|txq info <port_id> <queue_id>",
5957 (void *)&cmd_showqueue_show,
5958 (void *)&cmd_showqueue_type,
5959 (void *)&cmd_showqueue_what,
5960 (void *)&cmd_showqueue_portnum,
5961 (void *)&cmd_showqueue_queuenum,
5966 /* *** READ PORT REGISTER *** */
5967 struct cmd_read_reg_result {
5968 cmdline_fixed_string_t read;
5969 cmdline_fixed_string_t reg;
5975 cmd_read_reg_parsed(void *parsed_result,
5976 __attribute__((unused)) struct cmdline *cl,
5977 __attribute__((unused)) void *data)
5979 struct cmd_read_reg_result *res = parsed_result;
5980 port_reg_display(res->port_id, res->reg_off);
5983 cmdline_parse_token_string_t cmd_read_reg_read =
5984 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5985 cmdline_parse_token_string_t cmd_read_reg_reg =
5986 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5987 cmdline_parse_token_num_t cmd_read_reg_port_id =
5988 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5989 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5990 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5992 cmdline_parse_inst_t cmd_read_reg = {
5993 .f = cmd_read_reg_parsed,
5995 .help_str = "read reg <port_id> <reg_off>",
5997 (void *)&cmd_read_reg_read,
5998 (void *)&cmd_read_reg_reg,
5999 (void *)&cmd_read_reg_port_id,
6000 (void *)&cmd_read_reg_reg_off,
6005 /* *** READ PORT REGISTER BIT FIELD *** */
6006 struct cmd_read_reg_bit_field_result {
6007 cmdline_fixed_string_t read;
6008 cmdline_fixed_string_t regfield;
6016 cmd_read_reg_bit_field_parsed(void *parsed_result,
6017 __attribute__((unused)) struct cmdline *cl,
6018 __attribute__((unused)) void *data)
6020 struct cmd_read_reg_bit_field_result *res = parsed_result;
6021 port_reg_bit_field_display(res->port_id, res->reg_off,
6022 res->bit1_pos, res->bit2_pos);
6025 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6026 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6028 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6029 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6030 regfield, "regfield");
6031 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6032 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6034 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6035 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6037 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6038 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6040 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6041 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6044 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6045 .f = cmd_read_reg_bit_field_parsed,
6047 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6048 "Read register bit field between bit_x and bit_y included",
6050 (void *)&cmd_read_reg_bit_field_read,
6051 (void *)&cmd_read_reg_bit_field_regfield,
6052 (void *)&cmd_read_reg_bit_field_port_id,
6053 (void *)&cmd_read_reg_bit_field_reg_off,
6054 (void *)&cmd_read_reg_bit_field_bit1_pos,
6055 (void *)&cmd_read_reg_bit_field_bit2_pos,
6060 /* *** READ PORT REGISTER BIT *** */
6061 struct cmd_read_reg_bit_result {
6062 cmdline_fixed_string_t read;
6063 cmdline_fixed_string_t regbit;
6070 cmd_read_reg_bit_parsed(void *parsed_result,
6071 __attribute__((unused)) struct cmdline *cl,
6072 __attribute__((unused)) void *data)
6074 struct cmd_read_reg_bit_result *res = parsed_result;
6075 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6078 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6079 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6080 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6081 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6083 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6084 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6085 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6086 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6087 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6088 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6090 cmdline_parse_inst_t cmd_read_reg_bit = {
6091 .f = cmd_read_reg_bit_parsed,
6093 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6095 (void *)&cmd_read_reg_bit_read,
6096 (void *)&cmd_read_reg_bit_regbit,
6097 (void *)&cmd_read_reg_bit_port_id,
6098 (void *)&cmd_read_reg_bit_reg_off,
6099 (void *)&cmd_read_reg_bit_bit_pos,
6104 /* *** WRITE PORT REGISTER *** */
6105 struct cmd_write_reg_result {
6106 cmdline_fixed_string_t write;
6107 cmdline_fixed_string_t reg;
6114 cmd_write_reg_parsed(void *parsed_result,
6115 __attribute__((unused)) struct cmdline *cl,
6116 __attribute__((unused)) void *data)
6118 struct cmd_write_reg_result *res = parsed_result;
6119 port_reg_set(res->port_id, res->reg_off, res->value);
6122 cmdline_parse_token_string_t cmd_write_reg_write =
6123 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6124 cmdline_parse_token_string_t cmd_write_reg_reg =
6125 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6126 cmdline_parse_token_num_t cmd_write_reg_port_id =
6127 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6128 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6129 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6130 cmdline_parse_token_num_t cmd_write_reg_value =
6131 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6133 cmdline_parse_inst_t cmd_write_reg = {
6134 .f = cmd_write_reg_parsed,
6136 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6138 (void *)&cmd_write_reg_write,
6139 (void *)&cmd_write_reg_reg,
6140 (void *)&cmd_write_reg_port_id,
6141 (void *)&cmd_write_reg_reg_off,
6142 (void *)&cmd_write_reg_value,
6147 /* *** WRITE PORT REGISTER BIT FIELD *** */
6148 struct cmd_write_reg_bit_field_result {
6149 cmdline_fixed_string_t write;
6150 cmdline_fixed_string_t regfield;
6159 cmd_write_reg_bit_field_parsed(void *parsed_result,
6160 __attribute__((unused)) struct cmdline *cl,
6161 __attribute__((unused)) void *data)
6163 struct cmd_write_reg_bit_field_result *res = parsed_result;
6164 port_reg_bit_field_set(res->port_id, res->reg_off,
6165 res->bit1_pos, res->bit2_pos, res->value);
6168 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6169 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6171 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6172 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6173 regfield, "regfield");
6174 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6175 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6177 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6178 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6180 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6181 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6183 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6184 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6186 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6187 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6190 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6191 .f = cmd_write_reg_bit_field_parsed,
6193 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6195 "Set register bit field between bit_x and bit_y included",
6197 (void *)&cmd_write_reg_bit_field_write,
6198 (void *)&cmd_write_reg_bit_field_regfield,
6199 (void *)&cmd_write_reg_bit_field_port_id,
6200 (void *)&cmd_write_reg_bit_field_reg_off,
6201 (void *)&cmd_write_reg_bit_field_bit1_pos,
6202 (void *)&cmd_write_reg_bit_field_bit2_pos,
6203 (void *)&cmd_write_reg_bit_field_value,
6208 /* *** WRITE PORT REGISTER BIT *** */
6209 struct cmd_write_reg_bit_result {
6210 cmdline_fixed_string_t write;
6211 cmdline_fixed_string_t regbit;
6219 cmd_write_reg_bit_parsed(void *parsed_result,
6220 __attribute__((unused)) struct cmdline *cl,
6221 __attribute__((unused)) void *data)
6223 struct cmd_write_reg_bit_result *res = parsed_result;
6224 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6227 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6228 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6230 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6231 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6233 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6234 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6235 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6236 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6237 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6238 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6239 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6240 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6242 cmdline_parse_inst_t cmd_write_reg_bit = {
6243 .f = cmd_write_reg_bit_parsed,
6245 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6248 (void *)&cmd_write_reg_bit_write,
6249 (void *)&cmd_write_reg_bit_regbit,
6250 (void *)&cmd_write_reg_bit_port_id,
6251 (void *)&cmd_write_reg_bit_reg_off,
6252 (void *)&cmd_write_reg_bit_bit_pos,
6253 (void *)&cmd_write_reg_bit_value,
6258 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6259 struct cmd_read_rxd_txd_result {
6260 cmdline_fixed_string_t read;
6261 cmdline_fixed_string_t rxd_txd;
6268 cmd_read_rxd_txd_parsed(void *parsed_result,
6269 __attribute__((unused)) struct cmdline *cl,
6270 __attribute__((unused)) void *data)
6272 struct cmd_read_rxd_txd_result *res = parsed_result;
6274 if (!strcmp(res->rxd_txd, "rxd"))
6275 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6276 else if (!strcmp(res->rxd_txd, "txd"))
6277 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6280 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6281 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6282 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6283 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6285 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6286 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6287 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6288 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6289 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6290 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6292 cmdline_parse_inst_t cmd_read_rxd_txd = {
6293 .f = cmd_read_rxd_txd_parsed,
6295 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6297 (void *)&cmd_read_rxd_txd_read,
6298 (void *)&cmd_read_rxd_txd_rxd_txd,
6299 (void *)&cmd_read_rxd_txd_port_id,
6300 (void *)&cmd_read_rxd_txd_queue_id,
6301 (void *)&cmd_read_rxd_txd_desc_id,
6307 struct cmd_quit_result {
6308 cmdline_fixed_string_t quit;
6311 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6313 __attribute__((unused)) void *data)
6319 cmdline_parse_token_string_t cmd_quit_quit =
6320 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6322 cmdline_parse_inst_t cmd_quit = {
6323 .f = cmd_quit_parsed,
6325 .help_str = "quit: Exit application",
6327 (void *)&cmd_quit_quit,
6332 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6333 struct cmd_mac_addr_result {
6334 cmdline_fixed_string_t mac_addr_cmd;
6335 cmdline_fixed_string_t what;
6337 struct ether_addr address;
6340 static void cmd_mac_addr_parsed(void *parsed_result,
6341 __attribute__((unused)) struct cmdline *cl,
6342 __attribute__((unused)) void *data)
6344 struct cmd_mac_addr_result *res = parsed_result;
6347 if (strcmp(res->what, "add") == 0)
6348 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6350 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6352 /* check the return value and print it if is < 0 */
6354 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6358 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6359 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6361 cmdline_parse_token_string_t cmd_mac_addr_what =
6362 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6364 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6365 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6366 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6367 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6369 cmdline_parse_inst_t cmd_mac_addr = {
6370 .f = cmd_mac_addr_parsed,
6372 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6373 "Add/Remove MAC address on port_id",
6375 (void *)&cmd_mac_addr_cmd,
6376 (void *)&cmd_mac_addr_what,
6377 (void *)&cmd_mac_addr_portnum,
6378 (void *)&cmd_mac_addr_addr,
6384 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6385 struct cmd_set_qmap_result {
6386 cmdline_fixed_string_t set;
6387 cmdline_fixed_string_t qmap;
6388 cmdline_fixed_string_t what;
6395 cmd_set_qmap_parsed(void *parsed_result,
6396 __attribute__((unused)) struct cmdline *cl,
6397 __attribute__((unused)) void *data)
6399 struct cmd_set_qmap_result *res = parsed_result;
6400 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6402 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6405 cmdline_parse_token_string_t cmd_setqmap_set =
6406 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6408 cmdline_parse_token_string_t cmd_setqmap_qmap =
6409 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6411 cmdline_parse_token_string_t cmd_setqmap_what =
6412 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6414 cmdline_parse_token_num_t cmd_setqmap_portid =
6415 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6417 cmdline_parse_token_num_t cmd_setqmap_queueid =
6418 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6420 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6421 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6424 cmdline_parse_inst_t cmd_set_qmap = {
6425 .f = cmd_set_qmap_parsed,
6427 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6428 "Set statistics mapping value on tx|rx queue_id of port_id",
6430 (void *)&cmd_setqmap_set,
6431 (void *)&cmd_setqmap_qmap,
6432 (void *)&cmd_setqmap_what,
6433 (void *)&cmd_setqmap_portid,
6434 (void *)&cmd_setqmap_queueid,
6435 (void *)&cmd_setqmap_mapvalue,
6440 /* *** CONFIGURE UNICAST HASH TABLE *** */
6441 struct cmd_set_uc_hash_table {
6442 cmdline_fixed_string_t set;
6443 cmdline_fixed_string_t port;
6445 cmdline_fixed_string_t what;
6446 struct ether_addr address;
6447 cmdline_fixed_string_t mode;
6451 cmd_set_uc_hash_parsed(void *parsed_result,
6452 __attribute__((unused)) struct cmdline *cl,
6453 __attribute__((unused)) void *data)
6456 struct cmd_set_uc_hash_table *res = parsed_result;
6458 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6460 if (strcmp(res->what, "uta") == 0)
6461 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6462 &res->address,(uint8_t)is_on);
6464 printf("bad unicast hash table parameter, return code = %d \n", ret);
6468 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6469 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6471 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6474 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6475 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6477 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6480 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6481 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6483 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6487 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6488 .f = cmd_set_uc_hash_parsed,
6490 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6492 (void *)&cmd_set_uc_hash_set,
6493 (void *)&cmd_set_uc_hash_port,
6494 (void *)&cmd_set_uc_hash_portid,
6495 (void *)&cmd_set_uc_hash_what,
6496 (void *)&cmd_set_uc_hash_mac,
6497 (void *)&cmd_set_uc_hash_mode,
6502 struct cmd_set_uc_all_hash_table {
6503 cmdline_fixed_string_t set;
6504 cmdline_fixed_string_t port;
6506 cmdline_fixed_string_t what;
6507 cmdline_fixed_string_t value;
6508 cmdline_fixed_string_t mode;
6512 cmd_set_uc_all_hash_parsed(void *parsed_result,
6513 __attribute__((unused)) struct cmdline *cl,
6514 __attribute__((unused)) void *data)
6517 struct cmd_set_uc_all_hash_table *res = parsed_result;
6519 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6521 if ((strcmp(res->what, "uta") == 0) &&
6522 (strcmp(res->value, "all") == 0))
6523 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6525 printf("bad unicast hash table parameter,"
6526 "return code = %d \n", ret);
6529 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6530 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6532 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6533 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6535 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6536 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6538 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6539 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6541 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6542 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6544 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6548 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6549 .f = cmd_set_uc_all_hash_parsed,
6551 .help_str = "set port <port_id> uta all on|off",
6553 (void *)&cmd_set_uc_all_hash_set,
6554 (void *)&cmd_set_uc_all_hash_port,
6555 (void *)&cmd_set_uc_all_hash_portid,
6556 (void *)&cmd_set_uc_all_hash_what,
6557 (void *)&cmd_set_uc_all_hash_value,
6558 (void *)&cmd_set_uc_all_hash_mode,
6563 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6564 struct cmd_set_vf_macvlan_filter {
6565 cmdline_fixed_string_t set;
6566 cmdline_fixed_string_t port;
6568 cmdline_fixed_string_t vf;
6570 struct ether_addr address;
6571 cmdline_fixed_string_t filter_type;
6572 cmdline_fixed_string_t mode;
6576 cmd_set_vf_macvlan_parsed(void *parsed_result,
6577 __attribute__((unused)) struct cmdline *cl,
6578 __attribute__((unused)) void *data)
6581 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6582 struct rte_eth_mac_filter filter;
6584 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6586 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6588 /* set VF MAC filter */
6592 filter.dst_id = res->vf_id;
6594 if (!strcmp(res->filter_type, "exact-mac"))
6595 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6596 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6597 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6598 else if (!strcmp(res->filter_type, "hashmac"))
6599 filter.filter_type = RTE_MAC_HASH_MATCH;
6600 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6601 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6603 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6606 ret = rte_eth_dev_filter_ctrl(res->port_id,
6607 RTE_ETH_FILTER_MACVLAN,
6611 ret = rte_eth_dev_filter_ctrl(res->port_id,
6612 RTE_ETH_FILTER_MACVLAN,
6613 RTE_ETH_FILTER_DELETE,
6617 printf("bad set MAC hash parameter, return code = %d\n", ret);
6621 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6624 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6625 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6627 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6628 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6630 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6631 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6633 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6634 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6636 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6637 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6639 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6640 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6641 filter_type, "exact-mac#exact-mac-vlan"
6642 "#hashmac#hashmac-vlan");
6643 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6644 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6647 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6648 .f = cmd_set_vf_macvlan_parsed,
6650 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6651 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6652 "Exact match rule: exact match of MAC or MAC and VLAN; "
6653 "hash match rule: hash match of MAC and exact match of VLAN",
6655 (void *)&cmd_set_vf_macvlan_set,
6656 (void *)&cmd_set_vf_macvlan_port,
6657 (void *)&cmd_set_vf_macvlan_portid,
6658 (void *)&cmd_set_vf_macvlan_vf,
6659 (void *)&cmd_set_vf_macvlan_vf_id,
6660 (void *)&cmd_set_vf_macvlan_mac,
6661 (void *)&cmd_set_vf_macvlan_filter_type,
6662 (void *)&cmd_set_vf_macvlan_mode,
6667 #ifdef RTE_LIBRTE_IXGBE_PMD
6668 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6669 struct cmd_set_vf_traffic {
6670 cmdline_fixed_string_t set;
6671 cmdline_fixed_string_t port;
6673 cmdline_fixed_string_t vf;
6675 cmdline_fixed_string_t what;
6676 cmdline_fixed_string_t mode;
6680 cmd_set_vf_traffic_parsed(void *parsed_result,
6681 __attribute__((unused)) struct cmdline *cl,
6682 __attribute__((unused)) void *data)
6684 struct cmd_set_vf_traffic *res = parsed_result;
6685 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6686 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6688 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6691 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6692 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6694 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6695 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6697 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6698 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6700 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6701 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6703 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6704 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6706 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6707 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6709 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6710 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6713 cmdline_parse_inst_t cmd_set_vf_traffic = {
6714 .f = cmd_set_vf_traffic_parsed,
6716 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6718 (void *)&cmd_setvf_traffic_set,
6719 (void *)&cmd_setvf_traffic_port,
6720 (void *)&cmd_setvf_traffic_portid,
6721 (void *)&cmd_setvf_traffic_vf,
6722 (void *)&cmd_setvf_traffic_vfid,
6723 (void *)&cmd_setvf_traffic_what,
6724 (void *)&cmd_setvf_traffic_mode,
6729 /* *** CONFIGURE VF RECEIVE MODE *** */
6730 struct cmd_set_vf_rxmode {
6731 cmdline_fixed_string_t set;
6732 cmdline_fixed_string_t port;
6734 cmdline_fixed_string_t vf;
6736 cmdline_fixed_string_t what;
6737 cmdline_fixed_string_t mode;
6738 cmdline_fixed_string_t on;
6742 cmd_set_vf_rxmode_parsed(void *parsed_result,
6743 __attribute__((unused)) struct cmdline *cl,
6744 __attribute__((unused)) void *data)
6747 uint16_t rx_mode = 0;
6748 struct cmd_set_vf_rxmode *res = parsed_result;
6750 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6751 if (!strcmp(res->what,"rxmode")) {
6752 if (!strcmp(res->mode, "AUPE"))
6753 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6754 else if (!strcmp(res->mode, "ROPE"))
6755 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6756 else if (!strcmp(res->mode, "BAM"))
6757 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6758 else if (!strncmp(res->mode, "MPE",3))
6759 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6762 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6764 printf("bad VF receive mode parameter, return code = %d \n",
6768 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6769 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6771 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6774 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6775 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6777 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6778 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6780 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6781 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6783 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6784 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6786 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6787 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6788 mode, "AUPE#ROPE#BAM#MPE");
6789 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6790 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6793 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6794 .f = cmd_set_vf_rxmode_parsed,
6796 .help_str = "set port <port_id> vf <vf_id> rxmode "
6797 "AUPE|ROPE|BAM|MPE on|off",
6799 (void *)&cmd_set_vf_rxmode_set,
6800 (void *)&cmd_set_vf_rxmode_port,
6801 (void *)&cmd_set_vf_rxmode_portid,
6802 (void *)&cmd_set_vf_rxmode_vf,
6803 (void *)&cmd_set_vf_rxmode_vfid,
6804 (void *)&cmd_set_vf_rxmode_what,
6805 (void *)&cmd_set_vf_rxmode_mode,
6806 (void *)&cmd_set_vf_rxmode_on,
6812 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6813 struct cmd_vf_mac_addr_result {
6814 cmdline_fixed_string_t mac_addr_cmd;
6815 cmdline_fixed_string_t what;
6816 cmdline_fixed_string_t port;
6818 cmdline_fixed_string_t vf;
6820 struct ether_addr address;
6823 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6824 __attribute__((unused)) struct cmdline *cl,
6825 __attribute__((unused)) void *data)
6827 struct cmd_vf_mac_addr_result *res = parsed_result;
6830 if (strcmp(res->what, "add") == 0)
6831 ret = rte_eth_dev_mac_addr_add(res->port_num,
6832 &res->address, res->vf_num);
6834 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6838 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6839 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6840 mac_addr_cmd,"mac_addr");
6841 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6842 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6844 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6845 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6847 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6848 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6850 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6851 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6853 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6854 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6856 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6857 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6860 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6861 .f = cmd_vf_mac_addr_parsed,
6863 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6864 "Add MAC address filtering for a VF on port_id",
6866 (void *)&cmd_vf_mac_addr_cmd,
6867 (void *)&cmd_vf_mac_addr_what,
6868 (void *)&cmd_vf_mac_addr_port,
6869 (void *)&cmd_vf_mac_addr_portnum,
6870 (void *)&cmd_vf_mac_addr_vf,
6871 (void *)&cmd_vf_mac_addr_vfnum,
6872 (void *)&cmd_vf_mac_addr_addr,
6877 #ifdef RTE_LIBRTE_IXGBE_PMD
6878 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6879 struct cmd_vf_rx_vlan_filter {
6880 cmdline_fixed_string_t rx_vlan;
6881 cmdline_fixed_string_t what;
6883 cmdline_fixed_string_t port;
6885 cmdline_fixed_string_t vf;
6890 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6891 __attribute__((unused)) struct cmdline *cl,
6892 __attribute__((unused)) void *data)
6894 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6896 if (!strcmp(res->what, "add"))
6897 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6899 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6902 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6903 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6904 rx_vlan, "rx_vlan");
6905 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6906 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6908 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6909 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6911 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6912 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6914 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6915 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6917 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6918 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6920 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6921 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6924 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6925 .f = cmd_vf_rx_vlan_filter_parsed,
6927 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6928 "(vf_mask = hexadecimal VF mask)",
6930 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6931 (void *)&cmd_vf_rx_vlan_filter_what,
6932 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6933 (void *)&cmd_vf_rx_vlan_filter_port,
6934 (void *)&cmd_vf_rx_vlan_filter_portid,
6935 (void *)&cmd_vf_rx_vlan_filter_vf,
6936 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6942 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6943 struct cmd_queue_rate_limit_result {
6944 cmdline_fixed_string_t set;
6945 cmdline_fixed_string_t port;
6947 cmdline_fixed_string_t queue;
6949 cmdline_fixed_string_t rate;
6953 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6954 __attribute__((unused)) struct cmdline *cl,
6955 __attribute__((unused)) void *data)
6957 struct cmd_queue_rate_limit_result *res = parsed_result;
6960 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6961 && (strcmp(res->queue, "queue") == 0)
6962 && (strcmp(res->rate, "rate") == 0))
6963 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6966 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6970 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6971 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6973 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6974 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6976 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6977 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6979 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6980 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6982 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6983 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6985 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6986 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6988 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6989 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6992 cmdline_parse_inst_t cmd_queue_rate_limit = {
6993 .f = cmd_queue_rate_limit_parsed,
6995 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6996 "Set rate limit for a queue on port_id",
6998 (void *)&cmd_queue_rate_limit_set,
6999 (void *)&cmd_queue_rate_limit_port,
7000 (void *)&cmd_queue_rate_limit_portnum,
7001 (void *)&cmd_queue_rate_limit_queue,
7002 (void *)&cmd_queue_rate_limit_queuenum,
7003 (void *)&cmd_queue_rate_limit_rate,
7004 (void *)&cmd_queue_rate_limit_ratenum,
7009 #ifdef RTE_LIBRTE_IXGBE_PMD
7010 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7011 struct cmd_vf_rate_limit_result {
7012 cmdline_fixed_string_t set;
7013 cmdline_fixed_string_t port;
7015 cmdline_fixed_string_t vf;
7017 cmdline_fixed_string_t rate;
7019 cmdline_fixed_string_t q_msk;
7023 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7024 __attribute__((unused)) struct cmdline *cl,
7025 __attribute__((unused)) void *data)
7027 struct cmd_vf_rate_limit_result *res = parsed_result;
7030 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7031 && (strcmp(res->vf, "vf") == 0)
7032 && (strcmp(res->rate, "rate") == 0)
7033 && (strcmp(res->q_msk, "queue_mask") == 0))
7034 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7035 res->rate_num, res->q_msk_val);
7037 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7041 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7042 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7044 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7045 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7047 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7048 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7050 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7051 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7053 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7054 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7056 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7057 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7059 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7060 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7062 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7063 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7064 q_msk, "queue_mask");
7065 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7066 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7069 cmdline_parse_inst_t cmd_vf_rate_limit = {
7070 .f = cmd_vf_rate_limit_parsed,
7072 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7073 "queue_mask <queue_mask_value>: "
7074 "Set rate limit for queues of VF on port_id",
7076 (void *)&cmd_vf_rate_limit_set,
7077 (void *)&cmd_vf_rate_limit_port,
7078 (void *)&cmd_vf_rate_limit_portnum,
7079 (void *)&cmd_vf_rate_limit_vf,
7080 (void *)&cmd_vf_rate_limit_vfnum,
7081 (void *)&cmd_vf_rate_limit_rate,
7082 (void *)&cmd_vf_rate_limit_ratenum,
7083 (void *)&cmd_vf_rate_limit_q_msk,
7084 (void *)&cmd_vf_rate_limit_q_msk_val,
7090 /* *** ADD TUNNEL FILTER OF A PORT *** */
7091 struct cmd_tunnel_filter_result {
7092 cmdline_fixed_string_t cmd;
7093 cmdline_fixed_string_t what;
7095 struct ether_addr outer_mac;
7096 struct ether_addr inner_mac;
7097 cmdline_ipaddr_t ip_value;
7098 uint16_t inner_vlan;
7099 cmdline_fixed_string_t tunnel_type;
7100 cmdline_fixed_string_t filter_type;
7106 cmd_tunnel_filter_parsed(void *parsed_result,
7107 __attribute__((unused)) struct cmdline *cl,
7108 __attribute__((unused)) void *data)
7110 struct cmd_tunnel_filter_result *res = parsed_result;
7111 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7114 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7116 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7117 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7118 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7120 if (res->ip_value.family == AF_INET) {
7121 tunnel_filter_conf.ip_addr.ipv4_addr =
7122 res->ip_value.addr.ipv4.s_addr;
7123 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7125 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7126 &(res->ip_value.addr.ipv6),
7127 sizeof(struct in6_addr));
7128 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7131 if (!strcmp(res->filter_type, "imac-ivlan"))
7132 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7133 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7134 tunnel_filter_conf.filter_type =
7135 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7136 else if (!strcmp(res->filter_type, "imac-tenid"))
7137 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7138 else if (!strcmp(res->filter_type, "imac"))
7139 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7140 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7141 tunnel_filter_conf.filter_type =
7142 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7143 else if (!strcmp(res->filter_type, "oip"))
7144 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7145 else if (!strcmp(res->filter_type, "iip"))
7146 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7148 printf("The filter type is not supported");
7152 if (!strcmp(res->tunnel_type, "vxlan"))
7153 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7154 else if (!strcmp(res->tunnel_type, "nvgre"))
7155 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7156 else if (!strcmp(res->tunnel_type, "ipingre"))
7157 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7159 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7163 tunnel_filter_conf.tenant_id = res->tenant_id;
7164 tunnel_filter_conf.queue_id = res->queue_num;
7165 if (!strcmp(res->what, "add"))
7166 ret = rte_eth_dev_filter_ctrl(res->port_id,
7167 RTE_ETH_FILTER_TUNNEL,
7169 &tunnel_filter_conf);
7171 ret = rte_eth_dev_filter_ctrl(res->port_id,
7172 RTE_ETH_FILTER_TUNNEL,
7173 RTE_ETH_FILTER_DELETE,
7174 &tunnel_filter_conf);
7176 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7180 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7181 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7182 cmd, "tunnel_filter");
7183 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7184 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7186 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7187 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7189 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7190 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7192 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7193 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7195 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7196 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7197 inner_vlan, UINT16);
7198 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7199 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7201 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7202 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7203 tunnel_type, "vxlan#nvgre#ipingre");
7205 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7206 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7207 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7208 "imac#omac-imac-tenid");
7209 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7210 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7212 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7213 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7216 cmdline_parse_inst_t cmd_tunnel_filter = {
7217 .f = cmd_tunnel_filter_parsed,
7219 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7220 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7221 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7222 "<queue_id>: Add/Rm tunnel filter of a port",
7224 (void *)&cmd_tunnel_filter_cmd,
7225 (void *)&cmd_tunnel_filter_what,
7226 (void *)&cmd_tunnel_filter_port_id,
7227 (void *)&cmd_tunnel_filter_outer_mac,
7228 (void *)&cmd_tunnel_filter_inner_mac,
7229 (void *)&cmd_tunnel_filter_ip_value,
7230 (void *)&cmd_tunnel_filter_innner_vlan,
7231 (void *)&cmd_tunnel_filter_tunnel_type,
7232 (void *)&cmd_tunnel_filter_filter_type,
7233 (void *)&cmd_tunnel_filter_tenant_id,
7234 (void *)&cmd_tunnel_filter_queue_num,
7239 /* *** CONFIGURE TUNNEL UDP PORT *** */
7240 struct cmd_tunnel_udp_config {
7241 cmdline_fixed_string_t cmd;
7242 cmdline_fixed_string_t what;
7248 cmd_tunnel_udp_config_parsed(void *parsed_result,
7249 __attribute__((unused)) struct cmdline *cl,
7250 __attribute__((unused)) void *data)
7252 struct cmd_tunnel_udp_config *res = parsed_result;
7253 struct rte_eth_udp_tunnel tunnel_udp;
7256 tunnel_udp.udp_port = res->udp_port;
7258 if (!strcmp(res->cmd, "rx_vxlan_port"))
7259 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7261 if (!strcmp(res->what, "add"))
7262 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7265 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7269 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7272 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7273 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7274 cmd, "rx_vxlan_port");
7275 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7276 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7278 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7279 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7281 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7282 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7285 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7286 .f = cmd_tunnel_udp_config_parsed,
7288 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7289 "Add/Remove a tunneling UDP port filter",
7291 (void *)&cmd_tunnel_udp_config_cmd,
7292 (void *)&cmd_tunnel_udp_config_what,
7293 (void *)&cmd_tunnel_udp_config_udp_port,
7294 (void *)&cmd_tunnel_udp_config_port_id,
7299 /* *** GLOBAL CONFIG *** */
7300 struct cmd_global_config_result {
7301 cmdline_fixed_string_t cmd;
7303 cmdline_fixed_string_t cfg_type;
7308 cmd_global_config_parsed(void *parsed_result,
7309 __attribute__((unused)) struct cmdline *cl,
7310 __attribute__((unused)) void *data)
7312 struct cmd_global_config_result *res = parsed_result;
7313 struct rte_eth_global_cfg conf;
7316 memset(&conf, 0, sizeof(conf));
7317 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7318 conf.cfg.gre_key_len = res->len;
7319 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7320 RTE_ETH_FILTER_SET, &conf);
7322 printf("Global config error\n");
7325 cmdline_parse_token_string_t cmd_global_config_cmd =
7326 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7328 cmdline_parse_token_num_t cmd_global_config_port_id =
7329 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7330 cmdline_parse_token_string_t cmd_global_config_type =
7331 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7332 cfg_type, "gre-key-len");
7333 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7334 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7337 cmdline_parse_inst_t cmd_global_config = {
7338 .f = cmd_global_config_parsed,
7339 .data = (void *)NULL,
7340 .help_str = "global_config <port_id> gre-key-len <key_len>",
7342 (void *)&cmd_global_config_cmd,
7343 (void *)&cmd_global_config_port_id,
7344 (void *)&cmd_global_config_type,
7345 (void *)&cmd_global_config_gre_key_len,
7350 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7351 struct cmd_set_mirror_mask_result {
7352 cmdline_fixed_string_t set;
7353 cmdline_fixed_string_t port;
7355 cmdline_fixed_string_t mirror;
7357 cmdline_fixed_string_t what;
7358 cmdline_fixed_string_t value;
7359 cmdline_fixed_string_t dstpool;
7361 cmdline_fixed_string_t on;
7364 cmdline_parse_token_string_t cmd_mirror_mask_set =
7365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7367 cmdline_parse_token_string_t cmd_mirror_mask_port =
7368 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7370 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7371 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7373 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7374 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7375 mirror, "mirror-rule");
7376 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7377 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7379 cmdline_parse_token_string_t cmd_mirror_mask_what =
7380 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7381 what, "pool-mirror-up#pool-mirror-down"
7383 cmdline_parse_token_string_t cmd_mirror_mask_value =
7384 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7386 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7387 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7388 dstpool, "dst-pool");
7389 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7390 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7392 cmdline_parse_token_string_t cmd_mirror_mask_on =
7393 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7397 cmd_set_mirror_mask_parsed(void *parsed_result,
7398 __attribute__((unused)) struct cmdline *cl,
7399 __attribute__((unused)) void *data)
7402 struct cmd_set_mirror_mask_result *res = parsed_result;
7403 struct rte_eth_mirror_conf mr_conf;
7405 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7407 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7409 mr_conf.dst_pool = res->dstpool_id;
7411 if (!strcmp(res->what, "pool-mirror-up")) {
7412 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7413 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7414 } else if (!strcmp(res->what, "pool-mirror-down")) {
7415 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7416 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7417 } else if (!strcmp(res->what, "vlan-mirror")) {
7418 mr_conf.rule_type = ETH_MIRROR_VLAN;
7419 nb_item = parse_item_list(res->value, "vlan",
7420 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7424 for (i = 0; i < nb_item; i++) {
7425 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7426 printf("Invalid vlan_id: must be < 4096\n");
7430 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7431 mr_conf.vlan.vlan_mask |= 1ULL << i;
7435 if (!strcmp(res->on, "on"))
7436 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7439 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7442 printf("mirror rule add error: (%s)\n", strerror(-ret));
7445 cmdline_parse_inst_t cmd_set_mirror_mask = {
7446 .f = cmd_set_mirror_mask_parsed,
7448 .help_str = "set port <port_id> mirror-rule <rule_id> "
7449 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7450 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7452 (void *)&cmd_mirror_mask_set,
7453 (void *)&cmd_mirror_mask_port,
7454 (void *)&cmd_mirror_mask_portid,
7455 (void *)&cmd_mirror_mask_mirror,
7456 (void *)&cmd_mirror_mask_ruleid,
7457 (void *)&cmd_mirror_mask_what,
7458 (void *)&cmd_mirror_mask_value,
7459 (void *)&cmd_mirror_mask_dstpool,
7460 (void *)&cmd_mirror_mask_poolid,
7461 (void *)&cmd_mirror_mask_on,
7466 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7467 struct cmd_set_mirror_link_result {
7468 cmdline_fixed_string_t set;
7469 cmdline_fixed_string_t port;
7471 cmdline_fixed_string_t mirror;
7473 cmdline_fixed_string_t what;
7474 cmdline_fixed_string_t dstpool;
7476 cmdline_fixed_string_t on;
7479 cmdline_parse_token_string_t cmd_mirror_link_set =
7480 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7482 cmdline_parse_token_string_t cmd_mirror_link_port =
7483 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7485 cmdline_parse_token_num_t cmd_mirror_link_portid =
7486 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7488 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7489 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7490 mirror, "mirror-rule");
7491 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7492 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7494 cmdline_parse_token_string_t cmd_mirror_link_what =
7495 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7496 what, "uplink-mirror#downlink-mirror");
7497 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7498 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7499 dstpool, "dst-pool");
7500 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7501 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7503 cmdline_parse_token_string_t cmd_mirror_link_on =
7504 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7508 cmd_set_mirror_link_parsed(void *parsed_result,
7509 __attribute__((unused)) struct cmdline *cl,
7510 __attribute__((unused)) void *data)
7513 struct cmd_set_mirror_link_result *res = parsed_result;
7514 struct rte_eth_mirror_conf mr_conf;
7516 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7517 if (!strcmp(res->what, "uplink-mirror"))
7518 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7520 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7522 mr_conf.dst_pool = res->dstpool_id;
7524 if (!strcmp(res->on, "on"))
7525 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7528 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7531 /* check the return value and print it if is < 0 */
7533 printf("mirror rule add error: (%s)\n", strerror(-ret));
7537 cmdline_parse_inst_t cmd_set_mirror_link = {
7538 .f = cmd_set_mirror_link_parsed,
7540 .help_str = "set port <port_id> mirror-rule <rule_id> "
7541 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7543 (void *)&cmd_mirror_link_set,
7544 (void *)&cmd_mirror_link_port,
7545 (void *)&cmd_mirror_link_portid,
7546 (void *)&cmd_mirror_link_mirror,
7547 (void *)&cmd_mirror_link_ruleid,
7548 (void *)&cmd_mirror_link_what,
7549 (void *)&cmd_mirror_link_dstpool,
7550 (void *)&cmd_mirror_link_poolid,
7551 (void *)&cmd_mirror_link_on,
7556 /* *** RESET VM MIRROR RULE *** */
7557 struct cmd_rm_mirror_rule_result {
7558 cmdline_fixed_string_t reset;
7559 cmdline_fixed_string_t port;
7561 cmdline_fixed_string_t mirror;
7565 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7566 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7568 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7569 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7571 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7572 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7574 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7575 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7576 mirror, "mirror-rule");
7577 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7578 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7582 cmd_reset_mirror_rule_parsed(void *parsed_result,
7583 __attribute__((unused)) struct cmdline *cl,
7584 __attribute__((unused)) void *data)
7587 struct cmd_set_mirror_link_result *res = parsed_result;
7589 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7591 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7594 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7595 .f = cmd_reset_mirror_rule_parsed,
7597 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7599 (void *)&cmd_rm_mirror_rule_reset,
7600 (void *)&cmd_rm_mirror_rule_port,
7601 (void *)&cmd_rm_mirror_rule_portid,
7602 (void *)&cmd_rm_mirror_rule_mirror,
7603 (void *)&cmd_rm_mirror_rule_ruleid,
7608 /* ******************************************************************************** */
7610 struct cmd_dump_result {
7611 cmdline_fixed_string_t dump;
7615 dump_struct_sizes(void)
7617 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7618 DUMP_SIZE(struct rte_mbuf);
7619 DUMP_SIZE(struct rte_mempool);
7620 DUMP_SIZE(struct rte_ring);
7624 static void cmd_dump_parsed(void *parsed_result,
7625 __attribute__((unused)) struct cmdline *cl,
7626 __attribute__((unused)) void *data)
7628 struct cmd_dump_result *res = parsed_result;
7630 if (!strcmp(res->dump, "dump_physmem"))
7631 rte_dump_physmem_layout(stdout);
7632 else if (!strcmp(res->dump, "dump_memzone"))
7633 rte_memzone_dump(stdout);
7634 else if (!strcmp(res->dump, "dump_struct_sizes"))
7635 dump_struct_sizes();
7636 else if (!strcmp(res->dump, "dump_ring"))
7637 rte_ring_list_dump(stdout);
7638 else if (!strcmp(res->dump, "dump_mempool"))
7639 rte_mempool_list_dump(stdout);
7640 else if (!strcmp(res->dump, "dump_devargs"))
7641 rte_eal_devargs_dump(stdout);
7644 cmdline_parse_token_string_t cmd_dump_dump =
7645 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7648 "dump_struct_sizes#"
7653 cmdline_parse_inst_t cmd_dump = {
7654 .f = cmd_dump_parsed, /* function to call */
7655 .data = NULL, /* 2nd arg of func */
7656 .help_str = "Dump status",
7657 .tokens = { /* token list, NULL terminated */
7658 (void *)&cmd_dump_dump,
7663 /* ******************************************************************************** */
7665 struct cmd_dump_one_result {
7666 cmdline_fixed_string_t dump;
7667 cmdline_fixed_string_t name;
7670 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7671 __attribute__((unused)) void *data)
7673 struct cmd_dump_one_result *res = parsed_result;
7675 if (!strcmp(res->dump, "dump_ring")) {
7677 r = rte_ring_lookup(res->name);
7679 cmdline_printf(cl, "Cannot find ring\n");
7682 rte_ring_dump(stdout, r);
7683 } else if (!strcmp(res->dump, "dump_mempool")) {
7684 struct rte_mempool *mp;
7685 mp = rte_mempool_lookup(res->name);
7687 cmdline_printf(cl, "Cannot find mempool\n");
7690 rte_mempool_dump(stdout, mp);
7694 cmdline_parse_token_string_t cmd_dump_one_dump =
7695 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7696 "dump_ring#dump_mempool");
7698 cmdline_parse_token_string_t cmd_dump_one_name =
7699 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7701 cmdline_parse_inst_t cmd_dump_one = {
7702 .f = cmd_dump_one_parsed, /* function to call */
7703 .data = NULL, /* 2nd arg of func */
7704 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7705 .tokens = { /* token list, NULL terminated */
7706 (void *)&cmd_dump_one_dump,
7707 (void *)&cmd_dump_one_name,
7712 /* *** Add/Del syn filter *** */
7713 struct cmd_syn_filter_result {
7714 cmdline_fixed_string_t filter;
7716 cmdline_fixed_string_t ops;
7717 cmdline_fixed_string_t priority;
7718 cmdline_fixed_string_t high;
7719 cmdline_fixed_string_t queue;
7724 cmd_syn_filter_parsed(void *parsed_result,
7725 __attribute__((unused)) struct cmdline *cl,
7726 __attribute__((unused)) void *data)
7728 struct cmd_syn_filter_result *res = parsed_result;
7729 struct rte_eth_syn_filter syn_filter;
7732 ret = rte_eth_dev_filter_supported(res->port_id,
7733 RTE_ETH_FILTER_SYN);
7735 printf("syn filter is not supported on port %u.\n",
7740 memset(&syn_filter, 0, sizeof(syn_filter));
7742 if (!strcmp(res->ops, "add")) {
7743 if (!strcmp(res->high, "high"))
7744 syn_filter.hig_pri = 1;
7746 syn_filter.hig_pri = 0;
7748 syn_filter.queue = res->queue_id;
7749 ret = rte_eth_dev_filter_ctrl(res->port_id,
7754 ret = rte_eth_dev_filter_ctrl(res->port_id,
7756 RTE_ETH_FILTER_DELETE,
7760 printf("syn filter programming error: (%s)\n",
7764 cmdline_parse_token_string_t cmd_syn_filter_filter =
7765 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7766 filter, "syn_filter");
7767 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7768 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7770 cmdline_parse_token_string_t cmd_syn_filter_ops =
7771 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7773 cmdline_parse_token_string_t cmd_syn_filter_priority =
7774 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7775 priority, "priority");
7776 cmdline_parse_token_string_t cmd_syn_filter_high =
7777 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7779 cmdline_parse_token_string_t cmd_syn_filter_queue =
7780 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7782 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7783 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7786 cmdline_parse_inst_t cmd_syn_filter = {
7787 .f = cmd_syn_filter_parsed,
7789 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7790 "<queue_id>: Add/Delete syn filter",
7792 (void *)&cmd_syn_filter_filter,
7793 (void *)&cmd_syn_filter_port_id,
7794 (void *)&cmd_syn_filter_ops,
7795 (void *)&cmd_syn_filter_priority,
7796 (void *)&cmd_syn_filter_high,
7797 (void *)&cmd_syn_filter_queue,
7798 (void *)&cmd_syn_filter_queue_id,
7803 /* *** ADD/REMOVE A 2tuple FILTER *** */
7804 struct cmd_2tuple_filter_result {
7805 cmdline_fixed_string_t filter;
7807 cmdline_fixed_string_t ops;
7808 cmdline_fixed_string_t dst_port;
7809 uint16_t dst_port_value;
7810 cmdline_fixed_string_t protocol;
7811 uint8_t protocol_value;
7812 cmdline_fixed_string_t mask;
7814 cmdline_fixed_string_t tcp_flags;
7815 uint8_t tcp_flags_value;
7816 cmdline_fixed_string_t priority;
7817 uint8_t priority_value;
7818 cmdline_fixed_string_t queue;
7823 cmd_2tuple_filter_parsed(void *parsed_result,
7824 __attribute__((unused)) struct cmdline *cl,
7825 __attribute__((unused)) void *data)
7827 struct rte_eth_ntuple_filter filter;
7828 struct cmd_2tuple_filter_result *res = parsed_result;
7831 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7833 printf("ntuple filter is not supported on port %u.\n",
7838 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7840 filter.flags = RTE_2TUPLE_FLAGS;
7841 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7842 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7843 filter.proto = res->protocol_value;
7844 filter.priority = res->priority_value;
7845 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7846 printf("nonzero tcp_flags is only meaningful"
7847 " when protocol is TCP.\n");
7850 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7851 printf("invalid TCP flags.\n");
7855 if (res->tcp_flags_value != 0) {
7856 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7857 filter.tcp_flags = res->tcp_flags_value;
7860 /* need convert to big endian. */
7861 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7862 filter.queue = res->queue_id;
7864 if (!strcmp(res->ops, "add"))
7865 ret = rte_eth_dev_filter_ctrl(res->port_id,
7866 RTE_ETH_FILTER_NTUPLE,
7870 ret = rte_eth_dev_filter_ctrl(res->port_id,
7871 RTE_ETH_FILTER_NTUPLE,
7872 RTE_ETH_FILTER_DELETE,
7875 printf("2tuple filter programming error: (%s)\n",
7880 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7881 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7882 filter, "2tuple_filter");
7883 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7884 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7886 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7887 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7889 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7890 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7891 dst_port, "dst_port");
7892 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7893 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7894 dst_port_value, UINT16);
7895 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7896 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7897 protocol, "protocol");
7898 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7899 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7900 protocol_value, UINT8);
7901 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7902 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7904 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7905 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7907 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7908 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7909 tcp_flags, "tcp_flags");
7910 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7911 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7912 tcp_flags_value, UINT8);
7913 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7914 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7915 priority, "priority");
7916 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7917 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7918 priority_value, UINT8);
7919 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7920 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7922 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7923 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7926 cmdline_parse_inst_t cmd_2tuple_filter = {
7927 .f = cmd_2tuple_filter_parsed,
7929 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7930 "<value> mask <value> tcp_flags <value> priority <value> queue "
7931 "<queue_id>: Add a 2tuple filter",
7933 (void *)&cmd_2tuple_filter_filter,
7934 (void *)&cmd_2tuple_filter_port_id,
7935 (void *)&cmd_2tuple_filter_ops,
7936 (void *)&cmd_2tuple_filter_dst_port,
7937 (void *)&cmd_2tuple_filter_dst_port_value,
7938 (void *)&cmd_2tuple_filter_protocol,
7939 (void *)&cmd_2tuple_filter_protocol_value,
7940 (void *)&cmd_2tuple_filter_mask,
7941 (void *)&cmd_2tuple_filter_mask_value,
7942 (void *)&cmd_2tuple_filter_tcp_flags,
7943 (void *)&cmd_2tuple_filter_tcp_flags_value,
7944 (void *)&cmd_2tuple_filter_priority,
7945 (void *)&cmd_2tuple_filter_priority_value,
7946 (void *)&cmd_2tuple_filter_queue,
7947 (void *)&cmd_2tuple_filter_queue_id,
7952 /* *** ADD/REMOVE A 5tuple FILTER *** */
7953 struct cmd_5tuple_filter_result {
7954 cmdline_fixed_string_t filter;
7956 cmdline_fixed_string_t ops;
7957 cmdline_fixed_string_t dst_ip;
7958 cmdline_ipaddr_t dst_ip_value;
7959 cmdline_fixed_string_t src_ip;
7960 cmdline_ipaddr_t src_ip_value;
7961 cmdline_fixed_string_t dst_port;
7962 uint16_t dst_port_value;
7963 cmdline_fixed_string_t src_port;
7964 uint16_t src_port_value;
7965 cmdline_fixed_string_t protocol;
7966 uint8_t protocol_value;
7967 cmdline_fixed_string_t mask;
7969 cmdline_fixed_string_t tcp_flags;
7970 uint8_t tcp_flags_value;
7971 cmdline_fixed_string_t priority;
7972 uint8_t priority_value;
7973 cmdline_fixed_string_t queue;
7978 cmd_5tuple_filter_parsed(void *parsed_result,
7979 __attribute__((unused)) struct cmdline *cl,
7980 __attribute__((unused)) void *data)
7982 struct rte_eth_ntuple_filter filter;
7983 struct cmd_5tuple_filter_result *res = parsed_result;
7986 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7988 printf("ntuple filter is not supported on port %u.\n",
7993 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7995 filter.flags = RTE_5TUPLE_FLAGS;
7996 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7997 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7998 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7999 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8000 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8001 filter.proto = res->protocol_value;
8002 filter.priority = res->priority_value;
8003 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8004 printf("nonzero tcp_flags is only meaningful"
8005 " when protocol is TCP.\n");
8008 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8009 printf("invalid TCP flags.\n");
8013 if (res->tcp_flags_value != 0) {
8014 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8015 filter.tcp_flags = res->tcp_flags_value;
8018 if (res->dst_ip_value.family == AF_INET)
8019 /* no need to convert, already big endian. */
8020 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8022 if (filter.dst_ip_mask == 0) {
8023 printf("can not support ipv6 involved compare.\n");
8029 if (res->src_ip_value.family == AF_INET)
8030 /* no need to convert, already big endian. */
8031 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8033 if (filter.src_ip_mask == 0) {
8034 printf("can not support ipv6 involved compare.\n");
8039 /* need convert to big endian. */
8040 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8041 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8042 filter.queue = res->queue_id;
8044 if (!strcmp(res->ops, "add"))
8045 ret = rte_eth_dev_filter_ctrl(res->port_id,
8046 RTE_ETH_FILTER_NTUPLE,
8050 ret = rte_eth_dev_filter_ctrl(res->port_id,
8051 RTE_ETH_FILTER_NTUPLE,
8052 RTE_ETH_FILTER_DELETE,
8055 printf("5tuple filter programming error: (%s)\n",
8059 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8060 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8061 filter, "5tuple_filter");
8062 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8063 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8065 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8066 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8068 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8069 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8071 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8072 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8074 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8075 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8077 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8078 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8080 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8081 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8082 dst_port, "dst_port");
8083 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8084 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8085 dst_port_value, UINT16);
8086 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8087 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8088 src_port, "src_port");
8089 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8090 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8091 src_port_value, UINT16);
8092 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8093 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8094 protocol, "protocol");
8095 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8096 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8097 protocol_value, UINT8);
8098 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8099 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8101 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8102 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8104 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8105 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8106 tcp_flags, "tcp_flags");
8107 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8108 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8109 tcp_flags_value, UINT8);
8110 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8111 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8112 priority, "priority");
8113 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8114 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8115 priority_value, UINT8);
8116 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8117 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8119 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8120 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8123 cmdline_parse_inst_t cmd_5tuple_filter = {
8124 .f = cmd_5tuple_filter_parsed,
8126 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8127 "src_ip <value> dst_port <value> src_port <value> "
8128 "protocol <value> mask <value> tcp_flags <value> "
8129 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8131 (void *)&cmd_5tuple_filter_filter,
8132 (void *)&cmd_5tuple_filter_port_id,
8133 (void *)&cmd_5tuple_filter_ops,
8134 (void *)&cmd_5tuple_filter_dst_ip,
8135 (void *)&cmd_5tuple_filter_dst_ip_value,
8136 (void *)&cmd_5tuple_filter_src_ip,
8137 (void *)&cmd_5tuple_filter_src_ip_value,
8138 (void *)&cmd_5tuple_filter_dst_port,
8139 (void *)&cmd_5tuple_filter_dst_port_value,
8140 (void *)&cmd_5tuple_filter_src_port,
8141 (void *)&cmd_5tuple_filter_src_port_value,
8142 (void *)&cmd_5tuple_filter_protocol,
8143 (void *)&cmd_5tuple_filter_protocol_value,
8144 (void *)&cmd_5tuple_filter_mask,
8145 (void *)&cmd_5tuple_filter_mask_value,
8146 (void *)&cmd_5tuple_filter_tcp_flags,
8147 (void *)&cmd_5tuple_filter_tcp_flags_value,
8148 (void *)&cmd_5tuple_filter_priority,
8149 (void *)&cmd_5tuple_filter_priority_value,
8150 (void *)&cmd_5tuple_filter_queue,
8151 (void *)&cmd_5tuple_filter_queue_id,
8156 /* *** ADD/REMOVE A flex FILTER *** */
8157 struct cmd_flex_filter_result {
8158 cmdline_fixed_string_t filter;
8159 cmdline_fixed_string_t ops;
8161 cmdline_fixed_string_t len;
8163 cmdline_fixed_string_t bytes;
8164 cmdline_fixed_string_t bytes_value;
8165 cmdline_fixed_string_t mask;
8166 cmdline_fixed_string_t mask_value;
8167 cmdline_fixed_string_t priority;
8168 uint8_t priority_value;
8169 cmdline_fixed_string_t queue;
8173 static int xdigit2val(unsigned char c)
8178 else if (isupper(c))
8186 cmd_flex_filter_parsed(void *parsed_result,
8187 __attribute__((unused)) struct cmdline *cl,
8188 __attribute__((unused)) void *data)
8191 struct rte_eth_flex_filter filter;
8192 struct cmd_flex_filter_result *res = parsed_result;
8193 char *bytes_ptr, *mask_ptr;
8194 uint16_t len, i, j = 0;
8199 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8200 printf("the len exceed the max length 128\n");
8203 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8204 filter.len = res->len_value;
8205 filter.priority = res->priority_value;
8206 filter.queue = res->queue_id;
8207 bytes_ptr = res->bytes_value;
8208 mask_ptr = res->mask_value;
8210 /* translate bytes string to array. */
8211 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8212 (bytes_ptr[1] == 'X')))
8214 len = strnlen(bytes_ptr, res->len_value * 2);
8215 if (len == 0 || (len % 8 != 0)) {
8216 printf("please check len and bytes input\n");
8219 for (i = 0; i < len; i++) {
8221 if (isxdigit(c) == 0) {
8222 /* invalid characters. */
8223 printf("invalid input\n");
8226 val = xdigit2val(c);
8229 filter.bytes[j] = byte;
8230 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8237 /* translate mask string to uint8_t array. */
8238 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8239 (mask_ptr[1] == 'X')))
8241 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8243 printf("invalid input\n");
8248 for (i = 0; i < len; i++) {
8250 if (isxdigit(c) == 0) {
8251 /* invalid characters. */
8252 printf("invalid input\n");
8255 val = xdigit2val(c);
8258 filter.mask[j] = byte;
8259 printf("mask[%d]:%02x ", j, filter.mask[j]);
8267 if (!strcmp(res->ops, "add"))
8268 ret = rte_eth_dev_filter_ctrl(res->port_id,
8269 RTE_ETH_FILTER_FLEXIBLE,
8273 ret = rte_eth_dev_filter_ctrl(res->port_id,
8274 RTE_ETH_FILTER_FLEXIBLE,
8275 RTE_ETH_FILTER_DELETE,
8279 printf("flex filter setting error: (%s)\n", strerror(-ret));
8282 cmdline_parse_token_string_t cmd_flex_filter_filter =
8283 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8284 filter, "flex_filter");
8285 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8286 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8288 cmdline_parse_token_string_t cmd_flex_filter_ops =
8289 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8291 cmdline_parse_token_string_t cmd_flex_filter_len =
8292 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8294 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8295 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8297 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8298 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8300 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8301 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8303 cmdline_parse_token_string_t cmd_flex_filter_mask =
8304 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8306 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8307 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8309 cmdline_parse_token_string_t cmd_flex_filter_priority =
8310 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8311 priority, "priority");
8312 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8313 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8314 priority_value, UINT8);
8315 cmdline_parse_token_string_t cmd_flex_filter_queue =
8316 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8318 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8319 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8321 cmdline_parse_inst_t cmd_flex_filter = {
8322 .f = cmd_flex_filter_parsed,
8324 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8325 "<value> mask <value> priority <value> queue <queue_id>: "
8326 "Add/Del a flex filter",
8328 (void *)&cmd_flex_filter_filter,
8329 (void *)&cmd_flex_filter_port_id,
8330 (void *)&cmd_flex_filter_ops,
8331 (void *)&cmd_flex_filter_len,
8332 (void *)&cmd_flex_filter_len_value,
8333 (void *)&cmd_flex_filter_bytes,
8334 (void *)&cmd_flex_filter_bytes_value,
8335 (void *)&cmd_flex_filter_mask,
8336 (void *)&cmd_flex_filter_mask_value,
8337 (void *)&cmd_flex_filter_priority,
8338 (void *)&cmd_flex_filter_priority_value,
8339 (void *)&cmd_flex_filter_queue,
8340 (void *)&cmd_flex_filter_queue_id,
8345 /* *** Filters Control *** */
8347 /* *** deal with ethertype filter *** */
8348 struct cmd_ethertype_filter_result {
8349 cmdline_fixed_string_t filter;
8351 cmdline_fixed_string_t ops;
8352 cmdline_fixed_string_t mac;
8353 struct ether_addr mac_addr;
8354 cmdline_fixed_string_t ethertype;
8355 uint16_t ethertype_value;
8356 cmdline_fixed_string_t drop;
8357 cmdline_fixed_string_t queue;
8361 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8362 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8363 filter, "ethertype_filter");
8364 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8365 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8367 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8368 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8370 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8371 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8372 mac, "mac_addr#mac_ignr");
8373 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8374 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8376 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8377 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8378 ethertype, "ethertype");
8379 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8380 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8381 ethertype_value, UINT16);
8382 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8383 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8385 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8386 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8388 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8389 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8393 cmd_ethertype_filter_parsed(void *parsed_result,
8394 __attribute__((unused)) struct cmdline *cl,
8395 __attribute__((unused)) void *data)
8397 struct cmd_ethertype_filter_result *res = parsed_result;
8398 struct rte_eth_ethertype_filter filter;
8401 ret = rte_eth_dev_filter_supported(res->port_id,
8402 RTE_ETH_FILTER_ETHERTYPE);
8404 printf("ethertype filter is not supported on port %u.\n",
8409 memset(&filter, 0, sizeof(filter));
8410 if (!strcmp(res->mac, "mac_addr")) {
8411 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8412 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8413 sizeof(struct ether_addr));
8415 if (!strcmp(res->drop, "drop"))
8416 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8417 filter.ether_type = res->ethertype_value;
8418 filter.queue = res->queue_id;
8420 if (!strcmp(res->ops, "add"))
8421 ret = rte_eth_dev_filter_ctrl(res->port_id,
8422 RTE_ETH_FILTER_ETHERTYPE,
8426 ret = rte_eth_dev_filter_ctrl(res->port_id,
8427 RTE_ETH_FILTER_ETHERTYPE,
8428 RTE_ETH_FILTER_DELETE,
8431 printf("ethertype filter programming error: (%s)\n",
8435 cmdline_parse_inst_t cmd_ethertype_filter = {
8436 .f = cmd_ethertype_filter_parsed,
8438 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8439 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8440 "Add or delete an ethertype filter entry",
8442 (void *)&cmd_ethertype_filter_filter,
8443 (void *)&cmd_ethertype_filter_port_id,
8444 (void *)&cmd_ethertype_filter_ops,
8445 (void *)&cmd_ethertype_filter_mac,
8446 (void *)&cmd_ethertype_filter_mac_addr,
8447 (void *)&cmd_ethertype_filter_ethertype,
8448 (void *)&cmd_ethertype_filter_ethertype_value,
8449 (void *)&cmd_ethertype_filter_drop,
8450 (void *)&cmd_ethertype_filter_queue,
8451 (void *)&cmd_ethertype_filter_queue_id,
8456 /* *** deal with flow director filter *** */
8457 struct cmd_flow_director_result {
8458 cmdline_fixed_string_t flow_director_filter;
8460 cmdline_fixed_string_t mode;
8461 cmdline_fixed_string_t mode_value;
8462 cmdline_fixed_string_t ops;
8463 cmdline_fixed_string_t flow;
8464 cmdline_fixed_string_t flow_type;
8465 cmdline_fixed_string_t ether;
8466 uint16_t ether_type;
8467 cmdline_fixed_string_t src;
8468 cmdline_ipaddr_t ip_src;
8470 cmdline_fixed_string_t dst;
8471 cmdline_ipaddr_t ip_dst;
8473 cmdline_fixed_string_t verify_tag;
8474 uint32_t verify_tag_value;
8475 cmdline_ipaddr_t tos;
8477 cmdline_ipaddr_t proto;
8478 uint8_t proto_value;
8479 cmdline_ipaddr_t ttl;
8481 cmdline_fixed_string_t vlan;
8482 uint16_t vlan_value;
8483 cmdline_fixed_string_t flexbytes;
8484 cmdline_fixed_string_t flexbytes_value;
8485 cmdline_fixed_string_t pf_vf;
8486 cmdline_fixed_string_t drop;
8487 cmdline_fixed_string_t queue;
8489 cmdline_fixed_string_t fd_id;
8490 uint32_t fd_id_value;
8491 cmdline_fixed_string_t mac;
8492 struct ether_addr mac_addr;
8493 cmdline_fixed_string_t tunnel;
8494 cmdline_fixed_string_t tunnel_type;
8495 cmdline_fixed_string_t tunnel_id;
8496 uint32_t tunnel_id_value;
8500 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8503 const char *p, *p0 = q_arg;
8505 unsigned long int_fld;
8506 char *str_fld[max_num];
8511 p = strchr(p0, '(');
8515 p0 = strchr(p, ')');
8520 if (size >= sizeof(s))
8523 snprintf(s, sizeof(s), "%.*s", size, p);
8524 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8525 if (ret < 0 || ret > max_num)
8527 for (i = 0; i < ret; i++) {
8529 int_fld = strtoul(str_fld[i], &end, 0);
8530 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8532 flexbytes[i] = (uint8_t)int_fld;
8538 str2flowtype(char *string)
8541 static const struct {
8544 } flowtype_str[] = {
8545 {"raw", RTE_ETH_FLOW_RAW},
8546 {"ipv4", RTE_ETH_FLOW_IPV4},
8547 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8548 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8549 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8550 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8551 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8552 {"ipv6", RTE_ETH_FLOW_IPV6},
8553 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8554 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8555 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8556 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8557 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8558 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8561 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8562 if (!strcmp(flowtype_str[i].str, string))
8563 return flowtype_str[i].type;
8565 return RTE_ETH_FLOW_UNKNOWN;
8568 static enum rte_eth_fdir_tunnel_type
8569 str2fdir_tunneltype(char *string)
8573 static const struct {
8575 enum rte_eth_fdir_tunnel_type type;
8576 } tunneltype_str[] = {
8577 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8578 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8581 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8582 if (!strcmp(tunneltype_str[i].str, string))
8583 return tunneltype_str[i].type;
8585 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8588 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8590 if ((ip_addr).family == AF_INET) \
8591 (ip) = (ip_addr).addr.ipv4.s_addr; \
8593 printf("invalid parameter.\n"); \
8598 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8600 if ((ip_addr).family == AF_INET6) \
8601 (void)rte_memcpy(&(ip), \
8602 &((ip_addr).addr.ipv6), \
8603 sizeof(struct in6_addr)); \
8605 printf("invalid parameter.\n"); \
8611 cmd_flow_director_filter_parsed(void *parsed_result,
8612 __attribute__((unused)) struct cmdline *cl,
8613 __attribute__((unused)) void *data)
8615 struct cmd_flow_director_result *res = parsed_result;
8616 struct rte_eth_fdir_filter entry;
8617 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8619 unsigned long vf_id;
8622 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8624 printf("flow director is not supported on port %u.\n",
8628 memset(flexbytes, 0, sizeof(flexbytes));
8629 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8631 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8632 if (strcmp(res->mode_value, "MAC-VLAN")) {
8633 printf("Please set mode to MAC-VLAN.\n");
8636 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8637 if (strcmp(res->mode_value, "Tunnel")) {
8638 printf("Please set mode to Tunnel.\n");
8642 if (strcmp(res->mode_value, "IP")) {
8643 printf("Please set mode to IP.\n");
8646 entry.input.flow_type = str2flowtype(res->flow_type);
8649 ret = parse_flexbytes(res->flexbytes_value,
8651 RTE_ETH_FDIR_MAX_FLEXLEN);
8653 printf("error: Cannot parse flexbytes input.\n");
8657 switch (entry.input.flow_type) {
8658 case RTE_ETH_FLOW_FRAG_IPV4:
8659 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8660 entry.input.flow.ip4_flow.proto = res->proto_value;
8661 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8662 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8663 IPV4_ADDR_TO_UINT(res->ip_dst,
8664 entry.input.flow.ip4_flow.dst_ip);
8665 IPV4_ADDR_TO_UINT(res->ip_src,
8666 entry.input.flow.ip4_flow.src_ip);
8667 entry.input.flow.ip4_flow.tos = res->tos_value;
8668 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8669 /* need convert to big endian. */
8670 entry.input.flow.udp4_flow.dst_port =
8671 rte_cpu_to_be_16(res->port_dst);
8672 entry.input.flow.udp4_flow.src_port =
8673 rte_cpu_to_be_16(res->port_src);
8675 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8676 IPV4_ADDR_TO_UINT(res->ip_dst,
8677 entry.input.flow.sctp4_flow.ip.dst_ip);
8678 IPV4_ADDR_TO_UINT(res->ip_src,
8679 entry.input.flow.sctp4_flow.ip.src_ip);
8680 entry.input.flow.ip4_flow.tos = res->tos_value;
8681 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8682 /* need convert to big endian. */
8683 entry.input.flow.sctp4_flow.dst_port =
8684 rte_cpu_to_be_16(res->port_dst);
8685 entry.input.flow.sctp4_flow.src_port =
8686 rte_cpu_to_be_16(res->port_src);
8687 entry.input.flow.sctp4_flow.verify_tag =
8688 rte_cpu_to_be_32(res->verify_tag_value);
8690 case RTE_ETH_FLOW_FRAG_IPV6:
8691 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8692 entry.input.flow.ipv6_flow.proto = res->proto_value;
8693 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8694 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8695 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8696 entry.input.flow.ipv6_flow.dst_ip);
8697 IPV6_ADDR_TO_ARRAY(res->ip_src,
8698 entry.input.flow.ipv6_flow.src_ip);
8699 entry.input.flow.ipv6_flow.tc = res->tos_value;
8700 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8701 /* need convert to big endian. */
8702 entry.input.flow.udp6_flow.dst_port =
8703 rte_cpu_to_be_16(res->port_dst);
8704 entry.input.flow.udp6_flow.src_port =
8705 rte_cpu_to_be_16(res->port_src);
8707 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8708 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8709 entry.input.flow.sctp6_flow.ip.dst_ip);
8710 IPV6_ADDR_TO_ARRAY(res->ip_src,
8711 entry.input.flow.sctp6_flow.ip.src_ip);
8712 entry.input.flow.ipv6_flow.tc = res->tos_value;
8713 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8714 /* need convert to big endian. */
8715 entry.input.flow.sctp6_flow.dst_port =
8716 rte_cpu_to_be_16(res->port_dst);
8717 entry.input.flow.sctp6_flow.src_port =
8718 rte_cpu_to_be_16(res->port_src);
8719 entry.input.flow.sctp6_flow.verify_tag =
8720 rte_cpu_to_be_32(res->verify_tag_value);
8722 case RTE_ETH_FLOW_L2_PAYLOAD:
8723 entry.input.flow.l2_flow.ether_type =
8724 rte_cpu_to_be_16(res->ether_type);
8730 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8731 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8733 sizeof(struct ether_addr));
8735 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8736 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8738 sizeof(struct ether_addr));
8739 entry.input.flow.tunnel_flow.tunnel_type =
8740 str2fdir_tunneltype(res->tunnel_type);
8741 entry.input.flow.tunnel_flow.tunnel_id =
8742 rte_cpu_to_be_32(res->tunnel_id_value);
8745 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8747 RTE_ETH_FDIR_MAX_FLEXLEN);
8749 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8751 entry.action.flex_off = 0; /*use 0 by default */
8752 if (!strcmp(res->drop, "drop"))
8753 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8755 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8757 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8758 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8759 if (!strcmp(res->pf_vf, "pf"))
8760 entry.input.flow_ext.is_vf = 0;
8761 else if (!strncmp(res->pf_vf, "vf", 2)) {
8762 struct rte_eth_dev_info dev_info;
8764 memset(&dev_info, 0, sizeof(dev_info));
8765 rte_eth_dev_info_get(res->port_id, &dev_info);
8767 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8768 if (errno != 0 || *end != '\0' ||
8769 vf_id >= dev_info.max_vfs) {
8770 printf("invalid parameter %s.\n", res->pf_vf);
8773 entry.input.flow_ext.is_vf = 1;
8774 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8776 printf("invalid parameter %s.\n", res->pf_vf);
8781 /* set to report FD ID by default */
8782 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8783 entry.action.rx_queue = res->queue_id;
8784 entry.soft_id = res->fd_id_value;
8785 if (!strcmp(res->ops, "add"))
8786 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8787 RTE_ETH_FILTER_ADD, &entry);
8788 else if (!strcmp(res->ops, "del"))
8789 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8790 RTE_ETH_FILTER_DELETE, &entry);
8792 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8793 RTE_ETH_FILTER_UPDATE, &entry);
8795 printf("flow director programming error: (%s)\n",
8799 cmdline_parse_token_string_t cmd_flow_director_filter =
8800 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8801 flow_director_filter, "flow_director_filter");
8802 cmdline_parse_token_num_t cmd_flow_director_port_id =
8803 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8805 cmdline_parse_token_string_t cmd_flow_director_ops =
8806 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8807 ops, "add#del#update");
8808 cmdline_parse_token_string_t cmd_flow_director_flow =
8809 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8811 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8812 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8813 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8814 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8815 cmdline_parse_token_string_t cmd_flow_director_ether =
8816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8818 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8819 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8820 ether_type, UINT16);
8821 cmdline_parse_token_string_t cmd_flow_director_src =
8822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8824 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8825 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8827 cmdline_parse_token_num_t cmd_flow_director_port_src =
8828 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8830 cmdline_parse_token_string_t cmd_flow_director_dst =
8831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8833 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8834 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8836 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8837 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8839 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8841 verify_tag, "verify_tag");
8842 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8843 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8844 verify_tag_value, UINT32);
8845 cmdline_parse_token_string_t cmd_flow_director_tos =
8846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8848 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8849 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8851 cmdline_parse_token_string_t cmd_flow_director_proto =
8852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8854 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8855 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8856 proto_value, UINT8);
8857 cmdline_parse_token_string_t cmd_flow_director_ttl =
8858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8860 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8861 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8863 cmdline_parse_token_string_t cmd_flow_director_vlan =
8864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8866 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8867 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8868 vlan_value, UINT16);
8869 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8871 flexbytes, "flexbytes");
8872 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8874 flexbytes_value, NULL);
8875 cmdline_parse_token_string_t cmd_flow_director_drop =
8876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8878 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8881 cmdline_parse_token_string_t cmd_flow_director_queue =
8882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8884 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8885 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8887 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8888 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8890 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8891 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8892 fd_id_value, UINT32);
8894 cmdline_parse_token_string_t cmd_flow_director_mode =
8895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8897 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8900 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8902 mode_value, "MAC-VLAN");
8903 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8905 mode_value, "Tunnel");
8906 cmdline_parse_token_string_t cmd_flow_director_mac =
8907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8909 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8910 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8912 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8915 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8917 tunnel_type, "NVGRE#VxLAN");
8918 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8920 tunnel_id, "tunnel-id");
8921 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8922 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8923 tunnel_id_value, UINT32);
8925 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8926 .f = cmd_flow_director_filter_parsed,
8928 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8929 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8930 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8931 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8932 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8933 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8934 "fd_id <fd_id_value>: "
8935 "Add or delete an ip flow director entry on NIC",
8937 (void *)&cmd_flow_director_filter,
8938 (void *)&cmd_flow_director_port_id,
8939 (void *)&cmd_flow_director_mode,
8940 (void *)&cmd_flow_director_mode_ip,
8941 (void *)&cmd_flow_director_ops,
8942 (void *)&cmd_flow_director_flow,
8943 (void *)&cmd_flow_director_flow_type,
8944 (void *)&cmd_flow_director_src,
8945 (void *)&cmd_flow_director_ip_src,
8946 (void *)&cmd_flow_director_dst,
8947 (void *)&cmd_flow_director_ip_dst,
8948 (void *)&cmd_flow_director_tos,
8949 (void *)&cmd_flow_director_tos_value,
8950 (void *)&cmd_flow_director_proto,
8951 (void *)&cmd_flow_director_proto_value,
8952 (void *)&cmd_flow_director_ttl,
8953 (void *)&cmd_flow_director_ttl_value,
8954 (void *)&cmd_flow_director_vlan,
8955 (void *)&cmd_flow_director_vlan_value,
8956 (void *)&cmd_flow_director_flexbytes,
8957 (void *)&cmd_flow_director_flexbytes_value,
8958 (void *)&cmd_flow_director_drop,
8959 (void *)&cmd_flow_director_pf_vf,
8960 (void *)&cmd_flow_director_queue,
8961 (void *)&cmd_flow_director_queue_id,
8962 (void *)&cmd_flow_director_fd_id,
8963 (void *)&cmd_flow_director_fd_id_value,
8968 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8969 .f = cmd_flow_director_filter_parsed,
8971 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8972 "director entry on NIC",
8974 (void *)&cmd_flow_director_filter,
8975 (void *)&cmd_flow_director_port_id,
8976 (void *)&cmd_flow_director_mode,
8977 (void *)&cmd_flow_director_mode_ip,
8978 (void *)&cmd_flow_director_ops,
8979 (void *)&cmd_flow_director_flow,
8980 (void *)&cmd_flow_director_flow_type,
8981 (void *)&cmd_flow_director_src,
8982 (void *)&cmd_flow_director_ip_src,
8983 (void *)&cmd_flow_director_port_src,
8984 (void *)&cmd_flow_director_dst,
8985 (void *)&cmd_flow_director_ip_dst,
8986 (void *)&cmd_flow_director_port_dst,
8987 (void *)&cmd_flow_director_tos,
8988 (void *)&cmd_flow_director_tos_value,
8989 (void *)&cmd_flow_director_ttl,
8990 (void *)&cmd_flow_director_ttl_value,
8991 (void *)&cmd_flow_director_vlan,
8992 (void *)&cmd_flow_director_vlan_value,
8993 (void *)&cmd_flow_director_flexbytes,
8994 (void *)&cmd_flow_director_flexbytes_value,
8995 (void *)&cmd_flow_director_drop,
8996 (void *)&cmd_flow_director_pf_vf,
8997 (void *)&cmd_flow_director_queue,
8998 (void *)&cmd_flow_director_queue_id,
8999 (void *)&cmd_flow_director_fd_id,
9000 (void *)&cmd_flow_director_fd_id_value,
9005 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9006 .f = cmd_flow_director_filter_parsed,
9008 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9009 "director entry on NIC",
9011 (void *)&cmd_flow_director_filter,
9012 (void *)&cmd_flow_director_port_id,
9013 (void *)&cmd_flow_director_mode,
9014 (void *)&cmd_flow_director_mode_ip,
9015 (void *)&cmd_flow_director_ops,
9016 (void *)&cmd_flow_director_flow,
9017 (void *)&cmd_flow_director_flow_type,
9018 (void *)&cmd_flow_director_src,
9019 (void *)&cmd_flow_director_ip_src,
9020 (void *)&cmd_flow_director_port_dst,
9021 (void *)&cmd_flow_director_dst,
9022 (void *)&cmd_flow_director_ip_dst,
9023 (void *)&cmd_flow_director_port_dst,
9024 (void *)&cmd_flow_director_verify_tag,
9025 (void *)&cmd_flow_director_verify_tag_value,
9026 (void *)&cmd_flow_director_tos,
9027 (void *)&cmd_flow_director_tos_value,
9028 (void *)&cmd_flow_director_ttl,
9029 (void *)&cmd_flow_director_ttl_value,
9030 (void *)&cmd_flow_director_vlan,
9031 (void *)&cmd_flow_director_vlan_value,
9032 (void *)&cmd_flow_director_flexbytes,
9033 (void *)&cmd_flow_director_flexbytes_value,
9034 (void *)&cmd_flow_director_drop,
9035 (void *)&cmd_flow_director_pf_vf,
9036 (void *)&cmd_flow_director_queue,
9037 (void *)&cmd_flow_director_queue_id,
9038 (void *)&cmd_flow_director_fd_id,
9039 (void *)&cmd_flow_director_fd_id_value,
9044 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9045 .f = cmd_flow_director_filter_parsed,
9047 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9048 "director entry on NIC",
9050 (void *)&cmd_flow_director_filter,
9051 (void *)&cmd_flow_director_port_id,
9052 (void *)&cmd_flow_director_mode,
9053 (void *)&cmd_flow_director_mode_ip,
9054 (void *)&cmd_flow_director_ops,
9055 (void *)&cmd_flow_director_flow,
9056 (void *)&cmd_flow_director_flow_type,
9057 (void *)&cmd_flow_director_ether,
9058 (void *)&cmd_flow_director_ether_type,
9059 (void *)&cmd_flow_director_flexbytes,
9060 (void *)&cmd_flow_director_flexbytes_value,
9061 (void *)&cmd_flow_director_drop,
9062 (void *)&cmd_flow_director_pf_vf,
9063 (void *)&cmd_flow_director_queue,
9064 (void *)&cmd_flow_director_queue_id,
9065 (void *)&cmd_flow_director_fd_id,
9066 (void *)&cmd_flow_director_fd_id_value,
9071 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9072 .f = cmd_flow_director_filter_parsed,
9074 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9075 "director entry on NIC",
9077 (void *)&cmd_flow_director_filter,
9078 (void *)&cmd_flow_director_port_id,
9079 (void *)&cmd_flow_director_mode,
9080 (void *)&cmd_flow_director_mode_mac_vlan,
9081 (void *)&cmd_flow_director_ops,
9082 (void *)&cmd_flow_director_mac,
9083 (void *)&cmd_flow_director_mac_addr,
9084 (void *)&cmd_flow_director_vlan,
9085 (void *)&cmd_flow_director_vlan_value,
9086 (void *)&cmd_flow_director_flexbytes,
9087 (void *)&cmd_flow_director_flexbytes_value,
9088 (void *)&cmd_flow_director_drop,
9089 (void *)&cmd_flow_director_queue,
9090 (void *)&cmd_flow_director_queue_id,
9091 (void *)&cmd_flow_director_fd_id,
9092 (void *)&cmd_flow_director_fd_id_value,
9097 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9098 .f = cmd_flow_director_filter_parsed,
9100 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9101 "director entry on NIC",
9103 (void *)&cmd_flow_director_filter,
9104 (void *)&cmd_flow_director_port_id,
9105 (void *)&cmd_flow_director_mode,
9106 (void *)&cmd_flow_director_mode_tunnel,
9107 (void *)&cmd_flow_director_ops,
9108 (void *)&cmd_flow_director_mac,
9109 (void *)&cmd_flow_director_mac_addr,
9110 (void *)&cmd_flow_director_vlan,
9111 (void *)&cmd_flow_director_vlan_value,
9112 (void *)&cmd_flow_director_tunnel,
9113 (void *)&cmd_flow_director_tunnel_type,
9114 (void *)&cmd_flow_director_tunnel_id,
9115 (void *)&cmd_flow_director_tunnel_id_value,
9116 (void *)&cmd_flow_director_flexbytes,
9117 (void *)&cmd_flow_director_flexbytes_value,
9118 (void *)&cmd_flow_director_drop,
9119 (void *)&cmd_flow_director_queue,
9120 (void *)&cmd_flow_director_queue_id,
9121 (void *)&cmd_flow_director_fd_id,
9122 (void *)&cmd_flow_director_fd_id_value,
9127 struct cmd_flush_flow_director_result {
9128 cmdline_fixed_string_t flush_flow_director;
9132 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9133 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9134 flush_flow_director, "flush_flow_director");
9135 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9136 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9140 cmd_flush_flow_director_parsed(void *parsed_result,
9141 __attribute__((unused)) struct cmdline *cl,
9142 __attribute__((unused)) void *data)
9144 struct cmd_flow_director_result *res = parsed_result;
9147 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9149 printf("flow director is not supported on port %u.\n",
9154 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9155 RTE_ETH_FILTER_FLUSH, NULL);
9157 printf("flow director table flushing error: (%s)\n",
9161 cmdline_parse_inst_t cmd_flush_flow_director = {
9162 .f = cmd_flush_flow_director_parsed,
9164 .help_str = "flush_flow_director <port_id>: "
9165 "Flush all flow director entries of a device on NIC",
9167 (void *)&cmd_flush_flow_director_flush,
9168 (void *)&cmd_flush_flow_director_port_id,
9173 /* *** deal with flow director mask *** */
9174 struct cmd_flow_director_mask_result {
9175 cmdline_fixed_string_t flow_director_mask;
9177 cmdline_fixed_string_t mode;
9178 cmdline_fixed_string_t mode_value;
9179 cmdline_fixed_string_t vlan;
9181 cmdline_fixed_string_t src_mask;
9182 cmdline_ipaddr_t ipv4_src;
9183 cmdline_ipaddr_t ipv6_src;
9185 cmdline_fixed_string_t dst_mask;
9186 cmdline_ipaddr_t ipv4_dst;
9187 cmdline_ipaddr_t ipv6_dst;
9189 cmdline_fixed_string_t mac;
9190 uint8_t mac_addr_byte_mask;
9191 cmdline_fixed_string_t tunnel_id;
9192 uint32_t tunnel_id_mask;
9193 cmdline_fixed_string_t tunnel_type;
9194 uint8_t tunnel_type_mask;
9198 cmd_flow_director_mask_parsed(void *parsed_result,
9199 __attribute__((unused)) struct cmdline *cl,
9200 __attribute__((unused)) void *data)
9202 struct cmd_flow_director_mask_result *res = parsed_result;
9203 struct rte_eth_fdir_masks *mask;
9204 struct rte_port *port;
9206 if (res->port_id > nb_ports) {
9207 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9211 port = &ports[res->port_id];
9212 /** Check if the port is not started **/
9213 if (port->port_status != RTE_PORT_STOPPED) {
9214 printf("Please stop port %d first\n", res->port_id);
9218 mask = &port->dev_conf.fdir_conf.mask;
9220 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9221 if (strcmp(res->mode_value, "MAC-VLAN")) {
9222 printf("Please set mode to MAC-VLAN.\n");
9226 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9227 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9228 if (strcmp(res->mode_value, "Tunnel")) {
9229 printf("Please set mode to Tunnel.\n");
9233 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9234 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9235 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9236 mask->tunnel_type_mask = res->tunnel_type_mask;
9238 if (strcmp(res->mode_value, "IP")) {
9239 printf("Please set mode to IP.\n");
9243 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9244 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9245 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9246 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9247 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9248 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9249 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9252 cmd_reconfig_device_queue(res->port_id, 1, 1);
9255 cmdline_parse_token_string_t cmd_flow_director_mask =
9256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9257 flow_director_mask, "flow_director_mask");
9258 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9259 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9261 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9264 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9265 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9267 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9269 src_mask, "src_mask");
9270 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9271 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9273 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9274 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9276 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9277 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9279 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9281 dst_mask, "dst_mask");
9282 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9283 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9285 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9286 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9288 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9289 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9292 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9295 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9298 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9299 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9300 mode_value, "MAC-VLAN");
9301 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9303 mode_value, "Tunnel");
9304 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9305 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9307 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9308 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9309 mac_addr_byte_mask, UINT8);
9310 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9311 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9312 tunnel_type, "tunnel-type");
9313 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9314 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9315 tunnel_type_mask, UINT8);
9316 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9318 tunnel_id, "tunnel-id");
9319 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9320 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9321 tunnel_id_mask, UINT32);
9323 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9324 .f = cmd_flow_director_mask_parsed,
9326 .help_str = "flow_director_mask ... : "
9327 "Set IP mode flow director's mask on NIC",
9329 (void *)&cmd_flow_director_mask,
9330 (void *)&cmd_flow_director_mask_port_id,
9331 (void *)&cmd_flow_director_mask_mode,
9332 (void *)&cmd_flow_director_mask_mode_ip,
9333 (void *)&cmd_flow_director_mask_vlan,
9334 (void *)&cmd_flow_director_mask_vlan_value,
9335 (void *)&cmd_flow_director_mask_src,
9336 (void *)&cmd_flow_director_mask_ipv4_src,
9337 (void *)&cmd_flow_director_mask_ipv6_src,
9338 (void *)&cmd_flow_director_mask_port_src,
9339 (void *)&cmd_flow_director_mask_dst,
9340 (void *)&cmd_flow_director_mask_ipv4_dst,
9341 (void *)&cmd_flow_director_mask_ipv6_dst,
9342 (void *)&cmd_flow_director_mask_port_dst,
9347 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9348 .f = cmd_flow_director_mask_parsed,
9350 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9351 "flow director's mask on NIC",
9353 (void *)&cmd_flow_director_mask,
9354 (void *)&cmd_flow_director_mask_port_id,
9355 (void *)&cmd_flow_director_mask_mode,
9356 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9357 (void *)&cmd_flow_director_mask_vlan,
9358 (void *)&cmd_flow_director_mask_vlan_value,
9363 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9364 .f = cmd_flow_director_mask_parsed,
9366 .help_str = "flow_director_mask ... : Set tunnel mode "
9367 "flow director's mask on NIC",
9369 (void *)&cmd_flow_director_mask,
9370 (void *)&cmd_flow_director_mask_port_id,
9371 (void *)&cmd_flow_director_mask_mode,
9372 (void *)&cmd_flow_director_mask_mode_tunnel,
9373 (void *)&cmd_flow_director_mask_vlan,
9374 (void *)&cmd_flow_director_mask_vlan_value,
9375 (void *)&cmd_flow_director_mask_mac,
9376 (void *)&cmd_flow_director_mask_mac_value,
9377 (void *)&cmd_flow_director_mask_tunnel_type,
9378 (void *)&cmd_flow_director_mask_tunnel_type_value,
9379 (void *)&cmd_flow_director_mask_tunnel_id,
9380 (void *)&cmd_flow_director_mask_tunnel_id_value,
9385 /* *** deal with flow director mask on flexible payload *** */
9386 struct cmd_flow_director_flex_mask_result {
9387 cmdline_fixed_string_t flow_director_flexmask;
9389 cmdline_fixed_string_t flow;
9390 cmdline_fixed_string_t flow_type;
9391 cmdline_fixed_string_t mask;
9395 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9396 __attribute__((unused)) struct cmdline *cl,
9397 __attribute__((unused)) void *data)
9399 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9400 struct rte_eth_fdir_info fdir_info;
9401 struct rte_eth_fdir_flex_mask flex_mask;
9402 struct rte_port *port;
9403 uint32_t flow_type_mask;
9407 if (res->port_id > nb_ports) {
9408 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9412 port = &ports[res->port_id];
9413 /** Check if the port is not started **/
9414 if (port->port_status != RTE_PORT_STOPPED) {
9415 printf("Please stop port %d first\n", res->port_id);
9419 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9420 ret = parse_flexbytes(res->mask,
9422 RTE_ETH_FDIR_MAX_FLEXLEN);
9424 printf("error: Cannot parse mask input.\n");
9428 memset(&fdir_info, 0, sizeof(fdir_info));
9429 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9430 RTE_ETH_FILTER_INFO, &fdir_info);
9432 printf("Cannot get FDir filter info\n");
9436 if (!strcmp(res->flow_type, "none")) {
9437 /* means don't specify the flow type */
9438 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9439 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9440 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9441 0, sizeof(struct rte_eth_fdir_flex_mask));
9442 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9443 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9445 sizeof(struct rte_eth_fdir_flex_mask));
9446 cmd_reconfig_device_queue(res->port_id, 1, 1);
9449 flow_type_mask = fdir_info.flow_types_mask[0];
9450 if (!strcmp(res->flow_type, "all")) {
9451 if (!flow_type_mask) {
9452 printf("No flow type supported\n");
9455 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9456 if (flow_type_mask & (1 << i)) {
9457 flex_mask.flow_type = i;
9458 fdir_set_flex_mask(res->port_id, &flex_mask);
9461 cmd_reconfig_device_queue(res->port_id, 1, 1);
9464 flex_mask.flow_type = str2flowtype(res->flow_type);
9465 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9466 printf("Flow type %s not supported on port %d\n",
9467 res->flow_type, res->port_id);
9470 fdir_set_flex_mask(res->port_id, &flex_mask);
9471 cmd_reconfig_device_queue(res->port_id, 1, 1);
9474 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9476 flow_director_flexmask,
9477 "flow_director_flex_mask");
9478 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9479 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9481 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9482 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9484 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9486 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9487 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9488 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9489 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9492 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9493 .f = cmd_flow_director_flex_mask_parsed,
9495 .help_str = "flow_director_flex_mask ... : "
9496 "Set flow director's flex mask on NIC",
9498 (void *)&cmd_flow_director_flexmask,
9499 (void *)&cmd_flow_director_flexmask_port_id,
9500 (void *)&cmd_flow_director_flexmask_flow,
9501 (void *)&cmd_flow_director_flexmask_flow_type,
9502 (void *)&cmd_flow_director_flexmask_mask,
9507 /* *** deal with flow director flexible payload configuration *** */
9508 struct cmd_flow_director_flexpayload_result {
9509 cmdline_fixed_string_t flow_director_flexpayload;
9511 cmdline_fixed_string_t payload_layer;
9512 cmdline_fixed_string_t payload_cfg;
9516 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9519 const char *p, *p0 = q_arg;
9521 unsigned long int_fld;
9522 char *str_fld[max_num];
9527 p = strchr(p0, '(');
9531 p0 = strchr(p, ')');
9536 if (size >= sizeof(s))
9539 snprintf(s, sizeof(s), "%.*s", size, p);
9540 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9541 if (ret < 0 || ret > max_num)
9543 for (i = 0; i < ret; i++) {
9545 int_fld = strtoul(str_fld[i], &end, 0);
9546 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9548 offsets[i] = (uint16_t)int_fld;
9554 cmd_flow_director_flxpld_parsed(void *parsed_result,
9555 __attribute__((unused)) struct cmdline *cl,
9556 __attribute__((unused)) void *data)
9558 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9559 struct rte_eth_flex_payload_cfg flex_cfg;
9560 struct rte_port *port;
9563 if (res->port_id > nb_ports) {
9564 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9568 port = &ports[res->port_id];
9569 /** Check if the port is not started **/
9570 if (port->port_status != RTE_PORT_STOPPED) {
9571 printf("Please stop port %d first\n", res->port_id);
9575 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9577 if (!strcmp(res->payload_layer, "raw"))
9578 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9579 else if (!strcmp(res->payload_layer, "l2"))
9580 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9581 else if (!strcmp(res->payload_layer, "l3"))
9582 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9583 else if (!strcmp(res->payload_layer, "l4"))
9584 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9586 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9587 RTE_ETH_FDIR_MAX_FLEXLEN);
9589 printf("error: Cannot parse flex payload input.\n");
9593 fdir_set_flex_payload(res->port_id, &flex_cfg);
9594 cmd_reconfig_device_queue(res->port_id, 1, 1);
9597 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9598 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9599 flow_director_flexpayload,
9600 "flow_director_flex_payload");
9601 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9602 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9604 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9606 payload_layer, "raw#l2#l3#l4");
9607 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9611 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9612 .f = cmd_flow_director_flxpld_parsed,
9614 .help_str = "flow_director_flexpayload ... : "
9615 "Set flow director's flex payload on NIC",
9617 (void *)&cmd_flow_director_flexpayload,
9618 (void *)&cmd_flow_director_flexpayload_port_id,
9619 (void *)&cmd_flow_director_flexpayload_payload_layer,
9620 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9625 /* Generic flow interface command. */
9626 extern cmdline_parse_inst_t cmd_flow;
9628 /* *** Classification Filters Control *** */
9629 /* *** Get symmetric hash enable per port *** */
9630 struct cmd_get_sym_hash_ena_per_port_result {
9631 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9636 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9637 __rte_unused struct cmdline *cl,
9638 __rte_unused void *data)
9640 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9641 struct rte_eth_hash_filter_info info;
9644 if (rte_eth_dev_filter_supported(res->port_id,
9645 RTE_ETH_FILTER_HASH) < 0) {
9646 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9651 memset(&info, 0, sizeof(info));
9652 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9653 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9654 RTE_ETH_FILTER_GET, &info);
9657 printf("Cannot get symmetric hash enable per port "
9658 "on port %u\n", res->port_id);
9662 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9663 "enabled" : "disabled", res->port_id);
9666 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9667 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9668 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9669 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9670 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9673 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9674 .f = cmd_get_sym_hash_per_port_parsed,
9676 .help_str = "get_sym_hash_ena_per_port <port_id>",
9678 (void *)&cmd_get_sym_hash_ena_per_port_all,
9679 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9684 /* *** Set symmetric hash enable per port *** */
9685 struct cmd_set_sym_hash_ena_per_port_result {
9686 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9687 cmdline_fixed_string_t enable;
9692 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9693 __rte_unused struct cmdline *cl,
9694 __rte_unused void *data)
9696 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9697 struct rte_eth_hash_filter_info info;
9700 if (rte_eth_dev_filter_supported(res->port_id,
9701 RTE_ETH_FILTER_HASH) < 0) {
9702 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9707 memset(&info, 0, sizeof(info));
9708 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9709 if (!strcmp(res->enable, "enable"))
9710 info.info.enable = 1;
9711 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9712 RTE_ETH_FILTER_SET, &info);
9714 printf("Cannot set symmetric hash enable per port on "
9715 "port %u\n", res->port_id);
9718 printf("Symmetric hash has been set to %s on port %u\n",
9719 res->enable, res->port_id);
9722 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9723 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9724 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9725 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9726 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9728 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9729 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9730 enable, "enable#disable");
9732 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9733 .f = cmd_set_sym_hash_per_port_parsed,
9735 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9737 (void *)&cmd_set_sym_hash_ena_per_port_all,
9738 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9739 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9744 /* Get global config of hash function */
9745 struct cmd_get_hash_global_config_result {
9746 cmdline_fixed_string_t get_hash_global_config;
9751 flowtype_to_str(uint16_t ftype)
9758 {"ipv4", RTE_ETH_FLOW_IPV4},
9759 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9760 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9761 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9762 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9763 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9764 {"ipv6", RTE_ETH_FLOW_IPV6},
9765 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9766 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9767 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9768 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9769 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9770 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9771 {"port", RTE_ETH_FLOW_PORT},
9772 {"vxlan", RTE_ETH_FLOW_VXLAN},
9773 {"geneve", RTE_ETH_FLOW_GENEVE},
9774 {"nvgre", RTE_ETH_FLOW_NVGRE},
9777 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9778 if (ftype_table[i].ftype == ftype)
9779 return ftype_table[i].str;
9786 cmd_get_hash_global_config_parsed(void *parsed_result,
9787 __rte_unused struct cmdline *cl,
9788 __rte_unused void *data)
9790 struct cmd_get_hash_global_config_result *res = parsed_result;
9791 struct rte_eth_hash_filter_info info;
9792 uint32_t idx, offset;
9797 if (rte_eth_dev_filter_supported(res->port_id,
9798 RTE_ETH_FILTER_HASH) < 0) {
9799 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9804 memset(&info, 0, sizeof(info));
9805 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9806 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9807 RTE_ETH_FILTER_GET, &info);
9809 printf("Cannot get hash global configurations by port %d\n",
9814 switch (info.info.global_conf.hash_func) {
9815 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9816 printf("Hash function is Toeplitz\n");
9818 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9819 printf("Hash function is Simple XOR\n");
9822 printf("Unknown hash function\n");
9826 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9827 idx = i / UINT32_BIT;
9828 offset = i % UINT32_BIT;
9829 if (!(info.info.global_conf.valid_bit_mask[idx] &
9832 str = flowtype_to_str(i);
9835 printf("Symmetric hash is %s globally for flow type %s "
9837 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9838 (1UL << offset)) ? "enabled" : "disabled"), str,
9843 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9844 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9845 get_hash_global_config, "get_hash_global_config");
9846 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9847 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9850 cmdline_parse_inst_t cmd_get_hash_global_config = {
9851 .f = cmd_get_hash_global_config_parsed,
9853 .help_str = "get_hash_global_config <port_id>",
9855 (void *)&cmd_get_hash_global_config_all,
9856 (void *)&cmd_get_hash_global_config_port_id,
9861 /* Set global config of hash function */
9862 struct cmd_set_hash_global_config_result {
9863 cmdline_fixed_string_t set_hash_global_config;
9865 cmdline_fixed_string_t hash_func;
9866 cmdline_fixed_string_t flow_type;
9867 cmdline_fixed_string_t enable;
9871 cmd_set_hash_global_config_parsed(void *parsed_result,
9872 __rte_unused struct cmdline *cl,
9873 __rte_unused void *data)
9875 struct cmd_set_hash_global_config_result *res = parsed_result;
9876 struct rte_eth_hash_filter_info info;
9877 uint32_t ftype, idx, offset;
9880 if (rte_eth_dev_filter_supported(res->port_id,
9881 RTE_ETH_FILTER_HASH) < 0) {
9882 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9886 memset(&info, 0, sizeof(info));
9887 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9888 if (!strcmp(res->hash_func, "toeplitz"))
9889 info.info.global_conf.hash_func =
9890 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9891 else if (!strcmp(res->hash_func, "simple_xor"))
9892 info.info.global_conf.hash_func =
9893 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9894 else if (!strcmp(res->hash_func, "default"))
9895 info.info.global_conf.hash_func =
9896 RTE_ETH_HASH_FUNCTION_DEFAULT;
9898 ftype = str2flowtype(res->flow_type);
9899 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9900 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9901 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9902 if (!strcmp(res->enable, "enable"))
9903 info.info.global_conf.sym_hash_enable_mask[idx] |=
9905 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9906 RTE_ETH_FILTER_SET, &info);
9908 printf("Cannot set global hash configurations by port %d\n",
9911 printf("Global hash configurations have been set "
9912 "succcessfully by port %d\n", res->port_id);
9915 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9916 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9917 set_hash_global_config, "set_hash_global_config");
9918 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9919 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9921 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9922 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9923 hash_func, "toeplitz#simple_xor#default");
9924 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9925 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9927 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9928 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9929 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9930 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9931 enable, "enable#disable");
9933 cmdline_parse_inst_t cmd_set_hash_global_config = {
9934 .f = cmd_set_hash_global_config_parsed,
9936 .help_str = "set_hash_global_config <port_id> "
9937 "toeplitz|simple_xor|default "
9938 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9939 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9940 "l2_payload enable|disable",
9942 (void *)&cmd_set_hash_global_config_all,
9943 (void *)&cmd_set_hash_global_config_port_id,
9944 (void *)&cmd_set_hash_global_config_hash_func,
9945 (void *)&cmd_set_hash_global_config_flow_type,
9946 (void *)&cmd_set_hash_global_config_enable,
9951 /* Set hash input set */
9952 struct cmd_set_hash_input_set_result {
9953 cmdline_fixed_string_t set_hash_input_set;
9955 cmdline_fixed_string_t flow_type;
9956 cmdline_fixed_string_t inset_field;
9957 cmdline_fixed_string_t select;
9960 static enum rte_eth_input_set_field
9961 str2inset(char *string)
9965 static const struct {
9967 enum rte_eth_input_set_field inset;
9969 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9970 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9971 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9972 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9973 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9974 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9975 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9976 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9977 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9978 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9979 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9980 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9981 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9982 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9983 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9984 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9985 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9986 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9987 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9988 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9989 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9990 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9991 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9992 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9993 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9994 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9995 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9996 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9997 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9998 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9999 {"none", RTE_ETH_INPUT_SET_NONE},
10002 for (i = 0; i < RTE_DIM(inset_table); i++) {
10003 if (!strcmp(string, inset_table[i].str))
10004 return inset_table[i].inset;
10007 return RTE_ETH_INPUT_SET_UNKNOWN;
10011 cmd_set_hash_input_set_parsed(void *parsed_result,
10012 __rte_unused struct cmdline *cl,
10013 __rte_unused void *data)
10015 struct cmd_set_hash_input_set_result *res = parsed_result;
10016 struct rte_eth_hash_filter_info info;
10018 memset(&info, 0, sizeof(info));
10019 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10020 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10021 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10022 info.info.input_set_conf.inset_size = 1;
10023 if (!strcmp(res->select, "select"))
10024 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10025 else if (!strcmp(res->select, "add"))
10026 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10027 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10028 RTE_ETH_FILTER_SET, &info);
10031 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10032 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10033 set_hash_input_set, "set_hash_input_set");
10034 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10035 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10037 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10038 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10040 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10041 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10042 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10043 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10045 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10046 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10047 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10048 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10049 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10051 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10052 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10053 select, "select#add");
10055 cmdline_parse_inst_t cmd_set_hash_input_set = {
10056 .f = cmd_set_hash_input_set_parsed,
10058 .help_str = "set_hash_input_set <port_id> "
10059 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10060 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10061 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10062 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10063 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10064 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10065 "fld-7th|fld-8th|none select|add",
10067 (void *)&cmd_set_hash_input_set_cmd,
10068 (void *)&cmd_set_hash_input_set_port_id,
10069 (void *)&cmd_set_hash_input_set_flow_type,
10070 (void *)&cmd_set_hash_input_set_field,
10071 (void *)&cmd_set_hash_input_set_select,
10076 /* Set flow director input set */
10077 struct cmd_set_fdir_input_set_result {
10078 cmdline_fixed_string_t set_fdir_input_set;
10080 cmdline_fixed_string_t flow_type;
10081 cmdline_fixed_string_t inset_field;
10082 cmdline_fixed_string_t select;
10086 cmd_set_fdir_input_set_parsed(void *parsed_result,
10087 __rte_unused struct cmdline *cl,
10088 __rte_unused void *data)
10090 struct cmd_set_fdir_input_set_result *res = parsed_result;
10091 struct rte_eth_fdir_filter_info info;
10093 memset(&info, 0, sizeof(info));
10094 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10095 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10096 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10097 info.info.input_set_conf.inset_size = 1;
10098 if (!strcmp(res->select, "select"))
10099 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10100 else if (!strcmp(res->select, "add"))
10101 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10102 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10103 RTE_ETH_FILTER_SET, &info);
10106 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10107 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10108 set_fdir_input_set, "set_fdir_input_set");
10109 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10110 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10112 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10113 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10115 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10116 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10117 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10118 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10120 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10121 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10122 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10123 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10124 "sctp-veri-tag#none");
10125 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10126 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10127 select, "select#add");
10129 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10130 .f = cmd_set_fdir_input_set_parsed,
10132 .help_str = "set_fdir_input_set <port_id> "
10133 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10134 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10135 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10136 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10137 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10138 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10139 "sctp-veri-tag|none select|add",
10141 (void *)&cmd_set_fdir_input_set_cmd,
10142 (void *)&cmd_set_fdir_input_set_port_id,
10143 (void *)&cmd_set_fdir_input_set_flow_type,
10144 (void *)&cmd_set_fdir_input_set_field,
10145 (void *)&cmd_set_fdir_input_set_select,
10150 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10151 struct cmd_mcast_addr_result {
10152 cmdline_fixed_string_t mcast_addr_cmd;
10153 cmdline_fixed_string_t what;
10155 struct ether_addr mc_addr;
10158 static void cmd_mcast_addr_parsed(void *parsed_result,
10159 __attribute__((unused)) struct cmdline *cl,
10160 __attribute__((unused)) void *data)
10162 struct cmd_mcast_addr_result *res = parsed_result;
10164 if (!is_multicast_ether_addr(&res->mc_addr)) {
10165 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10166 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10167 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10168 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10171 if (strcmp(res->what, "add") == 0)
10172 mcast_addr_add(res->port_num, &res->mc_addr);
10174 mcast_addr_remove(res->port_num, &res->mc_addr);
10177 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10178 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10179 mcast_addr_cmd, "mcast_addr");
10180 cmdline_parse_token_string_t cmd_mcast_addr_what =
10181 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10183 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10184 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10185 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10186 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10188 cmdline_parse_inst_t cmd_mcast_addr = {
10189 .f = cmd_mcast_addr_parsed,
10191 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10192 "Add/Remove multicast MAC address on port_id",
10194 (void *)&cmd_mcast_addr_cmd,
10195 (void *)&cmd_mcast_addr_what,
10196 (void *)&cmd_mcast_addr_portnum,
10197 (void *)&cmd_mcast_addr_addr,
10202 /* l2 tunnel config
10203 * only support E-tag now.
10206 /* Ether type config */
10207 struct cmd_config_l2_tunnel_eth_type_result {
10208 cmdline_fixed_string_t port;
10209 cmdline_fixed_string_t config;
10210 cmdline_fixed_string_t all;
10212 cmdline_fixed_string_t l2_tunnel;
10213 cmdline_fixed_string_t l2_tunnel_type;
10214 cmdline_fixed_string_t eth_type;
10215 uint16_t eth_type_val;
10218 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10219 TOKEN_STRING_INITIALIZER
10220 (struct cmd_config_l2_tunnel_eth_type_result,
10222 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10223 TOKEN_STRING_INITIALIZER
10224 (struct cmd_config_l2_tunnel_eth_type_result,
10226 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10227 TOKEN_STRING_INITIALIZER
10228 (struct cmd_config_l2_tunnel_eth_type_result,
10230 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10231 TOKEN_NUM_INITIALIZER
10232 (struct cmd_config_l2_tunnel_eth_type_result,
10234 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10235 TOKEN_STRING_INITIALIZER
10236 (struct cmd_config_l2_tunnel_eth_type_result,
10237 l2_tunnel, "l2-tunnel");
10238 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10239 TOKEN_STRING_INITIALIZER
10240 (struct cmd_config_l2_tunnel_eth_type_result,
10241 l2_tunnel_type, "E-tag");
10242 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10243 TOKEN_STRING_INITIALIZER
10244 (struct cmd_config_l2_tunnel_eth_type_result,
10245 eth_type, "ether-type");
10246 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10247 TOKEN_NUM_INITIALIZER
10248 (struct cmd_config_l2_tunnel_eth_type_result,
10249 eth_type_val, UINT16);
10251 static enum rte_eth_tunnel_type
10252 str2fdir_l2_tunnel_type(char *string)
10256 static const struct {
10258 enum rte_eth_tunnel_type type;
10259 } l2_tunnel_type_str[] = {
10260 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10263 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10264 if (!strcmp(l2_tunnel_type_str[i].str, string))
10265 return l2_tunnel_type_str[i].type;
10267 return RTE_TUNNEL_TYPE_NONE;
10270 /* ether type config for all ports */
10272 cmd_config_l2_tunnel_eth_type_all_parsed
10273 (void *parsed_result,
10274 __attribute__((unused)) struct cmdline *cl,
10275 __attribute__((unused)) void *data)
10277 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10278 struct rte_eth_l2_tunnel_conf entry;
10281 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10282 entry.ether_type = res->eth_type_val;
10284 FOREACH_PORT(pid, ports) {
10285 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10289 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10290 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10292 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10294 (void *)&cmd_config_l2_tunnel_eth_type_port,
10295 (void *)&cmd_config_l2_tunnel_eth_type_config,
10296 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10297 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10298 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10299 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10300 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10305 /* ether type config for a specific port */
10307 cmd_config_l2_tunnel_eth_type_specific_parsed(
10308 void *parsed_result,
10309 __attribute__((unused)) struct cmdline *cl,
10310 __attribute__((unused)) void *data)
10312 struct cmd_config_l2_tunnel_eth_type_result *res =
10314 struct rte_eth_l2_tunnel_conf entry;
10316 if (port_id_is_invalid(res->id, ENABLED_WARN))
10319 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10320 entry.ether_type = res->eth_type_val;
10322 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10325 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10326 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10328 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10330 (void *)&cmd_config_l2_tunnel_eth_type_port,
10331 (void *)&cmd_config_l2_tunnel_eth_type_config,
10332 (void *)&cmd_config_l2_tunnel_eth_type_id,
10333 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10334 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10335 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10336 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10341 /* Enable/disable l2 tunnel */
10342 struct cmd_config_l2_tunnel_en_dis_result {
10343 cmdline_fixed_string_t port;
10344 cmdline_fixed_string_t config;
10345 cmdline_fixed_string_t all;
10347 cmdline_fixed_string_t l2_tunnel;
10348 cmdline_fixed_string_t l2_tunnel_type;
10349 cmdline_fixed_string_t en_dis;
10352 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10353 TOKEN_STRING_INITIALIZER
10354 (struct cmd_config_l2_tunnel_en_dis_result,
10356 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10357 TOKEN_STRING_INITIALIZER
10358 (struct cmd_config_l2_tunnel_en_dis_result,
10360 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10361 TOKEN_STRING_INITIALIZER
10362 (struct cmd_config_l2_tunnel_en_dis_result,
10364 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10365 TOKEN_NUM_INITIALIZER
10366 (struct cmd_config_l2_tunnel_en_dis_result,
10368 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10369 TOKEN_STRING_INITIALIZER
10370 (struct cmd_config_l2_tunnel_en_dis_result,
10371 l2_tunnel, "l2-tunnel");
10372 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10373 TOKEN_STRING_INITIALIZER
10374 (struct cmd_config_l2_tunnel_en_dis_result,
10375 l2_tunnel_type, "E-tag");
10376 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10377 TOKEN_STRING_INITIALIZER
10378 (struct cmd_config_l2_tunnel_en_dis_result,
10379 en_dis, "enable#disable");
10381 /* enable/disable l2 tunnel for all ports */
10383 cmd_config_l2_tunnel_en_dis_all_parsed(
10384 void *parsed_result,
10385 __attribute__((unused)) struct cmdline *cl,
10386 __attribute__((unused)) void *data)
10388 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10389 struct rte_eth_l2_tunnel_conf entry;
10393 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10395 if (!strcmp("enable", res->en_dis))
10400 FOREACH_PORT(pid, ports) {
10401 rte_eth_dev_l2_tunnel_offload_set(pid,
10403 ETH_L2_TUNNEL_ENABLE_MASK,
10408 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10409 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10411 .help_str = "port config all l2-tunnel E-tag enable|disable",
10413 (void *)&cmd_config_l2_tunnel_en_dis_port,
10414 (void *)&cmd_config_l2_tunnel_en_dis_config,
10415 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10416 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10417 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10418 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10423 /* enable/disable l2 tunnel for a port */
10425 cmd_config_l2_tunnel_en_dis_specific_parsed(
10426 void *parsed_result,
10427 __attribute__((unused)) struct cmdline *cl,
10428 __attribute__((unused)) void *data)
10430 struct cmd_config_l2_tunnel_en_dis_result *res =
10432 struct rte_eth_l2_tunnel_conf entry;
10434 if (port_id_is_invalid(res->id, ENABLED_WARN))
10437 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10439 if (!strcmp("enable", res->en_dis))
10440 rte_eth_dev_l2_tunnel_offload_set(res->id,
10442 ETH_L2_TUNNEL_ENABLE_MASK,
10445 rte_eth_dev_l2_tunnel_offload_set(res->id,
10447 ETH_L2_TUNNEL_ENABLE_MASK,
10451 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10452 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10454 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10456 (void *)&cmd_config_l2_tunnel_en_dis_port,
10457 (void *)&cmd_config_l2_tunnel_en_dis_config,
10458 (void *)&cmd_config_l2_tunnel_en_dis_id,
10459 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10460 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10461 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10466 /* E-tag configuration */
10468 /* Common result structure for all E-tag configuration */
10469 struct cmd_config_e_tag_result {
10470 cmdline_fixed_string_t e_tag;
10471 cmdline_fixed_string_t set;
10472 cmdline_fixed_string_t insertion;
10473 cmdline_fixed_string_t stripping;
10474 cmdline_fixed_string_t forwarding;
10475 cmdline_fixed_string_t filter;
10476 cmdline_fixed_string_t add;
10477 cmdline_fixed_string_t del;
10478 cmdline_fixed_string_t on;
10479 cmdline_fixed_string_t off;
10480 cmdline_fixed_string_t on_off;
10481 cmdline_fixed_string_t port_tag_id;
10482 uint32_t port_tag_id_val;
10483 cmdline_fixed_string_t e_tag_id;
10484 uint16_t e_tag_id_val;
10485 cmdline_fixed_string_t dst_pool;
10486 uint8_t dst_pool_val;
10487 cmdline_fixed_string_t port;
10489 cmdline_fixed_string_t vf;
10493 /* Common CLI fields for all E-tag configuration */
10494 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10495 TOKEN_STRING_INITIALIZER
10496 (struct cmd_config_e_tag_result,
10498 cmdline_parse_token_string_t cmd_config_e_tag_set =
10499 TOKEN_STRING_INITIALIZER
10500 (struct cmd_config_e_tag_result,
10502 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10503 TOKEN_STRING_INITIALIZER
10504 (struct cmd_config_e_tag_result,
10505 insertion, "insertion");
10506 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10507 TOKEN_STRING_INITIALIZER
10508 (struct cmd_config_e_tag_result,
10509 stripping, "stripping");
10510 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10511 TOKEN_STRING_INITIALIZER
10512 (struct cmd_config_e_tag_result,
10513 forwarding, "forwarding");
10514 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10515 TOKEN_STRING_INITIALIZER
10516 (struct cmd_config_e_tag_result,
10518 cmdline_parse_token_string_t cmd_config_e_tag_add =
10519 TOKEN_STRING_INITIALIZER
10520 (struct cmd_config_e_tag_result,
10522 cmdline_parse_token_string_t cmd_config_e_tag_del =
10523 TOKEN_STRING_INITIALIZER
10524 (struct cmd_config_e_tag_result,
10526 cmdline_parse_token_string_t cmd_config_e_tag_on =
10527 TOKEN_STRING_INITIALIZER
10528 (struct cmd_config_e_tag_result,
10530 cmdline_parse_token_string_t cmd_config_e_tag_off =
10531 TOKEN_STRING_INITIALIZER
10532 (struct cmd_config_e_tag_result,
10534 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10535 TOKEN_STRING_INITIALIZER
10536 (struct cmd_config_e_tag_result,
10538 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10539 TOKEN_STRING_INITIALIZER
10540 (struct cmd_config_e_tag_result,
10541 port_tag_id, "port-tag-id");
10542 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10543 TOKEN_NUM_INITIALIZER
10544 (struct cmd_config_e_tag_result,
10545 port_tag_id_val, UINT32);
10546 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10547 TOKEN_STRING_INITIALIZER
10548 (struct cmd_config_e_tag_result,
10549 e_tag_id, "e-tag-id");
10550 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10551 TOKEN_NUM_INITIALIZER
10552 (struct cmd_config_e_tag_result,
10553 e_tag_id_val, UINT16);
10554 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10555 TOKEN_STRING_INITIALIZER
10556 (struct cmd_config_e_tag_result,
10557 dst_pool, "dst-pool");
10558 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10559 TOKEN_NUM_INITIALIZER
10560 (struct cmd_config_e_tag_result,
10561 dst_pool_val, UINT8);
10562 cmdline_parse_token_string_t cmd_config_e_tag_port =
10563 TOKEN_STRING_INITIALIZER
10564 (struct cmd_config_e_tag_result,
10566 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10567 TOKEN_NUM_INITIALIZER
10568 (struct cmd_config_e_tag_result,
10570 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10571 TOKEN_STRING_INITIALIZER
10572 (struct cmd_config_e_tag_result,
10574 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10575 TOKEN_NUM_INITIALIZER
10576 (struct cmd_config_e_tag_result,
10579 /* E-tag insertion configuration */
10581 cmd_config_e_tag_insertion_en_parsed(
10582 void *parsed_result,
10583 __attribute__((unused)) struct cmdline *cl,
10584 __attribute__((unused)) void *data)
10586 struct cmd_config_e_tag_result *res =
10588 struct rte_eth_l2_tunnel_conf entry;
10590 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10593 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10594 entry.tunnel_id = res->port_tag_id_val;
10595 entry.vf_id = res->vf_id;
10596 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10598 ETH_L2_TUNNEL_INSERTION_MASK,
10603 cmd_config_e_tag_insertion_dis_parsed(
10604 void *parsed_result,
10605 __attribute__((unused)) struct cmdline *cl,
10606 __attribute__((unused)) void *data)
10608 struct cmd_config_e_tag_result *res =
10610 struct rte_eth_l2_tunnel_conf entry;
10612 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10615 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10616 entry.vf_id = res->vf_id;
10618 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10620 ETH_L2_TUNNEL_INSERTION_MASK,
10624 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10625 .f = cmd_config_e_tag_insertion_en_parsed,
10627 .help_str = "E-tag ... : E-tag insertion enable",
10629 (void *)&cmd_config_e_tag_e_tag,
10630 (void *)&cmd_config_e_tag_set,
10631 (void *)&cmd_config_e_tag_insertion,
10632 (void *)&cmd_config_e_tag_on,
10633 (void *)&cmd_config_e_tag_port_tag_id,
10634 (void *)&cmd_config_e_tag_port_tag_id_val,
10635 (void *)&cmd_config_e_tag_port,
10636 (void *)&cmd_config_e_tag_port_id,
10637 (void *)&cmd_config_e_tag_vf,
10638 (void *)&cmd_config_e_tag_vf_id,
10643 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10644 .f = cmd_config_e_tag_insertion_dis_parsed,
10646 .help_str = "E-tag ... : E-tag insertion disable",
10648 (void *)&cmd_config_e_tag_e_tag,
10649 (void *)&cmd_config_e_tag_set,
10650 (void *)&cmd_config_e_tag_insertion,
10651 (void *)&cmd_config_e_tag_off,
10652 (void *)&cmd_config_e_tag_port,
10653 (void *)&cmd_config_e_tag_port_id,
10654 (void *)&cmd_config_e_tag_vf,
10655 (void *)&cmd_config_e_tag_vf_id,
10660 /* E-tag stripping configuration */
10662 cmd_config_e_tag_stripping_parsed(
10663 void *parsed_result,
10664 __attribute__((unused)) struct cmdline *cl,
10665 __attribute__((unused)) void *data)
10667 struct cmd_config_e_tag_result *res =
10669 struct rte_eth_l2_tunnel_conf entry;
10671 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10674 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10676 if (!strcmp(res->on_off, "on"))
10677 rte_eth_dev_l2_tunnel_offload_set
10680 ETH_L2_TUNNEL_STRIPPING_MASK,
10683 rte_eth_dev_l2_tunnel_offload_set
10686 ETH_L2_TUNNEL_STRIPPING_MASK,
10690 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10691 .f = cmd_config_e_tag_stripping_parsed,
10693 .help_str = "E-tag ... : E-tag stripping enable/disable",
10695 (void *)&cmd_config_e_tag_e_tag,
10696 (void *)&cmd_config_e_tag_set,
10697 (void *)&cmd_config_e_tag_stripping,
10698 (void *)&cmd_config_e_tag_on_off,
10699 (void *)&cmd_config_e_tag_port,
10700 (void *)&cmd_config_e_tag_port_id,
10705 /* E-tag forwarding configuration */
10707 cmd_config_e_tag_forwarding_parsed(
10708 void *parsed_result,
10709 __attribute__((unused)) struct cmdline *cl,
10710 __attribute__((unused)) void *data)
10712 struct cmd_config_e_tag_result *res = parsed_result;
10713 struct rte_eth_l2_tunnel_conf entry;
10715 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10718 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10720 if (!strcmp(res->on_off, "on"))
10721 rte_eth_dev_l2_tunnel_offload_set
10724 ETH_L2_TUNNEL_FORWARDING_MASK,
10727 rte_eth_dev_l2_tunnel_offload_set
10730 ETH_L2_TUNNEL_FORWARDING_MASK,
10734 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10735 .f = cmd_config_e_tag_forwarding_parsed,
10737 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10739 (void *)&cmd_config_e_tag_e_tag,
10740 (void *)&cmd_config_e_tag_set,
10741 (void *)&cmd_config_e_tag_forwarding,
10742 (void *)&cmd_config_e_tag_on_off,
10743 (void *)&cmd_config_e_tag_port,
10744 (void *)&cmd_config_e_tag_port_id,
10749 /* E-tag filter configuration */
10751 cmd_config_e_tag_filter_add_parsed(
10752 void *parsed_result,
10753 __attribute__((unused)) struct cmdline *cl,
10754 __attribute__((unused)) void *data)
10756 struct cmd_config_e_tag_result *res = parsed_result;
10757 struct rte_eth_l2_tunnel_conf entry;
10760 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10763 if (res->e_tag_id_val > 0x3fff) {
10764 printf("e-tag-id must be equal or less than 0x3fff.\n");
10768 ret = rte_eth_dev_filter_supported(res->port_id,
10769 RTE_ETH_FILTER_L2_TUNNEL);
10771 printf("E-tag filter is not supported on port %u.\n",
10776 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10777 entry.tunnel_id = res->e_tag_id_val;
10778 entry.pool = res->dst_pool_val;
10780 ret = rte_eth_dev_filter_ctrl(res->port_id,
10781 RTE_ETH_FILTER_L2_TUNNEL,
10782 RTE_ETH_FILTER_ADD,
10785 printf("E-tag filter programming error: (%s)\n",
10789 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10790 .f = cmd_config_e_tag_filter_add_parsed,
10792 .help_str = "E-tag ... : E-tag filter add",
10794 (void *)&cmd_config_e_tag_e_tag,
10795 (void *)&cmd_config_e_tag_set,
10796 (void *)&cmd_config_e_tag_filter,
10797 (void *)&cmd_config_e_tag_add,
10798 (void *)&cmd_config_e_tag_e_tag_id,
10799 (void *)&cmd_config_e_tag_e_tag_id_val,
10800 (void *)&cmd_config_e_tag_dst_pool,
10801 (void *)&cmd_config_e_tag_dst_pool_val,
10802 (void *)&cmd_config_e_tag_port,
10803 (void *)&cmd_config_e_tag_port_id,
10809 cmd_config_e_tag_filter_del_parsed(
10810 void *parsed_result,
10811 __attribute__((unused)) struct cmdline *cl,
10812 __attribute__((unused)) void *data)
10814 struct cmd_config_e_tag_result *res = parsed_result;
10815 struct rte_eth_l2_tunnel_conf entry;
10818 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10821 if (res->e_tag_id_val > 0x3fff) {
10822 printf("e-tag-id must be less than 0x3fff.\n");
10826 ret = rte_eth_dev_filter_supported(res->port_id,
10827 RTE_ETH_FILTER_L2_TUNNEL);
10829 printf("E-tag filter is not supported on port %u.\n",
10834 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10835 entry.tunnel_id = res->e_tag_id_val;
10837 ret = rte_eth_dev_filter_ctrl(res->port_id,
10838 RTE_ETH_FILTER_L2_TUNNEL,
10839 RTE_ETH_FILTER_DELETE,
10842 printf("E-tag filter programming error: (%s)\n",
10846 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10847 .f = cmd_config_e_tag_filter_del_parsed,
10849 .help_str = "E-tag ... : E-tag filter delete",
10851 (void *)&cmd_config_e_tag_e_tag,
10852 (void *)&cmd_config_e_tag_set,
10853 (void *)&cmd_config_e_tag_filter,
10854 (void *)&cmd_config_e_tag_del,
10855 (void *)&cmd_config_e_tag_e_tag_id,
10856 (void *)&cmd_config_e_tag_e_tag_id_val,
10857 (void *)&cmd_config_e_tag_port,
10858 (void *)&cmd_config_e_tag_port_id,
10863 /* vf vlan anti spoof configuration */
10865 /* Common result structure for vf vlan anti spoof */
10866 struct cmd_vf_vlan_anti_spoof_result {
10867 cmdline_fixed_string_t set;
10868 cmdline_fixed_string_t vf;
10869 cmdline_fixed_string_t vlan;
10870 cmdline_fixed_string_t antispoof;
10873 cmdline_fixed_string_t on_off;
10876 /* Common CLI fields for vf vlan anti spoof enable disable */
10877 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10878 TOKEN_STRING_INITIALIZER
10879 (struct cmd_vf_vlan_anti_spoof_result,
10881 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10882 TOKEN_STRING_INITIALIZER
10883 (struct cmd_vf_vlan_anti_spoof_result,
10885 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10886 TOKEN_STRING_INITIALIZER
10887 (struct cmd_vf_vlan_anti_spoof_result,
10889 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10890 TOKEN_STRING_INITIALIZER
10891 (struct cmd_vf_vlan_anti_spoof_result,
10892 antispoof, "antispoof");
10893 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10894 TOKEN_NUM_INITIALIZER
10895 (struct cmd_vf_vlan_anti_spoof_result,
10897 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10898 TOKEN_NUM_INITIALIZER
10899 (struct cmd_vf_vlan_anti_spoof_result,
10901 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10902 TOKEN_STRING_INITIALIZER
10903 (struct cmd_vf_vlan_anti_spoof_result,
10907 cmd_set_vf_vlan_anti_spoof_parsed(
10908 void *parsed_result,
10909 __attribute__((unused)) struct cmdline *cl,
10910 __attribute__((unused)) void *data)
10912 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10913 int ret = -ENOTSUP;
10915 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10917 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10920 #ifdef RTE_LIBRTE_IXGBE_PMD
10921 if (ret == -ENOTSUP)
10922 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10923 res->vf_id, is_on);
10925 #ifdef RTE_LIBRTE_I40E_PMD
10926 if (ret == -ENOTSUP)
10927 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10928 res->vf_id, is_on);
10935 printf("invalid vf_id %d\n", res->vf_id);
10938 printf("invalid port_id %d\n", res->port_id);
10941 printf("function not implemented\n");
10944 printf("programming error: (%s)\n", strerror(-ret));
10948 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10949 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10951 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10953 (void *)&cmd_vf_vlan_anti_spoof_set,
10954 (void *)&cmd_vf_vlan_anti_spoof_vf,
10955 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10956 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10957 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10958 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10959 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10964 /* vf mac anti spoof configuration */
10966 /* Common result structure for vf mac anti spoof */
10967 struct cmd_vf_mac_anti_spoof_result {
10968 cmdline_fixed_string_t set;
10969 cmdline_fixed_string_t vf;
10970 cmdline_fixed_string_t mac;
10971 cmdline_fixed_string_t antispoof;
10974 cmdline_fixed_string_t on_off;
10977 /* Common CLI fields for vf mac anti spoof enable disable */
10978 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10979 TOKEN_STRING_INITIALIZER
10980 (struct cmd_vf_mac_anti_spoof_result,
10982 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10983 TOKEN_STRING_INITIALIZER
10984 (struct cmd_vf_mac_anti_spoof_result,
10986 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10987 TOKEN_STRING_INITIALIZER
10988 (struct cmd_vf_mac_anti_spoof_result,
10990 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10991 TOKEN_STRING_INITIALIZER
10992 (struct cmd_vf_mac_anti_spoof_result,
10993 antispoof, "antispoof");
10994 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10995 TOKEN_NUM_INITIALIZER
10996 (struct cmd_vf_mac_anti_spoof_result,
10998 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10999 TOKEN_NUM_INITIALIZER
11000 (struct cmd_vf_mac_anti_spoof_result,
11002 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11003 TOKEN_STRING_INITIALIZER
11004 (struct cmd_vf_mac_anti_spoof_result,
11008 cmd_set_vf_mac_anti_spoof_parsed(
11009 void *parsed_result,
11010 __attribute__((unused)) struct cmdline *cl,
11011 __attribute__((unused)) void *data)
11013 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11014 int ret = -ENOTSUP;
11016 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11018 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11021 #ifdef RTE_LIBRTE_IXGBE_PMD
11022 if (ret == -ENOTSUP)
11023 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11024 res->vf_id, is_on);
11026 #ifdef RTE_LIBRTE_I40E_PMD
11027 if (ret == -ENOTSUP)
11028 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11029 res->vf_id, is_on);
11036 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11039 printf("invalid port_id %d\n", res->port_id);
11042 printf("function not implemented\n");
11045 printf("programming error: (%s)\n", strerror(-ret));
11049 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11050 .f = cmd_set_vf_mac_anti_spoof_parsed,
11052 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11054 (void *)&cmd_vf_mac_anti_spoof_set,
11055 (void *)&cmd_vf_mac_anti_spoof_vf,
11056 (void *)&cmd_vf_mac_anti_spoof_mac,
11057 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11058 (void *)&cmd_vf_mac_anti_spoof_port_id,
11059 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11060 (void *)&cmd_vf_mac_anti_spoof_on_off,
11065 /* vf vlan strip queue configuration */
11067 /* Common result structure for vf mac anti spoof */
11068 struct cmd_vf_vlan_stripq_result {
11069 cmdline_fixed_string_t set;
11070 cmdline_fixed_string_t vf;
11071 cmdline_fixed_string_t vlan;
11072 cmdline_fixed_string_t stripq;
11075 cmdline_fixed_string_t on_off;
11078 /* Common CLI fields for vf vlan strip enable disable */
11079 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11080 TOKEN_STRING_INITIALIZER
11081 (struct cmd_vf_vlan_stripq_result,
11083 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11084 TOKEN_STRING_INITIALIZER
11085 (struct cmd_vf_vlan_stripq_result,
11087 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11088 TOKEN_STRING_INITIALIZER
11089 (struct cmd_vf_vlan_stripq_result,
11091 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11092 TOKEN_STRING_INITIALIZER
11093 (struct cmd_vf_vlan_stripq_result,
11095 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11096 TOKEN_NUM_INITIALIZER
11097 (struct cmd_vf_vlan_stripq_result,
11099 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11100 TOKEN_NUM_INITIALIZER
11101 (struct cmd_vf_vlan_stripq_result,
11103 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11104 TOKEN_STRING_INITIALIZER
11105 (struct cmd_vf_vlan_stripq_result,
11109 cmd_set_vf_vlan_stripq_parsed(
11110 void *parsed_result,
11111 __attribute__((unused)) struct cmdline *cl,
11112 __attribute__((unused)) void *data)
11114 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11115 int ret = -ENOTSUP;
11117 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11119 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11122 #ifdef RTE_LIBRTE_IXGBE_PMD
11123 if (ret == -ENOTSUP)
11124 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11125 res->vf_id, is_on);
11127 #ifdef RTE_LIBRTE_I40E_PMD
11128 if (ret == -ENOTSUP)
11129 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11130 res->vf_id, is_on);
11137 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11140 printf("invalid port_id %d\n", res->port_id);
11143 printf("function not implemented\n");
11146 printf("programming error: (%s)\n", strerror(-ret));
11150 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11151 .f = cmd_set_vf_vlan_stripq_parsed,
11153 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11155 (void *)&cmd_vf_vlan_stripq_set,
11156 (void *)&cmd_vf_vlan_stripq_vf,
11157 (void *)&cmd_vf_vlan_stripq_vlan,
11158 (void *)&cmd_vf_vlan_stripq_stripq,
11159 (void *)&cmd_vf_vlan_stripq_port_id,
11160 (void *)&cmd_vf_vlan_stripq_vf_id,
11161 (void *)&cmd_vf_vlan_stripq_on_off,
11166 /* vf vlan insert configuration */
11168 /* Common result structure for vf vlan insert */
11169 struct cmd_vf_vlan_insert_result {
11170 cmdline_fixed_string_t set;
11171 cmdline_fixed_string_t vf;
11172 cmdline_fixed_string_t vlan;
11173 cmdline_fixed_string_t insert;
11179 /* Common CLI fields for vf vlan insert enable disable */
11180 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11181 TOKEN_STRING_INITIALIZER
11182 (struct cmd_vf_vlan_insert_result,
11184 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11185 TOKEN_STRING_INITIALIZER
11186 (struct cmd_vf_vlan_insert_result,
11188 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11189 TOKEN_STRING_INITIALIZER
11190 (struct cmd_vf_vlan_insert_result,
11192 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11193 TOKEN_STRING_INITIALIZER
11194 (struct cmd_vf_vlan_insert_result,
11196 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11197 TOKEN_NUM_INITIALIZER
11198 (struct cmd_vf_vlan_insert_result,
11200 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11201 TOKEN_NUM_INITIALIZER
11202 (struct cmd_vf_vlan_insert_result,
11204 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11205 TOKEN_NUM_INITIALIZER
11206 (struct cmd_vf_vlan_insert_result,
11210 cmd_set_vf_vlan_insert_parsed(
11211 void *parsed_result,
11212 __attribute__((unused)) struct cmdline *cl,
11213 __attribute__((unused)) void *data)
11215 struct cmd_vf_vlan_insert_result *res = parsed_result;
11216 int ret = -ENOTSUP;
11218 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11221 #ifdef RTE_LIBRTE_IXGBE_PMD
11222 if (ret == -ENOTSUP)
11223 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11226 #ifdef RTE_LIBRTE_I40E_PMD
11227 if (ret == -ENOTSUP)
11228 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11236 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11239 printf("invalid port_id %d\n", res->port_id);
11242 printf("function not implemented\n");
11245 printf("programming error: (%s)\n", strerror(-ret));
11249 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11250 .f = cmd_set_vf_vlan_insert_parsed,
11252 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11254 (void *)&cmd_vf_vlan_insert_set,
11255 (void *)&cmd_vf_vlan_insert_vf,
11256 (void *)&cmd_vf_vlan_insert_vlan,
11257 (void *)&cmd_vf_vlan_insert_insert,
11258 (void *)&cmd_vf_vlan_insert_port_id,
11259 (void *)&cmd_vf_vlan_insert_vf_id,
11260 (void *)&cmd_vf_vlan_insert_vlan_id,
11265 /* tx loopback configuration */
11267 /* Common result structure for tx loopback */
11268 struct cmd_tx_loopback_result {
11269 cmdline_fixed_string_t set;
11270 cmdline_fixed_string_t tx;
11271 cmdline_fixed_string_t loopback;
11273 cmdline_fixed_string_t on_off;
11276 /* Common CLI fields for tx loopback enable disable */
11277 cmdline_parse_token_string_t cmd_tx_loopback_set =
11278 TOKEN_STRING_INITIALIZER
11279 (struct cmd_tx_loopback_result,
11281 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11282 TOKEN_STRING_INITIALIZER
11283 (struct cmd_tx_loopback_result,
11285 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11286 TOKEN_STRING_INITIALIZER
11287 (struct cmd_tx_loopback_result,
11288 loopback, "loopback");
11289 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11290 TOKEN_NUM_INITIALIZER
11291 (struct cmd_tx_loopback_result,
11293 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11294 TOKEN_STRING_INITIALIZER
11295 (struct cmd_tx_loopback_result,
11299 cmd_set_tx_loopback_parsed(
11300 void *parsed_result,
11301 __attribute__((unused)) struct cmdline *cl,
11302 __attribute__((unused)) void *data)
11304 struct cmd_tx_loopback_result *res = parsed_result;
11305 int ret = -ENOTSUP;
11307 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11309 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11312 #ifdef RTE_LIBRTE_IXGBE_PMD
11313 if (ret == -ENOTSUP)
11314 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11316 #ifdef RTE_LIBRTE_I40E_PMD
11317 if (ret == -ENOTSUP)
11318 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11325 printf("invalid is_on %d\n", is_on);
11328 printf("invalid port_id %d\n", res->port_id);
11331 printf("function not implemented\n");
11334 printf("programming error: (%s)\n", strerror(-ret));
11338 cmdline_parse_inst_t cmd_set_tx_loopback = {
11339 .f = cmd_set_tx_loopback_parsed,
11341 .help_str = "set tx loopback <port_id> on|off",
11343 (void *)&cmd_tx_loopback_set,
11344 (void *)&cmd_tx_loopback_tx,
11345 (void *)&cmd_tx_loopback_loopback,
11346 (void *)&cmd_tx_loopback_port_id,
11347 (void *)&cmd_tx_loopback_on_off,
11352 #ifdef RTE_LIBRTE_IXGBE_PMD
11353 /* all queues drop enable configuration */
11355 /* Common result structure for all queues drop enable */
11356 struct cmd_all_queues_drop_en_result {
11357 cmdline_fixed_string_t set;
11358 cmdline_fixed_string_t all;
11359 cmdline_fixed_string_t queues;
11360 cmdline_fixed_string_t drop;
11362 cmdline_fixed_string_t on_off;
11365 /* Common CLI fields for tx loopback enable disable */
11366 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11367 TOKEN_STRING_INITIALIZER
11368 (struct cmd_all_queues_drop_en_result,
11370 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11371 TOKEN_STRING_INITIALIZER
11372 (struct cmd_all_queues_drop_en_result,
11374 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11375 TOKEN_STRING_INITIALIZER
11376 (struct cmd_all_queues_drop_en_result,
11378 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11379 TOKEN_STRING_INITIALIZER
11380 (struct cmd_all_queues_drop_en_result,
11382 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11383 TOKEN_NUM_INITIALIZER
11384 (struct cmd_all_queues_drop_en_result,
11386 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11387 TOKEN_STRING_INITIALIZER
11388 (struct cmd_all_queues_drop_en_result,
11392 cmd_set_all_queues_drop_en_parsed(
11393 void *parsed_result,
11394 __attribute__((unused)) struct cmdline *cl,
11395 __attribute__((unused)) void *data)
11397 struct cmd_all_queues_drop_en_result *res = parsed_result;
11399 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11401 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11404 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11409 printf("invalid is_on %d\n", is_on);
11412 printf("invalid port_id %d\n", res->port_id);
11415 printf("function not implemented\n");
11418 printf("programming error: (%s)\n", strerror(-ret));
11422 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11423 .f = cmd_set_all_queues_drop_en_parsed,
11425 .help_str = "set all queues drop <port_id> on|off",
11427 (void *)&cmd_all_queues_drop_en_set,
11428 (void *)&cmd_all_queues_drop_en_all,
11429 (void *)&cmd_all_queues_drop_en_queues,
11430 (void *)&cmd_all_queues_drop_en_drop,
11431 (void *)&cmd_all_queues_drop_en_port_id,
11432 (void *)&cmd_all_queues_drop_en_on_off,
11437 /* vf split drop enable configuration */
11439 /* Common result structure for vf split drop enable */
11440 struct cmd_vf_split_drop_en_result {
11441 cmdline_fixed_string_t set;
11442 cmdline_fixed_string_t vf;
11443 cmdline_fixed_string_t split;
11444 cmdline_fixed_string_t drop;
11447 cmdline_fixed_string_t on_off;
11450 /* Common CLI fields for vf split drop enable disable */
11451 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11452 TOKEN_STRING_INITIALIZER
11453 (struct cmd_vf_split_drop_en_result,
11455 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11456 TOKEN_STRING_INITIALIZER
11457 (struct cmd_vf_split_drop_en_result,
11459 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11460 TOKEN_STRING_INITIALIZER
11461 (struct cmd_vf_split_drop_en_result,
11463 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11464 TOKEN_STRING_INITIALIZER
11465 (struct cmd_vf_split_drop_en_result,
11467 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11468 TOKEN_NUM_INITIALIZER
11469 (struct cmd_vf_split_drop_en_result,
11471 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11472 TOKEN_NUM_INITIALIZER
11473 (struct cmd_vf_split_drop_en_result,
11475 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11476 TOKEN_STRING_INITIALIZER
11477 (struct cmd_vf_split_drop_en_result,
11481 cmd_set_vf_split_drop_en_parsed(
11482 void *parsed_result,
11483 __attribute__((unused)) struct cmdline *cl,
11484 __attribute__((unused)) void *data)
11486 struct cmd_vf_split_drop_en_result *res = parsed_result;
11488 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11490 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11493 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11499 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11502 printf("invalid port_id %d\n", res->port_id);
11505 printf("programming error: (%s)\n", strerror(-ret));
11509 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11510 .f = cmd_set_vf_split_drop_en_parsed,
11512 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11514 (void *)&cmd_vf_split_drop_en_set,
11515 (void *)&cmd_vf_split_drop_en_vf,
11516 (void *)&cmd_vf_split_drop_en_split,
11517 (void *)&cmd_vf_split_drop_en_drop,
11518 (void *)&cmd_vf_split_drop_en_port_id,
11519 (void *)&cmd_vf_split_drop_en_vf_id,
11520 (void *)&cmd_vf_split_drop_en_on_off,
11526 /* vf mac address configuration */
11528 /* Common result structure for vf mac address */
11529 struct cmd_set_vf_mac_addr_result {
11530 cmdline_fixed_string_t set;
11531 cmdline_fixed_string_t vf;
11532 cmdline_fixed_string_t mac;
11533 cmdline_fixed_string_t addr;
11536 struct ether_addr mac_addr;
11540 /* Common CLI fields for vf split drop enable disable */
11541 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11542 TOKEN_STRING_INITIALIZER
11543 (struct cmd_set_vf_mac_addr_result,
11545 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11546 TOKEN_STRING_INITIALIZER
11547 (struct cmd_set_vf_mac_addr_result,
11549 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11550 TOKEN_STRING_INITIALIZER
11551 (struct cmd_set_vf_mac_addr_result,
11553 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11554 TOKEN_STRING_INITIALIZER
11555 (struct cmd_set_vf_mac_addr_result,
11557 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11558 TOKEN_NUM_INITIALIZER
11559 (struct cmd_set_vf_mac_addr_result,
11561 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11562 TOKEN_NUM_INITIALIZER
11563 (struct cmd_set_vf_mac_addr_result,
11565 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11566 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11570 cmd_set_vf_mac_addr_parsed(
11571 void *parsed_result,
11572 __attribute__((unused)) struct cmdline *cl,
11573 __attribute__((unused)) void *data)
11575 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11576 int ret = -ENOTSUP;
11578 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11581 #ifdef RTE_LIBRTE_IXGBE_PMD
11582 if (ret == -ENOTSUP)
11583 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11586 #ifdef RTE_LIBRTE_I40E_PMD
11587 if (ret == -ENOTSUP)
11588 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11596 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11599 printf("invalid port_id %d\n", res->port_id);
11602 printf("function not implemented\n");
11605 printf("programming error: (%s)\n", strerror(-ret));
11609 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11610 .f = cmd_set_vf_mac_addr_parsed,
11612 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11614 (void *)&cmd_set_vf_mac_addr_set,
11615 (void *)&cmd_set_vf_mac_addr_vf,
11616 (void *)&cmd_set_vf_mac_addr_mac,
11617 (void *)&cmd_set_vf_mac_addr_addr,
11618 (void *)&cmd_set_vf_mac_addr_port_id,
11619 (void *)&cmd_set_vf_mac_addr_vf_id,
11620 (void *)&cmd_set_vf_mac_addr_mac_addr,
11625 #ifdef RTE_LIBRTE_IXGBE_PMD
11626 /* MACsec configuration */
11628 /* Common result structure for MACsec offload enable */
11629 struct cmd_macsec_offload_on_result {
11630 cmdline_fixed_string_t set;
11631 cmdline_fixed_string_t macsec;
11632 cmdline_fixed_string_t offload;
11634 cmdline_fixed_string_t on;
11635 cmdline_fixed_string_t encrypt;
11636 cmdline_fixed_string_t en_on_off;
11637 cmdline_fixed_string_t replay_protect;
11638 cmdline_fixed_string_t rp_on_off;
11641 /* Common CLI fields for MACsec offload disable */
11642 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11643 TOKEN_STRING_INITIALIZER
11644 (struct cmd_macsec_offload_on_result,
11646 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11647 TOKEN_STRING_INITIALIZER
11648 (struct cmd_macsec_offload_on_result,
11650 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11651 TOKEN_STRING_INITIALIZER
11652 (struct cmd_macsec_offload_on_result,
11653 offload, "offload");
11654 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11655 TOKEN_NUM_INITIALIZER
11656 (struct cmd_macsec_offload_on_result,
11658 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11659 TOKEN_STRING_INITIALIZER
11660 (struct cmd_macsec_offload_on_result,
11662 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11663 TOKEN_STRING_INITIALIZER
11664 (struct cmd_macsec_offload_on_result,
11665 encrypt, "encrypt");
11666 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11667 TOKEN_STRING_INITIALIZER
11668 (struct cmd_macsec_offload_on_result,
11669 en_on_off, "on#off");
11670 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11671 TOKEN_STRING_INITIALIZER
11672 (struct cmd_macsec_offload_on_result,
11673 replay_protect, "replay-protect");
11674 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11675 TOKEN_STRING_INITIALIZER
11676 (struct cmd_macsec_offload_on_result,
11677 rp_on_off, "on#off");
11680 cmd_set_macsec_offload_on_parsed(
11681 void *parsed_result,
11682 __attribute__((unused)) struct cmdline *cl,
11683 __attribute__((unused)) void *data)
11685 struct cmd_macsec_offload_on_result *res = parsed_result;
11687 portid_t port_id = res->port_id;
11688 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11689 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11691 if (port_id_is_invalid(port_id, ENABLED_WARN))
11694 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11695 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11701 printf("invalid port_id %d\n", port_id);
11704 printf("programming error: (%s)\n", strerror(-ret));
11708 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11709 .f = cmd_set_macsec_offload_on_parsed,
11711 .help_str = "set macsec offload <port_id> on "
11712 "encrypt on|off replay-protect on|off",
11714 (void *)&cmd_macsec_offload_on_set,
11715 (void *)&cmd_macsec_offload_on_macsec,
11716 (void *)&cmd_macsec_offload_on_offload,
11717 (void *)&cmd_macsec_offload_on_port_id,
11718 (void *)&cmd_macsec_offload_on_on,
11719 (void *)&cmd_macsec_offload_on_encrypt,
11720 (void *)&cmd_macsec_offload_on_en_on_off,
11721 (void *)&cmd_macsec_offload_on_replay_protect,
11722 (void *)&cmd_macsec_offload_on_rp_on_off,
11727 /* Common result structure for MACsec offload disable */
11728 struct cmd_macsec_offload_off_result {
11729 cmdline_fixed_string_t set;
11730 cmdline_fixed_string_t macsec;
11731 cmdline_fixed_string_t offload;
11733 cmdline_fixed_string_t off;
11736 /* Common CLI fields for MACsec offload disable */
11737 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11738 TOKEN_STRING_INITIALIZER
11739 (struct cmd_macsec_offload_off_result,
11741 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11742 TOKEN_STRING_INITIALIZER
11743 (struct cmd_macsec_offload_off_result,
11745 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11746 TOKEN_STRING_INITIALIZER
11747 (struct cmd_macsec_offload_off_result,
11748 offload, "offload");
11749 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11750 TOKEN_NUM_INITIALIZER
11751 (struct cmd_macsec_offload_off_result,
11753 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11754 TOKEN_STRING_INITIALIZER
11755 (struct cmd_macsec_offload_off_result,
11759 cmd_set_macsec_offload_off_parsed(
11760 void *parsed_result,
11761 __attribute__((unused)) struct cmdline *cl,
11762 __attribute__((unused)) void *data)
11764 struct cmd_macsec_offload_off_result *res = parsed_result;
11766 portid_t port_id = res->port_id;
11768 if (port_id_is_invalid(port_id, ENABLED_WARN))
11771 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11772 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11778 printf("invalid port_id %d\n", port_id);
11781 printf("programming error: (%s)\n", strerror(-ret));
11785 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11786 .f = cmd_set_macsec_offload_off_parsed,
11788 .help_str = "set macsec offload <port_id> off",
11790 (void *)&cmd_macsec_offload_off_set,
11791 (void *)&cmd_macsec_offload_off_macsec,
11792 (void *)&cmd_macsec_offload_off_offload,
11793 (void *)&cmd_macsec_offload_off_port_id,
11794 (void *)&cmd_macsec_offload_off_off,
11799 /* Common result structure for MACsec secure connection configure */
11800 struct cmd_macsec_sc_result {
11801 cmdline_fixed_string_t set;
11802 cmdline_fixed_string_t macsec;
11803 cmdline_fixed_string_t sc;
11804 cmdline_fixed_string_t tx_rx;
11806 struct ether_addr mac;
11810 /* Common CLI fields for MACsec secure connection configure */
11811 cmdline_parse_token_string_t cmd_macsec_sc_set =
11812 TOKEN_STRING_INITIALIZER
11813 (struct cmd_macsec_sc_result,
11815 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11816 TOKEN_STRING_INITIALIZER
11817 (struct cmd_macsec_sc_result,
11819 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11820 TOKEN_STRING_INITIALIZER
11821 (struct cmd_macsec_sc_result,
11823 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11824 TOKEN_STRING_INITIALIZER
11825 (struct cmd_macsec_sc_result,
11827 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11828 TOKEN_NUM_INITIALIZER
11829 (struct cmd_macsec_sc_result,
11831 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11832 TOKEN_ETHERADDR_INITIALIZER
11833 (struct cmd_macsec_sc_result,
11835 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11836 TOKEN_NUM_INITIALIZER
11837 (struct cmd_macsec_sc_result,
11841 cmd_set_macsec_sc_parsed(
11842 void *parsed_result,
11843 __attribute__((unused)) struct cmdline *cl,
11844 __attribute__((unused)) void *data)
11846 struct cmd_macsec_sc_result *res = parsed_result;
11848 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11851 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11852 res->mac.addr_bytes) :
11853 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11854 res->mac.addr_bytes, res->pi);
11859 printf("invalid port_id %d\n", res->port_id);
11862 printf("programming error: (%s)\n", strerror(-ret));
11866 cmdline_parse_inst_t cmd_set_macsec_sc = {
11867 .f = cmd_set_macsec_sc_parsed,
11869 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11871 (void *)&cmd_macsec_sc_set,
11872 (void *)&cmd_macsec_sc_macsec,
11873 (void *)&cmd_macsec_sc_sc,
11874 (void *)&cmd_macsec_sc_tx_rx,
11875 (void *)&cmd_macsec_sc_port_id,
11876 (void *)&cmd_macsec_sc_mac,
11877 (void *)&cmd_macsec_sc_pi,
11882 /* Common result structure for MACsec secure connection configure */
11883 struct cmd_macsec_sa_result {
11884 cmdline_fixed_string_t set;
11885 cmdline_fixed_string_t macsec;
11886 cmdline_fixed_string_t sa;
11887 cmdline_fixed_string_t tx_rx;
11892 cmdline_fixed_string_t key;
11895 /* Common CLI fields for MACsec secure connection configure */
11896 cmdline_parse_token_string_t cmd_macsec_sa_set =
11897 TOKEN_STRING_INITIALIZER
11898 (struct cmd_macsec_sa_result,
11900 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11901 TOKEN_STRING_INITIALIZER
11902 (struct cmd_macsec_sa_result,
11904 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11905 TOKEN_STRING_INITIALIZER
11906 (struct cmd_macsec_sa_result,
11908 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11909 TOKEN_STRING_INITIALIZER
11910 (struct cmd_macsec_sa_result,
11912 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11913 TOKEN_NUM_INITIALIZER
11914 (struct cmd_macsec_sa_result,
11916 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11917 TOKEN_NUM_INITIALIZER
11918 (struct cmd_macsec_sa_result,
11920 cmdline_parse_token_num_t cmd_macsec_sa_an =
11921 TOKEN_NUM_INITIALIZER
11922 (struct cmd_macsec_sa_result,
11924 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11925 TOKEN_NUM_INITIALIZER
11926 (struct cmd_macsec_sa_result,
11928 cmdline_parse_token_string_t cmd_macsec_sa_key =
11929 TOKEN_STRING_INITIALIZER
11930 (struct cmd_macsec_sa_result,
11934 cmd_set_macsec_sa_parsed(
11935 void *parsed_result,
11936 __attribute__((unused)) struct cmdline *cl,
11937 __attribute__((unused)) void *data)
11939 struct cmd_macsec_sa_result *res = parsed_result;
11941 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11942 uint8_t key[16] = { 0 };
11948 key_len = strlen(res->key) / 2;
11952 for (i = 0; i < key_len; i++) {
11953 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11956 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11959 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11963 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11964 res->idx, res->an, res->pn, key) :
11965 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11966 res->idx, res->an, res->pn, key);
11971 printf("invalid idx %d or an %d\n", res->idx, res->an);
11974 printf("invalid port_id %d\n", res->port_id);
11977 printf("programming error: (%s)\n", strerror(-ret));
11981 cmdline_parse_inst_t cmd_set_macsec_sa = {
11982 .f = cmd_set_macsec_sa_parsed,
11984 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11986 (void *)&cmd_macsec_sa_set,
11987 (void *)&cmd_macsec_sa_macsec,
11988 (void *)&cmd_macsec_sa_sa,
11989 (void *)&cmd_macsec_sa_tx_rx,
11990 (void *)&cmd_macsec_sa_port_id,
11991 (void *)&cmd_macsec_sa_idx,
11992 (void *)&cmd_macsec_sa_an,
11993 (void *)&cmd_macsec_sa_pn,
11994 (void *)&cmd_macsec_sa_key,
12000 /* VF unicast promiscuous mode configuration */
12002 /* Common result structure for VF unicast promiscuous mode */
12003 struct cmd_vf_promisc_result {
12004 cmdline_fixed_string_t set;
12005 cmdline_fixed_string_t vf;
12006 cmdline_fixed_string_t promisc;
12009 cmdline_fixed_string_t on_off;
12012 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12013 cmdline_parse_token_string_t cmd_vf_promisc_set =
12014 TOKEN_STRING_INITIALIZER
12015 (struct cmd_vf_promisc_result,
12017 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12018 TOKEN_STRING_INITIALIZER
12019 (struct cmd_vf_promisc_result,
12021 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12022 TOKEN_STRING_INITIALIZER
12023 (struct cmd_vf_promisc_result,
12024 promisc, "promisc");
12025 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12026 TOKEN_NUM_INITIALIZER
12027 (struct cmd_vf_promisc_result,
12029 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12030 TOKEN_NUM_INITIALIZER
12031 (struct cmd_vf_promisc_result,
12033 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12034 TOKEN_STRING_INITIALIZER
12035 (struct cmd_vf_promisc_result,
12039 cmd_set_vf_promisc_parsed(
12040 void *parsed_result,
12041 __attribute__((unused)) struct cmdline *cl,
12042 __attribute__((unused)) void *data)
12044 struct cmd_vf_promisc_result *res = parsed_result;
12045 int ret = -ENOTSUP;
12047 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12052 #ifdef RTE_LIBRTE_I40E_PMD
12053 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12054 res->vf_id, is_on);
12061 printf("invalid vf_id %d\n", res->vf_id);
12064 printf("invalid port_id %d\n", res->port_id);
12067 printf("function not implemented\n");
12070 printf("programming error: (%s)\n", strerror(-ret));
12074 cmdline_parse_inst_t cmd_set_vf_promisc = {
12075 .f = cmd_set_vf_promisc_parsed,
12077 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12078 "Set unicast promiscuous mode for a VF from the PF",
12080 (void *)&cmd_vf_promisc_set,
12081 (void *)&cmd_vf_promisc_vf,
12082 (void *)&cmd_vf_promisc_promisc,
12083 (void *)&cmd_vf_promisc_port_id,
12084 (void *)&cmd_vf_promisc_vf_id,
12085 (void *)&cmd_vf_promisc_on_off,
12090 /* VF multicast promiscuous mode configuration */
12092 /* Common result structure for VF multicast promiscuous mode */
12093 struct cmd_vf_allmulti_result {
12094 cmdline_fixed_string_t set;
12095 cmdline_fixed_string_t vf;
12096 cmdline_fixed_string_t allmulti;
12099 cmdline_fixed_string_t on_off;
12102 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12103 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12104 TOKEN_STRING_INITIALIZER
12105 (struct cmd_vf_allmulti_result,
12107 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12108 TOKEN_STRING_INITIALIZER
12109 (struct cmd_vf_allmulti_result,
12111 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12112 TOKEN_STRING_INITIALIZER
12113 (struct cmd_vf_allmulti_result,
12114 allmulti, "allmulti");
12115 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12116 TOKEN_NUM_INITIALIZER
12117 (struct cmd_vf_allmulti_result,
12119 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12120 TOKEN_NUM_INITIALIZER
12121 (struct cmd_vf_allmulti_result,
12123 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12124 TOKEN_STRING_INITIALIZER
12125 (struct cmd_vf_allmulti_result,
12129 cmd_set_vf_allmulti_parsed(
12130 void *parsed_result,
12131 __attribute__((unused)) struct cmdline *cl,
12132 __attribute__((unused)) void *data)
12134 struct cmd_vf_allmulti_result *res = parsed_result;
12135 int ret = -ENOTSUP;
12137 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12139 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12142 #ifdef RTE_LIBRTE_I40E_PMD
12143 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12144 res->vf_id, is_on);
12151 printf("invalid vf_id %d\n", res->vf_id);
12154 printf("invalid port_id %d\n", res->port_id);
12157 printf("function not implemented\n");
12160 printf("programming error: (%s)\n", strerror(-ret));
12164 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12165 .f = cmd_set_vf_allmulti_parsed,
12167 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12168 "Set multicast promiscuous mode for a VF from the PF",
12170 (void *)&cmd_vf_allmulti_set,
12171 (void *)&cmd_vf_allmulti_vf,
12172 (void *)&cmd_vf_allmulti_allmulti,
12173 (void *)&cmd_vf_allmulti_port_id,
12174 (void *)&cmd_vf_allmulti_vf_id,
12175 (void *)&cmd_vf_allmulti_on_off,
12180 /* vf broadcast mode configuration */
12182 /* Common result structure for vf broadcast */
12183 struct cmd_set_vf_broadcast_result {
12184 cmdline_fixed_string_t set;
12185 cmdline_fixed_string_t vf;
12186 cmdline_fixed_string_t broadcast;
12189 cmdline_fixed_string_t on_off;
12192 /* Common CLI fields for vf broadcast enable disable */
12193 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12194 TOKEN_STRING_INITIALIZER
12195 (struct cmd_set_vf_broadcast_result,
12197 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12198 TOKEN_STRING_INITIALIZER
12199 (struct cmd_set_vf_broadcast_result,
12201 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12202 TOKEN_STRING_INITIALIZER
12203 (struct cmd_set_vf_broadcast_result,
12204 broadcast, "broadcast");
12205 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12206 TOKEN_NUM_INITIALIZER
12207 (struct cmd_set_vf_broadcast_result,
12209 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12210 TOKEN_NUM_INITIALIZER
12211 (struct cmd_set_vf_broadcast_result,
12213 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12214 TOKEN_STRING_INITIALIZER
12215 (struct cmd_set_vf_broadcast_result,
12219 cmd_set_vf_broadcast_parsed(
12220 void *parsed_result,
12221 __attribute__((unused)) struct cmdline *cl,
12222 __attribute__((unused)) void *data)
12224 struct cmd_set_vf_broadcast_result *res = parsed_result;
12225 int ret = -ENOTSUP;
12227 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12232 #ifdef RTE_LIBRTE_I40E_PMD
12233 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12234 res->vf_id, is_on);
12241 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12244 printf("invalid port_id %d\n", res->port_id);
12247 printf("function not implemented\n");
12250 printf("programming error: (%s)\n", strerror(-ret));
12254 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12255 .f = cmd_set_vf_broadcast_parsed,
12257 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12259 (void *)&cmd_set_vf_broadcast_set,
12260 (void *)&cmd_set_vf_broadcast_vf,
12261 (void *)&cmd_set_vf_broadcast_broadcast,
12262 (void *)&cmd_set_vf_broadcast_port_id,
12263 (void *)&cmd_set_vf_broadcast_vf_id,
12264 (void *)&cmd_set_vf_broadcast_on_off,
12269 /* ******************************************************************************** */
12271 /* list of instructions */
12272 cmdline_parse_ctx_t main_ctx[] = {
12273 (cmdline_parse_inst_t *)&cmd_help_brief,
12274 (cmdline_parse_inst_t *)&cmd_help_long,
12275 (cmdline_parse_inst_t *)&cmd_quit,
12276 (cmdline_parse_inst_t *)&cmd_showport,
12277 (cmdline_parse_inst_t *)&cmd_showqueue,
12278 (cmdline_parse_inst_t *)&cmd_showportall,
12279 (cmdline_parse_inst_t *)&cmd_showcfg,
12280 (cmdline_parse_inst_t *)&cmd_start,
12281 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12282 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12283 (cmdline_parse_inst_t *)&cmd_set_link_up,
12284 (cmdline_parse_inst_t *)&cmd_set_link_down,
12285 (cmdline_parse_inst_t *)&cmd_reset,
12286 (cmdline_parse_inst_t *)&cmd_set_numbers,
12287 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12288 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12289 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12290 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12291 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12292 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12293 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12294 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12295 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12296 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12297 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12298 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12299 (cmdline_parse_inst_t *)&cmd_set_link_check,
12300 #ifdef RTE_NIC_BYPASS
12301 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12302 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12303 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12304 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12306 #ifdef RTE_LIBRTE_PMD_BOND
12307 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12308 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12309 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12310 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12311 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12312 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12313 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12314 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12315 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12317 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12318 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12319 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12320 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12321 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12322 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12323 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12324 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12325 (cmdline_parse_inst_t *)&cmd_csum_set,
12326 (cmdline_parse_inst_t *)&cmd_csum_show,
12327 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12328 (cmdline_parse_inst_t *)&cmd_tso_set,
12329 (cmdline_parse_inst_t *)&cmd_tso_show,
12330 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12331 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12332 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12333 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12334 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12335 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12336 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12337 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12338 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12339 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12340 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12341 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12342 (cmdline_parse_inst_t *)&cmd_config_dcb,
12343 (cmdline_parse_inst_t *)&cmd_read_reg,
12344 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12345 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12346 (cmdline_parse_inst_t *)&cmd_write_reg,
12347 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12348 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12349 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12350 (cmdline_parse_inst_t *)&cmd_stop,
12351 (cmdline_parse_inst_t *)&cmd_mac_addr,
12352 (cmdline_parse_inst_t *)&cmd_set_qmap,
12353 (cmdline_parse_inst_t *)&cmd_operate_port,
12354 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12355 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12356 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12357 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12358 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12359 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12360 (cmdline_parse_inst_t *)&cmd_config_mtu,
12361 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12362 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12363 (cmdline_parse_inst_t *)&cmd_config_rss,
12364 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12365 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12366 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12367 (cmdline_parse_inst_t *)&cmd_showport_reta,
12368 (cmdline_parse_inst_t *)&cmd_config_burst,
12369 (cmdline_parse_inst_t *)&cmd_config_thresh,
12370 (cmdline_parse_inst_t *)&cmd_config_threshold,
12371 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12372 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12373 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12374 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12375 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12376 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12377 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12378 (cmdline_parse_inst_t *)&cmd_global_config,
12379 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12380 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12381 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12382 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12383 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12384 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12385 (cmdline_parse_inst_t *)&cmd_dump,
12386 (cmdline_parse_inst_t *)&cmd_dump_one,
12387 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12388 (cmdline_parse_inst_t *)&cmd_syn_filter,
12389 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12390 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12391 (cmdline_parse_inst_t *)&cmd_flex_filter,
12392 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12393 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12394 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12395 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12396 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12397 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12398 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12399 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12400 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12401 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12402 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12403 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12404 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12405 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12406 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12407 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12408 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12409 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12410 (cmdline_parse_inst_t *)&cmd_flow,
12411 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12412 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12413 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12414 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12415 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12416 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12417 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12418 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12419 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12420 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12421 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12422 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12423 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12424 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12425 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12426 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12427 #ifdef RTE_LIBRTE_IXGBE_PMD
12428 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12429 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12430 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12431 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12432 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12433 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12434 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12435 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12436 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12437 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12439 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12440 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12441 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
12442 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
12446 /* prompt function, called from main on MASTER lcore */
12450 /* initialize non-constant commands */
12451 cmd_set_fwd_mode_init();
12452 cmd_set_fwd_retry_mode_init();
12454 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12455 if (testpmd_cl == NULL)
12457 cmdline_interact(testpmd_cl);
12458 cmdline_stdin_exit(testpmd_cl);
12464 if (testpmd_cl != NULL)
12465 cmdline_quit(testpmd_cl);
12469 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12471 if (id == (portid_t)RTE_PORT_ALL) {
12474 FOREACH_PORT(pid, ports) {
12475 /* check if need_reconfig has been set to 1 */
12476 if (ports[pid].need_reconfig == 0)
12477 ports[pid].need_reconfig = dev;
12478 /* check if need_reconfig_queues has been set to 1 */
12479 if (ports[pid].need_reconfig_queues == 0)
12480 ports[pid].need_reconfig_queues = queue;
12482 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12483 /* check if need_reconfig has been set to 1 */
12484 if (ports[id].need_reconfig == 0)
12485 ports[id].need_reconfig = dev;
12486 /* check if need_reconfig_queues has been set to 1 */
12487 if (ports[id].need_reconfig_queues == 0)
12488 ports[id].need_reconfig_queues = queue;