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 "vlan set strip (on|off) (port_id)\n"
298 " Set the VLAN strip on a port.\n\n"
300 "vlan set stripq (on|off) (port_id,queue_id)\n"
301 " Set the VLAN strip for a queue on a port.\n\n"
303 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
304 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
306 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
307 " Set VLAN insert for a VF from the PF.\n\n"
309 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
310 " Set VLAN antispoof for a VF from the PF.\n\n"
312 "vlan set filter (on|off) (port_id)\n"
313 " Set the VLAN filter on a port.\n\n"
315 "vlan set qinq (on|off) (port_id)\n"
316 " Set the VLAN QinQ (extended queue in queue)"
319 "vlan set (inner|outer) tpid (value) (port_id)\n"
320 " Set the VLAN TPID for Packet Filtering on"
323 "rx_vlan add (vlan_id|all) (port_id)\n"
324 " Add a vlan_id, or all identifiers, to the set"
325 " of VLAN identifiers filtered by port_id.\n\n"
327 "rx_vlan rm (vlan_id|all) (port_id)\n"
328 " Remove a vlan_id, or all identifiers, from the set"
329 " of VLAN identifiers filtered by port_id.\n\n"
331 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
332 " Add a vlan_id, to the set of VLAN identifiers"
333 "filtered for VF(s) from port_id.\n\n"
335 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
336 " Remove a vlan_id, to the set of VLAN identifiers"
337 "filtered for VF(s) from port_id.\n\n"
339 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
340 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
341 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
342 " add a tunnel filter of a port.\n\n"
344 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
345 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
346 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
347 " remove a tunnel filter of a port.\n\n"
349 "rx_vxlan_port add (udp_port) (port_id)\n"
350 " Add an UDP port for VXLAN packet filter on a port\n\n"
352 "rx_vxlan_port rm (udp_port) (port_id)\n"
353 " Remove an UDP port for VXLAN packet filter on a port\n\n"
355 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
356 " Set hardware insertion of VLAN IDs (single or double VLAN "
357 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
359 "tx_vlan set pvid port_id vlan_id (on|off)\n"
360 " Set port based TX VLAN insertion.\n\n"
362 "tx_vlan reset (port_id)\n"
363 " Disable hardware insertion of a VLAN header in"
364 " packets sent on a port.\n\n"
366 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
367 " Select hardware or software calculation of the"
368 " checksum when transmitting a packet using the"
369 " csum forward engine.\n"
370 " ip|udp|tcp|sctp always concern the inner layer.\n"
371 " outer-ip concerns the outer IP layer in"
372 " case the packet is recognized as a tunnel packet by"
373 " the forward engine (vxlan, gre and ipip are supported)\n"
374 " Please check the NIC datasheet for HW limits.\n\n"
376 "csum parse-tunnel (on|off) (tx_port_id)\n"
377 " If disabled, treat tunnel packets as non-tunneled"
378 " packets (treat inner headers as payload). The port\n"
379 " argument is the port used for TX in csum forward"
382 "csum show (port_id)\n"
383 " Display tx checksum offload configuration\n\n"
385 "tso set (segsize) (portid)\n"
386 " Enable TCP Segmentation Offload in csum forward"
388 " Please check the NIC datasheet for HW limits.\n\n"
391 " Display the status of TCP Segmentation Offload.\n\n"
394 " Set packet forwarding mode.\n\n"
396 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
397 " Add a MAC address on port_id.\n\n"
399 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
400 " Remove a MAC address from port_id.\n\n"
402 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
403 " Add a MAC address for a VF on the port.\n\n"
405 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
406 " Set the MAC address for a VF from the PF.\n\n"
408 "set port (port_id) uta (mac_address|all) (on|off)\n"
409 " Add/Remove a or all unicast hash filter(s)"
412 "set promisc (port_id|all) (on|off)\n"
413 " Set the promiscuous mode on port_id, or all.\n\n"
415 "set allmulti (port_id|all) (on|off)\n"
416 " Set the allmulti mode on port_id, or all.\n\n"
418 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
419 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
420 " (on|off) autoneg (on|off) (port_id)\n"
421 "set flow_ctrl rx (on|off) (portid)\n"
422 "set flow_ctrl tx (on|off) (portid)\n"
423 "set flow_ctrl high_water (high_water) (portid)\n"
424 "set flow_ctrl low_water (low_water) (portid)\n"
425 "set flow_ctrl pause_time (pause_time) (portid)\n"
426 "set flow_ctrl send_xon (send_xon) (portid)\n"
427 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
428 "set flow_ctrl autoneg (on|off) (port_id)\n"
429 " Set the link flow control parameter on a port.\n\n"
431 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
432 " (low_water) (pause_time) (priority) (port_id)\n"
433 " Set the priority flow control parameter on a"
436 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
437 " Set statistics mapping (qmapping 0..15) for RX/TX"
439 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
440 " on port 0 to mapping 5.\n\n"
442 "set port (port_id) vf (vf_id) rx|tx on|off\n"
443 " Enable/Disable a VF receive/tranmit from a port\n\n"
445 "set port (port_id) vf (vf_id) (mac_addr)"
446 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
447 " Add/Remove unicast or multicast MAC addr filter"
450 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
452 " AUPE:accepts untagged VLAN;"
453 "ROPE:accept unicast hash\n\n"
454 " BAM:accepts broadcast packets;"
455 "MPE:accepts all multicast packets\n\n"
456 " Enable/Disable a VF receive mode of a port\n\n"
458 "set port (port_id) queue (queue_id) rate (rate_num)\n"
459 " Set rate limit for a queue of a port\n\n"
461 "set port (port_id) vf (vf_id) rate (rate_num) "
462 "queue_mask (queue_mask_value)\n"
463 " Set rate limit for queues in VF of a port\n\n"
465 "set port (port_id) mirror-rule (rule_id)"
466 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
467 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
468 " Set pool or vlan type mirror rule on a port.\n"
469 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
470 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
473 "set port (port_id) mirror-rule (rule_id)"
474 " (uplink-mirror|downlink-mirror) dst-pool"
475 " (pool_id) (on|off)\n"
476 " Set uplink or downlink type mirror rule on a port.\n"
477 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
478 " 0 on' enable mirror income traffic to pool 0.\n\n"
480 "reset port (port_id) mirror-rule (rule_id)\n"
481 " Reset a mirror rule.\n\n"
483 "set flush_rx (on|off)\n"
484 " Flush (default) or don't flush RX streams before"
485 " forwarding. Mainly used with PCAP drivers.\n\n"
487 #ifdef RTE_NIC_BYPASS
488 "set bypass mode (normal|bypass|isolate) (port_id)\n"
489 " Set the bypass mode for the lowest port on bypass enabled"
492 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
493 "mode (normal|bypass|isolate) (port_id)\n"
494 " Set the event required to initiate specified bypass mode for"
495 " the lowest port on a bypass enabled NIC where:\n"
496 " timeout = enable bypass after watchdog timeout.\n"
497 " os_on = enable bypass when OS/board is powered on.\n"
498 " os_off = enable bypass when OS/board is powered off.\n"
499 " power_on = enable bypass when power supply is turned on.\n"
500 " power_off = enable bypass when power supply is turned off."
503 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
504 " Set the bypass watchdog timeout to 'n' seconds"
505 " where 0 = instant.\n\n"
507 "show bypass config (port_id)\n"
508 " Show the bypass configuration for a bypass enabled NIC"
509 " using the lowest port on the NIC.\n\n"
511 #ifdef RTE_LIBRTE_PMD_BOND
512 "create bonded device (mode) (socket)\n"
513 " Create a new bonded device with specific bonding mode and socket.\n\n"
515 "add bonding slave (slave_id) (port_id)\n"
516 " Add a slave device to a bonded device.\n\n"
518 "remove bonding slave (slave_id) (port_id)\n"
519 " Remove a slave device from a bonded device.\n\n"
521 "set bonding mode (value) (port_id)\n"
522 " Set the bonding mode on a bonded device.\n\n"
524 "set bonding primary (slave_id) (port_id)\n"
525 " Set the primary slave for a bonded device.\n\n"
527 "show bonding config (port_id)\n"
528 " Show the bonding config for port_id.\n\n"
530 "set bonding mac_addr (port_id) (address)\n"
531 " Set the MAC address of a bonded device.\n\n"
533 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
534 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
536 "set bonding mon_period (port_id) (value)\n"
537 " Set the bonding link status monitoring polling period in ms.\n\n"
539 "set link-up port (port_id)\n"
540 " Set link up for a port.\n\n"
542 "set link-down port (port_id)\n"
543 " Set link down for a port.\n\n"
545 "E-tag set insertion on port-tag-id (value)"
546 " port (port_id) vf (vf_id)\n"
547 " Enable E-tag insertion for a VF on a port\n\n"
549 "E-tag set insertion off port (port_id) vf (vf_id)\n"
550 " Disable E-tag insertion for a VF on a port\n\n"
552 "E-tag set stripping (on|off) port (port_id)\n"
553 " Enable/disable E-tag stripping on a port\n\n"
555 "E-tag set forwarding (on|off) port (port_id)\n"
556 " Enable/disable E-tag based forwarding"
559 "E-tag set filter add e-tag-id (value) dst-pool"
560 " (pool_id) port (port_id)\n"
561 " Add an E-tag forwarding filter on a port\n\n"
563 "E-tag set filter del e-tag-id (value) port (port_id)\n"
564 " Delete an E-tag forwarding filter on a port\n\n"
566 , list_pkt_forwarding_modes()
570 if (show_all || !strcmp(res->section, "ports")) {
576 "----------------\n\n"
578 "port start (port_id|all)\n"
579 " Start all ports or port_id.\n\n"
581 "port stop (port_id|all)\n"
582 " Stop all ports or port_id.\n\n"
584 "port close (port_id|all)\n"
585 " Close all ports or port_id.\n\n"
587 "port attach (ident)\n"
588 " Attach physical or virtual dev by pci address or virtual device name\n\n"
590 "port detach (port_id)\n"
591 " Detach physical or virtual dev by port_id\n\n"
593 "port config (port_id|all)"
594 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
595 " duplex (half|full|auto)\n"
596 " Set speed and duplex for all ports or port_id\n\n"
598 "port config all (rxq|txq|rxd|txd) (value)\n"
599 " Set number for rxq/txq/rxd/txd.\n\n"
601 "port config all max-pkt-len (value)\n"
602 " Set the max packet length.\n\n"
604 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
605 "hw-vlan-strip|hw-vlan-extend|drop-en)"
607 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
610 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
611 " Set the RSS mode.\n\n"
613 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
614 " Set the RSS redirection table.\n\n"
616 "port config (port_id) dcb vt (on|off) (traffic_class)"
618 " Set the DCB mode.\n\n"
620 "port config all burst (value)\n"
621 " Set the number of packets per burst.\n\n"
623 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
625 " Set the ring prefetch/host/writeback threshold"
626 " for tx/rx queue.\n\n"
628 "port config all (txfreet|txrst|rxfreet) (value)\n"
629 " Set free threshold for rx/tx, or set"
630 " tx rs bit threshold.\n\n"
631 "port config mtu X value\n"
632 " Set the MTU of port X to a given value\n\n"
634 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
635 " Start/stop a rx/tx queue of port X. Only take effect"
636 " when port X is started\n\n"
638 "port config (port_id|all) l2-tunnel E-tag ether-type"
640 " Set the value of E-tag ether-type.\n\n"
642 "port config (port_id|all) l2-tunnel E-tag"
643 " (enable|disable)\n"
644 " Enable/disable the E-tag support.\n\n"
648 if (show_all || !strcmp(res->section, "registers")) {
656 "read reg (port_id) (address)\n"
657 " Display value of a port register.\n\n"
659 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
660 " Display a port register bit field.\n\n"
662 "read regbit (port_id) (address) (bit_x)\n"
663 " Display a single port register bit.\n\n"
665 "write reg (port_id) (address) (value)\n"
666 " Set value of a port register.\n\n"
668 "write regfield (port_id) (address) (bit_x) (bit_y)"
670 " Set bit field of a port register.\n\n"
672 "write regbit (port_id) (address) (bit_x) (value)\n"
673 " Set single bit value of a port register.\n\n"
676 if (show_all || !strcmp(res->section, "filters")) {
684 "ethertype_filter (port_id) (add|del)"
685 " (mac_addr|mac_ignr) (mac_address) ethertype"
686 " (ether_type) (drop|fwd) queue (queue_id)\n"
687 " Add/Del an ethertype filter.\n\n"
689 "2tuple_filter (port_id) (add|del)"
690 " dst_port (dst_port_value) protocol (protocol_value)"
691 " mask (mask_value) tcp_flags (tcp_flags_value)"
692 " priority (prio_value) queue (queue_id)\n"
693 " Add/Del a 2tuple filter.\n\n"
695 "5tuple_filter (port_id) (add|del)"
696 " dst_ip (dst_address) src_ip (src_address)"
697 " dst_port (dst_port_value) src_port (src_port_value)"
698 " protocol (protocol_value)"
699 " mask (mask_value) tcp_flags (tcp_flags_value)"
700 " priority (prio_value) queue (queue_id)\n"
701 " Add/Del a 5tuple filter.\n\n"
703 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
704 " Add/Del syn filter.\n\n"
706 "flex_filter (port_id) (add|del) len (len_value)"
707 " bytes (bytes_value) mask (mask_value)"
708 " priority (prio_value) queue (queue_id)\n"
709 " Add/Del a flex filter.\n\n"
711 "flow_director_filter (port_id) mode IP (add|del|update)"
712 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
713 " src (src_ip_address) dst (dst_ip_address)"
714 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
715 " vlan (vlan_value) flexbytes (flexbytes_value)"
716 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
717 " fd_id (fd_id_value)\n"
718 " Add/Del an IP type flow director filter.\n\n"
720 "flow_director_filter (port_id) mode IP (add|del|update)"
721 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
722 " src (src_ip_address) (src_port)"
723 " dst (dst_ip_address) (dst_port)"
724 " tos (tos_value) ttl (ttl_value)"
725 " vlan (vlan_value) flexbytes (flexbytes_value)"
726 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
727 " fd_id (fd_id_value)\n"
728 " Add/Del an UDP/TCP type flow director filter.\n\n"
730 "flow_director_filter (port_id) mode IP (add|del|update)"
731 " flow (ipv4-sctp|ipv6-sctp)"
732 " src (src_ip_address) (src_port)"
733 " dst (dst_ip_address) (dst_port)"
734 " tag (verification_tag) "
735 " tos (tos_value) ttl (ttl_value)"
737 " flexbytes (flexbytes_value) (drop|fwd)"
738 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
739 " Add/Del a SCTP type flow director filter.\n\n"
741 "flow_director_filter (port_id) mode IP (add|del|update)"
742 " flow l2_payload ether (ethertype)"
743 " flexbytes (flexbytes_value) (drop|fwd)"
744 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
745 " Add/Del a l2 payload type flow director filter.\n\n"
747 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
748 " mac (mac_address) vlan (vlan_value)"
749 " flexbytes (flexbytes_value) (drop|fwd)"
750 " queue (queue_id) fd_id (fd_id_value)\n"
751 " Add/Del a MAC-VLAN flow director filter.\n\n"
753 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
754 " mac (mac_address) vlan (vlan_value)"
755 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
756 " flexbytes (flexbytes_value) (drop|fwd)"
757 " queue (queue_id) fd_id (fd_id_value)\n"
758 " Add/Del a Tunnel flow director filter.\n\n"
760 "flush_flow_director (port_id)\n"
761 " Flush all flow director entries of a device.\n\n"
763 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
764 " src_mask (ipv4_src) (ipv6_src) (src_port)"
765 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
766 " Set flow director IP mask.\n\n"
768 "flow_director_mask (port_id) mode MAC-VLAN"
769 " vlan (vlan_value)\n"
770 " Set flow director MAC-VLAN mask.\n\n"
772 "flow_director_mask (port_id) mode Tunnel"
773 " vlan (vlan_value) mac (mac_value)"
774 " tunnel-type (tunnel_type_value)"
775 " tunnel-id (tunnel_id_value)\n"
776 " Set flow director Tunnel mask.\n\n"
778 "flow_director_flex_mask (port_id)"
779 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
780 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
782 " Configure mask of flex payload.\n\n"
784 "flow_director_flex_payload (port_id)"
785 " (raw|l2|l3|l4) (config)\n"
786 " Configure flex payload selection.\n\n"
788 "get_sym_hash_ena_per_port (port_id)\n"
789 " get symmetric hash enable configuration per port.\n\n"
791 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
792 " set symmetric hash enable configuration per port"
793 " to enable or disable.\n\n"
795 "get_hash_global_config (port_id)\n"
796 " Get the global configurations of hash filters.\n\n"
798 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
799 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
800 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
801 " (enable|disable)\n"
802 " Set the global configurations of hash filters.\n\n"
804 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
805 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
806 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
807 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
808 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
809 "ipv6-next-header|udp-src-port|udp-dst-port|"
810 "tcp-src-port|tcp-dst-port|sctp-src-port|"
811 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
812 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
813 "fld-8th|none) (select|add)\n"
814 " Set the input set for hash.\n\n"
816 "set_fdir_input_set (port_id) "
817 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
818 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
819 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
820 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
821 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
822 "udp-dst-port|tcp-src-port|tcp-dst-port|"
823 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
825 " Set the input set for FDir.\n\n"
827 "flow validate {port_id}"
828 " [group {group_id}] [priority {level}]"
829 " [ingress] [egress]"
830 " pattern {item} [/ {item} [...]] / end"
831 " actions {action} [/ {action} [...]] / end\n"
832 " Check whether a flow rule can be created.\n\n"
834 "flow create {port_id}"
835 " [group {group_id}] [priority {level}]"
836 " [ingress] [egress]"
837 " pattern {item} [/ {item} [...]] / end"
838 " actions {action} [/ {action} [...]] / end\n"
839 " Create a flow rule.\n\n"
841 "flow destroy {port_id} rule {rule_id} [...]\n"
842 " Destroy specific flow rules.\n\n"
844 "flow flush {port_id}\n"
845 " Destroy all flow rules.\n\n"
847 "flow query {port_id} {rule_id} {action}\n"
848 " Query an existing flow rule.\n\n"
850 "flow list {port_id} [group {group_id}] [...]\n"
851 " List existing flow rules sorted by priority,"
852 " filtered by group identifiers.\n\n"
857 cmdline_parse_token_string_t cmd_help_long_help =
858 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
860 cmdline_parse_token_string_t cmd_help_long_section =
861 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
862 "all#control#display#config#"
863 "ports#registers#filters");
865 cmdline_parse_inst_t cmd_help_long = {
866 .f = cmd_help_long_parsed,
868 .help_str = "help all|control|display|config|ports|register|filters: "
871 (void *)&cmd_help_long_help,
872 (void *)&cmd_help_long_section,
878 /* *** start/stop/close all ports *** */
879 struct cmd_operate_port_result {
880 cmdline_fixed_string_t keyword;
881 cmdline_fixed_string_t name;
882 cmdline_fixed_string_t value;
885 static void cmd_operate_port_parsed(void *parsed_result,
886 __attribute__((unused)) struct cmdline *cl,
887 __attribute__((unused)) void *data)
889 struct cmd_operate_port_result *res = parsed_result;
891 if (!strcmp(res->name, "start"))
892 start_port(RTE_PORT_ALL);
893 else if (!strcmp(res->name, "stop"))
894 stop_port(RTE_PORT_ALL);
895 else if (!strcmp(res->name, "close"))
896 close_port(RTE_PORT_ALL);
898 printf("Unknown parameter\n");
901 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
902 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
904 cmdline_parse_token_string_t cmd_operate_port_all_port =
905 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
907 cmdline_parse_token_string_t cmd_operate_port_all_all =
908 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
910 cmdline_parse_inst_t cmd_operate_port = {
911 .f = cmd_operate_port_parsed,
913 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
915 (void *)&cmd_operate_port_all_cmd,
916 (void *)&cmd_operate_port_all_port,
917 (void *)&cmd_operate_port_all_all,
922 /* *** start/stop/close specific port *** */
923 struct cmd_operate_specific_port_result {
924 cmdline_fixed_string_t keyword;
925 cmdline_fixed_string_t name;
929 static void cmd_operate_specific_port_parsed(void *parsed_result,
930 __attribute__((unused)) struct cmdline *cl,
931 __attribute__((unused)) void *data)
933 struct cmd_operate_specific_port_result *res = parsed_result;
935 if (!strcmp(res->name, "start"))
936 start_port(res->value);
937 else if (!strcmp(res->name, "stop"))
938 stop_port(res->value);
939 else if (!strcmp(res->name, "close"))
940 close_port(res->value);
942 printf("Unknown parameter\n");
945 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
946 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
948 cmdline_parse_token_string_t cmd_operate_specific_port_port =
949 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
950 name, "start#stop#close");
951 cmdline_parse_token_num_t cmd_operate_specific_port_id =
952 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
955 cmdline_parse_inst_t cmd_operate_specific_port = {
956 .f = cmd_operate_specific_port_parsed,
958 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
960 (void *)&cmd_operate_specific_port_cmd,
961 (void *)&cmd_operate_specific_port_port,
962 (void *)&cmd_operate_specific_port_id,
967 /* *** attach a specified port *** */
968 struct cmd_operate_attach_port_result {
969 cmdline_fixed_string_t port;
970 cmdline_fixed_string_t keyword;
971 cmdline_fixed_string_t identifier;
974 static void cmd_operate_attach_port_parsed(void *parsed_result,
975 __attribute__((unused)) struct cmdline *cl,
976 __attribute__((unused)) void *data)
978 struct cmd_operate_attach_port_result *res = parsed_result;
980 if (!strcmp(res->keyword, "attach"))
981 attach_port(res->identifier);
983 printf("Unknown parameter\n");
986 cmdline_parse_token_string_t cmd_operate_attach_port_port =
987 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
989 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
990 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
992 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
993 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
996 cmdline_parse_inst_t cmd_operate_attach_port = {
997 .f = cmd_operate_attach_port_parsed,
999 .help_str = "port attach <identifier>: "
1000 "(identifier: pci address or virtual dev name)",
1002 (void *)&cmd_operate_attach_port_port,
1003 (void *)&cmd_operate_attach_port_keyword,
1004 (void *)&cmd_operate_attach_port_identifier,
1009 /* *** detach a specified port *** */
1010 struct cmd_operate_detach_port_result {
1011 cmdline_fixed_string_t port;
1012 cmdline_fixed_string_t keyword;
1016 static void cmd_operate_detach_port_parsed(void *parsed_result,
1017 __attribute__((unused)) struct cmdline *cl,
1018 __attribute__((unused)) void *data)
1020 struct cmd_operate_detach_port_result *res = parsed_result;
1022 if (!strcmp(res->keyword, "detach"))
1023 detach_port(res->port_id);
1025 printf("Unknown parameter\n");
1028 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1029 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1031 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1032 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1034 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1035 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1038 cmdline_parse_inst_t cmd_operate_detach_port = {
1039 .f = cmd_operate_detach_port_parsed,
1041 .help_str = "port detach <port_id>",
1043 (void *)&cmd_operate_detach_port_port,
1044 (void *)&cmd_operate_detach_port_keyword,
1045 (void *)&cmd_operate_detach_port_port_id,
1050 /* *** configure speed for all ports *** */
1051 struct cmd_config_speed_all {
1052 cmdline_fixed_string_t port;
1053 cmdline_fixed_string_t keyword;
1054 cmdline_fixed_string_t all;
1055 cmdline_fixed_string_t item1;
1056 cmdline_fixed_string_t item2;
1057 cmdline_fixed_string_t value1;
1058 cmdline_fixed_string_t value2;
1062 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1067 if (!strcmp(duplexstr, "half")) {
1068 duplex = ETH_LINK_HALF_DUPLEX;
1069 } else if (!strcmp(duplexstr, "full")) {
1070 duplex = ETH_LINK_FULL_DUPLEX;
1071 } else if (!strcmp(duplexstr, "auto")) {
1072 duplex = ETH_LINK_FULL_DUPLEX;
1074 printf("Unknown duplex parameter\n");
1078 if (!strcmp(speedstr, "10")) {
1079 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1080 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1081 } else if (!strcmp(speedstr, "100")) {
1082 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1083 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1085 if (duplex != ETH_LINK_FULL_DUPLEX) {
1086 printf("Invalid speed/duplex parameters\n");
1089 if (!strcmp(speedstr, "1000")) {
1090 *speed = ETH_LINK_SPEED_1G;
1091 } else if (!strcmp(speedstr, "10000")) {
1092 *speed = ETH_LINK_SPEED_10G;
1093 } else if (!strcmp(speedstr, "25000")) {
1094 *speed = ETH_LINK_SPEED_25G;
1095 } else if (!strcmp(speedstr, "40000")) {
1096 *speed = ETH_LINK_SPEED_40G;
1097 } else if (!strcmp(speedstr, "50000")) {
1098 *speed = ETH_LINK_SPEED_50G;
1099 } else if (!strcmp(speedstr, "100000")) {
1100 *speed = ETH_LINK_SPEED_100G;
1101 } else if (!strcmp(speedstr, "auto")) {
1102 *speed = ETH_LINK_SPEED_AUTONEG;
1104 printf("Unknown speed parameter\n");
1113 cmd_config_speed_all_parsed(void *parsed_result,
1114 __attribute__((unused)) struct cmdline *cl,
1115 __attribute__((unused)) void *data)
1117 struct cmd_config_speed_all *res = parsed_result;
1118 uint32_t link_speed;
1121 if (!all_ports_stopped()) {
1122 printf("Please stop all ports first\n");
1126 if (parse_and_check_speed_duplex(res->value1, res->value2,
1130 FOREACH_PORT(pid, ports) {
1131 ports[pid].dev_conf.link_speeds = link_speed;
1134 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1137 cmdline_parse_token_string_t cmd_config_speed_all_port =
1138 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1139 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1140 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1142 cmdline_parse_token_string_t cmd_config_speed_all_all =
1143 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1144 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1145 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1146 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1148 "10#100#1000#10000#25000#40000#50000#100000#auto");
1149 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1151 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1152 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1155 cmdline_parse_inst_t cmd_config_speed_all = {
1156 .f = cmd_config_speed_all_parsed,
1158 .help_str = "port config all speed "
1159 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1162 (void *)&cmd_config_speed_all_port,
1163 (void *)&cmd_config_speed_all_keyword,
1164 (void *)&cmd_config_speed_all_all,
1165 (void *)&cmd_config_speed_all_item1,
1166 (void *)&cmd_config_speed_all_value1,
1167 (void *)&cmd_config_speed_all_item2,
1168 (void *)&cmd_config_speed_all_value2,
1173 /* *** configure speed for specific port *** */
1174 struct cmd_config_speed_specific {
1175 cmdline_fixed_string_t port;
1176 cmdline_fixed_string_t keyword;
1178 cmdline_fixed_string_t item1;
1179 cmdline_fixed_string_t item2;
1180 cmdline_fixed_string_t value1;
1181 cmdline_fixed_string_t value2;
1185 cmd_config_speed_specific_parsed(void *parsed_result,
1186 __attribute__((unused)) struct cmdline *cl,
1187 __attribute__((unused)) void *data)
1189 struct cmd_config_speed_specific *res = parsed_result;
1190 uint32_t link_speed;
1192 if (!all_ports_stopped()) {
1193 printf("Please stop all ports first\n");
1197 if (port_id_is_invalid(res->id, ENABLED_WARN))
1200 if (parse_and_check_speed_duplex(res->value1, res->value2,
1204 ports[res->id].dev_conf.link_speeds = link_speed;
1206 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1210 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1211 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1213 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1214 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1216 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1217 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1218 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1219 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1221 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1222 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1223 "10#100#1000#10000#25000#40000#50000#100000#auto");
1224 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1225 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1227 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1228 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1231 cmdline_parse_inst_t cmd_config_speed_specific = {
1232 .f = cmd_config_speed_specific_parsed,
1234 .help_str = "port config <port_id> speed "
1235 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1238 (void *)&cmd_config_speed_specific_port,
1239 (void *)&cmd_config_speed_specific_keyword,
1240 (void *)&cmd_config_speed_specific_id,
1241 (void *)&cmd_config_speed_specific_item1,
1242 (void *)&cmd_config_speed_specific_value1,
1243 (void *)&cmd_config_speed_specific_item2,
1244 (void *)&cmd_config_speed_specific_value2,
1249 /* *** configure txq/rxq, txd/rxd *** */
1250 struct cmd_config_rx_tx {
1251 cmdline_fixed_string_t port;
1252 cmdline_fixed_string_t keyword;
1253 cmdline_fixed_string_t all;
1254 cmdline_fixed_string_t name;
1259 cmd_config_rx_tx_parsed(void *parsed_result,
1260 __attribute__((unused)) struct cmdline *cl,
1261 __attribute__((unused)) void *data)
1263 struct cmd_config_rx_tx *res = parsed_result;
1265 if (!all_ports_stopped()) {
1266 printf("Please stop all ports first\n");
1269 if (!strcmp(res->name, "rxq")) {
1270 if (!res->value && !nb_txq) {
1271 printf("Warning: Either rx or tx queues should be non zero\n");
1274 nb_rxq = res->value;
1276 else if (!strcmp(res->name, "txq")) {
1277 if (!res->value && !nb_rxq) {
1278 printf("Warning: Either rx or tx queues should be non zero\n");
1281 nb_txq = res->value;
1283 else if (!strcmp(res->name, "rxd")) {
1284 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1285 printf("rxd %d invalid - must be > 0 && <= %d\n",
1286 res->value, RTE_TEST_RX_DESC_MAX);
1289 nb_rxd = res->value;
1290 } else if (!strcmp(res->name, "txd")) {
1291 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1292 printf("txd %d invalid - must be > 0 && <= %d\n",
1293 res->value, RTE_TEST_TX_DESC_MAX);
1296 nb_txd = res->value;
1298 printf("Unknown parameter\n");
1306 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1309 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1310 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1311 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1312 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1313 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1314 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1315 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1316 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1318 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1319 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1321 cmdline_parse_inst_t cmd_config_rx_tx = {
1322 .f = cmd_config_rx_tx_parsed,
1324 .help_str = "port config all rxq|txq|rxd|txd <value>",
1326 (void *)&cmd_config_rx_tx_port,
1327 (void *)&cmd_config_rx_tx_keyword,
1328 (void *)&cmd_config_rx_tx_all,
1329 (void *)&cmd_config_rx_tx_name,
1330 (void *)&cmd_config_rx_tx_value,
1335 /* *** config max packet length *** */
1336 struct cmd_config_max_pkt_len_result {
1337 cmdline_fixed_string_t port;
1338 cmdline_fixed_string_t keyword;
1339 cmdline_fixed_string_t all;
1340 cmdline_fixed_string_t name;
1345 cmd_config_max_pkt_len_parsed(void *parsed_result,
1346 __attribute__((unused)) struct cmdline *cl,
1347 __attribute__((unused)) void *data)
1349 struct cmd_config_max_pkt_len_result *res = parsed_result;
1351 if (!all_ports_stopped()) {
1352 printf("Please stop all ports first\n");
1356 if (!strcmp(res->name, "max-pkt-len")) {
1357 if (res->value < ETHER_MIN_LEN) {
1358 printf("max-pkt-len can not be less than %d\n",
1362 if (res->value == rx_mode.max_rx_pkt_len)
1365 rx_mode.max_rx_pkt_len = res->value;
1366 if (res->value > ETHER_MAX_LEN)
1367 rx_mode.jumbo_frame = 1;
1369 rx_mode.jumbo_frame = 0;
1371 printf("Unknown parameter\n");
1377 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1380 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1381 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1383 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1384 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1386 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1389 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1392 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1393 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1396 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1397 .f = cmd_config_max_pkt_len_parsed,
1399 .help_str = "port config all max-pkt-len <value>",
1401 (void *)&cmd_config_max_pkt_len_port,
1402 (void *)&cmd_config_max_pkt_len_keyword,
1403 (void *)&cmd_config_max_pkt_len_all,
1404 (void *)&cmd_config_max_pkt_len_name,
1405 (void *)&cmd_config_max_pkt_len_value,
1410 /* *** configure port MTU *** */
1411 struct cmd_config_mtu_result {
1412 cmdline_fixed_string_t port;
1413 cmdline_fixed_string_t keyword;
1414 cmdline_fixed_string_t mtu;
1420 cmd_config_mtu_parsed(void *parsed_result,
1421 __attribute__((unused)) struct cmdline *cl,
1422 __attribute__((unused)) void *data)
1424 struct cmd_config_mtu_result *res = parsed_result;
1426 if (res->value < ETHER_MIN_LEN) {
1427 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1430 port_mtu_set(res->port_id, res->value);
1433 cmdline_parse_token_string_t cmd_config_mtu_port =
1434 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1436 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1437 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1439 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1440 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1442 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1443 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1444 cmdline_parse_token_num_t cmd_config_mtu_value =
1445 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1447 cmdline_parse_inst_t cmd_config_mtu = {
1448 .f = cmd_config_mtu_parsed,
1450 .help_str = "port config mtu <port_id> <value>",
1452 (void *)&cmd_config_mtu_port,
1453 (void *)&cmd_config_mtu_keyword,
1454 (void *)&cmd_config_mtu_mtu,
1455 (void *)&cmd_config_mtu_port_id,
1456 (void *)&cmd_config_mtu_value,
1461 /* *** configure rx mode *** */
1462 struct cmd_config_rx_mode_flag {
1463 cmdline_fixed_string_t port;
1464 cmdline_fixed_string_t keyword;
1465 cmdline_fixed_string_t all;
1466 cmdline_fixed_string_t name;
1467 cmdline_fixed_string_t value;
1471 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1472 __attribute__((unused)) struct cmdline *cl,
1473 __attribute__((unused)) void *data)
1475 struct cmd_config_rx_mode_flag *res = parsed_result;
1477 if (!all_ports_stopped()) {
1478 printf("Please stop all ports first\n");
1482 if (!strcmp(res->name, "crc-strip")) {
1483 if (!strcmp(res->value, "on"))
1484 rx_mode.hw_strip_crc = 1;
1485 else if (!strcmp(res->value, "off"))
1486 rx_mode.hw_strip_crc = 0;
1488 printf("Unknown parameter\n");
1491 } else if (!strcmp(res->name, "scatter")) {
1492 if (!strcmp(res->value, "on"))
1493 rx_mode.enable_scatter = 1;
1494 else if (!strcmp(res->value, "off"))
1495 rx_mode.enable_scatter = 0;
1497 printf("Unknown parameter\n");
1500 } else if (!strcmp(res->name, "rx-cksum")) {
1501 if (!strcmp(res->value, "on"))
1502 rx_mode.hw_ip_checksum = 1;
1503 else if (!strcmp(res->value, "off"))
1504 rx_mode.hw_ip_checksum = 0;
1506 printf("Unknown parameter\n");
1509 } else if (!strcmp(res->name, "hw-vlan")) {
1510 if (!strcmp(res->value, "on")) {
1511 rx_mode.hw_vlan_filter = 1;
1512 rx_mode.hw_vlan_strip = 1;
1514 else if (!strcmp(res->value, "off")) {
1515 rx_mode.hw_vlan_filter = 0;
1516 rx_mode.hw_vlan_strip = 0;
1519 printf("Unknown parameter\n");
1522 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1523 if (!strcmp(res->value, "on"))
1524 rx_mode.hw_vlan_filter = 1;
1525 else if (!strcmp(res->value, "off"))
1526 rx_mode.hw_vlan_filter = 0;
1528 printf("Unknown parameter\n");
1531 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1532 if (!strcmp(res->value, "on"))
1533 rx_mode.hw_vlan_strip = 1;
1534 else if (!strcmp(res->value, "off"))
1535 rx_mode.hw_vlan_strip = 0;
1537 printf("Unknown parameter\n");
1540 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1541 if (!strcmp(res->value, "on"))
1542 rx_mode.hw_vlan_extend = 1;
1543 else if (!strcmp(res->value, "off"))
1544 rx_mode.hw_vlan_extend = 0;
1546 printf("Unknown parameter\n");
1549 } else if (!strcmp(res->name, "drop-en")) {
1550 if (!strcmp(res->value, "on"))
1552 else if (!strcmp(res->value, "off"))
1555 printf("Unknown parameter\n");
1559 printf("Unknown parameter\n");
1565 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1568 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1570 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1573 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1575 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1576 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1577 "crc-strip#scatter#rx-cksum#hw-vlan#"
1578 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1579 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1583 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1584 .f = cmd_config_rx_mode_flag_parsed,
1586 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1587 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1589 (void *)&cmd_config_rx_mode_flag_port,
1590 (void *)&cmd_config_rx_mode_flag_keyword,
1591 (void *)&cmd_config_rx_mode_flag_all,
1592 (void *)&cmd_config_rx_mode_flag_name,
1593 (void *)&cmd_config_rx_mode_flag_value,
1598 /* *** configure rss *** */
1599 struct cmd_config_rss {
1600 cmdline_fixed_string_t port;
1601 cmdline_fixed_string_t keyword;
1602 cmdline_fixed_string_t all;
1603 cmdline_fixed_string_t name;
1604 cmdline_fixed_string_t value;
1608 cmd_config_rss_parsed(void *parsed_result,
1609 __attribute__((unused)) struct cmdline *cl,
1610 __attribute__((unused)) void *data)
1612 struct cmd_config_rss *res = parsed_result;
1613 struct rte_eth_rss_conf rss_conf;
1617 if (!strcmp(res->value, "all"))
1618 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1619 ETH_RSS_UDP | ETH_RSS_SCTP |
1621 else if (!strcmp(res->value, "ip"))
1622 rss_conf.rss_hf = ETH_RSS_IP;
1623 else if (!strcmp(res->value, "udp"))
1624 rss_conf.rss_hf = ETH_RSS_UDP;
1625 else if (!strcmp(res->value, "tcp"))
1626 rss_conf.rss_hf = ETH_RSS_TCP;
1627 else if (!strcmp(res->value, "sctp"))
1628 rss_conf.rss_hf = ETH_RSS_SCTP;
1629 else if (!strcmp(res->value, "ether"))
1630 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1631 else if (!strcmp(res->value, "port"))
1632 rss_conf.rss_hf = ETH_RSS_PORT;
1633 else if (!strcmp(res->value, "vxlan"))
1634 rss_conf.rss_hf = ETH_RSS_VXLAN;
1635 else if (!strcmp(res->value, "geneve"))
1636 rss_conf.rss_hf = ETH_RSS_GENEVE;
1637 else if (!strcmp(res->value, "nvgre"))
1638 rss_conf.rss_hf = ETH_RSS_NVGRE;
1639 else if (!strcmp(res->value, "none"))
1640 rss_conf.rss_hf = 0;
1642 printf("Unknown parameter\n");
1645 rss_conf.rss_key = NULL;
1646 for (i = 0; i < rte_eth_dev_count(); i++) {
1647 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1649 printf("Configuration of RSS hash at ethernet port %d "
1650 "failed with error (%d): %s.\n",
1651 i, -diag, strerror(-diag));
1655 cmdline_parse_token_string_t cmd_config_rss_port =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1657 cmdline_parse_token_string_t cmd_config_rss_keyword =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1659 cmdline_parse_token_string_t cmd_config_rss_all =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1661 cmdline_parse_token_string_t cmd_config_rss_name =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1663 cmdline_parse_token_string_t cmd_config_rss_value =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1665 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1667 cmdline_parse_inst_t cmd_config_rss = {
1668 .f = cmd_config_rss_parsed,
1670 .help_str = "port config all rss "
1671 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1673 (void *)&cmd_config_rss_port,
1674 (void *)&cmd_config_rss_keyword,
1675 (void *)&cmd_config_rss_all,
1676 (void *)&cmd_config_rss_name,
1677 (void *)&cmd_config_rss_value,
1682 /* *** configure rss hash key *** */
1683 struct cmd_config_rss_hash_key {
1684 cmdline_fixed_string_t port;
1685 cmdline_fixed_string_t config;
1687 cmdline_fixed_string_t rss_hash_key;
1688 cmdline_fixed_string_t rss_type;
1689 cmdline_fixed_string_t key;
1693 hexa_digit_to_value(char hexa_digit)
1695 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1696 return (uint8_t) (hexa_digit - '0');
1697 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1698 return (uint8_t) ((hexa_digit - 'a') + 10);
1699 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1700 return (uint8_t) ((hexa_digit - 'A') + 10);
1701 /* Invalid hexa digit */
1706 parse_and_check_key_hexa_digit(char *key, int idx)
1710 hexa_v = hexa_digit_to_value(key[idx]);
1712 printf("invalid key: character %c at position %d is not a "
1713 "valid hexa digit\n", key[idx], idx);
1718 cmd_config_rss_hash_key_parsed(void *parsed_result,
1719 __attribute__((unused)) struct cmdline *cl,
1720 __attribute__((unused)) void *data)
1722 struct cmd_config_rss_hash_key *res = parsed_result;
1723 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1727 struct rte_eth_dev_info dev_info;
1728 uint8_t hash_key_size;
1731 memset(&dev_info, 0, sizeof(dev_info));
1732 rte_eth_dev_info_get(res->port_id, &dev_info);
1733 if (dev_info.hash_key_size > 0 &&
1734 dev_info.hash_key_size <= sizeof(hash_key))
1735 hash_key_size = dev_info.hash_key_size;
1737 printf("dev_info did not provide a valid hash key size\n");
1740 /* Check the length of the RSS hash key */
1741 key_len = strlen(res->key);
1742 if (key_len != (hash_key_size * 2)) {
1743 printf("key length: %d invalid - key must be a string of %d"
1744 " hexa-decimal numbers\n",
1745 (int) key_len, hash_key_size * 2);
1748 /* Translate RSS hash key into binary representation */
1749 for (i = 0; i < hash_key_size; i++) {
1750 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1753 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1756 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1758 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1762 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1763 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1764 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1765 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1767 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1768 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1769 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1771 rss_hash_key, "rss-hash-key");
1772 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1774 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1775 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1776 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1777 "ipv6-tcp-ex#ipv6-udp-ex");
1778 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1779 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1781 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1782 .f = cmd_config_rss_hash_key_parsed,
1784 .help_str = "port config <port_id> rss-hash-key "
1785 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1786 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1787 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1788 "<string of hex digits (variable length, NIC dependent)>",
1790 (void *)&cmd_config_rss_hash_key_port,
1791 (void *)&cmd_config_rss_hash_key_config,
1792 (void *)&cmd_config_rss_hash_key_port_id,
1793 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1794 (void *)&cmd_config_rss_hash_key_rss_type,
1795 (void *)&cmd_config_rss_hash_key_value,
1800 /* *** configure port rxq/txq start/stop *** */
1801 struct cmd_config_rxtx_queue {
1802 cmdline_fixed_string_t port;
1804 cmdline_fixed_string_t rxtxq;
1806 cmdline_fixed_string_t opname;
1810 cmd_config_rxtx_queue_parsed(void *parsed_result,
1811 __attribute__((unused)) struct cmdline *cl,
1812 __attribute__((unused)) void *data)
1814 struct cmd_config_rxtx_queue *res = parsed_result;
1819 if (test_done == 0) {
1820 printf("Please stop forwarding first\n");
1824 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1827 if (port_is_started(res->portid) != 1) {
1828 printf("Please start port %u first\n", res->portid);
1832 if (!strcmp(res->rxtxq, "rxq"))
1834 else if (!strcmp(res->rxtxq, "txq"))
1837 printf("Unknown parameter\n");
1841 if (isrx && rx_queue_id_is_invalid(res->qid))
1843 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1846 if (!strcmp(res->opname, "start"))
1848 else if (!strcmp(res->opname, "stop"))
1851 printf("Unknown parameter\n");
1855 if (isstart && isrx)
1856 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1857 else if (!isstart && isrx)
1858 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1859 else if (isstart && !isrx)
1860 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1862 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1864 if (ret == -ENOTSUP)
1865 printf("Function not supported in PMD driver\n");
1868 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1869 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1870 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1871 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1872 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1873 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1874 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1875 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1876 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1877 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1880 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1881 .f = cmd_config_rxtx_queue_parsed,
1883 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1885 (void *)&cmd_config_speed_all_port,
1886 (void *)&cmd_config_rxtx_queue_portid,
1887 (void *)&cmd_config_rxtx_queue_rxtxq,
1888 (void *)&cmd_config_rxtx_queue_qid,
1889 (void *)&cmd_config_rxtx_queue_opname,
1894 /* *** Configure RSS RETA *** */
1895 struct cmd_config_rss_reta {
1896 cmdline_fixed_string_t port;
1897 cmdline_fixed_string_t keyword;
1899 cmdline_fixed_string_t name;
1900 cmdline_fixed_string_t list_name;
1901 cmdline_fixed_string_t list_of_items;
1905 parse_reta_config(const char *str,
1906 struct rte_eth_rss_reta_entry64 *reta_conf,
1907 uint16_t nb_entries)
1911 uint16_t hash_index, idx, shift;
1914 const char *p, *p0 = str;
1921 unsigned long int_fld[_NUM_FLD];
1922 char *str_fld[_NUM_FLD];
1924 while ((p = strchr(p0,'(')) != NULL) {
1926 if((p0 = strchr(p,')')) == NULL)
1930 if(size >= sizeof(s))
1933 snprintf(s, sizeof(s), "%.*s", size, p);
1934 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1936 for (i = 0; i < _NUM_FLD; i++) {
1938 int_fld[i] = strtoul(str_fld[i], &end, 0);
1939 if (errno != 0 || end == str_fld[i] ||
1944 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1945 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1947 if (hash_index >= nb_entries) {
1948 printf("Invalid RETA hash index=%d\n", hash_index);
1952 idx = hash_index / RTE_RETA_GROUP_SIZE;
1953 shift = hash_index % RTE_RETA_GROUP_SIZE;
1954 reta_conf[idx].mask |= (1ULL << shift);
1955 reta_conf[idx].reta[shift] = nb_queue;
1962 cmd_set_rss_reta_parsed(void *parsed_result,
1963 __attribute__((unused)) struct cmdline *cl,
1964 __attribute__((unused)) void *data)
1967 struct rte_eth_dev_info dev_info;
1968 struct rte_eth_rss_reta_entry64 reta_conf[8];
1969 struct cmd_config_rss_reta *res = parsed_result;
1971 memset(&dev_info, 0, sizeof(dev_info));
1972 rte_eth_dev_info_get(res->port_id, &dev_info);
1973 if (dev_info.reta_size == 0) {
1974 printf("Redirection table size is 0 which is "
1975 "invalid for RSS\n");
1978 printf("The reta size of port %d is %u\n",
1979 res->port_id, dev_info.reta_size);
1980 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1981 printf("Currently do not support more than %u entries of "
1982 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1986 memset(reta_conf, 0, sizeof(reta_conf));
1987 if (!strcmp(res->list_name, "reta")) {
1988 if (parse_reta_config(res->list_of_items, reta_conf,
1989 dev_info.reta_size)) {
1990 printf("Invalid RSS Redirection Table "
1991 "config entered\n");
1994 ret = rte_eth_dev_rss_reta_update(res->port_id,
1995 reta_conf, dev_info.reta_size);
1997 printf("Bad redirection table parameter, "
1998 "return code = %d \n", ret);
2002 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2003 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2004 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2005 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2006 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2007 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2008 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2009 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2010 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2012 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2013 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2015 cmdline_parse_inst_t cmd_config_rss_reta = {
2016 .f = cmd_set_rss_reta_parsed,
2018 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2020 (void *)&cmd_config_rss_reta_port,
2021 (void *)&cmd_config_rss_reta_keyword,
2022 (void *)&cmd_config_rss_reta_port_id,
2023 (void *)&cmd_config_rss_reta_name,
2024 (void *)&cmd_config_rss_reta_list_name,
2025 (void *)&cmd_config_rss_reta_list_of_items,
2030 /* *** SHOW PORT RETA INFO *** */
2031 struct cmd_showport_reta {
2032 cmdline_fixed_string_t show;
2033 cmdline_fixed_string_t port;
2035 cmdline_fixed_string_t rss;
2036 cmdline_fixed_string_t reta;
2038 cmdline_fixed_string_t list_of_items;
2042 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2043 uint16_t nb_entries,
2047 const char *p, *p0 = str;
2051 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2054 p = strchr(p0, '(');
2058 p0 = strchr(p, ')');
2062 if (size >= sizeof(s)) {
2063 printf("The string size exceeds the internal buffer size\n");
2066 snprintf(s, sizeof(s), "%.*s", size, p);
2067 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2068 if (ret <= 0 || ret != num) {
2069 printf("The bits of masks do not match the number of "
2070 "reta entries: %u\n", num);
2073 for (i = 0; i < ret; i++)
2074 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2080 cmd_showport_reta_parsed(void *parsed_result,
2081 __attribute__((unused)) struct cmdline *cl,
2082 __attribute__((unused)) void *data)
2084 struct cmd_showport_reta *res = parsed_result;
2085 struct rte_eth_rss_reta_entry64 reta_conf[8];
2086 struct rte_eth_dev_info dev_info;
2088 memset(&dev_info, 0, sizeof(dev_info));
2089 rte_eth_dev_info_get(res->port_id, &dev_info);
2090 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2091 res->size > ETH_RSS_RETA_SIZE_512) {
2092 printf("Invalid redirection table size: %u\n", res->size);
2096 memset(reta_conf, 0, sizeof(reta_conf));
2097 if (showport_parse_reta_config(reta_conf, res->size,
2098 res->list_of_items) < 0) {
2099 printf("Invalid string: %s for reta masks\n",
2100 res->list_of_items);
2103 port_rss_reta_info(res->port_id, reta_conf, res->size);
2106 cmdline_parse_token_string_t cmd_showport_reta_show =
2107 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2108 cmdline_parse_token_string_t cmd_showport_reta_port =
2109 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2110 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2111 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2112 cmdline_parse_token_string_t cmd_showport_reta_rss =
2113 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2114 cmdline_parse_token_string_t cmd_showport_reta_reta =
2115 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2116 cmdline_parse_token_num_t cmd_showport_reta_size =
2117 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2118 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2119 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2120 list_of_items, NULL);
2122 cmdline_parse_inst_t cmd_showport_reta = {
2123 .f = cmd_showport_reta_parsed,
2125 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2127 (void *)&cmd_showport_reta_show,
2128 (void *)&cmd_showport_reta_port,
2129 (void *)&cmd_showport_reta_port_id,
2130 (void *)&cmd_showport_reta_rss,
2131 (void *)&cmd_showport_reta_reta,
2132 (void *)&cmd_showport_reta_size,
2133 (void *)&cmd_showport_reta_list_of_items,
2138 /* *** Show RSS hash configuration *** */
2139 struct cmd_showport_rss_hash {
2140 cmdline_fixed_string_t show;
2141 cmdline_fixed_string_t port;
2143 cmdline_fixed_string_t rss_hash;
2144 cmdline_fixed_string_t rss_type;
2145 cmdline_fixed_string_t key; /* optional argument */
2148 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2149 __attribute__((unused)) struct cmdline *cl,
2152 struct cmd_showport_rss_hash *res = parsed_result;
2154 port_rss_hash_conf_show(res->port_id, res->rss_type,
2155 show_rss_key != NULL);
2158 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2159 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2160 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2161 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2162 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2163 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2164 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2165 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2167 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2168 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2169 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2170 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2171 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2172 "ipv6-tcp-ex#ipv6-udp-ex");
2173 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2174 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2176 cmdline_parse_inst_t cmd_showport_rss_hash = {
2177 .f = cmd_showport_rss_hash_parsed,
2179 .help_str = "show port <port_id> rss-hash "
2180 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2181 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2182 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2184 (void *)&cmd_showport_rss_hash_show,
2185 (void *)&cmd_showport_rss_hash_port,
2186 (void *)&cmd_showport_rss_hash_port_id,
2187 (void *)&cmd_showport_rss_hash_rss_hash,
2188 (void *)&cmd_showport_rss_hash_rss_hash_info,
2193 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2194 .f = cmd_showport_rss_hash_parsed,
2196 .help_str = "show port <port_id> rss-hash "
2197 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2198 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2199 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2201 (void *)&cmd_showport_rss_hash_show,
2202 (void *)&cmd_showport_rss_hash_port,
2203 (void *)&cmd_showport_rss_hash_port_id,
2204 (void *)&cmd_showport_rss_hash_rss_hash,
2205 (void *)&cmd_showport_rss_hash_rss_hash_info,
2206 (void *)&cmd_showport_rss_hash_rss_key,
2211 /* *** Configure DCB *** */
2212 struct cmd_config_dcb {
2213 cmdline_fixed_string_t port;
2214 cmdline_fixed_string_t config;
2216 cmdline_fixed_string_t dcb;
2217 cmdline_fixed_string_t vt;
2218 cmdline_fixed_string_t vt_en;
2220 cmdline_fixed_string_t pfc;
2221 cmdline_fixed_string_t pfc_en;
2225 cmd_config_dcb_parsed(void *parsed_result,
2226 __attribute__((unused)) struct cmdline *cl,
2227 __attribute__((unused)) void *data)
2229 struct cmd_config_dcb *res = parsed_result;
2230 portid_t port_id = res->port_id;
2231 struct rte_port *port;
2235 port = &ports[port_id];
2236 /** Check if the port is not started **/
2237 if (port->port_status != RTE_PORT_STOPPED) {
2238 printf("Please stop port %d first\n", port_id);
2242 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2243 printf("The invalid number of traffic class,"
2244 " only 4 or 8 allowed.\n");
2248 if (nb_fwd_lcores < res->num_tcs) {
2249 printf("nb_cores shouldn't be less than number of TCs.\n");
2252 if (!strncmp(res->pfc_en, "on", 2))
2257 /* DCB in VT mode */
2258 if (!strncmp(res->vt_en, "on", 2))
2259 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2260 (enum rte_eth_nb_tcs)res->num_tcs,
2263 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2264 (enum rte_eth_nb_tcs)res->num_tcs,
2269 printf("Cannot initialize network ports.\n");
2273 cmd_reconfig_device_queue(port_id, 1, 1);
2276 cmdline_parse_token_string_t cmd_config_dcb_port =
2277 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2278 cmdline_parse_token_string_t cmd_config_dcb_config =
2279 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2280 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2281 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2282 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2284 cmdline_parse_token_string_t cmd_config_dcb_vt =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2286 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2287 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2288 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2289 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2290 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2291 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2292 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2293 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2295 cmdline_parse_inst_t cmd_config_dcb = {
2296 .f = cmd_config_dcb_parsed,
2298 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2300 (void *)&cmd_config_dcb_port,
2301 (void *)&cmd_config_dcb_config,
2302 (void *)&cmd_config_dcb_port_id,
2303 (void *)&cmd_config_dcb_dcb,
2304 (void *)&cmd_config_dcb_vt,
2305 (void *)&cmd_config_dcb_vt_en,
2306 (void *)&cmd_config_dcb_num_tcs,
2307 (void *)&cmd_config_dcb_pfc,
2308 (void *)&cmd_config_dcb_pfc_en,
2313 /* *** configure number of packets per burst *** */
2314 struct cmd_config_burst {
2315 cmdline_fixed_string_t port;
2316 cmdline_fixed_string_t keyword;
2317 cmdline_fixed_string_t all;
2318 cmdline_fixed_string_t name;
2323 cmd_config_burst_parsed(void *parsed_result,
2324 __attribute__((unused)) struct cmdline *cl,
2325 __attribute__((unused)) void *data)
2327 struct cmd_config_burst *res = parsed_result;
2329 if (!all_ports_stopped()) {
2330 printf("Please stop all ports first\n");
2334 if (!strcmp(res->name, "burst")) {
2335 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2336 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2339 nb_pkt_per_burst = res->value;
2341 printf("Unknown parameter\n");
2347 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2350 cmdline_parse_token_string_t cmd_config_burst_port =
2351 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2352 cmdline_parse_token_string_t cmd_config_burst_keyword =
2353 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2354 cmdline_parse_token_string_t cmd_config_burst_all =
2355 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2356 cmdline_parse_token_string_t cmd_config_burst_name =
2357 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2358 cmdline_parse_token_num_t cmd_config_burst_value =
2359 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2361 cmdline_parse_inst_t cmd_config_burst = {
2362 .f = cmd_config_burst_parsed,
2364 .help_str = "port config all burst <value>",
2366 (void *)&cmd_config_burst_port,
2367 (void *)&cmd_config_burst_keyword,
2368 (void *)&cmd_config_burst_all,
2369 (void *)&cmd_config_burst_name,
2370 (void *)&cmd_config_burst_value,
2375 /* *** configure rx/tx queues *** */
2376 struct cmd_config_thresh {
2377 cmdline_fixed_string_t port;
2378 cmdline_fixed_string_t keyword;
2379 cmdline_fixed_string_t all;
2380 cmdline_fixed_string_t name;
2385 cmd_config_thresh_parsed(void *parsed_result,
2386 __attribute__((unused)) struct cmdline *cl,
2387 __attribute__((unused)) void *data)
2389 struct cmd_config_thresh *res = parsed_result;
2391 if (!all_ports_stopped()) {
2392 printf("Please stop all ports first\n");
2396 if (!strcmp(res->name, "txpt"))
2397 tx_pthresh = res->value;
2398 else if(!strcmp(res->name, "txht"))
2399 tx_hthresh = res->value;
2400 else if(!strcmp(res->name, "txwt"))
2401 tx_wthresh = res->value;
2402 else if(!strcmp(res->name, "rxpt"))
2403 rx_pthresh = res->value;
2404 else if(!strcmp(res->name, "rxht"))
2405 rx_hthresh = res->value;
2406 else if(!strcmp(res->name, "rxwt"))
2407 rx_wthresh = res->value;
2409 printf("Unknown parameter\n");
2415 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2418 cmdline_parse_token_string_t cmd_config_thresh_port =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2420 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2421 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2422 cmdline_parse_token_string_t cmd_config_thresh_all =
2423 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2424 cmdline_parse_token_string_t cmd_config_thresh_name =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2426 "txpt#txht#txwt#rxpt#rxht#rxwt");
2427 cmdline_parse_token_num_t cmd_config_thresh_value =
2428 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2430 cmdline_parse_inst_t cmd_config_thresh = {
2431 .f = cmd_config_thresh_parsed,
2433 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2435 (void *)&cmd_config_thresh_port,
2436 (void *)&cmd_config_thresh_keyword,
2437 (void *)&cmd_config_thresh_all,
2438 (void *)&cmd_config_thresh_name,
2439 (void *)&cmd_config_thresh_value,
2444 /* *** configure free/rs threshold *** */
2445 struct cmd_config_threshold {
2446 cmdline_fixed_string_t port;
2447 cmdline_fixed_string_t keyword;
2448 cmdline_fixed_string_t all;
2449 cmdline_fixed_string_t name;
2454 cmd_config_threshold_parsed(void *parsed_result,
2455 __attribute__((unused)) struct cmdline *cl,
2456 __attribute__((unused)) void *data)
2458 struct cmd_config_threshold *res = parsed_result;
2460 if (!all_ports_stopped()) {
2461 printf("Please stop all ports first\n");
2465 if (!strcmp(res->name, "txfreet"))
2466 tx_free_thresh = res->value;
2467 else if (!strcmp(res->name, "txrst"))
2468 tx_rs_thresh = res->value;
2469 else if (!strcmp(res->name, "rxfreet"))
2470 rx_free_thresh = res->value;
2472 printf("Unknown parameter\n");
2478 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2481 cmdline_parse_token_string_t cmd_config_threshold_port =
2482 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2483 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2484 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2486 cmdline_parse_token_string_t cmd_config_threshold_all =
2487 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2488 cmdline_parse_token_string_t cmd_config_threshold_name =
2489 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2490 "txfreet#txrst#rxfreet");
2491 cmdline_parse_token_num_t cmd_config_threshold_value =
2492 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2494 cmdline_parse_inst_t cmd_config_threshold = {
2495 .f = cmd_config_threshold_parsed,
2497 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2499 (void *)&cmd_config_threshold_port,
2500 (void *)&cmd_config_threshold_keyword,
2501 (void *)&cmd_config_threshold_all,
2502 (void *)&cmd_config_threshold_name,
2503 (void *)&cmd_config_threshold_value,
2509 struct cmd_stop_result {
2510 cmdline_fixed_string_t stop;
2513 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2514 __attribute__((unused)) struct cmdline *cl,
2515 __attribute__((unused)) void *data)
2517 stop_packet_forwarding();
2520 cmdline_parse_token_string_t cmd_stop_stop =
2521 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2523 cmdline_parse_inst_t cmd_stop = {
2524 .f = cmd_stop_parsed,
2526 .help_str = "stop: Stop packet forwarding",
2528 (void *)&cmd_stop_stop,
2533 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2536 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2537 unsigned int *parsed_items, int check_unique_values)
2539 unsigned int nb_item;
2547 * First parse all items in the list and store their value.
2552 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2554 if ((c >= '0') && (c <= '9')) {
2555 value = (unsigned int) (value * 10 + (c - '0'));
2560 printf("character %c is not a decimal digit\n", c);
2564 printf("No valid value before comma\n");
2567 if (nb_item < max_items) {
2568 parsed_items[nb_item] = value;
2574 if (nb_item >= max_items) {
2575 printf("Number of %s = %u > %u (maximum items)\n",
2576 item_name, nb_item + 1, max_items);
2579 parsed_items[nb_item++] = value;
2580 if (! check_unique_values)
2584 * Then, check that all values in the list are differents.
2585 * No optimization here...
2587 for (i = 0; i < nb_item; i++) {
2588 for (j = i + 1; j < nb_item; j++) {
2589 if (parsed_items[j] == parsed_items[i]) {
2590 printf("duplicated %s %u at index %u and %u\n",
2591 item_name, parsed_items[i], i, j);
2599 struct cmd_set_list_result {
2600 cmdline_fixed_string_t cmd_keyword;
2601 cmdline_fixed_string_t list_name;
2602 cmdline_fixed_string_t list_of_items;
2605 static void cmd_set_list_parsed(void *parsed_result,
2606 __attribute__((unused)) struct cmdline *cl,
2607 __attribute__((unused)) void *data)
2609 struct cmd_set_list_result *res;
2611 unsigned int lcorelist[RTE_MAX_LCORE];
2612 unsigned int portlist[RTE_MAX_ETHPORTS];
2614 unsigned int nb_item;
2616 if (test_done == 0) {
2617 printf("Please stop forwarding first\n");
2621 res = parsed_result;
2622 if (!strcmp(res->list_name, "corelist")) {
2623 nb_item = parse_item_list(res->list_of_items, "core",
2625 parsed_items.lcorelist, 1);
2627 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2632 if (!strcmp(res->list_name, "portlist")) {
2633 nb_item = parse_item_list(res->list_of_items, "port",
2635 parsed_items.portlist, 1);
2637 set_fwd_ports_list(parsed_items.portlist, nb_item);
2643 cmdline_parse_token_string_t cmd_set_list_keyword =
2644 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2646 cmdline_parse_token_string_t cmd_set_list_name =
2647 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2648 "corelist#portlist");
2649 cmdline_parse_token_string_t cmd_set_list_of_items =
2650 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2653 cmdline_parse_inst_t cmd_set_fwd_list = {
2654 .f = cmd_set_list_parsed,
2656 .help_str = "set corelist|portlist <list0[,list1]*>",
2658 (void *)&cmd_set_list_keyword,
2659 (void *)&cmd_set_list_name,
2660 (void *)&cmd_set_list_of_items,
2665 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2667 struct cmd_setmask_result {
2668 cmdline_fixed_string_t set;
2669 cmdline_fixed_string_t mask;
2673 static void cmd_set_mask_parsed(void *parsed_result,
2674 __attribute__((unused)) struct cmdline *cl,
2675 __attribute__((unused)) void *data)
2677 struct cmd_setmask_result *res = parsed_result;
2679 if (test_done == 0) {
2680 printf("Please stop forwarding first\n");
2683 if (!strcmp(res->mask, "coremask")) {
2684 set_fwd_lcores_mask(res->hexavalue);
2686 } else if (!strcmp(res->mask, "portmask")) {
2687 set_fwd_ports_mask(res->hexavalue);
2692 cmdline_parse_token_string_t cmd_setmask_set =
2693 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2694 cmdline_parse_token_string_t cmd_setmask_mask =
2695 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2696 "coremask#portmask");
2697 cmdline_parse_token_num_t cmd_setmask_value =
2698 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2700 cmdline_parse_inst_t cmd_set_fwd_mask = {
2701 .f = cmd_set_mask_parsed,
2703 .help_str = "set coremask|portmask <hexadecimal value>",
2705 (void *)&cmd_setmask_set,
2706 (void *)&cmd_setmask_mask,
2707 (void *)&cmd_setmask_value,
2713 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2715 struct cmd_set_result {
2716 cmdline_fixed_string_t set;
2717 cmdline_fixed_string_t what;
2721 static void cmd_set_parsed(void *parsed_result,
2722 __attribute__((unused)) struct cmdline *cl,
2723 __attribute__((unused)) void *data)
2725 struct cmd_set_result *res = parsed_result;
2726 if (!strcmp(res->what, "nbport")) {
2727 set_fwd_ports_number(res->value);
2729 } else if (!strcmp(res->what, "nbcore")) {
2730 set_fwd_lcores_number(res->value);
2732 } else if (!strcmp(res->what, "burst"))
2733 set_nb_pkt_per_burst(res->value);
2734 else if (!strcmp(res->what, "verbose"))
2735 set_verbose_level(res->value);
2738 cmdline_parse_token_string_t cmd_set_set =
2739 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2740 cmdline_parse_token_string_t cmd_set_what =
2741 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2742 "nbport#nbcore#burst#verbose");
2743 cmdline_parse_token_num_t cmd_set_value =
2744 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2746 cmdline_parse_inst_t cmd_set_numbers = {
2747 .f = cmd_set_parsed,
2749 .help_str = "set nbport|nbcore|burst|verbose <value>",
2751 (void *)&cmd_set_set,
2752 (void *)&cmd_set_what,
2753 (void *)&cmd_set_value,
2758 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2760 struct cmd_set_txpkts_result {
2761 cmdline_fixed_string_t cmd_keyword;
2762 cmdline_fixed_string_t txpkts;
2763 cmdline_fixed_string_t seg_lengths;
2767 cmd_set_txpkts_parsed(void *parsed_result,
2768 __attribute__((unused)) struct cmdline *cl,
2769 __attribute__((unused)) void *data)
2771 struct cmd_set_txpkts_result *res;
2772 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2773 unsigned int nb_segs;
2775 res = parsed_result;
2776 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2777 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2779 set_tx_pkt_segments(seg_lengths, nb_segs);
2782 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2783 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2784 cmd_keyword, "set");
2785 cmdline_parse_token_string_t cmd_set_txpkts_name =
2786 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2788 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2789 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2792 cmdline_parse_inst_t cmd_set_txpkts = {
2793 .f = cmd_set_txpkts_parsed,
2795 .help_str = "set txpkts <len0[,len1]*>",
2797 (void *)&cmd_set_txpkts_keyword,
2798 (void *)&cmd_set_txpkts_name,
2799 (void *)&cmd_set_txpkts_lengths,
2804 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2806 struct cmd_set_txsplit_result {
2807 cmdline_fixed_string_t cmd_keyword;
2808 cmdline_fixed_string_t txsplit;
2809 cmdline_fixed_string_t mode;
2813 cmd_set_txsplit_parsed(void *parsed_result,
2814 __attribute__((unused)) struct cmdline *cl,
2815 __attribute__((unused)) void *data)
2817 struct cmd_set_txsplit_result *res;
2819 res = parsed_result;
2820 set_tx_pkt_split(res->mode);
2823 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2824 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2825 cmd_keyword, "set");
2826 cmdline_parse_token_string_t cmd_set_txsplit_name =
2827 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2828 txsplit, "txsplit");
2829 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2830 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2833 cmdline_parse_inst_t cmd_set_txsplit = {
2834 .f = cmd_set_txsplit_parsed,
2836 .help_str = "set txsplit on|off|rand",
2838 (void *)&cmd_set_txsplit_keyword,
2839 (void *)&cmd_set_txsplit_name,
2840 (void *)&cmd_set_txsplit_mode,
2845 /* *** CONFIG TX QUEUE FLAGS *** */
2847 struct cmd_config_txqflags_result {
2848 cmdline_fixed_string_t port;
2849 cmdline_fixed_string_t config;
2850 cmdline_fixed_string_t all;
2851 cmdline_fixed_string_t what;
2855 static void cmd_config_txqflags_parsed(void *parsed_result,
2856 __attribute__((unused)) struct cmdline *cl,
2857 __attribute__((unused)) void *data)
2859 struct cmd_config_txqflags_result *res = parsed_result;
2861 if (!all_ports_stopped()) {
2862 printf("Please stop all ports first\n");
2866 if (strcmp(res->what, "txqflags")) {
2867 printf("Unknown parameter\n");
2871 if (res->hexvalue >= 0) {
2872 txq_flags = res->hexvalue;
2874 printf("txqflags must be >= 0\n");
2880 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2883 cmdline_parse_token_string_t cmd_config_txqflags_port =
2884 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2886 cmdline_parse_token_string_t cmd_config_txqflags_config =
2887 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2889 cmdline_parse_token_string_t cmd_config_txqflags_all =
2890 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2892 cmdline_parse_token_string_t cmd_config_txqflags_what =
2893 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2895 cmdline_parse_token_num_t cmd_config_txqflags_value =
2896 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2899 cmdline_parse_inst_t cmd_config_txqflags = {
2900 .f = cmd_config_txqflags_parsed,
2902 .help_str = "port config all txqflags <value>",
2904 (void *)&cmd_config_txqflags_port,
2905 (void *)&cmd_config_txqflags_config,
2906 (void *)&cmd_config_txqflags_all,
2907 (void *)&cmd_config_txqflags_what,
2908 (void *)&cmd_config_txqflags_value,
2913 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2914 struct cmd_rx_vlan_filter_all_result {
2915 cmdline_fixed_string_t rx_vlan;
2916 cmdline_fixed_string_t what;
2917 cmdline_fixed_string_t all;
2922 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2923 __attribute__((unused)) struct cmdline *cl,
2924 __attribute__((unused)) void *data)
2926 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2928 if (!strcmp(res->what, "add"))
2929 rx_vlan_all_filter_set(res->port_id, 1);
2931 rx_vlan_all_filter_set(res->port_id, 0);
2934 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2935 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2936 rx_vlan, "rx_vlan");
2937 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2938 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2940 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2941 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2943 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2944 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2947 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2948 .f = cmd_rx_vlan_filter_all_parsed,
2950 .help_str = "rx_vlan add|rm all <port_id>: "
2951 "Add/Remove all identifiers to/from the set of VLAN "
2952 "identifiers filtered by a port",
2954 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2955 (void *)&cmd_rx_vlan_filter_all_what,
2956 (void *)&cmd_rx_vlan_filter_all_all,
2957 (void *)&cmd_rx_vlan_filter_all_portid,
2962 /* *** VLAN OFFLOAD SET ON A PORT *** */
2963 struct cmd_vlan_offload_result {
2964 cmdline_fixed_string_t vlan;
2965 cmdline_fixed_string_t set;
2966 cmdline_fixed_string_t vlan_type;
2967 cmdline_fixed_string_t what;
2968 cmdline_fixed_string_t on;
2969 cmdline_fixed_string_t port_id;
2973 cmd_vlan_offload_parsed(void *parsed_result,
2974 __attribute__((unused)) struct cmdline *cl,
2975 __attribute__((unused)) void *data)
2978 struct cmd_vlan_offload_result *res = parsed_result;
2981 portid_t port_id = 0;
2985 len = strnlen(str, STR_TOKEN_SIZE);
2987 /* Get port_id first */
2995 tmp = strtoul(str, NULL, 0);
2996 /* If port_id greater that what portid_t can represent, return */
2997 if(tmp >= RTE_MAX_ETHPORTS)
2999 port_id = (portid_t)tmp;
3001 if (!strcmp(res->on, "on"))
3006 if (!strcmp(res->what, "strip"))
3007 rx_vlan_strip_set(port_id, on);
3008 else if(!strcmp(res->what, "stripq")){
3009 uint16_t queue_id = 0;
3011 /* No queue_id, return */
3013 printf("must specify (port,queue_id)\n");
3016 tmp = strtoul(str + i + 1, NULL, 0);
3017 /* If queue_id greater that what 16-bits can represent, return */
3021 queue_id = (uint16_t)tmp;
3022 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3024 else if (!strcmp(res->what, "filter"))
3025 rx_vlan_filter_set(port_id, on);
3027 vlan_extend_set(port_id, on);
3032 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3033 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3035 cmdline_parse_token_string_t cmd_vlan_offload_set =
3036 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3038 cmdline_parse_token_string_t cmd_vlan_offload_what =
3039 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3040 what, "strip#filter#qinq#stripq");
3041 cmdline_parse_token_string_t cmd_vlan_offload_on =
3042 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3044 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3045 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3048 cmdline_parse_inst_t cmd_vlan_offload = {
3049 .f = cmd_vlan_offload_parsed,
3051 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3052 "<port_id[,queue_id]>: "
3053 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3055 (void *)&cmd_vlan_offload_vlan,
3056 (void *)&cmd_vlan_offload_set,
3057 (void *)&cmd_vlan_offload_what,
3058 (void *)&cmd_vlan_offload_on,
3059 (void *)&cmd_vlan_offload_portid,
3064 /* *** VLAN TPID SET ON A PORT *** */
3065 struct cmd_vlan_tpid_result {
3066 cmdline_fixed_string_t vlan;
3067 cmdline_fixed_string_t set;
3068 cmdline_fixed_string_t vlan_type;
3069 cmdline_fixed_string_t what;
3075 cmd_vlan_tpid_parsed(void *parsed_result,
3076 __attribute__((unused)) struct cmdline *cl,
3077 __attribute__((unused)) void *data)
3079 struct cmd_vlan_tpid_result *res = parsed_result;
3080 enum rte_vlan_type vlan_type;
3082 if (!strcmp(res->vlan_type, "inner"))
3083 vlan_type = ETH_VLAN_TYPE_INNER;
3084 else if (!strcmp(res->vlan_type, "outer"))
3085 vlan_type = ETH_VLAN_TYPE_OUTER;
3087 printf("Unknown vlan type\n");
3090 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3093 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3094 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3096 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3097 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3099 cmdline_parse_token_string_t cmd_vlan_type =
3100 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3101 vlan_type, "inner#outer");
3102 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3103 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3105 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3106 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3108 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3109 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3112 cmdline_parse_inst_t cmd_vlan_tpid = {
3113 .f = cmd_vlan_tpid_parsed,
3115 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3116 "Set the VLAN Ether type",
3118 (void *)&cmd_vlan_tpid_vlan,
3119 (void *)&cmd_vlan_tpid_set,
3120 (void *)&cmd_vlan_type,
3121 (void *)&cmd_vlan_tpid_what,
3122 (void *)&cmd_vlan_tpid_tpid,
3123 (void *)&cmd_vlan_tpid_portid,
3128 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3129 struct cmd_rx_vlan_filter_result {
3130 cmdline_fixed_string_t rx_vlan;
3131 cmdline_fixed_string_t what;
3137 cmd_rx_vlan_filter_parsed(void *parsed_result,
3138 __attribute__((unused)) struct cmdline *cl,
3139 __attribute__((unused)) void *data)
3141 struct cmd_rx_vlan_filter_result *res = parsed_result;
3143 if (!strcmp(res->what, "add"))
3144 rx_vft_set(res->port_id, res->vlan_id, 1);
3146 rx_vft_set(res->port_id, res->vlan_id, 0);
3149 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3150 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3151 rx_vlan, "rx_vlan");
3152 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3153 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3155 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3156 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3158 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3159 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3162 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3163 .f = cmd_rx_vlan_filter_parsed,
3165 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3166 "Add/Remove a VLAN identifier to/from the set of VLAN "
3167 "identifiers filtered by a port",
3169 (void *)&cmd_rx_vlan_filter_rx_vlan,
3170 (void *)&cmd_rx_vlan_filter_what,
3171 (void *)&cmd_rx_vlan_filter_vlanid,
3172 (void *)&cmd_rx_vlan_filter_portid,
3177 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3178 struct cmd_tx_vlan_set_result {
3179 cmdline_fixed_string_t tx_vlan;
3180 cmdline_fixed_string_t set;
3186 cmd_tx_vlan_set_parsed(void *parsed_result,
3187 __attribute__((unused)) struct cmdline *cl,
3188 __attribute__((unused)) void *data)
3190 struct cmd_tx_vlan_set_result *res = parsed_result;
3192 tx_vlan_set(res->port_id, res->vlan_id);
3195 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3196 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3197 tx_vlan, "tx_vlan");
3198 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3199 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3201 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3202 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3204 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3205 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3208 cmdline_parse_inst_t cmd_tx_vlan_set = {
3209 .f = cmd_tx_vlan_set_parsed,
3211 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3212 "Enable hardware insertion of a single VLAN header "
3213 "with a given TAG Identifier in packets sent on a port",
3215 (void *)&cmd_tx_vlan_set_tx_vlan,
3216 (void *)&cmd_tx_vlan_set_set,
3217 (void *)&cmd_tx_vlan_set_portid,
3218 (void *)&cmd_tx_vlan_set_vlanid,
3223 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3224 struct cmd_tx_vlan_set_qinq_result {
3225 cmdline_fixed_string_t tx_vlan;
3226 cmdline_fixed_string_t set;
3229 uint16_t vlan_id_outer;
3233 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3234 __attribute__((unused)) struct cmdline *cl,
3235 __attribute__((unused)) void *data)
3237 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3239 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3242 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3243 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3244 tx_vlan, "tx_vlan");
3245 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3246 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3248 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3249 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3251 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3252 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3254 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3255 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3256 vlan_id_outer, UINT16);
3258 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3259 .f = cmd_tx_vlan_set_qinq_parsed,
3261 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3262 "Enable hardware insertion of double VLAN header "
3263 "with given TAG Identifiers in packets sent on a port",
3265 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3266 (void *)&cmd_tx_vlan_set_qinq_set,
3267 (void *)&cmd_tx_vlan_set_qinq_portid,
3268 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3269 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3274 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3275 struct cmd_tx_vlan_set_pvid_result {
3276 cmdline_fixed_string_t tx_vlan;
3277 cmdline_fixed_string_t set;
3278 cmdline_fixed_string_t pvid;
3281 cmdline_fixed_string_t mode;
3285 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3286 __attribute__((unused)) struct cmdline *cl,
3287 __attribute__((unused)) void *data)
3289 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3291 if (strcmp(res->mode, "on") == 0)
3292 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3294 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3297 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3298 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3299 tx_vlan, "tx_vlan");
3300 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3301 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3303 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3304 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3306 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3307 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3309 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3310 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3312 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3313 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3316 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3317 .f = cmd_tx_vlan_set_pvid_parsed,
3319 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3321 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3322 (void *)&cmd_tx_vlan_set_pvid_set,
3323 (void *)&cmd_tx_vlan_set_pvid_pvid,
3324 (void *)&cmd_tx_vlan_set_pvid_port_id,
3325 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3326 (void *)&cmd_tx_vlan_set_pvid_mode,
3331 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3332 struct cmd_tx_vlan_reset_result {
3333 cmdline_fixed_string_t tx_vlan;
3334 cmdline_fixed_string_t reset;
3339 cmd_tx_vlan_reset_parsed(void *parsed_result,
3340 __attribute__((unused)) struct cmdline *cl,
3341 __attribute__((unused)) void *data)
3343 struct cmd_tx_vlan_reset_result *res = parsed_result;
3345 tx_vlan_reset(res->port_id);
3348 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3349 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3350 tx_vlan, "tx_vlan");
3351 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3352 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3354 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3355 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3358 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3359 .f = cmd_tx_vlan_reset_parsed,
3361 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3362 "VLAN header in packets sent on a port",
3364 (void *)&cmd_tx_vlan_reset_tx_vlan,
3365 (void *)&cmd_tx_vlan_reset_reset,
3366 (void *)&cmd_tx_vlan_reset_portid,
3372 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3373 struct cmd_csum_result {
3374 cmdline_fixed_string_t csum;
3375 cmdline_fixed_string_t mode;
3376 cmdline_fixed_string_t proto;
3377 cmdline_fixed_string_t hwsw;
3382 csum_show(int port_id)
3384 struct rte_eth_dev_info dev_info;
3387 ol_flags = ports[port_id].tx_ol_flags;
3388 printf("Parse tunnel is %s\n",
3389 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3390 printf("IP checksum offload is %s\n",
3391 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3392 printf("UDP checksum offload is %s\n",
3393 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3394 printf("TCP checksum offload is %s\n",
3395 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3396 printf("SCTP checksum offload is %s\n",
3397 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3398 printf("Outer-Ip checksum offload is %s\n",
3399 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3401 /* display warnings if configuration is not supported by the NIC */
3402 rte_eth_dev_info_get(port_id, &dev_info);
3403 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3404 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3405 printf("Warning: hardware IP checksum enabled but not "
3406 "supported by port %d\n", port_id);
3408 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3409 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3410 printf("Warning: hardware UDP checksum enabled but not "
3411 "supported by port %d\n", port_id);
3413 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3414 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3415 printf("Warning: hardware TCP checksum enabled but not "
3416 "supported by port %d\n", port_id);
3418 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3419 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3420 printf("Warning: hardware SCTP checksum enabled but not "
3421 "supported by port %d\n", port_id);
3423 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3424 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3425 printf("Warning: hardware outer IP checksum enabled but not "
3426 "supported by port %d\n", port_id);
3431 cmd_csum_parsed(void *parsed_result,
3432 __attribute__((unused)) struct cmdline *cl,
3433 __attribute__((unused)) void *data)
3435 struct cmd_csum_result *res = parsed_result;
3439 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3440 printf("invalid port %d\n", res->port_id);
3444 if (!strcmp(res->mode, "set")) {
3446 if (!strcmp(res->hwsw, "hw"))
3449 if (!strcmp(res->proto, "ip")) {
3450 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3451 } else if (!strcmp(res->proto, "udp")) {
3452 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3453 } else if (!strcmp(res->proto, "tcp")) {
3454 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3455 } else if (!strcmp(res->proto, "sctp")) {
3456 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3457 } else if (!strcmp(res->proto, "outer-ip")) {
3458 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3462 ports[res->port_id].tx_ol_flags |= mask;
3464 ports[res->port_id].tx_ol_flags &= (~mask);
3466 csum_show(res->port_id);
3469 cmdline_parse_token_string_t cmd_csum_csum =
3470 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3472 cmdline_parse_token_string_t cmd_csum_mode =
3473 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3475 cmdline_parse_token_string_t cmd_csum_proto =
3476 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3477 proto, "ip#tcp#udp#sctp#outer-ip");
3478 cmdline_parse_token_string_t cmd_csum_hwsw =
3479 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3481 cmdline_parse_token_num_t cmd_csum_portid =
3482 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3485 cmdline_parse_inst_t cmd_csum_set = {
3486 .f = cmd_csum_parsed,
3488 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3489 "Enable/Disable hardware calculation of L3/L4 checksum when "
3490 "using csum forward engine",
3492 (void *)&cmd_csum_csum,
3493 (void *)&cmd_csum_mode,
3494 (void *)&cmd_csum_proto,
3495 (void *)&cmd_csum_hwsw,
3496 (void *)&cmd_csum_portid,
3501 cmdline_parse_token_string_t cmd_csum_mode_show =
3502 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3505 cmdline_parse_inst_t cmd_csum_show = {
3506 .f = cmd_csum_parsed,
3508 .help_str = "csum show <port_id>: Show checksum offload configuration",
3510 (void *)&cmd_csum_csum,
3511 (void *)&cmd_csum_mode_show,
3512 (void *)&cmd_csum_portid,
3517 /* Enable/disable tunnel parsing */
3518 struct cmd_csum_tunnel_result {
3519 cmdline_fixed_string_t csum;
3520 cmdline_fixed_string_t parse;
3521 cmdline_fixed_string_t onoff;
3526 cmd_csum_tunnel_parsed(void *parsed_result,
3527 __attribute__((unused)) struct cmdline *cl,
3528 __attribute__((unused)) void *data)
3530 struct cmd_csum_tunnel_result *res = parsed_result;
3532 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3535 if (!strcmp(res->onoff, "on"))
3536 ports[res->port_id].tx_ol_flags |=
3537 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3539 ports[res->port_id].tx_ol_flags &=
3540 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3542 csum_show(res->port_id);
3545 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3546 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3548 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3549 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3550 parse, "parse_tunnel");
3551 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3552 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3554 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3555 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3558 cmdline_parse_inst_t cmd_csum_tunnel = {
3559 .f = cmd_csum_tunnel_parsed,
3561 .help_str = "csum parse_tunnel on|off <port_id>: "
3562 "Enable/Disable parsing of tunnels for csum engine",
3564 (void *)&cmd_csum_tunnel_csum,
3565 (void *)&cmd_csum_tunnel_parse,
3566 (void *)&cmd_csum_tunnel_onoff,
3567 (void *)&cmd_csum_tunnel_portid,
3572 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3573 struct cmd_tso_set_result {
3574 cmdline_fixed_string_t tso;
3575 cmdline_fixed_string_t mode;
3581 cmd_tso_set_parsed(void *parsed_result,
3582 __attribute__((unused)) struct cmdline *cl,
3583 __attribute__((unused)) void *data)
3585 struct cmd_tso_set_result *res = parsed_result;
3586 struct rte_eth_dev_info dev_info;
3588 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3591 if (!strcmp(res->mode, "set"))
3592 ports[res->port_id].tso_segsz = res->tso_segsz;
3594 if (ports[res->port_id].tso_segsz == 0)
3595 printf("TSO for non-tunneled packets is disabled\n");
3597 printf("TSO segment size for non-tunneled packets is %d\n",
3598 ports[res->port_id].tso_segsz);
3600 /* display warnings if configuration is not supported by the NIC */
3601 rte_eth_dev_info_get(res->port_id, &dev_info);
3602 if ((ports[res->port_id].tso_segsz != 0) &&
3603 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3604 printf("Warning: TSO enabled but not "
3605 "supported by port %d\n", res->port_id);
3609 cmdline_parse_token_string_t cmd_tso_set_tso =
3610 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3612 cmdline_parse_token_string_t cmd_tso_set_mode =
3613 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3615 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3616 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3618 cmdline_parse_token_num_t cmd_tso_set_portid =
3619 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3622 cmdline_parse_inst_t cmd_tso_set = {
3623 .f = cmd_tso_set_parsed,
3625 .help_str = "tso set <tso_segsz> <port_id>: "
3626 "Set TSO segment size of non-tunneled packets for csum engine "
3629 (void *)&cmd_tso_set_tso,
3630 (void *)&cmd_tso_set_mode,
3631 (void *)&cmd_tso_set_tso_segsz,
3632 (void *)&cmd_tso_set_portid,
3637 cmdline_parse_token_string_t cmd_tso_show_mode =
3638 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3642 cmdline_parse_inst_t cmd_tso_show = {
3643 .f = cmd_tso_set_parsed,
3645 .help_str = "tso show <port_id>: "
3646 "Show TSO segment size of non-tunneled packets for csum engine",
3648 (void *)&cmd_tso_set_tso,
3649 (void *)&cmd_tso_show_mode,
3650 (void *)&cmd_tso_set_portid,
3655 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3656 struct cmd_tunnel_tso_set_result {
3657 cmdline_fixed_string_t tso;
3658 cmdline_fixed_string_t mode;
3664 check_tunnel_tso_nic_support(uint8_t port_id)
3666 struct rte_eth_dev_info dev_info;
3668 rte_eth_dev_info_get(port_id, &dev_info);
3669 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3670 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3671 "supported by port %d\n", port_id);
3672 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3673 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3674 "supported by port %d\n", port_id);
3675 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3676 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3677 "supported by port %d\n", port_id);
3678 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3679 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3680 "supported by port %d\n", port_id);
3684 cmd_tunnel_tso_set_parsed(void *parsed_result,
3685 __attribute__((unused)) struct cmdline *cl,
3686 __attribute__((unused)) void *data)
3688 struct cmd_tunnel_tso_set_result *res = parsed_result;
3690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3693 if (!strcmp(res->mode, "set"))
3694 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3696 if (ports[res->port_id].tunnel_tso_segsz == 0)
3697 printf("TSO for tunneled packets is disabled\n");
3699 printf("TSO segment size for tunneled packets is %d\n",
3700 ports[res->port_id].tunnel_tso_segsz);
3702 /* Below conditions are needed to make it work:
3703 * (1) tunnel TSO is supported by the NIC;
3704 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3706 * (3) for tunneled pkts with outer L3 of IPv4,
3707 * "csum set outer-ip" must be set to hw, because after tso,
3708 * total_len of outer IP header is changed, and the checksum
3709 * of outer IP header calculated by sw should be wrong; that
3710 * is not necessary for IPv6 tunneled pkts because there's no
3711 * checksum in IP header anymore.
3713 check_tunnel_tso_nic_support(res->port_id);
3715 if (!(ports[res->port_id].tx_ol_flags &
3716 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3717 printf("Warning: csum parse_tunnel must be set "
3718 "so that tunneled packets are recognized\n");
3719 if (!(ports[res->port_id].tx_ol_flags &
3720 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3721 printf("Warning: csum set outer-ip must be set to hw "
3722 "if outer L3 is IPv4; not necessary for IPv6\n");
3726 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3727 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3729 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3730 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3732 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3733 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3735 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3736 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3739 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3740 .f = cmd_tunnel_tso_set_parsed,
3742 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3743 "Set TSO segment size of tunneled packets for csum engine "
3746 (void *)&cmd_tunnel_tso_set_tso,
3747 (void *)&cmd_tunnel_tso_set_mode,
3748 (void *)&cmd_tunnel_tso_set_tso_segsz,
3749 (void *)&cmd_tunnel_tso_set_portid,
3754 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3755 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3759 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3760 .f = cmd_tunnel_tso_set_parsed,
3762 .help_str = "tunnel_tso show <port_id> "
3763 "Show TSO segment size of tunneled packets for csum engine",
3765 (void *)&cmd_tunnel_tso_set_tso,
3766 (void *)&cmd_tunnel_tso_show_mode,
3767 (void *)&cmd_tunnel_tso_set_portid,
3772 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3773 struct cmd_set_flush_rx {
3774 cmdline_fixed_string_t set;
3775 cmdline_fixed_string_t flush_rx;
3776 cmdline_fixed_string_t mode;
3780 cmd_set_flush_rx_parsed(void *parsed_result,
3781 __attribute__((unused)) struct cmdline *cl,
3782 __attribute__((unused)) void *data)
3784 struct cmd_set_flush_rx *res = parsed_result;
3785 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3788 cmdline_parse_token_string_t cmd_setflushrx_set =
3789 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3791 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3792 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3793 flush_rx, "flush_rx");
3794 cmdline_parse_token_string_t cmd_setflushrx_mode =
3795 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3799 cmdline_parse_inst_t cmd_set_flush_rx = {
3800 .f = cmd_set_flush_rx_parsed,
3801 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3804 (void *)&cmd_setflushrx_set,
3805 (void *)&cmd_setflushrx_flush_rx,
3806 (void *)&cmd_setflushrx_mode,
3811 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3812 struct cmd_set_link_check {
3813 cmdline_fixed_string_t set;
3814 cmdline_fixed_string_t link_check;
3815 cmdline_fixed_string_t mode;
3819 cmd_set_link_check_parsed(void *parsed_result,
3820 __attribute__((unused)) struct cmdline *cl,
3821 __attribute__((unused)) void *data)
3823 struct cmd_set_link_check *res = parsed_result;
3824 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3827 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3828 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3830 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3832 link_check, "link_check");
3833 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3834 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3838 cmdline_parse_inst_t cmd_set_link_check = {
3839 .f = cmd_set_link_check_parsed,
3840 .help_str = "set link_check on|off: Enable/Disable link status check "
3841 "when starting/stopping a port",
3844 (void *)&cmd_setlinkcheck_set,
3845 (void *)&cmd_setlinkcheck_link_check,
3846 (void *)&cmd_setlinkcheck_mode,
3851 #ifdef RTE_NIC_BYPASS
3852 /* *** SET NIC BYPASS MODE *** */
3853 struct cmd_set_bypass_mode_result {
3854 cmdline_fixed_string_t set;
3855 cmdline_fixed_string_t bypass;
3856 cmdline_fixed_string_t mode;
3857 cmdline_fixed_string_t value;
3862 cmd_set_bypass_mode_parsed(void *parsed_result,
3863 __attribute__((unused)) struct cmdline *cl,
3864 __attribute__((unused)) void *data)
3866 struct cmd_set_bypass_mode_result *res = parsed_result;
3867 portid_t port_id = res->port_id;
3868 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3870 if (!strcmp(res->value, "bypass"))
3871 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3872 else if (!strcmp(res->value, "isolate"))
3873 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3875 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3877 /* Set the bypass mode for the relevant port. */
3878 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3879 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3883 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3884 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3886 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3887 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3889 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3890 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3892 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3893 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3894 value, "normal#bypass#isolate");
3895 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3896 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3899 cmdline_parse_inst_t cmd_set_bypass_mode = {
3900 .f = cmd_set_bypass_mode_parsed,
3901 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3902 "Set the NIC bypass mode for port_id",
3905 (void *)&cmd_setbypass_mode_set,
3906 (void *)&cmd_setbypass_mode_bypass,
3907 (void *)&cmd_setbypass_mode_mode,
3908 (void *)&cmd_setbypass_mode_value,
3909 (void *)&cmd_setbypass_mode_port,
3914 /* *** SET NIC BYPASS EVENT *** */
3915 struct cmd_set_bypass_event_result {
3916 cmdline_fixed_string_t set;
3917 cmdline_fixed_string_t bypass;
3918 cmdline_fixed_string_t event;
3919 cmdline_fixed_string_t event_value;
3920 cmdline_fixed_string_t mode;
3921 cmdline_fixed_string_t mode_value;
3926 cmd_set_bypass_event_parsed(void *parsed_result,
3927 __attribute__((unused)) struct cmdline *cl,
3928 __attribute__((unused)) void *data)
3931 struct cmd_set_bypass_event_result *res = parsed_result;
3932 portid_t port_id = res->port_id;
3933 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3934 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3936 if (!strcmp(res->event_value, "timeout"))
3937 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3938 else if (!strcmp(res->event_value, "os_on"))
3939 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3940 else if (!strcmp(res->event_value, "os_off"))
3941 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3942 else if (!strcmp(res->event_value, "power_on"))
3943 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3944 else if (!strcmp(res->event_value, "power_off"))
3945 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3947 bypass_event = RTE_BYPASS_EVENT_NONE;
3949 if (!strcmp(res->mode_value, "bypass"))
3950 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3951 else if (!strcmp(res->mode_value, "isolate"))
3952 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3954 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3956 /* Set the watchdog timeout. */
3957 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3960 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3961 (rc = rte_eth_dev_wd_timeout_store(port_id,
3962 bypass_timeout)) != 0) {
3963 printf("Failed to set timeout value %u "
3964 "for port %d, errto code: %d.\n",
3965 bypass_timeout, port_id, rc);
3969 /* Set the bypass event to transition to bypass mode. */
3970 if (0 != rte_eth_dev_bypass_event_store(port_id,
3971 bypass_event, bypass_mode)) {
3972 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3977 cmdline_parse_token_string_t cmd_setbypass_event_set =
3978 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3980 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3983 cmdline_parse_token_string_t cmd_setbypass_event_event =
3984 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3986 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3987 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3988 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3989 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3992 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3994 mode_value, "normal#bypass#isolate");
3995 cmdline_parse_token_num_t cmd_setbypass_event_port =
3996 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3999 cmdline_parse_inst_t cmd_set_bypass_event = {
4000 .f = cmd_set_bypass_event_parsed,
4001 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4002 "power_off mode normal|bypass|isolate <port_id>: "
4003 "Set the NIC bypass event mode for port_id",
4006 (void *)&cmd_setbypass_event_set,
4007 (void *)&cmd_setbypass_event_bypass,
4008 (void *)&cmd_setbypass_event_event,
4009 (void *)&cmd_setbypass_event_event_value,
4010 (void *)&cmd_setbypass_event_mode,
4011 (void *)&cmd_setbypass_event_mode_value,
4012 (void *)&cmd_setbypass_event_port,
4018 /* *** SET NIC BYPASS TIMEOUT *** */
4019 struct cmd_set_bypass_timeout_result {
4020 cmdline_fixed_string_t set;
4021 cmdline_fixed_string_t bypass;
4022 cmdline_fixed_string_t timeout;
4023 cmdline_fixed_string_t value;
4027 cmd_set_bypass_timeout_parsed(void *parsed_result,
4028 __attribute__((unused)) struct cmdline *cl,
4029 __attribute__((unused)) void *data)
4031 struct cmd_set_bypass_timeout_result *res = parsed_result;
4033 if (!strcmp(res->value, "1.5"))
4034 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4035 else if (!strcmp(res->value, "2"))
4036 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4037 else if (!strcmp(res->value, "3"))
4038 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4039 else if (!strcmp(res->value, "4"))
4040 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4041 else if (!strcmp(res->value, "8"))
4042 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4043 else if (!strcmp(res->value, "16"))
4044 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4045 else if (!strcmp(res->value, "32"))
4046 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4048 bypass_timeout = RTE_BYPASS_TMT_OFF;
4051 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4052 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4054 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4055 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4057 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4058 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4059 timeout, "timeout");
4060 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4061 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4062 value, "0#1.5#2#3#4#8#16#32");
4064 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4065 .f = cmd_set_bypass_timeout_parsed,
4066 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4067 "Set the NIC bypass watchdog timeout in seconds",
4070 (void *)&cmd_setbypass_timeout_set,
4071 (void *)&cmd_setbypass_timeout_bypass,
4072 (void *)&cmd_setbypass_timeout_timeout,
4073 (void *)&cmd_setbypass_timeout_value,
4078 /* *** SHOW NIC BYPASS MODE *** */
4079 struct cmd_show_bypass_config_result {
4080 cmdline_fixed_string_t show;
4081 cmdline_fixed_string_t bypass;
4082 cmdline_fixed_string_t config;
4087 cmd_show_bypass_config_parsed(void *parsed_result,
4088 __attribute__((unused)) struct cmdline *cl,
4089 __attribute__((unused)) void *data)
4091 struct cmd_show_bypass_config_result *res = parsed_result;
4092 uint32_t event_mode;
4093 uint32_t bypass_mode;
4094 portid_t port_id = res->port_id;
4095 uint32_t timeout = bypass_timeout;
4098 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4099 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4100 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4101 {"UNKNOWN", "normal", "bypass", "isolate"};
4102 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4109 int num_events = (sizeof events) / (sizeof events[0]);
4111 /* Display the bypass mode.*/
4112 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4113 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4117 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4118 bypass_mode = RTE_BYPASS_MODE_NONE;
4120 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4123 /* Display the bypass timeout.*/
4124 if (!RTE_BYPASS_TMT_VALID(timeout))
4125 timeout = RTE_BYPASS_TMT_OFF;
4127 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4129 /* Display the bypass events and associated modes. */
4130 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4132 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4133 printf("\tFailed to get bypass mode for event = %s\n",
4136 if (!RTE_BYPASS_MODE_VALID(event_mode))
4137 event_mode = RTE_BYPASS_MODE_NONE;
4139 printf("\tbypass event: %-16s = %s\n", events[i],
4145 cmdline_parse_token_string_t cmd_showbypass_config_show =
4146 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4148 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4149 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4151 cmdline_parse_token_string_t cmd_showbypass_config_config =
4152 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4154 cmdline_parse_token_num_t cmd_showbypass_config_port =
4155 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4158 cmdline_parse_inst_t cmd_show_bypass_config = {
4159 .f = cmd_show_bypass_config_parsed,
4160 .help_str = "show bypass config <port_id>: "
4161 "Show the NIC bypass config for port_id",
4164 (void *)&cmd_showbypass_config_show,
4165 (void *)&cmd_showbypass_config_bypass,
4166 (void *)&cmd_showbypass_config_config,
4167 (void *)&cmd_showbypass_config_port,
4173 #ifdef RTE_LIBRTE_PMD_BOND
4174 /* *** SET BONDING MODE *** */
4175 struct cmd_set_bonding_mode_result {
4176 cmdline_fixed_string_t set;
4177 cmdline_fixed_string_t bonding;
4178 cmdline_fixed_string_t mode;
4183 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4184 __attribute__((unused)) struct cmdline *cl,
4185 __attribute__((unused)) void *data)
4187 struct cmd_set_bonding_mode_result *res = parsed_result;
4188 portid_t port_id = res->port_id;
4190 /* Set the bonding mode for the relevant port. */
4191 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4192 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4195 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4196 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4198 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4199 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4200 bonding, "bonding");
4201 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4202 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4204 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4205 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4207 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4208 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4211 cmdline_parse_inst_t cmd_set_bonding_mode = {
4212 .f = cmd_set_bonding_mode_parsed,
4213 .help_str = "set bonding mode <mode_value> <port_id>: "
4214 "Set the bonding mode for port_id",
4217 (void *) &cmd_setbonding_mode_set,
4218 (void *) &cmd_setbonding_mode_bonding,
4219 (void *) &cmd_setbonding_mode_mode,
4220 (void *) &cmd_setbonding_mode_value,
4221 (void *) &cmd_setbonding_mode_port,
4226 /* *** SET BALANCE XMIT POLICY *** */
4227 struct cmd_set_bonding_balance_xmit_policy_result {
4228 cmdline_fixed_string_t set;
4229 cmdline_fixed_string_t bonding;
4230 cmdline_fixed_string_t balance_xmit_policy;
4232 cmdline_fixed_string_t policy;
4235 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4236 __attribute__((unused)) struct cmdline *cl,
4237 __attribute__((unused)) void *data)
4239 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4240 portid_t port_id = res->port_id;
4243 if (!strcmp(res->policy, "l2")) {
4244 policy = BALANCE_XMIT_POLICY_LAYER2;
4245 } else if (!strcmp(res->policy, "l23")) {
4246 policy = BALANCE_XMIT_POLICY_LAYER23;
4247 } else if (!strcmp(res->policy, "l34")) {
4248 policy = BALANCE_XMIT_POLICY_LAYER34;
4250 printf("\t Invalid xmit policy selection");
4254 /* Set the bonding mode for the relevant port. */
4255 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4256 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4261 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4262 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4264 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4265 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4266 bonding, "bonding");
4267 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4269 balance_xmit_policy, "balance_xmit_policy");
4270 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4271 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4273 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4274 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4275 policy, "l2#l23#l34");
4277 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4278 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4279 .help_str = "set bonding balance_xmit_policy <port_id> "
4281 "Set the bonding balance_xmit_policy for port_id",
4284 (void *)&cmd_setbonding_balance_xmit_policy_set,
4285 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4286 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4287 (void *)&cmd_setbonding_balance_xmit_policy_port,
4288 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4293 /* *** SHOW NIC BONDING CONFIGURATION *** */
4294 struct cmd_show_bonding_config_result {
4295 cmdline_fixed_string_t show;
4296 cmdline_fixed_string_t bonding;
4297 cmdline_fixed_string_t config;
4301 static void cmd_show_bonding_config_parsed(void *parsed_result,
4302 __attribute__((unused)) struct cmdline *cl,
4303 __attribute__((unused)) void *data)
4305 struct cmd_show_bonding_config_result *res = parsed_result;
4307 uint8_t slaves[RTE_MAX_ETHPORTS];
4308 int num_slaves, num_active_slaves;
4311 portid_t port_id = res->port_id;
4313 /* Display the bonding mode.*/
4314 bonding_mode = rte_eth_bond_mode_get(port_id);
4315 if (bonding_mode < 0) {
4316 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4319 printf("\tBonding mode: %d\n", bonding_mode);
4321 if (bonding_mode == BONDING_MODE_BALANCE) {
4322 int balance_xmit_policy;
4324 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4325 if (balance_xmit_policy < 0) {
4326 printf("\tFailed to get balance xmit policy for port = %d\n",
4330 printf("\tBalance Xmit Policy: ");
4332 switch (balance_xmit_policy) {
4333 case BALANCE_XMIT_POLICY_LAYER2:
4334 printf("BALANCE_XMIT_POLICY_LAYER2");
4336 case BALANCE_XMIT_POLICY_LAYER23:
4337 printf("BALANCE_XMIT_POLICY_LAYER23");
4339 case BALANCE_XMIT_POLICY_LAYER34:
4340 printf("BALANCE_XMIT_POLICY_LAYER34");
4347 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4349 if (num_slaves < 0) {
4350 printf("\tFailed to get slave list for port = %d\n", port_id);
4353 if (num_slaves > 0) {
4354 printf("\tSlaves (%d): [", num_slaves);
4355 for (i = 0; i < num_slaves - 1; i++)
4356 printf("%d ", slaves[i]);
4358 printf("%d]\n", slaves[num_slaves - 1]);
4360 printf("\tSlaves: []\n");
4364 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4367 if (num_active_slaves < 0) {
4368 printf("\tFailed to get active slave list for port = %d\n", port_id);
4371 if (num_active_slaves > 0) {
4372 printf("\tActive Slaves (%d): [", num_active_slaves);
4373 for (i = 0; i < num_active_slaves - 1; i++)
4374 printf("%d ", slaves[i]);
4376 printf("%d]\n", slaves[num_active_slaves - 1]);
4379 printf("\tActive Slaves: []\n");
4383 primary_id = rte_eth_bond_primary_get(port_id);
4384 if (primary_id < 0) {
4385 printf("\tFailed to get primary slave for port = %d\n", port_id);
4388 printf("\tPrimary: [%d]\n", primary_id);
4392 cmdline_parse_token_string_t cmd_showbonding_config_show =
4393 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4395 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4396 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4397 bonding, "bonding");
4398 cmdline_parse_token_string_t cmd_showbonding_config_config =
4399 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4401 cmdline_parse_token_num_t cmd_showbonding_config_port =
4402 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4405 cmdline_parse_inst_t cmd_show_bonding_config = {
4406 .f = cmd_show_bonding_config_parsed,
4407 .help_str = "show bonding config <port_id>: "
4408 "Show the bonding config for port_id",
4411 (void *)&cmd_showbonding_config_show,
4412 (void *)&cmd_showbonding_config_bonding,
4413 (void *)&cmd_showbonding_config_config,
4414 (void *)&cmd_showbonding_config_port,
4419 /* *** SET BONDING PRIMARY *** */
4420 struct cmd_set_bonding_primary_result {
4421 cmdline_fixed_string_t set;
4422 cmdline_fixed_string_t bonding;
4423 cmdline_fixed_string_t primary;
4428 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4429 __attribute__((unused)) struct cmdline *cl,
4430 __attribute__((unused)) void *data)
4432 struct cmd_set_bonding_primary_result *res = parsed_result;
4433 portid_t master_port_id = res->port_id;
4434 portid_t slave_port_id = res->slave_id;
4436 /* Set the primary slave for a bonded device. */
4437 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4438 printf("\t Failed to set primary slave for port = %d.\n",
4445 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4446 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4448 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4449 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4450 bonding, "bonding");
4451 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4452 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4453 primary, "primary");
4454 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4455 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4457 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4458 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4461 cmdline_parse_inst_t cmd_set_bonding_primary = {
4462 .f = cmd_set_bonding_primary_parsed,
4463 .help_str = "set bonding primary <slave_id> <port_id>: "
4464 "Set the primary slave for port_id",
4467 (void *)&cmd_setbonding_primary_set,
4468 (void *)&cmd_setbonding_primary_bonding,
4469 (void *)&cmd_setbonding_primary_primary,
4470 (void *)&cmd_setbonding_primary_slave,
4471 (void *)&cmd_setbonding_primary_port,
4476 /* *** ADD SLAVE *** */
4477 struct cmd_add_bonding_slave_result {
4478 cmdline_fixed_string_t add;
4479 cmdline_fixed_string_t bonding;
4480 cmdline_fixed_string_t slave;
4485 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4486 __attribute__((unused)) struct cmdline *cl,
4487 __attribute__((unused)) void *data)
4489 struct cmd_add_bonding_slave_result *res = parsed_result;
4490 portid_t master_port_id = res->port_id;
4491 portid_t slave_port_id = res->slave_id;
4493 /* Set the primary slave for a bonded device. */
4494 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4495 printf("\t Failed to add slave %d to master port = %d.\n",
4496 slave_port_id, master_port_id);
4500 set_port_slave_flag(slave_port_id);
4503 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4504 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4506 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4507 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4508 bonding, "bonding");
4509 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4510 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4512 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4513 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4515 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4516 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4519 cmdline_parse_inst_t cmd_add_bonding_slave = {
4520 .f = cmd_add_bonding_slave_parsed,
4521 .help_str = "add bonding slave <slave_id> <port_id>: "
4522 "Add a slave device to a bonded device",
4525 (void *)&cmd_addbonding_slave_add,
4526 (void *)&cmd_addbonding_slave_bonding,
4527 (void *)&cmd_addbonding_slave_slave,
4528 (void *)&cmd_addbonding_slave_slaveid,
4529 (void *)&cmd_addbonding_slave_port,
4534 /* *** REMOVE SLAVE *** */
4535 struct cmd_remove_bonding_slave_result {
4536 cmdline_fixed_string_t remove;
4537 cmdline_fixed_string_t bonding;
4538 cmdline_fixed_string_t slave;
4543 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4544 __attribute__((unused)) struct cmdline *cl,
4545 __attribute__((unused)) void *data)
4547 struct cmd_remove_bonding_slave_result *res = parsed_result;
4548 portid_t master_port_id = res->port_id;
4549 portid_t slave_port_id = res->slave_id;
4551 /* Set the primary slave for a bonded device. */
4552 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4553 printf("\t Failed to remove slave %d from master port = %d.\n",
4554 slave_port_id, master_port_id);
4558 clear_port_slave_flag(slave_port_id);
4561 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4562 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4564 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4565 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4566 bonding, "bonding");
4567 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4568 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4570 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4571 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4573 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4574 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4577 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4578 .f = cmd_remove_bonding_slave_parsed,
4579 .help_str = "remove bonding slave <slave_id> <port_id>: "
4580 "Remove a slave device from a bonded device",
4583 (void *)&cmd_removebonding_slave_remove,
4584 (void *)&cmd_removebonding_slave_bonding,
4585 (void *)&cmd_removebonding_slave_slave,
4586 (void *)&cmd_removebonding_slave_slaveid,
4587 (void *)&cmd_removebonding_slave_port,
4592 /* *** CREATE BONDED DEVICE *** */
4593 struct cmd_create_bonded_device_result {
4594 cmdline_fixed_string_t create;
4595 cmdline_fixed_string_t bonded;
4596 cmdline_fixed_string_t device;
4601 static int bond_dev_num = 0;
4603 static void cmd_create_bonded_device_parsed(void *parsed_result,
4604 __attribute__((unused)) struct cmdline *cl,
4605 __attribute__((unused)) void *data)
4607 struct cmd_create_bonded_device_result *res = parsed_result;
4608 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4611 if (test_done == 0) {
4612 printf("Please stop forwarding first\n");
4616 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4619 /* Create a new bonded device. */
4620 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4622 printf("\t Failed to create bonded device.\n");
4625 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4628 /* Update number of ports */
4629 nb_ports = rte_eth_dev_count();
4630 reconfig(port_id, res->socket);
4631 rte_eth_promiscuous_enable(port_id);
4632 ports[port_id].enabled = 1;
4637 cmdline_parse_token_string_t cmd_createbonded_device_create =
4638 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4640 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4641 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4643 cmdline_parse_token_string_t cmd_createbonded_device_device =
4644 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4646 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4647 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4649 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4650 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4653 cmdline_parse_inst_t cmd_create_bonded_device = {
4654 .f = cmd_create_bonded_device_parsed,
4655 .help_str = "create bonded device <mode> <socket>: "
4656 "Create a new bonded device with specific bonding mode and socket",
4659 (void *)&cmd_createbonded_device_create,
4660 (void *)&cmd_createbonded_device_bonded,
4661 (void *)&cmd_createbonded_device_device,
4662 (void *)&cmd_createbonded_device_mode,
4663 (void *)&cmd_createbonded_device_socket,
4668 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4669 struct cmd_set_bond_mac_addr_result {
4670 cmdline_fixed_string_t set;
4671 cmdline_fixed_string_t bonding;
4672 cmdline_fixed_string_t mac_addr;
4674 struct ether_addr address;
4677 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4678 __attribute__((unused)) struct cmdline *cl,
4679 __attribute__((unused)) void *data)
4681 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4684 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4687 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4689 /* check the return value and print it if is < 0 */
4691 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4694 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4695 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4696 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4697 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4699 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4700 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4702 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4703 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4704 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4705 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4707 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4708 .f = cmd_set_bond_mac_addr_parsed,
4710 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4712 (void *)&cmd_set_bond_mac_addr_set,
4713 (void *)&cmd_set_bond_mac_addr_bonding,
4714 (void *)&cmd_set_bond_mac_addr_mac,
4715 (void *)&cmd_set_bond_mac_addr_portnum,
4716 (void *)&cmd_set_bond_mac_addr_addr,
4722 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4723 struct cmd_set_bond_mon_period_result {
4724 cmdline_fixed_string_t set;
4725 cmdline_fixed_string_t bonding;
4726 cmdline_fixed_string_t mon_period;
4731 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4732 __attribute__((unused)) struct cmdline *cl,
4733 __attribute__((unused)) void *data)
4735 struct cmd_set_bond_mon_period_result *res = parsed_result;
4738 if (res->port_num >= nb_ports) {
4739 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4743 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4745 /* check the return value and print it if is < 0 */
4747 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4750 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4751 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4753 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4754 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4755 bonding, "bonding");
4756 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4757 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4758 mon_period, "mon_period");
4759 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4760 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4762 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4763 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4766 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4767 .f = cmd_set_bond_mon_period_parsed,
4769 .help_str = "set bonding mon_period <port_id> <period_ms>",
4771 (void *)&cmd_set_bond_mon_period_set,
4772 (void *)&cmd_set_bond_mon_period_bonding,
4773 (void *)&cmd_set_bond_mon_period_mon_period,
4774 (void *)&cmd_set_bond_mon_period_portnum,
4775 (void *)&cmd_set_bond_mon_period_period_ms,
4780 #endif /* RTE_LIBRTE_PMD_BOND */
4782 /* *** SET FORWARDING MODE *** */
4783 struct cmd_set_fwd_mode_result {
4784 cmdline_fixed_string_t set;
4785 cmdline_fixed_string_t fwd;
4786 cmdline_fixed_string_t mode;
4789 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4790 __attribute__((unused)) struct cmdline *cl,
4791 __attribute__((unused)) void *data)
4793 struct cmd_set_fwd_mode_result *res = parsed_result;
4796 set_pkt_forwarding_mode(res->mode);
4799 cmdline_parse_token_string_t cmd_setfwd_set =
4800 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4801 cmdline_parse_token_string_t cmd_setfwd_fwd =
4802 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4803 cmdline_parse_token_string_t cmd_setfwd_mode =
4804 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4805 "" /* defined at init */);
4807 cmdline_parse_inst_t cmd_set_fwd_mode = {
4808 .f = cmd_set_fwd_mode_parsed,
4810 .help_str = NULL, /* defined at init */
4812 (void *)&cmd_setfwd_set,
4813 (void *)&cmd_setfwd_fwd,
4814 (void *)&cmd_setfwd_mode,
4819 static void cmd_set_fwd_mode_init(void)
4822 static char token[128];
4823 static char help[256];
4824 cmdline_parse_token_string_t *token_struct;
4826 modes = list_pkt_forwarding_modes();
4827 snprintf(help, sizeof(help), "set fwd %s: "
4828 "Set packet forwarding mode", modes);
4829 cmd_set_fwd_mode.help_str = help;
4831 /* string token separator is # */
4832 for (c = token; *modes != '\0'; modes++)
4837 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4838 token_struct->string_data.str = token;
4841 /* *** SET RETRY FORWARDING MODE *** */
4842 struct cmd_set_fwd_retry_mode_result {
4843 cmdline_fixed_string_t set;
4844 cmdline_fixed_string_t fwd;
4845 cmdline_fixed_string_t mode;
4846 cmdline_fixed_string_t retry;
4849 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4850 __attribute__((unused)) struct cmdline *cl,
4851 __attribute__((unused)) void *data)
4853 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4856 set_pkt_forwarding_mode(res->mode);
4859 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4862 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4865 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4866 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4868 "" /* defined at init */);
4869 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4870 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4873 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4874 .f = cmd_set_fwd_retry_mode_parsed,
4876 .help_str = NULL, /* defined at init */
4878 (void *)&cmd_setfwd_retry_set,
4879 (void *)&cmd_setfwd_retry_fwd,
4880 (void *)&cmd_setfwd_retry_mode,
4881 (void *)&cmd_setfwd_retry_retry,
4886 static void cmd_set_fwd_retry_mode_init(void)
4889 static char token[128];
4890 static char help[256];
4891 cmdline_parse_token_string_t *token_struct;
4893 modes = list_pkt_forwarding_retry_modes();
4894 snprintf(help, sizeof(help), "set fwd %s retry: "
4895 "Set packet forwarding mode with retry", modes);
4896 cmd_set_fwd_retry_mode.help_str = help;
4898 /* string token separator is # */
4899 for (c = token; *modes != '\0'; modes++)
4904 token_struct = (cmdline_parse_token_string_t *)
4905 cmd_set_fwd_retry_mode.tokens[2];
4906 token_struct->string_data.str = token;
4909 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4910 struct cmd_set_burst_tx_retry_result {
4911 cmdline_fixed_string_t set;
4912 cmdline_fixed_string_t burst;
4913 cmdline_fixed_string_t tx;
4914 cmdline_fixed_string_t delay;
4916 cmdline_fixed_string_t retry;
4920 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4921 __attribute__((unused)) struct cmdline *cl,
4922 __attribute__((unused)) void *data)
4924 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4926 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4927 && !strcmp(res->tx, "tx")) {
4928 if (!strcmp(res->delay, "delay"))
4929 burst_tx_delay_time = res->time;
4930 if (!strcmp(res->retry, "retry"))
4931 burst_tx_retry_num = res->retry_num;
4936 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4937 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4938 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4939 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4941 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4942 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4943 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4944 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4945 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4946 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4947 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4948 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4949 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4950 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4952 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4953 .f = cmd_set_burst_tx_retry_parsed,
4954 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4956 (void *)&cmd_set_burst_tx_retry_set,
4957 (void *)&cmd_set_burst_tx_retry_burst,
4958 (void *)&cmd_set_burst_tx_retry_tx,
4959 (void *)&cmd_set_burst_tx_retry_delay,
4960 (void *)&cmd_set_burst_tx_retry_time,
4961 (void *)&cmd_set_burst_tx_retry_retry,
4962 (void *)&cmd_set_burst_tx_retry_retry_num,
4967 /* *** SET PROMISC MODE *** */
4968 struct cmd_set_promisc_mode_result {
4969 cmdline_fixed_string_t set;
4970 cmdline_fixed_string_t promisc;
4971 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4972 uint8_t port_num; /* valid if "allports" argument == 0 */
4973 cmdline_fixed_string_t mode;
4976 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4977 __attribute__((unused)) struct cmdline *cl,
4980 struct cmd_set_promisc_mode_result *res = parsed_result;
4984 if (!strcmp(res->mode, "on"))
4991 FOREACH_PORT(i, ports) {
4993 rte_eth_promiscuous_enable(i);
4995 rte_eth_promiscuous_disable(i);
5000 rte_eth_promiscuous_enable(res->port_num);
5002 rte_eth_promiscuous_disable(res->port_num);
5006 cmdline_parse_token_string_t cmd_setpromisc_set =
5007 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5008 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5009 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5011 cmdline_parse_token_string_t cmd_setpromisc_portall =
5012 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5014 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5015 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5017 cmdline_parse_token_string_t cmd_setpromisc_mode =
5018 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5021 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5022 .f = cmd_set_promisc_mode_parsed,
5024 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5026 (void *)&cmd_setpromisc_set,
5027 (void *)&cmd_setpromisc_promisc,
5028 (void *)&cmd_setpromisc_portall,
5029 (void *)&cmd_setpromisc_mode,
5034 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5035 .f = cmd_set_promisc_mode_parsed,
5037 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5039 (void *)&cmd_setpromisc_set,
5040 (void *)&cmd_setpromisc_promisc,
5041 (void *)&cmd_setpromisc_portnum,
5042 (void *)&cmd_setpromisc_mode,
5047 /* *** SET ALLMULTI MODE *** */
5048 struct cmd_set_allmulti_mode_result {
5049 cmdline_fixed_string_t set;
5050 cmdline_fixed_string_t allmulti;
5051 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5052 uint8_t port_num; /* valid if "allports" argument == 0 */
5053 cmdline_fixed_string_t mode;
5056 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5057 __attribute__((unused)) struct cmdline *cl,
5060 struct cmd_set_allmulti_mode_result *res = parsed_result;
5064 if (!strcmp(res->mode, "on"))
5071 FOREACH_PORT(i, ports) {
5073 rte_eth_allmulticast_enable(i);
5075 rte_eth_allmulticast_disable(i);
5080 rte_eth_allmulticast_enable(res->port_num);
5082 rte_eth_allmulticast_disable(res->port_num);
5086 cmdline_parse_token_string_t cmd_setallmulti_set =
5087 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5088 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5089 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5091 cmdline_parse_token_string_t cmd_setallmulti_portall =
5092 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5094 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5095 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5097 cmdline_parse_token_string_t cmd_setallmulti_mode =
5098 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5101 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5102 .f = cmd_set_allmulti_mode_parsed,
5104 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5106 (void *)&cmd_setallmulti_set,
5107 (void *)&cmd_setallmulti_allmulti,
5108 (void *)&cmd_setallmulti_portall,
5109 (void *)&cmd_setallmulti_mode,
5114 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5115 .f = cmd_set_allmulti_mode_parsed,
5117 .help_str = "set allmulti <port_id> on|off: "
5118 "Set allmulti mode on port_id",
5120 (void *)&cmd_setallmulti_set,
5121 (void *)&cmd_setallmulti_allmulti,
5122 (void *)&cmd_setallmulti_portnum,
5123 (void *)&cmd_setallmulti_mode,
5128 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5129 struct cmd_link_flow_ctrl_set_result {
5130 cmdline_fixed_string_t set;
5131 cmdline_fixed_string_t flow_ctrl;
5132 cmdline_fixed_string_t rx;
5133 cmdline_fixed_string_t rx_lfc_mode;
5134 cmdline_fixed_string_t tx;
5135 cmdline_fixed_string_t tx_lfc_mode;
5136 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5137 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5138 cmdline_fixed_string_t autoneg_str;
5139 cmdline_fixed_string_t autoneg;
5140 cmdline_fixed_string_t hw_str;
5141 uint32_t high_water;
5142 cmdline_fixed_string_t lw_str;
5144 cmdline_fixed_string_t pt_str;
5145 uint16_t pause_time;
5146 cmdline_fixed_string_t xon_str;
5151 cmdline_parse_token_string_t cmd_lfc_set_set =
5152 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5154 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5155 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5156 flow_ctrl, "flow_ctrl");
5157 cmdline_parse_token_string_t cmd_lfc_set_rx =
5158 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5160 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5162 rx_lfc_mode, "on#off");
5163 cmdline_parse_token_string_t cmd_lfc_set_tx =
5164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5166 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5168 tx_lfc_mode, "on#off");
5169 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5171 hw_str, "high_water");
5172 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5173 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5174 high_water, UINT32);
5175 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5177 lw_str, "low_water");
5178 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5179 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5181 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5182 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5183 pt_str, "pause_time");
5184 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5185 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5186 pause_time, UINT16);
5187 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5188 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5189 xon_str, "send_xon");
5190 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5191 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5193 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5194 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5195 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5196 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5197 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5198 mac_ctrl_frame_fwd_mode, "on#off");
5199 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5200 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5201 autoneg_str, "autoneg");
5202 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5203 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5205 cmdline_parse_token_num_t cmd_lfc_set_portid =
5206 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5209 /* forward declaration */
5211 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5214 cmdline_parse_inst_t cmd_link_flow_control_set = {
5215 .f = cmd_link_flow_ctrl_set_parsed,
5217 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5218 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5219 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5221 (void *)&cmd_lfc_set_set,
5222 (void *)&cmd_lfc_set_flow_ctrl,
5223 (void *)&cmd_lfc_set_rx,
5224 (void *)&cmd_lfc_set_rx_mode,
5225 (void *)&cmd_lfc_set_tx,
5226 (void *)&cmd_lfc_set_tx_mode,
5227 (void *)&cmd_lfc_set_high_water,
5228 (void *)&cmd_lfc_set_low_water,
5229 (void *)&cmd_lfc_set_pause_time,
5230 (void *)&cmd_lfc_set_send_xon,
5231 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5232 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5233 (void *)&cmd_lfc_set_autoneg_str,
5234 (void *)&cmd_lfc_set_autoneg,
5235 (void *)&cmd_lfc_set_portid,
5240 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5241 .f = cmd_link_flow_ctrl_set_parsed,
5242 .data = (void *)&cmd_link_flow_control_set_rx,
5243 .help_str = "set flow_ctrl rx on|off <port_id>: "
5244 "Change rx flow control parameter",
5246 (void *)&cmd_lfc_set_set,
5247 (void *)&cmd_lfc_set_flow_ctrl,
5248 (void *)&cmd_lfc_set_rx,
5249 (void *)&cmd_lfc_set_rx_mode,
5250 (void *)&cmd_lfc_set_portid,
5255 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5256 .f = cmd_link_flow_ctrl_set_parsed,
5257 .data = (void *)&cmd_link_flow_control_set_tx,
5258 .help_str = "set flow_ctrl tx on|off <port_id>: "
5259 "Change tx flow control parameter",
5261 (void *)&cmd_lfc_set_set,
5262 (void *)&cmd_lfc_set_flow_ctrl,
5263 (void *)&cmd_lfc_set_tx,
5264 (void *)&cmd_lfc_set_tx_mode,
5265 (void *)&cmd_lfc_set_portid,
5270 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5271 .f = cmd_link_flow_ctrl_set_parsed,
5272 .data = (void *)&cmd_link_flow_control_set_hw,
5273 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5274 "Change high water flow control parameter",
5276 (void *)&cmd_lfc_set_set,
5277 (void *)&cmd_lfc_set_flow_ctrl,
5278 (void *)&cmd_lfc_set_high_water_str,
5279 (void *)&cmd_lfc_set_high_water,
5280 (void *)&cmd_lfc_set_portid,
5285 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5286 .f = cmd_link_flow_ctrl_set_parsed,
5287 .data = (void *)&cmd_link_flow_control_set_lw,
5288 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5289 "Change low water flow control parameter",
5291 (void *)&cmd_lfc_set_set,
5292 (void *)&cmd_lfc_set_flow_ctrl,
5293 (void *)&cmd_lfc_set_low_water_str,
5294 (void *)&cmd_lfc_set_low_water,
5295 (void *)&cmd_lfc_set_portid,
5300 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5301 .f = cmd_link_flow_ctrl_set_parsed,
5302 .data = (void *)&cmd_link_flow_control_set_pt,
5303 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5304 "Change pause time flow control parameter",
5306 (void *)&cmd_lfc_set_set,
5307 (void *)&cmd_lfc_set_flow_ctrl,
5308 (void *)&cmd_lfc_set_pause_time_str,
5309 (void *)&cmd_lfc_set_pause_time,
5310 (void *)&cmd_lfc_set_portid,
5315 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5316 .f = cmd_link_flow_ctrl_set_parsed,
5317 .data = (void *)&cmd_link_flow_control_set_xon,
5318 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5319 "Change send_xon flow control parameter",
5321 (void *)&cmd_lfc_set_set,
5322 (void *)&cmd_lfc_set_flow_ctrl,
5323 (void *)&cmd_lfc_set_send_xon_str,
5324 (void *)&cmd_lfc_set_send_xon,
5325 (void *)&cmd_lfc_set_portid,
5330 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5331 .f = cmd_link_flow_ctrl_set_parsed,
5332 .data = (void *)&cmd_link_flow_control_set_macfwd,
5333 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5334 "Change mac ctrl fwd flow control parameter",
5336 (void *)&cmd_lfc_set_set,
5337 (void *)&cmd_lfc_set_flow_ctrl,
5338 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5339 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5340 (void *)&cmd_lfc_set_portid,
5345 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5346 .f = cmd_link_flow_ctrl_set_parsed,
5347 .data = (void *)&cmd_link_flow_control_set_autoneg,
5348 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5349 "Change autoneg flow control parameter",
5351 (void *)&cmd_lfc_set_set,
5352 (void *)&cmd_lfc_set_flow_ctrl,
5353 (void *)&cmd_lfc_set_autoneg_str,
5354 (void *)&cmd_lfc_set_autoneg,
5355 (void *)&cmd_lfc_set_portid,
5361 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5362 __attribute__((unused)) struct cmdline *cl,
5365 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5366 cmdline_parse_inst_t *cmd = data;
5367 struct rte_eth_fc_conf fc_conf;
5373 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5374 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5375 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5376 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5378 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5379 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5382 /* Partial command line, retrieve current configuration */
5384 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5386 printf("cannot get current flow ctrl parameters, return"
5387 "code = %d\n", ret);
5391 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5392 (fc_conf.mode == RTE_FC_FULL))
5394 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5395 (fc_conf.mode == RTE_FC_FULL))
5399 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5400 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5402 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5403 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5405 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5407 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5408 fc_conf.high_water = res->high_water;
5410 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5411 fc_conf.low_water = res->low_water;
5413 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5414 fc_conf.pause_time = res->pause_time;
5416 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5417 fc_conf.send_xon = res->send_xon;
5419 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5420 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5421 fc_conf.mac_ctrl_frame_fwd = 1;
5423 fc_conf.mac_ctrl_frame_fwd = 0;
5426 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5427 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5429 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5431 printf("bad flow contrl parameter, return code = %d \n", ret);
5434 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5435 struct cmd_priority_flow_ctrl_set_result {
5436 cmdline_fixed_string_t set;
5437 cmdline_fixed_string_t pfc_ctrl;
5438 cmdline_fixed_string_t rx;
5439 cmdline_fixed_string_t rx_pfc_mode;
5440 cmdline_fixed_string_t tx;
5441 cmdline_fixed_string_t tx_pfc_mode;
5442 uint32_t high_water;
5444 uint16_t pause_time;
5450 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5451 __attribute__((unused)) struct cmdline *cl,
5452 __attribute__((unused)) void *data)
5454 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5455 struct rte_eth_pfc_conf pfc_conf;
5456 int rx_fc_enable, tx_fc_enable;
5460 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5461 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5462 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5463 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5465 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5466 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5469 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5470 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5471 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5472 pfc_conf.fc.high_water = res->high_water;
5473 pfc_conf.fc.low_water = res->low_water;
5474 pfc_conf.fc.pause_time = res->pause_time;
5475 pfc_conf.priority = res->priority;
5477 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5479 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5482 cmdline_parse_token_string_t cmd_pfc_set_set =
5483 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5485 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5486 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5487 pfc_ctrl, "pfc_ctrl");
5488 cmdline_parse_token_string_t cmd_pfc_set_rx =
5489 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5491 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5492 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5493 rx_pfc_mode, "on#off");
5494 cmdline_parse_token_string_t cmd_pfc_set_tx =
5495 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5497 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5498 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5499 tx_pfc_mode, "on#off");
5500 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5501 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5502 high_water, UINT32);
5503 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5504 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5506 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5507 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5508 pause_time, UINT16);
5509 cmdline_parse_token_num_t cmd_pfc_set_priority =
5510 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5512 cmdline_parse_token_num_t cmd_pfc_set_portid =
5513 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5516 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5517 .f = cmd_priority_flow_ctrl_set_parsed,
5519 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5520 "<pause_time> <priority> <port_id>: "
5521 "Configure the Ethernet priority flow control",
5523 (void *)&cmd_pfc_set_set,
5524 (void *)&cmd_pfc_set_flow_ctrl,
5525 (void *)&cmd_pfc_set_rx,
5526 (void *)&cmd_pfc_set_rx_mode,
5527 (void *)&cmd_pfc_set_tx,
5528 (void *)&cmd_pfc_set_tx_mode,
5529 (void *)&cmd_pfc_set_high_water,
5530 (void *)&cmd_pfc_set_low_water,
5531 (void *)&cmd_pfc_set_pause_time,
5532 (void *)&cmd_pfc_set_priority,
5533 (void *)&cmd_pfc_set_portid,
5538 /* *** RESET CONFIGURATION *** */
5539 struct cmd_reset_result {
5540 cmdline_fixed_string_t reset;
5541 cmdline_fixed_string_t def;
5544 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5546 __attribute__((unused)) void *data)
5548 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5549 set_def_fwd_config();
5552 cmdline_parse_token_string_t cmd_reset_set =
5553 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5554 cmdline_parse_token_string_t cmd_reset_def =
5555 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5558 cmdline_parse_inst_t cmd_reset = {
5559 .f = cmd_reset_parsed,
5561 .help_str = "set default: Reset default forwarding configuration",
5563 (void *)&cmd_reset_set,
5564 (void *)&cmd_reset_def,
5569 /* *** START FORWARDING *** */
5570 struct cmd_start_result {
5571 cmdline_fixed_string_t start;
5574 cmdline_parse_token_string_t cmd_start_start =
5575 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5577 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5578 __attribute__((unused)) struct cmdline *cl,
5579 __attribute__((unused)) void *data)
5581 start_packet_forwarding(0);
5584 cmdline_parse_inst_t cmd_start = {
5585 .f = cmd_start_parsed,
5587 .help_str = "start: Start packet forwarding",
5589 (void *)&cmd_start_start,
5594 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5595 struct cmd_start_tx_first_result {
5596 cmdline_fixed_string_t start;
5597 cmdline_fixed_string_t tx_first;
5601 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5602 __attribute__((unused)) struct cmdline *cl,
5603 __attribute__((unused)) void *data)
5605 start_packet_forwarding(1);
5608 cmdline_parse_token_string_t cmd_start_tx_first_start =
5609 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5611 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5612 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5613 tx_first, "tx_first");
5615 cmdline_parse_inst_t cmd_start_tx_first = {
5616 .f = cmd_start_tx_first_parsed,
5618 .help_str = "start tx_first: Start packet forwarding, "
5619 "after sending 1 burst of packets",
5621 (void *)&cmd_start_tx_first_start,
5622 (void *)&cmd_start_tx_first_tx_first,
5627 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5628 struct cmd_start_tx_first_n_result {
5629 cmdline_fixed_string_t start;
5630 cmdline_fixed_string_t tx_first;
5635 cmd_start_tx_first_n_parsed(void *parsed_result,
5636 __attribute__((unused)) struct cmdline *cl,
5637 __attribute__((unused)) void *data)
5639 struct cmd_start_tx_first_n_result *res = parsed_result;
5641 start_packet_forwarding(res->tx_num);
5644 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5645 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5647 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5648 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5649 tx_first, "tx_first");
5650 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5651 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5654 cmdline_parse_inst_t cmd_start_tx_first_n = {
5655 .f = cmd_start_tx_first_n_parsed,
5657 .help_str = "start tx_first <num>: "
5658 "packet forwarding, after sending <num> bursts of packets",
5660 (void *)&cmd_start_tx_first_n_start,
5661 (void *)&cmd_start_tx_first_n_tx_first,
5662 (void *)&cmd_start_tx_first_n_tx_num,
5667 /* *** SET LINK UP *** */
5668 struct cmd_set_link_up_result {
5669 cmdline_fixed_string_t set;
5670 cmdline_fixed_string_t link_up;
5671 cmdline_fixed_string_t port;
5675 cmdline_parse_token_string_t cmd_set_link_up_set =
5676 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5677 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5680 cmdline_parse_token_string_t cmd_set_link_up_port =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5682 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5683 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5685 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5686 __attribute__((unused)) struct cmdline *cl,
5687 __attribute__((unused)) void *data)
5689 struct cmd_set_link_up_result *res = parsed_result;
5690 dev_set_link_up(res->port_id);
5693 cmdline_parse_inst_t cmd_set_link_up = {
5694 .f = cmd_set_link_up_parsed,
5696 .help_str = "set link-up port <port id>",
5698 (void *)&cmd_set_link_up_set,
5699 (void *)&cmd_set_link_up_link_up,
5700 (void *)&cmd_set_link_up_port,
5701 (void *)&cmd_set_link_up_port_id,
5706 /* *** SET LINK DOWN *** */
5707 struct cmd_set_link_down_result {
5708 cmdline_fixed_string_t set;
5709 cmdline_fixed_string_t link_down;
5710 cmdline_fixed_string_t port;
5714 cmdline_parse_token_string_t cmd_set_link_down_set =
5715 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5716 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5717 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5719 cmdline_parse_token_string_t cmd_set_link_down_port =
5720 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5721 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5722 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5724 static void cmd_set_link_down_parsed(
5725 __attribute__((unused)) void *parsed_result,
5726 __attribute__((unused)) struct cmdline *cl,
5727 __attribute__((unused)) void *data)
5729 struct cmd_set_link_down_result *res = parsed_result;
5730 dev_set_link_down(res->port_id);
5733 cmdline_parse_inst_t cmd_set_link_down = {
5734 .f = cmd_set_link_down_parsed,
5736 .help_str = "set link-down port <port id>",
5738 (void *)&cmd_set_link_down_set,
5739 (void *)&cmd_set_link_down_link_down,
5740 (void *)&cmd_set_link_down_port,
5741 (void *)&cmd_set_link_down_port_id,
5746 /* *** SHOW CFG *** */
5747 struct cmd_showcfg_result {
5748 cmdline_fixed_string_t show;
5749 cmdline_fixed_string_t cfg;
5750 cmdline_fixed_string_t what;
5753 static void cmd_showcfg_parsed(void *parsed_result,
5754 __attribute__((unused)) struct cmdline *cl,
5755 __attribute__((unused)) void *data)
5757 struct cmd_showcfg_result *res = parsed_result;
5758 if (!strcmp(res->what, "rxtx"))
5759 rxtx_config_display();
5760 else if (!strcmp(res->what, "cores"))
5761 fwd_lcores_config_display();
5762 else if (!strcmp(res->what, "fwd"))
5763 pkt_fwd_config_display(&cur_fwd_config);
5764 else if (!strcmp(res->what, "txpkts"))
5765 show_tx_pkt_segments();
5768 cmdline_parse_token_string_t cmd_showcfg_show =
5769 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5770 cmdline_parse_token_string_t cmd_showcfg_port =
5771 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5772 cmdline_parse_token_string_t cmd_showcfg_what =
5773 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5774 "rxtx#cores#fwd#txpkts");
5776 cmdline_parse_inst_t cmd_showcfg = {
5777 .f = cmd_showcfg_parsed,
5779 .help_str = "show config rxtx|cores|fwd|txpkts",
5781 (void *)&cmd_showcfg_show,
5782 (void *)&cmd_showcfg_port,
5783 (void *)&cmd_showcfg_what,
5788 /* *** SHOW ALL PORT INFO *** */
5789 struct cmd_showportall_result {
5790 cmdline_fixed_string_t show;
5791 cmdline_fixed_string_t port;
5792 cmdline_fixed_string_t what;
5793 cmdline_fixed_string_t all;
5796 static void cmd_showportall_parsed(void *parsed_result,
5797 __attribute__((unused)) struct cmdline *cl,
5798 __attribute__((unused)) void *data)
5802 struct cmd_showportall_result *res = parsed_result;
5803 if (!strcmp(res->show, "clear")) {
5804 if (!strcmp(res->what, "stats"))
5805 FOREACH_PORT(i, ports)
5807 else if (!strcmp(res->what, "xstats"))
5808 FOREACH_PORT(i, ports)
5809 nic_xstats_clear(i);
5810 } else if (!strcmp(res->what, "info"))
5811 FOREACH_PORT(i, ports)
5812 port_infos_display(i);
5813 else if (!strcmp(res->what, "stats"))
5814 FOREACH_PORT(i, ports)
5815 nic_stats_display(i);
5816 else if (!strcmp(res->what, "xstats"))
5817 FOREACH_PORT(i, ports)
5818 nic_xstats_display(i);
5819 else if (!strcmp(res->what, "fdir"))
5820 FOREACH_PORT(i, ports)
5822 else if (!strcmp(res->what, "stat_qmap"))
5823 FOREACH_PORT(i, ports)
5824 nic_stats_mapping_display(i);
5825 else if (!strcmp(res->what, "dcb_tc"))
5826 FOREACH_PORT(i, ports)
5827 port_dcb_info_display(i);
5830 cmdline_parse_token_string_t cmd_showportall_show =
5831 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5833 cmdline_parse_token_string_t cmd_showportall_port =
5834 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5835 cmdline_parse_token_string_t cmd_showportall_what =
5836 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5837 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5838 cmdline_parse_token_string_t cmd_showportall_all =
5839 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5840 cmdline_parse_inst_t cmd_showportall = {
5841 .f = cmd_showportall_parsed,
5843 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5845 (void *)&cmd_showportall_show,
5846 (void *)&cmd_showportall_port,
5847 (void *)&cmd_showportall_what,
5848 (void *)&cmd_showportall_all,
5853 /* *** SHOW PORT INFO *** */
5854 struct cmd_showport_result {
5855 cmdline_fixed_string_t show;
5856 cmdline_fixed_string_t port;
5857 cmdline_fixed_string_t what;
5861 static void cmd_showport_parsed(void *parsed_result,
5862 __attribute__((unused)) struct cmdline *cl,
5863 __attribute__((unused)) void *data)
5865 struct cmd_showport_result *res = parsed_result;
5866 if (!strcmp(res->show, "clear")) {
5867 if (!strcmp(res->what, "stats"))
5868 nic_stats_clear(res->portnum);
5869 else if (!strcmp(res->what, "xstats"))
5870 nic_xstats_clear(res->portnum);
5871 } else if (!strcmp(res->what, "info"))
5872 port_infos_display(res->portnum);
5873 else if (!strcmp(res->what, "stats"))
5874 nic_stats_display(res->portnum);
5875 else if (!strcmp(res->what, "xstats"))
5876 nic_xstats_display(res->portnum);
5877 else if (!strcmp(res->what, "fdir"))
5878 fdir_get_infos(res->portnum);
5879 else if (!strcmp(res->what, "stat_qmap"))
5880 nic_stats_mapping_display(res->portnum);
5881 else if (!strcmp(res->what, "dcb_tc"))
5882 port_dcb_info_display(res->portnum);
5885 cmdline_parse_token_string_t cmd_showport_show =
5886 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5888 cmdline_parse_token_string_t cmd_showport_port =
5889 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5890 cmdline_parse_token_string_t cmd_showport_what =
5891 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5892 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5893 cmdline_parse_token_num_t cmd_showport_portnum =
5894 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5896 cmdline_parse_inst_t cmd_showport = {
5897 .f = cmd_showport_parsed,
5899 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5902 (void *)&cmd_showport_show,
5903 (void *)&cmd_showport_port,
5904 (void *)&cmd_showport_what,
5905 (void *)&cmd_showport_portnum,
5910 /* *** SHOW QUEUE INFO *** */
5911 struct cmd_showqueue_result {
5912 cmdline_fixed_string_t show;
5913 cmdline_fixed_string_t type;
5914 cmdline_fixed_string_t what;
5920 cmd_showqueue_parsed(void *parsed_result,
5921 __attribute__((unused)) struct cmdline *cl,
5922 __attribute__((unused)) void *data)
5924 struct cmd_showqueue_result *res = parsed_result;
5926 if (!strcmp(res->type, "rxq"))
5927 rx_queue_infos_display(res->portnum, res->queuenum);
5928 else if (!strcmp(res->type, "txq"))
5929 tx_queue_infos_display(res->portnum, res->queuenum);
5932 cmdline_parse_token_string_t cmd_showqueue_show =
5933 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5934 cmdline_parse_token_string_t cmd_showqueue_type =
5935 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5936 cmdline_parse_token_string_t cmd_showqueue_what =
5937 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5938 cmdline_parse_token_num_t cmd_showqueue_portnum =
5939 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5940 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5941 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5943 cmdline_parse_inst_t cmd_showqueue = {
5944 .f = cmd_showqueue_parsed,
5946 .help_str = "show rxq|txq info <port_id> <queue_id>",
5948 (void *)&cmd_showqueue_show,
5949 (void *)&cmd_showqueue_type,
5950 (void *)&cmd_showqueue_what,
5951 (void *)&cmd_showqueue_portnum,
5952 (void *)&cmd_showqueue_queuenum,
5957 /* *** READ PORT REGISTER *** */
5958 struct cmd_read_reg_result {
5959 cmdline_fixed_string_t read;
5960 cmdline_fixed_string_t reg;
5966 cmd_read_reg_parsed(void *parsed_result,
5967 __attribute__((unused)) struct cmdline *cl,
5968 __attribute__((unused)) void *data)
5970 struct cmd_read_reg_result *res = parsed_result;
5971 port_reg_display(res->port_id, res->reg_off);
5974 cmdline_parse_token_string_t cmd_read_reg_read =
5975 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5976 cmdline_parse_token_string_t cmd_read_reg_reg =
5977 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5978 cmdline_parse_token_num_t cmd_read_reg_port_id =
5979 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5980 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5981 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5983 cmdline_parse_inst_t cmd_read_reg = {
5984 .f = cmd_read_reg_parsed,
5986 .help_str = "read reg <port_id> <reg_off>",
5988 (void *)&cmd_read_reg_read,
5989 (void *)&cmd_read_reg_reg,
5990 (void *)&cmd_read_reg_port_id,
5991 (void *)&cmd_read_reg_reg_off,
5996 /* *** READ PORT REGISTER BIT FIELD *** */
5997 struct cmd_read_reg_bit_field_result {
5998 cmdline_fixed_string_t read;
5999 cmdline_fixed_string_t regfield;
6007 cmd_read_reg_bit_field_parsed(void *parsed_result,
6008 __attribute__((unused)) struct cmdline *cl,
6009 __attribute__((unused)) void *data)
6011 struct cmd_read_reg_bit_field_result *res = parsed_result;
6012 port_reg_bit_field_display(res->port_id, res->reg_off,
6013 res->bit1_pos, res->bit2_pos);
6016 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6017 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6019 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6020 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6021 regfield, "regfield");
6022 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6023 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6025 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6026 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6028 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6029 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6031 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6032 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6035 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6036 .f = cmd_read_reg_bit_field_parsed,
6038 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6039 "Read register bit field between bit_x and bit_y included",
6041 (void *)&cmd_read_reg_bit_field_read,
6042 (void *)&cmd_read_reg_bit_field_regfield,
6043 (void *)&cmd_read_reg_bit_field_port_id,
6044 (void *)&cmd_read_reg_bit_field_reg_off,
6045 (void *)&cmd_read_reg_bit_field_bit1_pos,
6046 (void *)&cmd_read_reg_bit_field_bit2_pos,
6051 /* *** READ PORT REGISTER BIT *** */
6052 struct cmd_read_reg_bit_result {
6053 cmdline_fixed_string_t read;
6054 cmdline_fixed_string_t regbit;
6061 cmd_read_reg_bit_parsed(void *parsed_result,
6062 __attribute__((unused)) struct cmdline *cl,
6063 __attribute__((unused)) void *data)
6065 struct cmd_read_reg_bit_result *res = parsed_result;
6066 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6069 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6070 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6071 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6072 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6074 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6075 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6076 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6077 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6078 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6079 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6081 cmdline_parse_inst_t cmd_read_reg_bit = {
6082 .f = cmd_read_reg_bit_parsed,
6084 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6086 (void *)&cmd_read_reg_bit_read,
6087 (void *)&cmd_read_reg_bit_regbit,
6088 (void *)&cmd_read_reg_bit_port_id,
6089 (void *)&cmd_read_reg_bit_reg_off,
6090 (void *)&cmd_read_reg_bit_bit_pos,
6095 /* *** WRITE PORT REGISTER *** */
6096 struct cmd_write_reg_result {
6097 cmdline_fixed_string_t write;
6098 cmdline_fixed_string_t reg;
6105 cmd_write_reg_parsed(void *parsed_result,
6106 __attribute__((unused)) struct cmdline *cl,
6107 __attribute__((unused)) void *data)
6109 struct cmd_write_reg_result *res = parsed_result;
6110 port_reg_set(res->port_id, res->reg_off, res->value);
6113 cmdline_parse_token_string_t cmd_write_reg_write =
6114 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6115 cmdline_parse_token_string_t cmd_write_reg_reg =
6116 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6117 cmdline_parse_token_num_t cmd_write_reg_port_id =
6118 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6119 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6120 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6121 cmdline_parse_token_num_t cmd_write_reg_value =
6122 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6124 cmdline_parse_inst_t cmd_write_reg = {
6125 .f = cmd_write_reg_parsed,
6127 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6129 (void *)&cmd_write_reg_write,
6130 (void *)&cmd_write_reg_reg,
6131 (void *)&cmd_write_reg_port_id,
6132 (void *)&cmd_write_reg_reg_off,
6133 (void *)&cmd_write_reg_value,
6138 /* *** WRITE PORT REGISTER BIT FIELD *** */
6139 struct cmd_write_reg_bit_field_result {
6140 cmdline_fixed_string_t write;
6141 cmdline_fixed_string_t regfield;
6150 cmd_write_reg_bit_field_parsed(void *parsed_result,
6151 __attribute__((unused)) struct cmdline *cl,
6152 __attribute__((unused)) void *data)
6154 struct cmd_write_reg_bit_field_result *res = parsed_result;
6155 port_reg_bit_field_set(res->port_id, res->reg_off,
6156 res->bit1_pos, res->bit2_pos, res->value);
6159 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6160 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6162 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6163 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6164 regfield, "regfield");
6165 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6166 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6168 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6169 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6171 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6172 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6174 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6175 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6177 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6178 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6181 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6182 .f = cmd_write_reg_bit_field_parsed,
6184 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6186 "Set register bit field between bit_x and bit_y included",
6188 (void *)&cmd_write_reg_bit_field_write,
6189 (void *)&cmd_write_reg_bit_field_regfield,
6190 (void *)&cmd_write_reg_bit_field_port_id,
6191 (void *)&cmd_write_reg_bit_field_reg_off,
6192 (void *)&cmd_write_reg_bit_field_bit1_pos,
6193 (void *)&cmd_write_reg_bit_field_bit2_pos,
6194 (void *)&cmd_write_reg_bit_field_value,
6199 /* *** WRITE PORT REGISTER BIT *** */
6200 struct cmd_write_reg_bit_result {
6201 cmdline_fixed_string_t write;
6202 cmdline_fixed_string_t regbit;
6210 cmd_write_reg_bit_parsed(void *parsed_result,
6211 __attribute__((unused)) struct cmdline *cl,
6212 __attribute__((unused)) void *data)
6214 struct cmd_write_reg_bit_result *res = parsed_result;
6215 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6218 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6219 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6221 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6222 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6224 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6225 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6226 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6227 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6228 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6229 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6230 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6231 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6233 cmdline_parse_inst_t cmd_write_reg_bit = {
6234 .f = cmd_write_reg_bit_parsed,
6236 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6239 (void *)&cmd_write_reg_bit_write,
6240 (void *)&cmd_write_reg_bit_regbit,
6241 (void *)&cmd_write_reg_bit_port_id,
6242 (void *)&cmd_write_reg_bit_reg_off,
6243 (void *)&cmd_write_reg_bit_bit_pos,
6244 (void *)&cmd_write_reg_bit_value,
6249 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6250 struct cmd_read_rxd_txd_result {
6251 cmdline_fixed_string_t read;
6252 cmdline_fixed_string_t rxd_txd;
6259 cmd_read_rxd_txd_parsed(void *parsed_result,
6260 __attribute__((unused)) struct cmdline *cl,
6261 __attribute__((unused)) void *data)
6263 struct cmd_read_rxd_txd_result *res = parsed_result;
6265 if (!strcmp(res->rxd_txd, "rxd"))
6266 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6267 else if (!strcmp(res->rxd_txd, "txd"))
6268 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6271 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6272 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6273 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6274 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6276 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6277 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6278 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6279 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6280 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6281 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6283 cmdline_parse_inst_t cmd_read_rxd_txd = {
6284 .f = cmd_read_rxd_txd_parsed,
6286 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6288 (void *)&cmd_read_rxd_txd_read,
6289 (void *)&cmd_read_rxd_txd_rxd_txd,
6290 (void *)&cmd_read_rxd_txd_port_id,
6291 (void *)&cmd_read_rxd_txd_queue_id,
6292 (void *)&cmd_read_rxd_txd_desc_id,
6298 struct cmd_quit_result {
6299 cmdline_fixed_string_t quit;
6302 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6304 __attribute__((unused)) void *data)
6310 cmdline_parse_token_string_t cmd_quit_quit =
6311 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6313 cmdline_parse_inst_t cmd_quit = {
6314 .f = cmd_quit_parsed,
6316 .help_str = "quit: Exit application",
6318 (void *)&cmd_quit_quit,
6323 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6324 struct cmd_mac_addr_result {
6325 cmdline_fixed_string_t mac_addr_cmd;
6326 cmdline_fixed_string_t what;
6328 struct ether_addr address;
6331 static void cmd_mac_addr_parsed(void *parsed_result,
6332 __attribute__((unused)) struct cmdline *cl,
6333 __attribute__((unused)) void *data)
6335 struct cmd_mac_addr_result *res = parsed_result;
6338 if (strcmp(res->what, "add") == 0)
6339 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6341 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6343 /* check the return value and print it if is < 0 */
6345 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6349 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6350 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6352 cmdline_parse_token_string_t cmd_mac_addr_what =
6353 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6355 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6356 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6357 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6358 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6360 cmdline_parse_inst_t cmd_mac_addr = {
6361 .f = cmd_mac_addr_parsed,
6363 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6364 "Add/Remove MAC address on port_id",
6366 (void *)&cmd_mac_addr_cmd,
6367 (void *)&cmd_mac_addr_what,
6368 (void *)&cmd_mac_addr_portnum,
6369 (void *)&cmd_mac_addr_addr,
6375 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6376 struct cmd_set_qmap_result {
6377 cmdline_fixed_string_t set;
6378 cmdline_fixed_string_t qmap;
6379 cmdline_fixed_string_t what;
6386 cmd_set_qmap_parsed(void *parsed_result,
6387 __attribute__((unused)) struct cmdline *cl,
6388 __attribute__((unused)) void *data)
6390 struct cmd_set_qmap_result *res = parsed_result;
6391 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6393 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6396 cmdline_parse_token_string_t cmd_setqmap_set =
6397 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6399 cmdline_parse_token_string_t cmd_setqmap_qmap =
6400 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6402 cmdline_parse_token_string_t cmd_setqmap_what =
6403 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6405 cmdline_parse_token_num_t cmd_setqmap_portid =
6406 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6408 cmdline_parse_token_num_t cmd_setqmap_queueid =
6409 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6411 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6412 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6415 cmdline_parse_inst_t cmd_set_qmap = {
6416 .f = cmd_set_qmap_parsed,
6418 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6419 "Set statistics mapping value on tx|rx queue_id of port_id",
6421 (void *)&cmd_setqmap_set,
6422 (void *)&cmd_setqmap_qmap,
6423 (void *)&cmd_setqmap_what,
6424 (void *)&cmd_setqmap_portid,
6425 (void *)&cmd_setqmap_queueid,
6426 (void *)&cmd_setqmap_mapvalue,
6431 /* *** CONFIGURE UNICAST HASH TABLE *** */
6432 struct cmd_set_uc_hash_table {
6433 cmdline_fixed_string_t set;
6434 cmdline_fixed_string_t port;
6436 cmdline_fixed_string_t what;
6437 struct ether_addr address;
6438 cmdline_fixed_string_t mode;
6442 cmd_set_uc_hash_parsed(void *parsed_result,
6443 __attribute__((unused)) struct cmdline *cl,
6444 __attribute__((unused)) void *data)
6447 struct cmd_set_uc_hash_table *res = parsed_result;
6449 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6451 if (strcmp(res->what, "uta") == 0)
6452 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6453 &res->address,(uint8_t)is_on);
6455 printf("bad unicast hash table parameter, return code = %d \n", ret);
6459 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6462 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6463 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6465 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6466 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6468 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6469 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6471 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6472 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6474 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6478 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6479 .f = cmd_set_uc_hash_parsed,
6481 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6483 (void *)&cmd_set_uc_hash_set,
6484 (void *)&cmd_set_uc_hash_port,
6485 (void *)&cmd_set_uc_hash_portid,
6486 (void *)&cmd_set_uc_hash_what,
6487 (void *)&cmd_set_uc_hash_mac,
6488 (void *)&cmd_set_uc_hash_mode,
6493 struct cmd_set_uc_all_hash_table {
6494 cmdline_fixed_string_t set;
6495 cmdline_fixed_string_t port;
6497 cmdline_fixed_string_t what;
6498 cmdline_fixed_string_t value;
6499 cmdline_fixed_string_t mode;
6503 cmd_set_uc_all_hash_parsed(void *parsed_result,
6504 __attribute__((unused)) struct cmdline *cl,
6505 __attribute__((unused)) void *data)
6508 struct cmd_set_uc_all_hash_table *res = parsed_result;
6510 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6512 if ((strcmp(res->what, "uta") == 0) &&
6513 (strcmp(res->value, "all") == 0))
6514 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6516 printf("bad unicast hash table parameter,"
6517 "return code = %d \n", ret);
6520 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6521 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6523 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6524 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6526 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6527 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6529 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6530 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6532 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6533 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6535 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6536 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6539 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6540 .f = cmd_set_uc_all_hash_parsed,
6542 .help_str = "set port <port_id> uta all on|off",
6544 (void *)&cmd_set_uc_all_hash_set,
6545 (void *)&cmd_set_uc_all_hash_port,
6546 (void *)&cmd_set_uc_all_hash_portid,
6547 (void *)&cmd_set_uc_all_hash_what,
6548 (void *)&cmd_set_uc_all_hash_value,
6549 (void *)&cmd_set_uc_all_hash_mode,
6554 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6555 struct cmd_set_vf_macvlan_filter {
6556 cmdline_fixed_string_t set;
6557 cmdline_fixed_string_t port;
6559 cmdline_fixed_string_t vf;
6561 struct ether_addr address;
6562 cmdline_fixed_string_t filter_type;
6563 cmdline_fixed_string_t mode;
6567 cmd_set_vf_macvlan_parsed(void *parsed_result,
6568 __attribute__((unused)) struct cmdline *cl,
6569 __attribute__((unused)) void *data)
6572 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6573 struct rte_eth_mac_filter filter;
6575 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6577 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6579 /* set VF MAC filter */
6583 filter.dst_id = res->vf_id;
6585 if (!strcmp(res->filter_type, "exact-mac"))
6586 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6587 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6588 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6589 else if (!strcmp(res->filter_type, "hashmac"))
6590 filter.filter_type = RTE_MAC_HASH_MATCH;
6591 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6592 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6594 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6597 ret = rte_eth_dev_filter_ctrl(res->port_id,
6598 RTE_ETH_FILTER_MACVLAN,
6602 ret = rte_eth_dev_filter_ctrl(res->port_id,
6603 RTE_ETH_FILTER_MACVLAN,
6604 RTE_ETH_FILTER_DELETE,
6608 printf("bad set MAC hash parameter, return code = %d\n", ret);
6612 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6613 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6615 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6616 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6618 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6619 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6621 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6624 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6625 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6627 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6628 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6630 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6631 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6632 filter_type, "exact-mac#exact-mac-vlan"
6633 "#hashmac#hashmac-vlan");
6634 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6635 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6638 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6639 .f = cmd_set_vf_macvlan_parsed,
6641 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6642 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6643 "Exact match rule: exact match of MAC or MAC and VLAN; "
6644 "hash match rule: hash match of MAC and exact match of VLAN",
6646 (void *)&cmd_set_vf_macvlan_set,
6647 (void *)&cmd_set_vf_macvlan_port,
6648 (void *)&cmd_set_vf_macvlan_portid,
6649 (void *)&cmd_set_vf_macvlan_vf,
6650 (void *)&cmd_set_vf_macvlan_vf_id,
6651 (void *)&cmd_set_vf_macvlan_mac,
6652 (void *)&cmd_set_vf_macvlan_filter_type,
6653 (void *)&cmd_set_vf_macvlan_mode,
6658 #ifdef RTE_LIBRTE_IXGBE_PMD
6659 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6660 struct cmd_set_vf_traffic {
6661 cmdline_fixed_string_t set;
6662 cmdline_fixed_string_t port;
6664 cmdline_fixed_string_t vf;
6666 cmdline_fixed_string_t what;
6667 cmdline_fixed_string_t mode;
6671 cmd_set_vf_traffic_parsed(void *parsed_result,
6672 __attribute__((unused)) struct cmdline *cl,
6673 __attribute__((unused)) void *data)
6675 struct cmd_set_vf_traffic *res = parsed_result;
6676 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6677 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6679 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6682 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6683 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6685 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6686 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6688 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6689 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6691 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6692 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6694 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6695 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6697 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6698 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6700 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6701 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6704 cmdline_parse_inst_t cmd_set_vf_traffic = {
6705 .f = cmd_set_vf_traffic_parsed,
6707 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6709 (void *)&cmd_setvf_traffic_set,
6710 (void *)&cmd_setvf_traffic_port,
6711 (void *)&cmd_setvf_traffic_portid,
6712 (void *)&cmd_setvf_traffic_vf,
6713 (void *)&cmd_setvf_traffic_vfid,
6714 (void *)&cmd_setvf_traffic_what,
6715 (void *)&cmd_setvf_traffic_mode,
6720 /* *** CONFIGURE VF RECEIVE MODE *** */
6721 struct cmd_set_vf_rxmode {
6722 cmdline_fixed_string_t set;
6723 cmdline_fixed_string_t port;
6725 cmdline_fixed_string_t vf;
6727 cmdline_fixed_string_t what;
6728 cmdline_fixed_string_t mode;
6729 cmdline_fixed_string_t on;
6733 cmd_set_vf_rxmode_parsed(void *parsed_result,
6734 __attribute__((unused)) struct cmdline *cl,
6735 __attribute__((unused)) void *data)
6738 uint16_t rx_mode = 0;
6739 struct cmd_set_vf_rxmode *res = parsed_result;
6741 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6742 if (!strcmp(res->what,"rxmode")) {
6743 if (!strcmp(res->mode, "AUPE"))
6744 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6745 else if (!strcmp(res->mode, "ROPE"))
6746 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6747 else if (!strcmp(res->mode, "BAM"))
6748 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6749 else if (!strncmp(res->mode, "MPE",3))
6750 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6753 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6755 printf("bad VF receive mode parameter, return code = %d \n",
6759 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6760 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6762 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6763 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6765 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6766 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6768 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6769 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6771 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6772 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6774 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6775 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6777 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6778 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6779 mode, "AUPE#ROPE#BAM#MPE");
6780 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6781 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6784 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6785 .f = cmd_set_vf_rxmode_parsed,
6787 .help_str = "set port <port_id> vf <vf_id> rxmode "
6788 "AUPE|ROPE|BAM|MPE on|off",
6790 (void *)&cmd_set_vf_rxmode_set,
6791 (void *)&cmd_set_vf_rxmode_port,
6792 (void *)&cmd_set_vf_rxmode_portid,
6793 (void *)&cmd_set_vf_rxmode_vf,
6794 (void *)&cmd_set_vf_rxmode_vfid,
6795 (void *)&cmd_set_vf_rxmode_what,
6796 (void *)&cmd_set_vf_rxmode_mode,
6797 (void *)&cmd_set_vf_rxmode_on,
6803 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6804 struct cmd_vf_mac_addr_result {
6805 cmdline_fixed_string_t mac_addr_cmd;
6806 cmdline_fixed_string_t what;
6807 cmdline_fixed_string_t port;
6809 cmdline_fixed_string_t vf;
6811 struct ether_addr address;
6814 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6815 __attribute__((unused)) struct cmdline *cl,
6816 __attribute__((unused)) void *data)
6818 struct cmd_vf_mac_addr_result *res = parsed_result;
6821 if (strcmp(res->what, "add") == 0)
6822 ret = rte_eth_dev_mac_addr_add(res->port_num,
6823 &res->address, res->vf_num);
6825 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6829 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6830 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6831 mac_addr_cmd,"mac_addr");
6832 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6833 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6835 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6836 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6838 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6839 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6841 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6842 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6844 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6845 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6847 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6848 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6851 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6852 .f = cmd_vf_mac_addr_parsed,
6854 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6855 "Add MAC address filtering for a VF on port_id",
6857 (void *)&cmd_vf_mac_addr_cmd,
6858 (void *)&cmd_vf_mac_addr_what,
6859 (void *)&cmd_vf_mac_addr_port,
6860 (void *)&cmd_vf_mac_addr_portnum,
6861 (void *)&cmd_vf_mac_addr_vf,
6862 (void *)&cmd_vf_mac_addr_vfnum,
6863 (void *)&cmd_vf_mac_addr_addr,
6868 #ifdef RTE_LIBRTE_IXGBE_PMD
6869 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6870 struct cmd_vf_rx_vlan_filter {
6871 cmdline_fixed_string_t rx_vlan;
6872 cmdline_fixed_string_t what;
6874 cmdline_fixed_string_t port;
6876 cmdline_fixed_string_t vf;
6881 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6882 __attribute__((unused)) struct cmdline *cl,
6883 __attribute__((unused)) void *data)
6885 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6887 if (!strcmp(res->what, "add"))
6888 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6890 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6893 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6894 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6895 rx_vlan, "rx_vlan");
6896 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6897 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6899 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6900 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6902 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6903 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6905 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6906 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6908 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6909 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6911 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6912 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6915 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6916 .f = cmd_vf_rx_vlan_filter_parsed,
6918 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6919 "(vf_mask = hexadecimal VF mask)",
6921 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6922 (void *)&cmd_vf_rx_vlan_filter_what,
6923 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6924 (void *)&cmd_vf_rx_vlan_filter_port,
6925 (void *)&cmd_vf_rx_vlan_filter_portid,
6926 (void *)&cmd_vf_rx_vlan_filter_vf,
6927 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6933 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6934 struct cmd_queue_rate_limit_result {
6935 cmdline_fixed_string_t set;
6936 cmdline_fixed_string_t port;
6938 cmdline_fixed_string_t queue;
6940 cmdline_fixed_string_t rate;
6944 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6945 __attribute__((unused)) struct cmdline *cl,
6946 __attribute__((unused)) void *data)
6948 struct cmd_queue_rate_limit_result *res = parsed_result;
6951 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6952 && (strcmp(res->queue, "queue") == 0)
6953 && (strcmp(res->rate, "rate") == 0))
6954 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6957 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6961 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6962 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6964 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6965 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6967 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6968 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6970 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6971 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6973 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6974 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6976 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6977 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6979 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6980 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6983 cmdline_parse_inst_t cmd_queue_rate_limit = {
6984 .f = cmd_queue_rate_limit_parsed,
6986 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6987 "Set rate limit for a queue on port_id",
6989 (void *)&cmd_queue_rate_limit_set,
6990 (void *)&cmd_queue_rate_limit_port,
6991 (void *)&cmd_queue_rate_limit_portnum,
6992 (void *)&cmd_queue_rate_limit_queue,
6993 (void *)&cmd_queue_rate_limit_queuenum,
6994 (void *)&cmd_queue_rate_limit_rate,
6995 (void *)&cmd_queue_rate_limit_ratenum,
7000 #ifdef RTE_LIBRTE_IXGBE_PMD
7001 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7002 struct cmd_vf_rate_limit_result {
7003 cmdline_fixed_string_t set;
7004 cmdline_fixed_string_t port;
7006 cmdline_fixed_string_t vf;
7008 cmdline_fixed_string_t rate;
7010 cmdline_fixed_string_t q_msk;
7014 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7015 __attribute__((unused)) struct cmdline *cl,
7016 __attribute__((unused)) void *data)
7018 struct cmd_vf_rate_limit_result *res = parsed_result;
7021 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7022 && (strcmp(res->vf, "vf") == 0)
7023 && (strcmp(res->rate, "rate") == 0)
7024 && (strcmp(res->q_msk, "queue_mask") == 0))
7025 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7026 res->rate_num, res->q_msk_val);
7028 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7032 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7033 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7035 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7036 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7038 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7039 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7041 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7042 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7044 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7045 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7047 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7048 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7050 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7051 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7053 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7054 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7055 q_msk, "queue_mask");
7056 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7057 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7060 cmdline_parse_inst_t cmd_vf_rate_limit = {
7061 .f = cmd_vf_rate_limit_parsed,
7063 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7064 "queue_mask <queue_mask_value>: "
7065 "Set rate limit for queues of VF on port_id",
7067 (void *)&cmd_vf_rate_limit_set,
7068 (void *)&cmd_vf_rate_limit_port,
7069 (void *)&cmd_vf_rate_limit_portnum,
7070 (void *)&cmd_vf_rate_limit_vf,
7071 (void *)&cmd_vf_rate_limit_vfnum,
7072 (void *)&cmd_vf_rate_limit_rate,
7073 (void *)&cmd_vf_rate_limit_ratenum,
7074 (void *)&cmd_vf_rate_limit_q_msk,
7075 (void *)&cmd_vf_rate_limit_q_msk_val,
7081 /* *** ADD TUNNEL FILTER OF A PORT *** */
7082 struct cmd_tunnel_filter_result {
7083 cmdline_fixed_string_t cmd;
7084 cmdline_fixed_string_t what;
7086 struct ether_addr outer_mac;
7087 struct ether_addr inner_mac;
7088 cmdline_ipaddr_t ip_value;
7089 uint16_t inner_vlan;
7090 cmdline_fixed_string_t tunnel_type;
7091 cmdline_fixed_string_t filter_type;
7097 cmd_tunnel_filter_parsed(void *parsed_result,
7098 __attribute__((unused)) struct cmdline *cl,
7099 __attribute__((unused)) void *data)
7101 struct cmd_tunnel_filter_result *res = parsed_result;
7102 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7105 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7107 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7108 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7109 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7111 if (res->ip_value.family == AF_INET) {
7112 tunnel_filter_conf.ip_addr.ipv4_addr =
7113 res->ip_value.addr.ipv4.s_addr;
7114 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7116 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7117 &(res->ip_value.addr.ipv6),
7118 sizeof(struct in6_addr));
7119 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7122 if (!strcmp(res->filter_type, "imac-ivlan"))
7123 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7124 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7125 tunnel_filter_conf.filter_type =
7126 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7127 else if (!strcmp(res->filter_type, "imac-tenid"))
7128 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7129 else if (!strcmp(res->filter_type, "imac"))
7130 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7131 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7132 tunnel_filter_conf.filter_type =
7133 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7134 else if (!strcmp(res->filter_type, "oip"))
7135 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7136 else if (!strcmp(res->filter_type, "iip"))
7137 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7139 printf("The filter type is not supported");
7143 if (!strcmp(res->tunnel_type, "vxlan"))
7144 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7145 else if (!strcmp(res->tunnel_type, "nvgre"))
7146 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7147 else if (!strcmp(res->tunnel_type, "ipingre"))
7148 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7150 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7154 tunnel_filter_conf.tenant_id = res->tenant_id;
7155 tunnel_filter_conf.queue_id = res->queue_num;
7156 if (!strcmp(res->what, "add"))
7157 ret = rte_eth_dev_filter_ctrl(res->port_id,
7158 RTE_ETH_FILTER_TUNNEL,
7160 &tunnel_filter_conf);
7162 ret = rte_eth_dev_filter_ctrl(res->port_id,
7163 RTE_ETH_FILTER_TUNNEL,
7164 RTE_ETH_FILTER_DELETE,
7165 &tunnel_filter_conf);
7167 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7171 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7172 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7173 cmd, "tunnel_filter");
7174 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7175 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7177 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7178 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7180 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7181 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7183 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7184 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7186 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7187 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7188 inner_vlan, UINT16);
7189 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7190 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7192 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7193 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7194 tunnel_type, "vxlan#nvgre#ipingre");
7196 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7197 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7198 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7199 "imac#omac-imac-tenid");
7200 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7201 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7203 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7204 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7207 cmdline_parse_inst_t cmd_tunnel_filter = {
7208 .f = cmd_tunnel_filter_parsed,
7210 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7211 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7212 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7213 "<queue_id>: Add/Rm tunnel filter of a port",
7215 (void *)&cmd_tunnel_filter_cmd,
7216 (void *)&cmd_tunnel_filter_what,
7217 (void *)&cmd_tunnel_filter_port_id,
7218 (void *)&cmd_tunnel_filter_outer_mac,
7219 (void *)&cmd_tunnel_filter_inner_mac,
7220 (void *)&cmd_tunnel_filter_ip_value,
7221 (void *)&cmd_tunnel_filter_innner_vlan,
7222 (void *)&cmd_tunnel_filter_tunnel_type,
7223 (void *)&cmd_tunnel_filter_filter_type,
7224 (void *)&cmd_tunnel_filter_tenant_id,
7225 (void *)&cmd_tunnel_filter_queue_num,
7230 /* *** CONFIGURE TUNNEL UDP PORT *** */
7231 struct cmd_tunnel_udp_config {
7232 cmdline_fixed_string_t cmd;
7233 cmdline_fixed_string_t what;
7239 cmd_tunnel_udp_config_parsed(void *parsed_result,
7240 __attribute__((unused)) struct cmdline *cl,
7241 __attribute__((unused)) void *data)
7243 struct cmd_tunnel_udp_config *res = parsed_result;
7244 struct rte_eth_udp_tunnel tunnel_udp;
7247 tunnel_udp.udp_port = res->udp_port;
7249 if (!strcmp(res->cmd, "rx_vxlan_port"))
7250 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7252 if (!strcmp(res->what, "add"))
7253 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7256 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7260 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7263 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7264 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7265 cmd, "rx_vxlan_port");
7266 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7267 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7269 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7270 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7272 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7273 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7276 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7277 .f = cmd_tunnel_udp_config_parsed,
7279 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7280 "Add/Remove a tunneling UDP port filter",
7282 (void *)&cmd_tunnel_udp_config_cmd,
7283 (void *)&cmd_tunnel_udp_config_what,
7284 (void *)&cmd_tunnel_udp_config_udp_port,
7285 (void *)&cmd_tunnel_udp_config_port_id,
7290 /* *** GLOBAL CONFIG *** */
7291 struct cmd_global_config_result {
7292 cmdline_fixed_string_t cmd;
7294 cmdline_fixed_string_t cfg_type;
7299 cmd_global_config_parsed(void *parsed_result,
7300 __attribute__((unused)) struct cmdline *cl,
7301 __attribute__((unused)) void *data)
7303 struct cmd_global_config_result *res = parsed_result;
7304 struct rte_eth_global_cfg conf;
7307 memset(&conf, 0, sizeof(conf));
7308 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7309 conf.cfg.gre_key_len = res->len;
7310 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7311 RTE_ETH_FILTER_SET, &conf);
7313 printf("Global config error\n");
7316 cmdline_parse_token_string_t cmd_global_config_cmd =
7317 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7319 cmdline_parse_token_num_t cmd_global_config_port_id =
7320 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7321 cmdline_parse_token_string_t cmd_global_config_type =
7322 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7323 cfg_type, "gre-key-len");
7324 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7325 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7328 cmdline_parse_inst_t cmd_global_config = {
7329 .f = cmd_global_config_parsed,
7330 .data = (void *)NULL,
7331 .help_str = "global_config <port_id> gre-key-len <key_len>",
7333 (void *)&cmd_global_config_cmd,
7334 (void *)&cmd_global_config_port_id,
7335 (void *)&cmd_global_config_type,
7336 (void *)&cmd_global_config_gre_key_len,
7341 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7342 struct cmd_set_mirror_mask_result {
7343 cmdline_fixed_string_t set;
7344 cmdline_fixed_string_t port;
7346 cmdline_fixed_string_t mirror;
7348 cmdline_fixed_string_t what;
7349 cmdline_fixed_string_t value;
7350 cmdline_fixed_string_t dstpool;
7352 cmdline_fixed_string_t on;
7355 cmdline_parse_token_string_t cmd_mirror_mask_set =
7356 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7358 cmdline_parse_token_string_t cmd_mirror_mask_port =
7359 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7361 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7362 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7364 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7366 mirror, "mirror-rule");
7367 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7368 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7370 cmdline_parse_token_string_t cmd_mirror_mask_what =
7371 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7372 what, "pool-mirror-up#pool-mirror-down"
7374 cmdline_parse_token_string_t cmd_mirror_mask_value =
7375 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7377 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7378 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7379 dstpool, "dst-pool");
7380 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7381 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7383 cmdline_parse_token_string_t cmd_mirror_mask_on =
7384 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7388 cmd_set_mirror_mask_parsed(void *parsed_result,
7389 __attribute__((unused)) struct cmdline *cl,
7390 __attribute__((unused)) void *data)
7393 struct cmd_set_mirror_mask_result *res = parsed_result;
7394 struct rte_eth_mirror_conf mr_conf;
7396 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7398 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7400 mr_conf.dst_pool = res->dstpool_id;
7402 if (!strcmp(res->what, "pool-mirror-up")) {
7403 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7404 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7405 } else if (!strcmp(res->what, "pool-mirror-down")) {
7406 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7407 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7408 } else if (!strcmp(res->what, "vlan-mirror")) {
7409 mr_conf.rule_type = ETH_MIRROR_VLAN;
7410 nb_item = parse_item_list(res->value, "vlan",
7411 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7415 for (i = 0; i < nb_item; i++) {
7416 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7417 printf("Invalid vlan_id: must be < 4096\n");
7421 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7422 mr_conf.vlan.vlan_mask |= 1ULL << i;
7426 if (!strcmp(res->on, "on"))
7427 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7430 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7433 printf("mirror rule add error: (%s)\n", strerror(-ret));
7436 cmdline_parse_inst_t cmd_set_mirror_mask = {
7437 .f = cmd_set_mirror_mask_parsed,
7439 .help_str = "set port <port_id> mirror-rule <rule_id> "
7440 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7441 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7443 (void *)&cmd_mirror_mask_set,
7444 (void *)&cmd_mirror_mask_port,
7445 (void *)&cmd_mirror_mask_portid,
7446 (void *)&cmd_mirror_mask_mirror,
7447 (void *)&cmd_mirror_mask_ruleid,
7448 (void *)&cmd_mirror_mask_what,
7449 (void *)&cmd_mirror_mask_value,
7450 (void *)&cmd_mirror_mask_dstpool,
7451 (void *)&cmd_mirror_mask_poolid,
7452 (void *)&cmd_mirror_mask_on,
7457 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7458 struct cmd_set_mirror_link_result {
7459 cmdline_fixed_string_t set;
7460 cmdline_fixed_string_t port;
7462 cmdline_fixed_string_t mirror;
7464 cmdline_fixed_string_t what;
7465 cmdline_fixed_string_t dstpool;
7467 cmdline_fixed_string_t on;
7470 cmdline_parse_token_string_t cmd_mirror_link_set =
7471 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7473 cmdline_parse_token_string_t cmd_mirror_link_port =
7474 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7476 cmdline_parse_token_num_t cmd_mirror_link_portid =
7477 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7479 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7480 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7481 mirror, "mirror-rule");
7482 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7483 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7485 cmdline_parse_token_string_t cmd_mirror_link_what =
7486 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7487 what, "uplink-mirror#downlink-mirror");
7488 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7489 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7490 dstpool, "dst-pool");
7491 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7492 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7494 cmdline_parse_token_string_t cmd_mirror_link_on =
7495 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7499 cmd_set_mirror_link_parsed(void *parsed_result,
7500 __attribute__((unused)) struct cmdline *cl,
7501 __attribute__((unused)) void *data)
7504 struct cmd_set_mirror_link_result *res = parsed_result;
7505 struct rte_eth_mirror_conf mr_conf;
7507 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7508 if (!strcmp(res->what, "uplink-mirror"))
7509 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7511 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7513 mr_conf.dst_pool = res->dstpool_id;
7515 if (!strcmp(res->on, "on"))
7516 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7519 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7522 /* check the return value and print it if is < 0 */
7524 printf("mirror rule add error: (%s)\n", strerror(-ret));
7528 cmdline_parse_inst_t cmd_set_mirror_link = {
7529 .f = cmd_set_mirror_link_parsed,
7531 .help_str = "set port <port_id> mirror-rule <rule_id> "
7532 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7534 (void *)&cmd_mirror_link_set,
7535 (void *)&cmd_mirror_link_port,
7536 (void *)&cmd_mirror_link_portid,
7537 (void *)&cmd_mirror_link_mirror,
7538 (void *)&cmd_mirror_link_ruleid,
7539 (void *)&cmd_mirror_link_what,
7540 (void *)&cmd_mirror_link_dstpool,
7541 (void *)&cmd_mirror_link_poolid,
7542 (void *)&cmd_mirror_link_on,
7547 /* *** RESET VM MIRROR RULE *** */
7548 struct cmd_rm_mirror_rule_result {
7549 cmdline_fixed_string_t reset;
7550 cmdline_fixed_string_t port;
7552 cmdline_fixed_string_t mirror;
7556 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7557 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7559 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7560 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7562 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7563 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7565 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7566 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7567 mirror, "mirror-rule");
7568 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7569 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7573 cmd_reset_mirror_rule_parsed(void *parsed_result,
7574 __attribute__((unused)) struct cmdline *cl,
7575 __attribute__((unused)) void *data)
7578 struct cmd_set_mirror_link_result *res = parsed_result;
7580 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7582 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7585 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7586 .f = cmd_reset_mirror_rule_parsed,
7588 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7590 (void *)&cmd_rm_mirror_rule_reset,
7591 (void *)&cmd_rm_mirror_rule_port,
7592 (void *)&cmd_rm_mirror_rule_portid,
7593 (void *)&cmd_rm_mirror_rule_mirror,
7594 (void *)&cmd_rm_mirror_rule_ruleid,
7599 /* ******************************************************************************** */
7601 struct cmd_dump_result {
7602 cmdline_fixed_string_t dump;
7606 dump_struct_sizes(void)
7608 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7609 DUMP_SIZE(struct rte_mbuf);
7610 DUMP_SIZE(struct rte_mempool);
7611 DUMP_SIZE(struct rte_ring);
7615 static void cmd_dump_parsed(void *parsed_result,
7616 __attribute__((unused)) struct cmdline *cl,
7617 __attribute__((unused)) void *data)
7619 struct cmd_dump_result *res = parsed_result;
7621 if (!strcmp(res->dump, "dump_physmem"))
7622 rte_dump_physmem_layout(stdout);
7623 else if (!strcmp(res->dump, "dump_memzone"))
7624 rte_memzone_dump(stdout);
7625 else if (!strcmp(res->dump, "dump_struct_sizes"))
7626 dump_struct_sizes();
7627 else if (!strcmp(res->dump, "dump_ring"))
7628 rte_ring_list_dump(stdout);
7629 else if (!strcmp(res->dump, "dump_mempool"))
7630 rte_mempool_list_dump(stdout);
7631 else if (!strcmp(res->dump, "dump_devargs"))
7632 rte_eal_devargs_dump(stdout);
7635 cmdline_parse_token_string_t cmd_dump_dump =
7636 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7639 "dump_struct_sizes#"
7644 cmdline_parse_inst_t cmd_dump = {
7645 .f = cmd_dump_parsed, /* function to call */
7646 .data = NULL, /* 2nd arg of func */
7647 .help_str = "Dump status",
7648 .tokens = { /* token list, NULL terminated */
7649 (void *)&cmd_dump_dump,
7654 /* ******************************************************************************** */
7656 struct cmd_dump_one_result {
7657 cmdline_fixed_string_t dump;
7658 cmdline_fixed_string_t name;
7661 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7662 __attribute__((unused)) void *data)
7664 struct cmd_dump_one_result *res = parsed_result;
7666 if (!strcmp(res->dump, "dump_ring")) {
7668 r = rte_ring_lookup(res->name);
7670 cmdline_printf(cl, "Cannot find ring\n");
7673 rte_ring_dump(stdout, r);
7674 } else if (!strcmp(res->dump, "dump_mempool")) {
7675 struct rte_mempool *mp;
7676 mp = rte_mempool_lookup(res->name);
7678 cmdline_printf(cl, "Cannot find mempool\n");
7681 rte_mempool_dump(stdout, mp);
7685 cmdline_parse_token_string_t cmd_dump_one_dump =
7686 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7687 "dump_ring#dump_mempool");
7689 cmdline_parse_token_string_t cmd_dump_one_name =
7690 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7692 cmdline_parse_inst_t cmd_dump_one = {
7693 .f = cmd_dump_one_parsed, /* function to call */
7694 .data = NULL, /* 2nd arg of func */
7695 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7696 .tokens = { /* token list, NULL terminated */
7697 (void *)&cmd_dump_one_dump,
7698 (void *)&cmd_dump_one_name,
7703 /* *** Add/Del syn filter *** */
7704 struct cmd_syn_filter_result {
7705 cmdline_fixed_string_t filter;
7707 cmdline_fixed_string_t ops;
7708 cmdline_fixed_string_t priority;
7709 cmdline_fixed_string_t high;
7710 cmdline_fixed_string_t queue;
7715 cmd_syn_filter_parsed(void *parsed_result,
7716 __attribute__((unused)) struct cmdline *cl,
7717 __attribute__((unused)) void *data)
7719 struct cmd_syn_filter_result *res = parsed_result;
7720 struct rte_eth_syn_filter syn_filter;
7723 ret = rte_eth_dev_filter_supported(res->port_id,
7724 RTE_ETH_FILTER_SYN);
7726 printf("syn filter is not supported on port %u.\n",
7731 memset(&syn_filter, 0, sizeof(syn_filter));
7733 if (!strcmp(res->ops, "add")) {
7734 if (!strcmp(res->high, "high"))
7735 syn_filter.hig_pri = 1;
7737 syn_filter.hig_pri = 0;
7739 syn_filter.queue = res->queue_id;
7740 ret = rte_eth_dev_filter_ctrl(res->port_id,
7745 ret = rte_eth_dev_filter_ctrl(res->port_id,
7747 RTE_ETH_FILTER_DELETE,
7751 printf("syn filter programming error: (%s)\n",
7755 cmdline_parse_token_string_t cmd_syn_filter_filter =
7756 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7757 filter, "syn_filter");
7758 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7759 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7761 cmdline_parse_token_string_t cmd_syn_filter_ops =
7762 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7764 cmdline_parse_token_string_t cmd_syn_filter_priority =
7765 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7766 priority, "priority");
7767 cmdline_parse_token_string_t cmd_syn_filter_high =
7768 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7770 cmdline_parse_token_string_t cmd_syn_filter_queue =
7771 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7773 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7774 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7777 cmdline_parse_inst_t cmd_syn_filter = {
7778 .f = cmd_syn_filter_parsed,
7780 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7781 "<queue_id>: Add/Delete syn filter",
7783 (void *)&cmd_syn_filter_filter,
7784 (void *)&cmd_syn_filter_port_id,
7785 (void *)&cmd_syn_filter_ops,
7786 (void *)&cmd_syn_filter_priority,
7787 (void *)&cmd_syn_filter_high,
7788 (void *)&cmd_syn_filter_queue,
7789 (void *)&cmd_syn_filter_queue_id,
7794 /* *** ADD/REMOVE A 2tuple FILTER *** */
7795 struct cmd_2tuple_filter_result {
7796 cmdline_fixed_string_t filter;
7798 cmdline_fixed_string_t ops;
7799 cmdline_fixed_string_t dst_port;
7800 uint16_t dst_port_value;
7801 cmdline_fixed_string_t protocol;
7802 uint8_t protocol_value;
7803 cmdline_fixed_string_t mask;
7805 cmdline_fixed_string_t tcp_flags;
7806 uint8_t tcp_flags_value;
7807 cmdline_fixed_string_t priority;
7808 uint8_t priority_value;
7809 cmdline_fixed_string_t queue;
7814 cmd_2tuple_filter_parsed(void *parsed_result,
7815 __attribute__((unused)) struct cmdline *cl,
7816 __attribute__((unused)) void *data)
7818 struct rte_eth_ntuple_filter filter;
7819 struct cmd_2tuple_filter_result *res = parsed_result;
7822 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7824 printf("ntuple filter is not supported on port %u.\n",
7829 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7831 filter.flags = RTE_2TUPLE_FLAGS;
7832 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7833 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7834 filter.proto = res->protocol_value;
7835 filter.priority = res->priority_value;
7836 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7837 printf("nonzero tcp_flags is only meaningful"
7838 " when protocol is TCP.\n");
7841 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7842 printf("invalid TCP flags.\n");
7846 if (res->tcp_flags_value != 0) {
7847 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7848 filter.tcp_flags = res->tcp_flags_value;
7851 /* need convert to big endian. */
7852 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7853 filter.queue = res->queue_id;
7855 if (!strcmp(res->ops, "add"))
7856 ret = rte_eth_dev_filter_ctrl(res->port_id,
7857 RTE_ETH_FILTER_NTUPLE,
7861 ret = rte_eth_dev_filter_ctrl(res->port_id,
7862 RTE_ETH_FILTER_NTUPLE,
7863 RTE_ETH_FILTER_DELETE,
7866 printf("2tuple filter programming error: (%s)\n",
7871 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7872 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7873 filter, "2tuple_filter");
7874 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7875 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7877 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7878 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7880 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7881 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7882 dst_port, "dst_port");
7883 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7884 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7885 dst_port_value, UINT16);
7886 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7887 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7888 protocol, "protocol");
7889 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7890 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7891 protocol_value, UINT8);
7892 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7893 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7895 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7896 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7898 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7899 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7900 tcp_flags, "tcp_flags");
7901 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7902 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7903 tcp_flags_value, UINT8);
7904 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7905 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7906 priority, "priority");
7907 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7908 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7909 priority_value, UINT8);
7910 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7911 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7913 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7914 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7917 cmdline_parse_inst_t cmd_2tuple_filter = {
7918 .f = cmd_2tuple_filter_parsed,
7920 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7921 "<value> mask <value> tcp_flags <value> priority <value> queue "
7922 "<queue_id>: Add a 2tuple filter",
7924 (void *)&cmd_2tuple_filter_filter,
7925 (void *)&cmd_2tuple_filter_port_id,
7926 (void *)&cmd_2tuple_filter_ops,
7927 (void *)&cmd_2tuple_filter_dst_port,
7928 (void *)&cmd_2tuple_filter_dst_port_value,
7929 (void *)&cmd_2tuple_filter_protocol,
7930 (void *)&cmd_2tuple_filter_protocol_value,
7931 (void *)&cmd_2tuple_filter_mask,
7932 (void *)&cmd_2tuple_filter_mask_value,
7933 (void *)&cmd_2tuple_filter_tcp_flags,
7934 (void *)&cmd_2tuple_filter_tcp_flags_value,
7935 (void *)&cmd_2tuple_filter_priority,
7936 (void *)&cmd_2tuple_filter_priority_value,
7937 (void *)&cmd_2tuple_filter_queue,
7938 (void *)&cmd_2tuple_filter_queue_id,
7943 /* *** ADD/REMOVE A 5tuple FILTER *** */
7944 struct cmd_5tuple_filter_result {
7945 cmdline_fixed_string_t filter;
7947 cmdline_fixed_string_t ops;
7948 cmdline_fixed_string_t dst_ip;
7949 cmdline_ipaddr_t dst_ip_value;
7950 cmdline_fixed_string_t src_ip;
7951 cmdline_ipaddr_t src_ip_value;
7952 cmdline_fixed_string_t dst_port;
7953 uint16_t dst_port_value;
7954 cmdline_fixed_string_t src_port;
7955 uint16_t src_port_value;
7956 cmdline_fixed_string_t protocol;
7957 uint8_t protocol_value;
7958 cmdline_fixed_string_t mask;
7960 cmdline_fixed_string_t tcp_flags;
7961 uint8_t tcp_flags_value;
7962 cmdline_fixed_string_t priority;
7963 uint8_t priority_value;
7964 cmdline_fixed_string_t queue;
7969 cmd_5tuple_filter_parsed(void *parsed_result,
7970 __attribute__((unused)) struct cmdline *cl,
7971 __attribute__((unused)) void *data)
7973 struct rte_eth_ntuple_filter filter;
7974 struct cmd_5tuple_filter_result *res = parsed_result;
7977 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7979 printf("ntuple filter is not supported on port %u.\n",
7984 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7986 filter.flags = RTE_5TUPLE_FLAGS;
7987 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7988 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7989 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7990 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7991 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7992 filter.proto = res->protocol_value;
7993 filter.priority = res->priority_value;
7994 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7995 printf("nonzero tcp_flags is only meaningful"
7996 " when protocol is TCP.\n");
7999 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8000 printf("invalid TCP flags.\n");
8004 if (res->tcp_flags_value != 0) {
8005 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8006 filter.tcp_flags = res->tcp_flags_value;
8009 if (res->dst_ip_value.family == AF_INET)
8010 /* no need to convert, already big endian. */
8011 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8013 if (filter.dst_ip_mask == 0) {
8014 printf("can not support ipv6 involved compare.\n");
8020 if (res->src_ip_value.family == AF_INET)
8021 /* no need to convert, already big endian. */
8022 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8024 if (filter.src_ip_mask == 0) {
8025 printf("can not support ipv6 involved compare.\n");
8030 /* need convert to big endian. */
8031 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8032 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8033 filter.queue = res->queue_id;
8035 if (!strcmp(res->ops, "add"))
8036 ret = rte_eth_dev_filter_ctrl(res->port_id,
8037 RTE_ETH_FILTER_NTUPLE,
8041 ret = rte_eth_dev_filter_ctrl(res->port_id,
8042 RTE_ETH_FILTER_NTUPLE,
8043 RTE_ETH_FILTER_DELETE,
8046 printf("5tuple filter programming error: (%s)\n",
8050 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8051 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8052 filter, "5tuple_filter");
8053 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8054 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8056 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8057 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8059 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8060 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8062 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8063 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8065 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8066 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8068 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8069 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8071 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8072 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8073 dst_port, "dst_port");
8074 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8075 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8076 dst_port_value, UINT16);
8077 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8078 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8079 src_port, "src_port");
8080 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8081 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8082 src_port_value, UINT16);
8083 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8084 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8085 protocol, "protocol");
8086 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8087 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8088 protocol_value, UINT8);
8089 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8090 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8092 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8093 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8095 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8096 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8097 tcp_flags, "tcp_flags");
8098 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8099 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8100 tcp_flags_value, UINT8);
8101 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8102 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8103 priority, "priority");
8104 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8105 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8106 priority_value, UINT8);
8107 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8108 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8110 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8111 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8114 cmdline_parse_inst_t cmd_5tuple_filter = {
8115 .f = cmd_5tuple_filter_parsed,
8117 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8118 "src_ip <value> dst_port <value> src_port <value> "
8119 "protocol <value> mask <value> tcp_flags <value> "
8120 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8122 (void *)&cmd_5tuple_filter_filter,
8123 (void *)&cmd_5tuple_filter_port_id,
8124 (void *)&cmd_5tuple_filter_ops,
8125 (void *)&cmd_5tuple_filter_dst_ip,
8126 (void *)&cmd_5tuple_filter_dst_ip_value,
8127 (void *)&cmd_5tuple_filter_src_ip,
8128 (void *)&cmd_5tuple_filter_src_ip_value,
8129 (void *)&cmd_5tuple_filter_dst_port,
8130 (void *)&cmd_5tuple_filter_dst_port_value,
8131 (void *)&cmd_5tuple_filter_src_port,
8132 (void *)&cmd_5tuple_filter_src_port_value,
8133 (void *)&cmd_5tuple_filter_protocol,
8134 (void *)&cmd_5tuple_filter_protocol_value,
8135 (void *)&cmd_5tuple_filter_mask,
8136 (void *)&cmd_5tuple_filter_mask_value,
8137 (void *)&cmd_5tuple_filter_tcp_flags,
8138 (void *)&cmd_5tuple_filter_tcp_flags_value,
8139 (void *)&cmd_5tuple_filter_priority,
8140 (void *)&cmd_5tuple_filter_priority_value,
8141 (void *)&cmd_5tuple_filter_queue,
8142 (void *)&cmd_5tuple_filter_queue_id,
8147 /* *** ADD/REMOVE A flex FILTER *** */
8148 struct cmd_flex_filter_result {
8149 cmdline_fixed_string_t filter;
8150 cmdline_fixed_string_t ops;
8152 cmdline_fixed_string_t len;
8154 cmdline_fixed_string_t bytes;
8155 cmdline_fixed_string_t bytes_value;
8156 cmdline_fixed_string_t mask;
8157 cmdline_fixed_string_t mask_value;
8158 cmdline_fixed_string_t priority;
8159 uint8_t priority_value;
8160 cmdline_fixed_string_t queue;
8164 static int xdigit2val(unsigned char c)
8169 else if (isupper(c))
8177 cmd_flex_filter_parsed(void *parsed_result,
8178 __attribute__((unused)) struct cmdline *cl,
8179 __attribute__((unused)) void *data)
8182 struct rte_eth_flex_filter filter;
8183 struct cmd_flex_filter_result *res = parsed_result;
8184 char *bytes_ptr, *mask_ptr;
8185 uint16_t len, i, j = 0;
8190 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8191 printf("the len exceed the max length 128\n");
8194 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8195 filter.len = res->len_value;
8196 filter.priority = res->priority_value;
8197 filter.queue = res->queue_id;
8198 bytes_ptr = res->bytes_value;
8199 mask_ptr = res->mask_value;
8201 /* translate bytes string to array. */
8202 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8203 (bytes_ptr[1] == 'X')))
8205 len = strnlen(bytes_ptr, res->len_value * 2);
8206 if (len == 0 || (len % 8 != 0)) {
8207 printf("please check len and bytes input\n");
8210 for (i = 0; i < len; i++) {
8212 if (isxdigit(c) == 0) {
8213 /* invalid characters. */
8214 printf("invalid input\n");
8217 val = xdigit2val(c);
8220 filter.bytes[j] = byte;
8221 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8228 /* translate mask string to uint8_t array. */
8229 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8230 (mask_ptr[1] == 'X')))
8232 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8234 printf("invalid input\n");
8239 for (i = 0; i < len; i++) {
8241 if (isxdigit(c) == 0) {
8242 /* invalid characters. */
8243 printf("invalid input\n");
8246 val = xdigit2val(c);
8249 filter.mask[j] = byte;
8250 printf("mask[%d]:%02x ", j, filter.mask[j]);
8258 if (!strcmp(res->ops, "add"))
8259 ret = rte_eth_dev_filter_ctrl(res->port_id,
8260 RTE_ETH_FILTER_FLEXIBLE,
8264 ret = rte_eth_dev_filter_ctrl(res->port_id,
8265 RTE_ETH_FILTER_FLEXIBLE,
8266 RTE_ETH_FILTER_DELETE,
8270 printf("flex filter setting error: (%s)\n", strerror(-ret));
8273 cmdline_parse_token_string_t cmd_flex_filter_filter =
8274 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8275 filter, "flex_filter");
8276 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8277 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8279 cmdline_parse_token_string_t cmd_flex_filter_ops =
8280 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8282 cmdline_parse_token_string_t cmd_flex_filter_len =
8283 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8285 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8286 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8288 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8289 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8291 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8292 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8294 cmdline_parse_token_string_t cmd_flex_filter_mask =
8295 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8297 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8298 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8300 cmdline_parse_token_string_t cmd_flex_filter_priority =
8301 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8302 priority, "priority");
8303 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8304 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8305 priority_value, UINT8);
8306 cmdline_parse_token_string_t cmd_flex_filter_queue =
8307 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8309 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8310 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8312 cmdline_parse_inst_t cmd_flex_filter = {
8313 .f = cmd_flex_filter_parsed,
8315 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8316 "<value> mask <value> priority <value> queue <queue_id>: "
8317 "Add/Del a flex filter",
8319 (void *)&cmd_flex_filter_filter,
8320 (void *)&cmd_flex_filter_port_id,
8321 (void *)&cmd_flex_filter_ops,
8322 (void *)&cmd_flex_filter_len,
8323 (void *)&cmd_flex_filter_len_value,
8324 (void *)&cmd_flex_filter_bytes,
8325 (void *)&cmd_flex_filter_bytes_value,
8326 (void *)&cmd_flex_filter_mask,
8327 (void *)&cmd_flex_filter_mask_value,
8328 (void *)&cmd_flex_filter_priority,
8329 (void *)&cmd_flex_filter_priority_value,
8330 (void *)&cmd_flex_filter_queue,
8331 (void *)&cmd_flex_filter_queue_id,
8336 /* *** Filters Control *** */
8338 /* *** deal with ethertype filter *** */
8339 struct cmd_ethertype_filter_result {
8340 cmdline_fixed_string_t filter;
8342 cmdline_fixed_string_t ops;
8343 cmdline_fixed_string_t mac;
8344 struct ether_addr mac_addr;
8345 cmdline_fixed_string_t ethertype;
8346 uint16_t ethertype_value;
8347 cmdline_fixed_string_t drop;
8348 cmdline_fixed_string_t queue;
8352 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8353 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8354 filter, "ethertype_filter");
8355 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8356 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8358 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8359 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8361 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8362 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8363 mac, "mac_addr#mac_ignr");
8364 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8365 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8367 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8368 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8369 ethertype, "ethertype");
8370 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8371 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8372 ethertype_value, UINT16);
8373 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8374 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8376 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8377 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8379 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8380 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8384 cmd_ethertype_filter_parsed(void *parsed_result,
8385 __attribute__((unused)) struct cmdline *cl,
8386 __attribute__((unused)) void *data)
8388 struct cmd_ethertype_filter_result *res = parsed_result;
8389 struct rte_eth_ethertype_filter filter;
8392 ret = rte_eth_dev_filter_supported(res->port_id,
8393 RTE_ETH_FILTER_ETHERTYPE);
8395 printf("ethertype filter is not supported on port %u.\n",
8400 memset(&filter, 0, sizeof(filter));
8401 if (!strcmp(res->mac, "mac_addr")) {
8402 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8403 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8404 sizeof(struct ether_addr));
8406 if (!strcmp(res->drop, "drop"))
8407 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8408 filter.ether_type = res->ethertype_value;
8409 filter.queue = res->queue_id;
8411 if (!strcmp(res->ops, "add"))
8412 ret = rte_eth_dev_filter_ctrl(res->port_id,
8413 RTE_ETH_FILTER_ETHERTYPE,
8417 ret = rte_eth_dev_filter_ctrl(res->port_id,
8418 RTE_ETH_FILTER_ETHERTYPE,
8419 RTE_ETH_FILTER_DELETE,
8422 printf("ethertype filter programming error: (%s)\n",
8426 cmdline_parse_inst_t cmd_ethertype_filter = {
8427 .f = cmd_ethertype_filter_parsed,
8429 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8430 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8431 "Add or delete an ethertype filter entry",
8433 (void *)&cmd_ethertype_filter_filter,
8434 (void *)&cmd_ethertype_filter_port_id,
8435 (void *)&cmd_ethertype_filter_ops,
8436 (void *)&cmd_ethertype_filter_mac,
8437 (void *)&cmd_ethertype_filter_mac_addr,
8438 (void *)&cmd_ethertype_filter_ethertype,
8439 (void *)&cmd_ethertype_filter_ethertype_value,
8440 (void *)&cmd_ethertype_filter_drop,
8441 (void *)&cmd_ethertype_filter_queue,
8442 (void *)&cmd_ethertype_filter_queue_id,
8447 /* *** deal with flow director filter *** */
8448 struct cmd_flow_director_result {
8449 cmdline_fixed_string_t flow_director_filter;
8451 cmdline_fixed_string_t mode;
8452 cmdline_fixed_string_t mode_value;
8453 cmdline_fixed_string_t ops;
8454 cmdline_fixed_string_t flow;
8455 cmdline_fixed_string_t flow_type;
8456 cmdline_fixed_string_t ether;
8457 uint16_t ether_type;
8458 cmdline_fixed_string_t src;
8459 cmdline_ipaddr_t ip_src;
8461 cmdline_fixed_string_t dst;
8462 cmdline_ipaddr_t ip_dst;
8464 cmdline_fixed_string_t verify_tag;
8465 uint32_t verify_tag_value;
8466 cmdline_ipaddr_t tos;
8468 cmdline_ipaddr_t proto;
8469 uint8_t proto_value;
8470 cmdline_ipaddr_t ttl;
8472 cmdline_fixed_string_t vlan;
8473 uint16_t vlan_value;
8474 cmdline_fixed_string_t flexbytes;
8475 cmdline_fixed_string_t flexbytes_value;
8476 cmdline_fixed_string_t pf_vf;
8477 cmdline_fixed_string_t drop;
8478 cmdline_fixed_string_t queue;
8480 cmdline_fixed_string_t fd_id;
8481 uint32_t fd_id_value;
8482 cmdline_fixed_string_t mac;
8483 struct ether_addr mac_addr;
8484 cmdline_fixed_string_t tunnel;
8485 cmdline_fixed_string_t tunnel_type;
8486 cmdline_fixed_string_t tunnel_id;
8487 uint32_t tunnel_id_value;
8491 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8494 const char *p, *p0 = q_arg;
8496 unsigned long int_fld;
8497 char *str_fld[max_num];
8502 p = strchr(p0, '(');
8506 p0 = strchr(p, ')');
8511 if (size >= sizeof(s))
8514 snprintf(s, sizeof(s), "%.*s", size, p);
8515 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8516 if (ret < 0 || ret > max_num)
8518 for (i = 0; i < ret; i++) {
8520 int_fld = strtoul(str_fld[i], &end, 0);
8521 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8523 flexbytes[i] = (uint8_t)int_fld;
8529 str2flowtype(char *string)
8532 static const struct {
8535 } flowtype_str[] = {
8536 {"raw", RTE_ETH_FLOW_RAW},
8537 {"ipv4", RTE_ETH_FLOW_IPV4},
8538 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8539 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8540 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8541 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8542 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8543 {"ipv6", RTE_ETH_FLOW_IPV6},
8544 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8545 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8546 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8547 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8548 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8549 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8552 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8553 if (!strcmp(flowtype_str[i].str, string))
8554 return flowtype_str[i].type;
8556 return RTE_ETH_FLOW_UNKNOWN;
8559 static enum rte_eth_fdir_tunnel_type
8560 str2fdir_tunneltype(char *string)
8564 static const struct {
8566 enum rte_eth_fdir_tunnel_type type;
8567 } tunneltype_str[] = {
8568 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8569 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8572 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8573 if (!strcmp(tunneltype_str[i].str, string))
8574 return tunneltype_str[i].type;
8576 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8579 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8581 if ((ip_addr).family == AF_INET) \
8582 (ip) = (ip_addr).addr.ipv4.s_addr; \
8584 printf("invalid parameter.\n"); \
8589 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8591 if ((ip_addr).family == AF_INET6) \
8592 (void)rte_memcpy(&(ip), \
8593 &((ip_addr).addr.ipv6), \
8594 sizeof(struct in6_addr)); \
8596 printf("invalid parameter.\n"); \
8602 cmd_flow_director_filter_parsed(void *parsed_result,
8603 __attribute__((unused)) struct cmdline *cl,
8604 __attribute__((unused)) void *data)
8606 struct cmd_flow_director_result *res = parsed_result;
8607 struct rte_eth_fdir_filter entry;
8608 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8610 unsigned long vf_id;
8613 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8615 printf("flow director is not supported on port %u.\n",
8619 memset(flexbytes, 0, sizeof(flexbytes));
8620 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8622 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8623 if (strcmp(res->mode_value, "MAC-VLAN")) {
8624 printf("Please set mode to MAC-VLAN.\n");
8627 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8628 if (strcmp(res->mode_value, "Tunnel")) {
8629 printf("Please set mode to Tunnel.\n");
8633 if (strcmp(res->mode_value, "IP")) {
8634 printf("Please set mode to IP.\n");
8637 entry.input.flow_type = str2flowtype(res->flow_type);
8640 ret = parse_flexbytes(res->flexbytes_value,
8642 RTE_ETH_FDIR_MAX_FLEXLEN);
8644 printf("error: Cannot parse flexbytes input.\n");
8648 switch (entry.input.flow_type) {
8649 case RTE_ETH_FLOW_FRAG_IPV4:
8650 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8651 entry.input.flow.ip4_flow.proto = res->proto_value;
8652 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8653 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8654 IPV4_ADDR_TO_UINT(res->ip_dst,
8655 entry.input.flow.ip4_flow.dst_ip);
8656 IPV4_ADDR_TO_UINT(res->ip_src,
8657 entry.input.flow.ip4_flow.src_ip);
8658 entry.input.flow.ip4_flow.tos = res->tos_value;
8659 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8660 /* need convert to big endian. */
8661 entry.input.flow.udp4_flow.dst_port =
8662 rte_cpu_to_be_16(res->port_dst);
8663 entry.input.flow.udp4_flow.src_port =
8664 rte_cpu_to_be_16(res->port_src);
8666 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8667 IPV4_ADDR_TO_UINT(res->ip_dst,
8668 entry.input.flow.sctp4_flow.ip.dst_ip);
8669 IPV4_ADDR_TO_UINT(res->ip_src,
8670 entry.input.flow.sctp4_flow.ip.src_ip);
8671 entry.input.flow.ip4_flow.tos = res->tos_value;
8672 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8673 /* need convert to big endian. */
8674 entry.input.flow.sctp4_flow.dst_port =
8675 rte_cpu_to_be_16(res->port_dst);
8676 entry.input.flow.sctp4_flow.src_port =
8677 rte_cpu_to_be_16(res->port_src);
8678 entry.input.flow.sctp4_flow.verify_tag =
8679 rte_cpu_to_be_32(res->verify_tag_value);
8681 case RTE_ETH_FLOW_FRAG_IPV6:
8682 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8683 entry.input.flow.ipv6_flow.proto = res->proto_value;
8684 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8685 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8686 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8687 entry.input.flow.ipv6_flow.dst_ip);
8688 IPV6_ADDR_TO_ARRAY(res->ip_src,
8689 entry.input.flow.ipv6_flow.src_ip);
8690 entry.input.flow.ipv6_flow.tc = res->tos_value;
8691 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8692 /* need convert to big endian. */
8693 entry.input.flow.udp6_flow.dst_port =
8694 rte_cpu_to_be_16(res->port_dst);
8695 entry.input.flow.udp6_flow.src_port =
8696 rte_cpu_to_be_16(res->port_src);
8698 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8699 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8700 entry.input.flow.sctp6_flow.ip.dst_ip);
8701 IPV6_ADDR_TO_ARRAY(res->ip_src,
8702 entry.input.flow.sctp6_flow.ip.src_ip);
8703 entry.input.flow.ipv6_flow.tc = res->tos_value;
8704 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8705 /* need convert to big endian. */
8706 entry.input.flow.sctp6_flow.dst_port =
8707 rte_cpu_to_be_16(res->port_dst);
8708 entry.input.flow.sctp6_flow.src_port =
8709 rte_cpu_to_be_16(res->port_src);
8710 entry.input.flow.sctp6_flow.verify_tag =
8711 rte_cpu_to_be_32(res->verify_tag_value);
8713 case RTE_ETH_FLOW_L2_PAYLOAD:
8714 entry.input.flow.l2_flow.ether_type =
8715 rte_cpu_to_be_16(res->ether_type);
8721 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8722 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8724 sizeof(struct ether_addr));
8726 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8727 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8729 sizeof(struct ether_addr));
8730 entry.input.flow.tunnel_flow.tunnel_type =
8731 str2fdir_tunneltype(res->tunnel_type);
8732 entry.input.flow.tunnel_flow.tunnel_id =
8733 rte_cpu_to_be_32(res->tunnel_id_value);
8736 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8738 RTE_ETH_FDIR_MAX_FLEXLEN);
8740 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8742 entry.action.flex_off = 0; /*use 0 by default */
8743 if (!strcmp(res->drop, "drop"))
8744 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8746 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8748 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8749 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8750 if (!strcmp(res->pf_vf, "pf"))
8751 entry.input.flow_ext.is_vf = 0;
8752 else if (!strncmp(res->pf_vf, "vf", 2)) {
8753 struct rte_eth_dev_info dev_info;
8755 memset(&dev_info, 0, sizeof(dev_info));
8756 rte_eth_dev_info_get(res->port_id, &dev_info);
8758 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8759 if (errno != 0 || *end != '\0' ||
8760 vf_id >= dev_info.max_vfs) {
8761 printf("invalid parameter %s.\n", res->pf_vf);
8764 entry.input.flow_ext.is_vf = 1;
8765 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8767 printf("invalid parameter %s.\n", res->pf_vf);
8772 /* set to report FD ID by default */
8773 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8774 entry.action.rx_queue = res->queue_id;
8775 entry.soft_id = res->fd_id_value;
8776 if (!strcmp(res->ops, "add"))
8777 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8778 RTE_ETH_FILTER_ADD, &entry);
8779 else if (!strcmp(res->ops, "del"))
8780 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8781 RTE_ETH_FILTER_DELETE, &entry);
8783 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8784 RTE_ETH_FILTER_UPDATE, &entry);
8786 printf("flow director programming error: (%s)\n",
8790 cmdline_parse_token_string_t cmd_flow_director_filter =
8791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8792 flow_director_filter, "flow_director_filter");
8793 cmdline_parse_token_num_t cmd_flow_director_port_id =
8794 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8796 cmdline_parse_token_string_t cmd_flow_director_ops =
8797 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8798 ops, "add#del#update");
8799 cmdline_parse_token_string_t cmd_flow_director_flow =
8800 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8802 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8803 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8804 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8805 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8806 cmdline_parse_token_string_t cmd_flow_director_ether =
8807 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8809 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8810 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8811 ether_type, UINT16);
8812 cmdline_parse_token_string_t cmd_flow_director_src =
8813 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8815 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8816 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8818 cmdline_parse_token_num_t cmd_flow_director_port_src =
8819 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8821 cmdline_parse_token_string_t cmd_flow_director_dst =
8822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8824 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8825 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8827 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8828 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8830 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8832 verify_tag, "verify_tag");
8833 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8834 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8835 verify_tag_value, UINT32);
8836 cmdline_parse_token_string_t cmd_flow_director_tos =
8837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8839 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8840 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8842 cmdline_parse_token_string_t cmd_flow_director_proto =
8843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8845 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8846 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8847 proto_value, UINT8);
8848 cmdline_parse_token_string_t cmd_flow_director_ttl =
8849 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8851 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8852 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8854 cmdline_parse_token_string_t cmd_flow_director_vlan =
8855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8857 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8858 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8859 vlan_value, UINT16);
8860 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8862 flexbytes, "flexbytes");
8863 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8865 flexbytes_value, NULL);
8866 cmdline_parse_token_string_t cmd_flow_director_drop =
8867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8869 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8872 cmdline_parse_token_string_t cmd_flow_director_queue =
8873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8875 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8876 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8878 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8881 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8882 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8883 fd_id_value, UINT32);
8885 cmdline_parse_token_string_t cmd_flow_director_mode =
8886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8888 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8891 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8893 mode_value, "MAC-VLAN");
8894 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8896 mode_value, "Tunnel");
8897 cmdline_parse_token_string_t cmd_flow_director_mac =
8898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8900 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8901 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8903 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8906 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8908 tunnel_type, "NVGRE#VxLAN");
8909 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8911 tunnel_id, "tunnel-id");
8912 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8913 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8914 tunnel_id_value, UINT32);
8916 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8917 .f = cmd_flow_director_filter_parsed,
8919 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8920 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8921 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8922 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8923 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8924 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8925 "fd_id <fd_id_value>: "
8926 "Add or delete an ip flow director entry on NIC",
8928 (void *)&cmd_flow_director_filter,
8929 (void *)&cmd_flow_director_port_id,
8930 (void *)&cmd_flow_director_mode,
8931 (void *)&cmd_flow_director_mode_ip,
8932 (void *)&cmd_flow_director_ops,
8933 (void *)&cmd_flow_director_flow,
8934 (void *)&cmd_flow_director_flow_type,
8935 (void *)&cmd_flow_director_src,
8936 (void *)&cmd_flow_director_ip_src,
8937 (void *)&cmd_flow_director_dst,
8938 (void *)&cmd_flow_director_ip_dst,
8939 (void *)&cmd_flow_director_tos,
8940 (void *)&cmd_flow_director_tos_value,
8941 (void *)&cmd_flow_director_proto,
8942 (void *)&cmd_flow_director_proto_value,
8943 (void *)&cmd_flow_director_ttl,
8944 (void *)&cmd_flow_director_ttl_value,
8945 (void *)&cmd_flow_director_vlan,
8946 (void *)&cmd_flow_director_vlan_value,
8947 (void *)&cmd_flow_director_flexbytes,
8948 (void *)&cmd_flow_director_flexbytes_value,
8949 (void *)&cmd_flow_director_drop,
8950 (void *)&cmd_flow_director_pf_vf,
8951 (void *)&cmd_flow_director_queue,
8952 (void *)&cmd_flow_director_queue_id,
8953 (void *)&cmd_flow_director_fd_id,
8954 (void *)&cmd_flow_director_fd_id_value,
8959 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8960 .f = cmd_flow_director_filter_parsed,
8962 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8963 "director entry on NIC",
8965 (void *)&cmd_flow_director_filter,
8966 (void *)&cmd_flow_director_port_id,
8967 (void *)&cmd_flow_director_mode,
8968 (void *)&cmd_flow_director_mode_ip,
8969 (void *)&cmd_flow_director_ops,
8970 (void *)&cmd_flow_director_flow,
8971 (void *)&cmd_flow_director_flow_type,
8972 (void *)&cmd_flow_director_src,
8973 (void *)&cmd_flow_director_ip_src,
8974 (void *)&cmd_flow_director_port_src,
8975 (void *)&cmd_flow_director_dst,
8976 (void *)&cmd_flow_director_ip_dst,
8977 (void *)&cmd_flow_director_port_dst,
8978 (void *)&cmd_flow_director_tos,
8979 (void *)&cmd_flow_director_tos_value,
8980 (void *)&cmd_flow_director_ttl,
8981 (void *)&cmd_flow_director_ttl_value,
8982 (void *)&cmd_flow_director_vlan,
8983 (void *)&cmd_flow_director_vlan_value,
8984 (void *)&cmd_flow_director_flexbytes,
8985 (void *)&cmd_flow_director_flexbytes_value,
8986 (void *)&cmd_flow_director_drop,
8987 (void *)&cmd_flow_director_pf_vf,
8988 (void *)&cmd_flow_director_queue,
8989 (void *)&cmd_flow_director_queue_id,
8990 (void *)&cmd_flow_director_fd_id,
8991 (void *)&cmd_flow_director_fd_id_value,
8996 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8997 .f = cmd_flow_director_filter_parsed,
8999 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9000 "director entry on NIC",
9002 (void *)&cmd_flow_director_filter,
9003 (void *)&cmd_flow_director_port_id,
9004 (void *)&cmd_flow_director_mode,
9005 (void *)&cmd_flow_director_mode_ip,
9006 (void *)&cmd_flow_director_ops,
9007 (void *)&cmd_flow_director_flow,
9008 (void *)&cmd_flow_director_flow_type,
9009 (void *)&cmd_flow_director_src,
9010 (void *)&cmd_flow_director_ip_src,
9011 (void *)&cmd_flow_director_port_dst,
9012 (void *)&cmd_flow_director_dst,
9013 (void *)&cmd_flow_director_ip_dst,
9014 (void *)&cmd_flow_director_port_dst,
9015 (void *)&cmd_flow_director_verify_tag,
9016 (void *)&cmd_flow_director_verify_tag_value,
9017 (void *)&cmd_flow_director_tos,
9018 (void *)&cmd_flow_director_tos_value,
9019 (void *)&cmd_flow_director_ttl,
9020 (void *)&cmd_flow_director_ttl_value,
9021 (void *)&cmd_flow_director_vlan,
9022 (void *)&cmd_flow_director_vlan_value,
9023 (void *)&cmd_flow_director_flexbytes,
9024 (void *)&cmd_flow_director_flexbytes_value,
9025 (void *)&cmd_flow_director_drop,
9026 (void *)&cmd_flow_director_pf_vf,
9027 (void *)&cmd_flow_director_queue,
9028 (void *)&cmd_flow_director_queue_id,
9029 (void *)&cmd_flow_director_fd_id,
9030 (void *)&cmd_flow_director_fd_id_value,
9035 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9036 .f = cmd_flow_director_filter_parsed,
9038 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9039 "director entry on NIC",
9041 (void *)&cmd_flow_director_filter,
9042 (void *)&cmd_flow_director_port_id,
9043 (void *)&cmd_flow_director_mode,
9044 (void *)&cmd_flow_director_mode_ip,
9045 (void *)&cmd_flow_director_ops,
9046 (void *)&cmd_flow_director_flow,
9047 (void *)&cmd_flow_director_flow_type,
9048 (void *)&cmd_flow_director_ether,
9049 (void *)&cmd_flow_director_ether_type,
9050 (void *)&cmd_flow_director_flexbytes,
9051 (void *)&cmd_flow_director_flexbytes_value,
9052 (void *)&cmd_flow_director_drop,
9053 (void *)&cmd_flow_director_pf_vf,
9054 (void *)&cmd_flow_director_queue,
9055 (void *)&cmd_flow_director_queue_id,
9056 (void *)&cmd_flow_director_fd_id,
9057 (void *)&cmd_flow_director_fd_id_value,
9062 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9063 .f = cmd_flow_director_filter_parsed,
9065 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9066 "director entry on NIC",
9068 (void *)&cmd_flow_director_filter,
9069 (void *)&cmd_flow_director_port_id,
9070 (void *)&cmd_flow_director_mode,
9071 (void *)&cmd_flow_director_mode_mac_vlan,
9072 (void *)&cmd_flow_director_ops,
9073 (void *)&cmd_flow_director_mac,
9074 (void *)&cmd_flow_director_mac_addr,
9075 (void *)&cmd_flow_director_vlan,
9076 (void *)&cmd_flow_director_vlan_value,
9077 (void *)&cmd_flow_director_flexbytes,
9078 (void *)&cmd_flow_director_flexbytes_value,
9079 (void *)&cmd_flow_director_drop,
9080 (void *)&cmd_flow_director_queue,
9081 (void *)&cmd_flow_director_queue_id,
9082 (void *)&cmd_flow_director_fd_id,
9083 (void *)&cmd_flow_director_fd_id_value,
9088 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9089 .f = cmd_flow_director_filter_parsed,
9091 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9092 "director entry on NIC",
9094 (void *)&cmd_flow_director_filter,
9095 (void *)&cmd_flow_director_port_id,
9096 (void *)&cmd_flow_director_mode,
9097 (void *)&cmd_flow_director_mode_tunnel,
9098 (void *)&cmd_flow_director_ops,
9099 (void *)&cmd_flow_director_mac,
9100 (void *)&cmd_flow_director_mac_addr,
9101 (void *)&cmd_flow_director_vlan,
9102 (void *)&cmd_flow_director_vlan_value,
9103 (void *)&cmd_flow_director_tunnel,
9104 (void *)&cmd_flow_director_tunnel_type,
9105 (void *)&cmd_flow_director_tunnel_id,
9106 (void *)&cmd_flow_director_tunnel_id_value,
9107 (void *)&cmd_flow_director_flexbytes,
9108 (void *)&cmd_flow_director_flexbytes_value,
9109 (void *)&cmd_flow_director_drop,
9110 (void *)&cmd_flow_director_queue,
9111 (void *)&cmd_flow_director_queue_id,
9112 (void *)&cmd_flow_director_fd_id,
9113 (void *)&cmd_flow_director_fd_id_value,
9118 struct cmd_flush_flow_director_result {
9119 cmdline_fixed_string_t flush_flow_director;
9123 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9124 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9125 flush_flow_director, "flush_flow_director");
9126 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9127 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9131 cmd_flush_flow_director_parsed(void *parsed_result,
9132 __attribute__((unused)) struct cmdline *cl,
9133 __attribute__((unused)) void *data)
9135 struct cmd_flow_director_result *res = parsed_result;
9138 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9140 printf("flow director is not supported on port %u.\n",
9145 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9146 RTE_ETH_FILTER_FLUSH, NULL);
9148 printf("flow director table flushing error: (%s)\n",
9152 cmdline_parse_inst_t cmd_flush_flow_director = {
9153 .f = cmd_flush_flow_director_parsed,
9155 .help_str = "flush_flow_director <port_id>: "
9156 "Flush all flow director entries of a device on NIC",
9158 (void *)&cmd_flush_flow_director_flush,
9159 (void *)&cmd_flush_flow_director_port_id,
9164 /* *** deal with flow director mask *** */
9165 struct cmd_flow_director_mask_result {
9166 cmdline_fixed_string_t flow_director_mask;
9168 cmdline_fixed_string_t mode;
9169 cmdline_fixed_string_t mode_value;
9170 cmdline_fixed_string_t vlan;
9172 cmdline_fixed_string_t src_mask;
9173 cmdline_ipaddr_t ipv4_src;
9174 cmdline_ipaddr_t ipv6_src;
9176 cmdline_fixed_string_t dst_mask;
9177 cmdline_ipaddr_t ipv4_dst;
9178 cmdline_ipaddr_t ipv6_dst;
9180 cmdline_fixed_string_t mac;
9181 uint8_t mac_addr_byte_mask;
9182 cmdline_fixed_string_t tunnel_id;
9183 uint32_t tunnel_id_mask;
9184 cmdline_fixed_string_t tunnel_type;
9185 uint8_t tunnel_type_mask;
9189 cmd_flow_director_mask_parsed(void *parsed_result,
9190 __attribute__((unused)) struct cmdline *cl,
9191 __attribute__((unused)) void *data)
9193 struct cmd_flow_director_mask_result *res = parsed_result;
9194 struct rte_eth_fdir_masks *mask;
9195 struct rte_port *port;
9197 if (res->port_id > nb_ports) {
9198 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9202 port = &ports[res->port_id];
9203 /** Check if the port is not started **/
9204 if (port->port_status != RTE_PORT_STOPPED) {
9205 printf("Please stop port %d first\n", res->port_id);
9209 mask = &port->dev_conf.fdir_conf.mask;
9211 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9212 if (strcmp(res->mode_value, "MAC-VLAN")) {
9213 printf("Please set mode to MAC-VLAN.\n");
9217 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9218 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9219 if (strcmp(res->mode_value, "Tunnel")) {
9220 printf("Please set mode to Tunnel.\n");
9224 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9225 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9226 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9227 mask->tunnel_type_mask = res->tunnel_type_mask;
9229 if (strcmp(res->mode_value, "IP")) {
9230 printf("Please set mode to IP.\n");
9234 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9235 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9236 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9237 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9238 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9239 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9240 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9243 cmd_reconfig_device_queue(res->port_id, 1, 1);
9246 cmdline_parse_token_string_t cmd_flow_director_mask =
9247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9248 flow_director_mask, "flow_director_mask");
9249 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9250 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9252 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9255 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9256 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9258 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9260 src_mask, "src_mask");
9261 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9262 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9264 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9265 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9267 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9268 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9270 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9272 dst_mask, "dst_mask");
9273 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9274 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9276 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9277 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9279 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9280 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9283 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9286 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9287 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9289 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9290 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9291 mode_value, "MAC-VLAN");
9292 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9294 mode_value, "Tunnel");
9295 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9298 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9299 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9300 mac_addr_byte_mask, UINT8);
9301 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9303 tunnel_type, "tunnel-type");
9304 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9305 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9306 tunnel_type_mask, UINT8);
9307 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9308 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9309 tunnel_id, "tunnel-id");
9310 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9311 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9312 tunnel_id_mask, UINT32);
9314 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9315 .f = cmd_flow_director_mask_parsed,
9317 .help_str = "flow_director_mask ... : "
9318 "Set IP mode flow director's mask on NIC",
9320 (void *)&cmd_flow_director_mask,
9321 (void *)&cmd_flow_director_mask_port_id,
9322 (void *)&cmd_flow_director_mask_mode,
9323 (void *)&cmd_flow_director_mask_mode_ip,
9324 (void *)&cmd_flow_director_mask_vlan,
9325 (void *)&cmd_flow_director_mask_vlan_value,
9326 (void *)&cmd_flow_director_mask_src,
9327 (void *)&cmd_flow_director_mask_ipv4_src,
9328 (void *)&cmd_flow_director_mask_ipv6_src,
9329 (void *)&cmd_flow_director_mask_port_src,
9330 (void *)&cmd_flow_director_mask_dst,
9331 (void *)&cmd_flow_director_mask_ipv4_dst,
9332 (void *)&cmd_flow_director_mask_ipv6_dst,
9333 (void *)&cmd_flow_director_mask_port_dst,
9338 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9339 .f = cmd_flow_director_mask_parsed,
9341 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9342 "flow director's mask on NIC",
9344 (void *)&cmd_flow_director_mask,
9345 (void *)&cmd_flow_director_mask_port_id,
9346 (void *)&cmd_flow_director_mask_mode,
9347 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9348 (void *)&cmd_flow_director_mask_vlan,
9349 (void *)&cmd_flow_director_mask_vlan_value,
9354 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9355 .f = cmd_flow_director_mask_parsed,
9357 .help_str = "flow_director_mask ... : Set tunnel mode "
9358 "flow director's mask on NIC",
9360 (void *)&cmd_flow_director_mask,
9361 (void *)&cmd_flow_director_mask_port_id,
9362 (void *)&cmd_flow_director_mask_mode,
9363 (void *)&cmd_flow_director_mask_mode_tunnel,
9364 (void *)&cmd_flow_director_mask_vlan,
9365 (void *)&cmd_flow_director_mask_vlan_value,
9366 (void *)&cmd_flow_director_mask_mac,
9367 (void *)&cmd_flow_director_mask_mac_value,
9368 (void *)&cmd_flow_director_mask_tunnel_type,
9369 (void *)&cmd_flow_director_mask_tunnel_type_value,
9370 (void *)&cmd_flow_director_mask_tunnel_id,
9371 (void *)&cmd_flow_director_mask_tunnel_id_value,
9376 /* *** deal with flow director mask on flexible payload *** */
9377 struct cmd_flow_director_flex_mask_result {
9378 cmdline_fixed_string_t flow_director_flexmask;
9380 cmdline_fixed_string_t flow;
9381 cmdline_fixed_string_t flow_type;
9382 cmdline_fixed_string_t mask;
9386 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9387 __attribute__((unused)) struct cmdline *cl,
9388 __attribute__((unused)) void *data)
9390 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9391 struct rte_eth_fdir_info fdir_info;
9392 struct rte_eth_fdir_flex_mask flex_mask;
9393 struct rte_port *port;
9394 uint32_t flow_type_mask;
9398 if (res->port_id > nb_ports) {
9399 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9403 port = &ports[res->port_id];
9404 /** Check if the port is not started **/
9405 if (port->port_status != RTE_PORT_STOPPED) {
9406 printf("Please stop port %d first\n", res->port_id);
9410 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9411 ret = parse_flexbytes(res->mask,
9413 RTE_ETH_FDIR_MAX_FLEXLEN);
9415 printf("error: Cannot parse mask input.\n");
9419 memset(&fdir_info, 0, sizeof(fdir_info));
9420 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9421 RTE_ETH_FILTER_INFO, &fdir_info);
9423 printf("Cannot get FDir filter info\n");
9427 if (!strcmp(res->flow_type, "none")) {
9428 /* means don't specify the flow type */
9429 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9430 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9431 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9432 0, sizeof(struct rte_eth_fdir_flex_mask));
9433 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9434 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9436 sizeof(struct rte_eth_fdir_flex_mask));
9437 cmd_reconfig_device_queue(res->port_id, 1, 1);
9440 flow_type_mask = fdir_info.flow_types_mask[0];
9441 if (!strcmp(res->flow_type, "all")) {
9442 if (!flow_type_mask) {
9443 printf("No flow type supported\n");
9446 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9447 if (flow_type_mask & (1 << i)) {
9448 flex_mask.flow_type = i;
9449 fdir_set_flex_mask(res->port_id, &flex_mask);
9452 cmd_reconfig_device_queue(res->port_id, 1, 1);
9455 flex_mask.flow_type = str2flowtype(res->flow_type);
9456 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9457 printf("Flow type %s not supported on port %d\n",
9458 res->flow_type, res->port_id);
9461 fdir_set_flex_mask(res->port_id, &flex_mask);
9462 cmd_reconfig_device_queue(res->port_id, 1, 1);
9465 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9466 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9467 flow_director_flexmask,
9468 "flow_director_flex_mask");
9469 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9470 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9472 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9475 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9476 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9477 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9478 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9479 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9480 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9483 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9484 .f = cmd_flow_director_flex_mask_parsed,
9486 .help_str = "flow_director_flex_mask ... : "
9487 "Set flow director's flex mask on NIC",
9489 (void *)&cmd_flow_director_flexmask,
9490 (void *)&cmd_flow_director_flexmask_port_id,
9491 (void *)&cmd_flow_director_flexmask_flow,
9492 (void *)&cmd_flow_director_flexmask_flow_type,
9493 (void *)&cmd_flow_director_flexmask_mask,
9498 /* *** deal with flow director flexible payload configuration *** */
9499 struct cmd_flow_director_flexpayload_result {
9500 cmdline_fixed_string_t flow_director_flexpayload;
9502 cmdline_fixed_string_t payload_layer;
9503 cmdline_fixed_string_t payload_cfg;
9507 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9510 const char *p, *p0 = q_arg;
9512 unsigned long int_fld;
9513 char *str_fld[max_num];
9518 p = strchr(p0, '(');
9522 p0 = strchr(p, ')');
9527 if (size >= sizeof(s))
9530 snprintf(s, sizeof(s), "%.*s", size, p);
9531 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9532 if (ret < 0 || ret > max_num)
9534 for (i = 0; i < ret; i++) {
9536 int_fld = strtoul(str_fld[i], &end, 0);
9537 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9539 offsets[i] = (uint16_t)int_fld;
9545 cmd_flow_director_flxpld_parsed(void *parsed_result,
9546 __attribute__((unused)) struct cmdline *cl,
9547 __attribute__((unused)) void *data)
9549 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9550 struct rte_eth_flex_payload_cfg flex_cfg;
9551 struct rte_port *port;
9554 if (res->port_id > nb_ports) {
9555 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9559 port = &ports[res->port_id];
9560 /** Check if the port is not started **/
9561 if (port->port_status != RTE_PORT_STOPPED) {
9562 printf("Please stop port %d first\n", res->port_id);
9566 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9568 if (!strcmp(res->payload_layer, "raw"))
9569 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9570 else if (!strcmp(res->payload_layer, "l2"))
9571 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9572 else if (!strcmp(res->payload_layer, "l3"))
9573 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9574 else if (!strcmp(res->payload_layer, "l4"))
9575 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9577 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9578 RTE_ETH_FDIR_MAX_FLEXLEN);
9580 printf("error: Cannot parse flex payload input.\n");
9584 fdir_set_flex_payload(res->port_id, &flex_cfg);
9585 cmd_reconfig_device_queue(res->port_id, 1, 1);
9588 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9589 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9590 flow_director_flexpayload,
9591 "flow_director_flex_payload");
9592 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9593 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9595 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9597 payload_layer, "raw#l2#l3#l4");
9598 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9602 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9603 .f = cmd_flow_director_flxpld_parsed,
9605 .help_str = "flow_director_flexpayload ... : "
9606 "Set flow director's flex payload on NIC",
9608 (void *)&cmd_flow_director_flexpayload,
9609 (void *)&cmd_flow_director_flexpayload_port_id,
9610 (void *)&cmd_flow_director_flexpayload_payload_layer,
9611 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9616 /* Generic flow interface command. */
9617 extern cmdline_parse_inst_t cmd_flow;
9619 /* *** Classification Filters Control *** */
9620 /* *** Get symmetric hash enable per port *** */
9621 struct cmd_get_sym_hash_ena_per_port_result {
9622 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9627 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9628 __rte_unused struct cmdline *cl,
9629 __rte_unused void *data)
9631 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9632 struct rte_eth_hash_filter_info info;
9635 if (rte_eth_dev_filter_supported(res->port_id,
9636 RTE_ETH_FILTER_HASH) < 0) {
9637 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9642 memset(&info, 0, sizeof(info));
9643 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9644 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9645 RTE_ETH_FILTER_GET, &info);
9648 printf("Cannot get symmetric hash enable per port "
9649 "on port %u\n", res->port_id);
9653 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9654 "enabled" : "disabled", res->port_id);
9657 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9658 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9659 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9660 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9661 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9664 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9665 .f = cmd_get_sym_hash_per_port_parsed,
9667 .help_str = "get_sym_hash_ena_per_port <port_id>",
9669 (void *)&cmd_get_sym_hash_ena_per_port_all,
9670 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9675 /* *** Set symmetric hash enable per port *** */
9676 struct cmd_set_sym_hash_ena_per_port_result {
9677 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9678 cmdline_fixed_string_t enable;
9683 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9684 __rte_unused struct cmdline *cl,
9685 __rte_unused void *data)
9687 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9688 struct rte_eth_hash_filter_info info;
9691 if (rte_eth_dev_filter_supported(res->port_id,
9692 RTE_ETH_FILTER_HASH) < 0) {
9693 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9698 memset(&info, 0, sizeof(info));
9699 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9700 if (!strcmp(res->enable, "enable"))
9701 info.info.enable = 1;
9702 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9703 RTE_ETH_FILTER_SET, &info);
9705 printf("Cannot set symmetric hash enable per port on "
9706 "port %u\n", res->port_id);
9709 printf("Symmetric hash has been set to %s on port %u\n",
9710 res->enable, res->port_id);
9713 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9714 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9715 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9716 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9717 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9719 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9720 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9721 enable, "enable#disable");
9723 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9724 .f = cmd_set_sym_hash_per_port_parsed,
9726 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9728 (void *)&cmd_set_sym_hash_ena_per_port_all,
9729 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9730 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9735 /* Get global config of hash function */
9736 struct cmd_get_hash_global_config_result {
9737 cmdline_fixed_string_t get_hash_global_config;
9742 flowtype_to_str(uint16_t ftype)
9749 {"ipv4", RTE_ETH_FLOW_IPV4},
9750 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9751 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9752 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9753 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9754 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9755 {"ipv6", RTE_ETH_FLOW_IPV6},
9756 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9757 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9758 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9759 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9760 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9761 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9762 {"port", RTE_ETH_FLOW_PORT},
9763 {"vxlan", RTE_ETH_FLOW_VXLAN},
9764 {"geneve", RTE_ETH_FLOW_GENEVE},
9765 {"nvgre", RTE_ETH_FLOW_NVGRE},
9768 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9769 if (ftype_table[i].ftype == ftype)
9770 return ftype_table[i].str;
9777 cmd_get_hash_global_config_parsed(void *parsed_result,
9778 __rte_unused struct cmdline *cl,
9779 __rte_unused void *data)
9781 struct cmd_get_hash_global_config_result *res = parsed_result;
9782 struct rte_eth_hash_filter_info info;
9783 uint32_t idx, offset;
9788 if (rte_eth_dev_filter_supported(res->port_id,
9789 RTE_ETH_FILTER_HASH) < 0) {
9790 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9795 memset(&info, 0, sizeof(info));
9796 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9797 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9798 RTE_ETH_FILTER_GET, &info);
9800 printf("Cannot get hash global configurations by port %d\n",
9805 switch (info.info.global_conf.hash_func) {
9806 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9807 printf("Hash function is Toeplitz\n");
9809 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9810 printf("Hash function is Simple XOR\n");
9813 printf("Unknown hash function\n");
9817 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9818 idx = i / UINT32_BIT;
9819 offset = i % UINT32_BIT;
9820 if (!(info.info.global_conf.valid_bit_mask[idx] &
9823 str = flowtype_to_str(i);
9826 printf("Symmetric hash is %s globally for flow type %s "
9828 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9829 (1UL << offset)) ? "enabled" : "disabled"), str,
9834 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9835 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9836 get_hash_global_config, "get_hash_global_config");
9837 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9838 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9841 cmdline_parse_inst_t cmd_get_hash_global_config = {
9842 .f = cmd_get_hash_global_config_parsed,
9844 .help_str = "get_hash_global_config <port_id>",
9846 (void *)&cmd_get_hash_global_config_all,
9847 (void *)&cmd_get_hash_global_config_port_id,
9852 /* Set global config of hash function */
9853 struct cmd_set_hash_global_config_result {
9854 cmdline_fixed_string_t set_hash_global_config;
9856 cmdline_fixed_string_t hash_func;
9857 cmdline_fixed_string_t flow_type;
9858 cmdline_fixed_string_t enable;
9862 cmd_set_hash_global_config_parsed(void *parsed_result,
9863 __rte_unused struct cmdline *cl,
9864 __rte_unused void *data)
9866 struct cmd_set_hash_global_config_result *res = parsed_result;
9867 struct rte_eth_hash_filter_info info;
9868 uint32_t ftype, idx, offset;
9871 if (rte_eth_dev_filter_supported(res->port_id,
9872 RTE_ETH_FILTER_HASH) < 0) {
9873 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9877 memset(&info, 0, sizeof(info));
9878 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9879 if (!strcmp(res->hash_func, "toeplitz"))
9880 info.info.global_conf.hash_func =
9881 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9882 else if (!strcmp(res->hash_func, "simple_xor"))
9883 info.info.global_conf.hash_func =
9884 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9885 else if (!strcmp(res->hash_func, "default"))
9886 info.info.global_conf.hash_func =
9887 RTE_ETH_HASH_FUNCTION_DEFAULT;
9889 ftype = str2flowtype(res->flow_type);
9890 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9891 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9892 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9893 if (!strcmp(res->enable, "enable"))
9894 info.info.global_conf.sym_hash_enable_mask[idx] |=
9896 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9897 RTE_ETH_FILTER_SET, &info);
9899 printf("Cannot set global hash configurations by port %d\n",
9902 printf("Global hash configurations have been set "
9903 "succcessfully by port %d\n", res->port_id);
9906 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9907 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9908 set_hash_global_config, "set_hash_global_config");
9909 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9910 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9912 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9913 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9914 hash_func, "toeplitz#simple_xor#default");
9915 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9916 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9918 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9919 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9920 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9921 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9922 enable, "enable#disable");
9924 cmdline_parse_inst_t cmd_set_hash_global_config = {
9925 .f = cmd_set_hash_global_config_parsed,
9927 .help_str = "set_hash_global_config <port_id> "
9928 "toeplitz|simple_xor|default "
9929 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9930 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9931 "l2_payload enable|disable",
9933 (void *)&cmd_set_hash_global_config_all,
9934 (void *)&cmd_set_hash_global_config_port_id,
9935 (void *)&cmd_set_hash_global_config_hash_func,
9936 (void *)&cmd_set_hash_global_config_flow_type,
9937 (void *)&cmd_set_hash_global_config_enable,
9942 /* Set hash input set */
9943 struct cmd_set_hash_input_set_result {
9944 cmdline_fixed_string_t set_hash_input_set;
9946 cmdline_fixed_string_t flow_type;
9947 cmdline_fixed_string_t inset_field;
9948 cmdline_fixed_string_t select;
9951 static enum rte_eth_input_set_field
9952 str2inset(char *string)
9956 static const struct {
9958 enum rte_eth_input_set_field inset;
9960 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9961 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9962 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9963 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9964 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9965 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9966 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9967 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9968 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9969 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9970 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9971 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9972 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9973 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9974 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9975 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9976 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9977 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9978 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9979 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9980 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9981 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9982 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9983 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9984 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9985 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9986 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9987 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9988 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9989 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9990 {"none", RTE_ETH_INPUT_SET_NONE},
9993 for (i = 0; i < RTE_DIM(inset_table); i++) {
9994 if (!strcmp(string, inset_table[i].str))
9995 return inset_table[i].inset;
9998 return RTE_ETH_INPUT_SET_UNKNOWN;
10002 cmd_set_hash_input_set_parsed(void *parsed_result,
10003 __rte_unused struct cmdline *cl,
10004 __rte_unused void *data)
10006 struct cmd_set_hash_input_set_result *res = parsed_result;
10007 struct rte_eth_hash_filter_info info;
10009 memset(&info, 0, sizeof(info));
10010 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10011 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10012 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10013 info.info.input_set_conf.inset_size = 1;
10014 if (!strcmp(res->select, "select"))
10015 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10016 else if (!strcmp(res->select, "add"))
10017 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10018 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10019 RTE_ETH_FILTER_SET, &info);
10022 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10023 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10024 set_hash_input_set, "set_hash_input_set");
10025 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10026 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10028 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10029 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10031 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10032 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10033 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10034 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10036 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10037 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10038 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10039 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10040 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10042 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10043 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10044 select, "select#add");
10046 cmdline_parse_inst_t cmd_set_hash_input_set = {
10047 .f = cmd_set_hash_input_set_parsed,
10049 .help_str = "set_hash_input_set <port_id> "
10050 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10051 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10052 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10053 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10054 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10055 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10056 "fld-7th|fld-8th|none select|add",
10058 (void *)&cmd_set_hash_input_set_cmd,
10059 (void *)&cmd_set_hash_input_set_port_id,
10060 (void *)&cmd_set_hash_input_set_flow_type,
10061 (void *)&cmd_set_hash_input_set_field,
10062 (void *)&cmd_set_hash_input_set_select,
10067 /* Set flow director input set */
10068 struct cmd_set_fdir_input_set_result {
10069 cmdline_fixed_string_t set_fdir_input_set;
10071 cmdline_fixed_string_t flow_type;
10072 cmdline_fixed_string_t inset_field;
10073 cmdline_fixed_string_t select;
10077 cmd_set_fdir_input_set_parsed(void *parsed_result,
10078 __rte_unused struct cmdline *cl,
10079 __rte_unused void *data)
10081 struct cmd_set_fdir_input_set_result *res = parsed_result;
10082 struct rte_eth_fdir_filter_info info;
10084 memset(&info, 0, sizeof(info));
10085 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10086 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10087 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10088 info.info.input_set_conf.inset_size = 1;
10089 if (!strcmp(res->select, "select"))
10090 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10091 else if (!strcmp(res->select, "add"))
10092 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10093 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10094 RTE_ETH_FILTER_SET, &info);
10097 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10098 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10099 set_fdir_input_set, "set_fdir_input_set");
10100 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10101 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10103 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10104 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10106 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10107 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10108 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10109 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10111 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10112 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10113 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10114 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10115 "sctp-veri-tag#none");
10116 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10117 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10118 select, "select#add");
10120 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10121 .f = cmd_set_fdir_input_set_parsed,
10123 .help_str = "set_fdir_input_set <port_id> "
10124 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10125 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10126 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10127 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10128 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10129 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10130 "sctp-veri-tag|none select|add",
10132 (void *)&cmd_set_fdir_input_set_cmd,
10133 (void *)&cmd_set_fdir_input_set_port_id,
10134 (void *)&cmd_set_fdir_input_set_flow_type,
10135 (void *)&cmd_set_fdir_input_set_field,
10136 (void *)&cmd_set_fdir_input_set_select,
10141 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10142 struct cmd_mcast_addr_result {
10143 cmdline_fixed_string_t mcast_addr_cmd;
10144 cmdline_fixed_string_t what;
10146 struct ether_addr mc_addr;
10149 static void cmd_mcast_addr_parsed(void *parsed_result,
10150 __attribute__((unused)) struct cmdline *cl,
10151 __attribute__((unused)) void *data)
10153 struct cmd_mcast_addr_result *res = parsed_result;
10155 if (!is_multicast_ether_addr(&res->mc_addr)) {
10156 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10157 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10158 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10159 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10162 if (strcmp(res->what, "add") == 0)
10163 mcast_addr_add(res->port_num, &res->mc_addr);
10165 mcast_addr_remove(res->port_num, &res->mc_addr);
10168 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10169 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10170 mcast_addr_cmd, "mcast_addr");
10171 cmdline_parse_token_string_t cmd_mcast_addr_what =
10172 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10174 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10175 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10176 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10177 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10179 cmdline_parse_inst_t cmd_mcast_addr = {
10180 .f = cmd_mcast_addr_parsed,
10182 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10183 "Add/Remove multicast MAC address on port_id",
10185 (void *)&cmd_mcast_addr_cmd,
10186 (void *)&cmd_mcast_addr_what,
10187 (void *)&cmd_mcast_addr_portnum,
10188 (void *)&cmd_mcast_addr_addr,
10193 /* l2 tunnel config
10194 * only support E-tag now.
10197 /* Ether type config */
10198 struct cmd_config_l2_tunnel_eth_type_result {
10199 cmdline_fixed_string_t port;
10200 cmdline_fixed_string_t config;
10201 cmdline_fixed_string_t all;
10203 cmdline_fixed_string_t l2_tunnel;
10204 cmdline_fixed_string_t l2_tunnel_type;
10205 cmdline_fixed_string_t eth_type;
10206 uint16_t eth_type_val;
10209 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10210 TOKEN_STRING_INITIALIZER
10211 (struct cmd_config_l2_tunnel_eth_type_result,
10213 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10214 TOKEN_STRING_INITIALIZER
10215 (struct cmd_config_l2_tunnel_eth_type_result,
10217 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10218 TOKEN_STRING_INITIALIZER
10219 (struct cmd_config_l2_tunnel_eth_type_result,
10221 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10222 TOKEN_NUM_INITIALIZER
10223 (struct cmd_config_l2_tunnel_eth_type_result,
10225 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10226 TOKEN_STRING_INITIALIZER
10227 (struct cmd_config_l2_tunnel_eth_type_result,
10228 l2_tunnel, "l2-tunnel");
10229 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10230 TOKEN_STRING_INITIALIZER
10231 (struct cmd_config_l2_tunnel_eth_type_result,
10232 l2_tunnel_type, "E-tag");
10233 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10234 TOKEN_STRING_INITIALIZER
10235 (struct cmd_config_l2_tunnel_eth_type_result,
10236 eth_type, "ether-type");
10237 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10238 TOKEN_NUM_INITIALIZER
10239 (struct cmd_config_l2_tunnel_eth_type_result,
10240 eth_type_val, UINT16);
10242 static enum rte_eth_tunnel_type
10243 str2fdir_l2_tunnel_type(char *string)
10247 static const struct {
10249 enum rte_eth_tunnel_type type;
10250 } l2_tunnel_type_str[] = {
10251 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10254 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10255 if (!strcmp(l2_tunnel_type_str[i].str, string))
10256 return l2_tunnel_type_str[i].type;
10258 return RTE_TUNNEL_TYPE_NONE;
10261 /* ether type config for all ports */
10263 cmd_config_l2_tunnel_eth_type_all_parsed
10264 (void *parsed_result,
10265 __attribute__((unused)) struct cmdline *cl,
10266 __attribute__((unused)) void *data)
10268 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10269 struct rte_eth_l2_tunnel_conf entry;
10272 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10273 entry.ether_type = res->eth_type_val;
10275 FOREACH_PORT(pid, ports) {
10276 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10280 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10281 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10283 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10285 (void *)&cmd_config_l2_tunnel_eth_type_port,
10286 (void *)&cmd_config_l2_tunnel_eth_type_config,
10287 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10288 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10289 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10290 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10291 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10296 /* ether type config for a specific port */
10298 cmd_config_l2_tunnel_eth_type_specific_parsed(
10299 void *parsed_result,
10300 __attribute__((unused)) struct cmdline *cl,
10301 __attribute__((unused)) void *data)
10303 struct cmd_config_l2_tunnel_eth_type_result *res =
10305 struct rte_eth_l2_tunnel_conf entry;
10307 if (port_id_is_invalid(res->id, ENABLED_WARN))
10310 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10311 entry.ether_type = res->eth_type_val;
10313 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10316 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10317 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10319 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10321 (void *)&cmd_config_l2_tunnel_eth_type_port,
10322 (void *)&cmd_config_l2_tunnel_eth_type_config,
10323 (void *)&cmd_config_l2_tunnel_eth_type_id,
10324 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10325 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10326 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10327 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10332 /* Enable/disable l2 tunnel */
10333 struct cmd_config_l2_tunnel_en_dis_result {
10334 cmdline_fixed_string_t port;
10335 cmdline_fixed_string_t config;
10336 cmdline_fixed_string_t all;
10338 cmdline_fixed_string_t l2_tunnel;
10339 cmdline_fixed_string_t l2_tunnel_type;
10340 cmdline_fixed_string_t en_dis;
10343 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10344 TOKEN_STRING_INITIALIZER
10345 (struct cmd_config_l2_tunnel_en_dis_result,
10347 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10348 TOKEN_STRING_INITIALIZER
10349 (struct cmd_config_l2_tunnel_en_dis_result,
10351 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10352 TOKEN_STRING_INITIALIZER
10353 (struct cmd_config_l2_tunnel_en_dis_result,
10355 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10356 TOKEN_NUM_INITIALIZER
10357 (struct cmd_config_l2_tunnel_en_dis_result,
10359 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10360 TOKEN_STRING_INITIALIZER
10361 (struct cmd_config_l2_tunnel_en_dis_result,
10362 l2_tunnel, "l2-tunnel");
10363 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10364 TOKEN_STRING_INITIALIZER
10365 (struct cmd_config_l2_tunnel_en_dis_result,
10366 l2_tunnel_type, "E-tag");
10367 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10368 TOKEN_STRING_INITIALIZER
10369 (struct cmd_config_l2_tunnel_en_dis_result,
10370 en_dis, "enable#disable");
10372 /* enable/disable l2 tunnel for all ports */
10374 cmd_config_l2_tunnel_en_dis_all_parsed(
10375 void *parsed_result,
10376 __attribute__((unused)) struct cmdline *cl,
10377 __attribute__((unused)) void *data)
10379 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10380 struct rte_eth_l2_tunnel_conf entry;
10384 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10386 if (!strcmp("enable", res->en_dis))
10391 FOREACH_PORT(pid, ports) {
10392 rte_eth_dev_l2_tunnel_offload_set(pid,
10394 ETH_L2_TUNNEL_ENABLE_MASK,
10399 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10400 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10402 .help_str = "port config all l2-tunnel E-tag enable|disable",
10404 (void *)&cmd_config_l2_tunnel_en_dis_port,
10405 (void *)&cmd_config_l2_tunnel_en_dis_config,
10406 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10407 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10408 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10409 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10414 /* enable/disable l2 tunnel for a port */
10416 cmd_config_l2_tunnel_en_dis_specific_parsed(
10417 void *parsed_result,
10418 __attribute__((unused)) struct cmdline *cl,
10419 __attribute__((unused)) void *data)
10421 struct cmd_config_l2_tunnel_en_dis_result *res =
10423 struct rte_eth_l2_tunnel_conf entry;
10425 if (port_id_is_invalid(res->id, ENABLED_WARN))
10428 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10430 if (!strcmp("enable", res->en_dis))
10431 rte_eth_dev_l2_tunnel_offload_set(res->id,
10433 ETH_L2_TUNNEL_ENABLE_MASK,
10436 rte_eth_dev_l2_tunnel_offload_set(res->id,
10438 ETH_L2_TUNNEL_ENABLE_MASK,
10442 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10443 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10445 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10447 (void *)&cmd_config_l2_tunnel_en_dis_port,
10448 (void *)&cmd_config_l2_tunnel_en_dis_config,
10449 (void *)&cmd_config_l2_tunnel_en_dis_id,
10450 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10451 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10452 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10457 /* E-tag configuration */
10459 /* Common result structure for all E-tag configuration */
10460 struct cmd_config_e_tag_result {
10461 cmdline_fixed_string_t e_tag;
10462 cmdline_fixed_string_t set;
10463 cmdline_fixed_string_t insertion;
10464 cmdline_fixed_string_t stripping;
10465 cmdline_fixed_string_t forwarding;
10466 cmdline_fixed_string_t filter;
10467 cmdline_fixed_string_t add;
10468 cmdline_fixed_string_t del;
10469 cmdline_fixed_string_t on;
10470 cmdline_fixed_string_t off;
10471 cmdline_fixed_string_t on_off;
10472 cmdline_fixed_string_t port_tag_id;
10473 uint32_t port_tag_id_val;
10474 cmdline_fixed_string_t e_tag_id;
10475 uint16_t e_tag_id_val;
10476 cmdline_fixed_string_t dst_pool;
10477 uint8_t dst_pool_val;
10478 cmdline_fixed_string_t port;
10480 cmdline_fixed_string_t vf;
10484 /* Common CLI fields for all E-tag configuration */
10485 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10486 TOKEN_STRING_INITIALIZER
10487 (struct cmd_config_e_tag_result,
10489 cmdline_parse_token_string_t cmd_config_e_tag_set =
10490 TOKEN_STRING_INITIALIZER
10491 (struct cmd_config_e_tag_result,
10493 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10494 TOKEN_STRING_INITIALIZER
10495 (struct cmd_config_e_tag_result,
10496 insertion, "insertion");
10497 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10498 TOKEN_STRING_INITIALIZER
10499 (struct cmd_config_e_tag_result,
10500 stripping, "stripping");
10501 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10502 TOKEN_STRING_INITIALIZER
10503 (struct cmd_config_e_tag_result,
10504 forwarding, "forwarding");
10505 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10506 TOKEN_STRING_INITIALIZER
10507 (struct cmd_config_e_tag_result,
10509 cmdline_parse_token_string_t cmd_config_e_tag_add =
10510 TOKEN_STRING_INITIALIZER
10511 (struct cmd_config_e_tag_result,
10513 cmdline_parse_token_string_t cmd_config_e_tag_del =
10514 TOKEN_STRING_INITIALIZER
10515 (struct cmd_config_e_tag_result,
10517 cmdline_parse_token_string_t cmd_config_e_tag_on =
10518 TOKEN_STRING_INITIALIZER
10519 (struct cmd_config_e_tag_result,
10521 cmdline_parse_token_string_t cmd_config_e_tag_off =
10522 TOKEN_STRING_INITIALIZER
10523 (struct cmd_config_e_tag_result,
10525 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10526 TOKEN_STRING_INITIALIZER
10527 (struct cmd_config_e_tag_result,
10529 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10530 TOKEN_STRING_INITIALIZER
10531 (struct cmd_config_e_tag_result,
10532 port_tag_id, "port-tag-id");
10533 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10534 TOKEN_NUM_INITIALIZER
10535 (struct cmd_config_e_tag_result,
10536 port_tag_id_val, UINT32);
10537 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10538 TOKEN_STRING_INITIALIZER
10539 (struct cmd_config_e_tag_result,
10540 e_tag_id, "e-tag-id");
10541 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10542 TOKEN_NUM_INITIALIZER
10543 (struct cmd_config_e_tag_result,
10544 e_tag_id_val, UINT16);
10545 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10546 TOKEN_STRING_INITIALIZER
10547 (struct cmd_config_e_tag_result,
10548 dst_pool, "dst-pool");
10549 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10550 TOKEN_NUM_INITIALIZER
10551 (struct cmd_config_e_tag_result,
10552 dst_pool_val, UINT8);
10553 cmdline_parse_token_string_t cmd_config_e_tag_port =
10554 TOKEN_STRING_INITIALIZER
10555 (struct cmd_config_e_tag_result,
10557 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10558 TOKEN_NUM_INITIALIZER
10559 (struct cmd_config_e_tag_result,
10561 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10562 TOKEN_STRING_INITIALIZER
10563 (struct cmd_config_e_tag_result,
10565 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10566 TOKEN_NUM_INITIALIZER
10567 (struct cmd_config_e_tag_result,
10570 /* E-tag insertion configuration */
10572 cmd_config_e_tag_insertion_en_parsed(
10573 void *parsed_result,
10574 __attribute__((unused)) struct cmdline *cl,
10575 __attribute__((unused)) void *data)
10577 struct cmd_config_e_tag_result *res =
10579 struct rte_eth_l2_tunnel_conf entry;
10581 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10584 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10585 entry.tunnel_id = res->port_tag_id_val;
10586 entry.vf_id = res->vf_id;
10587 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10589 ETH_L2_TUNNEL_INSERTION_MASK,
10594 cmd_config_e_tag_insertion_dis_parsed(
10595 void *parsed_result,
10596 __attribute__((unused)) struct cmdline *cl,
10597 __attribute__((unused)) void *data)
10599 struct cmd_config_e_tag_result *res =
10601 struct rte_eth_l2_tunnel_conf entry;
10603 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10606 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10607 entry.vf_id = res->vf_id;
10609 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10611 ETH_L2_TUNNEL_INSERTION_MASK,
10615 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10616 .f = cmd_config_e_tag_insertion_en_parsed,
10618 .help_str = "E-tag ... : E-tag insertion enable",
10620 (void *)&cmd_config_e_tag_e_tag,
10621 (void *)&cmd_config_e_tag_set,
10622 (void *)&cmd_config_e_tag_insertion,
10623 (void *)&cmd_config_e_tag_on,
10624 (void *)&cmd_config_e_tag_port_tag_id,
10625 (void *)&cmd_config_e_tag_port_tag_id_val,
10626 (void *)&cmd_config_e_tag_port,
10627 (void *)&cmd_config_e_tag_port_id,
10628 (void *)&cmd_config_e_tag_vf,
10629 (void *)&cmd_config_e_tag_vf_id,
10634 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10635 .f = cmd_config_e_tag_insertion_dis_parsed,
10637 .help_str = "E-tag ... : E-tag insertion disable",
10639 (void *)&cmd_config_e_tag_e_tag,
10640 (void *)&cmd_config_e_tag_set,
10641 (void *)&cmd_config_e_tag_insertion,
10642 (void *)&cmd_config_e_tag_off,
10643 (void *)&cmd_config_e_tag_port,
10644 (void *)&cmd_config_e_tag_port_id,
10645 (void *)&cmd_config_e_tag_vf,
10646 (void *)&cmd_config_e_tag_vf_id,
10651 /* E-tag stripping configuration */
10653 cmd_config_e_tag_stripping_parsed(
10654 void *parsed_result,
10655 __attribute__((unused)) struct cmdline *cl,
10656 __attribute__((unused)) void *data)
10658 struct cmd_config_e_tag_result *res =
10660 struct rte_eth_l2_tunnel_conf entry;
10662 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10665 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10667 if (!strcmp(res->on_off, "on"))
10668 rte_eth_dev_l2_tunnel_offload_set
10671 ETH_L2_TUNNEL_STRIPPING_MASK,
10674 rte_eth_dev_l2_tunnel_offload_set
10677 ETH_L2_TUNNEL_STRIPPING_MASK,
10681 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10682 .f = cmd_config_e_tag_stripping_parsed,
10684 .help_str = "E-tag ... : E-tag stripping enable/disable",
10686 (void *)&cmd_config_e_tag_e_tag,
10687 (void *)&cmd_config_e_tag_set,
10688 (void *)&cmd_config_e_tag_stripping,
10689 (void *)&cmd_config_e_tag_on_off,
10690 (void *)&cmd_config_e_tag_port,
10691 (void *)&cmd_config_e_tag_port_id,
10696 /* E-tag forwarding configuration */
10698 cmd_config_e_tag_forwarding_parsed(
10699 void *parsed_result,
10700 __attribute__((unused)) struct cmdline *cl,
10701 __attribute__((unused)) void *data)
10703 struct cmd_config_e_tag_result *res = parsed_result;
10704 struct rte_eth_l2_tunnel_conf entry;
10706 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10709 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10711 if (!strcmp(res->on_off, "on"))
10712 rte_eth_dev_l2_tunnel_offload_set
10715 ETH_L2_TUNNEL_FORWARDING_MASK,
10718 rte_eth_dev_l2_tunnel_offload_set
10721 ETH_L2_TUNNEL_FORWARDING_MASK,
10725 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10726 .f = cmd_config_e_tag_forwarding_parsed,
10728 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10730 (void *)&cmd_config_e_tag_e_tag,
10731 (void *)&cmd_config_e_tag_set,
10732 (void *)&cmd_config_e_tag_forwarding,
10733 (void *)&cmd_config_e_tag_on_off,
10734 (void *)&cmd_config_e_tag_port,
10735 (void *)&cmd_config_e_tag_port_id,
10740 /* E-tag filter configuration */
10742 cmd_config_e_tag_filter_add_parsed(
10743 void *parsed_result,
10744 __attribute__((unused)) struct cmdline *cl,
10745 __attribute__((unused)) void *data)
10747 struct cmd_config_e_tag_result *res = parsed_result;
10748 struct rte_eth_l2_tunnel_conf entry;
10751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10754 if (res->e_tag_id_val > 0x3fff) {
10755 printf("e-tag-id must be equal or less than 0x3fff.\n");
10759 ret = rte_eth_dev_filter_supported(res->port_id,
10760 RTE_ETH_FILTER_L2_TUNNEL);
10762 printf("E-tag filter is not supported on port %u.\n",
10767 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10768 entry.tunnel_id = res->e_tag_id_val;
10769 entry.pool = res->dst_pool_val;
10771 ret = rte_eth_dev_filter_ctrl(res->port_id,
10772 RTE_ETH_FILTER_L2_TUNNEL,
10773 RTE_ETH_FILTER_ADD,
10776 printf("E-tag filter programming error: (%s)\n",
10780 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10781 .f = cmd_config_e_tag_filter_add_parsed,
10783 .help_str = "E-tag ... : E-tag filter add",
10785 (void *)&cmd_config_e_tag_e_tag,
10786 (void *)&cmd_config_e_tag_set,
10787 (void *)&cmd_config_e_tag_filter,
10788 (void *)&cmd_config_e_tag_add,
10789 (void *)&cmd_config_e_tag_e_tag_id,
10790 (void *)&cmd_config_e_tag_e_tag_id_val,
10791 (void *)&cmd_config_e_tag_dst_pool,
10792 (void *)&cmd_config_e_tag_dst_pool_val,
10793 (void *)&cmd_config_e_tag_port,
10794 (void *)&cmd_config_e_tag_port_id,
10800 cmd_config_e_tag_filter_del_parsed(
10801 void *parsed_result,
10802 __attribute__((unused)) struct cmdline *cl,
10803 __attribute__((unused)) void *data)
10805 struct cmd_config_e_tag_result *res = parsed_result;
10806 struct rte_eth_l2_tunnel_conf entry;
10809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10812 if (res->e_tag_id_val > 0x3fff) {
10813 printf("e-tag-id must be less than 0x3fff.\n");
10817 ret = rte_eth_dev_filter_supported(res->port_id,
10818 RTE_ETH_FILTER_L2_TUNNEL);
10820 printf("E-tag filter is not supported on port %u.\n",
10825 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10826 entry.tunnel_id = res->e_tag_id_val;
10828 ret = rte_eth_dev_filter_ctrl(res->port_id,
10829 RTE_ETH_FILTER_L2_TUNNEL,
10830 RTE_ETH_FILTER_DELETE,
10833 printf("E-tag filter programming error: (%s)\n",
10837 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10838 .f = cmd_config_e_tag_filter_del_parsed,
10840 .help_str = "E-tag ... : E-tag filter delete",
10842 (void *)&cmd_config_e_tag_e_tag,
10843 (void *)&cmd_config_e_tag_set,
10844 (void *)&cmd_config_e_tag_filter,
10845 (void *)&cmd_config_e_tag_del,
10846 (void *)&cmd_config_e_tag_e_tag_id,
10847 (void *)&cmd_config_e_tag_e_tag_id_val,
10848 (void *)&cmd_config_e_tag_port,
10849 (void *)&cmd_config_e_tag_port_id,
10854 /* vf vlan anti spoof configuration */
10856 /* Common result structure for vf vlan anti spoof */
10857 struct cmd_vf_vlan_anti_spoof_result {
10858 cmdline_fixed_string_t set;
10859 cmdline_fixed_string_t vf;
10860 cmdline_fixed_string_t vlan;
10861 cmdline_fixed_string_t antispoof;
10864 cmdline_fixed_string_t on_off;
10867 /* Common CLI fields for vf vlan anti spoof enable disable */
10868 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10869 TOKEN_STRING_INITIALIZER
10870 (struct cmd_vf_vlan_anti_spoof_result,
10872 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10873 TOKEN_STRING_INITIALIZER
10874 (struct cmd_vf_vlan_anti_spoof_result,
10876 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10877 TOKEN_STRING_INITIALIZER
10878 (struct cmd_vf_vlan_anti_spoof_result,
10880 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10881 TOKEN_STRING_INITIALIZER
10882 (struct cmd_vf_vlan_anti_spoof_result,
10883 antispoof, "antispoof");
10884 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10885 TOKEN_NUM_INITIALIZER
10886 (struct cmd_vf_vlan_anti_spoof_result,
10888 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10889 TOKEN_NUM_INITIALIZER
10890 (struct cmd_vf_vlan_anti_spoof_result,
10892 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10893 TOKEN_STRING_INITIALIZER
10894 (struct cmd_vf_vlan_anti_spoof_result,
10898 cmd_set_vf_vlan_anti_spoof_parsed(
10899 void *parsed_result,
10900 __attribute__((unused)) struct cmdline *cl,
10901 __attribute__((unused)) void *data)
10903 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10904 int ret = -ENOTSUP;
10906 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10911 #ifdef RTE_LIBRTE_IXGBE_PMD
10912 if (ret == -ENOTSUP)
10913 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10914 res->vf_id, is_on);
10916 #ifdef RTE_LIBRTE_I40E_PMD
10917 if (ret == -ENOTSUP)
10918 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10919 res->vf_id, is_on);
10926 printf("invalid vf_id %d\n", res->vf_id);
10929 printf("invalid port_id %d\n", res->port_id);
10932 printf("function not implemented\n");
10935 printf("programming error: (%s)\n", strerror(-ret));
10939 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10940 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10942 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10944 (void *)&cmd_vf_vlan_anti_spoof_set,
10945 (void *)&cmd_vf_vlan_anti_spoof_vf,
10946 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10947 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10948 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10949 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10950 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10955 /* vf mac anti spoof configuration */
10957 /* Common result structure for vf mac anti spoof */
10958 struct cmd_vf_mac_anti_spoof_result {
10959 cmdline_fixed_string_t set;
10960 cmdline_fixed_string_t vf;
10961 cmdline_fixed_string_t mac;
10962 cmdline_fixed_string_t antispoof;
10965 cmdline_fixed_string_t on_off;
10968 /* Common CLI fields for vf mac anti spoof enable disable */
10969 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10970 TOKEN_STRING_INITIALIZER
10971 (struct cmd_vf_mac_anti_spoof_result,
10973 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10974 TOKEN_STRING_INITIALIZER
10975 (struct cmd_vf_mac_anti_spoof_result,
10977 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10978 TOKEN_STRING_INITIALIZER
10979 (struct cmd_vf_mac_anti_spoof_result,
10981 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10982 TOKEN_STRING_INITIALIZER
10983 (struct cmd_vf_mac_anti_spoof_result,
10984 antispoof, "antispoof");
10985 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10986 TOKEN_NUM_INITIALIZER
10987 (struct cmd_vf_mac_anti_spoof_result,
10989 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10990 TOKEN_NUM_INITIALIZER
10991 (struct cmd_vf_mac_anti_spoof_result,
10993 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10994 TOKEN_STRING_INITIALIZER
10995 (struct cmd_vf_mac_anti_spoof_result,
10999 cmd_set_vf_mac_anti_spoof_parsed(
11000 void *parsed_result,
11001 __attribute__((unused)) struct cmdline *cl,
11002 __attribute__((unused)) void *data)
11004 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11005 int ret = -ENOTSUP;
11007 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11009 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11012 #ifdef RTE_LIBRTE_IXGBE_PMD
11013 if (ret == -ENOTSUP)
11014 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11015 res->vf_id, is_on);
11017 #ifdef RTE_LIBRTE_I40E_PMD
11018 if (ret == -ENOTSUP)
11019 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11020 res->vf_id, is_on);
11027 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11030 printf("invalid port_id %d\n", res->port_id);
11033 printf("function not implemented\n");
11036 printf("programming error: (%s)\n", strerror(-ret));
11040 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11041 .f = cmd_set_vf_mac_anti_spoof_parsed,
11043 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11045 (void *)&cmd_vf_mac_anti_spoof_set,
11046 (void *)&cmd_vf_mac_anti_spoof_vf,
11047 (void *)&cmd_vf_mac_anti_spoof_mac,
11048 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11049 (void *)&cmd_vf_mac_anti_spoof_port_id,
11050 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11051 (void *)&cmd_vf_mac_anti_spoof_on_off,
11056 /* vf vlan strip queue configuration */
11058 /* Common result structure for vf mac anti spoof */
11059 struct cmd_vf_vlan_stripq_result {
11060 cmdline_fixed_string_t set;
11061 cmdline_fixed_string_t vf;
11062 cmdline_fixed_string_t vlan;
11063 cmdline_fixed_string_t stripq;
11066 cmdline_fixed_string_t on_off;
11069 /* Common CLI fields for vf vlan strip enable disable */
11070 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11071 TOKEN_STRING_INITIALIZER
11072 (struct cmd_vf_vlan_stripq_result,
11074 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11075 TOKEN_STRING_INITIALIZER
11076 (struct cmd_vf_vlan_stripq_result,
11078 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11079 TOKEN_STRING_INITIALIZER
11080 (struct cmd_vf_vlan_stripq_result,
11082 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11083 TOKEN_STRING_INITIALIZER
11084 (struct cmd_vf_vlan_stripq_result,
11086 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11087 TOKEN_NUM_INITIALIZER
11088 (struct cmd_vf_vlan_stripq_result,
11090 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11091 TOKEN_NUM_INITIALIZER
11092 (struct cmd_vf_vlan_stripq_result,
11094 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11095 TOKEN_STRING_INITIALIZER
11096 (struct cmd_vf_vlan_stripq_result,
11100 cmd_set_vf_vlan_stripq_parsed(
11101 void *parsed_result,
11102 __attribute__((unused)) struct cmdline *cl,
11103 __attribute__((unused)) void *data)
11105 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11106 int ret = -ENOTSUP;
11108 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11110 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11113 #ifdef RTE_LIBRTE_IXGBE_PMD
11114 if (ret == -ENOTSUP)
11115 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11116 res->vf_id, is_on);
11118 #ifdef RTE_LIBRTE_I40E_PMD
11119 if (ret == -ENOTSUP)
11120 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11121 res->vf_id, is_on);
11128 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11131 printf("invalid port_id %d\n", res->port_id);
11134 printf("function not implemented\n");
11137 printf("programming error: (%s)\n", strerror(-ret));
11141 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11142 .f = cmd_set_vf_vlan_stripq_parsed,
11144 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11146 (void *)&cmd_vf_vlan_stripq_set,
11147 (void *)&cmd_vf_vlan_stripq_vf,
11148 (void *)&cmd_vf_vlan_stripq_vlan,
11149 (void *)&cmd_vf_vlan_stripq_stripq,
11150 (void *)&cmd_vf_vlan_stripq_port_id,
11151 (void *)&cmd_vf_vlan_stripq_vf_id,
11152 (void *)&cmd_vf_vlan_stripq_on_off,
11157 /* vf vlan insert configuration */
11159 /* Common result structure for vf vlan insert */
11160 struct cmd_vf_vlan_insert_result {
11161 cmdline_fixed_string_t set;
11162 cmdline_fixed_string_t vf;
11163 cmdline_fixed_string_t vlan;
11164 cmdline_fixed_string_t insert;
11170 /* Common CLI fields for vf vlan insert enable disable */
11171 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11172 TOKEN_STRING_INITIALIZER
11173 (struct cmd_vf_vlan_insert_result,
11175 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11176 TOKEN_STRING_INITIALIZER
11177 (struct cmd_vf_vlan_insert_result,
11179 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11180 TOKEN_STRING_INITIALIZER
11181 (struct cmd_vf_vlan_insert_result,
11183 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11184 TOKEN_STRING_INITIALIZER
11185 (struct cmd_vf_vlan_insert_result,
11187 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11188 TOKEN_NUM_INITIALIZER
11189 (struct cmd_vf_vlan_insert_result,
11191 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11192 TOKEN_NUM_INITIALIZER
11193 (struct cmd_vf_vlan_insert_result,
11195 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11196 TOKEN_NUM_INITIALIZER
11197 (struct cmd_vf_vlan_insert_result,
11201 cmd_set_vf_vlan_insert_parsed(
11202 void *parsed_result,
11203 __attribute__((unused)) struct cmdline *cl,
11204 __attribute__((unused)) void *data)
11206 struct cmd_vf_vlan_insert_result *res = parsed_result;
11207 int ret = -ENOTSUP;
11209 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11212 #ifdef RTE_LIBRTE_IXGBE_PMD
11213 if (ret == -ENOTSUP)
11214 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11217 #ifdef RTE_LIBRTE_I40E_PMD
11218 if (ret == -ENOTSUP)
11219 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11227 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11230 printf("invalid port_id %d\n", res->port_id);
11233 printf("function not implemented\n");
11236 printf("programming error: (%s)\n", strerror(-ret));
11240 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11241 .f = cmd_set_vf_vlan_insert_parsed,
11243 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11245 (void *)&cmd_vf_vlan_insert_set,
11246 (void *)&cmd_vf_vlan_insert_vf,
11247 (void *)&cmd_vf_vlan_insert_vlan,
11248 (void *)&cmd_vf_vlan_insert_insert,
11249 (void *)&cmd_vf_vlan_insert_port_id,
11250 (void *)&cmd_vf_vlan_insert_vf_id,
11251 (void *)&cmd_vf_vlan_insert_vlan_id,
11256 /* tx loopback configuration */
11258 /* Common result structure for tx loopback */
11259 struct cmd_tx_loopback_result {
11260 cmdline_fixed_string_t set;
11261 cmdline_fixed_string_t tx;
11262 cmdline_fixed_string_t loopback;
11264 cmdline_fixed_string_t on_off;
11267 /* Common CLI fields for tx loopback enable disable */
11268 cmdline_parse_token_string_t cmd_tx_loopback_set =
11269 TOKEN_STRING_INITIALIZER
11270 (struct cmd_tx_loopback_result,
11272 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11273 TOKEN_STRING_INITIALIZER
11274 (struct cmd_tx_loopback_result,
11276 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11277 TOKEN_STRING_INITIALIZER
11278 (struct cmd_tx_loopback_result,
11279 loopback, "loopback");
11280 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11281 TOKEN_NUM_INITIALIZER
11282 (struct cmd_tx_loopback_result,
11284 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11285 TOKEN_STRING_INITIALIZER
11286 (struct cmd_tx_loopback_result,
11290 cmd_set_tx_loopback_parsed(
11291 void *parsed_result,
11292 __attribute__((unused)) struct cmdline *cl,
11293 __attribute__((unused)) void *data)
11295 struct cmd_tx_loopback_result *res = parsed_result;
11296 int ret = -ENOTSUP;
11298 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11300 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11303 #ifdef RTE_LIBRTE_IXGBE_PMD
11304 if (ret == -ENOTSUP)
11305 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11307 #ifdef RTE_LIBRTE_I40E_PMD
11308 if (ret == -ENOTSUP)
11309 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11316 printf("invalid is_on %d\n", is_on);
11319 printf("invalid port_id %d\n", res->port_id);
11322 printf("function not implemented\n");
11325 printf("programming error: (%s)\n", strerror(-ret));
11329 cmdline_parse_inst_t cmd_set_tx_loopback = {
11330 .f = cmd_set_tx_loopback_parsed,
11332 .help_str = "set tx loopback <port_id> on|off",
11334 (void *)&cmd_tx_loopback_set,
11335 (void *)&cmd_tx_loopback_tx,
11336 (void *)&cmd_tx_loopback_loopback,
11337 (void *)&cmd_tx_loopback_port_id,
11338 (void *)&cmd_tx_loopback_on_off,
11343 #ifdef RTE_LIBRTE_IXGBE_PMD
11344 /* all queues drop enable configuration */
11346 /* Common result structure for all queues drop enable */
11347 struct cmd_all_queues_drop_en_result {
11348 cmdline_fixed_string_t set;
11349 cmdline_fixed_string_t all;
11350 cmdline_fixed_string_t queues;
11351 cmdline_fixed_string_t drop;
11353 cmdline_fixed_string_t on_off;
11356 /* Common CLI fields for tx loopback enable disable */
11357 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11358 TOKEN_STRING_INITIALIZER
11359 (struct cmd_all_queues_drop_en_result,
11361 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11362 TOKEN_STRING_INITIALIZER
11363 (struct cmd_all_queues_drop_en_result,
11365 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11366 TOKEN_STRING_INITIALIZER
11367 (struct cmd_all_queues_drop_en_result,
11369 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11370 TOKEN_STRING_INITIALIZER
11371 (struct cmd_all_queues_drop_en_result,
11373 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11374 TOKEN_NUM_INITIALIZER
11375 (struct cmd_all_queues_drop_en_result,
11377 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11378 TOKEN_STRING_INITIALIZER
11379 (struct cmd_all_queues_drop_en_result,
11383 cmd_set_all_queues_drop_en_parsed(
11384 void *parsed_result,
11385 __attribute__((unused)) struct cmdline *cl,
11386 __attribute__((unused)) void *data)
11388 struct cmd_all_queues_drop_en_result *res = parsed_result;
11390 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11392 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11395 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11400 printf("invalid is_on %d\n", is_on);
11403 printf("invalid port_id %d\n", res->port_id);
11406 printf("function not implemented\n");
11409 printf("programming error: (%s)\n", strerror(-ret));
11413 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11414 .f = cmd_set_all_queues_drop_en_parsed,
11416 .help_str = "set all queues drop <port_id> on|off",
11418 (void *)&cmd_all_queues_drop_en_set,
11419 (void *)&cmd_all_queues_drop_en_all,
11420 (void *)&cmd_all_queues_drop_en_queues,
11421 (void *)&cmd_all_queues_drop_en_drop,
11422 (void *)&cmd_all_queues_drop_en_port_id,
11423 (void *)&cmd_all_queues_drop_en_on_off,
11428 /* vf split drop enable configuration */
11430 /* Common result structure for vf split drop enable */
11431 struct cmd_vf_split_drop_en_result {
11432 cmdline_fixed_string_t set;
11433 cmdline_fixed_string_t vf;
11434 cmdline_fixed_string_t split;
11435 cmdline_fixed_string_t drop;
11438 cmdline_fixed_string_t on_off;
11441 /* Common CLI fields for vf split drop enable disable */
11442 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11443 TOKEN_STRING_INITIALIZER
11444 (struct cmd_vf_split_drop_en_result,
11446 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11447 TOKEN_STRING_INITIALIZER
11448 (struct cmd_vf_split_drop_en_result,
11450 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11451 TOKEN_STRING_INITIALIZER
11452 (struct cmd_vf_split_drop_en_result,
11454 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11455 TOKEN_STRING_INITIALIZER
11456 (struct cmd_vf_split_drop_en_result,
11458 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11459 TOKEN_NUM_INITIALIZER
11460 (struct cmd_vf_split_drop_en_result,
11462 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11463 TOKEN_NUM_INITIALIZER
11464 (struct cmd_vf_split_drop_en_result,
11466 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11467 TOKEN_STRING_INITIALIZER
11468 (struct cmd_vf_split_drop_en_result,
11472 cmd_set_vf_split_drop_en_parsed(
11473 void *parsed_result,
11474 __attribute__((unused)) struct cmdline *cl,
11475 __attribute__((unused)) void *data)
11477 struct cmd_vf_split_drop_en_result *res = parsed_result;
11479 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11481 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11484 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11490 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11493 printf("invalid port_id %d\n", res->port_id);
11496 printf("programming error: (%s)\n", strerror(-ret));
11500 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11501 .f = cmd_set_vf_split_drop_en_parsed,
11503 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11505 (void *)&cmd_vf_split_drop_en_set,
11506 (void *)&cmd_vf_split_drop_en_vf,
11507 (void *)&cmd_vf_split_drop_en_split,
11508 (void *)&cmd_vf_split_drop_en_drop,
11509 (void *)&cmd_vf_split_drop_en_port_id,
11510 (void *)&cmd_vf_split_drop_en_vf_id,
11511 (void *)&cmd_vf_split_drop_en_on_off,
11517 /* vf mac address configuration */
11519 /* Common result structure for vf mac address */
11520 struct cmd_set_vf_mac_addr_result {
11521 cmdline_fixed_string_t set;
11522 cmdline_fixed_string_t vf;
11523 cmdline_fixed_string_t mac;
11524 cmdline_fixed_string_t addr;
11527 struct ether_addr mac_addr;
11531 /* Common CLI fields for vf split drop enable disable */
11532 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11533 TOKEN_STRING_INITIALIZER
11534 (struct cmd_set_vf_mac_addr_result,
11536 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11537 TOKEN_STRING_INITIALIZER
11538 (struct cmd_set_vf_mac_addr_result,
11540 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11541 TOKEN_STRING_INITIALIZER
11542 (struct cmd_set_vf_mac_addr_result,
11544 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11545 TOKEN_STRING_INITIALIZER
11546 (struct cmd_set_vf_mac_addr_result,
11548 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11549 TOKEN_NUM_INITIALIZER
11550 (struct cmd_set_vf_mac_addr_result,
11552 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11553 TOKEN_NUM_INITIALIZER
11554 (struct cmd_set_vf_mac_addr_result,
11556 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11557 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11561 cmd_set_vf_mac_addr_parsed(
11562 void *parsed_result,
11563 __attribute__((unused)) struct cmdline *cl,
11564 __attribute__((unused)) void *data)
11566 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11567 int ret = -ENOTSUP;
11569 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11572 #ifdef RTE_LIBRTE_IXGBE_PMD
11573 if (ret == -ENOTSUP)
11574 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11577 #ifdef RTE_LIBRTE_I40E_PMD
11578 if (ret == -ENOTSUP)
11579 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11587 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11590 printf("invalid port_id %d\n", res->port_id);
11593 printf("function not implemented\n");
11596 printf("programming error: (%s)\n", strerror(-ret));
11600 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11601 .f = cmd_set_vf_mac_addr_parsed,
11603 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11605 (void *)&cmd_set_vf_mac_addr_set,
11606 (void *)&cmd_set_vf_mac_addr_vf,
11607 (void *)&cmd_set_vf_mac_addr_mac,
11608 (void *)&cmd_set_vf_mac_addr_addr,
11609 (void *)&cmd_set_vf_mac_addr_port_id,
11610 (void *)&cmd_set_vf_mac_addr_vf_id,
11611 (void *)&cmd_set_vf_mac_addr_mac_addr,
11616 #ifdef RTE_LIBRTE_IXGBE_PMD
11617 /* MACsec configuration */
11619 /* Common result structure for MACsec offload enable */
11620 struct cmd_macsec_offload_on_result {
11621 cmdline_fixed_string_t set;
11622 cmdline_fixed_string_t macsec;
11623 cmdline_fixed_string_t offload;
11625 cmdline_fixed_string_t on;
11626 cmdline_fixed_string_t encrypt;
11627 cmdline_fixed_string_t en_on_off;
11628 cmdline_fixed_string_t replay_protect;
11629 cmdline_fixed_string_t rp_on_off;
11632 /* Common CLI fields for MACsec offload disable */
11633 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11634 TOKEN_STRING_INITIALIZER
11635 (struct cmd_macsec_offload_on_result,
11637 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11638 TOKEN_STRING_INITIALIZER
11639 (struct cmd_macsec_offload_on_result,
11641 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11642 TOKEN_STRING_INITIALIZER
11643 (struct cmd_macsec_offload_on_result,
11644 offload, "offload");
11645 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11646 TOKEN_NUM_INITIALIZER
11647 (struct cmd_macsec_offload_on_result,
11649 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11650 TOKEN_STRING_INITIALIZER
11651 (struct cmd_macsec_offload_on_result,
11653 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11654 TOKEN_STRING_INITIALIZER
11655 (struct cmd_macsec_offload_on_result,
11656 encrypt, "encrypt");
11657 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11658 TOKEN_STRING_INITIALIZER
11659 (struct cmd_macsec_offload_on_result,
11660 en_on_off, "on#off");
11661 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11662 TOKEN_STRING_INITIALIZER
11663 (struct cmd_macsec_offload_on_result,
11664 replay_protect, "replay-protect");
11665 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11666 TOKEN_STRING_INITIALIZER
11667 (struct cmd_macsec_offload_on_result,
11668 rp_on_off, "on#off");
11671 cmd_set_macsec_offload_on_parsed(
11672 void *parsed_result,
11673 __attribute__((unused)) struct cmdline *cl,
11674 __attribute__((unused)) void *data)
11676 struct cmd_macsec_offload_on_result *res = parsed_result;
11678 portid_t port_id = res->port_id;
11679 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11680 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11682 if (port_id_is_invalid(port_id, ENABLED_WARN))
11685 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11686 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11692 printf("invalid port_id %d\n", port_id);
11695 printf("programming error: (%s)\n", strerror(-ret));
11699 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11700 .f = cmd_set_macsec_offload_on_parsed,
11702 .help_str = "set macsec offload <port_id> on "
11703 "encrypt on|off replay-protect on|off",
11705 (void *)&cmd_macsec_offload_on_set,
11706 (void *)&cmd_macsec_offload_on_macsec,
11707 (void *)&cmd_macsec_offload_on_offload,
11708 (void *)&cmd_macsec_offload_on_port_id,
11709 (void *)&cmd_macsec_offload_on_on,
11710 (void *)&cmd_macsec_offload_on_encrypt,
11711 (void *)&cmd_macsec_offload_on_en_on_off,
11712 (void *)&cmd_macsec_offload_on_replay_protect,
11713 (void *)&cmd_macsec_offload_on_rp_on_off,
11718 /* Common result structure for MACsec offload disable */
11719 struct cmd_macsec_offload_off_result {
11720 cmdline_fixed_string_t set;
11721 cmdline_fixed_string_t macsec;
11722 cmdline_fixed_string_t offload;
11724 cmdline_fixed_string_t off;
11727 /* Common CLI fields for MACsec offload disable */
11728 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11729 TOKEN_STRING_INITIALIZER
11730 (struct cmd_macsec_offload_off_result,
11732 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11733 TOKEN_STRING_INITIALIZER
11734 (struct cmd_macsec_offload_off_result,
11736 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11737 TOKEN_STRING_INITIALIZER
11738 (struct cmd_macsec_offload_off_result,
11739 offload, "offload");
11740 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11741 TOKEN_NUM_INITIALIZER
11742 (struct cmd_macsec_offload_off_result,
11744 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11745 TOKEN_STRING_INITIALIZER
11746 (struct cmd_macsec_offload_off_result,
11750 cmd_set_macsec_offload_off_parsed(
11751 void *parsed_result,
11752 __attribute__((unused)) struct cmdline *cl,
11753 __attribute__((unused)) void *data)
11755 struct cmd_macsec_offload_off_result *res = parsed_result;
11757 portid_t port_id = res->port_id;
11759 if (port_id_is_invalid(port_id, ENABLED_WARN))
11762 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11763 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11769 printf("invalid port_id %d\n", port_id);
11772 printf("programming error: (%s)\n", strerror(-ret));
11776 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11777 .f = cmd_set_macsec_offload_off_parsed,
11779 .help_str = "set macsec offload <port_id> off",
11781 (void *)&cmd_macsec_offload_off_set,
11782 (void *)&cmd_macsec_offload_off_macsec,
11783 (void *)&cmd_macsec_offload_off_offload,
11784 (void *)&cmd_macsec_offload_off_port_id,
11785 (void *)&cmd_macsec_offload_off_off,
11790 /* Common result structure for MACsec secure connection configure */
11791 struct cmd_macsec_sc_result {
11792 cmdline_fixed_string_t set;
11793 cmdline_fixed_string_t macsec;
11794 cmdline_fixed_string_t sc;
11795 cmdline_fixed_string_t tx_rx;
11797 struct ether_addr mac;
11801 /* Common CLI fields for MACsec secure connection configure */
11802 cmdline_parse_token_string_t cmd_macsec_sc_set =
11803 TOKEN_STRING_INITIALIZER
11804 (struct cmd_macsec_sc_result,
11806 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11807 TOKEN_STRING_INITIALIZER
11808 (struct cmd_macsec_sc_result,
11810 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11811 TOKEN_STRING_INITIALIZER
11812 (struct cmd_macsec_sc_result,
11814 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11815 TOKEN_STRING_INITIALIZER
11816 (struct cmd_macsec_sc_result,
11818 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11819 TOKEN_NUM_INITIALIZER
11820 (struct cmd_macsec_sc_result,
11822 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11823 TOKEN_ETHERADDR_INITIALIZER
11824 (struct cmd_macsec_sc_result,
11826 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11827 TOKEN_NUM_INITIALIZER
11828 (struct cmd_macsec_sc_result,
11832 cmd_set_macsec_sc_parsed(
11833 void *parsed_result,
11834 __attribute__((unused)) struct cmdline *cl,
11835 __attribute__((unused)) void *data)
11837 struct cmd_macsec_sc_result *res = parsed_result;
11839 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11842 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11843 res->mac.addr_bytes) :
11844 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11845 res->mac.addr_bytes, res->pi);
11850 printf("invalid port_id %d\n", res->port_id);
11853 printf("programming error: (%s)\n", strerror(-ret));
11857 cmdline_parse_inst_t cmd_set_macsec_sc = {
11858 .f = cmd_set_macsec_sc_parsed,
11860 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11862 (void *)&cmd_macsec_sc_set,
11863 (void *)&cmd_macsec_sc_macsec,
11864 (void *)&cmd_macsec_sc_sc,
11865 (void *)&cmd_macsec_sc_tx_rx,
11866 (void *)&cmd_macsec_sc_port_id,
11867 (void *)&cmd_macsec_sc_mac,
11868 (void *)&cmd_macsec_sc_pi,
11873 /* Common result structure for MACsec secure connection configure */
11874 struct cmd_macsec_sa_result {
11875 cmdline_fixed_string_t set;
11876 cmdline_fixed_string_t macsec;
11877 cmdline_fixed_string_t sa;
11878 cmdline_fixed_string_t tx_rx;
11883 cmdline_fixed_string_t key;
11886 /* Common CLI fields for MACsec secure connection configure */
11887 cmdline_parse_token_string_t cmd_macsec_sa_set =
11888 TOKEN_STRING_INITIALIZER
11889 (struct cmd_macsec_sa_result,
11891 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11892 TOKEN_STRING_INITIALIZER
11893 (struct cmd_macsec_sa_result,
11895 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11896 TOKEN_STRING_INITIALIZER
11897 (struct cmd_macsec_sa_result,
11899 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11900 TOKEN_STRING_INITIALIZER
11901 (struct cmd_macsec_sa_result,
11903 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11904 TOKEN_NUM_INITIALIZER
11905 (struct cmd_macsec_sa_result,
11907 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11908 TOKEN_NUM_INITIALIZER
11909 (struct cmd_macsec_sa_result,
11911 cmdline_parse_token_num_t cmd_macsec_sa_an =
11912 TOKEN_NUM_INITIALIZER
11913 (struct cmd_macsec_sa_result,
11915 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11916 TOKEN_NUM_INITIALIZER
11917 (struct cmd_macsec_sa_result,
11919 cmdline_parse_token_string_t cmd_macsec_sa_key =
11920 TOKEN_STRING_INITIALIZER
11921 (struct cmd_macsec_sa_result,
11925 cmd_set_macsec_sa_parsed(
11926 void *parsed_result,
11927 __attribute__((unused)) struct cmdline *cl,
11928 __attribute__((unused)) void *data)
11930 struct cmd_macsec_sa_result *res = parsed_result;
11932 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11933 uint8_t key[16] = { 0 };
11939 key_len = strlen(res->key) / 2;
11943 for (i = 0; i < key_len; i++) {
11944 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11947 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11950 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11954 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11955 res->idx, res->an, res->pn, key) :
11956 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11957 res->idx, res->an, res->pn, key);
11962 printf("invalid idx %d or an %d\n", res->idx, res->an);
11965 printf("invalid port_id %d\n", res->port_id);
11968 printf("programming error: (%s)\n", strerror(-ret));
11972 cmdline_parse_inst_t cmd_set_macsec_sa = {
11973 .f = cmd_set_macsec_sa_parsed,
11975 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11977 (void *)&cmd_macsec_sa_set,
11978 (void *)&cmd_macsec_sa_macsec,
11979 (void *)&cmd_macsec_sa_sa,
11980 (void *)&cmd_macsec_sa_tx_rx,
11981 (void *)&cmd_macsec_sa_port_id,
11982 (void *)&cmd_macsec_sa_idx,
11983 (void *)&cmd_macsec_sa_an,
11984 (void *)&cmd_macsec_sa_pn,
11985 (void *)&cmd_macsec_sa_key,
11991 /* ******************************************************************************** */
11993 /* list of instructions */
11994 cmdline_parse_ctx_t main_ctx[] = {
11995 (cmdline_parse_inst_t *)&cmd_help_brief,
11996 (cmdline_parse_inst_t *)&cmd_help_long,
11997 (cmdline_parse_inst_t *)&cmd_quit,
11998 (cmdline_parse_inst_t *)&cmd_showport,
11999 (cmdline_parse_inst_t *)&cmd_showqueue,
12000 (cmdline_parse_inst_t *)&cmd_showportall,
12001 (cmdline_parse_inst_t *)&cmd_showcfg,
12002 (cmdline_parse_inst_t *)&cmd_start,
12003 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12004 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12005 (cmdline_parse_inst_t *)&cmd_set_link_up,
12006 (cmdline_parse_inst_t *)&cmd_set_link_down,
12007 (cmdline_parse_inst_t *)&cmd_reset,
12008 (cmdline_parse_inst_t *)&cmd_set_numbers,
12009 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12010 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12011 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12012 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12013 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12014 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12015 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12016 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12017 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12018 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12019 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12020 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12021 (cmdline_parse_inst_t *)&cmd_set_link_check,
12022 #ifdef RTE_NIC_BYPASS
12023 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12024 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12025 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12026 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12028 #ifdef RTE_LIBRTE_PMD_BOND
12029 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12030 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12031 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12032 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12033 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12034 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12035 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12036 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12037 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12039 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12040 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12041 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12042 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12043 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12044 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12045 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12046 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12047 (cmdline_parse_inst_t *)&cmd_csum_set,
12048 (cmdline_parse_inst_t *)&cmd_csum_show,
12049 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12050 (cmdline_parse_inst_t *)&cmd_tso_set,
12051 (cmdline_parse_inst_t *)&cmd_tso_show,
12052 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12053 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12054 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12055 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12056 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12057 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12058 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12059 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12060 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12061 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12062 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12063 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12064 (cmdline_parse_inst_t *)&cmd_config_dcb,
12065 (cmdline_parse_inst_t *)&cmd_read_reg,
12066 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12067 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12068 (cmdline_parse_inst_t *)&cmd_write_reg,
12069 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12070 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12071 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12072 (cmdline_parse_inst_t *)&cmd_stop,
12073 (cmdline_parse_inst_t *)&cmd_mac_addr,
12074 (cmdline_parse_inst_t *)&cmd_set_qmap,
12075 (cmdline_parse_inst_t *)&cmd_operate_port,
12076 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12077 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12078 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12079 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12080 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12081 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12082 (cmdline_parse_inst_t *)&cmd_config_mtu,
12083 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12084 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12085 (cmdline_parse_inst_t *)&cmd_config_rss,
12086 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12087 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12088 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12089 (cmdline_parse_inst_t *)&cmd_showport_reta,
12090 (cmdline_parse_inst_t *)&cmd_config_burst,
12091 (cmdline_parse_inst_t *)&cmd_config_thresh,
12092 (cmdline_parse_inst_t *)&cmd_config_threshold,
12093 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12094 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12095 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12096 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12097 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12098 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12099 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12100 (cmdline_parse_inst_t *)&cmd_global_config,
12101 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12102 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12103 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12104 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12105 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12106 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12107 (cmdline_parse_inst_t *)&cmd_dump,
12108 (cmdline_parse_inst_t *)&cmd_dump_one,
12109 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12110 (cmdline_parse_inst_t *)&cmd_syn_filter,
12111 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12112 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12113 (cmdline_parse_inst_t *)&cmd_flex_filter,
12114 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12115 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12116 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12117 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12118 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12119 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12120 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12121 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12122 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12123 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12124 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12125 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12126 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12127 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12128 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12129 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12130 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12131 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12132 (cmdline_parse_inst_t *)&cmd_flow,
12133 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12134 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12135 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12136 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12137 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12138 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12139 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12140 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12141 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12142 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12143 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12144 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12145 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12146 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12147 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12148 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12149 #ifdef RTE_LIBRTE_IXGBE_PMD
12150 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12151 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12152 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12153 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12154 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12155 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12156 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12157 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12158 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12159 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12161 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12165 /* prompt function, called from main on MASTER lcore */
12169 /* initialize non-constant commands */
12170 cmd_set_fwd_mode_init();
12171 cmd_set_fwd_retry_mode_init();
12173 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12174 if (testpmd_cl == NULL)
12176 cmdline_interact(testpmd_cl);
12177 cmdline_stdin_exit(testpmd_cl);
12183 if (testpmd_cl != NULL)
12184 cmdline_quit(testpmd_cl);
12188 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12190 if (id == (portid_t)RTE_PORT_ALL) {
12193 FOREACH_PORT(pid, ports) {
12194 /* check if need_reconfig has been set to 1 */
12195 if (ports[pid].need_reconfig == 0)
12196 ports[pid].need_reconfig = dev;
12197 /* check if need_reconfig_queues has been set to 1 */
12198 if (ports[pid].need_reconfig_queues == 0)
12199 ports[pid].need_reconfig_queues = queue;
12201 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12202 /* check if need_reconfig has been set to 1 */
12203 if (ports[id].need_reconfig == 0)
12204 ports[id].need_reconfig = dev;
12205 /* check if need_reconfig_queues has been set to 1 */
12206 if (ports[id].need_reconfig_queues == 0)
12207 ports[id].need_reconfig_queues = queue;