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 vf promisc (port_id) (vf_id) (on|off)\n"
419 " Set unicast promiscuous mode for a VF from the PF.\n\n"
421 "set vf allmulti (port_id) (vf_id) (on|off)\n"
422 " Set multicast promiscuous mode for a VF from the PF.\n\n"
424 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
425 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
426 " (on|off) autoneg (on|off) (port_id)\n"
427 "set flow_ctrl rx (on|off) (portid)\n"
428 "set flow_ctrl tx (on|off) (portid)\n"
429 "set flow_ctrl high_water (high_water) (portid)\n"
430 "set flow_ctrl low_water (low_water) (portid)\n"
431 "set flow_ctrl pause_time (pause_time) (portid)\n"
432 "set flow_ctrl send_xon (send_xon) (portid)\n"
433 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
434 "set flow_ctrl autoneg (on|off) (port_id)\n"
435 " Set the link flow control parameter on a port.\n\n"
437 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
438 " (low_water) (pause_time) (priority) (port_id)\n"
439 " Set the priority flow control parameter on a"
442 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
443 " Set statistics mapping (qmapping 0..15) for RX/TX"
445 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
446 " on port 0 to mapping 5.\n\n"
448 "set port (port_id) vf (vf_id) rx|tx on|off\n"
449 " Enable/Disable a VF receive/tranmit from a port\n\n"
451 "set port (port_id) vf (vf_id) (mac_addr)"
452 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
453 " Add/Remove unicast or multicast MAC addr filter"
456 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
458 " AUPE:accepts untagged VLAN;"
459 "ROPE:accept unicast hash\n\n"
460 " BAM:accepts broadcast packets;"
461 "MPE:accepts all multicast packets\n\n"
462 " Enable/Disable a VF receive mode of a port\n\n"
464 "set port (port_id) queue (queue_id) rate (rate_num)\n"
465 " Set rate limit for a queue of a port\n\n"
467 "set port (port_id) vf (vf_id) rate (rate_num) "
468 "queue_mask (queue_mask_value)\n"
469 " Set rate limit for queues in VF of a port\n\n"
471 "set port (port_id) mirror-rule (rule_id)"
472 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
473 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
474 " Set pool or vlan type mirror rule on a port.\n"
475 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
476 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
479 "set port (port_id) mirror-rule (rule_id)"
480 " (uplink-mirror|downlink-mirror) dst-pool"
481 " (pool_id) (on|off)\n"
482 " Set uplink or downlink type mirror rule on a port.\n"
483 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
484 " 0 on' enable mirror income traffic to pool 0.\n\n"
486 "reset port (port_id) mirror-rule (rule_id)\n"
487 " Reset a mirror rule.\n\n"
489 "set flush_rx (on|off)\n"
490 " Flush (default) or don't flush RX streams before"
491 " forwarding. Mainly used with PCAP drivers.\n\n"
493 #ifdef RTE_NIC_BYPASS
494 "set bypass mode (normal|bypass|isolate) (port_id)\n"
495 " Set the bypass mode for the lowest port on bypass enabled"
498 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
499 "mode (normal|bypass|isolate) (port_id)\n"
500 " Set the event required to initiate specified bypass mode for"
501 " the lowest port on a bypass enabled NIC where:\n"
502 " timeout = enable bypass after watchdog timeout.\n"
503 " os_on = enable bypass when OS/board is powered on.\n"
504 " os_off = enable bypass when OS/board is powered off.\n"
505 " power_on = enable bypass when power supply is turned on.\n"
506 " power_off = enable bypass when power supply is turned off."
509 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
510 " Set the bypass watchdog timeout to 'n' seconds"
511 " where 0 = instant.\n\n"
513 "show bypass config (port_id)\n"
514 " Show the bypass configuration for a bypass enabled NIC"
515 " using the lowest port on the NIC.\n\n"
517 #ifdef RTE_LIBRTE_PMD_BOND
518 "create bonded device (mode) (socket)\n"
519 " Create a new bonded device with specific bonding mode and socket.\n\n"
521 "add bonding slave (slave_id) (port_id)\n"
522 " Add a slave device to a bonded device.\n\n"
524 "remove bonding slave (slave_id) (port_id)\n"
525 " Remove a slave device from a bonded device.\n\n"
527 "set bonding mode (value) (port_id)\n"
528 " Set the bonding mode on a bonded device.\n\n"
530 "set bonding primary (slave_id) (port_id)\n"
531 " Set the primary slave for a bonded device.\n\n"
533 "show bonding config (port_id)\n"
534 " Show the bonding config for port_id.\n\n"
536 "set bonding mac_addr (port_id) (address)\n"
537 " Set the MAC address of a bonded device.\n\n"
539 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
540 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
542 "set bonding mon_period (port_id) (value)\n"
543 " Set the bonding link status monitoring polling period in ms.\n\n"
545 "set link-up port (port_id)\n"
546 " Set link up for a port.\n\n"
548 "set link-down port (port_id)\n"
549 " Set link down for a port.\n\n"
551 "E-tag set insertion on port-tag-id (value)"
552 " port (port_id) vf (vf_id)\n"
553 " Enable E-tag insertion for a VF on a port\n\n"
555 "E-tag set insertion off port (port_id) vf (vf_id)\n"
556 " Disable E-tag insertion for a VF on a port\n\n"
558 "E-tag set stripping (on|off) port (port_id)\n"
559 " Enable/disable E-tag stripping on a port\n\n"
561 "E-tag set forwarding (on|off) port (port_id)\n"
562 " Enable/disable E-tag based forwarding"
565 "E-tag set filter add e-tag-id (value) dst-pool"
566 " (pool_id) port (port_id)\n"
567 " Add an E-tag forwarding filter on a port\n\n"
569 "E-tag set filter del e-tag-id (value) port (port_id)\n"
570 " Delete an E-tag forwarding filter on a port\n\n"
572 , list_pkt_forwarding_modes()
576 if (show_all || !strcmp(res->section, "ports")) {
582 "----------------\n\n"
584 "port start (port_id|all)\n"
585 " Start all ports or port_id.\n\n"
587 "port stop (port_id|all)\n"
588 " Stop all ports or port_id.\n\n"
590 "port close (port_id|all)\n"
591 " Close all ports or port_id.\n\n"
593 "port attach (ident)\n"
594 " Attach physical or virtual dev by pci address or virtual device name\n\n"
596 "port detach (port_id)\n"
597 " Detach physical or virtual dev by port_id\n\n"
599 "port config (port_id|all)"
600 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
601 " duplex (half|full|auto)\n"
602 " Set speed and duplex for all ports or port_id\n\n"
604 "port config all (rxq|txq|rxd|txd) (value)\n"
605 " Set number for rxq/txq/rxd/txd.\n\n"
607 "port config all max-pkt-len (value)\n"
608 " Set the max packet length.\n\n"
610 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
611 "hw-vlan-strip|hw-vlan-extend|drop-en)"
613 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
616 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
617 " Set the RSS mode.\n\n"
619 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
620 " Set the RSS redirection table.\n\n"
622 "port config (port_id) dcb vt (on|off) (traffic_class)"
624 " Set the DCB mode.\n\n"
626 "port config all burst (value)\n"
627 " Set the number of packets per burst.\n\n"
629 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
631 " Set the ring prefetch/host/writeback threshold"
632 " for tx/rx queue.\n\n"
634 "port config all (txfreet|txrst|rxfreet) (value)\n"
635 " Set free threshold for rx/tx, or set"
636 " tx rs bit threshold.\n\n"
637 "port config mtu X value\n"
638 " Set the MTU of port X to a given value\n\n"
640 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
641 " Start/stop a rx/tx queue of port X. Only take effect"
642 " when port X is started\n\n"
644 "port config (port_id|all) l2-tunnel E-tag ether-type"
646 " Set the value of E-tag ether-type.\n\n"
648 "port config (port_id|all) l2-tunnel E-tag"
649 " (enable|disable)\n"
650 " Enable/disable the E-tag support.\n\n"
654 if (show_all || !strcmp(res->section, "registers")) {
662 "read reg (port_id) (address)\n"
663 " Display value of a port register.\n\n"
665 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
666 " Display a port register bit field.\n\n"
668 "read regbit (port_id) (address) (bit_x)\n"
669 " Display a single port register bit.\n\n"
671 "write reg (port_id) (address) (value)\n"
672 " Set value of a port register.\n\n"
674 "write regfield (port_id) (address) (bit_x) (bit_y)"
676 " Set bit field of a port register.\n\n"
678 "write regbit (port_id) (address) (bit_x) (value)\n"
679 " Set single bit value of a port register.\n\n"
682 if (show_all || !strcmp(res->section, "filters")) {
690 "ethertype_filter (port_id) (add|del)"
691 " (mac_addr|mac_ignr) (mac_address) ethertype"
692 " (ether_type) (drop|fwd) queue (queue_id)\n"
693 " Add/Del an ethertype filter.\n\n"
695 "2tuple_filter (port_id) (add|del)"
696 " dst_port (dst_port_value) protocol (protocol_value)"
697 " mask (mask_value) tcp_flags (tcp_flags_value)"
698 " priority (prio_value) queue (queue_id)\n"
699 " Add/Del a 2tuple filter.\n\n"
701 "5tuple_filter (port_id) (add|del)"
702 " dst_ip (dst_address) src_ip (src_address)"
703 " dst_port (dst_port_value) src_port (src_port_value)"
704 " protocol (protocol_value)"
705 " mask (mask_value) tcp_flags (tcp_flags_value)"
706 " priority (prio_value) queue (queue_id)\n"
707 " Add/Del a 5tuple filter.\n\n"
709 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
710 " Add/Del syn filter.\n\n"
712 "flex_filter (port_id) (add|del) len (len_value)"
713 " bytes (bytes_value) mask (mask_value)"
714 " priority (prio_value) queue (queue_id)\n"
715 " Add/Del a flex filter.\n\n"
717 "flow_director_filter (port_id) mode IP (add|del|update)"
718 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
719 " src (src_ip_address) dst (dst_ip_address)"
720 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
721 " vlan (vlan_value) flexbytes (flexbytes_value)"
722 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
723 " fd_id (fd_id_value)\n"
724 " Add/Del an IP type flow director filter.\n\n"
726 "flow_director_filter (port_id) mode IP (add|del|update)"
727 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
728 " src (src_ip_address) (src_port)"
729 " dst (dst_ip_address) (dst_port)"
730 " tos (tos_value) ttl (ttl_value)"
731 " vlan (vlan_value) flexbytes (flexbytes_value)"
732 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
733 " fd_id (fd_id_value)\n"
734 " Add/Del an UDP/TCP type flow director filter.\n\n"
736 "flow_director_filter (port_id) mode IP (add|del|update)"
737 " flow (ipv4-sctp|ipv6-sctp)"
738 " src (src_ip_address) (src_port)"
739 " dst (dst_ip_address) (dst_port)"
740 " tag (verification_tag) "
741 " tos (tos_value) ttl (ttl_value)"
743 " flexbytes (flexbytes_value) (drop|fwd)"
744 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
745 " Add/Del a SCTP type flow director filter.\n\n"
747 "flow_director_filter (port_id) mode IP (add|del|update)"
748 " flow l2_payload ether (ethertype)"
749 " flexbytes (flexbytes_value) (drop|fwd)"
750 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
751 " Add/Del a l2 payload type flow director filter.\n\n"
753 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
754 " mac (mac_address) vlan (vlan_value)"
755 " flexbytes (flexbytes_value) (drop|fwd)"
756 " queue (queue_id) fd_id (fd_id_value)\n"
757 " Add/Del a MAC-VLAN flow director filter.\n\n"
759 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
760 " mac (mac_address) vlan (vlan_value)"
761 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
762 " flexbytes (flexbytes_value) (drop|fwd)"
763 " queue (queue_id) fd_id (fd_id_value)\n"
764 " Add/Del a Tunnel flow director filter.\n\n"
766 "flush_flow_director (port_id)\n"
767 " Flush all flow director entries of a device.\n\n"
769 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
770 " src_mask (ipv4_src) (ipv6_src) (src_port)"
771 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
772 " Set flow director IP mask.\n\n"
774 "flow_director_mask (port_id) mode MAC-VLAN"
775 " vlan (vlan_value)\n"
776 " Set flow director MAC-VLAN mask.\n\n"
778 "flow_director_mask (port_id) mode Tunnel"
779 " vlan (vlan_value) mac (mac_value)"
780 " tunnel-type (tunnel_type_value)"
781 " tunnel-id (tunnel_id_value)\n"
782 " Set flow director Tunnel mask.\n\n"
784 "flow_director_flex_mask (port_id)"
785 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
786 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
788 " Configure mask of flex payload.\n\n"
790 "flow_director_flex_payload (port_id)"
791 " (raw|l2|l3|l4) (config)\n"
792 " Configure flex payload selection.\n\n"
794 "get_sym_hash_ena_per_port (port_id)\n"
795 " get symmetric hash enable configuration per port.\n\n"
797 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
798 " set symmetric hash enable configuration per port"
799 " to enable or disable.\n\n"
801 "get_hash_global_config (port_id)\n"
802 " Get the global configurations of hash filters.\n\n"
804 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
805 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
806 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
807 " (enable|disable)\n"
808 " Set the global configurations of hash filters.\n\n"
810 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
811 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
812 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
813 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
814 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
815 "ipv6-next-header|udp-src-port|udp-dst-port|"
816 "tcp-src-port|tcp-dst-port|sctp-src-port|"
817 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
818 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
819 "fld-8th|none) (select|add)\n"
820 " Set the input set for hash.\n\n"
822 "set_fdir_input_set (port_id) "
823 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
824 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
825 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
826 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
827 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
828 "udp-dst-port|tcp-src-port|tcp-dst-port|"
829 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
831 " Set the input set for FDir.\n\n"
833 "flow validate {port_id}"
834 " [group {group_id}] [priority {level}]"
835 " [ingress] [egress]"
836 " pattern {item} [/ {item} [...]] / end"
837 " actions {action} [/ {action} [...]] / end\n"
838 " Check whether a flow rule can be created.\n\n"
840 "flow create {port_id}"
841 " [group {group_id}] [priority {level}]"
842 " [ingress] [egress]"
843 " pattern {item} [/ {item} [...]] / end"
844 " actions {action} [/ {action} [...]] / end\n"
845 " Create a flow rule.\n\n"
847 "flow destroy {port_id} rule {rule_id} [...]\n"
848 " Destroy specific flow rules.\n\n"
850 "flow flush {port_id}\n"
851 " Destroy all flow rules.\n\n"
853 "flow query {port_id} {rule_id} {action}\n"
854 " Query an existing flow rule.\n\n"
856 "flow list {port_id} [group {group_id}] [...]\n"
857 " List existing flow rules sorted by priority,"
858 " filtered by group identifiers.\n\n"
863 cmdline_parse_token_string_t cmd_help_long_help =
864 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
866 cmdline_parse_token_string_t cmd_help_long_section =
867 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
868 "all#control#display#config#"
869 "ports#registers#filters");
871 cmdline_parse_inst_t cmd_help_long = {
872 .f = cmd_help_long_parsed,
874 .help_str = "help all|control|display|config|ports|register|filters: "
877 (void *)&cmd_help_long_help,
878 (void *)&cmd_help_long_section,
884 /* *** start/stop/close all ports *** */
885 struct cmd_operate_port_result {
886 cmdline_fixed_string_t keyword;
887 cmdline_fixed_string_t name;
888 cmdline_fixed_string_t value;
891 static void cmd_operate_port_parsed(void *parsed_result,
892 __attribute__((unused)) struct cmdline *cl,
893 __attribute__((unused)) void *data)
895 struct cmd_operate_port_result *res = parsed_result;
897 if (!strcmp(res->name, "start"))
898 start_port(RTE_PORT_ALL);
899 else if (!strcmp(res->name, "stop"))
900 stop_port(RTE_PORT_ALL);
901 else if (!strcmp(res->name, "close"))
902 close_port(RTE_PORT_ALL);
904 printf("Unknown parameter\n");
907 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
908 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
910 cmdline_parse_token_string_t cmd_operate_port_all_port =
911 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
913 cmdline_parse_token_string_t cmd_operate_port_all_all =
914 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
916 cmdline_parse_inst_t cmd_operate_port = {
917 .f = cmd_operate_port_parsed,
919 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
921 (void *)&cmd_operate_port_all_cmd,
922 (void *)&cmd_operate_port_all_port,
923 (void *)&cmd_operate_port_all_all,
928 /* *** start/stop/close specific port *** */
929 struct cmd_operate_specific_port_result {
930 cmdline_fixed_string_t keyword;
931 cmdline_fixed_string_t name;
935 static void cmd_operate_specific_port_parsed(void *parsed_result,
936 __attribute__((unused)) struct cmdline *cl,
937 __attribute__((unused)) void *data)
939 struct cmd_operate_specific_port_result *res = parsed_result;
941 if (!strcmp(res->name, "start"))
942 start_port(res->value);
943 else if (!strcmp(res->name, "stop"))
944 stop_port(res->value);
945 else if (!strcmp(res->name, "close"))
946 close_port(res->value);
948 printf("Unknown parameter\n");
951 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
952 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
954 cmdline_parse_token_string_t cmd_operate_specific_port_port =
955 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
956 name, "start#stop#close");
957 cmdline_parse_token_num_t cmd_operate_specific_port_id =
958 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
961 cmdline_parse_inst_t cmd_operate_specific_port = {
962 .f = cmd_operate_specific_port_parsed,
964 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
966 (void *)&cmd_operate_specific_port_cmd,
967 (void *)&cmd_operate_specific_port_port,
968 (void *)&cmd_operate_specific_port_id,
973 /* *** attach a specified port *** */
974 struct cmd_operate_attach_port_result {
975 cmdline_fixed_string_t port;
976 cmdline_fixed_string_t keyword;
977 cmdline_fixed_string_t identifier;
980 static void cmd_operate_attach_port_parsed(void *parsed_result,
981 __attribute__((unused)) struct cmdline *cl,
982 __attribute__((unused)) void *data)
984 struct cmd_operate_attach_port_result *res = parsed_result;
986 if (!strcmp(res->keyword, "attach"))
987 attach_port(res->identifier);
989 printf("Unknown parameter\n");
992 cmdline_parse_token_string_t cmd_operate_attach_port_port =
993 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
995 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
996 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
998 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
999 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1002 cmdline_parse_inst_t cmd_operate_attach_port = {
1003 .f = cmd_operate_attach_port_parsed,
1005 .help_str = "port attach <identifier>: "
1006 "(identifier: pci address or virtual dev name)",
1008 (void *)&cmd_operate_attach_port_port,
1009 (void *)&cmd_operate_attach_port_keyword,
1010 (void *)&cmd_operate_attach_port_identifier,
1015 /* *** detach a specified port *** */
1016 struct cmd_operate_detach_port_result {
1017 cmdline_fixed_string_t port;
1018 cmdline_fixed_string_t keyword;
1022 static void cmd_operate_detach_port_parsed(void *parsed_result,
1023 __attribute__((unused)) struct cmdline *cl,
1024 __attribute__((unused)) void *data)
1026 struct cmd_operate_detach_port_result *res = parsed_result;
1028 if (!strcmp(res->keyword, "detach"))
1029 detach_port(res->port_id);
1031 printf("Unknown parameter\n");
1034 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1035 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1037 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1038 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1040 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1041 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1044 cmdline_parse_inst_t cmd_operate_detach_port = {
1045 .f = cmd_operate_detach_port_parsed,
1047 .help_str = "port detach <port_id>",
1049 (void *)&cmd_operate_detach_port_port,
1050 (void *)&cmd_operate_detach_port_keyword,
1051 (void *)&cmd_operate_detach_port_port_id,
1056 /* *** configure speed for all ports *** */
1057 struct cmd_config_speed_all {
1058 cmdline_fixed_string_t port;
1059 cmdline_fixed_string_t keyword;
1060 cmdline_fixed_string_t all;
1061 cmdline_fixed_string_t item1;
1062 cmdline_fixed_string_t item2;
1063 cmdline_fixed_string_t value1;
1064 cmdline_fixed_string_t value2;
1068 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1073 if (!strcmp(duplexstr, "half")) {
1074 duplex = ETH_LINK_HALF_DUPLEX;
1075 } else if (!strcmp(duplexstr, "full")) {
1076 duplex = ETH_LINK_FULL_DUPLEX;
1077 } else if (!strcmp(duplexstr, "auto")) {
1078 duplex = ETH_LINK_FULL_DUPLEX;
1080 printf("Unknown duplex parameter\n");
1084 if (!strcmp(speedstr, "10")) {
1085 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1086 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1087 } else if (!strcmp(speedstr, "100")) {
1088 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1089 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1091 if (duplex != ETH_LINK_FULL_DUPLEX) {
1092 printf("Invalid speed/duplex parameters\n");
1095 if (!strcmp(speedstr, "1000")) {
1096 *speed = ETH_LINK_SPEED_1G;
1097 } else if (!strcmp(speedstr, "10000")) {
1098 *speed = ETH_LINK_SPEED_10G;
1099 } else if (!strcmp(speedstr, "25000")) {
1100 *speed = ETH_LINK_SPEED_25G;
1101 } else if (!strcmp(speedstr, "40000")) {
1102 *speed = ETH_LINK_SPEED_40G;
1103 } else if (!strcmp(speedstr, "50000")) {
1104 *speed = ETH_LINK_SPEED_50G;
1105 } else if (!strcmp(speedstr, "100000")) {
1106 *speed = ETH_LINK_SPEED_100G;
1107 } else if (!strcmp(speedstr, "auto")) {
1108 *speed = ETH_LINK_SPEED_AUTONEG;
1110 printf("Unknown speed parameter\n");
1119 cmd_config_speed_all_parsed(void *parsed_result,
1120 __attribute__((unused)) struct cmdline *cl,
1121 __attribute__((unused)) void *data)
1123 struct cmd_config_speed_all *res = parsed_result;
1124 uint32_t link_speed;
1127 if (!all_ports_stopped()) {
1128 printf("Please stop all ports first\n");
1132 if (parse_and_check_speed_duplex(res->value1, res->value2,
1136 FOREACH_PORT(pid, ports) {
1137 ports[pid].dev_conf.link_speeds = link_speed;
1140 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1143 cmdline_parse_token_string_t cmd_config_speed_all_port =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1145 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1146 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1148 cmdline_parse_token_string_t cmd_config_speed_all_all =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1150 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1152 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1154 "10#100#1000#10000#25000#40000#50000#100000#auto");
1155 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1156 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1157 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1158 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1161 cmdline_parse_inst_t cmd_config_speed_all = {
1162 .f = cmd_config_speed_all_parsed,
1164 .help_str = "port config all speed "
1165 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1168 (void *)&cmd_config_speed_all_port,
1169 (void *)&cmd_config_speed_all_keyword,
1170 (void *)&cmd_config_speed_all_all,
1171 (void *)&cmd_config_speed_all_item1,
1172 (void *)&cmd_config_speed_all_value1,
1173 (void *)&cmd_config_speed_all_item2,
1174 (void *)&cmd_config_speed_all_value2,
1179 /* *** configure speed for specific port *** */
1180 struct cmd_config_speed_specific {
1181 cmdline_fixed_string_t port;
1182 cmdline_fixed_string_t keyword;
1184 cmdline_fixed_string_t item1;
1185 cmdline_fixed_string_t item2;
1186 cmdline_fixed_string_t value1;
1187 cmdline_fixed_string_t value2;
1191 cmd_config_speed_specific_parsed(void *parsed_result,
1192 __attribute__((unused)) struct cmdline *cl,
1193 __attribute__((unused)) void *data)
1195 struct cmd_config_speed_specific *res = parsed_result;
1196 uint32_t link_speed;
1198 if (!all_ports_stopped()) {
1199 printf("Please stop all ports first\n");
1203 if (port_id_is_invalid(res->id, ENABLED_WARN))
1206 if (parse_and_check_speed_duplex(res->value1, res->value2,
1210 ports[res->id].dev_conf.link_speeds = link_speed;
1212 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1216 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1217 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1219 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1220 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1222 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1223 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1224 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1225 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1227 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1228 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1229 "10#100#1000#10000#25000#40000#50000#100000#auto");
1230 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1231 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1233 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1234 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1237 cmdline_parse_inst_t cmd_config_speed_specific = {
1238 .f = cmd_config_speed_specific_parsed,
1240 .help_str = "port config <port_id> speed "
1241 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1244 (void *)&cmd_config_speed_specific_port,
1245 (void *)&cmd_config_speed_specific_keyword,
1246 (void *)&cmd_config_speed_specific_id,
1247 (void *)&cmd_config_speed_specific_item1,
1248 (void *)&cmd_config_speed_specific_value1,
1249 (void *)&cmd_config_speed_specific_item2,
1250 (void *)&cmd_config_speed_specific_value2,
1255 /* *** configure txq/rxq, txd/rxd *** */
1256 struct cmd_config_rx_tx {
1257 cmdline_fixed_string_t port;
1258 cmdline_fixed_string_t keyword;
1259 cmdline_fixed_string_t all;
1260 cmdline_fixed_string_t name;
1265 cmd_config_rx_tx_parsed(void *parsed_result,
1266 __attribute__((unused)) struct cmdline *cl,
1267 __attribute__((unused)) void *data)
1269 struct cmd_config_rx_tx *res = parsed_result;
1271 if (!all_ports_stopped()) {
1272 printf("Please stop all ports first\n");
1275 if (!strcmp(res->name, "rxq")) {
1276 if (!res->value && !nb_txq) {
1277 printf("Warning: Either rx or tx queues should be non zero\n");
1280 nb_rxq = res->value;
1282 else if (!strcmp(res->name, "txq")) {
1283 if (!res->value && !nb_rxq) {
1284 printf("Warning: Either rx or tx queues should be non zero\n");
1287 nb_txq = res->value;
1289 else if (!strcmp(res->name, "rxd")) {
1290 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1291 printf("rxd %d invalid - must be > 0 && <= %d\n",
1292 res->value, RTE_TEST_RX_DESC_MAX);
1295 nb_rxd = res->value;
1296 } else if (!strcmp(res->name, "txd")) {
1297 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1298 printf("txd %d invalid - must be > 0 && <= %d\n",
1299 res->value, RTE_TEST_TX_DESC_MAX);
1302 nb_txd = res->value;
1304 printf("Unknown parameter\n");
1312 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1315 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1316 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1317 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1318 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1319 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1320 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1321 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1322 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1324 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1325 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1327 cmdline_parse_inst_t cmd_config_rx_tx = {
1328 .f = cmd_config_rx_tx_parsed,
1330 .help_str = "port config all rxq|txq|rxd|txd <value>",
1332 (void *)&cmd_config_rx_tx_port,
1333 (void *)&cmd_config_rx_tx_keyword,
1334 (void *)&cmd_config_rx_tx_all,
1335 (void *)&cmd_config_rx_tx_name,
1336 (void *)&cmd_config_rx_tx_value,
1341 /* *** config max packet length *** */
1342 struct cmd_config_max_pkt_len_result {
1343 cmdline_fixed_string_t port;
1344 cmdline_fixed_string_t keyword;
1345 cmdline_fixed_string_t all;
1346 cmdline_fixed_string_t name;
1351 cmd_config_max_pkt_len_parsed(void *parsed_result,
1352 __attribute__((unused)) struct cmdline *cl,
1353 __attribute__((unused)) void *data)
1355 struct cmd_config_max_pkt_len_result *res = parsed_result;
1357 if (!all_ports_stopped()) {
1358 printf("Please stop all ports first\n");
1362 if (!strcmp(res->name, "max-pkt-len")) {
1363 if (res->value < ETHER_MIN_LEN) {
1364 printf("max-pkt-len can not be less than %d\n",
1368 if (res->value == rx_mode.max_rx_pkt_len)
1371 rx_mode.max_rx_pkt_len = res->value;
1372 if (res->value > ETHER_MAX_LEN)
1373 rx_mode.jumbo_frame = 1;
1375 rx_mode.jumbo_frame = 0;
1377 printf("Unknown parameter\n");
1383 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1386 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1389 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1392 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1393 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1395 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1398 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1399 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1402 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1403 .f = cmd_config_max_pkt_len_parsed,
1405 .help_str = "port config all max-pkt-len <value>",
1407 (void *)&cmd_config_max_pkt_len_port,
1408 (void *)&cmd_config_max_pkt_len_keyword,
1409 (void *)&cmd_config_max_pkt_len_all,
1410 (void *)&cmd_config_max_pkt_len_name,
1411 (void *)&cmd_config_max_pkt_len_value,
1416 /* *** configure port MTU *** */
1417 struct cmd_config_mtu_result {
1418 cmdline_fixed_string_t port;
1419 cmdline_fixed_string_t keyword;
1420 cmdline_fixed_string_t mtu;
1426 cmd_config_mtu_parsed(void *parsed_result,
1427 __attribute__((unused)) struct cmdline *cl,
1428 __attribute__((unused)) void *data)
1430 struct cmd_config_mtu_result *res = parsed_result;
1432 if (res->value < ETHER_MIN_LEN) {
1433 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1436 port_mtu_set(res->port_id, res->value);
1439 cmdline_parse_token_string_t cmd_config_mtu_port =
1440 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1442 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1443 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1445 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1446 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1448 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1449 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1450 cmdline_parse_token_num_t cmd_config_mtu_value =
1451 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1453 cmdline_parse_inst_t cmd_config_mtu = {
1454 .f = cmd_config_mtu_parsed,
1456 .help_str = "port config mtu <port_id> <value>",
1458 (void *)&cmd_config_mtu_port,
1459 (void *)&cmd_config_mtu_keyword,
1460 (void *)&cmd_config_mtu_mtu,
1461 (void *)&cmd_config_mtu_port_id,
1462 (void *)&cmd_config_mtu_value,
1467 /* *** configure rx mode *** */
1468 struct cmd_config_rx_mode_flag {
1469 cmdline_fixed_string_t port;
1470 cmdline_fixed_string_t keyword;
1471 cmdline_fixed_string_t all;
1472 cmdline_fixed_string_t name;
1473 cmdline_fixed_string_t value;
1477 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1478 __attribute__((unused)) struct cmdline *cl,
1479 __attribute__((unused)) void *data)
1481 struct cmd_config_rx_mode_flag *res = parsed_result;
1483 if (!all_ports_stopped()) {
1484 printf("Please stop all ports first\n");
1488 if (!strcmp(res->name, "crc-strip")) {
1489 if (!strcmp(res->value, "on"))
1490 rx_mode.hw_strip_crc = 1;
1491 else if (!strcmp(res->value, "off"))
1492 rx_mode.hw_strip_crc = 0;
1494 printf("Unknown parameter\n");
1497 } else if (!strcmp(res->name, "scatter")) {
1498 if (!strcmp(res->value, "on"))
1499 rx_mode.enable_scatter = 1;
1500 else if (!strcmp(res->value, "off"))
1501 rx_mode.enable_scatter = 0;
1503 printf("Unknown parameter\n");
1506 } else if (!strcmp(res->name, "rx-cksum")) {
1507 if (!strcmp(res->value, "on"))
1508 rx_mode.hw_ip_checksum = 1;
1509 else if (!strcmp(res->value, "off"))
1510 rx_mode.hw_ip_checksum = 0;
1512 printf("Unknown parameter\n");
1515 } else if (!strcmp(res->name, "hw-vlan")) {
1516 if (!strcmp(res->value, "on")) {
1517 rx_mode.hw_vlan_filter = 1;
1518 rx_mode.hw_vlan_strip = 1;
1520 else if (!strcmp(res->value, "off")) {
1521 rx_mode.hw_vlan_filter = 0;
1522 rx_mode.hw_vlan_strip = 0;
1525 printf("Unknown parameter\n");
1528 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1529 if (!strcmp(res->value, "on"))
1530 rx_mode.hw_vlan_filter = 1;
1531 else if (!strcmp(res->value, "off"))
1532 rx_mode.hw_vlan_filter = 0;
1534 printf("Unknown parameter\n");
1537 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1538 if (!strcmp(res->value, "on"))
1539 rx_mode.hw_vlan_strip = 1;
1540 else if (!strcmp(res->value, "off"))
1541 rx_mode.hw_vlan_strip = 0;
1543 printf("Unknown parameter\n");
1546 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1547 if (!strcmp(res->value, "on"))
1548 rx_mode.hw_vlan_extend = 1;
1549 else if (!strcmp(res->value, "off"))
1550 rx_mode.hw_vlan_extend = 0;
1552 printf("Unknown parameter\n");
1555 } else if (!strcmp(res->name, "drop-en")) {
1556 if (!strcmp(res->value, "on"))
1558 else if (!strcmp(res->value, "off"))
1561 printf("Unknown parameter\n");
1565 printf("Unknown parameter\n");
1571 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1574 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1575 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1576 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1577 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1579 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1581 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1583 "crc-strip#scatter#rx-cksum#hw-vlan#"
1584 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1585 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1589 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1590 .f = cmd_config_rx_mode_flag_parsed,
1592 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1593 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1595 (void *)&cmd_config_rx_mode_flag_port,
1596 (void *)&cmd_config_rx_mode_flag_keyword,
1597 (void *)&cmd_config_rx_mode_flag_all,
1598 (void *)&cmd_config_rx_mode_flag_name,
1599 (void *)&cmd_config_rx_mode_flag_value,
1604 /* *** configure rss *** */
1605 struct cmd_config_rss {
1606 cmdline_fixed_string_t port;
1607 cmdline_fixed_string_t keyword;
1608 cmdline_fixed_string_t all;
1609 cmdline_fixed_string_t name;
1610 cmdline_fixed_string_t value;
1614 cmd_config_rss_parsed(void *parsed_result,
1615 __attribute__((unused)) struct cmdline *cl,
1616 __attribute__((unused)) void *data)
1618 struct cmd_config_rss *res = parsed_result;
1619 struct rte_eth_rss_conf rss_conf;
1623 if (!strcmp(res->value, "all"))
1624 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1625 ETH_RSS_UDP | ETH_RSS_SCTP |
1627 else if (!strcmp(res->value, "ip"))
1628 rss_conf.rss_hf = ETH_RSS_IP;
1629 else if (!strcmp(res->value, "udp"))
1630 rss_conf.rss_hf = ETH_RSS_UDP;
1631 else if (!strcmp(res->value, "tcp"))
1632 rss_conf.rss_hf = ETH_RSS_TCP;
1633 else if (!strcmp(res->value, "sctp"))
1634 rss_conf.rss_hf = ETH_RSS_SCTP;
1635 else if (!strcmp(res->value, "ether"))
1636 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1637 else if (!strcmp(res->value, "port"))
1638 rss_conf.rss_hf = ETH_RSS_PORT;
1639 else if (!strcmp(res->value, "vxlan"))
1640 rss_conf.rss_hf = ETH_RSS_VXLAN;
1641 else if (!strcmp(res->value, "geneve"))
1642 rss_conf.rss_hf = ETH_RSS_GENEVE;
1643 else if (!strcmp(res->value, "nvgre"))
1644 rss_conf.rss_hf = ETH_RSS_NVGRE;
1645 else if (!strcmp(res->value, "none"))
1646 rss_conf.rss_hf = 0;
1648 printf("Unknown parameter\n");
1651 rss_conf.rss_key = NULL;
1652 for (i = 0; i < rte_eth_dev_count(); i++) {
1653 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1655 printf("Configuration of RSS hash at ethernet port %d "
1656 "failed with error (%d): %s.\n",
1657 i, -diag, strerror(-diag));
1661 cmdline_parse_token_string_t cmd_config_rss_port =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1663 cmdline_parse_token_string_t cmd_config_rss_keyword =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1665 cmdline_parse_token_string_t cmd_config_rss_all =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1667 cmdline_parse_token_string_t cmd_config_rss_name =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1669 cmdline_parse_token_string_t cmd_config_rss_value =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1671 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1673 cmdline_parse_inst_t cmd_config_rss = {
1674 .f = cmd_config_rss_parsed,
1676 .help_str = "port config all rss "
1677 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1679 (void *)&cmd_config_rss_port,
1680 (void *)&cmd_config_rss_keyword,
1681 (void *)&cmd_config_rss_all,
1682 (void *)&cmd_config_rss_name,
1683 (void *)&cmd_config_rss_value,
1688 /* *** configure rss hash key *** */
1689 struct cmd_config_rss_hash_key {
1690 cmdline_fixed_string_t port;
1691 cmdline_fixed_string_t config;
1693 cmdline_fixed_string_t rss_hash_key;
1694 cmdline_fixed_string_t rss_type;
1695 cmdline_fixed_string_t key;
1699 hexa_digit_to_value(char hexa_digit)
1701 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1702 return (uint8_t) (hexa_digit - '0');
1703 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1704 return (uint8_t) ((hexa_digit - 'a') + 10);
1705 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1706 return (uint8_t) ((hexa_digit - 'A') + 10);
1707 /* Invalid hexa digit */
1712 parse_and_check_key_hexa_digit(char *key, int idx)
1716 hexa_v = hexa_digit_to_value(key[idx]);
1718 printf("invalid key: character %c at position %d is not a "
1719 "valid hexa digit\n", key[idx], idx);
1724 cmd_config_rss_hash_key_parsed(void *parsed_result,
1725 __attribute__((unused)) struct cmdline *cl,
1726 __attribute__((unused)) void *data)
1728 struct cmd_config_rss_hash_key *res = parsed_result;
1729 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1733 struct rte_eth_dev_info dev_info;
1734 uint8_t hash_key_size;
1737 memset(&dev_info, 0, sizeof(dev_info));
1738 rte_eth_dev_info_get(res->port_id, &dev_info);
1739 if (dev_info.hash_key_size > 0 &&
1740 dev_info.hash_key_size <= sizeof(hash_key))
1741 hash_key_size = dev_info.hash_key_size;
1743 printf("dev_info did not provide a valid hash key size\n");
1746 /* Check the length of the RSS hash key */
1747 key_len = strlen(res->key);
1748 if (key_len != (hash_key_size * 2)) {
1749 printf("key length: %d invalid - key must be a string of %d"
1750 " hexa-decimal numbers\n",
1751 (int) key_len, hash_key_size * 2);
1754 /* Translate RSS hash key into binary representation */
1755 for (i = 0; i < hash_key_size; i++) {
1756 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1759 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1762 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1764 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1768 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1770 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1771 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1773 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1774 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1775 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1777 rss_hash_key, "rss-hash-key");
1778 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1779 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1780 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1781 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1782 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1783 "ipv6-tcp-ex#ipv6-udp-ex");
1784 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1787 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1788 .f = cmd_config_rss_hash_key_parsed,
1790 .help_str = "port config <port_id> rss-hash-key "
1791 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1792 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1793 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1794 "<string of hex digits (variable length, NIC dependent)>",
1796 (void *)&cmd_config_rss_hash_key_port,
1797 (void *)&cmd_config_rss_hash_key_config,
1798 (void *)&cmd_config_rss_hash_key_port_id,
1799 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1800 (void *)&cmd_config_rss_hash_key_rss_type,
1801 (void *)&cmd_config_rss_hash_key_value,
1806 /* *** configure port rxq/txq start/stop *** */
1807 struct cmd_config_rxtx_queue {
1808 cmdline_fixed_string_t port;
1810 cmdline_fixed_string_t rxtxq;
1812 cmdline_fixed_string_t opname;
1816 cmd_config_rxtx_queue_parsed(void *parsed_result,
1817 __attribute__((unused)) struct cmdline *cl,
1818 __attribute__((unused)) void *data)
1820 struct cmd_config_rxtx_queue *res = parsed_result;
1825 if (test_done == 0) {
1826 printf("Please stop forwarding first\n");
1830 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1833 if (port_is_started(res->portid) != 1) {
1834 printf("Please start port %u first\n", res->portid);
1838 if (!strcmp(res->rxtxq, "rxq"))
1840 else if (!strcmp(res->rxtxq, "txq"))
1843 printf("Unknown parameter\n");
1847 if (isrx && rx_queue_id_is_invalid(res->qid))
1849 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1852 if (!strcmp(res->opname, "start"))
1854 else if (!strcmp(res->opname, "stop"))
1857 printf("Unknown parameter\n");
1861 if (isstart && isrx)
1862 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1863 else if (!isstart && isrx)
1864 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1865 else if (isstart && !isrx)
1866 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1868 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1870 if (ret == -ENOTSUP)
1871 printf("Function not supported in PMD driver\n");
1874 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1875 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1876 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1877 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1878 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1879 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1880 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1881 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1882 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1883 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1886 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1887 .f = cmd_config_rxtx_queue_parsed,
1889 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1891 (void *)&cmd_config_speed_all_port,
1892 (void *)&cmd_config_rxtx_queue_portid,
1893 (void *)&cmd_config_rxtx_queue_rxtxq,
1894 (void *)&cmd_config_rxtx_queue_qid,
1895 (void *)&cmd_config_rxtx_queue_opname,
1900 /* *** Configure RSS RETA *** */
1901 struct cmd_config_rss_reta {
1902 cmdline_fixed_string_t port;
1903 cmdline_fixed_string_t keyword;
1905 cmdline_fixed_string_t name;
1906 cmdline_fixed_string_t list_name;
1907 cmdline_fixed_string_t list_of_items;
1911 parse_reta_config(const char *str,
1912 struct rte_eth_rss_reta_entry64 *reta_conf,
1913 uint16_t nb_entries)
1917 uint16_t hash_index, idx, shift;
1920 const char *p, *p0 = str;
1927 unsigned long int_fld[_NUM_FLD];
1928 char *str_fld[_NUM_FLD];
1930 while ((p = strchr(p0,'(')) != NULL) {
1932 if((p0 = strchr(p,')')) == NULL)
1936 if(size >= sizeof(s))
1939 snprintf(s, sizeof(s), "%.*s", size, p);
1940 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1942 for (i = 0; i < _NUM_FLD; i++) {
1944 int_fld[i] = strtoul(str_fld[i], &end, 0);
1945 if (errno != 0 || end == str_fld[i] ||
1950 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1951 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1953 if (hash_index >= nb_entries) {
1954 printf("Invalid RETA hash index=%d\n", hash_index);
1958 idx = hash_index / RTE_RETA_GROUP_SIZE;
1959 shift = hash_index % RTE_RETA_GROUP_SIZE;
1960 reta_conf[idx].mask |= (1ULL << shift);
1961 reta_conf[idx].reta[shift] = nb_queue;
1968 cmd_set_rss_reta_parsed(void *parsed_result,
1969 __attribute__((unused)) struct cmdline *cl,
1970 __attribute__((unused)) void *data)
1973 struct rte_eth_dev_info dev_info;
1974 struct rte_eth_rss_reta_entry64 reta_conf[8];
1975 struct cmd_config_rss_reta *res = parsed_result;
1977 memset(&dev_info, 0, sizeof(dev_info));
1978 rte_eth_dev_info_get(res->port_id, &dev_info);
1979 if (dev_info.reta_size == 0) {
1980 printf("Redirection table size is 0 which is "
1981 "invalid for RSS\n");
1984 printf("The reta size of port %d is %u\n",
1985 res->port_id, dev_info.reta_size);
1986 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1987 printf("Currently do not support more than %u entries of "
1988 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1992 memset(reta_conf, 0, sizeof(reta_conf));
1993 if (!strcmp(res->list_name, "reta")) {
1994 if (parse_reta_config(res->list_of_items, reta_conf,
1995 dev_info.reta_size)) {
1996 printf("Invalid RSS Redirection Table "
1997 "config entered\n");
2000 ret = rte_eth_dev_rss_reta_update(res->port_id,
2001 reta_conf, dev_info.reta_size);
2003 printf("Bad redirection table parameter, "
2004 "return code = %d \n", ret);
2008 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2009 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2010 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2012 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2013 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2014 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2015 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2016 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2018 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2019 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2021 cmdline_parse_inst_t cmd_config_rss_reta = {
2022 .f = cmd_set_rss_reta_parsed,
2024 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2026 (void *)&cmd_config_rss_reta_port,
2027 (void *)&cmd_config_rss_reta_keyword,
2028 (void *)&cmd_config_rss_reta_port_id,
2029 (void *)&cmd_config_rss_reta_name,
2030 (void *)&cmd_config_rss_reta_list_name,
2031 (void *)&cmd_config_rss_reta_list_of_items,
2036 /* *** SHOW PORT RETA INFO *** */
2037 struct cmd_showport_reta {
2038 cmdline_fixed_string_t show;
2039 cmdline_fixed_string_t port;
2041 cmdline_fixed_string_t rss;
2042 cmdline_fixed_string_t reta;
2044 cmdline_fixed_string_t list_of_items;
2048 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2049 uint16_t nb_entries,
2053 const char *p, *p0 = str;
2057 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2060 p = strchr(p0, '(');
2064 p0 = strchr(p, ')');
2068 if (size >= sizeof(s)) {
2069 printf("The string size exceeds the internal buffer size\n");
2072 snprintf(s, sizeof(s), "%.*s", size, p);
2073 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2074 if (ret <= 0 || ret != num) {
2075 printf("The bits of masks do not match the number of "
2076 "reta entries: %u\n", num);
2079 for (i = 0; i < ret; i++)
2080 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2086 cmd_showport_reta_parsed(void *parsed_result,
2087 __attribute__((unused)) struct cmdline *cl,
2088 __attribute__((unused)) void *data)
2090 struct cmd_showport_reta *res = parsed_result;
2091 struct rte_eth_rss_reta_entry64 reta_conf[8];
2092 struct rte_eth_dev_info dev_info;
2094 memset(&dev_info, 0, sizeof(dev_info));
2095 rte_eth_dev_info_get(res->port_id, &dev_info);
2096 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2097 res->size > ETH_RSS_RETA_SIZE_512) {
2098 printf("Invalid redirection table size: %u\n", res->size);
2102 memset(reta_conf, 0, sizeof(reta_conf));
2103 if (showport_parse_reta_config(reta_conf, res->size,
2104 res->list_of_items) < 0) {
2105 printf("Invalid string: %s for reta masks\n",
2106 res->list_of_items);
2109 port_rss_reta_info(res->port_id, reta_conf, res->size);
2112 cmdline_parse_token_string_t cmd_showport_reta_show =
2113 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2114 cmdline_parse_token_string_t cmd_showport_reta_port =
2115 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2116 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2117 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2118 cmdline_parse_token_string_t cmd_showport_reta_rss =
2119 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2120 cmdline_parse_token_string_t cmd_showport_reta_reta =
2121 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2122 cmdline_parse_token_num_t cmd_showport_reta_size =
2123 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2124 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2125 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2126 list_of_items, NULL);
2128 cmdline_parse_inst_t cmd_showport_reta = {
2129 .f = cmd_showport_reta_parsed,
2131 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2133 (void *)&cmd_showport_reta_show,
2134 (void *)&cmd_showport_reta_port,
2135 (void *)&cmd_showport_reta_port_id,
2136 (void *)&cmd_showport_reta_rss,
2137 (void *)&cmd_showport_reta_reta,
2138 (void *)&cmd_showport_reta_size,
2139 (void *)&cmd_showport_reta_list_of_items,
2144 /* *** Show RSS hash configuration *** */
2145 struct cmd_showport_rss_hash {
2146 cmdline_fixed_string_t show;
2147 cmdline_fixed_string_t port;
2149 cmdline_fixed_string_t rss_hash;
2150 cmdline_fixed_string_t rss_type;
2151 cmdline_fixed_string_t key; /* optional argument */
2154 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2155 __attribute__((unused)) struct cmdline *cl,
2158 struct cmd_showport_rss_hash *res = parsed_result;
2160 port_rss_hash_conf_show(res->port_id, res->rss_type,
2161 show_rss_key != NULL);
2164 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2165 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2166 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2167 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2168 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2169 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2170 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2171 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2173 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2174 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2175 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2176 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2177 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2178 "ipv6-tcp-ex#ipv6-udp-ex");
2179 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2180 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2182 cmdline_parse_inst_t cmd_showport_rss_hash = {
2183 .f = cmd_showport_rss_hash_parsed,
2185 .help_str = "show port <port_id> rss-hash "
2186 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2187 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2188 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2190 (void *)&cmd_showport_rss_hash_show,
2191 (void *)&cmd_showport_rss_hash_port,
2192 (void *)&cmd_showport_rss_hash_port_id,
2193 (void *)&cmd_showport_rss_hash_rss_hash,
2194 (void *)&cmd_showport_rss_hash_rss_hash_info,
2199 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2200 .f = cmd_showport_rss_hash_parsed,
2202 .help_str = "show port <port_id> rss-hash "
2203 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2204 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2205 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2207 (void *)&cmd_showport_rss_hash_show,
2208 (void *)&cmd_showport_rss_hash_port,
2209 (void *)&cmd_showport_rss_hash_port_id,
2210 (void *)&cmd_showport_rss_hash_rss_hash,
2211 (void *)&cmd_showport_rss_hash_rss_hash_info,
2212 (void *)&cmd_showport_rss_hash_rss_key,
2217 /* *** Configure DCB *** */
2218 struct cmd_config_dcb {
2219 cmdline_fixed_string_t port;
2220 cmdline_fixed_string_t config;
2222 cmdline_fixed_string_t dcb;
2223 cmdline_fixed_string_t vt;
2224 cmdline_fixed_string_t vt_en;
2226 cmdline_fixed_string_t pfc;
2227 cmdline_fixed_string_t pfc_en;
2231 cmd_config_dcb_parsed(void *parsed_result,
2232 __attribute__((unused)) struct cmdline *cl,
2233 __attribute__((unused)) void *data)
2235 struct cmd_config_dcb *res = parsed_result;
2236 portid_t port_id = res->port_id;
2237 struct rte_port *port;
2241 port = &ports[port_id];
2242 /** Check if the port is not started **/
2243 if (port->port_status != RTE_PORT_STOPPED) {
2244 printf("Please stop port %d first\n", port_id);
2248 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2249 printf("The invalid number of traffic class,"
2250 " only 4 or 8 allowed.\n");
2254 if (nb_fwd_lcores < res->num_tcs) {
2255 printf("nb_cores shouldn't be less than number of TCs.\n");
2258 if (!strncmp(res->pfc_en, "on", 2))
2263 /* DCB in VT mode */
2264 if (!strncmp(res->vt_en, "on", 2))
2265 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2266 (enum rte_eth_nb_tcs)res->num_tcs,
2269 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2270 (enum rte_eth_nb_tcs)res->num_tcs,
2275 printf("Cannot initialize network ports.\n");
2279 cmd_reconfig_device_queue(port_id, 1, 1);
2282 cmdline_parse_token_string_t cmd_config_dcb_port =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2284 cmdline_parse_token_string_t cmd_config_dcb_config =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2286 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2287 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2288 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2289 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2290 cmdline_parse_token_string_t cmd_config_dcb_vt =
2291 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2292 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2293 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2294 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2295 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2296 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2298 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2299 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2301 cmdline_parse_inst_t cmd_config_dcb = {
2302 .f = cmd_config_dcb_parsed,
2304 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2306 (void *)&cmd_config_dcb_port,
2307 (void *)&cmd_config_dcb_config,
2308 (void *)&cmd_config_dcb_port_id,
2309 (void *)&cmd_config_dcb_dcb,
2310 (void *)&cmd_config_dcb_vt,
2311 (void *)&cmd_config_dcb_vt_en,
2312 (void *)&cmd_config_dcb_num_tcs,
2313 (void *)&cmd_config_dcb_pfc,
2314 (void *)&cmd_config_dcb_pfc_en,
2319 /* *** configure number of packets per burst *** */
2320 struct cmd_config_burst {
2321 cmdline_fixed_string_t port;
2322 cmdline_fixed_string_t keyword;
2323 cmdline_fixed_string_t all;
2324 cmdline_fixed_string_t name;
2329 cmd_config_burst_parsed(void *parsed_result,
2330 __attribute__((unused)) struct cmdline *cl,
2331 __attribute__((unused)) void *data)
2333 struct cmd_config_burst *res = parsed_result;
2335 if (!all_ports_stopped()) {
2336 printf("Please stop all ports first\n");
2340 if (!strcmp(res->name, "burst")) {
2341 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2342 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2345 nb_pkt_per_burst = res->value;
2347 printf("Unknown parameter\n");
2353 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2356 cmdline_parse_token_string_t cmd_config_burst_port =
2357 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2358 cmdline_parse_token_string_t cmd_config_burst_keyword =
2359 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2360 cmdline_parse_token_string_t cmd_config_burst_all =
2361 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2362 cmdline_parse_token_string_t cmd_config_burst_name =
2363 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2364 cmdline_parse_token_num_t cmd_config_burst_value =
2365 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2367 cmdline_parse_inst_t cmd_config_burst = {
2368 .f = cmd_config_burst_parsed,
2370 .help_str = "port config all burst <value>",
2372 (void *)&cmd_config_burst_port,
2373 (void *)&cmd_config_burst_keyword,
2374 (void *)&cmd_config_burst_all,
2375 (void *)&cmd_config_burst_name,
2376 (void *)&cmd_config_burst_value,
2381 /* *** configure rx/tx queues *** */
2382 struct cmd_config_thresh {
2383 cmdline_fixed_string_t port;
2384 cmdline_fixed_string_t keyword;
2385 cmdline_fixed_string_t all;
2386 cmdline_fixed_string_t name;
2391 cmd_config_thresh_parsed(void *parsed_result,
2392 __attribute__((unused)) struct cmdline *cl,
2393 __attribute__((unused)) void *data)
2395 struct cmd_config_thresh *res = parsed_result;
2397 if (!all_ports_stopped()) {
2398 printf("Please stop all ports first\n");
2402 if (!strcmp(res->name, "txpt"))
2403 tx_pthresh = res->value;
2404 else if(!strcmp(res->name, "txht"))
2405 tx_hthresh = res->value;
2406 else if(!strcmp(res->name, "txwt"))
2407 tx_wthresh = res->value;
2408 else if(!strcmp(res->name, "rxpt"))
2409 rx_pthresh = res->value;
2410 else if(!strcmp(res->name, "rxht"))
2411 rx_hthresh = res->value;
2412 else if(!strcmp(res->name, "rxwt"))
2413 rx_wthresh = res->value;
2415 printf("Unknown parameter\n");
2421 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2424 cmdline_parse_token_string_t cmd_config_thresh_port =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2426 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2427 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2428 cmdline_parse_token_string_t cmd_config_thresh_all =
2429 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2430 cmdline_parse_token_string_t cmd_config_thresh_name =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2432 "txpt#txht#txwt#rxpt#rxht#rxwt");
2433 cmdline_parse_token_num_t cmd_config_thresh_value =
2434 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2436 cmdline_parse_inst_t cmd_config_thresh = {
2437 .f = cmd_config_thresh_parsed,
2439 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2441 (void *)&cmd_config_thresh_port,
2442 (void *)&cmd_config_thresh_keyword,
2443 (void *)&cmd_config_thresh_all,
2444 (void *)&cmd_config_thresh_name,
2445 (void *)&cmd_config_thresh_value,
2450 /* *** configure free/rs threshold *** */
2451 struct cmd_config_threshold {
2452 cmdline_fixed_string_t port;
2453 cmdline_fixed_string_t keyword;
2454 cmdline_fixed_string_t all;
2455 cmdline_fixed_string_t name;
2460 cmd_config_threshold_parsed(void *parsed_result,
2461 __attribute__((unused)) struct cmdline *cl,
2462 __attribute__((unused)) void *data)
2464 struct cmd_config_threshold *res = parsed_result;
2466 if (!all_ports_stopped()) {
2467 printf("Please stop all ports first\n");
2471 if (!strcmp(res->name, "txfreet"))
2472 tx_free_thresh = res->value;
2473 else if (!strcmp(res->name, "txrst"))
2474 tx_rs_thresh = res->value;
2475 else if (!strcmp(res->name, "rxfreet"))
2476 rx_free_thresh = res->value;
2478 printf("Unknown parameter\n");
2484 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2487 cmdline_parse_token_string_t cmd_config_threshold_port =
2488 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2489 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2490 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2492 cmdline_parse_token_string_t cmd_config_threshold_all =
2493 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2494 cmdline_parse_token_string_t cmd_config_threshold_name =
2495 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2496 "txfreet#txrst#rxfreet");
2497 cmdline_parse_token_num_t cmd_config_threshold_value =
2498 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2500 cmdline_parse_inst_t cmd_config_threshold = {
2501 .f = cmd_config_threshold_parsed,
2503 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2505 (void *)&cmd_config_threshold_port,
2506 (void *)&cmd_config_threshold_keyword,
2507 (void *)&cmd_config_threshold_all,
2508 (void *)&cmd_config_threshold_name,
2509 (void *)&cmd_config_threshold_value,
2515 struct cmd_stop_result {
2516 cmdline_fixed_string_t stop;
2519 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2520 __attribute__((unused)) struct cmdline *cl,
2521 __attribute__((unused)) void *data)
2523 stop_packet_forwarding();
2526 cmdline_parse_token_string_t cmd_stop_stop =
2527 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2529 cmdline_parse_inst_t cmd_stop = {
2530 .f = cmd_stop_parsed,
2532 .help_str = "stop: Stop packet forwarding",
2534 (void *)&cmd_stop_stop,
2539 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2542 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2543 unsigned int *parsed_items, int check_unique_values)
2545 unsigned int nb_item;
2553 * First parse all items in the list and store their value.
2558 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2560 if ((c >= '0') && (c <= '9')) {
2561 value = (unsigned int) (value * 10 + (c - '0'));
2566 printf("character %c is not a decimal digit\n", c);
2570 printf("No valid value before comma\n");
2573 if (nb_item < max_items) {
2574 parsed_items[nb_item] = value;
2580 if (nb_item >= max_items) {
2581 printf("Number of %s = %u > %u (maximum items)\n",
2582 item_name, nb_item + 1, max_items);
2585 parsed_items[nb_item++] = value;
2586 if (! check_unique_values)
2590 * Then, check that all values in the list are differents.
2591 * No optimization here...
2593 for (i = 0; i < nb_item; i++) {
2594 for (j = i + 1; j < nb_item; j++) {
2595 if (parsed_items[j] == parsed_items[i]) {
2596 printf("duplicated %s %u at index %u and %u\n",
2597 item_name, parsed_items[i], i, j);
2605 struct cmd_set_list_result {
2606 cmdline_fixed_string_t cmd_keyword;
2607 cmdline_fixed_string_t list_name;
2608 cmdline_fixed_string_t list_of_items;
2611 static void cmd_set_list_parsed(void *parsed_result,
2612 __attribute__((unused)) struct cmdline *cl,
2613 __attribute__((unused)) void *data)
2615 struct cmd_set_list_result *res;
2617 unsigned int lcorelist[RTE_MAX_LCORE];
2618 unsigned int portlist[RTE_MAX_ETHPORTS];
2620 unsigned int nb_item;
2622 if (test_done == 0) {
2623 printf("Please stop forwarding first\n");
2627 res = parsed_result;
2628 if (!strcmp(res->list_name, "corelist")) {
2629 nb_item = parse_item_list(res->list_of_items, "core",
2631 parsed_items.lcorelist, 1);
2633 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2638 if (!strcmp(res->list_name, "portlist")) {
2639 nb_item = parse_item_list(res->list_of_items, "port",
2641 parsed_items.portlist, 1);
2643 set_fwd_ports_list(parsed_items.portlist, nb_item);
2649 cmdline_parse_token_string_t cmd_set_list_keyword =
2650 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2652 cmdline_parse_token_string_t cmd_set_list_name =
2653 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2654 "corelist#portlist");
2655 cmdline_parse_token_string_t cmd_set_list_of_items =
2656 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2659 cmdline_parse_inst_t cmd_set_fwd_list = {
2660 .f = cmd_set_list_parsed,
2662 .help_str = "set corelist|portlist <list0[,list1]*>",
2664 (void *)&cmd_set_list_keyword,
2665 (void *)&cmd_set_list_name,
2666 (void *)&cmd_set_list_of_items,
2671 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2673 struct cmd_setmask_result {
2674 cmdline_fixed_string_t set;
2675 cmdline_fixed_string_t mask;
2679 static void cmd_set_mask_parsed(void *parsed_result,
2680 __attribute__((unused)) struct cmdline *cl,
2681 __attribute__((unused)) void *data)
2683 struct cmd_setmask_result *res = parsed_result;
2685 if (test_done == 0) {
2686 printf("Please stop forwarding first\n");
2689 if (!strcmp(res->mask, "coremask")) {
2690 set_fwd_lcores_mask(res->hexavalue);
2692 } else if (!strcmp(res->mask, "portmask")) {
2693 set_fwd_ports_mask(res->hexavalue);
2698 cmdline_parse_token_string_t cmd_setmask_set =
2699 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2700 cmdline_parse_token_string_t cmd_setmask_mask =
2701 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2702 "coremask#portmask");
2703 cmdline_parse_token_num_t cmd_setmask_value =
2704 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2706 cmdline_parse_inst_t cmd_set_fwd_mask = {
2707 .f = cmd_set_mask_parsed,
2709 .help_str = "set coremask|portmask <hexadecimal value>",
2711 (void *)&cmd_setmask_set,
2712 (void *)&cmd_setmask_mask,
2713 (void *)&cmd_setmask_value,
2719 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2721 struct cmd_set_result {
2722 cmdline_fixed_string_t set;
2723 cmdline_fixed_string_t what;
2727 static void cmd_set_parsed(void *parsed_result,
2728 __attribute__((unused)) struct cmdline *cl,
2729 __attribute__((unused)) void *data)
2731 struct cmd_set_result *res = parsed_result;
2732 if (!strcmp(res->what, "nbport")) {
2733 set_fwd_ports_number(res->value);
2735 } else if (!strcmp(res->what, "nbcore")) {
2736 set_fwd_lcores_number(res->value);
2738 } else if (!strcmp(res->what, "burst"))
2739 set_nb_pkt_per_burst(res->value);
2740 else if (!strcmp(res->what, "verbose"))
2741 set_verbose_level(res->value);
2744 cmdline_parse_token_string_t cmd_set_set =
2745 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2746 cmdline_parse_token_string_t cmd_set_what =
2747 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2748 "nbport#nbcore#burst#verbose");
2749 cmdline_parse_token_num_t cmd_set_value =
2750 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2752 cmdline_parse_inst_t cmd_set_numbers = {
2753 .f = cmd_set_parsed,
2755 .help_str = "set nbport|nbcore|burst|verbose <value>",
2757 (void *)&cmd_set_set,
2758 (void *)&cmd_set_what,
2759 (void *)&cmd_set_value,
2764 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2766 struct cmd_set_txpkts_result {
2767 cmdline_fixed_string_t cmd_keyword;
2768 cmdline_fixed_string_t txpkts;
2769 cmdline_fixed_string_t seg_lengths;
2773 cmd_set_txpkts_parsed(void *parsed_result,
2774 __attribute__((unused)) struct cmdline *cl,
2775 __attribute__((unused)) void *data)
2777 struct cmd_set_txpkts_result *res;
2778 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2779 unsigned int nb_segs;
2781 res = parsed_result;
2782 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2783 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2785 set_tx_pkt_segments(seg_lengths, nb_segs);
2788 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2789 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2790 cmd_keyword, "set");
2791 cmdline_parse_token_string_t cmd_set_txpkts_name =
2792 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2794 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2795 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2798 cmdline_parse_inst_t cmd_set_txpkts = {
2799 .f = cmd_set_txpkts_parsed,
2801 .help_str = "set txpkts <len0[,len1]*>",
2803 (void *)&cmd_set_txpkts_keyword,
2804 (void *)&cmd_set_txpkts_name,
2805 (void *)&cmd_set_txpkts_lengths,
2810 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2812 struct cmd_set_txsplit_result {
2813 cmdline_fixed_string_t cmd_keyword;
2814 cmdline_fixed_string_t txsplit;
2815 cmdline_fixed_string_t mode;
2819 cmd_set_txsplit_parsed(void *parsed_result,
2820 __attribute__((unused)) struct cmdline *cl,
2821 __attribute__((unused)) void *data)
2823 struct cmd_set_txsplit_result *res;
2825 res = parsed_result;
2826 set_tx_pkt_split(res->mode);
2829 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2830 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2831 cmd_keyword, "set");
2832 cmdline_parse_token_string_t cmd_set_txsplit_name =
2833 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2834 txsplit, "txsplit");
2835 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2836 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2839 cmdline_parse_inst_t cmd_set_txsplit = {
2840 .f = cmd_set_txsplit_parsed,
2842 .help_str = "set txsplit on|off|rand",
2844 (void *)&cmd_set_txsplit_keyword,
2845 (void *)&cmd_set_txsplit_name,
2846 (void *)&cmd_set_txsplit_mode,
2851 /* *** CONFIG TX QUEUE FLAGS *** */
2853 struct cmd_config_txqflags_result {
2854 cmdline_fixed_string_t port;
2855 cmdline_fixed_string_t config;
2856 cmdline_fixed_string_t all;
2857 cmdline_fixed_string_t what;
2861 static void cmd_config_txqflags_parsed(void *parsed_result,
2862 __attribute__((unused)) struct cmdline *cl,
2863 __attribute__((unused)) void *data)
2865 struct cmd_config_txqflags_result *res = parsed_result;
2867 if (!all_ports_stopped()) {
2868 printf("Please stop all ports first\n");
2872 if (strcmp(res->what, "txqflags")) {
2873 printf("Unknown parameter\n");
2877 if (res->hexvalue >= 0) {
2878 txq_flags = res->hexvalue;
2880 printf("txqflags must be >= 0\n");
2886 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2889 cmdline_parse_token_string_t cmd_config_txqflags_port =
2890 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2892 cmdline_parse_token_string_t cmd_config_txqflags_config =
2893 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2895 cmdline_parse_token_string_t cmd_config_txqflags_all =
2896 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2898 cmdline_parse_token_string_t cmd_config_txqflags_what =
2899 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2901 cmdline_parse_token_num_t cmd_config_txqflags_value =
2902 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2905 cmdline_parse_inst_t cmd_config_txqflags = {
2906 .f = cmd_config_txqflags_parsed,
2908 .help_str = "port config all txqflags <value>",
2910 (void *)&cmd_config_txqflags_port,
2911 (void *)&cmd_config_txqflags_config,
2912 (void *)&cmd_config_txqflags_all,
2913 (void *)&cmd_config_txqflags_what,
2914 (void *)&cmd_config_txqflags_value,
2919 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2920 struct cmd_rx_vlan_filter_all_result {
2921 cmdline_fixed_string_t rx_vlan;
2922 cmdline_fixed_string_t what;
2923 cmdline_fixed_string_t all;
2928 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2929 __attribute__((unused)) struct cmdline *cl,
2930 __attribute__((unused)) void *data)
2932 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2934 if (!strcmp(res->what, "add"))
2935 rx_vlan_all_filter_set(res->port_id, 1);
2937 rx_vlan_all_filter_set(res->port_id, 0);
2940 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2941 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2942 rx_vlan, "rx_vlan");
2943 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2944 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2946 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2947 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2949 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2950 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2953 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2954 .f = cmd_rx_vlan_filter_all_parsed,
2956 .help_str = "rx_vlan add|rm all <port_id>: "
2957 "Add/Remove all identifiers to/from the set of VLAN "
2958 "identifiers filtered by a port",
2960 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2961 (void *)&cmd_rx_vlan_filter_all_what,
2962 (void *)&cmd_rx_vlan_filter_all_all,
2963 (void *)&cmd_rx_vlan_filter_all_portid,
2968 /* *** VLAN OFFLOAD SET ON A PORT *** */
2969 struct cmd_vlan_offload_result {
2970 cmdline_fixed_string_t vlan;
2971 cmdline_fixed_string_t set;
2972 cmdline_fixed_string_t vlan_type;
2973 cmdline_fixed_string_t what;
2974 cmdline_fixed_string_t on;
2975 cmdline_fixed_string_t port_id;
2979 cmd_vlan_offload_parsed(void *parsed_result,
2980 __attribute__((unused)) struct cmdline *cl,
2981 __attribute__((unused)) void *data)
2984 struct cmd_vlan_offload_result *res = parsed_result;
2987 portid_t port_id = 0;
2991 len = strnlen(str, STR_TOKEN_SIZE);
2993 /* Get port_id first */
3001 tmp = strtoul(str, NULL, 0);
3002 /* If port_id greater that what portid_t can represent, return */
3003 if(tmp >= RTE_MAX_ETHPORTS)
3005 port_id = (portid_t)tmp;
3007 if (!strcmp(res->on, "on"))
3012 if (!strcmp(res->what, "strip"))
3013 rx_vlan_strip_set(port_id, on);
3014 else if(!strcmp(res->what, "stripq")){
3015 uint16_t queue_id = 0;
3017 /* No queue_id, return */
3019 printf("must specify (port,queue_id)\n");
3022 tmp = strtoul(str + i + 1, NULL, 0);
3023 /* If queue_id greater that what 16-bits can represent, return */
3027 queue_id = (uint16_t)tmp;
3028 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3030 else if (!strcmp(res->what, "filter"))
3031 rx_vlan_filter_set(port_id, on);
3033 vlan_extend_set(port_id, on);
3038 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3039 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3041 cmdline_parse_token_string_t cmd_vlan_offload_set =
3042 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3044 cmdline_parse_token_string_t cmd_vlan_offload_what =
3045 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3046 what, "strip#filter#qinq#stripq");
3047 cmdline_parse_token_string_t cmd_vlan_offload_on =
3048 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3050 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3051 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3054 cmdline_parse_inst_t cmd_vlan_offload = {
3055 .f = cmd_vlan_offload_parsed,
3057 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3058 "<port_id[,queue_id]>: "
3059 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3061 (void *)&cmd_vlan_offload_vlan,
3062 (void *)&cmd_vlan_offload_set,
3063 (void *)&cmd_vlan_offload_what,
3064 (void *)&cmd_vlan_offload_on,
3065 (void *)&cmd_vlan_offload_portid,
3070 /* *** VLAN TPID SET ON A PORT *** */
3071 struct cmd_vlan_tpid_result {
3072 cmdline_fixed_string_t vlan;
3073 cmdline_fixed_string_t set;
3074 cmdline_fixed_string_t vlan_type;
3075 cmdline_fixed_string_t what;
3081 cmd_vlan_tpid_parsed(void *parsed_result,
3082 __attribute__((unused)) struct cmdline *cl,
3083 __attribute__((unused)) void *data)
3085 struct cmd_vlan_tpid_result *res = parsed_result;
3086 enum rte_vlan_type vlan_type;
3088 if (!strcmp(res->vlan_type, "inner"))
3089 vlan_type = ETH_VLAN_TYPE_INNER;
3090 else if (!strcmp(res->vlan_type, "outer"))
3091 vlan_type = ETH_VLAN_TYPE_OUTER;
3093 printf("Unknown vlan type\n");
3096 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3099 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3100 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3102 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3103 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3105 cmdline_parse_token_string_t cmd_vlan_type =
3106 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3107 vlan_type, "inner#outer");
3108 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3109 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3111 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3112 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3114 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3115 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3118 cmdline_parse_inst_t cmd_vlan_tpid = {
3119 .f = cmd_vlan_tpid_parsed,
3121 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3122 "Set the VLAN Ether type",
3124 (void *)&cmd_vlan_tpid_vlan,
3125 (void *)&cmd_vlan_tpid_set,
3126 (void *)&cmd_vlan_type,
3127 (void *)&cmd_vlan_tpid_what,
3128 (void *)&cmd_vlan_tpid_tpid,
3129 (void *)&cmd_vlan_tpid_portid,
3134 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3135 struct cmd_rx_vlan_filter_result {
3136 cmdline_fixed_string_t rx_vlan;
3137 cmdline_fixed_string_t what;
3143 cmd_rx_vlan_filter_parsed(void *parsed_result,
3144 __attribute__((unused)) struct cmdline *cl,
3145 __attribute__((unused)) void *data)
3147 struct cmd_rx_vlan_filter_result *res = parsed_result;
3149 if (!strcmp(res->what, "add"))
3150 rx_vft_set(res->port_id, res->vlan_id, 1);
3152 rx_vft_set(res->port_id, res->vlan_id, 0);
3155 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3156 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3157 rx_vlan, "rx_vlan");
3158 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3159 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3161 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3162 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3164 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3165 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3168 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3169 .f = cmd_rx_vlan_filter_parsed,
3171 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3172 "Add/Remove a VLAN identifier to/from the set of VLAN "
3173 "identifiers filtered by a port",
3175 (void *)&cmd_rx_vlan_filter_rx_vlan,
3176 (void *)&cmd_rx_vlan_filter_what,
3177 (void *)&cmd_rx_vlan_filter_vlanid,
3178 (void *)&cmd_rx_vlan_filter_portid,
3183 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3184 struct cmd_tx_vlan_set_result {
3185 cmdline_fixed_string_t tx_vlan;
3186 cmdline_fixed_string_t set;
3192 cmd_tx_vlan_set_parsed(void *parsed_result,
3193 __attribute__((unused)) struct cmdline *cl,
3194 __attribute__((unused)) void *data)
3196 struct cmd_tx_vlan_set_result *res = parsed_result;
3198 tx_vlan_set(res->port_id, res->vlan_id);
3201 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3202 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3203 tx_vlan, "tx_vlan");
3204 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3205 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3207 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3208 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3210 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3211 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3214 cmdline_parse_inst_t cmd_tx_vlan_set = {
3215 .f = cmd_tx_vlan_set_parsed,
3217 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3218 "Enable hardware insertion of a single VLAN header "
3219 "with a given TAG Identifier in packets sent on a port",
3221 (void *)&cmd_tx_vlan_set_tx_vlan,
3222 (void *)&cmd_tx_vlan_set_set,
3223 (void *)&cmd_tx_vlan_set_portid,
3224 (void *)&cmd_tx_vlan_set_vlanid,
3229 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3230 struct cmd_tx_vlan_set_qinq_result {
3231 cmdline_fixed_string_t tx_vlan;
3232 cmdline_fixed_string_t set;
3235 uint16_t vlan_id_outer;
3239 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3240 __attribute__((unused)) struct cmdline *cl,
3241 __attribute__((unused)) void *data)
3243 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3245 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3248 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3249 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3250 tx_vlan, "tx_vlan");
3251 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3252 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3254 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3255 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3257 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3258 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3260 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3261 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3262 vlan_id_outer, UINT16);
3264 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3265 .f = cmd_tx_vlan_set_qinq_parsed,
3267 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3268 "Enable hardware insertion of double VLAN header "
3269 "with given TAG Identifiers in packets sent on a port",
3271 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3272 (void *)&cmd_tx_vlan_set_qinq_set,
3273 (void *)&cmd_tx_vlan_set_qinq_portid,
3274 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3275 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3280 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3281 struct cmd_tx_vlan_set_pvid_result {
3282 cmdline_fixed_string_t tx_vlan;
3283 cmdline_fixed_string_t set;
3284 cmdline_fixed_string_t pvid;
3287 cmdline_fixed_string_t mode;
3291 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3292 __attribute__((unused)) struct cmdline *cl,
3293 __attribute__((unused)) void *data)
3295 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3297 if (strcmp(res->mode, "on") == 0)
3298 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3300 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3303 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3304 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3305 tx_vlan, "tx_vlan");
3306 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3307 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3309 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3310 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3312 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3313 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3315 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3316 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3318 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3319 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3322 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3323 .f = cmd_tx_vlan_set_pvid_parsed,
3325 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3327 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3328 (void *)&cmd_tx_vlan_set_pvid_set,
3329 (void *)&cmd_tx_vlan_set_pvid_pvid,
3330 (void *)&cmd_tx_vlan_set_pvid_port_id,
3331 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3332 (void *)&cmd_tx_vlan_set_pvid_mode,
3337 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3338 struct cmd_tx_vlan_reset_result {
3339 cmdline_fixed_string_t tx_vlan;
3340 cmdline_fixed_string_t reset;
3345 cmd_tx_vlan_reset_parsed(void *parsed_result,
3346 __attribute__((unused)) struct cmdline *cl,
3347 __attribute__((unused)) void *data)
3349 struct cmd_tx_vlan_reset_result *res = parsed_result;
3351 tx_vlan_reset(res->port_id);
3354 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3355 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3356 tx_vlan, "tx_vlan");
3357 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3358 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3360 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3361 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3364 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3365 .f = cmd_tx_vlan_reset_parsed,
3367 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3368 "VLAN header in packets sent on a port",
3370 (void *)&cmd_tx_vlan_reset_tx_vlan,
3371 (void *)&cmd_tx_vlan_reset_reset,
3372 (void *)&cmd_tx_vlan_reset_portid,
3378 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3379 struct cmd_csum_result {
3380 cmdline_fixed_string_t csum;
3381 cmdline_fixed_string_t mode;
3382 cmdline_fixed_string_t proto;
3383 cmdline_fixed_string_t hwsw;
3388 csum_show(int port_id)
3390 struct rte_eth_dev_info dev_info;
3393 ol_flags = ports[port_id].tx_ol_flags;
3394 printf("Parse tunnel is %s\n",
3395 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3396 printf("IP checksum offload is %s\n",
3397 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3398 printf("UDP checksum offload is %s\n",
3399 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3400 printf("TCP checksum offload is %s\n",
3401 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3402 printf("SCTP checksum offload is %s\n",
3403 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3404 printf("Outer-Ip checksum offload is %s\n",
3405 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3407 /* display warnings if configuration is not supported by the NIC */
3408 rte_eth_dev_info_get(port_id, &dev_info);
3409 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3410 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3411 printf("Warning: hardware IP checksum enabled but not "
3412 "supported by port %d\n", port_id);
3414 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3415 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3416 printf("Warning: hardware UDP checksum enabled but not "
3417 "supported by port %d\n", port_id);
3419 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3420 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3421 printf("Warning: hardware TCP checksum enabled but not "
3422 "supported by port %d\n", port_id);
3424 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3425 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3426 printf("Warning: hardware SCTP checksum enabled but not "
3427 "supported by port %d\n", port_id);
3429 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3430 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3431 printf("Warning: hardware outer IP checksum enabled but not "
3432 "supported by port %d\n", port_id);
3437 cmd_csum_parsed(void *parsed_result,
3438 __attribute__((unused)) struct cmdline *cl,
3439 __attribute__((unused)) void *data)
3441 struct cmd_csum_result *res = parsed_result;
3445 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3446 printf("invalid port %d\n", res->port_id);
3450 if (!strcmp(res->mode, "set")) {
3452 if (!strcmp(res->hwsw, "hw"))
3455 if (!strcmp(res->proto, "ip")) {
3456 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3457 } else if (!strcmp(res->proto, "udp")) {
3458 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3459 } else if (!strcmp(res->proto, "tcp")) {
3460 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3461 } else if (!strcmp(res->proto, "sctp")) {
3462 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3463 } else if (!strcmp(res->proto, "outer-ip")) {
3464 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3468 ports[res->port_id].tx_ol_flags |= mask;
3470 ports[res->port_id].tx_ol_flags &= (~mask);
3472 csum_show(res->port_id);
3475 cmdline_parse_token_string_t cmd_csum_csum =
3476 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3478 cmdline_parse_token_string_t cmd_csum_mode =
3479 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3481 cmdline_parse_token_string_t cmd_csum_proto =
3482 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3483 proto, "ip#tcp#udp#sctp#outer-ip");
3484 cmdline_parse_token_string_t cmd_csum_hwsw =
3485 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3487 cmdline_parse_token_num_t cmd_csum_portid =
3488 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3491 cmdline_parse_inst_t cmd_csum_set = {
3492 .f = cmd_csum_parsed,
3494 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3495 "Enable/Disable hardware calculation of L3/L4 checksum when "
3496 "using csum forward engine",
3498 (void *)&cmd_csum_csum,
3499 (void *)&cmd_csum_mode,
3500 (void *)&cmd_csum_proto,
3501 (void *)&cmd_csum_hwsw,
3502 (void *)&cmd_csum_portid,
3507 cmdline_parse_token_string_t cmd_csum_mode_show =
3508 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3511 cmdline_parse_inst_t cmd_csum_show = {
3512 .f = cmd_csum_parsed,
3514 .help_str = "csum show <port_id>: Show checksum offload configuration",
3516 (void *)&cmd_csum_csum,
3517 (void *)&cmd_csum_mode_show,
3518 (void *)&cmd_csum_portid,
3523 /* Enable/disable tunnel parsing */
3524 struct cmd_csum_tunnel_result {
3525 cmdline_fixed_string_t csum;
3526 cmdline_fixed_string_t parse;
3527 cmdline_fixed_string_t onoff;
3532 cmd_csum_tunnel_parsed(void *parsed_result,
3533 __attribute__((unused)) struct cmdline *cl,
3534 __attribute__((unused)) void *data)
3536 struct cmd_csum_tunnel_result *res = parsed_result;
3538 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3541 if (!strcmp(res->onoff, "on"))
3542 ports[res->port_id].tx_ol_flags |=
3543 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3545 ports[res->port_id].tx_ol_flags &=
3546 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3548 csum_show(res->port_id);
3551 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3552 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3554 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3555 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3556 parse, "parse_tunnel");
3557 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3558 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3560 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3561 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3564 cmdline_parse_inst_t cmd_csum_tunnel = {
3565 .f = cmd_csum_tunnel_parsed,
3567 .help_str = "csum parse_tunnel on|off <port_id>: "
3568 "Enable/Disable parsing of tunnels for csum engine",
3570 (void *)&cmd_csum_tunnel_csum,
3571 (void *)&cmd_csum_tunnel_parse,
3572 (void *)&cmd_csum_tunnel_onoff,
3573 (void *)&cmd_csum_tunnel_portid,
3578 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3579 struct cmd_tso_set_result {
3580 cmdline_fixed_string_t tso;
3581 cmdline_fixed_string_t mode;
3587 cmd_tso_set_parsed(void *parsed_result,
3588 __attribute__((unused)) struct cmdline *cl,
3589 __attribute__((unused)) void *data)
3591 struct cmd_tso_set_result *res = parsed_result;
3592 struct rte_eth_dev_info dev_info;
3594 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3597 if (!strcmp(res->mode, "set"))
3598 ports[res->port_id].tso_segsz = res->tso_segsz;
3600 if (ports[res->port_id].tso_segsz == 0)
3601 printf("TSO for non-tunneled packets is disabled\n");
3603 printf("TSO segment size for non-tunneled packets is %d\n",
3604 ports[res->port_id].tso_segsz);
3606 /* display warnings if configuration is not supported by the NIC */
3607 rte_eth_dev_info_get(res->port_id, &dev_info);
3608 if ((ports[res->port_id].tso_segsz != 0) &&
3609 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3610 printf("Warning: TSO enabled but not "
3611 "supported by port %d\n", res->port_id);
3615 cmdline_parse_token_string_t cmd_tso_set_tso =
3616 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3618 cmdline_parse_token_string_t cmd_tso_set_mode =
3619 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3621 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3622 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3624 cmdline_parse_token_num_t cmd_tso_set_portid =
3625 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3628 cmdline_parse_inst_t cmd_tso_set = {
3629 .f = cmd_tso_set_parsed,
3631 .help_str = "tso set <tso_segsz> <port_id>: "
3632 "Set TSO segment size of non-tunneled packets for csum engine "
3635 (void *)&cmd_tso_set_tso,
3636 (void *)&cmd_tso_set_mode,
3637 (void *)&cmd_tso_set_tso_segsz,
3638 (void *)&cmd_tso_set_portid,
3643 cmdline_parse_token_string_t cmd_tso_show_mode =
3644 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3648 cmdline_parse_inst_t cmd_tso_show = {
3649 .f = cmd_tso_set_parsed,
3651 .help_str = "tso show <port_id>: "
3652 "Show TSO segment size of non-tunneled packets for csum engine",
3654 (void *)&cmd_tso_set_tso,
3655 (void *)&cmd_tso_show_mode,
3656 (void *)&cmd_tso_set_portid,
3661 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3662 struct cmd_tunnel_tso_set_result {
3663 cmdline_fixed_string_t tso;
3664 cmdline_fixed_string_t mode;
3670 check_tunnel_tso_nic_support(uint8_t port_id)
3672 struct rte_eth_dev_info dev_info;
3674 rte_eth_dev_info_get(port_id, &dev_info);
3675 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3676 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3677 "supported by port %d\n", port_id);
3678 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3679 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3680 "supported by port %d\n", port_id);
3681 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3682 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3683 "supported by port %d\n", port_id);
3684 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3685 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3686 "supported by port %d\n", port_id);
3690 cmd_tunnel_tso_set_parsed(void *parsed_result,
3691 __attribute__((unused)) struct cmdline *cl,
3692 __attribute__((unused)) void *data)
3694 struct cmd_tunnel_tso_set_result *res = parsed_result;
3696 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3699 if (!strcmp(res->mode, "set"))
3700 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3702 if (ports[res->port_id].tunnel_tso_segsz == 0)
3703 printf("TSO for tunneled packets is disabled\n");
3705 printf("TSO segment size for tunneled packets is %d\n",
3706 ports[res->port_id].tunnel_tso_segsz);
3708 /* Below conditions are needed to make it work:
3709 * (1) tunnel TSO is supported by the NIC;
3710 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3712 * (3) for tunneled pkts with outer L3 of IPv4,
3713 * "csum set outer-ip" must be set to hw, because after tso,
3714 * total_len of outer IP header is changed, and the checksum
3715 * of outer IP header calculated by sw should be wrong; that
3716 * is not necessary for IPv6 tunneled pkts because there's no
3717 * checksum in IP header anymore.
3719 check_tunnel_tso_nic_support(res->port_id);
3721 if (!(ports[res->port_id].tx_ol_flags &
3722 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3723 printf("Warning: csum parse_tunnel must be set "
3724 "so that tunneled packets are recognized\n");
3725 if (!(ports[res->port_id].tx_ol_flags &
3726 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3727 printf("Warning: csum set outer-ip must be set to hw "
3728 "if outer L3 is IPv4; not necessary for IPv6\n");
3732 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3733 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3735 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3736 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3738 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3739 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3741 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3742 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3745 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3746 .f = cmd_tunnel_tso_set_parsed,
3748 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3749 "Set TSO segment size of tunneled packets for csum engine "
3752 (void *)&cmd_tunnel_tso_set_tso,
3753 (void *)&cmd_tunnel_tso_set_mode,
3754 (void *)&cmd_tunnel_tso_set_tso_segsz,
3755 (void *)&cmd_tunnel_tso_set_portid,
3760 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3761 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3765 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3766 .f = cmd_tunnel_tso_set_parsed,
3768 .help_str = "tunnel_tso show <port_id> "
3769 "Show TSO segment size of tunneled packets for csum engine",
3771 (void *)&cmd_tunnel_tso_set_tso,
3772 (void *)&cmd_tunnel_tso_show_mode,
3773 (void *)&cmd_tunnel_tso_set_portid,
3778 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3779 struct cmd_set_flush_rx {
3780 cmdline_fixed_string_t set;
3781 cmdline_fixed_string_t flush_rx;
3782 cmdline_fixed_string_t mode;
3786 cmd_set_flush_rx_parsed(void *parsed_result,
3787 __attribute__((unused)) struct cmdline *cl,
3788 __attribute__((unused)) void *data)
3790 struct cmd_set_flush_rx *res = parsed_result;
3791 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3794 cmdline_parse_token_string_t cmd_setflushrx_set =
3795 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3797 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3799 flush_rx, "flush_rx");
3800 cmdline_parse_token_string_t cmd_setflushrx_mode =
3801 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3805 cmdline_parse_inst_t cmd_set_flush_rx = {
3806 .f = cmd_set_flush_rx_parsed,
3807 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3810 (void *)&cmd_setflushrx_set,
3811 (void *)&cmd_setflushrx_flush_rx,
3812 (void *)&cmd_setflushrx_mode,
3817 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3818 struct cmd_set_link_check {
3819 cmdline_fixed_string_t set;
3820 cmdline_fixed_string_t link_check;
3821 cmdline_fixed_string_t mode;
3825 cmd_set_link_check_parsed(void *parsed_result,
3826 __attribute__((unused)) struct cmdline *cl,
3827 __attribute__((unused)) void *data)
3829 struct cmd_set_link_check *res = parsed_result;
3830 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3833 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3834 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3836 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3837 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3838 link_check, "link_check");
3839 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3840 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3844 cmdline_parse_inst_t cmd_set_link_check = {
3845 .f = cmd_set_link_check_parsed,
3846 .help_str = "set link_check on|off: Enable/Disable link status check "
3847 "when starting/stopping a port",
3850 (void *)&cmd_setlinkcheck_set,
3851 (void *)&cmd_setlinkcheck_link_check,
3852 (void *)&cmd_setlinkcheck_mode,
3857 #ifdef RTE_NIC_BYPASS
3858 /* *** SET NIC BYPASS MODE *** */
3859 struct cmd_set_bypass_mode_result {
3860 cmdline_fixed_string_t set;
3861 cmdline_fixed_string_t bypass;
3862 cmdline_fixed_string_t mode;
3863 cmdline_fixed_string_t value;
3868 cmd_set_bypass_mode_parsed(void *parsed_result,
3869 __attribute__((unused)) struct cmdline *cl,
3870 __attribute__((unused)) void *data)
3872 struct cmd_set_bypass_mode_result *res = parsed_result;
3873 portid_t port_id = res->port_id;
3874 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3876 if (!strcmp(res->value, "bypass"))
3877 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3878 else if (!strcmp(res->value, "isolate"))
3879 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3881 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3883 /* Set the bypass mode for the relevant port. */
3884 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3885 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3889 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3890 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3892 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3893 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3895 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3896 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3898 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3899 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3900 value, "normal#bypass#isolate");
3901 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3902 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3905 cmdline_parse_inst_t cmd_set_bypass_mode = {
3906 .f = cmd_set_bypass_mode_parsed,
3907 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3908 "Set the NIC bypass mode for port_id",
3911 (void *)&cmd_setbypass_mode_set,
3912 (void *)&cmd_setbypass_mode_bypass,
3913 (void *)&cmd_setbypass_mode_mode,
3914 (void *)&cmd_setbypass_mode_value,
3915 (void *)&cmd_setbypass_mode_port,
3920 /* *** SET NIC BYPASS EVENT *** */
3921 struct cmd_set_bypass_event_result {
3922 cmdline_fixed_string_t set;
3923 cmdline_fixed_string_t bypass;
3924 cmdline_fixed_string_t event;
3925 cmdline_fixed_string_t event_value;
3926 cmdline_fixed_string_t mode;
3927 cmdline_fixed_string_t mode_value;
3932 cmd_set_bypass_event_parsed(void *parsed_result,
3933 __attribute__((unused)) struct cmdline *cl,
3934 __attribute__((unused)) void *data)
3937 struct cmd_set_bypass_event_result *res = parsed_result;
3938 portid_t port_id = res->port_id;
3939 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3940 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3942 if (!strcmp(res->event_value, "timeout"))
3943 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3944 else if (!strcmp(res->event_value, "os_on"))
3945 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3946 else if (!strcmp(res->event_value, "os_off"))
3947 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3948 else if (!strcmp(res->event_value, "power_on"))
3949 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3950 else if (!strcmp(res->event_value, "power_off"))
3951 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3953 bypass_event = RTE_BYPASS_EVENT_NONE;
3955 if (!strcmp(res->mode_value, "bypass"))
3956 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3957 else if (!strcmp(res->mode_value, "isolate"))
3958 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3960 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3962 /* Set the watchdog timeout. */
3963 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3966 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3967 (rc = rte_eth_dev_wd_timeout_store(port_id,
3968 bypass_timeout)) != 0) {
3969 printf("Failed to set timeout value %u "
3970 "for port %d, errto code: %d.\n",
3971 bypass_timeout, port_id, rc);
3975 /* Set the bypass event to transition to bypass mode. */
3976 if (0 != rte_eth_dev_bypass_event_store(port_id,
3977 bypass_event, bypass_mode)) {
3978 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3983 cmdline_parse_token_string_t cmd_setbypass_event_set =
3984 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3986 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3987 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3989 cmdline_parse_token_string_t cmd_setbypass_event_event =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3992 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3994 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3995 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3996 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3998 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3999 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4000 mode_value, "normal#bypass#isolate");
4001 cmdline_parse_token_num_t cmd_setbypass_event_port =
4002 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4005 cmdline_parse_inst_t cmd_set_bypass_event = {
4006 .f = cmd_set_bypass_event_parsed,
4007 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4008 "power_off mode normal|bypass|isolate <port_id>: "
4009 "Set the NIC bypass event mode for port_id",
4012 (void *)&cmd_setbypass_event_set,
4013 (void *)&cmd_setbypass_event_bypass,
4014 (void *)&cmd_setbypass_event_event,
4015 (void *)&cmd_setbypass_event_event_value,
4016 (void *)&cmd_setbypass_event_mode,
4017 (void *)&cmd_setbypass_event_mode_value,
4018 (void *)&cmd_setbypass_event_port,
4024 /* *** SET NIC BYPASS TIMEOUT *** */
4025 struct cmd_set_bypass_timeout_result {
4026 cmdline_fixed_string_t set;
4027 cmdline_fixed_string_t bypass;
4028 cmdline_fixed_string_t timeout;
4029 cmdline_fixed_string_t value;
4033 cmd_set_bypass_timeout_parsed(void *parsed_result,
4034 __attribute__((unused)) struct cmdline *cl,
4035 __attribute__((unused)) void *data)
4037 struct cmd_set_bypass_timeout_result *res = parsed_result;
4039 if (!strcmp(res->value, "1.5"))
4040 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4041 else if (!strcmp(res->value, "2"))
4042 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4043 else if (!strcmp(res->value, "3"))
4044 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4045 else if (!strcmp(res->value, "4"))
4046 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4047 else if (!strcmp(res->value, "8"))
4048 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4049 else if (!strcmp(res->value, "16"))
4050 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4051 else if (!strcmp(res->value, "32"))
4052 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4054 bypass_timeout = RTE_BYPASS_TMT_OFF;
4057 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4058 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4060 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4061 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4063 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4064 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4065 timeout, "timeout");
4066 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4067 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4068 value, "0#1.5#2#3#4#8#16#32");
4070 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4071 .f = cmd_set_bypass_timeout_parsed,
4072 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4073 "Set the NIC bypass watchdog timeout in seconds",
4076 (void *)&cmd_setbypass_timeout_set,
4077 (void *)&cmd_setbypass_timeout_bypass,
4078 (void *)&cmd_setbypass_timeout_timeout,
4079 (void *)&cmd_setbypass_timeout_value,
4084 /* *** SHOW NIC BYPASS MODE *** */
4085 struct cmd_show_bypass_config_result {
4086 cmdline_fixed_string_t show;
4087 cmdline_fixed_string_t bypass;
4088 cmdline_fixed_string_t config;
4093 cmd_show_bypass_config_parsed(void *parsed_result,
4094 __attribute__((unused)) struct cmdline *cl,
4095 __attribute__((unused)) void *data)
4097 struct cmd_show_bypass_config_result *res = parsed_result;
4098 uint32_t event_mode;
4099 uint32_t bypass_mode;
4100 portid_t port_id = res->port_id;
4101 uint32_t timeout = bypass_timeout;
4104 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4105 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4106 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4107 {"UNKNOWN", "normal", "bypass", "isolate"};
4108 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4115 int num_events = (sizeof events) / (sizeof events[0]);
4117 /* Display the bypass mode.*/
4118 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4119 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4123 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4124 bypass_mode = RTE_BYPASS_MODE_NONE;
4126 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4129 /* Display the bypass timeout.*/
4130 if (!RTE_BYPASS_TMT_VALID(timeout))
4131 timeout = RTE_BYPASS_TMT_OFF;
4133 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4135 /* Display the bypass events and associated modes. */
4136 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4138 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4139 printf("\tFailed to get bypass mode for event = %s\n",
4142 if (!RTE_BYPASS_MODE_VALID(event_mode))
4143 event_mode = RTE_BYPASS_MODE_NONE;
4145 printf("\tbypass event: %-16s = %s\n", events[i],
4151 cmdline_parse_token_string_t cmd_showbypass_config_show =
4152 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4154 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4155 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4157 cmdline_parse_token_string_t cmd_showbypass_config_config =
4158 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4160 cmdline_parse_token_num_t cmd_showbypass_config_port =
4161 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4164 cmdline_parse_inst_t cmd_show_bypass_config = {
4165 .f = cmd_show_bypass_config_parsed,
4166 .help_str = "show bypass config <port_id>: "
4167 "Show the NIC bypass config for port_id",
4170 (void *)&cmd_showbypass_config_show,
4171 (void *)&cmd_showbypass_config_bypass,
4172 (void *)&cmd_showbypass_config_config,
4173 (void *)&cmd_showbypass_config_port,
4179 #ifdef RTE_LIBRTE_PMD_BOND
4180 /* *** SET BONDING MODE *** */
4181 struct cmd_set_bonding_mode_result {
4182 cmdline_fixed_string_t set;
4183 cmdline_fixed_string_t bonding;
4184 cmdline_fixed_string_t mode;
4189 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4190 __attribute__((unused)) struct cmdline *cl,
4191 __attribute__((unused)) void *data)
4193 struct cmd_set_bonding_mode_result *res = parsed_result;
4194 portid_t port_id = res->port_id;
4196 /* Set the bonding mode for the relevant port. */
4197 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4198 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4201 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4202 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4204 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4205 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4206 bonding, "bonding");
4207 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4208 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4210 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4211 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4213 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4214 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4217 cmdline_parse_inst_t cmd_set_bonding_mode = {
4218 .f = cmd_set_bonding_mode_parsed,
4219 .help_str = "set bonding mode <mode_value> <port_id>: "
4220 "Set the bonding mode for port_id",
4223 (void *) &cmd_setbonding_mode_set,
4224 (void *) &cmd_setbonding_mode_bonding,
4225 (void *) &cmd_setbonding_mode_mode,
4226 (void *) &cmd_setbonding_mode_value,
4227 (void *) &cmd_setbonding_mode_port,
4232 /* *** SET BALANCE XMIT POLICY *** */
4233 struct cmd_set_bonding_balance_xmit_policy_result {
4234 cmdline_fixed_string_t set;
4235 cmdline_fixed_string_t bonding;
4236 cmdline_fixed_string_t balance_xmit_policy;
4238 cmdline_fixed_string_t policy;
4241 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4242 __attribute__((unused)) struct cmdline *cl,
4243 __attribute__((unused)) void *data)
4245 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4246 portid_t port_id = res->port_id;
4249 if (!strcmp(res->policy, "l2")) {
4250 policy = BALANCE_XMIT_POLICY_LAYER2;
4251 } else if (!strcmp(res->policy, "l23")) {
4252 policy = BALANCE_XMIT_POLICY_LAYER23;
4253 } else if (!strcmp(res->policy, "l34")) {
4254 policy = BALANCE_XMIT_POLICY_LAYER34;
4256 printf("\t Invalid xmit policy selection");
4260 /* Set the bonding mode for the relevant port. */
4261 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4262 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4267 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4270 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4271 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4272 bonding, "bonding");
4273 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4274 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4275 balance_xmit_policy, "balance_xmit_policy");
4276 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4277 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4279 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4280 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4281 policy, "l2#l23#l34");
4283 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4284 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4285 .help_str = "set bonding balance_xmit_policy <port_id> "
4287 "Set the bonding balance_xmit_policy for port_id",
4290 (void *)&cmd_setbonding_balance_xmit_policy_set,
4291 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4292 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4293 (void *)&cmd_setbonding_balance_xmit_policy_port,
4294 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4299 /* *** SHOW NIC BONDING CONFIGURATION *** */
4300 struct cmd_show_bonding_config_result {
4301 cmdline_fixed_string_t show;
4302 cmdline_fixed_string_t bonding;
4303 cmdline_fixed_string_t config;
4307 static void cmd_show_bonding_config_parsed(void *parsed_result,
4308 __attribute__((unused)) struct cmdline *cl,
4309 __attribute__((unused)) void *data)
4311 struct cmd_show_bonding_config_result *res = parsed_result;
4313 uint8_t slaves[RTE_MAX_ETHPORTS];
4314 int num_slaves, num_active_slaves;
4317 portid_t port_id = res->port_id;
4319 /* Display the bonding mode.*/
4320 bonding_mode = rte_eth_bond_mode_get(port_id);
4321 if (bonding_mode < 0) {
4322 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4325 printf("\tBonding mode: %d\n", bonding_mode);
4327 if (bonding_mode == BONDING_MODE_BALANCE) {
4328 int balance_xmit_policy;
4330 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4331 if (balance_xmit_policy < 0) {
4332 printf("\tFailed to get balance xmit policy for port = %d\n",
4336 printf("\tBalance Xmit Policy: ");
4338 switch (balance_xmit_policy) {
4339 case BALANCE_XMIT_POLICY_LAYER2:
4340 printf("BALANCE_XMIT_POLICY_LAYER2");
4342 case BALANCE_XMIT_POLICY_LAYER23:
4343 printf("BALANCE_XMIT_POLICY_LAYER23");
4345 case BALANCE_XMIT_POLICY_LAYER34:
4346 printf("BALANCE_XMIT_POLICY_LAYER34");
4353 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4355 if (num_slaves < 0) {
4356 printf("\tFailed to get slave list for port = %d\n", port_id);
4359 if (num_slaves > 0) {
4360 printf("\tSlaves (%d): [", num_slaves);
4361 for (i = 0; i < num_slaves - 1; i++)
4362 printf("%d ", slaves[i]);
4364 printf("%d]\n", slaves[num_slaves - 1]);
4366 printf("\tSlaves: []\n");
4370 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4373 if (num_active_slaves < 0) {
4374 printf("\tFailed to get active slave list for port = %d\n", port_id);
4377 if (num_active_slaves > 0) {
4378 printf("\tActive Slaves (%d): [", num_active_slaves);
4379 for (i = 0; i < num_active_slaves - 1; i++)
4380 printf("%d ", slaves[i]);
4382 printf("%d]\n", slaves[num_active_slaves - 1]);
4385 printf("\tActive Slaves: []\n");
4389 primary_id = rte_eth_bond_primary_get(port_id);
4390 if (primary_id < 0) {
4391 printf("\tFailed to get primary slave for port = %d\n", port_id);
4394 printf("\tPrimary: [%d]\n", primary_id);
4398 cmdline_parse_token_string_t cmd_showbonding_config_show =
4399 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4401 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4402 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4403 bonding, "bonding");
4404 cmdline_parse_token_string_t cmd_showbonding_config_config =
4405 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4407 cmdline_parse_token_num_t cmd_showbonding_config_port =
4408 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4411 cmdline_parse_inst_t cmd_show_bonding_config = {
4412 .f = cmd_show_bonding_config_parsed,
4413 .help_str = "show bonding config <port_id>: "
4414 "Show the bonding config for port_id",
4417 (void *)&cmd_showbonding_config_show,
4418 (void *)&cmd_showbonding_config_bonding,
4419 (void *)&cmd_showbonding_config_config,
4420 (void *)&cmd_showbonding_config_port,
4425 /* *** SET BONDING PRIMARY *** */
4426 struct cmd_set_bonding_primary_result {
4427 cmdline_fixed_string_t set;
4428 cmdline_fixed_string_t bonding;
4429 cmdline_fixed_string_t primary;
4434 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4435 __attribute__((unused)) struct cmdline *cl,
4436 __attribute__((unused)) void *data)
4438 struct cmd_set_bonding_primary_result *res = parsed_result;
4439 portid_t master_port_id = res->port_id;
4440 portid_t slave_port_id = res->slave_id;
4442 /* Set the primary slave for a bonded device. */
4443 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4444 printf("\t Failed to set primary slave for port = %d.\n",
4451 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4452 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4454 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4455 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4456 bonding, "bonding");
4457 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4458 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4459 primary, "primary");
4460 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4461 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4463 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4464 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4467 cmdline_parse_inst_t cmd_set_bonding_primary = {
4468 .f = cmd_set_bonding_primary_parsed,
4469 .help_str = "set bonding primary <slave_id> <port_id>: "
4470 "Set the primary slave for port_id",
4473 (void *)&cmd_setbonding_primary_set,
4474 (void *)&cmd_setbonding_primary_bonding,
4475 (void *)&cmd_setbonding_primary_primary,
4476 (void *)&cmd_setbonding_primary_slave,
4477 (void *)&cmd_setbonding_primary_port,
4482 /* *** ADD SLAVE *** */
4483 struct cmd_add_bonding_slave_result {
4484 cmdline_fixed_string_t add;
4485 cmdline_fixed_string_t bonding;
4486 cmdline_fixed_string_t slave;
4491 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4492 __attribute__((unused)) struct cmdline *cl,
4493 __attribute__((unused)) void *data)
4495 struct cmd_add_bonding_slave_result *res = parsed_result;
4496 portid_t master_port_id = res->port_id;
4497 portid_t slave_port_id = res->slave_id;
4499 /* Set the primary slave for a bonded device. */
4500 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4501 printf("\t Failed to add slave %d to master port = %d.\n",
4502 slave_port_id, master_port_id);
4506 set_port_slave_flag(slave_port_id);
4509 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4510 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4512 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4513 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4514 bonding, "bonding");
4515 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4516 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4518 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4519 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4521 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4522 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4525 cmdline_parse_inst_t cmd_add_bonding_slave = {
4526 .f = cmd_add_bonding_slave_parsed,
4527 .help_str = "add bonding slave <slave_id> <port_id>: "
4528 "Add a slave device to a bonded device",
4531 (void *)&cmd_addbonding_slave_add,
4532 (void *)&cmd_addbonding_slave_bonding,
4533 (void *)&cmd_addbonding_slave_slave,
4534 (void *)&cmd_addbonding_slave_slaveid,
4535 (void *)&cmd_addbonding_slave_port,
4540 /* *** REMOVE SLAVE *** */
4541 struct cmd_remove_bonding_slave_result {
4542 cmdline_fixed_string_t remove;
4543 cmdline_fixed_string_t bonding;
4544 cmdline_fixed_string_t slave;
4549 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4550 __attribute__((unused)) struct cmdline *cl,
4551 __attribute__((unused)) void *data)
4553 struct cmd_remove_bonding_slave_result *res = parsed_result;
4554 portid_t master_port_id = res->port_id;
4555 portid_t slave_port_id = res->slave_id;
4557 /* Set the primary slave for a bonded device. */
4558 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4559 printf("\t Failed to remove slave %d from master port = %d.\n",
4560 slave_port_id, master_port_id);
4564 clear_port_slave_flag(slave_port_id);
4567 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4568 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4570 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4571 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4572 bonding, "bonding");
4573 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4574 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4576 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4577 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4579 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4580 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4583 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4584 .f = cmd_remove_bonding_slave_parsed,
4585 .help_str = "remove bonding slave <slave_id> <port_id>: "
4586 "Remove a slave device from a bonded device",
4589 (void *)&cmd_removebonding_slave_remove,
4590 (void *)&cmd_removebonding_slave_bonding,
4591 (void *)&cmd_removebonding_slave_slave,
4592 (void *)&cmd_removebonding_slave_slaveid,
4593 (void *)&cmd_removebonding_slave_port,
4598 /* *** CREATE BONDED DEVICE *** */
4599 struct cmd_create_bonded_device_result {
4600 cmdline_fixed_string_t create;
4601 cmdline_fixed_string_t bonded;
4602 cmdline_fixed_string_t device;
4607 static int bond_dev_num = 0;
4609 static void cmd_create_bonded_device_parsed(void *parsed_result,
4610 __attribute__((unused)) struct cmdline *cl,
4611 __attribute__((unused)) void *data)
4613 struct cmd_create_bonded_device_result *res = parsed_result;
4614 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4617 if (test_done == 0) {
4618 printf("Please stop forwarding first\n");
4622 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4625 /* Create a new bonded device. */
4626 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4628 printf("\t Failed to create bonded device.\n");
4631 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4634 /* Update number of ports */
4635 nb_ports = rte_eth_dev_count();
4636 reconfig(port_id, res->socket);
4637 rte_eth_promiscuous_enable(port_id);
4638 ports[port_id].enabled = 1;
4643 cmdline_parse_token_string_t cmd_createbonded_device_create =
4644 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4646 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4647 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4649 cmdline_parse_token_string_t cmd_createbonded_device_device =
4650 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4652 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4653 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4655 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4656 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4659 cmdline_parse_inst_t cmd_create_bonded_device = {
4660 .f = cmd_create_bonded_device_parsed,
4661 .help_str = "create bonded device <mode> <socket>: "
4662 "Create a new bonded device with specific bonding mode and socket",
4665 (void *)&cmd_createbonded_device_create,
4666 (void *)&cmd_createbonded_device_bonded,
4667 (void *)&cmd_createbonded_device_device,
4668 (void *)&cmd_createbonded_device_mode,
4669 (void *)&cmd_createbonded_device_socket,
4674 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4675 struct cmd_set_bond_mac_addr_result {
4676 cmdline_fixed_string_t set;
4677 cmdline_fixed_string_t bonding;
4678 cmdline_fixed_string_t mac_addr;
4680 struct ether_addr address;
4683 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4684 __attribute__((unused)) struct cmdline *cl,
4685 __attribute__((unused)) void *data)
4687 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4690 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4693 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4695 /* check the return value and print it if is < 0 */
4697 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4700 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4701 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4702 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4703 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4705 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4706 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4708 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4709 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4710 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4711 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4713 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4714 .f = cmd_set_bond_mac_addr_parsed,
4716 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4718 (void *)&cmd_set_bond_mac_addr_set,
4719 (void *)&cmd_set_bond_mac_addr_bonding,
4720 (void *)&cmd_set_bond_mac_addr_mac,
4721 (void *)&cmd_set_bond_mac_addr_portnum,
4722 (void *)&cmd_set_bond_mac_addr_addr,
4728 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4729 struct cmd_set_bond_mon_period_result {
4730 cmdline_fixed_string_t set;
4731 cmdline_fixed_string_t bonding;
4732 cmdline_fixed_string_t mon_period;
4737 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4738 __attribute__((unused)) struct cmdline *cl,
4739 __attribute__((unused)) void *data)
4741 struct cmd_set_bond_mon_period_result *res = parsed_result;
4744 if (res->port_num >= nb_ports) {
4745 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4749 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4751 /* check the return value and print it if is < 0 */
4753 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4756 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4757 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4759 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4760 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4761 bonding, "bonding");
4762 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4763 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4764 mon_period, "mon_period");
4765 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4766 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4768 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4769 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4772 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4773 .f = cmd_set_bond_mon_period_parsed,
4775 .help_str = "set bonding mon_period <port_id> <period_ms>",
4777 (void *)&cmd_set_bond_mon_period_set,
4778 (void *)&cmd_set_bond_mon_period_bonding,
4779 (void *)&cmd_set_bond_mon_period_mon_period,
4780 (void *)&cmd_set_bond_mon_period_portnum,
4781 (void *)&cmd_set_bond_mon_period_period_ms,
4786 #endif /* RTE_LIBRTE_PMD_BOND */
4788 /* *** SET FORWARDING MODE *** */
4789 struct cmd_set_fwd_mode_result {
4790 cmdline_fixed_string_t set;
4791 cmdline_fixed_string_t fwd;
4792 cmdline_fixed_string_t mode;
4795 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4796 __attribute__((unused)) struct cmdline *cl,
4797 __attribute__((unused)) void *data)
4799 struct cmd_set_fwd_mode_result *res = parsed_result;
4802 set_pkt_forwarding_mode(res->mode);
4805 cmdline_parse_token_string_t cmd_setfwd_set =
4806 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4807 cmdline_parse_token_string_t cmd_setfwd_fwd =
4808 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4809 cmdline_parse_token_string_t cmd_setfwd_mode =
4810 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4811 "" /* defined at init */);
4813 cmdline_parse_inst_t cmd_set_fwd_mode = {
4814 .f = cmd_set_fwd_mode_parsed,
4816 .help_str = NULL, /* defined at init */
4818 (void *)&cmd_setfwd_set,
4819 (void *)&cmd_setfwd_fwd,
4820 (void *)&cmd_setfwd_mode,
4825 static void cmd_set_fwd_mode_init(void)
4828 static char token[128];
4829 static char help[256];
4830 cmdline_parse_token_string_t *token_struct;
4832 modes = list_pkt_forwarding_modes();
4833 snprintf(help, sizeof(help), "set fwd %s: "
4834 "Set packet forwarding mode", modes);
4835 cmd_set_fwd_mode.help_str = help;
4837 /* string token separator is # */
4838 for (c = token; *modes != '\0'; modes++)
4843 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4844 token_struct->string_data.str = token;
4847 /* *** SET RETRY FORWARDING MODE *** */
4848 struct cmd_set_fwd_retry_mode_result {
4849 cmdline_fixed_string_t set;
4850 cmdline_fixed_string_t fwd;
4851 cmdline_fixed_string_t mode;
4852 cmdline_fixed_string_t retry;
4855 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4856 __attribute__((unused)) struct cmdline *cl,
4857 __attribute__((unused)) void *data)
4859 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4862 set_pkt_forwarding_mode(res->mode);
4865 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4866 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4868 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4869 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4871 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4872 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4874 "" /* defined at init */);
4875 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4876 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4879 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4880 .f = cmd_set_fwd_retry_mode_parsed,
4882 .help_str = NULL, /* defined at init */
4884 (void *)&cmd_setfwd_retry_set,
4885 (void *)&cmd_setfwd_retry_fwd,
4886 (void *)&cmd_setfwd_retry_mode,
4887 (void *)&cmd_setfwd_retry_retry,
4892 static void cmd_set_fwd_retry_mode_init(void)
4895 static char token[128];
4896 static char help[256];
4897 cmdline_parse_token_string_t *token_struct;
4899 modes = list_pkt_forwarding_retry_modes();
4900 snprintf(help, sizeof(help), "set fwd %s retry: "
4901 "Set packet forwarding mode with retry", modes);
4902 cmd_set_fwd_retry_mode.help_str = help;
4904 /* string token separator is # */
4905 for (c = token; *modes != '\0'; modes++)
4910 token_struct = (cmdline_parse_token_string_t *)
4911 cmd_set_fwd_retry_mode.tokens[2];
4912 token_struct->string_data.str = token;
4915 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4916 struct cmd_set_burst_tx_retry_result {
4917 cmdline_fixed_string_t set;
4918 cmdline_fixed_string_t burst;
4919 cmdline_fixed_string_t tx;
4920 cmdline_fixed_string_t delay;
4922 cmdline_fixed_string_t retry;
4926 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4927 __attribute__((unused)) struct cmdline *cl,
4928 __attribute__((unused)) void *data)
4930 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4932 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4933 && !strcmp(res->tx, "tx")) {
4934 if (!strcmp(res->delay, "delay"))
4935 burst_tx_delay_time = res->time;
4936 if (!strcmp(res->retry, "retry"))
4937 burst_tx_retry_num = res->retry_num;
4942 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4943 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4944 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4945 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4947 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4948 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4949 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4950 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4951 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4952 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4953 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4954 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4955 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4956 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4958 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4959 .f = cmd_set_burst_tx_retry_parsed,
4960 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4962 (void *)&cmd_set_burst_tx_retry_set,
4963 (void *)&cmd_set_burst_tx_retry_burst,
4964 (void *)&cmd_set_burst_tx_retry_tx,
4965 (void *)&cmd_set_burst_tx_retry_delay,
4966 (void *)&cmd_set_burst_tx_retry_time,
4967 (void *)&cmd_set_burst_tx_retry_retry,
4968 (void *)&cmd_set_burst_tx_retry_retry_num,
4973 /* *** SET PROMISC MODE *** */
4974 struct cmd_set_promisc_mode_result {
4975 cmdline_fixed_string_t set;
4976 cmdline_fixed_string_t promisc;
4977 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4978 uint8_t port_num; /* valid if "allports" argument == 0 */
4979 cmdline_fixed_string_t mode;
4982 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4983 __attribute__((unused)) struct cmdline *cl,
4986 struct cmd_set_promisc_mode_result *res = parsed_result;
4990 if (!strcmp(res->mode, "on"))
4997 FOREACH_PORT(i, ports) {
4999 rte_eth_promiscuous_enable(i);
5001 rte_eth_promiscuous_disable(i);
5006 rte_eth_promiscuous_enable(res->port_num);
5008 rte_eth_promiscuous_disable(res->port_num);
5012 cmdline_parse_token_string_t cmd_setpromisc_set =
5013 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5014 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5015 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5017 cmdline_parse_token_string_t cmd_setpromisc_portall =
5018 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5020 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5021 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5023 cmdline_parse_token_string_t cmd_setpromisc_mode =
5024 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5027 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5028 .f = cmd_set_promisc_mode_parsed,
5030 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5032 (void *)&cmd_setpromisc_set,
5033 (void *)&cmd_setpromisc_promisc,
5034 (void *)&cmd_setpromisc_portall,
5035 (void *)&cmd_setpromisc_mode,
5040 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5041 .f = cmd_set_promisc_mode_parsed,
5043 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5045 (void *)&cmd_setpromisc_set,
5046 (void *)&cmd_setpromisc_promisc,
5047 (void *)&cmd_setpromisc_portnum,
5048 (void *)&cmd_setpromisc_mode,
5053 /* *** SET ALLMULTI MODE *** */
5054 struct cmd_set_allmulti_mode_result {
5055 cmdline_fixed_string_t set;
5056 cmdline_fixed_string_t allmulti;
5057 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5058 uint8_t port_num; /* valid if "allports" argument == 0 */
5059 cmdline_fixed_string_t mode;
5062 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5063 __attribute__((unused)) struct cmdline *cl,
5066 struct cmd_set_allmulti_mode_result *res = parsed_result;
5070 if (!strcmp(res->mode, "on"))
5077 FOREACH_PORT(i, ports) {
5079 rte_eth_allmulticast_enable(i);
5081 rte_eth_allmulticast_disable(i);
5086 rte_eth_allmulticast_enable(res->port_num);
5088 rte_eth_allmulticast_disable(res->port_num);
5092 cmdline_parse_token_string_t cmd_setallmulti_set =
5093 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5094 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5095 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5097 cmdline_parse_token_string_t cmd_setallmulti_portall =
5098 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5100 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5101 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5103 cmdline_parse_token_string_t cmd_setallmulti_mode =
5104 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5107 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5108 .f = cmd_set_allmulti_mode_parsed,
5110 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5112 (void *)&cmd_setallmulti_set,
5113 (void *)&cmd_setallmulti_allmulti,
5114 (void *)&cmd_setallmulti_portall,
5115 (void *)&cmd_setallmulti_mode,
5120 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5121 .f = cmd_set_allmulti_mode_parsed,
5123 .help_str = "set allmulti <port_id> on|off: "
5124 "Set allmulti mode on port_id",
5126 (void *)&cmd_setallmulti_set,
5127 (void *)&cmd_setallmulti_allmulti,
5128 (void *)&cmd_setallmulti_portnum,
5129 (void *)&cmd_setallmulti_mode,
5134 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5135 struct cmd_link_flow_ctrl_set_result {
5136 cmdline_fixed_string_t set;
5137 cmdline_fixed_string_t flow_ctrl;
5138 cmdline_fixed_string_t rx;
5139 cmdline_fixed_string_t rx_lfc_mode;
5140 cmdline_fixed_string_t tx;
5141 cmdline_fixed_string_t tx_lfc_mode;
5142 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5143 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5144 cmdline_fixed_string_t autoneg_str;
5145 cmdline_fixed_string_t autoneg;
5146 cmdline_fixed_string_t hw_str;
5147 uint32_t high_water;
5148 cmdline_fixed_string_t lw_str;
5150 cmdline_fixed_string_t pt_str;
5151 uint16_t pause_time;
5152 cmdline_fixed_string_t xon_str;
5157 cmdline_parse_token_string_t cmd_lfc_set_set =
5158 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5160 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5162 flow_ctrl, "flow_ctrl");
5163 cmdline_parse_token_string_t cmd_lfc_set_rx =
5164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5166 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5168 rx_lfc_mode, "on#off");
5169 cmdline_parse_token_string_t cmd_lfc_set_tx =
5170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5172 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5174 tx_lfc_mode, "on#off");
5175 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5177 hw_str, "high_water");
5178 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5179 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5180 high_water, UINT32);
5181 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5182 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5183 lw_str, "low_water");
5184 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5185 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5187 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5188 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5189 pt_str, "pause_time");
5190 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5191 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 pause_time, UINT16);
5193 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5194 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5195 xon_str, "send_xon");
5196 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5197 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5199 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5200 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5201 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5202 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5203 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 mac_ctrl_frame_fwd_mode, "on#off");
5205 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5206 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5207 autoneg_str, "autoneg");
5208 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5209 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5211 cmdline_parse_token_num_t cmd_lfc_set_portid =
5212 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5215 /* forward declaration */
5217 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5220 cmdline_parse_inst_t cmd_link_flow_control_set = {
5221 .f = cmd_link_flow_ctrl_set_parsed,
5223 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5224 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5225 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5227 (void *)&cmd_lfc_set_set,
5228 (void *)&cmd_lfc_set_flow_ctrl,
5229 (void *)&cmd_lfc_set_rx,
5230 (void *)&cmd_lfc_set_rx_mode,
5231 (void *)&cmd_lfc_set_tx,
5232 (void *)&cmd_lfc_set_tx_mode,
5233 (void *)&cmd_lfc_set_high_water,
5234 (void *)&cmd_lfc_set_low_water,
5235 (void *)&cmd_lfc_set_pause_time,
5236 (void *)&cmd_lfc_set_send_xon,
5237 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5238 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5239 (void *)&cmd_lfc_set_autoneg_str,
5240 (void *)&cmd_lfc_set_autoneg,
5241 (void *)&cmd_lfc_set_portid,
5246 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5247 .f = cmd_link_flow_ctrl_set_parsed,
5248 .data = (void *)&cmd_link_flow_control_set_rx,
5249 .help_str = "set flow_ctrl rx on|off <port_id>: "
5250 "Change rx flow control parameter",
5252 (void *)&cmd_lfc_set_set,
5253 (void *)&cmd_lfc_set_flow_ctrl,
5254 (void *)&cmd_lfc_set_rx,
5255 (void *)&cmd_lfc_set_rx_mode,
5256 (void *)&cmd_lfc_set_portid,
5261 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5262 .f = cmd_link_flow_ctrl_set_parsed,
5263 .data = (void *)&cmd_link_flow_control_set_tx,
5264 .help_str = "set flow_ctrl tx on|off <port_id>: "
5265 "Change tx flow control parameter",
5267 (void *)&cmd_lfc_set_set,
5268 (void *)&cmd_lfc_set_flow_ctrl,
5269 (void *)&cmd_lfc_set_tx,
5270 (void *)&cmd_lfc_set_tx_mode,
5271 (void *)&cmd_lfc_set_portid,
5276 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5277 .f = cmd_link_flow_ctrl_set_parsed,
5278 .data = (void *)&cmd_link_flow_control_set_hw,
5279 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5280 "Change high water flow control parameter",
5282 (void *)&cmd_lfc_set_set,
5283 (void *)&cmd_lfc_set_flow_ctrl,
5284 (void *)&cmd_lfc_set_high_water_str,
5285 (void *)&cmd_lfc_set_high_water,
5286 (void *)&cmd_lfc_set_portid,
5291 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5292 .f = cmd_link_flow_ctrl_set_parsed,
5293 .data = (void *)&cmd_link_flow_control_set_lw,
5294 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5295 "Change low water flow control parameter",
5297 (void *)&cmd_lfc_set_set,
5298 (void *)&cmd_lfc_set_flow_ctrl,
5299 (void *)&cmd_lfc_set_low_water_str,
5300 (void *)&cmd_lfc_set_low_water,
5301 (void *)&cmd_lfc_set_portid,
5306 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5307 .f = cmd_link_flow_ctrl_set_parsed,
5308 .data = (void *)&cmd_link_flow_control_set_pt,
5309 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5310 "Change pause time flow control parameter",
5312 (void *)&cmd_lfc_set_set,
5313 (void *)&cmd_lfc_set_flow_ctrl,
5314 (void *)&cmd_lfc_set_pause_time_str,
5315 (void *)&cmd_lfc_set_pause_time,
5316 (void *)&cmd_lfc_set_portid,
5321 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5322 .f = cmd_link_flow_ctrl_set_parsed,
5323 .data = (void *)&cmd_link_flow_control_set_xon,
5324 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5325 "Change send_xon flow control parameter",
5327 (void *)&cmd_lfc_set_set,
5328 (void *)&cmd_lfc_set_flow_ctrl,
5329 (void *)&cmd_lfc_set_send_xon_str,
5330 (void *)&cmd_lfc_set_send_xon,
5331 (void *)&cmd_lfc_set_portid,
5336 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5337 .f = cmd_link_flow_ctrl_set_parsed,
5338 .data = (void *)&cmd_link_flow_control_set_macfwd,
5339 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5340 "Change mac ctrl fwd flow control parameter",
5342 (void *)&cmd_lfc_set_set,
5343 (void *)&cmd_lfc_set_flow_ctrl,
5344 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5345 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5346 (void *)&cmd_lfc_set_portid,
5351 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5352 .f = cmd_link_flow_ctrl_set_parsed,
5353 .data = (void *)&cmd_link_flow_control_set_autoneg,
5354 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5355 "Change autoneg flow control parameter",
5357 (void *)&cmd_lfc_set_set,
5358 (void *)&cmd_lfc_set_flow_ctrl,
5359 (void *)&cmd_lfc_set_autoneg_str,
5360 (void *)&cmd_lfc_set_autoneg,
5361 (void *)&cmd_lfc_set_portid,
5367 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5368 __attribute__((unused)) struct cmdline *cl,
5371 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5372 cmdline_parse_inst_t *cmd = data;
5373 struct rte_eth_fc_conf fc_conf;
5379 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5380 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5381 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5382 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5384 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5385 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5388 /* Partial command line, retrieve current configuration */
5390 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5392 printf("cannot get current flow ctrl parameters, return"
5393 "code = %d\n", ret);
5397 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5398 (fc_conf.mode == RTE_FC_FULL))
5400 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5401 (fc_conf.mode == RTE_FC_FULL))
5405 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5406 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5408 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5409 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5411 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5413 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5414 fc_conf.high_water = res->high_water;
5416 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5417 fc_conf.low_water = res->low_water;
5419 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5420 fc_conf.pause_time = res->pause_time;
5422 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5423 fc_conf.send_xon = res->send_xon;
5425 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5426 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5427 fc_conf.mac_ctrl_frame_fwd = 1;
5429 fc_conf.mac_ctrl_frame_fwd = 0;
5432 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5433 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5435 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5437 printf("bad flow contrl parameter, return code = %d \n", ret);
5440 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5441 struct cmd_priority_flow_ctrl_set_result {
5442 cmdline_fixed_string_t set;
5443 cmdline_fixed_string_t pfc_ctrl;
5444 cmdline_fixed_string_t rx;
5445 cmdline_fixed_string_t rx_pfc_mode;
5446 cmdline_fixed_string_t tx;
5447 cmdline_fixed_string_t tx_pfc_mode;
5448 uint32_t high_water;
5450 uint16_t pause_time;
5456 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5457 __attribute__((unused)) struct cmdline *cl,
5458 __attribute__((unused)) void *data)
5460 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5461 struct rte_eth_pfc_conf pfc_conf;
5462 int rx_fc_enable, tx_fc_enable;
5466 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5467 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5468 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5469 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5471 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5472 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5475 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5476 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5477 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5478 pfc_conf.fc.high_water = res->high_water;
5479 pfc_conf.fc.low_water = res->low_water;
5480 pfc_conf.fc.pause_time = res->pause_time;
5481 pfc_conf.priority = res->priority;
5483 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5485 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5488 cmdline_parse_token_string_t cmd_pfc_set_set =
5489 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5491 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5492 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5493 pfc_ctrl, "pfc_ctrl");
5494 cmdline_parse_token_string_t cmd_pfc_set_rx =
5495 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5497 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5498 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5499 rx_pfc_mode, "on#off");
5500 cmdline_parse_token_string_t cmd_pfc_set_tx =
5501 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5503 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5504 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5505 tx_pfc_mode, "on#off");
5506 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5507 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5508 high_water, UINT32);
5509 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5510 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5512 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5513 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5514 pause_time, UINT16);
5515 cmdline_parse_token_num_t cmd_pfc_set_priority =
5516 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5518 cmdline_parse_token_num_t cmd_pfc_set_portid =
5519 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5522 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5523 .f = cmd_priority_flow_ctrl_set_parsed,
5525 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5526 "<pause_time> <priority> <port_id>: "
5527 "Configure the Ethernet priority flow control",
5529 (void *)&cmd_pfc_set_set,
5530 (void *)&cmd_pfc_set_flow_ctrl,
5531 (void *)&cmd_pfc_set_rx,
5532 (void *)&cmd_pfc_set_rx_mode,
5533 (void *)&cmd_pfc_set_tx,
5534 (void *)&cmd_pfc_set_tx_mode,
5535 (void *)&cmd_pfc_set_high_water,
5536 (void *)&cmd_pfc_set_low_water,
5537 (void *)&cmd_pfc_set_pause_time,
5538 (void *)&cmd_pfc_set_priority,
5539 (void *)&cmd_pfc_set_portid,
5544 /* *** RESET CONFIGURATION *** */
5545 struct cmd_reset_result {
5546 cmdline_fixed_string_t reset;
5547 cmdline_fixed_string_t def;
5550 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5552 __attribute__((unused)) void *data)
5554 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5555 set_def_fwd_config();
5558 cmdline_parse_token_string_t cmd_reset_set =
5559 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5560 cmdline_parse_token_string_t cmd_reset_def =
5561 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5564 cmdline_parse_inst_t cmd_reset = {
5565 .f = cmd_reset_parsed,
5567 .help_str = "set default: Reset default forwarding configuration",
5569 (void *)&cmd_reset_set,
5570 (void *)&cmd_reset_def,
5575 /* *** START FORWARDING *** */
5576 struct cmd_start_result {
5577 cmdline_fixed_string_t start;
5580 cmdline_parse_token_string_t cmd_start_start =
5581 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5583 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5584 __attribute__((unused)) struct cmdline *cl,
5585 __attribute__((unused)) void *data)
5587 start_packet_forwarding(0);
5590 cmdline_parse_inst_t cmd_start = {
5591 .f = cmd_start_parsed,
5593 .help_str = "start: Start packet forwarding",
5595 (void *)&cmd_start_start,
5600 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5601 struct cmd_start_tx_first_result {
5602 cmdline_fixed_string_t start;
5603 cmdline_fixed_string_t tx_first;
5607 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5608 __attribute__((unused)) struct cmdline *cl,
5609 __attribute__((unused)) void *data)
5611 start_packet_forwarding(1);
5614 cmdline_parse_token_string_t cmd_start_tx_first_start =
5615 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5617 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5618 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5619 tx_first, "tx_first");
5621 cmdline_parse_inst_t cmd_start_tx_first = {
5622 .f = cmd_start_tx_first_parsed,
5624 .help_str = "start tx_first: Start packet forwarding, "
5625 "after sending 1 burst of packets",
5627 (void *)&cmd_start_tx_first_start,
5628 (void *)&cmd_start_tx_first_tx_first,
5633 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5634 struct cmd_start_tx_first_n_result {
5635 cmdline_fixed_string_t start;
5636 cmdline_fixed_string_t tx_first;
5641 cmd_start_tx_first_n_parsed(void *parsed_result,
5642 __attribute__((unused)) struct cmdline *cl,
5643 __attribute__((unused)) void *data)
5645 struct cmd_start_tx_first_n_result *res = parsed_result;
5647 start_packet_forwarding(res->tx_num);
5650 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5651 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5653 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5654 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5655 tx_first, "tx_first");
5656 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5657 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5660 cmdline_parse_inst_t cmd_start_tx_first_n = {
5661 .f = cmd_start_tx_first_n_parsed,
5663 .help_str = "start tx_first <num>: "
5664 "packet forwarding, after sending <num> bursts of packets",
5666 (void *)&cmd_start_tx_first_n_start,
5667 (void *)&cmd_start_tx_first_n_tx_first,
5668 (void *)&cmd_start_tx_first_n_tx_num,
5673 /* *** SET LINK UP *** */
5674 struct cmd_set_link_up_result {
5675 cmdline_fixed_string_t set;
5676 cmdline_fixed_string_t link_up;
5677 cmdline_fixed_string_t port;
5681 cmdline_parse_token_string_t cmd_set_link_up_set =
5682 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5683 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5686 cmdline_parse_token_string_t cmd_set_link_up_port =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5688 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5689 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5691 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5692 __attribute__((unused)) struct cmdline *cl,
5693 __attribute__((unused)) void *data)
5695 struct cmd_set_link_up_result *res = parsed_result;
5696 dev_set_link_up(res->port_id);
5699 cmdline_parse_inst_t cmd_set_link_up = {
5700 .f = cmd_set_link_up_parsed,
5702 .help_str = "set link-up port <port id>",
5704 (void *)&cmd_set_link_up_set,
5705 (void *)&cmd_set_link_up_link_up,
5706 (void *)&cmd_set_link_up_port,
5707 (void *)&cmd_set_link_up_port_id,
5712 /* *** SET LINK DOWN *** */
5713 struct cmd_set_link_down_result {
5714 cmdline_fixed_string_t set;
5715 cmdline_fixed_string_t link_down;
5716 cmdline_fixed_string_t port;
5720 cmdline_parse_token_string_t cmd_set_link_down_set =
5721 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5722 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5723 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5725 cmdline_parse_token_string_t cmd_set_link_down_port =
5726 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5727 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5728 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5730 static void cmd_set_link_down_parsed(
5731 __attribute__((unused)) void *parsed_result,
5732 __attribute__((unused)) struct cmdline *cl,
5733 __attribute__((unused)) void *data)
5735 struct cmd_set_link_down_result *res = parsed_result;
5736 dev_set_link_down(res->port_id);
5739 cmdline_parse_inst_t cmd_set_link_down = {
5740 .f = cmd_set_link_down_parsed,
5742 .help_str = "set link-down port <port id>",
5744 (void *)&cmd_set_link_down_set,
5745 (void *)&cmd_set_link_down_link_down,
5746 (void *)&cmd_set_link_down_port,
5747 (void *)&cmd_set_link_down_port_id,
5752 /* *** SHOW CFG *** */
5753 struct cmd_showcfg_result {
5754 cmdline_fixed_string_t show;
5755 cmdline_fixed_string_t cfg;
5756 cmdline_fixed_string_t what;
5759 static void cmd_showcfg_parsed(void *parsed_result,
5760 __attribute__((unused)) struct cmdline *cl,
5761 __attribute__((unused)) void *data)
5763 struct cmd_showcfg_result *res = parsed_result;
5764 if (!strcmp(res->what, "rxtx"))
5765 rxtx_config_display();
5766 else if (!strcmp(res->what, "cores"))
5767 fwd_lcores_config_display();
5768 else if (!strcmp(res->what, "fwd"))
5769 pkt_fwd_config_display(&cur_fwd_config);
5770 else if (!strcmp(res->what, "txpkts"))
5771 show_tx_pkt_segments();
5774 cmdline_parse_token_string_t cmd_showcfg_show =
5775 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5776 cmdline_parse_token_string_t cmd_showcfg_port =
5777 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5778 cmdline_parse_token_string_t cmd_showcfg_what =
5779 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5780 "rxtx#cores#fwd#txpkts");
5782 cmdline_parse_inst_t cmd_showcfg = {
5783 .f = cmd_showcfg_parsed,
5785 .help_str = "show config rxtx|cores|fwd|txpkts",
5787 (void *)&cmd_showcfg_show,
5788 (void *)&cmd_showcfg_port,
5789 (void *)&cmd_showcfg_what,
5794 /* *** SHOW ALL PORT INFO *** */
5795 struct cmd_showportall_result {
5796 cmdline_fixed_string_t show;
5797 cmdline_fixed_string_t port;
5798 cmdline_fixed_string_t what;
5799 cmdline_fixed_string_t all;
5802 static void cmd_showportall_parsed(void *parsed_result,
5803 __attribute__((unused)) struct cmdline *cl,
5804 __attribute__((unused)) void *data)
5808 struct cmd_showportall_result *res = parsed_result;
5809 if (!strcmp(res->show, "clear")) {
5810 if (!strcmp(res->what, "stats"))
5811 FOREACH_PORT(i, ports)
5813 else if (!strcmp(res->what, "xstats"))
5814 FOREACH_PORT(i, ports)
5815 nic_xstats_clear(i);
5816 } else if (!strcmp(res->what, "info"))
5817 FOREACH_PORT(i, ports)
5818 port_infos_display(i);
5819 else if (!strcmp(res->what, "stats"))
5820 FOREACH_PORT(i, ports)
5821 nic_stats_display(i);
5822 else if (!strcmp(res->what, "xstats"))
5823 FOREACH_PORT(i, ports)
5824 nic_xstats_display(i);
5825 else if (!strcmp(res->what, "fdir"))
5826 FOREACH_PORT(i, ports)
5828 else if (!strcmp(res->what, "stat_qmap"))
5829 FOREACH_PORT(i, ports)
5830 nic_stats_mapping_display(i);
5831 else if (!strcmp(res->what, "dcb_tc"))
5832 FOREACH_PORT(i, ports)
5833 port_dcb_info_display(i);
5836 cmdline_parse_token_string_t cmd_showportall_show =
5837 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5839 cmdline_parse_token_string_t cmd_showportall_port =
5840 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5841 cmdline_parse_token_string_t cmd_showportall_what =
5842 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5843 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5844 cmdline_parse_token_string_t cmd_showportall_all =
5845 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5846 cmdline_parse_inst_t cmd_showportall = {
5847 .f = cmd_showportall_parsed,
5849 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5851 (void *)&cmd_showportall_show,
5852 (void *)&cmd_showportall_port,
5853 (void *)&cmd_showportall_what,
5854 (void *)&cmd_showportall_all,
5859 /* *** SHOW PORT INFO *** */
5860 struct cmd_showport_result {
5861 cmdline_fixed_string_t show;
5862 cmdline_fixed_string_t port;
5863 cmdline_fixed_string_t what;
5867 static void cmd_showport_parsed(void *parsed_result,
5868 __attribute__((unused)) struct cmdline *cl,
5869 __attribute__((unused)) void *data)
5871 struct cmd_showport_result *res = parsed_result;
5872 if (!strcmp(res->show, "clear")) {
5873 if (!strcmp(res->what, "stats"))
5874 nic_stats_clear(res->portnum);
5875 else if (!strcmp(res->what, "xstats"))
5876 nic_xstats_clear(res->portnum);
5877 } else if (!strcmp(res->what, "info"))
5878 port_infos_display(res->portnum);
5879 else if (!strcmp(res->what, "stats"))
5880 nic_stats_display(res->portnum);
5881 else if (!strcmp(res->what, "xstats"))
5882 nic_xstats_display(res->portnum);
5883 else if (!strcmp(res->what, "fdir"))
5884 fdir_get_infos(res->portnum);
5885 else if (!strcmp(res->what, "stat_qmap"))
5886 nic_stats_mapping_display(res->portnum);
5887 else if (!strcmp(res->what, "dcb_tc"))
5888 port_dcb_info_display(res->portnum);
5891 cmdline_parse_token_string_t cmd_showport_show =
5892 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5894 cmdline_parse_token_string_t cmd_showport_port =
5895 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5896 cmdline_parse_token_string_t cmd_showport_what =
5897 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5898 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5899 cmdline_parse_token_num_t cmd_showport_portnum =
5900 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5902 cmdline_parse_inst_t cmd_showport = {
5903 .f = cmd_showport_parsed,
5905 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5908 (void *)&cmd_showport_show,
5909 (void *)&cmd_showport_port,
5910 (void *)&cmd_showport_what,
5911 (void *)&cmd_showport_portnum,
5916 /* *** SHOW QUEUE INFO *** */
5917 struct cmd_showqueue_result {
5918 cmdline_fixed_string_t show;
5919 cmdline_fixed_string_t type;
5920 cmdline_fixed_string_t what;
5926 cmd_showqueue_parsed(void *parsed_result,
5927 __attribute__((unused)) struct cmdline *cl,
5928 __attribute__((unused)) void *data)
5930 struct cmd_showqueue_result *res = parsed_result;
5932 if (!strcmp(res->type, "rxq"))
5933 rx_queue_infos_display(res->portnum, res->queuenum);
5934 else if (!strcmp(res->type, "txq"))
5935 tx_queue_infos_display(res->portnum, res->queuenum);
5938 cmdline_parse_token_string_t cmd_showqueue_show =
5939 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5940 cmdline_parse_token_string_t cmd_showqueue_type =
5941 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5942 cmdline_parse_token_string_t cmd_showqueue_what =
5943 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5944 cmdline_parse_token_num_t cmd_showqueue_portnum =
5945 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5946 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5947 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5949 cmdline_parse_inst_t cmd_showqueue = {
5950 .f = cmd_showqueue_parsed,
5952 .help_str = "show rxq|txq info <port_id> <queue_id>",
5954 (void *)&cmd_showqueue_show,
5955 (void *)&cmd_showqueue_type,
5956 (void *)&cmd_showqueue_what,
5957 (void *)&cmd_showqueue_portnum,
5958 (void *)&cmd_showqueue_queuenum,
5963 /* *** READ PORT REGISTER *** */
5964 struct cmd_read_reg_result {
5965 cmdline_fixed_string_t read;
5966 cmdline_fixed_string_t reg;
5972 cmd_read_reg_parsed(void *parsed_result,
5973 __attribute__((unused)) struct cmdline *cl,
5974 __attribute__((unused)) void *data)
5976 struct cmd_read_reg_result *res = parsed_result;
5977 port_reg_display(res->port_id, res->reg_off);
5980 cmdline_parse_token_string_t cmd_read_reg_read =
5981 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5982 cmdline_parse_token_string_t cmd_read_reg_reg =
5983 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5984 cmdline_parse_token_num_t cmd_read_reg_port_id =
5985 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5986 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5987 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5989 cmdline_parse_inst_t cmd_read_reg = {
5990 .f = cmd_read_reg_parsed,
5992 .help_str = "read reg <port_id> <reg_off>",
5994 (void *)&cmd_read_reg_read,
5995 (void *)&cmd_read_reg_reg,
5996 (void *)&cmd_read_reg_port_id,
5997 (void *)&cmd_read_reg_reg_off,
6002 /* *** READ PORT REGISTER BIT FIELD *** */
6003 struct cmd_read_reg_bit_field_result {
6004 cmdline_fixed_string_t read;
6005 cmdline_fixed_string_t regfield;
6013 cmd_read_reg_bit_field_parsed(void *parsed_result,
6014 __attribute__((unused)) struct cmdline *cl,
6015 __attribute__((unused)) void *data)
6017 struct cmd_read_reg_bit_field_result *res = parsed_result;
6018 port_reg_bit_field_display(res->port_id, res->reg_off,
6019 res->bit1_pos, res->bit2_pos);
6022 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6023 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6025 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6026 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6027 regfield, "regfield");
6028 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6029 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6031 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6032 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6034 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6035 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6037 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6038 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6041 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6042 .f = cmd_read_reg_bit_field_parsed,
6044 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6045 "Read register bit field between bit_x and bit_y included",
6047 (void *)&cmd_read_reg_bit_field_read,
6048 (void *)&cmd_read_reg_bit_field_regfield,
6049 (void *)&cmd_read_reg_bit_field_port_id,
6050 (void *)&cmd_read_reg_bit_field_reg_off,
6051 (void *)&cmd_read_reg_bit_field_bit1_pos,
6052 (void *)&cmd_read_reg_bit_field_bit2_pos,
6057 /* *** READ PORT REGISTER BIT *** */
6058 struct cmd_read_reg_bit_result {
6059 cmdline_fixed_string_t read;
6060 cmdline_fixed_string_t regbit;
6067 cmd_read_reg_bit_parsed(void *parsed_result,
6068 __attribute__((unused)) struct cmdline *cl,
6069 __attribute__((unused)) void *data)
6071 struct cmd_read_reg_bit_result *res = parsed_result;
6072 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6075 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6076 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6077 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6078 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6080 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6081 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6082 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6083 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6084 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6085 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6087 cmdline_parse_inst_t cmd_read_reg_bit = {
6088 .f = cmd_read_reg_bit_parsed,
6090 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6092 (void *)&cmd_read_reg_bit_read,
6093 (void *)&cmd_read_reg_bit_regbit,
6094 (void *)&cmd_read_reg_bit_port_id,
6095 (void *)&cmd_read_reg_bit_reg_off,
6096 (void *)&cmd_read_reg_bit_bit_pos,
6101 /* *** WRITE PORT REGISTER *** */
6102 struct cmd_write_reg_result {
6103 cmdline_fixed_string_t write;
6104 cmdline_fixed_string_t reg;
6111 cmd_write_reg_parsed(void *parsed_result,
6112 __attribute__((unused)) struct cmdline *cl,
6113 __attribute__((unused)) void *data)
6115 struct cmd_write_reg_result *res = parsed_result;
6116 port_reg_set(res->port_id, res->reg_off, res->value);
6119 cmdline_parse_token_string_t cmd_write_reg_write =
6120 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6121 cmdline_parse_token_string_t cmd_write_reg_reg =
6122 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6123 cmdline_parse_token_num_t cmd_write_reg_port_id =
6124 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6125 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6126 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6127 cmdline_parse_token_num_t cmd_write_reg_value =
6128 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6130 cmdline_parse_inst_t cmd_write_reg = {
6131 .f = cmd_write_reg_parsed,
6133 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6135 (void *)&cmd_write_reg_write,
6136 (void *)&cmd_write_reg_reg,
6137 (void *)&cmd_write_reg_port_id,
6138 (void *)&cmd_write_reg_reg_off,
6139 (void *)&cmd_write_reg_value,
6144 /* *** WRITE PORT REGISTER BIT FIELD *** */
6145 struct cmd_write_reg_bit_field_result {
6146 cmdline_fixed_string_t write;
6147 cmdline_fixed_string_t regfield;
6156 cmd_write_reg_bit_field_parsed(void *parsed_result,
6157 __attribute__((unused)) struct cmdline *cl,
6158 __attribute__((unused)) void *data)
6160 struct cmd_write_reg_bit_field_result *res = parsed_result;
6161 port_reg_bit_field_set(res->port_id, res->reg_off,
6162 res->bit1_pos, res->bit2_pos, res->value);
6165 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6166 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6168 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6169 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6170 regfield, "regfield");
6171 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6172 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6174 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6175 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6177 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6178 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6180 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6181 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6183 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6184 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6187 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6188 .f = cmd_write_reg_bit_field_parsed,
6190 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6192 "Set register bit field between bit_x and bit_y included",
6194 (void *)&cmd_write_reg_bit_field_write,
6195 (void *)&cmd_write_reg_bit_field_regfield,
6196 (void *)&cmd_write_reg_bit_field_port_id,
6197 (void *)&cmd_write_reg_bit_field_reg_off,
6198 (void *)&cmd_write_reg_bit_field_bit1_pos,
6199 (void *)&cmd_write_reg_bit_field_bit2_pos,
6200 (void *)&cmd_write_reg_bit_field_value,
6205 /* *** WRITE PORT REGISTER BIT *** */
6206 struct cmd_write_reg_bit_result {
6207 cmdline_fixed_string_t write;
6208 cmdline_fixed_string_t regbit;
6216 cmd_write_reg_bit_parsed(void *parsed_result,
6217 __attribute__((unused)) struct cmdline *cl,
6218 __attribute__((unused)) void *data)
6220 struct cmd_write_reg_bit_result *res = parsed_result;
6221 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6224 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6225 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6227 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6228 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6230 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6231 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6232 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6233 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6234 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6235 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6236 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6237 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6239 cmdline_parse_inst_t cmd_write_reg_bit = {
6240 .f = cmd_write_reg_bit_parsed,
6242 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6245 (void *)&cmd_write_reg_bit_write,
6246 (void *)&cmd_write_reg_bit_regbit,
6247 (void *)&cmd_write_reg_bit_port_id,
6248 (void *)&cmd_write_reg_bit_reg_off,
6249 (void *)&cmd_write_reg_bit_bit_pos,
6250 (void *)&cmd_write_reg_bit_value,
6255 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6256 struct cmd_read_rxd_txd_result {
6257 cmdline_fixed_string_t read;
6258 cmdline_fixed_string_t rxd_txd;
6265 cmd_read_rxd_txd_parsed(void *parsed_result,
6266 __attribute__((unused)) struct cmdline *cl,
6267 __attribute__((unused)) void *data)
6269 struct cmd_read_rxd_txd_result *res = parsed_result;
6271 if (!strcmp(res->rxd_txd, "rxd"))
6272 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6273 else if (!strcmp(res->rxd_txd, "txd"))
6274 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6277 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6278 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6279 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6280 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6282 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6283 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6284 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6285 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6286 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6287 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6289 cmdline_parse_inst_t cmd_read_rxd_txd = {
6290 .f = cmd_read_rxd_txd_parsed,
6292 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6294 (void *)&cmd_read_rxd_txd_read,
6295 (void *)&cmd_read_rxd_txd_rxd_txd,
6296 (void *)&cmd_read_rxd_txd_port_id,
6297 (void *)&cmd_read_rxd_txd_queue_id,
6298 (void *)&cmd_read_rxd_txd_desc_id,
6304 struct cmd_quit_result {
6305 cmdline_fixed_string_t quit;
6308 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6310 __attribute__((unused)) void *data)
6316 cmdline_parse_token_string_t cmd_quit_quit =
6317 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6319 cmdline_parse_inst_t cmd_quit = {
6320 .f = cmd_quit_parsed,
6322 .help_str = "quit: Exit application",
6324 (void *)&cmd_quit_quit,
6329 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6330 struct cmd_mac_addr_result {
6331 cmdline_fixed_string_t mac_addr_cmd;
6332 cmdline_fixed_string_t what;
6334 struct ether_addr address;
6337 static void cmd_mac_addr_parsed(void *parsed_result,
6338 __attribute__((unused)) struct cmdline *cl,
6339 __attribute__((unused)) void *data)
6341 struct cmd_mac_addr_result *res = parsed_result;
6344 if (strcmp(res->what, "add") == 0)
6345 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6347 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6349 /* check the return value and print it if is < 0 */
6351 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6355 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6356 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6358 cmdline_parse_token_string_t cmd_mac_addr_what =
6359 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6361 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6362 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6363 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6364 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6366 cmdline_parse_inst_t cmd_mac_addr = {
6367 .f = cmd_mac_addr_parsed,
6369 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6370 "Add/Remove MAC address on port_id",
6372 (void *)&cmd_mac_addr_cmd,
6373 (void *)&cmd_mac_addr_what,
6374 (void *)&cmd_mac_addr_portnum,
6375 (void *)&cmd_mac_addr_addr,
6381 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6382 struct cmd_set_qmap_result {
6383 cmdline_fixed_string_t set;
6384 cmdline_fixed_string_t qmap;
6385 cmdline_fixed_string_t what;
6392 cmd_set_qmap_parsed(void *parsed_result,
6393 __attribute__((unused)) struct cmdline *cl,
6394 __attribute__((unused)) void *data)
6396 struct cmd_set_qmap_result *res = parsed_result;
6397 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6399 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6402 cmdline_parse_token_string_t cmd_setqmap_set =
6403 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6405 cmdline_parse_token_string_t cmd_setqmap_qmap =
6406 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6408 cmdline_parse_token_string_t cmd_setqmap_what =
6409 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6411 cmdline_parse_token_num_t cmd_setqmap_portid =
6412 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6414 cmdline_parse_token_num_t cmd_setqmap_queueid =
6415 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6417 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6418 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6421 cmdline_parse_inst_t cmd_set_qmap = {
6422 .f = cmd_set_qmap_parsed,
6424 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6425 "Set statistics mapping value on tx|rx queue_id of port_id",
6427 (void *)&cmd_setqmap_set,
6428 (void *)&cmd_setqmap_qmap,
6429 (void *)&cmd_setqmap_what,
6430 (void *)&cmd_setqmap_portid,
6431 (void *)&cmd_setqmap_queueid,
6432 (void *)&cmd_setqmap_mapvalue,
6437 /* *** CONFIGURE UNICAST HASH TABLE *** */
6438 struct cmd_set_uc_hash_table {
6439 cmdline_fixed_string_t set;
6440 cmdline_fixed_string_t port;
6442 cmdline_fixed_string_t what;
6443 struct ether_addr address;
6444 cmdline_fixed_string_t mode;
6448 cmd_set_uc_hash_parsed(void *parsed_result,
6449 __attribute__((unused)) struct cmdline *cl,
6450 __attribute__((unused)) void *data)
6453 struct cmd_set_uc_hash_table *res = parsed_result;
6455 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6457 if (strcmp(res->what, "uta") == 0)
6458 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6459 &res->address,(uint8_t)is_on);
6461 printf("bad unicast hash table parameter, return code = %d \n", ret);
6465 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6468 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6469 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6471 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6472 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6474 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6477 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6478 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6480 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6481 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6484 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6485 .f = cmd_set_uc_hash_parsed,
6487 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6489 (void *)&cmd_set_uc_hash_set,
6490 (void *)&cmd_set_uc_hash_port,
6491 (void *)&cmd_set_uc_hash_portid,
6492 (void *)&cmd_set_uc_hash_what,
6493 (void *)&cmd_set_uc_hash_mac,
6494 (void *)&cmd_set_uc_hash_mode,
6499 struct cmd_set_uc_all_hash_table {
6500 cmdline_fixed_string_t set;
6501 cmdline_fixed_string_t port;
6503 cmdline_fixed_string_t what;
6504 cmdline_fixed_string_t value;
6505 cmdline_fixed_string_t mode;
6509 cmd_set_uc_all_hash_parsed(void *parsed_result,
6510 __attribute__((unused)) struct cmdline *cl,
6511 __attribute__((unused)) void *data)
6514 struct cmd_set_uc_all_hash_table *res = parsed_result;
6516 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6518 if ((strcmp(res->what, "uta") == 0) &&
6519 (strcmp(res->value, "all") == 0))
6520 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6522 printf("bad unicast hash table parameter,"
6523 "return code = %d \n", ret);
6526 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6527 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6529 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6530 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6532 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6533 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6535 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6536 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6538 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6539 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6541 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6542 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6545 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6546 .f = cmd_set_uc_all_hash_parsed,
6548 .help_str = "set port <port_id> uta all on|off",
6550 (void *)&cmd_set_uc_all_hash_set,
6551 (void *)&cmd_set_uc_all_hash_port,
6552 (void *)&cmd_set_uc_all_hash_portid,
6553 (void *)&cmd_set_uc_all_hash_what,
6554 (void *)&cmd_set_uc_all_hash_value,
6555 (void *)&cmd_set_uc_all_hash_mode,
6560 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6561 struct cmd_set_vf_macvlan_filter {
6562 cmdline_fixed_string_t set;
6563 cmdline_fixed_string_t port;
6565 cmdline_fixed_string_t vf;
6567 struct ether_addr address;
6568 cmdline_fixed_string_t filter_type;
6569 cmdline_fixed_string_t mode;
6573 cmd_set_vf_macvlan_parsed(void *parsed_result,
6574 __attribute__((unused)) struct cmdline *cl,
6575 __attribute__((unused)) void *data)
6578 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6579 struct rte_eth_mac_filter filter;
6581 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6583 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6585 /* set VF MAC filter */
6589 filter.dst_id = res->vf_id;
6591 if (!strcmp(res->filter_type, "exact-mac"))
6592 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6593 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6594 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6595 else if (!strcmp(res->filter_type, "hashmac"))
6596 filter.filter_type = RTE_MAC_HASH_MATCH;
6597 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6598 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6600 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6603 ret = rte_eth_dev_filter_ctrl(res->port_id,
6604 RTE_ETH_FILTER_MACVLAN,
6608 ret = rte_eth_dev_filter_ctrl(res->port_id,
6609 RTE_ETH_FILTER_MACVLAN,
6610 RTE_ETH_FILTER_DELETE,
6614 printf("bad set MAC hash parameter, return code = %d\n", ret);
6618 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6621 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6624 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6625 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6627 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6628 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6630 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6631 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6633 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6634 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6636 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6637 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6638 filter_type, "exact-mac#exact-mac-vlan"
6639 "#hashmac#hashmac-vlan");
6640 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6641 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6644 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6645 .f = cmd_set_vf_macvlan_parsed,
6647 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6648 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6649 "Exact match rule: exact match of MAC or MAC and VLAN; "
6650 "hash match rule: hash match of MAC and exact match of VLAN",
6652 (void *)&cmd_set_vf_macvlan_set,
6653 (void *)&cmd_set_vf_macvlan_port,
6654 (void *)&cmd_set_vf_macvlan_portid,
6655 (void *)&cmd_set_vf_macvlan_vf,
6656 (void *)&cmd_set_vf_macvlan_vf_id,
6657 (void *)&cmd_set_vf_macvlan_mac,
6658 (void *)&cmd_set_vf_macvlan_filter_type,
6659 (void *)&cmd_set_vf_macvlan_mode,
6664 #ifdef RTE_LIBRTE_IXGBE_PMD
6665 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6666 struct cmd_set_vf_traffic {
6667 cmdline_fixed_string_t set;
6668 cmdline_fixed_string_t port;
6670 cmdline_fixed_string_t vf;
6672 cmdline_fixed_string_t what;
6673 cmdline_fixed_string_t mode;
6677 cmd_set_vf_traffic_parsed(void *parsed_result,
6678 __attribute__((unused)) struct cmdline *cl,
6679 __attribute__((unused)) void *data)
6681 struct cmd_set_vf_traffic *res = parsed_result;
6682 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6683 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6685 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6688 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6689 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6691 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6692 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6694 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6695 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6697 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6698 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6700 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6701 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6703 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6704 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6706 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6707 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6710 cmdline_parse_inst_t cmd_set_vf_traffic = {
6711 .f = cmd_set_vf_traffic_parsed,
6713 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6715 (void *)&cmd_setvf_traffic_set,
6716 (void *)&cmd_setvf_traffic_port,
6717 (void *)&cmd_setvf_traffic_portid,
6718 (void *)&cmd_setvf_traffic_vf,
6719 (void *)&cmd_setvf_traffic_vfid,
6720 (void *)&cmd_setvf_traffic_what,
6721 (void *)&cmd_setvf_traffic_mode,
6726 /* *** CONFIGURE VF RECEIVE MODE *** */
6727 struct cmd_set_vf_rxmode {
6728 cmdline_fixed_string_t set;
6729 cmdline_fixed_string_t port;
6731 cmdline_fixed_string_t vf;
6733 cmdline_fixed_string_t what;
6734 cmdline_fixed_string_t mode;
6735 cmdline_fixed_string_t on;
6739 cmd_set_vf_rxmode_parsed(void *parsed_result,
6740 __attribute__((unused)) struct cmdline *cl,
6741 __attribute__((unused)) void *data)
6744 uint16_t rx_mode = 0;
6745 struct cmd_set_vf_rxmode *res = parsed_result;
6747 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6748 if (!strcmp(res->what,"rxmode")) {
6749 if (!strcmp(res->mode, "AUPE"))
6750 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6751 else if (!strcmp(res->mode, "ROPE"))
6752 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6753 else if (!strcmp(res->mode, "BAM"))
6754 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6755 else if (!strncmp(res->mode, "MPE",3))
6756 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6759 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6761 printf("bad VF receive mode parameter, return code = %d \n",
6765 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6766 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6768 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6769 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6771 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6772 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6774 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6775 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6777 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6778 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6780 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6781 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6783 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6784 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6785 mode, "AUPE#ROPE#BAM#MPE");
6786 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6787 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6790 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6791 .f = cmd_set_vf_rxmode_parsed,
6793 .help_str = "set port <port_id> vf <vf_id> rxmode "
6794 "AUPE|ROPE|BAM|MPE on|off",
6796 (void *)&cmd_set_vf_rxmode_set,
6797 (void *)&cmd_set_vf_rxmode_port,
6798 (void *)&cmd_set_vf_rxmode_portid,
6799 (void *)&cmd_set_vf_rxmode_vf,
6800 (void *)&cmd_set_vf_rxmode_vfid,
6801 (void *)&cmd_set_vf_rxmode_what,
6802 (void *)&cmd_set_vf_rxmode_mode,
6803 (void *)&cmd_set_vf_rxmode_on,
6809 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6810 struct cmd_vf_mac_addr_result {
6811 cmdline_fixed_string_t mac_addr_cmd;
6812 cmdline_fixed_string_t what;
6813 cmdline_fixed_string_t port;
6815 cmdline_fixed_string_t vf;
6817 struct ether_addr address;
6820 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6821 __attribute__((unused)) struct cmdline *cl,
6822 __attribute__((unused)) void *data)
6824 struct cmd_vf_mac_addr_result *res = parsed_result;
6827 if (strcmp(res->what, "add") == 0)
6828 ret = rte_eth_dev_mac_addr_add(res->port_num,
6829 &res->address, res->vf_num);
6831 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6835 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6836 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6837 mac_addr_cmd,"mac_addr");
6838 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6839 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6841 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6842 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6844 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6845 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6847 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6848 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6850 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6851 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6853 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6854 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6857 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6858 .f = cmd_vf_mac_addr_parsed,
6860 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6861 "Add MAC address filtering for a VF on port_id",
6863 (void *)&cmd_vf_mac_addr_cmd,
6864 (void *)&cmd_vf_mac_addr_what,
6865 (void *)&cmd_vf_mac_addr_port,
6866 (void *)&cmd_vf_mac_addr_portnum,
6867 (void *)&cmd_vf_mac_addr_vf,
6868 (void *)&cmd_vf_mac_addr_vfnum,
6869 (void *)&cmd_vf_mac_addr_addr,
6874 #ifdef RTE_LIBRTE_IXGBE_PMD
6875 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6876 struct cmd_vf_rx_vlan_filter {
6877 cmdline_fixed_string_t rx_vlan;
6878 cmdline_fixed_string_t what;
6880 cmdline_fixed_string_t port;
6882 cmdline_fixed_string_t vf;
6887 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6888 __attribute__((unused)) struct cmdline *cl,
6889 __attribute__((unused)) void *data)
6891 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6893 if (!strcmp(res->what, "add"))
6894 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6896 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6899 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6900 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6901 rx_vlan, "rx_vlan");
6902 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6903 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6905 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6906 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6908 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6909 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6911 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6912 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6914 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6915 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6917 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6918 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6921 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6922 .f = cmd_vf_rx_vlan_filter_parsed,
6924 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6925 "(vf_mask = hexadecimal VF mask)",
6927 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6928 (void *)&cmd_vf_rx_vlan_filter_what,
6929 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6930 (void *)&cmd_vf_rx_vlan_filter_port,
6931 (void *)&cmd_vf_rx_vlan_filter_portid,
6932 (void *)&cmd_vf_rx_vlan_filter_vf,
6933 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6939 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6940 struct cmd_queue_rate_limit_result {
6941 cmdline_fixed_string_t set;
6942 cmdline_fixed_string_t port;
6944 cmdline_fixed_string_t queue;
6946 cmdline_fixed_string_t rate;
6950 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6951 __attribute__((unused)) struct cmdline *cl,
6952 __attribute__((unused)) void *data)
6954 struct cmd_queue_rate_limit_result *res = parsed_result;
6957 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6958 && (strcmp(res->queue, "queue") == 0)
6959 && (strcmp(res->rate, "rate") == 0))
6960 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6963 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6967 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6968 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6970 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6971 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6973 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6974 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6976 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6977 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6979 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6980 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6982 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6983 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6985 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6986 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6989 cmdline_parse_inst_t cmd_queue_rate_limit = {
6990 .f = cmd_queue_rate_limit_parsed,
6992 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6993 "Set rate limit for a queue on port_id",
6995 (void *)&cmd_queue_rate_limit_set,
6996 (void *)&cmd_queue_rate_limit_port,
6997 (void *)&cmd_queue_rate_limit_portnum,
6998 (void *)&cmd_queue_rate_limit_queue,
6999 (void *)&cmd_queue_rate_limit_queuenum,
7000 (void *)&cmd_queue_rate_limit_rate,
7001 (void *)&cmd_queue_rate_limit_ratenum,
7006 #ifdef RTE_LIBRTE_IXGBE_PMD
7007 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7008 struct cmd_vf_rate_limit_result {
7009 cmdline_fixed_string_t set;
7010 cmdline_fixed_string_t port;
7012 cmdline_fixed_string_t vf;
7014 cmdline_fixed_string_t rate;
7016 cmdline_fixed_string_t q_msk;
7020 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7021 __attribute__((unused)) struct cmdline *cl,
7022 __attribute__((unused)) void *data)
7024 struct cmd_vf_rate_limit_result *res = parsed_result;
7027 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7028 && (strcmp(res->vf, "vf") == 0)
7029 && (strcmp(res->rate, "rate") == 0)
7030 && (strcmp(res->q_msk, "queue_mask") == 0))
7031 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7032 res->rate_num, res->q_msk_val);
7034 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7038 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7039 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7041 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7042 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7044 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7045 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7047 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7048 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7050 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7051 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7053 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7054 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7056 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7057 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7059 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7060 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7061 q_msk, "queue_mask");
7062 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7063 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7066 cmdline_parse_inst_t cmd_vf_rate_limit = {
7067 .f = cmd_vf_rate_limit_parsed,
7069 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7070 "queue_mask <queue_mask_value>: "
7071 "Set rate limit for queues of VF on port_id",
7073 (void *)&cmd_vf_rate_limit_set,
7074 (void *)&cmd_vf_rate_limit_port,
7075 (void *)&cmd_vf_rate_limit_portnum,
7076 (void *)&cmd_vf_rate_limit_vf,
7077 (void *)&cmd_vf_rate_limit_vfnum,
7078 (void *)&cmd_vf_rate_limit_rate,
7079 (void *)&cmd_vf_rate_limit_ratenum,
7080 (void *)&cmd_vf_rate_limit_q_msk,
7081 (void *)&cmd_vf_rate_limit_q_msk_val,
7087 /* *** ADD TUNNEL FILTER OF A PORT *** */
7088 struct cmd_tunnel_filter_result {
7089 cmdline_fixed_string_t cmd;
7090 cmdline_fixed_string_t what;
7092 struct ether_addr outer_mac;
7093 struct ether_addr inner_mac;
7094 cmdline_ipaddr_t ip_value;
7095 uint16_t inner_vlan;
7096 cmdline_fixed_string_t tunnel_type;
7097 cmdline_fixed_string_t filter_type;
7103 cmd_tunnel_filter_parsed(void *parsed_result,
7104 __attribute__((unused)) struct cmdline *cl,
7105 __attribute__((unused)) void *data)
7107 struct cmd_tunnel_filter_result *res = parsed_result;
7108 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7111 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7113 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7114 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7115 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7117 if (res->ip_value.family == AF_INET) {
7118 tunnel_filter_conf.ip_addr.ipv4_addr =
7119 res->ip_value.addr.ipv4.s_addr;
7120 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7122 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7123 &(res->ip_value.addr.ipv6),
7124 sizeof(struct in6_addr));
7125 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7128 if (!strcmp(res->filter_type, "imac-ivlan"))
7129 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7130 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7131 tunnel_filter_conf.filter_type =
7132 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7133 else if (!strcmp(res->filter_type, "imac-tenid"))
7134 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7135 else if (!strcmp(res->filter_type, "imac"))
7136 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7137 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7138 tunnel_filter_conf.filter_type =
7139 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7140 else if (!strcmp(res->filter_type, "oip"))
7141 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7142 else if (!strcmp(res->filter_type, "iip"))
7143 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7145 printf("The filter type is not supported");
7149 if (!strcmp(res->tunnel_type, "vxlan"))
7150 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7151 else if (!strcmp(res->tunnel_type, "nvgre"))
7152 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7153 else if (!strcmp(res->tunnel_type, "ipingre"))
7154 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7156 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7160 tunnel_filter_conf.tenant_id = res->tenant_id;
7161 tunnel_filter_conf.queue_id = res->queue_num;
7162 if (!strcmp(res->what, "add"))
7163 ret = rte_eth_dev_filter_ctrl(res->port_id,
7164 RTE_ETH_FILTER_TUNNEL,
7166 &tunnel_filter_conf);
7168 ret = rte_eth_dev_filter_ctrl(res->port_id,
7169 RTE_ETH_FILTER_TUNNEL,
7170 RTE_ETH_FILTER_DELETE,
7171 &tunnel_filter_conf);
7173 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7177 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7178 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7179 cmd, "tunnel_filter");
7180 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7181 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7183 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7184 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7186 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7187 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7189 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7190 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7192 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7193 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7194 inner_vlan, UINT16);
7195 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7196 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7198 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7199 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7200 tunnel_type, "vxlan#nvgre#ipingre");
7202 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7203 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7204 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7205 "imac#omac-imac-tenid");
7206 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7207 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7209 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7210 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7213 cmdline_parse_inst_t cmd_tunnel_filter = {
7214 .f = cmd_tunnel_filter_parsed,
7216 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7217 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7218 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7219 "<queue_id>: Add/Rm tunnel filter of a port",
7221 (void *)&cmd_tunnel_filter_cmd,
7222 (void *)&cmd_tunnel_filter_what,
7223 (void *)&cmd_tunnel_filter_port_id,
7224 (void *)&cmd_tunnel_filter_outer_mac,
7225 (void *)&cmd_tunnel_filter_inner_mac,
7226 (void *)&cmd_tunnel_filter_ip_value,
7227 (void *)&cmd_tunnel_filter_innner_vlan,
7228 (void *)&cmd_tunnel_filter_tunnel_type,
7229 (void *)&cmd_tunnel_filter_filter_type,
7230 (void *)&cmd_tunnel_filter_tenant_id,
7231 (void *)&cmd_tunnel_filter_queue_num,
7236 /* *** CONFIGURE TUNNEL UDP PORT *** */
7237 struct cmd_tunnel_udp_config {
7238 cmdline_fixed_string_t cmd;
7239 cmdline_fixed_string_t what;
7245 cmd_tunnel_udp_config_parsed(void *parsed_result,
7246 __attribute__((unused)) struct cmdline *cl,
7247 __attribute__((unused)) void *data)
7249 struct cmd_tunnel_udp_config *res = parsed_result;
7250 struct rte_eth_udp_tunnel tunnel_udp;
7253 tunnel_udp.udp_port = res->udp_port;
7255 if (!strcmp(res->cmd, "rx_vxlan_port"))
7256 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7258 if (!strcmp(res->what, "add"))
7259 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7262 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7266 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7269 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7270 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7271 cmd, "rx_vxlan_port");
7272 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7273 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7275 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7276 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7278 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7279 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7282 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7283 .f = cmd_tunnel_udp_config_parsed,
7285 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7286 "Add/Remove a tunneling UDP port filter",
7288 (void *)&cmd_tunnel_udp_config_cmd,
7289 (void *)&cmd_tunnel_udp_config_what,
7290 (void *)&cmd_tunnel_udp_config_udp_port,
7291 (void *)&cmd_tunnel_udp_config_port_id,
7296 /* *** GLOBAL CONFIG *** */
7297 struct cmd_global_config_result {
7298 cmdline_fixed_string_t cmd;
7300 cmdline_fixed_string_t cfg_type;
7305 cmd_global_config_parsed(void *parsed_result,
7306 __attribute__((unused)) struct cmdline *cl,
7307 __attribute__((unused)) void *data)
7309 struct cmd_global_config_result *res = parsed_result;
7310 struct rte_eth_global_cfg conf;
7313 memset(&conf, 0, sizeof(conf));
7314 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7315 conf.cfg.gre_key_len = res->len;
7316 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7317 RTE_ETH_FILTER_SET, &conf);
7319 printf("Global config error\n");
7322 cmdline_parse_token_string_t cmd_global_config_cmd =
7323 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7325 cmdline_parse_token_num_t cmd_global_config_port_id =
7326 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7327 cmdline_parse_token_string_t cmd_global_config_type =
7328 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7329 cfg_type, "gre-key-len");
7330 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7331 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7334 cmdline_parse_inst_t cmd_global_config = {
7335 .f = cmd_global_config_parsed,
7336 .data = (void *)NULL,
7337 .help_str = "global_config <port_id> gre-key-len <key_len>",
7339 (void *)&cmd_global_config_cmd,
7340 (void *)&cmd_global_config_port_id,
7341 (void *)&cmd_global_config_type,
7342 (void *)&cmd_global_config_gre_key_len,
7347 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7348 struct cmd_set_mirror_mask_result {
7349 cmdline_fixed_string_t set;
7350 cmdline_fixed_string_t port;
7352 cmdline_fixed_string_t mirror;
7354 cmdline_fixed_string_t what;
7355 cmdline_fixed_string_t value;
7356 cmdline_fixed_string_t dstpool;
7358 cmdline_fixed_string_t on;
7361 cmdline_parse_token_string_t cmd_mirror_mask_set =
7362 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7364 cmdline_parse_token_string_t cmd_mirror_mask_port =
7365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7367 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7368 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7370 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7371 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7372 mirror, "mirror-rule");
7373 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7374 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7376 cmdline_parse_token_string_t cmd_mirror_mask_what =
7377 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7378 what, "pool-mirror-up#pool-mirror-down"
7380 cmdline_parse_token_string_t cmd_mirror_mask_value =
7381 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7383 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7384 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7385 dstpool, "dst-pool");
7386 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7387 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7389 cmdline_parse_token_string_t cmd_mirror_mask_on =
7390 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7394 cmd_set_mirror_mask_parsed(void *parsed_result,
7395 __attribute__((unused)) struct cmdline *cl,
7396 __attribute__((unused)) void *data)
7399 struct cmd_set_mirror_mask_result *res = parsed_result;
7400 struct rte_eth_mirror_conf mr_conf;
7402 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7404 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7406 mr_conf.dst_pool = res->dstpool_id;
7408 if (!strcmp(res->what, "pool-mirror-up")) {
7409 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7410 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7411 } else if (!strcmp(res->what, "pool-mirror-down")) {
7412 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7413 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7414 } else if (!strcmp(res->what, "vlan-mirror")) {
7415 mr_conf.rule_type = ETH_MIRROR_VLAN;
7416 nb_item = parse_item_list(res->value, "vlan",
7417 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7421 for (i = 0; i < nb_item; i++) {
7422 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7423 printf("Invalid vlan_id: must be < 4096\n");
7427 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7428 mr_conf.vlan.vlan_mask |= 1ULL << i;
7432 if (!strcmp(res->on, "on"))
7433 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7436 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7439 printf("mirror rule add error: (%s)\n", strerror(-ret));
7442 cmdline_parse_inst_t cmd_set_mirror_mask = {
7443 .f = cmd_set_mirror_mask_parsed,
7445 .help_str = "set port <port_id> mirror-rule <rule_id> "
7446 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7447 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7449 (void *)&cmd_mirror_mask_set,
7450 (void *)&cmd_mirror_mask_port,
7451 (void *)&cmd_mirror_mask_portid,
7452 (void *)&cmd_mirror_mask_mirror,
7453 (void *)&cmd_mirror_mask_ruleid,
7454 (void *)&cmd_mirror_mask_what,
7455 (void *)&cmd_mirror_mask_value,
7456 (void *)&cmd_mirror_mask_dstpool,
7457 (void *)&cmd_mirror_mask_poolid,
7458 (void *)&cmd_mirror_mask_on,
7463 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7464 struct cmd_set_mirror_link_result {
7465 cmdline_fixed_string_t set;
7466 cmdline_fixed_string_t port;
7468 cmdline_fixed_string_t mirror;
7470 cmdline_fixed_string_t what;
7471 cmdline_fixed_string_t dstpool;
7473 cmdline_fixed_string_t on;
7476 cmdline_parse_token_string_t cmd_mirror_link_set =
7477 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7479 cmdline_parse_token_string_t cmd_mirror_link_port =
7480 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7482 cmdline_parse_token_num_t cmd_mirror_link_portid =
7483 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7485 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7486 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7487 mirror, "mirror-rule");
7488 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7489 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7491 cmdline_parse_token_string_t cmd_mirror_link_what =
7492 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7493 what, "uplink-mirror#downlink-mirror");
7494 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7495 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7496 dstpool, "dst-pool");
7497 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7498 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7500 cmdline_parse_token_string_t cmd_mirror_link_on =
7501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7505 cmd_set_mirror_link_parsed(void *parsed_result,
7506 __attribute__((unused)) struct cmdline *cl,
7507 __attribute__((unused)) void *data)
7510 struct cmd_set_mirror_link_result *res = parsed_result;
7511 struct rte_eth_mirror_conf mr_conf;
7513 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7514 if (!strcmp(res->what, "uplink-mirror"))
7515 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7517 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7519 mr_conf.dst_pool = res->dstpool_id;
7521 if (!strcmp(res->on, "on"))
7522 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7525 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7528 /* check the return value and print it if is < 0 */
7530 printf("mirror rule add error: (%s)\n", strerror(-ret));
7534 cmdline_parse_inst_t cmd_set_mirror_link = {
7535 .f = cmd_set_mirror_link_parsed,
7537 .help_str = "set port <port_id> mirror-rule <rule_id> "
7538 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7540 (void *)&cmd_mirror_link_set,
7541 (void *)&cmd_mirror_link_port,
7542 (void *)&cmd_mirror_link_portid,
7543 (void *)&cmd_mirror_link_mirror,
7544 (void *)&cmd_mirror_link_ruleid,
7545 (void *)&cmd_mirror_link_what,
7546 (void *)&cmd_mirror_link_dstpool,
7547 (void *)&cmd_mirror_link_poolid,
7548 (void *)&cmd_mirror_link_on,
7553 /* *** RESET VM MIRROR RULE *** */
7554 struct cmd_rm_mirror_rule_result {
7555 cmdline_fixed_string_t reset;
7556 cmdline_fixed_string_t port;
7558 cmdline_fixed_string_t mirror;
7562 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7563 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7565 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7566 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7568 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7569 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7571 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7572 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7573 mirror, "mirror-rule");
7574 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7575 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7579 cmd_reset_mirror_rule_parsed(void *parsed_result,
7580 __attribute__((unused)) struct cmdline *cl,
7581 __attribute__((unused)) void *data)
7584 struct cmd_set_mirror_link_result *res = parsed_result;
7586 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7588 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7591 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7592 .f = cmd_reset_mirror_rule_parsed,
7594 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7596 (void *)&cmd_rm_mirror_rule_reset,
7597 (void *)&cmd_rm_mirror_rule_port,
7598 (void *)&cmd_rm_mirror_rule_portid,
7599 (void *)&cmd_rm_mirror_rule_mirror,
7600 (void *)&cmd_rm_mirror_rule_ruleid,
7605 /* ******************************************************************************** */
7607 struct cmd_dump_result {
7608 cmdline_fixed_string_t dump;
7612 dump_struct_sizes(void)
7614 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7615 DUMP_SIZE(struct rte_mbuf);
7616 DUMP_SIZE(struct rte_mempool);
7617 DUMP_SIZE(struct rte_ring);
7621 static void cmd_dump_parsed(void *parsed_result,
7622 __attribute__((unused)) struct cmdline *cl,
7623 __attribute__((unused)) void *data)
7625 struct cmd_dump_result *res = parsed_result;
7627 if (!strcmp(res->dump, "dump_physmem"))
7628 rte_dump_physmem_layout(stdout);
7629 else if (!strcmp(res->dump, "dump_memzone"))
7630 rte_memzone_dump(stdout);
7631 else if (!strcmp(res->dump, "dump_struct_sizes"))
7632 dump_struct_sizes();
7633 else if (!strcmp(res->dump, "dump_ring"))
7634 rte_ring_list_dump(stdout);
7635 else if (!strcmp(res->dump, "dump_mempool"))
7636 rte_mempool_list_dump(stdout);
7637 else if (!strcmp(res->dump, "dump_devargs"))
7638 rte_eal_devargs_dump(stdout);
7641 cmdline_parse_token_string_t cmd_dump_dump =
7642 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7645 "dump_struct_sizes#"
7650 cmdline_parse_inst_t cmd_dump = {
7651 .f = cmd_dump_parsed, /* function to call */
7652 .data = NULL, /* 2nd arg of func */
7653 .help_str = "Dump status",
7654 .tokens = { /* token list, NULL terminated */
7655 (void *)&cmd_dump_dump,
7660 /* ******************************************************************************** */
7662 struct cmd_dump_one_result {
7663 cmdline_fixed_string_t dump;
7664 cmdline_fixed_string_t name;
7667 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7668 __attribute__((unused)) void *data)
7670 struct cmd_dump_one_result *res = parsed_result;
7672 if (!strcmp(res->dump, "dump_ring")) {
7674 r = rte_ring_lookup(res->name);
7676 cmdline_printf(cl, "Cannot find ring\n");
7679 rte_ring_dump(stdout, r);
7680 } else if (!strcmp(res->dump, "dump_mempool")) {
7681 struct rte_mempool *mp;
7682 mp = rte_mempool_lookup(res->name);
7684 cmdline_printf(cl, "Cannot find mempool\n");
7687 rte_mempool_dump(stdout, mp);
7691 cmdline_parse_token_string_t cmd_dump_one_dump =
7692 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7693 "dump_ring#dump_mempool");
7695 cmdline_parse_token_string_t cmd_dump_one_name =
7696 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7698 cmdline_parse_inst_t cmd_dump_one = {
7699 .f = cmd_dump_one_parsed, /* function to call */
7700 .data = NULL, /* 2nd arg of func */
7701 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7702 .tokens = { /* token list, NULL terminated */
7703 (void *)&cmd_dump_one_dump,
7704 (void *)&cmd_dump_one_name,
7709 /* *** Add/Del syn filter *** */
7710 struct cmd_syn_filter_result {
7711 cmdline_fixed_string_t filter;
7713 cmdline_fixed_string_t ops;
7714 cmdline_fixed_string_t priority;
7715 cmdline_fixed_string_t high;
7716 cmdline_fixed_string_t queue;
7721 cmd_syn_filter_parsed(void *parsed_result,
7722 __attribute__((unused)) struct cmdline *cl,
7723 __attribute__((unused)) void *data)
7725 struct cmd_syn_filter_result *res = parsed_result;
7726 struct rte_eth_syn_filter syn_filter;
7729 ret = rte_eth_dev_filter_supported(res->port_id,
7730 RTE_ETH_FILTER_SYN);
7732 printf("syn filter is not supported on port %u.\n",
7737 memset(&syn_filter, 0, sizeof(syn_filter));
7739 if (!strcmp(res->ops, "add")) {
7740 if (!strcmp(res->high, "high"))
7741 syn_filter.hig_pri = 1;
7743 syn_filter.hig_pri = 0;
7745 syn_filter.queue = res->queue_id;
7746 ret = rte_eth_dev_filter_ctrl(res->port_id,
7751 ret = rte_eth_dev_filter_ctrl(res->port_id,
7753 RTE_ETH_FILTER_DELETE,
7757 printf("syn filter programming error: (%s)\n",
7761 cmdline_parse_token_string_t cmd_syn_filter_filter =
7762 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7763 filter, "syn_filter");
7764 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7765 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7767 cmdline_parse_token_string_t cmd_syn_filter_ops =
7768 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7770 cmdline_parse_token_string_t cmd_syn_filter_priority =
7771 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7772 priority, "priority");
7773 cmdline_parse_token_string_t cmd_syn_filter_high =
7774 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7776 cmdline_parse_token_string_t cmd_syn_filter_queue =
7777 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7779 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7780 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7783 cmdline_parse_inst_t cmd_syn_filter = {
7784 .f = cmd_syn_filter_parsed,
7786 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7787 "<queue_id>: Add/Delete syn filter",
7789 (void *)&cmd_syn_filter_filter,
7790 (void *)&cmd_syn_filter_port_id,
7791 (void *)&cmd_syn_filter_ops,
7792 (void *)&cmd_syn_filter_priority,
7793 (void *)&cmd_syn_filter_high,
7794 (void *)&cmd_syn_filter_queue,
7795 (void *)&cmd_syn_filter_queue_id,
7800 /* *** ADD/REMOVE A 2tuple FILTER *** */
7801 struct cmd_2tuple_filter_result {
7802 cmdline_fixed_string_t filter;
7804 cmdline_fixed_string_t ops;
7805 cmdline_fixed_string_t dst_port;
7806 uint16_t dst_port_value;
7807 cmdline_fixed_string_t protocol;
7808 uint8_t protocol_value;
7809 cmdline_fixed_string_t mask;
7811 cmdline_fixed_string_t tcp_flags;
7812 uint8_t tcp_flags_value;
7813 cmdline_fixed_string_t priority;
7814 uint8_t priority_value;
7815 cmdline_fixed_string_t queue;
7820 cmd_2tuple_filter_parsed(void *parsed_result,
7821 __attribute__((unused)) struct cmdline *cl,
7822 __attribute__((unused)) void *data)
7824 struct rte_eth_ntuple_filter filter;
7825 struct cmd_2tuple_filter_result *res = parsed_result;
7828 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7830 printf("ntuple filter is not supported on port %u.\n",
7835 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7837 filter.flags = RTE_2TUPLE_FLAGS;
7838 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7839 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7840 filter.proto = res->protocol_value;
7841 filter.priority = res->priority_value;
7842 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7843 printf("nonzero tcp_flags is only meaningful"
7844 " when protocol is TCP.\n");
7847 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7848 printf("invalid TCP flags.\n");
7852 if (res->tcp_flags_value != 0) {
7853 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7854 filter.tcp_flags = res->tcp_flags_value;
7857 /* need convert to big endian. */
7858 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7859 filter.queue = res->queue_id;
7861 if (!strcmp(res->ops, "add"))
7862 ret = rte_eth_dev_filter_ctrl(res->port_id,
7863 RTE_ETH_FILTER_NTUPLE,
7867 ret = rte_eth_dev_filter_ctrl(res->port_id,
7868 RTE_ETH_FILTER_NTUPLE,
7869 RTE_ETH_FILTER_DELETE,
7872 printf("2tuple filter programming error: (%s)\n",
7877 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7878 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7879 filter, "2tuple_filter");
7880 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7881 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7883 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7884 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7886 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7887 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7888 dst_port, "dst_port");
7889 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7890 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7891 dst_port_value, UINT16);
7892 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7893 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7894 protocol, "protocol");
7895 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7896 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7897 protocol_value, UINT8);
7898 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7899 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7901 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7902 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7904 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7905 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7906 tcp_flags, "tcp_flags");
7907 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7908 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7909 tcp_flags_value, UINT8);
7910 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7911 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7912 priority, "priority");
7913 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7914 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7915 priority_value, UINT8);
7916 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7917 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7919 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7920 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7923 cmdline_parse_inst_t cmd_2tuple_filter = {
7924 .f = cmd_2tuple_filter_parsed,
7926 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7927 "<value> mask <value> tcp_flags <value> priority <value> queue "
7928 "<queue_id>: Add a 2tuple filter",
7930 (void *)&cmd_2tuple_filter_filter,
7931 (void *)&cmd_2tuple_filter_port_id,
7932 (void *)&cmd_2tuple_filter_ops,
7933 (void *)&cmd_2tuple_filter_dst_port,
7934 (void *)&cmd_2tuple_filter_dst_port_value,
7935 (void *)&cmd_2tuple_filter_protocol,
7936 (void *)&cmd_2tuple_filter_protocol_value,
7937 (void *)&cmd_2tuple_filter_mask,
7938 (void *)&cmd_2tuple_filter_mask_value,
7939 (void *)&cmd_2tuple_filter_tcp_flags,
7940 (void *)&cmd_2tuple_filter_tcp_flags_value,
7941 (void *)&cmd_2tuple_filter_priority,
7942 (void *)&cmd_2tuple_filter_priority_value,
7943 (void *)&cmd_2tuple_filter_queue,
7944 (void *)&cmd_2tuple_filter_queue_id,
7949 /* *** ADD/REMOVE A 5tuple FILTER *** */
7950 struct cmd_5tuple_filter_result {
7951 cmdline_fixed_string_t filter;
7953 cmdline_fixed_string_t ops;
7954 cmdline_fixed_string_t dst_ip;
7955 cmdline_ipaddr_t dst_ip_value;
7956 cmdline_fixed_string_t src_ip;
7957 cmdline_ipaddr_t src_ip_value;
7958 cmdline_fixed_string_t dst_port;
7959 uint16_t dst_port_value;
7960 cmdline_fixed_string_t src_port;
7961 uint16_t src_port_value;
7962 cmdline_fixed_string_t protocol;
7963 uint8_t protocol_value;
7964 cmdline_fixed_string_t mask;
7966 cmdline_fixed_string_t tcp_flags;
7967 uint8_t tcp_flags_value;
7968 cmdline_fixed_string_t priority;
7969 uint8_t priority_value;
7970 cmdline_fixed_string_t queue;
7975 cmd_5tuple_filter_parsed(void *parsed_result,
7976 __attribute__((unused)) struct cmdline *cl,
7977 __attribute__((unused)) void *data)
7979 struct rte_eth_ntuple_filter filter;
7980 struct cmd_5tuple_filter_result *res = parsed_result;
7983 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7985 printf("ntuple filter is not supported on port %u.\n",
7990 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7992 filter.flags = RTE_5TUPLE_FLAGS;
7993 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7994 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7995 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7996 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7997 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7998 filter.proto = res->protocol_value;
7999 filter.priority = res->priority_value;
8000 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8001 printf("nonzero tcp_flags is only meaningful"
8002 " when protocol is TCP.\n");
8005 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8006 printf("invalid TCP flags.\n");
8010 if (res->tcp_flags_value != 0) {
8011 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8012 filter.tcp_flags = res->tcp_flags_value;
8015 if (res->dst_ip_value.family == AF_INET)
8016 /* no need to convert, already big endian. */
8017 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8019 if (filter.dst_ip_mask == 0) {
8020 printf("can not support ipv6 involved compare.\n");
8026 if (res->src_ip_value.family == AF_INET)
8027 /* no need to convert, already big endian. */
8028 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8030 if (filter.src_ip_mask == 0) {
8031 printf("can not support ipv6 involved compare.\n");
8036 /* need convert to big endian. */
8037 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8038 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8039 filter.queue = res->queue_id;
8041 if (!strcmp(res->ops, "add"))
8042 ret = rte_eth_dev_filter_ctrl(res->port_id,
8043 RTE_ETH_FILTER_NTUPLE,
8047 ret = rte_eth_dev_filter_ctrl(res->port_id,
8048 RTE_ETH_FILTER_NTUPLE,
8049 RTE_ETH_FILTER_DELETE,
8052 printf("5tuple filter programming error: (%s)\n",
8056 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8057 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8058 filter, "5tuple_filter");
8059 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8060 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8062 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8063 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8065 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8066 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8068 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8069 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8071 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8072 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8074 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8075 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8077 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8078 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8079 dst_port, "dst_port");
8080 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8081 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8082 dst_port_value, UINT16);
8083 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8084 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8085 src_port, "src_port");
8086 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8087 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8088 src_port_value, UINT16);
8089 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8090 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8091 protocol, "protocol");
8092 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8093 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8094 protocol_value, UINT8);
8095 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8096 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8098 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8099 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8101 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8102 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8103 tcp_flags, "tcp_flags");
8104 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8105 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8106 tcp_flags_value, UINT8);
8107 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8108 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8109 priority, "priority");
8110 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8111 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8112 priority_value, UINT8);
8113 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8114 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8116 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8117 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8120 cmdline_parse_inst_t cmd_5tuple_filter = {
8121 .f = cmd_5tuple_filter_parsed,
8123 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8124 "src_ip <value> dst_port <value> src_port <value> "
8125 "protocol <value> mask <value> tcp_flags <value> "
8126 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8128 (void *)&cmd_5tuple_filter_filter,
8129 (void *)&cmd_5tuple_filter_port_id,
8130 (void *)&cmd_5tuple_filter_ops,
8131 (void *)&cmd_5tuple_filter_dst_ip,
8132 (void *)&cmd_5tuple_filter_dst_ip_value,
8133 (void *)&cmd_5tuple_filter_src_ip,
8134 (void *)&cmd_5tuple_filter_src_ip_value,
8135 (void *)&cmd_5tuple_filter_dst_port,
8136 (void *)&cmd_5tuple_filter_dst_port_value,
8137 (void *)&cmd_5tuple_filter_src_port,
8138 (void *)&cmd_5tuple_filter_src_port_value,
8139 (void *)&cmd_5tuple_filter_protocol,
8140 (void *)&cmd_5tuple_filter_protocol_value,
8141 (void *)&cmd_5tuple_filter_mask,
8142 (void *)&cmd_5tuple_filter_mask_value,
8143 (void *)&cmd_5tuple_filter_tcp_flags,
8144 (void *)&cmd_5tuple_filter_tcp_flags_value,
8145 (void *)&cmd_5tuple_filter_priority,
8146 (void *)&cmd_5tuple_filter_priority_value,
8147 (void *)&cmd_5tuple_filter_queue,
8148 (void *)&cmd_5tuple_filter_queue_id,
8153 /* *** ADD/REMOVE A flex FILTER *** */
8154 struct cmd_flex_filter_result {
8155 cmdline_fixed_string_t filter;
8156 cmdline_fixed_string_t ops;
8158 cmdline_fixed_string_t len;
8160 cmdline_fixed_string_t bytes;
8161 cmdline_fixed_string_t bytes_value;
8162 cmdline_fixed_string_t mask;
8163 cmdline_fixed_string_t mask_value;
8164 cmdline_fixed_string_t priority;
8165 uint8_t priority_value;
8166 cmdline_fixed_string_t queue;
8170 static int xdigit2val(unsigned char c)
8175 else if (isupper(c))
8183 cmd_flex_filter_parsed(void *parsed_result,
8184 __attribute__((unused)) struct cmdline *cl,
8185 __attribute__((unused)) void *data)
8188 struct rte_eth_flex_filter filter;
8189 struct cmd_flex_filter_result *res = parsed_result;
8190 char *bytes_ptr, *mask_ptr;
8191 uint16_t len, i, j = 0;
8196 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8197 printf("the len exceed the max length 128\n");
8200 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8201 filter.len = res->len_value;
8202 filter.priority = res->priority_value;
8203 filter.queue = res->queue_id;
8204 bytes_ptr = res->bytes_value;
8205 mask_ptr = res->mask_value;
8207 /* translate bytes string to array. */
8208 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8209 (bytes_ptr[1] == 'X')))
8211 len = strnlen(bytes_ptr, res->len_value * 2);
8212 if (len == 0 || (len % 8 != 0)) {
8213 printf("please check len and bytes input\n");
8216 for (i = 0; i < len; i++) {
8218 if (isxdigit(c) == 0) {
8219 /* invalid characters. */
8220 printf("invalid input\n");
8223 val = xdigit2val(c);
8226 filter.bytes[j] = byte;
8227 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8234 /* translate mask string to uint8_t array. */
8235 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8236 (mask_ptr[1] == 'X')))
8238 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8240 printf("invalid input\n");
8245 for (i = 0; i < len; i++) {
8247 if (isxdigit(c) == 0) {
8248 /* invalid characters. */
8249 printf("invalid input\n");
8252 val = xdigit2val(c);
8255 filter.mask[j] = byte;
8256 printf("mask[%d]:%02x ", j, filter.mask[j]);
8264 if (!strcmp(res->ops, "add"))
8265 ret = rte_eth_dev_filter_ctrl(res->port_id,
8266 RTE_ETH_FILTER_FLEXIBLE,
8270 ret = rte_eth_dev_filter_ctrl(res->port_id,
8271 RTE_ETH_FILTER_FLEXIBLE,
8272 RTE_ETH_FILTER_DELETE,
8276 printf("flex filter setting error: (%s)\n", strerror(-ret));
8279 cmdline_parse_token_string_t cmd_flex_filter_filter =
8280 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8281 filter, "flex_filter");
8282 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8283 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8285 cmdline_parse_token_string_t cmd_flex_filter_ops =
8286 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8288 cmdline_parse_token_string_t cmd_flex_filter_len =
8289 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8291 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8292 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8294 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8295 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8297 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8298 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8300 cmdline_parse_token_string_t cmd_flex_filter_mask =
8301 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8303 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8304 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8306 cmdline_parse_token_string_t cmd_flex_filter_priority =
8307 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8308 priority, "priority");
8309 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8310 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8311 priority_value, UINT8);
8312 cmdline_parse_token_string_t cmd_flex_filter_queue =
8313 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8315 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8316 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8318 cmdline_parse_inst_t cmd_flex_filter = {
8319 .f = cmd_flex_filter_parsed,
8321 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8322 "<value> mask <value> priority <value> queue <queue_id>: "
8323 "Add/Del a flex filter",
8325 (void *)&cmd_flex_filter_filter,
8326 (void *)&cmd_flex_filter_port_id,
8327 (void *)&cmd_flex_filter_ops,
8328 (void *)&cmd_flex_filter_len,
8329 (void *)&cmd_flex_filter_len_value,
8330 (void *)&cmd_flex_filter_bytes,
8331 (void *)&cmd_flex_filter_bytes_value,
8332 (void *)&cmd_flex_filter_mask,
8333 (void *)&cmd_flex_filter_mask_value,
8334 (void *)&cmd_flex_filter_priority,
8335 (void *)&cmd_flex_filter_priority_value,
8336 (void *)&cmd_flex_filter_queue,
8337 (void *)&cmd_flex_filter_queue_id,
8342 /* *** Filters Control *** */
8344 /* *** deal with ethertype filter *** */
8345 struct cmd_ethertype_filter_result {
8346 cmdline_fixed_string_t filter;
8348 cmdline_fixed_string_t ops;
8349 cmdline_fixed_string_t mac;
8350 struct ether_addr mac_addr;
8351 cmdline_fixed_string_t ethertype;
8352 uint16_t ethertype_value;
8353 cmdline_fixed_string_t drop;
8354 cmdline_fixed_string_t queue;
8358 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8359 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8360 filter, "ethertype_filter");
8361 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8362 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8364 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8365 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8367 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8368 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8369 mac, "mac_addr#mac_ignr");
8370 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8371 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8373 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8374 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8375 ethertype, "ethertype");
8376 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8377 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8378 ethertype_value, UINT16);
8379 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8380 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8382 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8383 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8385 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8386 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8390 cmd_ethertype_filter_parsed(void *parsed_result,
8391 __attribute__((unused)) struct cmdline *cl,
8392 __attribute__((unused)) void *data)
8394 struct cmd_ethertype_filter_result *res = parsed_result;
8395 struct rte_eth_ethertype_filter filter;
8398 ret = rte_eth_dev_filter_supported(res->port_id,
8399 RTE_ETH_FILTER_ETHERTYPE);
8401 printf("ethertype filter is not supported on port %u.\n",
8406 memset(&filter, 0, sizeof(filter));
8407 if (!strcmp(res->mac, "mac_addr")) {
8408 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8409 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8410 sizeof(struct ether_addr));
8412 if (!strcmp(res->drop, "drop"))
8413 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8414 filter.ether_type = res->ethertype_value;
8415 filter.queue = res->queue_id;
8417 if (!strcmp(res->ops, "add"))
8418 ret = rte_eth_dev_filter_ctrl(res->port_id,
8419 RTE_ETH_FILTER_ETHERTYPE,
8423 ret = rte_eth_dev_filter_ctrl(res->port_id,
8424 RTE_ETH_FILTER_ETHERTYPE,
8425 RTE_ETH_FILTER_DELETE,
8428 printf("ethertype filter programming error: (%s)\n",
8432 cmdline_parse_inst_t cmd_ethertype_filter = {
8433 .f = cmd_ethertype_filter_parsed,
8435 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8436 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8437 "Add or delete an ethertype filter entry",
8439 (void *)&cmd_ethertype_filter_filter,
8440 (void *)&cmd_ethertype_filter_port_id,
8441 (void *)&cmd_ethertype_filter_ops,
8442 (void *)&cmd_ethertype_filter_mac,
8443 (void *)&cmd_ethertype_filter_mac_addr,
8444 (void *)&cmd_ethertype_filter_ethertype,
8445 (void *)&cmd_ethertype_filter_ethertype_value,
8446 (void *)&cmd_ethertype_filter_drop,
8447 (void *)&cmd_ethertype_filter_queue,
8448 (void *)&cmd_ethertype_filter_queue_id,
8453 /* *** deal with flow director filter *** */
8454 struct cmd_flow_director_result {
8455 cmdline_fixed_string_t flow_director_filter;
8457 cmdline_fixed_string_t mode;
8458 cmdline_fixed_string_t mode_value;
8459 cmdline_fixed_string_t ops;
8460 cmdline_fixed_string_t flow;
8461 cmdline_fixed_string_t flow_type;
8462 cmdline_fixed_string_t ether;
8463 uint16_t ether_type;
8464 cmdline_fixed_string_t src;
8465 cmdline_ipaddr_t ip_src;
8467 cmdline_fixed_string_t dst;
8468 cmdline_ipaddr_t ip_dst;
8470 cmdline_fixed_string_t verify_tag;
8471 uint32_t verify_tag_value;
8472 cmdline_ipaddr_t tos;
8474 cmdline_ipaddr_t proto;
8475 uint8_t proto_value;
8476 cmdline_ipaddr_t ttl;
8478 cmdline_fixed_string_t vlan;
8479 uint16_t vlan_value;
8480 cmdline_fixed_string_t flexbytes;
8481 cmdline_fixed_string_t flexbytes_value;
8482 cmdline_fixed_string_t pf_vf;
8483 cmdline_fixed_string_t drop;
8484 cmdline_fixed_string_t queue;
8486 cmdline_fixed_string_t fd_id;
8487 uint32_t fd_id_value;
8488 cmdline_fixed_string_t mac;
8489 struct ether_addr mac_addr;
8490 cmdline_fixed_string_t tunnel;
8491 cmdline_fixed_string_t tunnel_type;
8492 cmdline_fixed_string_t tunnel_id;
8493 uint32_t tunnel_id_value;
8497 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8500 const char *p, *p0 = q_arg;
8502 unsigned long int_fld;
8503 char *str_fld[max_num];
8508 p = strchr(p0, '(');
8512 p0 = strchr(p, ')');
8517 if (size >= sizeof(s))
8520 snprintf(s, sizeof(s), "%.*s", size, p);
8521 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8522 if (ret < 0 || ret > max_num)
8524 for (i = 0; i < ret; i++) {
8526 int_fld = strtoul(str_fld[i], &end, 0);
8527 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8529 flexbytes[i] = (uint8_t)int_fld;
8535 str2flowtype(char *string)
8538 static const struct {
8541 } flowtype_str[] = {
8542 {"raw", RTE_ETH_FLOW_RAW},
8543 {"ipv4", RTE_ETH_FLOW_IPV4},
8544 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8545 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8546 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8547 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8548 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8549 {"ipv6", RTE_ETH_FLOW_IPV6},
8550 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8551 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8552 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8553 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8554 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8555 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8558 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8559 if (!strcmp(flowtype_str[i].str, string))
8560 return flowtype_str[i].type;
8562 return RTE_ETH_FLOW_UNKNOWN;
8565 static enum rte_eth_fdir_tunnel_type
8566 str2fdir_tunneltype(char *string)
8570 static const struct {
8572 enum rte_eth_fdir_tunnel_type type;
8573 } tunneltype_str[] = {
8574 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8575 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8578 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8579 if (!strcmp(tunneltype_str[i].str, string))
8580 return tunneltype_str[i].type;
8582 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8585 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8587 if ((ip_addr).family == AF_INET) \
8588 (ip) = (ip_addr).addr.ipv4.s_addr; \
8590 printf("invalid parameter.\n"); \
8595 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8597 if ((ip_addr).family == AF_INET6) \
8598 (void)rte_memcpy(&(ip), \
8599 &((ip_addr).addr.ipv6), \
8600 sizeof(struct in6_addr)); \
8602 printf("invalid parameter.\n"); \
8608 cmd_flow_director_filter_parsed(void *parsed_result,
8609 __attribute__((unused)) struct cmdline *cl,
8610 __attribute__((unused)) void *data)
8612 struct cmd_flow_director_result *res = parsed_result;
8613 struct rte_eth_fdir_filter entry;
8614 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8616 unsigned long vf_id;
8619 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8621 printf("flow director is not supported on port %u.\n",
8625 memset(flexbytes, 0, sizeof(flexbytes));
8626 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8628 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8629 if (strcmp(res->mode_value, "MAC-VLAN")) {
8630 printf("Please set mode to MAC-VLAN.\n");
8633 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8634 if (strcmp(res->mode_value, "Tunnel")) {
8635 printf("Please set mode to Tunnel.\n");
8639 if (strcmp(res->mode_value, "IP")) {
8640 printf("Please set mode to IP.\n");
8643 entry.input.flow_type = str2flowtype(res->flow_type);
8646 ret = parse_flexbytes(res->flexbytes_value,
8648 RTE_ETH_FDIR_MAX_FLEXLEN);
8650 printf("error: Cannot parse flexbytes input.\n");
8654 switch (entry.input.flow_type) {
8655 case RTE_ETH_FLOW_FRAG_IPV4:
8656 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8657 entry.input.flow.ip4_flow.proto = res->proto_value;
8658 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8659 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8660 IPV4_ADDR_TO_UINT(res->ip_dst,
8661 entry.input.flow.ip4_flow.dst_ip);
8662 IPV4_ADDR_TO_UINT(res->ip_src,
8663 entry.input.flow.ip4_flow.src_ip);
8664 entry.input.flow.ip4_flow.tos = res->tos_value;
8665 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8666 /* need convert to big endian. */
8667 entry.input.flow.udp4_flow.dst_port =
8668 rte_cpu_to_be_16(res->port_dst);
8669 entry.input.flow.udp4_flow.src_port =
8670 rte_cpu_to_be_16(res->port_src);
8672 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8673 IPV4_ADDR_TO_UINT(res->ip_dst,
8674 entry.input.flow.sctp4_flow.ip.dst_ip);
8675 IPV4_ADDR_TO_UINT(res->ip_src,
8676 entry.input.flow.sctp4_flow.ip.src_ip);
8677 entry.input.flow.ip4_flow.tos = res->tos_value;
8678 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8679 /* need convert to big endian. */
8680 entry.input.flow.sctp4_flow.dst_port =
8681 rte_cpu_to_be_16(res->port_dst);
8682 entry.input.flow.sctp4_flow.src_port =
8683 rte_cpu_to_be_16(res->port_src);
8684 entry.input.flow.sctp4_flow.verify_tag =
8685 rte_cpu_to_be_32(res->verify_tag_value);
8687 case RTE_ETH_FLOW_FRAG_IPV6:
8688 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8689 entry.input.flow.ipv6_flow.proto = res->proto_value;
8690 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8691 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8692 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8693 entry.input.flow.ipv6_flow.dst_ip);
8694 IPV6_ADDR_TO_ARRAY(res->ip_src,
8695 entry.input.flow.ipv6_flow.src_ip);
8696 entry.input.flow.ipv6_flow.tc = res->tos_value;
8697 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8698 /* need convert to big endian. */
8699 entry.input.flow.udp6_flow.dst_port =
8700 rte_cpu_to_be_16(res->port_dst);
8701 entry.input.flow.udp6_flow.src_port =
8702 rte_cpu_to_be_16(res->port_src);
8704 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8705 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8706 entry.input.flow.sctp6_flow.ip.dst_ip);
8707 IPV6_ADDR_TO_ARRAY(res->ip_src,
8708 entry.input.flow.sctp6_flow.ip.src_ip);
8709 entry.input.flow.ipv6_flow.tc = res->tos_value;
8710 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8711 /* need convert to big endian. */
8712 entry.input.flow.sctp6_flow.dst_port =
8713 rte_cpu_to_be_16(res->port_dst);
8714 entry.input.flow.sctp6_flow.src_port =
8715 rte_cpu_to_be_16(res->port_src);
8716 entry.input.flow.sctp6_flow.verify_tag =
8717 rte_cpu_to_be_32(res->verify_tag_value);
8719 case RTE_ETH_FLOW_L2_PAYLOAD:
8720 entry.input.flow.l2_flow.ether_type =
8721 rte_cpu_to_be_16(res->ether_type);
8727 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8728 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8730 sizeof(struct ether_addr));
8732 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8733 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8735 sizeof(struct ether_addr));
8736 entry.input.flow.tunnel_flow.tunnel_type =
8737 str2fdir_tunneltype(res->tunnel_type);
8738 entry.input.flow.tunnel_flow.tunnel_id =
8739 rte_cpu_to_be_32(res->tunnel_id_value);
8742 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8744 RTE_ETH_FDIR_MAX_FLEXLEN);
8746 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8748 entry.action.flex_off = 0; /*use 0 by default */
8749 if (!strcmp(res->drop, "drop"))
8750 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8752 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8754 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8755 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8756 if (!strcmp(res->pf_vf, "pf"))
8757 entry.input.flow_ext.is_vf = 0;
8758 else if (!strncmp(res->pf_vf, "vf", 2)) {
8759 struct rte_eth_dev_info dev_info;
8761 memset(&dev_info, 0, sizeof(dev_info));
8762 rte_eth_dev_info_get(res->port_id, &dev_info);
8764 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8765 if (errno != 0 || *end != '\0' ||
8766 vf_id >= dev_info.max_vfs) {
8767 printf("invalid parameter %s.\n", res->pf_vf);
8770 entry.input.flow_ext.is_vf = 1;
8771 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8773 printf("invalid parameter %s.\n", res->pf_vf);
8778 /* set to report FD ID by default */
8779 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8780 entry.action.rx_queue = res->queue_id;
8781 entry.soft_id = res->fd_id_value;
8782 if (!strcmp(res->ops, "add"))
8783 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8784 RTE_ETH_FILTER_ADD, &entry);
8785 else if (!strcmp(res->ops, "del"))
8786 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8787 RTE_ETH_FILTER_DELETE, &entry);
8789 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8790 RTE_ETH_FILTER_UPDATE, &entry);
8792 printf("flow director programming error: (%s)\n",
8796 cmdline_parse_token_string_t cmd_flow_director_filter =
8797 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8798 flow_director_filter, "flow_director_filter");
8799 cmdline_parse_token_num_t cmd_flow_director_port_id =
8800 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8802 cmdline_parse_token_string_t cmd_flow_director_ops =
8803 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8804 ops, "add#del#update");
8805 cmdline_parse_token_string_t cmd_flow_director_flow =
8806 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8808 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8809 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8810 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8811 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8812 cmdline_parse_token_string_t cmd_flow_director_ether =
8813 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8815 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8816 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8817 ether_type, UINT16);
8818 cmdline_parse_token_string_t cmd_flow_director_src =
8819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8821 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8822 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8824 cmdline_parse_token_num_t cmd_flow_director_port_src =
8825 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8827 cmdline_parse_token_string_t cmd_flow_director_dst =
8828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8830 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8831 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8833 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8834 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8836 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8838 verify_tag, "verify_tag");
8839 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8840 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8841 verify_tag_value, UINT32);
8842 cmdline_parse_token_string_t cmd_flow_director_tos =
8843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8845 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8846 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8848 cmdline_parse_token_string_t cmd_flow_director_proto =
8849 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8851 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8852 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8853 proto_value, UINT8);
8854 cmdline_parse_token_string_t cmd_flow_director_ttl =
8855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8857 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8858 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8860 cmdline_parse_token_string_t cmd_flow_director_vlan =
8861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8863 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8864 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8865 vlan_value, UINT16);
8866 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8868 flexbytes, "flexbytes");
8869 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8871 flexbytes_value, NULL);
8872 cmdline_parse_token_string_t cmd_flow_director_drop =
8873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8875 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8878 cmdline_parse_token_string_t cmd_flow_director_queue =
8879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8881 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8882 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8884 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8887 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8888 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8889 fd_id_value, UINT32);
8891 cmdline_parse_token_string_t cmd_flow_director_mode =
8892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8894 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8897 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8899 mode_value, "MAC-VLAN");
8900 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8902 mode_value, "Tunnel");
8903 cmdline_parse_token_string_t cmd_flow_director_mac =
8904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8906 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8907 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8909 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8912 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8914 tunnel_type, "NVGRE#VxLAN");
8915 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8917 tunnel_id, "tunnel-id");
8918 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8919 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8920 tunnel_id_value, UINT32);
8922 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8923 .f = cmd_flow_director_filter_parsed,
8925 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8926 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8927 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8928 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8929 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8930 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8931 "fd_id <fd_id_value>: "
8932 "Add or delete an ip flow director entry on NIC",
8934 (void *)&cmd_flow_director_filter,
8935 (void *)&cmd_flow_director_port_id,
8936 (void *)&cmd_flow_director_mode,
8937 (void *)&cmd_flow_director_mode_ip,
8938 (void *)&cmd_flow_director_ops,
8939 (void *)&cmd_flow_director_flow,
8940 (void *)&cmd_flow_director_flow_type,
8941 (void *)&cmd_flow_director_src,
8942 (void *)&cmd_flow_director_ip_src,
8943 (void *)&cmd_flow_director_dst,
8944 (void *)&cmd_flow_director_ip_dst,
8945 (void *)&cmd_flow_director_tos,
8946 (void *)&cmd_flow_director_tos_value,
8947 (void *)&cmd_flow_director_proto,
8948 (void *)&cmd_flow_director_proto_value,
8949 (void *)&cmd_flow_director_ttl,
8950 (void *)&cmd_flow_director_ttl_value,
8951 (void *)&cmd_flow_director_vlan,
8952 (void *)&cmd_flow_director_vlan_value,
8953 (void *)&cmd_flow_director_flexbytes,
8954 (void *)&cmd_flow_director_flexbytes_value,
8955 (void *)&cmd_flow_director_drop,
8956 (void *)&cmd_flow_director_pf_vf,
8957 (void *)&cmd_flow_director_queue,
8958 (void *)&cmd_flow_director_queue_id,
8959 (void *)&cmd_flow_director_fd_id,
8960 (void *)&cmd_flow_director_fd_id_value,
8965 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8966 .f = cmd_flow_director_filter_parsed,
8968 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8969 "director entry on NIC",
8971 (void *)&cmd_flow_director_filter,
8972 (void *)&cmd_flow_director_port_id,
8973 (void *)&cmd_flow_director_mode,
8974 (void *)&cmd_flow_director_mode_ip,
8975 (void *)&cmd_flow_director_ops,
8976 (void *)&cmd_flow_director_flow,
8977 (void *)&cmd_flow_director_flow_type,
8978 (void *)&cmd_flow_director_src,
8979 (void *)&cmd_flow_director_ip_src,
8980 (void *)&cmd_flow_director_port_src,
8981 (void *)&cmd_flow_director_dst,
8982 (void *)&cmd_flow_director_ip_dst,
8983 (void *)&cmd_flow_director_port_dst,
8984 (void *)&cmd_flow_director_tos,
8985 (void *)&cmd_flow_director_tos_value,
8986 (void *)&cmd_flow_director_ttl,
8987 (void *)&cmd_flow_director_ttl_value,
8988 (void *)&cmd_flow_director_vlan,
8989 (void *)&cmd_flow_director_vlan_value,
8990 (void *)&cmd_flow_director_flexbytes,
8991 (void *)&cmd_flow_director_flexbytes_value,
8992 (void *)&cmd_flow_director_drop,
8993 (void *)&cmd_flow_director_pf_vf,
8994 (void *)&cmd_flow_director_queue,
8995 (void *)&cmd_flow_director_queue_id,
8996 (void *)&cmd_flow_director_fd_id,
8997 (void *)&cmd_flow_director_fd_id_value,
9002 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9003 .f = cmd_flow_director_filter_parsed,
9005 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9006 "director entry on NIC",
9008 (void *)&cmd_flow_director_filter,
9009 (void *)&cmd_flow_director_port_id,
9010 (void *)&cmd_flow_director_mode,
9011 (void *)&cmd_flow_director_mode_ip,
9012 (void *)&cmd_flow_director_ops,
9013 (void *)&cmd_flow_director_flow,
9014 (void *)&cmd_flow_director_flow_type,
9015 (void *)&cmd_flow_director_src,
9016 (void *)&cmd_flow_director_ip_src,
9017 (void *)&cmd_flow_director_port_dst,
9018 (void *)&cmd_flow_director_dst,
9019 (void *)&cmd_flow_director_ip_dst,
9020 (void *)&cmd_flow_director_port_dst,
9021 (void *)&cmd_flow_director_verify_tag,
9022 (void *)&cmd_flow_director_verify_tag_value,
9023 (void *)&cmd_flow_director_tos,
9024 (void *)&cmd_flow_director_tos_value,
9025 (void *)&cmd_flow_director_ttl,
9026 (void *)&cmd_flow_director_ttl_value,
9027 (void *)&cmd_flow_director_vlan,
9028 (void *)&cmd_flow_director_vlan_value,
9029 (void *)&cmd_flow_director_flexbytes,
9030 (void *)&cmd_flow_director_flexbytes_value,
9031 (void *)&cmd_flow_director_drop,
9032 (void *)&cmd_flow_director_pf_vf,
9033 (void *)&cmd_flow_director_queue,
9034 (void *)&cmd_flow_director_queue_id,
9035 (void *)&cmd_flow_director_fd_id,
9036 (void *)&cmd_flow_director_fd_id_value,
9041 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9042 .f = cmd_flow_director_filter_parsed,
9044 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9045 "director entry on NIC",
9047 (void *)&cmd_flow_director_filter,
9048 (void *)&cmd_flow_director_port_id,
9049 (void *)&cmd_flow_director_mode,
9050 (void *)&cmd_flow_director_mode_ip,
9051 (void *)&cmd_flow_director_ops,
9052 (void *)&cmd_flow_director_flow,
9053 (void *)&cmd_flow_director_flow_type,
9054 (void *)&cmd_flow_director_ether,
9055 (void *)&cmd_flow_director_ether_type,
9056 (void *)&cmd_flow_director_flexbytes,
9057 (void *)&cmd_flow_director_flexbytes_value,
9058 (void *)&cmd_flow_director_drop,
9059 (void *)&cmd_flow_director_pf_vf,
9060 (void *)&cmd_flow_director_queue,
9061 (void *)&cmd_flow_director_queue_id,
9062 (void *)&cmd_flow_director_fd_id,
9063 (void *)&cmd_flow_director_fd_id_value,
9068 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9069 .f = cmd_flow_director_filter_parsed,
9071 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9072 "director entry on NIC",
9074 (void *)&cmd_flow_director_filter,
9075 (void *)&cmd_flow_director_port_id,
9076 (void *)&cmd_flow_director_mode,
9077 (void *)&cmd_flow_director_mode_mac_vlan,
9078 (void *)&cmd_flow_director_ops,
9079 (void *)&cmd_flow_director_mac,
9080 (void *)&cmd_flow_director_mac_addr,
9081 (void *)&cmd_flow_director_vlan,
9082 (void *)&cmd_flow_director_vlan_value,
9083 (void *)&cmd_flow_director_flexbytes,
9084 (void *)&cmd_flow_director_flexbytes_value,
9085 (void *)&cmd_flow_director_drop,
9086 (void *)&cmd_flow_director_queue,
9087 (void *)&cmd_flow_director_queue_id,
9088 (void *)&cmd_flow_director_fd_id,
9089 (void *)&cmd_flow_director_fd_id_value,
9094 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9095 .f = cmd_flow_director_filter_parsed,
9097 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9098 "director entry on NIC",
9100 (void *)&cmd_flow_director_filter,
9101 (void *)&cmd_flow_director_port_id,
9102 (void *)&cmd_flow_director_mode,
9103 (void *)&cmd_flow_director_mode_tunnel,
9104 (void *)&cmd_flow_director_ops,
9105 (void *)&cmd_flow_director_mac,
9106 (void *)&cmd_flow_director_mac_addr,
9107 (void *)&cmd_flow_director_vlan,
9108 (void *)&cmd_flow_director_vlan_value,
9109 (void *)&cmd_flow_director_tunnel,
9110 (void *)&cmd_flow_director_tunnel_type,
9111 (void *)&cmd_flow_director_tunnel_id,
9112 (void *)&cmd_flow_director_tunnel_id_value,
9113 (void *)&cmd_flow_director_flexbytes,
9114 (void *)&cmd_flow_director_flexbytes_value,
9115 (void *)&cmd_flow_director_drop,
9116 (void *)&cmd_flow_director_queue,
9117 (void *)&cmd_flow_director_queue_id,
9118 (void *)&cmd_flow_director_fd_id,
9119 (void *)&cmd_flow_director_fd_id_value,
9124 struct cmd_flush_flow_director_result {
9125 cmdline_fixed_string_t flush_flow_director;
9129 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9130 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9131 flush_flow_director, "flush_flow_director");
9132 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9133 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9137 cmd_flush_flow_director_parsed(void *parsed_result,
9138 __attribute__((unused)) struct cmdline *cl,
9139 __attribute__((unused)) void *data)
9141 struct cmd_flow_director_result *res = parsed_result;
9144 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9146 printf("flow director is not supported on port %u.\n",
9151 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9152 RTE_ETH_FILTER_FLUSH, NULL);
9154 printf("flow director table flushing error: (%s)\n",
9158 cmdline_parse_inst_t cmd_flush_flow_director = {
9159 .f = cmd_flush_flow_director_parsed,
9161 .help_str = "flush_flow_director <port_id>: "
9162 "Flush all flow director entries of a device on NIC",
9164 (void *)&cmd_flush_flow_director_flush,
9165 (void *)&cmd_flush_flow_director_port_id,
9170 /* *** deal with flow director mask *** */
9171 struct cmd_flow_director_mask_result {
9172 cmdline_fixed_string_t flow_director_mask;
9174 cmdline_fixed_string_t mode;
9175 cmdline_fixed_string_t mode_value;
9176 cmdline_fixed_string_t vlan;
9178 cmdline_fixed_string_t src_mask;
9179 cmdline_ipaddr_t ipv4_src;
9180 cmdline_ipaddr_t ipv6_src;
9182 cmdline_fixed_string_t dst_mask;
9183 cmdline_ipaddr_t ipv4_dst;
9184 cmdline_ipaddr_t ipv6_dst;
9186 cmdline_fixed_string_t mac;
9187 uint8_t mac_addr_byte_mask;
9188 cmdline_fixed_string_t tunnel_id;
9189 uint32_t tunnel_id_mask;
9190 cmdline_fixed_string_t tunnel_type;
9191 uint8_t tunnel_type_mask;
9195 cmd_flow_director_mask_parsed(void *parsed_result,
9196 __attribute__((unused)) struct cmdline *cl,
9197 __attribute__((unused)) void *data)
9199 struct cmd_flow_director_mask_result *res = parsed_result;
9200 struct rte_eth_fdir_masks *mask;
9201 struct rte_port *port;
9203 if (res->port_id > nb_ports) {
9204 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9208 port = &ports[res->port_id];
9209 /** Check if the port is not started **/
9210 if (port->port_status != RTE_PORT_STOPPED) {
9211 printf("Please stop port %d first\n", res->port_id);
9215 mask = &port->dev_conf.fdir_conf.mask;
9217 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9218 if (strcmp(res->mode_value, "MAC-VLAN")) {
9219 printf("Please set mode to MAC-VLAN.\n");
9223 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9224 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9225 if (strcmp(res->mode_value, "Tunnel")) {
9226 printf("Please set mode to Tunnel.\n");
9230 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9231 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9232 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9233 mask->tunnel_type_mask = res->tunnel_type_mask;
9235 if (strcmp(res->mode_value, "IP")) {
9236 printf("Please set mode to IP.\n");
9240 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9241 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9242 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9243 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9244 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9245 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9246 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9249 cmd_reconfig_device_queue(res->port_id, 1, 1);
9252 cmdline_parse_token_string_t cmd_flow_director_mask =
9253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9254 flow_director_mask, "flow_director_mask");
9255 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9256 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9258 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9261 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9262 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9264 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9266 src_mask, "src_mask");
9267 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9268 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9270 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9271 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9273 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9274 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9276 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9278 dst_mask, "dst_mask");
9279 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9280 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9282 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9283 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9285 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9286 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9289 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9290 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9292 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9295 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9297 mode_value, "MAC-VLAN");
9298 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9299 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9300 mode_value, "Tunnel");
9301 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9304 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9305 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9306 mac_addr_byte_mask, UINT8);
9307 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9308 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9309 tunnel_type, "tunnel-type");
9310 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9311 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9312 tunnel_type_mask, UINT8);
9313 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9314 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9315 tunnel_id, "tunnel-id");
9316 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9317 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9318 tunnel_id_mask, UINT32);
9320 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9321 .f = cmd_flow_director_mask_parsed,
9323 .help_str = "flow_director_mask ... : "
9324 "Set IP mode flow director's mask on NIC",
9326 (void *)&cmd_flow_director_mask,
9327 (void *)&cmd_flow_director_mask_port_id,
9328 (void *)&cmd_flow_director_mask_mode,
9329 (void *)&cmd_flow_director_mask_mode_ip,
9330 (void *)&cmd_flow_director_mask_vlan,
9331 (void *)&cmd_flow_director_mask_vlan_value,
9332 (void *)&cmd_flow_director_mask_src,
9333 (void *)&cmd_flow_director_mask_ipv4_src,
9334 (void *)&cmd_flow_director_mask_ipv6_src,
9335 (void *)&cmd_flow_director_mask_port_src,
9336 (void *)&cmd_flow_director_mask_dst,
9337 (void *)&cmd_flow_director_mask_ipv4_dst,
9338 (void *)&cmd_flow_director_mask_ipv6_dst,
9339 (void *)&cmd_flow_director_mask_port_dst,
9344 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9345 .f = cmd_flow_director_mask_parsed,
9347 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9348 "flow director's mask on NIC",
9350 (void *)&cmd_flow_director_mask,
9351 (void *)&cmd_flow_director_mask_port_id,
9352 (void *)&cmd_flow_director_mask_mode,
9353 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9354 (void *)&cmd_flow_director_mask_vlan,
9355 (void *)&cmd_flow_director_mask_vlan_value,
9360 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9361 .f = cmd_flow_director_mask_parsed,
9363 .help_str = "flow_director_mask ... : Set tunnel mode "
9364 "flow director's mask on NIC",
9366 (void *)&cmd_flow_director_mask,
9367 (void *)&cmd_flow_director_mask_port_id,
9368 (void *)&cmd_flow_director_mask_mode,
9369 (void *)&cmd_flow_director_mask_mode_tunnel,
9370 (void *)&cmd_flow_director_mask_vlan,
9371 (void *)&cmd_flow_director_mask_vlan_value,
9372 (void *)&cmd_flow_director_mask_mac,
9373 (void *)&cmd_flow_director_mask_mac_value,
9374 (void *)&cmd_flow_director_mask_tunnel_type,
9375 (void *)&cmd_flow_director_mask_tunnel_type_value,
9376 (void *)&cmd_flow_director_mask_tunnel_id,
9377 (void *)&cmd_flow_director_mask_tunnel_id_value,
9382 /* *** deal with flow director mask on flexible payload *** */
9383 struct cmd_flow_director_flex_mask_result {
9384 cmdline_fixed_string_t flow_director_flexmask;
9386 cmdline_fixed_string_t flow;
9387 cmdline_fixed_string_t flow_type;
9388 cmdline_fixed_string_t mask;
9392 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9393 __attribute__((unused)) struct cmdline *cl,
9394 __attribute__((unused)) void *data)
9396 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9397 struct rte_eth_fdir_info fdir_info;
9398 struct rte_eth_fdir_flex_mask flex_mask;
9399 struct rte_port *port;
9400 uint32_t flow_type_mask;
9404 if (res->port_id > nb_ports) {
9405 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9409 port = &ports[res->port_id];
9410 /** Check if the port is not started **/
9411 if (port->port_status != RTE_PORT_STOPPED) {
9412 printf("Please stop port %d first\n", res->port_id);
9416 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9417 ret = parse_flexbytes(res->mask,
9419 RTE_ETH_FDIR_MAX_FLEXLEN);
9421 printf("error: Cannot parse mask input.\n");
9425 memset(&fdir_info, 0, sizeof(fdir_info));
9426 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9427 RTE_ETH_FILTER_INFO, &fdir_info);
9429 printf("Cannot get FDir filter info\n");
9433 if (!strcmp(res->flow_type, "none")) {
9434 /* means don't specify the flow type */
9435 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9436 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9437 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9438 0, sizeof(struct rte_eth_fdir_flex_mask));
9439 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9440 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9442 sizeof(struct rte_eth_fdir_flex_mask));
9443 cmd_reconfig_device_queue(res->port_id, 1, 1);
9446 flow_type_mask = fdir_info.flow_types_mask[0];
9447 if (!strcmp(res->flow_type, "all")) {
9448 if (!flow_type_mask) {
9449 printf("No flow type supported\n");
9452 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9453 if (flow_type_mask & (1 << i)) {
9454 flex_mask.flow_type = i;
9455 fdir_set_flex_mask(res->port_id, &flex_mask);
9458 cmd_reconfig_device_queue(res->port_id, 1, 1);
9461 flex_mask.flow_type = str2flowtype(res->flow_type);
9462 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9463 printf("Flow type %s not supported on port %d\n",
9464 res->flow_type, res->port_id);
9467 fdir_set_flex_mask(res->port_id, &flex_mask);
9468 cmd_reconfig_device_queue(res->port_id, 1, 1);
9471 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9472 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9473 flow_director_flexmask,
9474 "flow_director_flex_mask");
9475 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9476 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9478 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9479 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9481 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9482 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9483 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9484 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9485 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9486 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9489 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9490 .f = cmd_flow_director_flex_mask_parsed,
9492 .help_str = "flow_director_flex_mask ... : "
9493 "Set flow director's flex mask on NIC",
9495 (void *)&cmd_flow_director_flexmask,
9496 (void *)&cmd_flow_director_flexmask_port_id,
9497 (void *)&cmd_flow_director_flexmask_flow,
9498 (void *)&cmd_flow_director_flexmask_flow_type,
9499 (void *)&cmd_flow_director_flexmask_mask,
9504 /* *** deal with flow director flexible payload configuration *** */
9505 struct cmd_flow_director_flexpayload_result {
9506 cmdline_fixed_string_t flow_director_flexpayload;
9508 cmdline_fixed_string_t payload_layer;
9509 cmdline_fixed_string_t payload_cfg;
9513 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9516 const char *p, *p0 = q_arg;
9518 unsigned long int_fld;
9519 char *str_fld[max_num];
9524 p = strchr(p0, '(');
9528 p0 = strchr(p, ')');
9533 if (size >= sizeof(s))
9536 snprintf(s, sizeof(s), "%.*s", size, p);
9537 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9538 if (ret < 0 || ret > max_num)
9540 for (i = 0; i < ret; i++) {
9542 int_fld = strtoul(str_fld[i], &end, 0);
9543 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9545 offsets[i] = (uint16_t)int_fld;
9551 cmd_flow_director_flxpld_parsed(void *parsed_result,
9552 __attribute__((unused)) struct cmdline *cl,
9553 __attribute__((unused)) void *data)
9555 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9556 struct rte_eth_flex_payload_cfg flex_cfg;
9557 struct rte_port *port;
9560 if (res->port_id > nb_ports) {
9561 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9565 port = &ports[res->port_id];
9566 /** Check if the port is not started **/
9567 if (port->port_status != RTE_PORT_STOPPED) {
9568 printf("Please stop port %d first\n", res->port_id);
9572 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9574 if (!strcmp(res->payload_layer, "raw"))
9575 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9576 else if (!strcmp(res->payload_layer, "l2"))
9577 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9578 else if (!strcmp(res->payload_layer, "l3"))
9579 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9580 else if (!strcmp(res->payload_layer, "l4"))
9581 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9583 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9584 RTE_ETH_FDIR_MAX_FLEXLEN);
9586 printf("error: Cannot parse flex payload input.\n");
9590 fdir_set_flex_payload(res->port_id, &flex_cfg);
9591 cmd_reconfig_device_queue(res->port_id, 1, 1);
9594 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9595 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9596 flow_director_flexpayload,
9597 "flow_director_flex_payload");
9598 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9599 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9601 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9603 payload_layer, "raw#l2#l3#l4");
9604 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9608 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9609 .f = cmd_flow_director_flxpld_parsed,
9611 .help_str = "flow_director_flexpayload ... : "
9612 "Set flow director's flex payload on NIC",
9614 (void *)&cmd_flow_director_flexpayload,
9615 (void *)&cmd_flow_director_flexpayload_port_id,
9616 (void *)&cmd_flow_director_flexpayload_payload_layer,
9617 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9622 /* Generic flow interface command. */
9623 extern cmdline_parse_inst_t cmd_flow;
9625 /* *** Classification Filters Control *** */
9626 /* *** Get symmetric hash enable per port *** */
9627 struct cmd_get_sym_hash_ena_per_port_result {
9628 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9633 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9634 __rte_unused struct cmdline *cl,
9635 __rte_unused void *data)
9637 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9638 struct rte_eth_hash_filter_info info;
9641 if (rte_eth_dev_filter_supported(res->port_id,
9642 RTE_ETH_FILTER_HASH) < 0) {
9643 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9648 memset(&info, 0, sizeof(info));
9649 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9650 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9651 RTE_ETH_FILTER_GET, &info);
9654 printf("Cannot get symmetric hash enable per port "
9655 "on port %u\n", res->port_id);
9659 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9660 "enabled" : "disabled", res->port_id);
9663 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9664 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9665 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9666 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9667 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9670 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9671 .f = cmd_get_sym_hash_per_port_parsed,
9673 .help_str = "get_sym_hash_ena_per_port <port_id>",
9675 (void *)&cmd_get_sym_hash_ena_per_port_all,
9676 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9681 /* *** Set symmetric hash enable per port *** */
9682 struct cmd_set_sym_hash_ena_per_port_result {
9683 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9684 cmdline_fixed_string_t enable;
9689 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9690 __rte_unused struct cmdline *cl,
9691 __rte_unused void *data)
9693 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9694 struct rte_eth_hash_filter_info info;
9697 if (rte_eth_dev_filter_supported(res->port_id,
9698 RTE_ETH_FILTER_HASH) < 0) {
9699 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9704 memset(&info, 0, sizeof(info));
9705 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9706 if (!strcmp(res->enable, "enable"))
9707 info.info.enable = 1;
9708 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9709 RTE_ETH_FILTER_SET, &info);
9711 printf("Cannot set symmetric hash enable per port on "
9712 "port %u\n", res->port_id);
9715 printf("Symmetric hash has been set to %s on port %u\n",
9716 res->enable, res->port_id);
9719 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9720 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9721 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9722 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9723 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9725 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9726 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9727 enable, "enable#disable");
9729 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9730 .f = cmd_set_sym_hash_per_port_parsed,
9732 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9734 (void *)&cmd_set_sym_hash_ena_per_port_all,
9735 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9736 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9741 /* Get global config of hash function */
9742 struct cmd_get_hash_global_config_result {
9743 cmdline_fixed_string_t get_hash_global_config;
9748 flowtype_to_str(uint16_t ftype)
9755 {"ipv4", RTE_ETH_FLOW_IPV4},
9756 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9757 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9758 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9759 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9760 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9761 {"ipv6", RTE_ETH_FLOW_IPV6},
9762 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9763 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9764 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9765 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9766 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9767 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9768 {"port", RTE_ETH_FLOW_PORT},
9769 {"vxlan", RTE_ETH_FLOW_VXLAN},
9770 {"geneve", RTE_ETH_FLOW_GENEVE},
9771 {"nvgre", RTE_ETH_FLOW_NVGRE},
9774 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9775 if (ftype_table[i].ftype == ftype)
9776 return ftype_table[i].str;
9783 cmd_get_hash_global_config_parsed(void *parsed_result,
9784 __rte_unused struct cmdline *cl,
9785 __rte_unused void *data)
9787 struct cmd_get_hash_global_config_result *res = parsed_result;
9788 struct rte_eth_hash_filter_info info;
9789 uint32_t idx, offset;
9794 if (rte_eth_dev_filter_supported(res->port_id,
9795 RTE_ETH_FILTER_HASH) < 0) {
9796 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9801 memset(&info, 0, sizeof(info));
9802 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9803 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9804 RTE_ETH_FILTER_GET, &info);
9806 printf("Cannot get hash global configurations by port %d\n",
9811 switch (info.info.global_conf.hash_func) {
9812 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9813 printf("Hash function is Toeplitz\n");
9815 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9816 printf("Hash function is Simple XOR\n");
9819 printf("Unknown hash function\n");
9823 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9824 idx = i / UINT32_BIT;
9825 offset = i % UINT32_BIT;
9826 if (!(info.info.global_conf.valid_bit_mask[idx] &
9829 str = flowtype_to_str(i);
9832 printf("Symmetric hash is %s globally for flow type %s "
9834 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9835 (1UL << offset)) ? "enabled" : "disabled"), str,
9840 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9841 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9842 get_hash_global_config, "get_hash_global_config");
9843 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9844 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9847 cmdline_parse_inst_t cmd_get_hash_global_config = {
9848 .f = cmd_get_hash_global_config_parsed,
9850 .help_str = "get_hash_global_config <port_id>",
9852 (void *)&cmd_get_hash_global_config_all,
9853 (void *)&cmd_get_hash_global_config_port_id,
9858 /* Set global config of hash function */
9859 struct cmd_set_hash_global_config_result {
9860 cmdline_fixed_string_t set_hash_global_config;
9862 cmdline_fixed_string_t hash_func;
9863 cmdline_fixed_string_t flow_type;
9864 cmdline_fixed_string_t enable;
9868 cmd_set_hash_global_config_parsed(void *parsed_result,
9869 __rte_unused struct cmdline *cl,
9870 __rte_unused void *data)
9872 struct cmd_set_hash_global_config_result *res = parsed_result;
9873 struct rte_eth_hash_filter_info info;
9874 uint32_t ftype, idx, offset;
9877 if (rte_eth_dev_filter_supported(res->port_id,
9878 RTE_ETH_FILTER_HASH) < 0) {
9879 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9883 memset(&info, 0, sizeof(info));
9884 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9885 if (!strcmp(res->hash_func, "toeplitz"))
9886 info.info.global_conf.hash_func =
9887 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9888 else if (!strcmp(res->hash_func, "simple_xor"))
9889 info.info.global_conf.hash_func =
9890 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9891 else if (!strcmp(res->hash_func, "default"))
9892 info.info.global_conf.hash_func =
9893 RTE_ETH_HASH_FUNCTION_DEFAULT;
9895 ftype = str2flowtype(res->flow_type);
9896 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9897 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9898 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9899 if (!strcmp(res->enable, "enable"))
9900 info.info.global_conf.sym_hash_enable_mask[idx] |=
9902 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9903 RTE_ETH_FILTER_SET, &info);
9905 printf("Cannot set global hash configurations by port %d\n",
9908 printf("Global hash configurations have been set "
9909 "succcessfully by port %d\n", res->port_id);
9912 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9913 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9914 set_hash_global_config, "set_hash_global_config");
9915 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9916 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9918 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9919 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9920 hash_func, "toeplitz#simple_xor#default");
9921 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9922 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9924 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9925 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9926 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9927 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9928 enable, "enable#disable");
9930 cmdline_parse_inst_t cmd_set_hash_global_config = {
9931 .f = cmd_set_hash_global_config_parsed,
9933 .help_str = "set_hash_global_config <port_id> "
9934 "toeplitz|simple_xor|default "
9935 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9936 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9937 "l2_payload enable|disable",
9939 (void *)&cmd_set_hash_global_config_all,
9940 (void *)&cmd_set_hash_global_config_port_id,
9941 (void *)&cmd_set_hash_global_config_hash_func,
9942 (void *)&cmd_set_hash_global_config_flow_type,
9943 (void *)&cmd_set_hash_global_config_enable,
9948 /* Set hash input set */
9949 struct cmd_set_hash_input_set_result {
9950 cmdline_fixed_string_t set_hash_input_set;
9952 cmdline_fixed_string_t flow_type;
9953 cmdline_fixed_string_t inset_field;
9954 cmdline_fixed_string_t select;
9957 static enum rte_eth_input_set_field
9958 str2inset(char *string)
9962 static const struct {
9964 enum rte_eth_input_set_field inset;
9966 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9967 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9968 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9969 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9970 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9971 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9972 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9973 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9974 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9975 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9976 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9977 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9978 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9979 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9980 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9981 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9982 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9983 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9984 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9985 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9986 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9987 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9988 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9989 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9990 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9991 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9992 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9993 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9994 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9995 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9996 {"none", RTE_ETH_INPUT_SET_NONE},
9999 for (i = 0; i < RTE_DIM(inset_table); i++) {
10000 if (!strcmp(string, inset_table[i].str))
10001 return inset_table[i].inset;
10004 return RTE_ETH_INPUT_SET_UNKNOWN;
10008 cmd_set_hash_input_set_parsed(void *parsed_result,
10009 __rte_unused struct cmdline *cl,
10010 __rte_unused void *data)
10012 struct cmd_set_hash_input_set_result *res = parsed_result;
10013 struct rte_eth_hash_filter_info info;
10015 memset(&info, 0, sizeof(info));
10016 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10017 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10018 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10019 info.info.input_set_conf.inset_size = 1;
10020 if (!strcmp(res->select, "select"))
10021 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10022 else if (!strcmp(res->select, "add"))
10023 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10024 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10025 RTE_ETH_FILTER_SET, &info);
10028 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10029 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10030 set_hash_input_set, "set_hash_input_set");
10031 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10032 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10034 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10035 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10037 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10038 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10039 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10040 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10042 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10043 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10044 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10045 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10046 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10048 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10049 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10050 select, "select#add");
10052 cmdline_parse_inst_t cmd_set_hash_input_set = {
10053 .f = cmd_set_hash_input_set_parsed,
10055 .help_str = "set_hash_input_set <port_id> "
10056 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10058 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10059 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10060 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10061 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10062 "fld-7th|fld-8th|none select|add",
10064 (void *)&cmd_set_hash_input_set_cmd,
10065 (void *)&cmd_set_hash_input_set_port_id,
10066 (void *)&cmd_set_hash_input_set_flow_type,
10067 (void *)&cmd_set_hash_input_set_field,
10068 (void *)&cmd_set_hash_input_set_select,
10073 /* Set flow director input set */
10074 struct cmd_set_fdir_input_set_result {
10075 cmdline_fixed_string_t set_fdir_input_set;
10077 cmdline_fixed_string_t flow_type;
10078 cmdline_fixed_string_t inset_field;
10079 cmdline_fixed_string_t select;
10083 cmd_set_fdir_input_set_parsed(void *parsed_result,
10084 __rte_unused struct cmdline *cl,
10085 __rte_unused void *data)
10087 struct cmd_set_fdir_input_set_result *res = parsed_result;
10088 struct rte_eth_fdir_filter_info info;
10090 memset(&info, 0, sizeof(info));
10091 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10092 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10093 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10094 info.info.input_set_conf.inset_size = 1;
10095 if (!strcmp(res->select, "select"))
10096 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10097 else if (!strcmp(res->select, "add"))
10098 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10099 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10100 RTE_ETH_FILTER_SET, &info);
10103 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10104 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10105 set_fdir_input_set, "set_fdir_input_set");
10106 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10107 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10109 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10110 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10112 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10113 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10114 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10115 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10117 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10118 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10119 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10120 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10121 "sctp-veri-tag#none");
10122 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10123 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10124 select, "select#add");
10126 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10127 .f = cmd_set_fdir_input_set_parsed,
10129 .help_str = "set_fdir_input_set <port_id> "
10130 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10131 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10132 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10133 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10134 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10135 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10136 "sctp-veri-tag|none select|add",
10138 (void *)&cmd_set_fdir_input_set_cmd,
10139 (void *)&cmd_set_fdir_input_set_port_id,
10140 (void *)&cmd_set_fdir_input_set_flow_type,
10141 (void *)&cmd_set_fdir_input_set_field,
10142 (void *)&cmd_set_fdir_input_set_select,
10147 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10148 struct cmd_mcast_addr_result {
10149 cmdline_fixed_string_t mcast_addr_cmd;
10150 cmdline_fixed_string_t what;
10152 struct ether_addr mc_addr;
10155 static void cmd_mcast_addr_parsed(void *parsed_result,
10156 __attribute__((unused)) struct cmdline *cl,
10157 __attribute__((unused)) void *data)
10159 struct cmd_mcast_addr_result *res = parsed_result;
10161 if (!is_multicast_ether_addr(&res->mc_addr)) {
10162 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10163 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10164 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10165 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10168 if (strcmp(res->what, "add") == 0)
10169 mcast_addr_add(res->port_num, &res->mc_addr);
10171 mcast_addr_remove(res->port_num, &res->mc_addr);
10174 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10175 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10176 mcast_addr_cmd, "mcast_addr");
10177 cmdline_parse_token_string_t cmd_mcast_addr_what =
10178 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10180 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10181 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10182 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10183 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10185 cmdline_parse_inst_t cmd_mcast_addr = {
10186 .f = cmd_mcast_addr_parsed,
10188 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10189 "Add/Remove multicast MAC address on port_id",
10191 (void *)&cmd_mcast_addr_cmd,
10192 (void *)&cmd_mcast_addr_what,
10193 (void *)&cmd_mcast_addr_portnum,
10194 (void *)&cmd_mcast_addr_addr,
10199 /* l2 tunnel config
10200 * only support E-tag now.
10203 /* Ether type config */
10204 struct cmd_config_l2_tunnel_eth_type_result {
10205 cmdline_fixed_string_t port;
10206 cmdline_fixed_string_t config;
10207 cmdline_fixed_string_t all;
10209 cmdline_fixed_string_t l2_tunnel;
10210 cmdline_fixed_string_t l2_tunnel_type;
10211 cmdline_fixed_string_t eth_type;
10212 uint16_t eth_type_val;
10215 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10216 TOKEN_STRING_INITIALIZER
10217 (struct cmd_config_l2_tunnel_eth_type_result,
10219 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10220 TOKEN_STRING_INITIALIZER
10221 (struct cmd_config_l2_tunnel_eth_type_result,
10223 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10224 TOKEN_STRING_INITIALIZER
10225 (struct cmd_config_l2_tunnel_eth_type_result,
10227 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10228 TOKEN_NUM_INITIALIZER
10229 (struct cmd_config_l2_tunnel_eth_type_result,
10231 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10232 TOKEN_STRING_INITIALIZER
10233 (struct cmd_config_l2_tunnel_eth_type_result,
10234 l2_tunnel, "l2-tunnel");
10235 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10236 TOKEN_STRING_INITIALIZER
10237 (struct cmd_config_l2_tunnel_eth_type_result,
10238 l2_tunnel_type, "E-tag");
10239 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10240 TOKEN_STRING_INITIALIZER
10241 (struct cmd_config_l2_tunnel_eth_type_result,
10242 eth_type, "ether-type");
10243 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10244 TOKEN_NUM_INITIALIZER
10245 (struct cmd_config_l2_tunnel_eth_type_result,
10246 eth_type_val, UINT16);
10248 static enum rte_eth_tunnel_type
10249 str2fdir_l2_tunnel_type(char *string)
10253 static const struct {
10255 enum rte_eth_tunnel_type type;
10256 } l2_tunnel_type_str[] = {
10257 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10260 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10261 if (!strcmp(l2_tunnel_type_str[i].str, string))
10262 return l2_tunnel_type_str[i].type;
10264 return RTE_TUNNEL_TYPE_NONE;
10267 /* ether type config for all ports */
10269 cmd_config_l2_tunnel_eth_type_all_parsed
10270 (void *parsed_result,
10271 __attribute__((unused)) struct cmdline *cl,
10272 __attribute__((unused)) void *data)
10274 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10275 struct rte_eth_l2_tunnel_conf entry;
10278 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10279 entry.ether_type = res->eth_type_val;
10281 FOREACH_PORT(pid, ports) {
10282 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10286 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10287 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10289 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10291 (void *)&cmd_config_l2_tunnel_eth_type_port,
10292 (void *)&cmd_config_l2_tunnel_eth_type_config,
10293 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10294 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10295 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10296 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10297 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10302 /* ether type config for a specific port */
10304 cmd_config_l2_tunnel_eth_type_specific_parsed(
10305 void *parsed_result,
10306 __attribute__((unused)) struct cmdline *cl,
10307 __attribute__((unused)) void *data)
10309 struct cmd_config_l2_tunnel_eth_type_result *res =
10311 struct rte_eth_l2_tunnel_conf entry;
10313 if (port_id_is_invalid(res->id, ENABLED_WARN))
10316 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10317 entry.ether_type = res->eth_type_val;
10319 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10322 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10323 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10325 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10327 (void *)&cmd_config_l2_tunnel_eth_type_port,
10328 (void *)&cmd_config_l2_tunnel_eth_type_config,
10329 (void *)&cmd_config_l2_tunnel_eth_type_id,
10330 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10331 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10332 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10333 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10338 /* Enable/disable l2 tunnel */
10339 struct cmd_config_l2_tunnel_en_dis_result {
10340 cmdline_fixed_string_t port;
10341 cmdline_fixed_string_t config;
10342 cmdline_fixed_string_t all;
10344 cmdline_fixed_string_t l2_tunnel;
10345 cmdline_fixed_string_t l2_tunnel_type;
10346 cmdline_fixed_string_t en_dis;
10349 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10350 TOKEN_STRING_INITIALIZER
10351 (struct cmd_config_l2_tunnel_en_dis_result,
10353 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10354 TOKEN_STRING_INITIALIZER
10355 (struct cmd_config_l2_tunnel_en_dis_result,
10357 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10358 TOKEN_STRING_INITIALIZER
10359 (struct cmd_config_l2_tunnel_en_dis_result,
10361 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10362 TOKEN_NUM_INITIALIZER
10363 (struct cmd_config_l2_tunnel_en_dis_result,
10365 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10366 TOKEN_STRING_INITIALIZER
10367 (struct cmd_config_l2_tunnel_en_dis_result,
10368 l2_tunnel, "l2-tunnel");
10369 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10370 TOKEN_STRING_INITIALIZER
10371 (struct cmd_config_l2_tunnel_en_dis_result,
10372 l2_tunnel_type, "E-tag");
10373 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10374 TOKEN_STRING_INITIALIZER
10375 (struct cmd_config_l2_tunnel_en_dis_result,
10376 en_dis, "enable#disable");
10378 /* enable/disable l2 tunnel for all ports */
10380 cmd_config_l2_tunnel_en_dis_all_parsed(
10381 void *parsed_result,
10382 __attribute__((unused)) struct cmdline *cl,
10383 __attribute__((unused)) void *data)
10385 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10386 struct rte_eth_l2_tunnel_conf entry;
10390 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10392 if (!strcmp("enable", res->en_dis))
10397 FOREACH_PORT(pid, ports) {
10398 rte_eth_dev_l2_tunnel_offload_set(pid,
10400 ETH_L2_TUNNEL_ENABLE_MASK,
10405 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10406 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10408 .help_str = "port config all l2-tunnel E-tag enable|disable",
10410 (void *)&cmd_config_l2_tunnel_en_dis_port,
10411 (void *)&cmd_config_l2_tunnel_en_dis_config,
10412 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10413 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10414 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10415 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10420 /* enable/disable l2 tunnel for a port */
10422 cmd_config_l2_tunnel_en_dis_specific_parsed(
10423 void *parsed_result,
10424 __attribute__((unused)) struct cmdline *cl,
10425 __attribute__((unused)) void *data)
10427 struct cmd_config_l2_tunnel_en_dis_result *res =
10429 struct rte_eth_l2_tunnel_conf entry;
10431 if (port_id_is_invalid(res->id, ENABLED_WARN))
10434 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10436 if (!strcmp("enable", res->en_dis))
10437 rte_eth_dev_l2_tunnel_offload_set(res->id,
10439 ETH_L2_TUNNEL_ENABLE_MASK,
10442 rte_eth_dev_l2_tunnel_offload_set(res->id,
10444 ETH_L2_TUNNEL_ENABLE_MASK,
10448 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10449 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10451 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10453 (void *)&cmd_config_l2_tunnel_en_dis_port,
10454 (void *)&cmd_config_l2_tunnel_en_dis_config,
10455 (void *)&cmd_config_l2_tunnel_en_dis_id,
10456 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10457 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10458 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10463 /* E-tag configuration */
10465 /* Common result structure for all E-tag configuration */
10466 struct cmd_config_e_tag_result {
10467 cmdline_fixed_string_t e_tag;
10468 cmdline_fixed_string_t set;
10469 cmdline_fixed_string_t insertion;
10470 cmdline_fixed_string_t stripping;
10471 cmdline_fixed_string_t forwarding;
10472 cmdline_fixed_string_t filter;
10473 cmdline_fixed_string_t add;
10474 cmdline_fixed_string_t del;
10475 cmdline_fixed_string_t on;
10476 cmdline_fixed_string_t off;
10477 cmdline_fixed_string_t on_off;
10478 cmdline_fixed_string_t port_tag_id;
10479 uint32_t port_tag_id_val;
10480 cmdline_fixed_string_t e_tag_id;
10481 uint16_t e_tag_id_val;
10482 cmdline_fixed_string_t dst_pool;
10483 uint8_t dst_pool_val;
10484 cmdline_fixed_string_t port;
10486 cmdline_fixed_string_t vf;
10490 /* Common CLI fields for all E-tag configuration */
10491 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10492 TOKEN_STRING_INITIALIZER
10493 (struct cmd_config_e_tag_result,
10495 cmdline_parse_token_string_t cmd_config_e_tag_set =
10496 TOKEN_STRING_INITIALIZER
10497 (struct cmd_config_e_tag_result,
10499 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10500 TOKEN_STRING_INITIALIZER
10501 (struct cmd_config_e_tag_result,
10502 insertion, "insertion");
10503 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10504 TOKEN_STRING_INITIALIZER
10505 (struct cmd_config_e_tag_result,
10506 stripping, "stripping");
10507 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10508 TOKEN_STRING_INITIALIZER
10509 (struct cmd_config_e_tag_result,
10510 forwarding, "forwarding");
10511 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10512 TOKEN_STRING_INITIALIZER
10513 (struct cmd_config_e_tag_result,
10515 cmdline_parse_token_string_t cmd_config_e_tag_add =
10516 TOKEN_STRING_INITIALIZER
10517 (struct cmd_config_e_tag_result,
10519 cmdline_parse_token_string_t cmd_config_e_tag_del =
10520 TOKEN_STRING_INITIALIZER
10521 (struct cmd_config_e_tag_result,
10523 cmdline_parse_token_string_t cmd_config_e_tag_on =
10524 TOKEN_STRING_INITIALIZER
10525 (struct cmd_config_e_tag_result,
10527 cmdline_parse_token_string_t cmd_config_e_tag_off =
10528 TOKEN_STRING_INITIALIZER
10529 (struct cmd_config_e_tag_result,
10531 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10532 TOKEN_STRING_INITIALIZER
10533 (struct cmd_config_e_tag_result,
10535 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10536 TOKEN_STRING_INITIALIZER
10537 (struct cmd_config_e_tag_result,
10538 port_tag_id, "port-tag-id");
10539 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10540 TOKEN_NUM_INITIALIZER
10541 (struct cmd_config_e_tag_result,
10542 port_tag_id_val, UINT32);
10543 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10544 TOKEN_STRING_INITIALIZER
10545 (struct cmd_config_e_tag_result,
10546 e_tag_id, "e-tag-id");
10547 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10548 TOKEN_NUM_INITIALIZER
10549 (struct cmd_config_e_tag_result,
10550 e_tag_id_val, UINT16);
10551 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10552 TOKEN_STRING_INITIALIZER
10553 (struct cmd_config_e_tag_result,
10554 dst_pool, "dst-pool");
10555 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10556 TOKEN_NUM_INITIALIZER
10557 (struct cmd_config_e_tag_result,
10558 dst_pool_val, UINT8);
10559 cmdline_parse_token_string_t cmd_config_e_tag_port =
10560 TOKEN_STRING_INITIALIZER
10561 (struct cmd_config_e_tag_result,
10563 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10564 TOKEN_NUM_INITIALIZER
10565 (struct cmd_config_e_tag_result,
10567 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10568 TOKEN_STRING_INITIALIZER
10569 (struct cmd_config_e_tag_result,
10571 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10572 TOKEN_NUM_INITIALIZER
10573 (struct cmd_config_e_tag_result,
10576 /* E-tag insertion configuration */
10578 cmd_config_e_tag_insertion_en_parsed(
10579 void *parsed_result,
10580 __attribute__((unused)) struct cmdline *cl,
10581 __attribute__((unused)) void *data)
10583 struct cmd_config_e_tag_result *res =
10585 struct rte_eth_l2_tunnel_conf entry;
10587 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10590 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10591 entry.tunnel_id = res->port_tag_id_val;
10592 entry.vf_id = res->vf_id;
10593 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10595 ETH_L2_TUNNEL_INSERTION_MASK,
10600 cmd_config_e_tag_insertion_dis_parsed(
10601 void *parsed_result,
10602 __attribute__((unused)) struct cmdline *cl,
10603 __attribute__((unused)) void *data)
10605 struct cmd_config_e_tag_result *res =
10607 struct rte_eth_l2_tunnel_conf entry;
10609 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10612 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10613 entry.vf_id = res->vf_id;
10615 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10617 ETH_L2_TUNNEL_INSERTION_MASK,
10621 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10622 .f = cmd_config_e_tag_insertion_en_parsed,
10624 .help_str = "E-tag ... : E-tag insertion enable",
10626 (void *)&cmd_config_e_tag_e_tag,
10627 (void *)&cmd_config_e_tag_set,
10628 (void *)&cmd_config_e_tag_insertion,
10629 (void *)&cmd_config_e_tag_on,
10630 (void *)&cmd_config_e_tag_port_tag_id,
10631 (void *)&cmd_config_e_tag_port_tag_id_val,
10632 (void *)&cmd_config_e_tag_port,
10633 (void *)&cmd_config_e_tag_port_id,
10634 (void *)&cmd_config_e_tag_vf,
10635 (void *)&cmd_config_e_tag_vf_id,
10640 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10641 .f = cmd_config_e_tag_insertion_dis_parsed,
10643 .help_str = "E-tag ... : E-tag insertion disable",
10645 (void *)&cmd_config_e_tag_e_tag,
10646 (void *)&cmd_config_e_tag_set,
10647 (void *)&cmd_config_e_tag_insertion,
10648 (void *)&cmd_config_e_tag_off,
10649 (void *)&cmd_config_e_tag_port,
10650 (void *)&cmd_config_e_tag_port_id,
10651 (void *)&cmd_config_e_tag_vf,
10652 (void *)&cmd_config_e_tag_vf_id,
10657 /* E-tag stripping configuration */
10659 cmd_config_e_tag_stripping_parsed(
10660 void *parsed_result,
10661 __attribute__((unused)) struct cmdline *cl,
10662 __attribute__((unused)) void *data)
10664 struct cmd_config_e_tag_result *res =
10666 struct rte_eth_l2_tunnel_conf entry;
10668 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10671 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10673 if (!strcmp(res->on_off, "on"))
10674 rte_eth_dev_l2_tunnel_offload_set
10677 ETH_L2_TUNNEL_STRIPPING_MASK,
10680 rte_eth_dev_l2_tunnel_offload_set
10683 ETH_L2_TUNNEL_STRIPPING_MASK,
10687 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10688 .f = cmd_config_e_tag_stripping_parsed,
10690 .help_str = "E-tag ... : E-tag stripping enable/disable",
10692 (void *)&cmd_config_e_tag_e_tag,
10693 (void *)&cmd_config_e_tag_set,
10694 (void *)&cmd_config_e_tag_stripping,
10695 (void *)&cmd_config_e_tag_on_off,
10696 (void *)&cmd_config_e_tag_port,
10697 (void *)&cmd_config_e_tag_port_id,
10702 /* E-tag forwarding configuration */
10704 cmd_config_e_tag_forwarding_parsed(
10705 void *parsed_result,
10706 __attribute__((unused)) struct cmdline *cl,
10707 __attribute__((unused)) void *data)
10709 struct cmd_config_e_tag_result *res = parsed_result;
10710 struct rte_eth_l2_tunnel_conf entry;
10712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10715 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10717 if (!strcmp(res->on_off, "on"))
10718 rte_eth_dev_l2_tunnel_offload_set
10721 ETH_L2_TUNNEL_FORWARDING_MASK,
10724 rte_eth_dev_l2_tunnel_offload_set
10727 ETH_L2_TUNNEL_FORWARDING_MASK,
10731 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10732 .f = cmd_config_e_tag_forwarding_parsed,
10734 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10736 (void *)&cmd_config_e_tag_e_tag,
10737 (void *)&cmd_config_e_tag_set,
10738 (void *)&cmd_config_e_tag_forwarding,
10739 (void *)&cmd_config_e_tag_on_off,
10740 (void *)&cmd_config_e_tag_port,
10741 (void *)&cmd_config_e_tag_port_id,
10746 /* E-tag filter configuration */
10748 cmd_config_e_tag_filter_add_parsed(
10749 void *parsed_result,
10750 __attribute__((unused)) struct cmdline *cl,
10751 __attribute__((unused)) void *data)
10753 struct cmd_config_e_tag_result *res = parsed_result;
10754 struct rte_eth_l2_tunnel_conf entry;
10757 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10760 if (res->e_tag_id_val > 0x3fff) {
10761 printf("e-tag-id must be equal or less than 0x3fff.\n");
10765 ret = rte_eth_dev_filter_supported(res->port_id,
10766 RTE_ETH_FILTER_L2_TUNNEL);
10768 printf("E-tag filter is not supported on port %u.\n",
10773 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10774 entry.tunnel_id = res->e_tag_id_val;
10775 entry.pool = res->dst_pool_val;
10777 ret = rte_eth_dev_filter_ctrl(res->port_id,
10778 RTE_ETH_FILTER_L2_TUNNEL,
10779 RTE_ETH_FILTER_ADD,
10782 printf("E-tag filter programming error: (%s)\n",
10786 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10787 .f = cmd_config_e_tag_filter_add_parsed,
10789 .help_str = "E-tag ... : E-tag filter add",
10791 (void *)&cmd_config_e_tag_e_tag,
10792 (void *)&cmd_config_e_tag_set,
10793 (void *)&cmd_config_e_tag_filter,
10794 (void *)&cmd_config_e_tag_add,
10795 (void *)&cmd_config_e_tag_e_tag_id,
10796 (void *)&cmd_config_e_tag_e_tag_id_val,
10797 (void *)&cmd_config_e_tag_dst_pool,
10798 (void *)&cmd_config_e_tag_dst_pool_val,
10799 (void *)&cmd_config_e_tag_port,
10800 (void *)&cmd_config_e_tag_port_id,
10806 cmd_config_e_tag_filter_del_parsed(
10807 void *parsed_result,
10808 __attribute__((unused)) struct cmdline *cl,
10809 __attribute__((unused)) void *data)
10811 struct cmd_config_e_tag_result *res = parsed_result;
10812 struct rte_eth_l2_tunnel_conf entry;
10815 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10818 if (res->e_tag_id_val > 0x3fff) {
10819 printf("e-tag-id must be less than 0x3fff.\n");
10823 ret = rte_eth_dev_filter_supported(res->port_id,
10824 RTE_ETH_FILTER_L2_TUNNEL);
10826 printf("E-tag filter is not supported on port %u.\n",
10831 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10832 entry.tunnel_id = res->e_tag_id_val;
10834 ret = rte_eth_dev_filter_ctrl(res->port_id,
10835 RTE_ETH_FILTER_L2_TUNNEL,
10836 RTE_ETH_FILTER_DELETE,
10839 printf("E-tag filter programming error: (%s)\n",
10843 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10844 .f = cmd_config_e_tag_filter_del_parsed,
10846 .help_str = "E-tag ... : E-tag filter delete",
10848 (void *)&cmd_config_e_tag_e_tag,
10849 (void *)&cmd_config_e_tag_set,
10850 (void *)&cmd_config_e_tag_filter,
10851 (void *)&cmd_config_e_tag_del,
10852 (void *)&cmd_config_e_tag_e_tag_id,
10853 (void *)&cmd_config_e_tag_e_tag_id_val,
10854 (void *)&cmd_config_e_tag_port,
10855 (void *)&cmd_config_e_tag_port_id,
10860 /* vf vlan anti spoof configuration */
10862 /* Common result structure for vf vlan anti spoof */
10863 struct cmd_vf_vlan_anti_spoof_result {
10864 cmdline_fixed_string_t set;
10865 cmdline_fixed_string_t vf;
10866 cmdline_fixed_string_t vlan;
10867 cmdline_fixed_string_t antispoof;
10870 cmdline_fixed_string_t on_off;
10873 /* Common CLI fields for vf vlan anti spoof enable disable */
10874 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10875 TOKEN_STRING_INITIALIZER
10876 (struct cmd_vf_vlan_anti_spoof_result,
10878 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10879 TOKEN_STRING_INITIALIZER
10880 (struct cmd_vf_vlan_anti_spoof_result,
10882 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10883 TOKEN_STRING_INITIALIZER
10884 (struct cmd_vf_vlan_anti_spoof_result,
10886 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10887 TOKEN_STRING_INITIALIZER
10888 (struct cmd_vf_vlan_anti_spoof_result,
10889 antispoof, "antispoof");
10890 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10891 TOKEN_NUM_INITIALIZER
10892 (struct cmd_vf_vlan_anti_spoof_result,
10894 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10895 TOKEN_NUM_INITIALIZER
10896 (struct cmd_vf_vlan_anti_spoof_result,
10898 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10899 TOKEN_STRING_INITIALIZER
10900 (struct cmd_vf_vlan_anti_spoof_result,
10904 cmd_set_vf_vlan_anti_spoof_parsed(
10905 void *parsed_result,
10906 __attribute__((unused)) struct cmdline *cl,
10907 __attribute__((unused)) void *data)
10909 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10910 int ret = -ENOTSUP;
10912 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10914 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10917 #ifdef RTE_LIBRTE_IXGBE_PMD
10918 if (ret == -ENOTSUP)
10919 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10920 res->vf_id, is_on);
10922 #ifdef RTE_LIBRTE_I40E_PMD
10923 if (ret == -ENOTSUP)
10924 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10925 res->vf_id, is_on);
10932 printf("invalid vf_id %d\n", res->vf_id);
10935 printf("invalid port_id %d\n", res->port_id);
10938 printf("function not implemented\n");
10941 printf("programming error: (%s)\n", strerror(-ret));
10945 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10946 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10948 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10950 (void *)&cmd_vf_vlan_anti_spoof_set,
10951 (void *)&cmd_vf_vlan_anti_spoof_vf,
10952 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10953 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10954 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10955 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10956 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10961 /* vf mac anti spoof configuration */
10963 /* Common result structure for vf mac anti spoof */
10964 struct cmd_vf_mac_anti_spoof_result {
10965 cmdline_fixed_string_t set;
10966 cmdline_fixed_string_t vf;
10967 cmdline_fixed_string_t mac;
10968 cmdline_fixed_string_t antispoof;
10971 cmdline_fixed_string_t on_off;
10974 /* Common CLI fields for vf mac anti spoof enable disable */
10975 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10976 TOKEN_STRING_INITIALIZER
10977 (struct cmd_vf_mac_anti_spoof_result,
10979 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10980 TOKEN_STRING_INITIALIZER
10981 (struct cmd_vf_mac_anti_spoof_result,
10983 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10984 TOKEN_STRING_INITIALIZER
10985 (struct cmd_vf_mac_anti_spoof_result,
10987 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10988 TOKEN_STRING_INITIALIZER
10989 (struct cmd_vf_mac_anti_spoof_result,
10990 antispoof, "antispoof");
10991 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10992 TOKEN_NUM_INITIALIZER
10993 (struct cmd_vf_mac_anti_spoof_result,
10995 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10996 TOKEN_NUM_INITIALIZER
10997 (struct cmd_vf_mac_anti_spoof_result,
10999 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11000 TOKEN_STRING_INITIALIZER
11001 (struct cmd_vf_mac_anti_spoof_result,
11005 cmd_set_vf_mac_anti_spoof_parsed(
11006 void *parsed_result,
11007 __attribute__((unused)) struct cmdline *cl,
11008 __attribute__((unused)) void *data)
11010 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11011 int ret = -ENOTSUP;
11013 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11015 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11018 #ifdef RTE_LIBRTE_IXGBE_PMD
11019 if (ret == -ENOTSUP)
11020 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11021 res->vf_id, is_on);
11023 #ifdef RTE_LIBRTE_I40E_PMD
11024 if (ret == -ENOTSUP)
11025 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11026 res->vf_id, is_on);
11033 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11036 printf("invalid port_id %d\n", res->port_id);
11039 printf("function not implemented\n");
11042 printf("programming error: (%s)\n", strerror(-ret));
11046 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11047 .f = cmd_set_vf_mac_anti_spoof_parsed,
11049 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11051 (void *)&cmd_vf_mac_anti_spoof_set,
11052 (void *)&cmd_vf_mac_anti_spoof_vf,
11053 (void *)&cmd_vf_mac_anti_spoof_mac,
11054 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11055 (void *)&cmd_vf_mac_anti_spoof_port_id,
11056 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11057 (void *)&cmd_vf_mac_anti_spoof_on_off,
11062 /* vf vlan strip queue configuration */
11064 /* Common result structure for vf mac anti spoof */
11065 struct cmd_vf_vlan_stripq_result {
11066 cmdline_fixed_string_t set;
11067 cmdline_fixed_string_t vf;
11068 cmdline_fixed_string_t vlan;
11069 cmdline_fixed_string_t stripq;
11072 cmdline_fixed_string_t on_off;
11075 /* Common CLI fields for vf vlan strip enable disable */
11076 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11077 TOKEN_STRING_INITIALIZER
11078 (struct cmd_vf_vlan_stripq_result,
11080 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11081 TOKEN_STRING_INITIALIZER
11082 (struct cmd_vf_vlan_stripq_result,
11084 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11085 TOKEN_STRING_INITIALIZER
11086 (struct cmd_vf_vlan_stripq_result,
11088 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11089 TOKEN_STRING_INITIALIZER
11090 (struct cmd_vf_vlan_stripq_result,
11092 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11093 TOKEN_NUM_INITIALIZER
11094 (struct cmd_vf_vlan_stripq_result,
11096 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11097 TOKEN_NUM_INITIALIZER
11098 (struct cmd_vf_vlan_stripq_result,
11100 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11101 TOKEN_STRING_INITIALIZER
11102 (struct cmd_vf_vlan_stripq_result,
11106 cmd_set_vf_vlan_stripq_parsed(
11107 void *parsed_result,
11108 __attribute__((unused)) struct cmdline *cl,
11109 __attribute__((unused)) void *data)
11111 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11112 int ret = -ENOTSUP;
11114 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11116 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11119 #ifdef RTE_LIBRTE_IXGBE_PMD
11120 if (ret == -ENOTSUP)
11121 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11122 res->vf_id, is_on);
11124 #ifdef RTE_LIBRTE_I40E_PMD
11125 if (ret == -ENOTSUP)
11126 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11127 res->vf_id, is_on);
11134 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11137 printf("invalid port_id %d\n", res->port_id);
11140 printf("function not implemented\n");
11143 printf("programming error: (%s)\n", strerror(-ret));
11147 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11148 .f = cmd_set_vf_vlan_stripq_parsed,
11150 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11152 (void *)&cmd_vf_vlan_stripq_set,
11153 (void *)&cmd_vf_vlan_stripq_vf,
11154 (void *)&cmd_vf_vlan_stripq_vlan,
11155 (void *)&cmd_vf_vlan_stripq_stripq,
11156 (void *)&cmd_vf_vlan_stripq_port_id,
11157 (void *)&cmd_vf_vlan_stripq_vf_id,
11158 (void *)&cmd_vf_vlan_stripq_on_off,
11163 /* vf vlan insert configuration */
11165 /* Common result structure for vf vlan insert */
11166 struct cmd_vf_vlan_insert_result {
11167 cmdline_fixed_string_t set;
11168 cmdline_fixed_string_t vf;
11169 cmdline_fixed_string_t vlan;
11170 cmdline_fixed_string_t insert;
11176 /* Common CLI fields for vf vlan insert enable disable */
11177 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11178 TOKEN_STRING_INITIALIZER
11179 (struct cmd_vf_vlan_insert_result,
11181 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11182 TOKEN_STRING_INITIALIZER
11183 (struct cmd_vf_vlan_insert_result,
11185 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11186 TOKEN_STRING_INITIALIZER
11187 (struct cmd_vf_vlan_insert_result,
11189 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11190 TOKEN_STRING_INITIALIZER
11191 (struct cmd_vf_vlan_insert_result,
11193 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11194 TOKEN_NUM_INITIALIZER
11195 (struct cmd_vf_vlan_insert_result,
11197 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11198 TOKEN_NUM_INITIALIZER
11199 (struct cmd_vf_vlan_insert_result,
11201 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11202 TOKEN_NUM_INITIALIZER
11203 (struct cmd_vf_vlan_insert_result,
11207 cmd_set_vf_vlan_insert_parsed(
11208 void *parsed_result,
11209 __attribute__((unused)) struct cmdline *cl,
11210 __attribute__((unused)) void *data)
11212 struct cmd_vf_vlan_insert_result *res = parsed_result;
11213 int ret = -ENOTSUP;
11215 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11218 #ifdef RTE_LIBRTE_IXGBE_PMD
11219 if (ret == -ENOTSUP)
11220 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11223 #ifdef RTE_LIBRTE_I40E_PMD
11224 if (ret == -ENOTSUP)
11225 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11233 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11236 printf("invalid port_id %d\n", res->port_id);
11239 printf("function not implemented\n");
11242 printf("programming error: (%s)\n", strerror(-ret));
11246 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11247 .f = cmd_set_vf_vlan_insert_parsed,
11249 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11251 (void *)&cmd_vf_vlan_insert_set,
11252 (void *)&cmd_vf_vlan_insert_vf,
11253 (void *)&cmd_vf_vlan_insert_vlan,
11254 (void *)&cmd_vf_vlan_insert_insert,
11255 (void *)&cmd_vf_vlan_insert_port_id,
11256 (void *)&cmd_vf_vlan_insert_vf_id,
11257 (void *)&cmd_vf_vlan_insert_vlan_id,
11262 /* tx loopback configuration */
11264 /* Common result structure for tx loopback */
11265 struct cmd_tx_loopback_result {
11266 cmdline_fixed_string_t set;
11267 cmdline_fixed_string_t tx;
11268 cmdline_fixed_string_t loopback;
11270 cmdline_fixed_string_t on_off;
11273 /* Common CLI fields for tx loopback enable disable */
11274 cmdline_parse_token_string_t cmd_tx_loopback_set =
11275 TOKEN_STRING_INITIALIZER
11276 (struct cmd_tx_loopback_result,
11278 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11279 TOKEN_STRING_INITIALIZER
11280 (struct cmd_tx_loopback_result,
11282 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11283 TOKEN_STRING_INITIALIZER
11284 (struct cmd_tx_loopback_result,
11285 loopback, "loopback");
11286 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11287 TOKEN_NUM_INITIALIZER
11288 (struct cmd_tx_loopback_result,
11290 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11291 TOKEN_STRING_INITIALIZER
11292 (struct cmd_tx_loopback_result,
11296 cmd_set_tx_loopback_parsed(
11297 void *parsed_result,
11298 __attribute__((unused)) struct cmdline *cl,
11299 __attribute__((unused)) void *data)
11301 struct cmd_tx_loopback_result *res = parsed_result;
11302 int ret = -ENOTSUP;
11304 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11306 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11309 #ifdef RTE_LIBRTE_IXGBE_PMD
11310 if (ret == -ENOTSUP)
11311 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11313 #ifdef RTE_LIBRTE_I40E_PMD
11314 if (ret == -ENOTSUP)
11315 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11322 printf("invalid is_on %d\n", is_on);
11325 printf("invalid port_id %d\n", res->port_id);
11328 printf("function not implemented\n");
11331 printf("programming error: (%s)\n", strerror(-ret));
11335 cmdline_parse_inst_t cmd_set_tx_loopback = {
11336 .f = cmd_set_tx_loopback_parsed,
11338 .help_str = "set tx loopback <port_id> on|off",
11340 (void *)&cmd_tx_loopback_set,
11341 (void *)&cmd_tx_loopback_tx,
11342 (void *)&cmd_tx_loopback_loopback,
11343 (void *)&cmd_tx_loopback_port_id,
11344 (void *)&cmd_tx_loopback_on_off,
11349 #ifdef RTE_LIBRTE_IXGBE_PMD
11350 /* all queues drop enable configuration */
11352 /* Common result structure for all queues drop enable */
11353 struct cmd_all_queues_drop_en_result {
11354 cmdline_fixed_string_t set;
11355 cmdline_fixed_string_t all;
11356 cmdline_fixed_string_t queues;
11357 cmdline_fixed_string_t drop;
11359 cmdline_fixed_string_t on_off;
11362 /* Common CLI fields for tx loopback enable disable */
11363 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11364 TOKEN_STRING_INITIALIZER
11365 (struct cmd_all_queues_drop_en_result,
11367 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11368 TOKEN_STRING_INITIALIZER
11369 (struct cmd_all_queues_drop_en_result,
11371 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11372 TOKEN_STRING_INITIALIZER
11373 (struct cmd_all_queues_drop_en_result,
11375 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11376 TOKEN_STRING_INITIALIZER
11377 (struct cmd_all_queues_drop_en_result,
11379 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11380 TOKEN_NUM_INITIALIZER
11381 (struct cmd_all_queues_drop_en_result,
11383 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11384 TOKEN_STRING_INITIALIZER
11385 (struct cmd_all_queues_drop_en_result,
11389 cmd_set_all_queues_drop_en_parsed(
11390 void *parsed_result,
11391 __attribute__((unused)) struct cmdline *cl,
11392 __attribute__((unused)) void *data)
11394 struct cmd_all_queues_drop_en_result *res = parsed_result;
11396 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11398 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11401 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11406 printf("invalid is_on %d\n", is_on);
11409 printf("invalid port_id %d\n", res->port_id);
11412 printf("function not implemented\n");
11415 printf("programming error: (%s)\n", strerror(-ret));
11419 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11420 .f = cmd_set_all_queues_drop_en_parsed,
11422 .help_str = "set all queues drop <port_id> on|off",
11424 (void *)&cmd_all_queues_drop_en_set,
11425 (void *)&cmd_all_queues_drop_en_all,
11426 (void *)&cmd_all_queues_drop_en_queues,
11427 (void *)&cmd_all_queues_drop_en_drop,
11428 (void *)&cmd_all_queues_drop_en_port_id,
11429 (void *)&cmd_all_queues_drop_en_on_off,
11434 /* vf split drop enable configuration */
11436 /* Common result structure for vf split drop enable */
11437 struct cmd_vf_split_drop_en_result {
11438 cmdline_fixed_string_t set;
11439 cmdline_fixed_string_t vf;
11440 cmdline_fixed_string_t split;
11441 cmdline_fixed_string_t drop;
11444 cmdline_fixed_string_t on_off;
11447 /* Common CLI fields for vf split drop enable disable */
11448 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11449 TOKEN_STRING_INITIALIZER
11450 (struct cmd_vf_split_drop_en_result,
11452 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11453 TOKEN_STRING_INITIALIZER
11454 (struct cmd_vf_split_drop_en_result,
11456 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11457 TOKEN_STRING_INITIALIZER
11458 (struct cmd_vf_split_drop_en_result,
11460 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11461 TOKEN_STRING_INITIALIZER
11462 (struct cmd_vf_split_drop_en_result,
11464 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11465 TOKEN_NUM_INITIALIZER
11466 (struct cmd_vf_split_drop_en_result,
11468 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11469 TOKEN_NUM_INITIALIZER
11470 (struct cmd_vf_split_drop_en_result,
11472 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11473 TOKEN_STRING_INITIALIZER
11474 (struct cmd_vf_split_drop_en_result,
11478 cmd_set_vf_split_drop_en_parsed(
11479 void *parsed_result,
11480 __attribute__((unused)) struct cmdline *cl,
11481 __attribute__((unused)) void *data)
11483 struct cmd_vf_split_drop_en_result *res = parsed_result;
11485 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11487 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11490 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11496 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11499 printf("invalid port_id %d\n", res->port_id);
11502 printf("programming error: (%s)\n", strerror(-ret));
11506 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11507 .f = cmd_set_vf_split_drop_en_parsed,
11509 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11511 (void *)&cmd_vf_split_drop_en_set,
11512 (void *)&cmd_vf_split_drop_en_vf,
11513 (void *)&cmd_vf_split_drop_en_split,
11514 (void *)&cmd_vf_split_drop_en_drop,
11515 (void *)&cmd_vf_split_drop_en_port_id,
11516 (void *)&cmd_vf_split_drop_en_vf_id,
11517 (void *)&cmd_vf_split_drop_en_on_off,
11523 /* vf mac address configuration */
11525 /* Common result structure for vf mac address */
11526 struct cmd_set_vf_mac_addr_result {
11527 cmdline_fixed_string_t set;
11528 cmdline_fixed_string_t vf;
11529 cmdline_fixed_string_t mac;
11530 cmdline_fixed_string_t addr;
11533 struct ether_addr mac_addr;
11537 /* Common CLI fields for vf split drop enable disable */
11538 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11539 TOKEN_STRING_INITIALIZER
11540 (struct cmd_set_vf_mac_addr_result,
11542 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11543 TOKEN_STRING_INITIALIZER
11544 (struct cmd_set_vf_mac_addr_result,
11546 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11547 TOKEN_STRING_INITIALIZER
11548 (struct cmd_set_vf_mac_addr_result,
11550 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11551 TOKEN_STRING_INITIALIZER
11552 (struct cmd_set_vf_mac_addr_result,
11554 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11555 TOKEN_NUM_INITIALIZER
11556 (struct cmd_set_vf_mac_addr_result,
11558 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11559 TOKEN_NUM_INITIALIZER
11560 (struct cmd_set_vf_mac_addr_result,
11562 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11563 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11567 cmd_set_vf_mac_addr_parsed(
11568 void *parsed_result,
11569 __attribute__((unused)) struct cmdline *cl,
11570 __attribute__((unused)) void *data)
11572 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11573 int ret = -ENOTSUP;
11575 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11578 #ifdef RTE_LIBRTE_IXGBE_PMD
11579 if (ret == -ENOTSUP)
11580 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11583 #ifdef RTE_LIBRTE_I40E_PMD
11584 if (ret == -ENOTSUP)
11585 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11593 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11596 printf("invalid port_id %d\n", res->port_id);
11599 printf("function not implemented\n");
11602 printf("programming error: (%s)\n", strerror(-ret));
11606 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11607 .f = cmd_set_vf_mac_addr_parsed,
11609 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11611 (void *)&cmd_set_vf_mac_addr_set,
11612 (void *)&cmd_set_vf_mac_addr_vf,
11613 (void *)&cmd_set_vf_mac_addr_mac,
11614 (void *)&cmd_set_vf_mac_addr_addr,
11615 (void *)&cmd_set_vf_mac_addr_port_id,
11616 (void *)&cmd_set_vf_mac_addr_vf_id,
11617 (void *)&cmd_set_vf_mac_addr_mac_addr,
11622 #ifdef RTE_LIBRTE_IXGBE_PMD
11623 /* MACsec configuration */
11625 /* Common result structure for MACsec offload enable */
11626 struct cmd_macsec_offload_on_result {
11627 cmdline_fixed_string_t set;
11628 cmdline_fixed_string_t macsec;
11629 cmdline_fixed_string_t offload;
11631 cmdline_fixed_string_t on;
11632 cmdline_fixed_string_t encrypt;
11633 cmdline_fixed_string_t en_on_off;
11634 cmdline_fixed_string_t replay_protect;
11635 cmdline_fixed_string_t rp_on_off;
11638 /* Common CLI fields for MACsec offload disable */
11639 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11640 TOKEN_STRING_INITIALIZER
11641 (struct cmd_macsec_offload_on_result,
11643 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11644 TOKEN_STRING_INITIALIZER
11645 (struct cmd_macsec_offload_on_result,
11647 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11648 TOKEN_STRING_INITIALIZER
11649 (struct cmd_macsec_offload_on_result,
11650 offload, "offload");
11651 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11652 TOKEN_NUM_INITIALIZER
11653 (struct cmd_macsec_offload_on_result,
11655 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11656 TOKEN_STRING_INITIALIZER
11657 (struct cmd_macsec_offload_on_result,
11659 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11660 TOKEN_STRING_INITIALIZER
11661 (struct cmd_macsec_offload_on_result,
11662 encrypt, "encrypt");
11663 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11664 TOKEN_STRING_INITIALIZER
11665 (struct cmd_macsec_offload_on_result,
11666 en_on_off, "on#off");
11667 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11668 TOKEN_STRING_INITIALIZER
11669 (struct cmd_macsec_offload_on_result,
11670 replay_protect, "replay-protect");
11671 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11672 TOKEN_STRING_INITIALIZER
11673 (struct cmd_macsec_offload_on_result,
11674 rp_on_off, "on#off");
11677 cmd_set_macsec_offload_on_parsed(
11678 void *parsed_result,
11679 __attribute__((unused)) struct cmdline *cl,
11680 __attribute__((unused)) void *data)
11682 struct cmd_macsec_offload_on_result *res = parsed_result;
11684 portid_t port_id = res->port_id;
11685 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11686 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11688 if (port_id_is_invalid(port_id, ENABLED_WARN))
11691 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11692 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11698 printf("invalid port_id %d\n", port_id);
11701 printf("programming error: (%s)\n", strerror(-ret));
11705 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11706 .f = cmd_set_macsec_offload_on_parsed,
11708 .help_str = "set macsec offload <port_id> on "
11709 "encrypt on|off replay-protect on|off",
11711 (void *)&cmd_macsec_offload_on_set,
11712 (void *)&cmd_macsec_offload_on_macsec,
11713 (void *)&cmd_macsec_offload_on_offload,
11714 (void *)&cmd_macsec_offload_on_port_id,
11715 (void *)&cmd_macsec_offload_on_on,
11716 (void *)&cmd_macsec_offload_on_encrypt,
11717 (void *)&cmd_macsec_offload_on_en_on_off,
11718 (void *)&cmd_macsec_offload_on_replay_protect,
11719 (void *)&cmd_macsec_offload_on_rp_on_off,
11724 /* Common result structure for MACsec offload disable */
11725 struct cmd_macsec_offload_off_result {
11726 cmdline_fixed_string_t set;
11727 cmdline_fixed_string_t macsec;
11728 cmdline_fixed_string_t offload;
11730 cmdline_fixed_string_t off;
11733 /* Common CLI fields for MACsec offload disable */
11734 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11735 TOKEN_STRING_INITIALIZER
11736 (struct cmd_macsec_offload_off_result,
11738 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11739 TOKEN_STRING_INITIALIZER
11740 (struct cmd_macsec_offload_off_result,
11742 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11743 TOKEN_STRING_INITIALIZER
11744 (struct cmd_macsec_offload_off_result,
11745 offload, "offload");
11746 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11747 TOKEN_NUM_INITIALIZER
11748 (struct cmd_macsec_offload_off_result,
11750 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11751 TOKEN_STRING_INITIALIZER
11752 (struct cmd_macsec_offload_off_result,
11756 cmd_set_macsec_offload_off_parsed(
11757 void *parsed_result,
11758 __attribute__((unused)) struct cmdline *cl,
11759 __attribute__((unused)) void *data)
11761 struct cmd_macsec_offload_off_result *res = parsed_result;
11763 portid_t port_id = res->port_id;
11765 if (port_id_is_invalid(port_id, ENABLED_WARN))
11768 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11769 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11775 printf("invalid port_id %d\n", port_id);
11778 printf("programming error: (%s)\n", strerror(-ret));
11782 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11783 .f = cmd_set_macsec_offload_off_parsed,
11785 .help_str = "set macsec offload <port_id> off",
11787 (void *)&cmd_macsec_offload_off_set,
11788 (void *)&cmd_macsec_offload_off_macsec,
11789 (void *)&cmd_macsec_offload_off_offload,
11790 (void *)&cmd_macsec_offload_off_port_id,
11791 (void *)&cmd_macsec_offload_off_off,
11796 /* Common result structure for MACsec secure connection configure */
11797 struct cmd_macsec_sc_result {
11798 cmdline_fixed_string_t set;
11799 cmdline_fixed_string_t macsec;
11800 cmdline_fixed_string_t sc;
11801 cmdline_fixed_string_t tx_rx;
11803 struct ether_addr mac;
11807 /* Common CLI fields for MACsec secure connection configure */
11808 cmdline_parse_token_string_t cmd_macsec_sc_set =
11809 TOKEN_STRING_INITIALIZER
11810 (struct cmd_macsec_sc_result,
11812 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11813 TOKEN_STRING_INITIALIZER
11814 (struct cmd_macsec_sc_result,
11816 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11817 TOKEN_STRING_INITIALIZER
11818 (struct cmd_macsec_sc_result,
11820 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11821 TOKEN_STRING_INITIALIZER
11822 (struct cmd_macsec_sc_result,
11824 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11825 TOKEN_NUM_INITIALIZER
11826 (struct cmd_macsec_sc_result,
11828 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11829 TOKEN_ETHERADDR_INITIALIZER
11830 (struct cmd_macsec_sc_result,
11832 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11833 TOKEN_NUM_INITIALIZER
11834 (struct cmd_macsec_sc_result,
11838 cmd_set_macsec_sc_parsed(
11839 void *parsed_result,
11840 __attribute__((unused)) struct cmdline *cl,
11841 __attribute__((unused)) void *data)
11843 struct cmd_macsec_sc_result *res = parsed_result;
11845 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11848 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11849 res->mac.addr_bytes) :
11850 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11851 res->mac.addr_bytes, res->pi);
11856 printf("invalid port_id %d\n", res->port_id);
11859 printf("programming error: (%s)\n", strerror(-ret));
11863 cmdline_parse_inst_t cmd_set_macsec_sc = {
11864 .f = cmd_set_macsec_sc_parsed,
11866 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11868 (void *)&cmd_macsec_sc_set,
11869 (void *)&cmd_macsec_sc_macsec,
11870 (void *)&cmd_macsec_sc_sc,
11871 (void *)&cmd_macsec_sc_tx_rx,
11872 (void *)&cmd_macsec_sc_port_id,
11873 (void *)&cmd_macsec_sc_mac,
11874 (void *)&cmd_macsec_sc_pi,
11879 /* Common result structure for MACsec secure connection configure */
11880 struct cmd_macsec_sa_result {
11881 cmdline_fixed_string_t set;
11882 cmdline_fixed_string_t macsec;
11883 cmdline_fixed_string_t sa;
11884 cmdline_fixed_string_t tx_rx;
11889 cmdline_fixed_string_t key;
11892 /* Common CLI fields for MACsec secure connection configure */
11893 cmdline_parse_token_string_t cmd_macsec_sa_set =
11894 TOKEN_STRING_INITIALIZER
11895 (struct cmd_macsec_sa_result,
11897 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11898 TOKEN_STRING_INITIALIZER
11899 (struct cmd_macsec_sa_result,
11901 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11902 TOKEN_STRING_INITIALIZER
11903 (struct cmd_macsec_sa_result,
11905 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11906 TOKEN_STRING_INITIALIZER
11907 (struct cmd_macsec_sa_result,
11909 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11910 TOKEN_NUM_INITIALIZER
11911 (struct cmd_macsec_sa_result,
11913 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11914 TOKEN_NUM_INITIALIZER
11915 (struct cmd_macsec_sa_result,
11917 cmdline_parse_token_num_t cmd_macsec_sa_an =
11918 TOKEN_NUM_INITIALIZER
11919 (struct cmd_macsec_sa_result,
11921 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11922 TOKEN_NUM_INITIALIZER
11923 (struct cmd_macsec_sa_result,
11925 cmdline_parse_token_string_t cmd_macsec_sa_key =
11926 TOKEN_STRING_INITIALIZER
11927 (struct cmd_macsec_sa_result,
11931 cmd_set_macsec_sa_parsed(
11932 void *parsed_result,
11933 __attribute__((unused)) struct cmdline *cl,
11934 __attribute__((unused)) void *data)
11936 struct cmd_macsec_sa_result *res = parsed_result;
11938 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11939 uint8_t key[16] = { 0 };
11945 key_len = strlen(res->key) / 2;
11949 for (i = 0; i < key_len; i++) {
11950 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11953 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11956 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11960 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11961 res->idx, res->an, res->pn, key) :
11962 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11963 res->idx, res->an, res->pn, key);
11968 printf("invalid idx %d or an %d\n", res->idx, res->an);
11971 printf("invalid port_id %d\n", res->port_id);
11974 printf("programming error: (%s)\n", strerror(-ret));
11978 cmdline_parse_inst_t cmd_set_macsec_sa = {
11979 .f = cmd_set_macsec_sa_parsed,
11981 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11983 (void *)&cmd_macsec_sa_set,
11984 (void *)&cmd_macsec_sa_macsec,
11985 (void *)&cmd_macsec_sa_sa,
11986 (void *)&cmd_macsec_sa_tx_rx,
11987 (void *)&cmd_macsec_sa_port_id,
11988 (void *)&cmd_macsec_sa_idx,
11989 (void *)&cmd_macsec_sa_an,
11990 (void *)&cmd_macsec_sa_pn,
11991 (void *)&cmd_macsec_sa_key,
11997 /* VF unicast promiscuous mode configuration */
11999 /* Common result structure for VF unicast promiscuous mode */
12000 struct cmd_vf_promisc_result {
12001 cmdline_fixed_string_t set;
12002 cmdline_fixed_string_t vf;
12003 cmdline_fixed_string_t promisc;
12006 cmdline_fixed_string_t on_off;
12009 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12010 cmdline_parse_token_string_t cmd_vf_promisc_set =
12011 TOKEN_STRING_INITIALIZER
12012 (struct cmd_vf_promisc_result,
12014 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12015 TOKEN_STRING_INITIALIZER
12016 (struct cmd_vf_promisc_result,
12018 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12019 TOKEN_STRING_INITIALIZER
12020 (struct cmd_vf_promisc_result,
12021 promisc, "promisc");
12022 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12023 TOKEN_NUM_INITIALIZER
12024 (struct cmd_vf_promisc_result,
12026 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12027 TOKEN_NUM_INITIALIZER
12028 (struct cmd_vf_promisc_result,
12030 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12031 TOKEN_STRING_INITIALIZER
12032 (struct cmd_vf_promisc_result,
12036 cmd_set_vf_promisc_parsed(
12037 void *parsed_result,
12038 __attribute__((unused)) struct cmdline *cl,
12039 __attribute__((unused)) void *data)
12041 struct cmd_vf_promisc_result *res = parsed_result;
12042 int ret = -ENOTSUP;
12044 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12046 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12049 #ifdef RTE_LIBRTE_I40E_PMD
12050 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12051 res->vf_id, is_on);
12058 printf("invalid vf_id %d\n", res->vf_id);
12061 printf("invalid port_id %d\n", res->port_id);
12064 printf("function not implemented\n");
12067 printf("programming error: (%s)\n", strerror(-ret));
12071 cmdline_parse_inst_t cmd_set_vf_promisc = {
12072 .f = cmd_set_vf_promisc_parsed,
12074 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12075 "Set unicast promiscuous mode for a VF from the PF",
12077 (void *)&cmd_vf_promisc_set,
12078 (void *)&cmd_vf_promisc_vf,
12079 (void *)&cmd_vf_promisc_promisc,
12080 (void *)&cmd_vf_promisc_port_id,
12081 (void *)&cmd_vf_promisc_vf_id,
12082 (void *)&cmd_vf_promisc_on_off,
12087 /* VF multicast promiscuous mode configuration */
12089 /* Common result structure for VF multicast promiscuous mode */
12090 struct cmd_vf_allmulti_result {
12091 cmdline_fixed_string_t set;
12092 cmdline_fixed_string_t vf;
12093 cmdline_fixed_string_t allmulti;
12096 cmdline_fixed_string_t on_off;
12099 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12100 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12101 TOKEN_STRING_INITIALIZER
12102 (struct cmd_vf_allmulti_result,
12104 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_vf_allmulti_result,
12108 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12109 TOKEN_STRING_INITIALIZER
12110 (struct cmd_vf_allmulti_result,
12111 allmulti, "allmulti");
12112 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12113 TOKEN_NUM_INITIALIZER
12114 (struct cmd_vf_allmulti_result,
12116 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12117 TOKEN_NUM_INITIALIZER
12118 (struct cmd_vf_allmulti_result,
12120 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12121 TOKEN_STRING_INITIALIZER
12122 (struct cmd_vf_allmulti_result,
12126 cmd_set_vf_allmulti_parsed(
12127 void *parsed_result,
12128 __attribute__((unused)) struct cmdline *cl,
12129 __attribute__((unused)) void *data)
12131 struct cmd_vf_allmulti_result *res = parsed_result;
12132 int ret = -ENOTSUP;
12134 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12136 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12139 #ifdef RTE_LIBRTE_I40E_PMD
12140 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12141 res->vf_id, is_on);
12148 printf("invalid vf_id %d\n", res->vf_id);
12151 printf("invalid port_id %d\n", res->port_id);
12154 printf("function not implemented\n");
12157 printf("programming error: (%s)\n", strerror(-ret));
12161 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12162 .f = cmd_set_vf_allmulti_parsed,
12164 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12165 "Set multicast promiscuous mode for a VF from the PF",
12167 (void *)&cmd_vf_allmulti_set,
12168 (void *)&cmd_vf_allmulti_vf,
12169 (void *)&cmd_vf_allmulti_allmulti,
12170 (void *)&cmd_vf_allmulti_port_id,
12171 (void *)&cmd_vf_allmulti_vf_id,
12172 (void *)&cmd_vf_allmulti_on_off,
12177 /* ******************************************************************************** */
12179 /* list of instructions */
12180 cmdline_parse_ctx_t main_ctx[] = {
12181 (cmdline_parse_inst_t *)&cmd_help_brief,
12182 (cmdline_parse_inst_t *)&cmd_help_long,
12183 (cmdline_parse_inst_t *)&cmd_quit,
12184 (cmdline_parse_inst_t *)&cmd_showport,
12185 (cmdline_parse_inst_t *)&cmd_showqueue,
12186 (cmdline_parse_inst_t *)&cmd_showportall,
12187 (cmdline_parse_inst_t *)&cmd_showcfg,
12188 (cmdline_parse_inst_t *)&cmd_start,
12189 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12190 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12191 (cmdline_parse_inst_t *)&cmd_set_link_up,
12192 (cmdline_parse_inst_t *)&cmd_set_link_down,
12193 (cmdline_parse_inst_t *)&cmd_reset,
12194 (cmdline_parse_inst_t *)&cmd_set_numbers,
12195 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12196 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12197 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12198 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12199 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12200 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12201 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12202 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12203 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12204 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12205 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12206 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12207 (cmdline_parse_inst_t *)&cmd_set_link_check,
12208 #ifdef RTE_NIC_BYPASS
12209 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12210 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12211 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12212 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12214 #ifdef RTE_LIBRTE_PMD_BOND
12215 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12216 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12217 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12218 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12219 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12220 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12221 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12222 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12223 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12225 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12226 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12227 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12228 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12229 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12230 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12231 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12232 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12233 (cmdline_parse_inst_t *)&cmd_csum_set,
12234 (cmdline_parse_inst_t *)&cmd_csum_show,
12235 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12236 (cmdline_parse_inst_t *)&cmd_tso_set,
12237 (cmdline_parse_inst_t *)&cmd_tso_show,
12238 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12239 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12240 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12241 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12242 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12243 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12244 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12245 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12246 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12247 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12248 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12249 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12250 (cmdline_parse_inst_t *)&cmd_config_dcb,
12251 (cmdline_parse_inst_t *)&cmd_read_reg,
12252 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12253 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12254 (cmdline_parse_inst_t *)&cmd_write_reg,
12255 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12256 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12257 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12258 (cmdline_parse_inst_t *)&cmd_stop,
12259 (cmdline_parse_inst_t *)&cmd_mac_addr,
12260 (cmdline_parse_inst_t *)&cmd_set_qmap,
12261 (cmdline_parse_inst_t *)&cmd_operate_port,
12262 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12263 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12264 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12265 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12266 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12267 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12268 (cmdline_parse_inst_t *)&cmd_config_mtu,
12269 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12270 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12271 (cmdline_parse_inst_t *)&cmd_config_rss,
12272 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12273 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12274 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12275 (cmdline_parse_inst_t *)&cmd_showport_reta,
12276 (cmdline_parse_inst_t *)&cmd_config_burst,
12277 (cmdline_parse_inst_t *)&cmd_config_thresh,
12278 (cmdline_parse_inst_t *)&cmd_config_threshold,
12279 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12280 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12281 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12282 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12283 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12284 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12285 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12286 (cmdline_parse_inst_t *)&cmd_global_config,
12287 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12288 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12289 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12290 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12291 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12292 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12293 (cmdline_parse_inst_t *)&cmd_dump,
12294 (cmdline_parse_inst_t *)&cmd_dump_one,
12295 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12296 (cmdline_parse_inst_t *)&cmd_syn_filter,
12297 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12298 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12299 (cmdline_parse_inst_t *)&cmd_flex_filter,
12300 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12301 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12302 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12303 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12304 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12305 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12306 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12307 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12308 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12309 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12310 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12311 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12312 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12313 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12314 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12315 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12316 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12317 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12318 (cmdline_parse_inst_t *)&cmd_flow,
12319 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12320 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12321 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12322 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12323 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12324 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12325 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12326 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12327 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12328 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12329 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12330 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12331 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12332 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12333 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12334 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12335 #ifdef RTE_LIBRTE_IXGBE_PMD
12336 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12337 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12338 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12339 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12340 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12341 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12342 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12343 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12344 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12345 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12347 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12348 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12349 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
12353 /* prompt function, called from main on MASTER lcore */
12357 /* initialize non-constant commands */
12358 cmd_set_fwd_mode_init();
12359 cmd_set_fwd_retry_mode_init();
12361 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12362 if (testpmd_cl == NULL)
12364 cmdline_interact(testpmd_cl);
12365 cmdline_stdin_exit(testpmd_cl);
12371 if (testpmd_cl != NULL)
12372 cmdline_quit(testpmd_cl);
12376 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12378 if (id == (portid_t)RTE_PORT_ALL) {
12381 FOREACH_PORT(pid, ports) {
12382 /* check if need_reconfig has been set to 1 */
12383 if (ports[pid].need_reconfig == 0)
12384 ports[pid].need_reconfig = dev;
12385 /* check if need_reconfig_queues has been set to 1 */
12386 if (ports[pid].need_reconfig_queues == 0)
12387 ports[pid].need_reconfig_queues = queue;
12389 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12390 /* check if need_reconfig has been set to 1 */
12391 if (ports[id].need_reconfig == 0)
12392 ports[id].need_reconfig = dev;
12393 /* check if need_reconfig_queues has been set to 1 */
12394 if (ports[id].need_reconfig_queues == 0)
12395 ports[id].need_reconfig_queues = queue;