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|cap) (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"
218 "ddp get list (port_id)\n"
219 " Get ddp profile info list\n\n"
223 if (show_all || !strcmp(res->section, "config")) {
229 "Configuration changes only become active when"
230 " forwarding is started/restarted.\n\n"
233 " Reset forwarding to the default configuration.\n\n"
235 "set verbose (level)\n"
236 " Set the debug verbosity level X.\n\n"
239 " Set number of ports.\n\n"
242 " Set number of cores.\n\n"
244 "set coremask (mask)\n"
245 " Set the forwarding cores hexadecimal mask.\n\n"
247 "set portmask (mask)\n"
248 " Set the forwarding ports hexadecimal mask.\n\n"
251 " Set number of packets per burst.\n\n"
253 "set burst tx delay (microseconds) retry (num)\n"
254 " Set the transmit delay time and number of retries,"
255 " effective when retry is enabled.\n\n"
257 "set txpkts (x[,y]*)\n"
258 " Set the length of each segment of TXONLY"
259 " and optionally CSUM packets.\n\n"
261 "set txsplit (off|on|rand)\n"
262 " Set the split policy for the TX packets."
263 " Right now only applicable for CSUM and TXONLY"
266 "set corelist (x[,y]*)\n"
267 " Set the list of forwarding cores.\n\n"
269 "set portlist (x[,y]*)\n"
270 " Set the list of forwarding ports.\n\n"
272 "set tx loopback (port_id) (on|off)\n"
273 " Enable or disable tx loopback.\n\n"
275 #ifdef RTE_LIBRTE_IXGBE_PMD
276 "set all queues drop (port_id) (on|off)\n"
277 " Set drop enable bit for all queues.\n\n"
279 "set vf split drop (port_id) (vf_id) (on|off)\n"
280 " Set split drop enable bit for a VF from the PF.\n\n"
283 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
284 " Set MAC antispoof for a VF from the PF.\n\n"
286 #ifdef RTE_LIBRTE_IXGBE_PMD
287 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
288 " Enable MACsec offload.\n\n"
290 "set macsec offload (port_id) off\n"
291 " Disable MACsec offload.\n\n"
293 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
294 " Configure MACsec secure connection (SC).\n\n"
296 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
297 " Configure MACsec secure association (SA).\n\n"
300 "set vf broadcast (port_id) (vf_id) (on|off)\n"
301 " Set VF broadcast for a VF from the PF.\n\n"
303 "vlan set strip (on|off) (port_id)\n"
304 " Set the VLAN strip on a port.\n\n"
306 "vlan set stripq (on|off) (port_id,queue_id)\n"
307 " Set the VLAN strip for a queue on a port.\n\n"
309 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
310 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
312 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
313 " Set VLAN insert for a VF from the PF.\n\n"
315 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
316 " Set VLAN antispoof for a VF from the PF.\n\n"
318 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
319 " Set VLAN tag for a VF from the PF.\n\n"
321 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
322 " Set a VF's max bandwidth(Mbps).\n\n"
324 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
325 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
327 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
328 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
330 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
331 " Set some TCs' strict link priority mode on a physical port.\n\n"
333 "vlan set filter (on|off) (port_id)\n"
334 " Set the VLAN filter on a port.\n\n"
336 "vlan set qinq (on|off) (port_id)\n"
337 " Set the VLAN QinQ (extended queue in queue)"
340 "vlan set (inner|outer) tpid (value) (port_id)\n"
341 " Set the VLAN TPID for Packet Filtering on"
344 "rx_vlan add (vlan_id|all) (port_id)\n"
345 " Add a vlan_id, or all identifiers, to the set"
346 " of VLAN identifiers filtered by port_id.\n\n"
348 "rx_vlan rm (vlan_id|all) (port_id)\n"
349 " Remove a vlan_id, or all identifiers, from the set"
350 " of VLAN identifiers filtered by port_id.\n\n"
352 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
353 " Add a vlan_id, to the set of VLAN identifiers"
354 "filtered for VF(s) from port_id.\n\n"
356 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
357 " Remove a vlan_id, to the set of VLAN identifiers"
358 "filtered for VF(s) from port_id.\n\n"
360 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
361 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
362 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
363 " add a tunnel filter of a port.\n\n"
365 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
366 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
367 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
368 " remove a tunnel filter of a port.\n\n"
370 "rx_vxlan_port add (udp_port) (port_id)\n"
371 " Add an UDP port for VXLAN packet filter on a port\n\n"
373 "rx_vxlan_port rm (udp_port) (port_id)\n"
374 " Remove an UDP port for VXLAN packet filter on a port\n\n"
376 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
377 " Set hardware insertion of VLAN IDs (single or double VLAN "
378 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
380 "tx_vlan set pvid port_id vlan_id (on|off)\n"
381 " Set port based TX VLAN insertion.\n\n"
383 "tx_vlan reset (port_id)\n"
384 " Disable hardware insertion of a VLAN header in"
385 " packets sent on a port.\n\n"
387 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
388 " Select hardware or software calculation of the"
389 " checksum when transmitting a packet using the"
390 " csum forward engine.\n"
391 " ip|udp|tcp|sctp always concern the inner layer.\n"
392 " outer-ip concerns the outer IP layer in"
393 " case the packet is recognized as a tunnel packet by"
394 " the forward engine (vxlan, gre and ipip are supported)\n"
395 " Please check the NIC datasheet for HW limits.\n\n"
397 "csum parse-tunnel (on|off) (tx_port_id)\n"
398 " If disabled, treat tunnel packets as non-tunneled"
399 " packets (treat inner headers as payload). The port\n"
400 " argument is the port used for TX in csum forward"
403 "csum show (port_id)\n"
404 " Display tx checksum offload configuration\n\n"
406 "tso set (segsize) (portid)\n"
407 " Enable TCP Segmentation Offload in csum forward"
409 " Please check the NIC datasheet for HW limits.\n\n"
412 " Display the status of TCP Segmentation Offload.\n\n"
415 " Set packet forwarding mode.\n\n"
417 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
418 " Add a MAC address on port_id.\n\n"
420 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
421 " Remove a MAC address from port_id.\n\n"
423 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
424 " Set the default MAC address for port_id.\n\n"
426 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
427 " Add a MAC address for a VF on the port.\n\n"
429 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
430 " Set the MAC address for a VF from the PF.\n\n"
432 "set port (port_id) uta (mac_address|all) (on|off)\n"
433 " Add/Remove a or all unicast hash filter(s)"
436 "set promisc (port_id|all) (on|off)\n"
437 " Set the promiscuous mode on port_id, or all.\n\n"
439 "set allmulti (port_id|all) (on|off)\n"
440 " Set the allmulti mode on port_id, or all.\n\n"
442 "set vf promisc (port_id) (vf_id) (on|off)\n"
443 " Set unicast promiscuous mode for a VF from the PF.\n\n"
445 "set vf allmulti (port_id) (vf_id) (on|off)\n"
446 " Set multicast promiscuous mode for a VF from the PF.\n\n"
448 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
449 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
450 " (on|off) autoneg (on|off) (port_id)\n"
451 "set flow_ctrl rx (on|off) (portid)\n"
452 "set flow_ctrl tx (on|off) (portid)\n"
453 "set flow_ctrl high_water (high_water) (portid)\n"
454 "set flow_ctrl low_water (low_water) (portid)\n"
455 "set flow_ctrl pause_time (pause_time) (portid)\n"
456 "set flow_ctrl send_xon (send_xon) (portid)\n"
457 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
458 "set flow_ctrl autoneg (on|off) (port_id)\n"
459 " Set the link flow control parameter on a port.\n\n"
461 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
462 " (low_water) (pause_time) (priority) (port_id)\n"
463 " Set the priority flow control parameter on a"
466 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
467 " Set statistics mapping (qmapping 0..15) for RX/TX"
469 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
470 " on port 0 to mapping 5.\n\n"
472 "set port (port_id) vf (vf_id) rx|tx on|off\n"
473 " Enable/Disable a VF receive/tranmit from a port\n\n"
475 "set port (port_id) vf (vf_id) (mac_addr)"
476 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
477 " Add/Remove unicast or multicast MAC addr filter"
480 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
482 " AUPE:accepts untagged VLAN;"
483 "ROPE:accept unicast hash\n\n"
484 " BAM:accepts broadcast packets;"
485 "MPE:accepts all multicast packets\n\n"
486 " Enable/Disable a VF receive mode of a port\n\n"
488 "set port (port_id) queue (queue_id) rate (rate_num)\n"
489 " Set rate limit for a queue of a port\n\n"
491 "set port (port_id) vf (vf_id) rate (rate_num) "
492 "queue_mask (queue_mask_value)\n"
493 " Set rate limit for queues in VF of a port\n\n"
495 "set port (port_id) mirror-rule (rule_id)"
496 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
497 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
498 " Set pool or vlan type mirror rule on a port.\n"
499 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
500 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
503 "set port (port_id) mirror-rule (rule_id)"
504 " (uplink-mirror|downlink-mirror) dst-pool"
505 " (pool_id) (on|off)\n"
506 " Set uplink or downlink type mirror rule on a port.\n"
507 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
508 " 0 on' enable mirror income traffic to pool 0.\n\n"
510 "reset port (port_id) mirror-rule (rule_id)\n"
511 " Reset a mirror rule.\n\n"
513 "set flush_rx (on|off)\n"
514 " Flush (default) or don't flush RX streams before"
515 " forwarding. Mainly used with PCAP drivers.\n\n"
517 #ifdef RTE_NIC_BYPASS
518 "set bypass mode (normal|bypass|isolate) (port_id)\n"
519 " Set the bypass mode for the lowest port on bypass enabled"
522 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
523 "mode (normal|bypass|isolate) (port_id)\n"
524 " Set the event required to initiate specified bypass mode for"
525 " the lowest port on a bypass enabled NIC where:\n"
526 " timeout = enable bypass after watchdog timeout.\n"
527 " os_on = enable bypass when OS/board is powered on.\n"
528 " os_off = enable bypass when OS/board is powered off.\n"
529 " power_on = enable bypass when power supply is turned on.\n"
530 " power_off = enable bypass when power supply is turned off."
533 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
534 " Set the bypass watchdog timeout to 'n' seconds"
535 " where 0 = instant.\n\n"
537 "show bypass config (port_id)\n"
538 " Show the bypass configuration for a bypass enabled NIC"
539 " using the lowest port on the NIC.\n\n"
541 #ifdef RTE_LIBRTE_PMD_BOND
542 "create bonded device (mode) (socket)\n"
543 " Create a new bonded device with specific bonding mode and socket.\n\n"
545 "add bonding slave (slave_id) (port_id)\n"
546 " Add a slave device to a bonded device.\n\n"
548 "remove bonding slave (slave_id) (port_id)\n"
549 " Remove a slave device from a bonded device.\n\n"
551 "set bonding mode (value) (port_id)\n"
552 " Set the bonding mode on a bonded device.\n\n"
554 "set bonding primary (slave_id) (port_id)\n"
555 " Set the primary slave for a bonded device.\n\n"
557 "show bonding config (port_id)\n"
558 " Show the bonding config for port_id.\n\n"
560 "set bonding mac_addr (port_id) (address)\n"
561 " Set the MAC address of a bonded device.\n\n"
563 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
564 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
566 "set bonding mon_period (port_id) (value)\n"
567 " Set the bonding link status monitoring polling period in ms.\n\n"
569 "set link-up port (port_id)\n"
570 " Set link up for a port.\n\n"
572 "set link-down port (port_id)\n"
573 " Set link down for a port.\n\n"
575 "E-tag set insertion on port-tag-id (value)"
576 " port (port_id) vf (vf_id)\n"
577 " Enable E-tag insertion for a VF on a port\n\n"
579 "E-tag set insertion off port (port_id) vf (vf_id)\n"
580 " Disable E-tag insertion for a VF on a port\n\n"
582 "E-tag set stripping (on|off) port (port_id)\n"
583 " Enable/disable E-tag stripping on a port\n\n"
585 "E-tag set forwarding (on|off) port (port_id)\n"
586 " Enable/disable E-tag based forwarding"
589 "E-tag set filter add e-tag-id (value) dst-pool"
590 " (pool_id) port (port_id)\n"
591 " Add an E-tag forwarding filter on a port\n\n"
593 "E-tag set filter del e-tag-id (value) port (port_id)\n"
594 " Delete an E-tag forwarding filter on a port\n\n"
596 "ddp add (port_id) (profile_path)\n"
597 " Load a profile package on a port\n\n"
599 , list_pkt_forwarding_modes()
603 if (show_all || !strcmp(res->section, "ports")) {
609 "----------------\n\n"
611 "port start (port_id|all)\n"
612 " Start all ports or port_id.\n\n"
614 "port stop (port_id|all)\n"
615 " Stop all ports or port_id.\n\n"
617 "port close (port_id|all)\n"
618 " Close all ports or port_id.\n\n"
620 "port attach (ident)\n"
621 " Attach physical or virtual dev by pci address or virtual device name\n\n"
623 "port detach (port_id)\n"
624 " Detach physical or virtual dev by port_id\n\n"
626 "port config (port_id|all)"
627 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
628 " duplex (half|full|auto)\n"
629 " Set speed and duplex for all ports or port_id\n\n"
631 "port config all (rxq|txq|rxd|txd) (value)\n"
632 " Set number for rxq/txq/rxd/txd.\n\n"
634 "port config all max-pkt-len (value)\n"
635 " Set the max packet length.\n\n"
637 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
638 "hw-vlan-strip|hw-vlan-extend|drop-en)"
640 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
643 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
644 " Set the RSS mode.\n\n"
646 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
647 " Set the RSS redirection table.\n\n"
649 "port config (port_id) dcb vt (on|off) (traffic_class)"
651 " Set the DCB mode.\n\n"
653 "port config all burst (value)\n"
654 " Set the number of packets per burst.\n\n"
656 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
658 " Set the ring prefetch/host/writeback threshold"
659 " for tx/rx queue.\n\n"
661 "port config all (txfreet|txrst|rxfreet) (value)\n"
662 " Set free threshold for rx/tx, or set"
663 " tx rs bit threshold.\n\n"
664 "port config mtu X value\n"
665 " Set the MTU of port X to a given value\n\n"
667 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
668 " Start/stop a rx/tx queue of port X. Only take effect"
669 " when port X is started\n\n"
671 "port config (port_id|all) l2-tunnel E-tag ether-type"
673 " Set the value of E-tag ether-type.\n\n"
675 "port config (port_id|all) l2-tunnel E-tag"
676 " (enable|disable)\n"
677 " Enable/disable the E-tag support.\n\n"
681 if (show_all || !strcmp(res->section, "registers")) {
689 "read reg (port_id) (address)\n"
690 " Display value of a port register.\n\n"
692 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
693 " Display a port register bit field.\n\n"
695 "read regbit (port_id) (address) (bit_x)\n"
696 " Display a single port register bit.\n\n"
698 "write reg (port_id) (address) (value)\n"
699 " Set value of a port register.\n\n"
701 "write regfield (port_id) (address) (bit_x) (bit_y)"
703 " Set bit field of a port register.\n\n"
705 "write regbit (port_id) (address) (bit_x) (value)\n"
706 " Set single bit value of a port register.\n\n"
709 if (show_all || !strcmp(res->section, "filters")) {
717 "ethertype_filter (port_id) (add|del)"
718 " (mac_addr|mac_ignr) (mac_address) ethertype"
719 " (ether_type) (drop|fwd) queue (queue_id)\n"
720 " Add/Del an ethertype filter.\n\n"
722 "2tuple_filter (port_id) (add|del)"
723 " dst_port (dst_port_value) protocol (protocol_value)"
724 " mask (mask_value) tcp_flags (tcp_flags_value)"
725 " priority (prio_value) queue (queue_id)\n"
726 " Add/Del a 2tuple filter.\n\n"
728 "5tuple_filter (port_id) (add|del)"
729 " dst_ip (dst_address) src_ip (src_address)"
730 " dst_port (dst_port_value) src_port (src_port_value)"
731 " protocol (protocol_value)"
732 " mask (mask_value) tcp_flags (tcp_flags_value)"
733 " priority (prio_value) queue (queue_id)\n"
734 " Add/Del a 5tuple filter.\n\n"
736 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
737 " Add/Del syn filter.\n\n"
739 "flex_filter (port_id) (add|del) len (len_value)"
740 " bytes (bytes_value) mask (mask_value)"
741 " priority (prio_value) queue (queue_id)\n"
742 " Add/Del a flex filter.\n\n"
744 "flow_director_filter (port_id) mode IP (add|del|update)"
745 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
746 " src (src_ip_address) dst (dst_ip_address)"
747 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
748 " vlan (vlan_value) flexbytes (flexbytes_value)"
749 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
750 " fd_id (fd_id_value)\n"
751 " Add/Del an IP type flow director filter.\n\n"
753 "flow_director_filter (port_id) mode IP (add|del|update)"
754 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
755 " src (src_ip_address) (src_port)"
756 " dst (dst_ip_address) (dst_port)"
757 " tos (tos_value) ttl (ttl_value)"
758 " vlan (vlan_value) flexbytes (flexbytes_value)"
759 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
760 " fd_id (fd_id_value)\n"
761 " Add/Del an UDP/TCP type flow director filter.\n\n"
763 "flow_director_filter (port_id) mode IP (add|del|update)"
764 " flow (ipv4-sctp|ipv6-sctp)"
765 " src (src_ip_address) (src_port)"
766 " dst (dst_ip_address) (dst_port)"
767 " tag (verification_tag) "
768 " tos (tos_value) ttl (ttl_value)"
770 " flexbytes (flexbytes_value) (drop|fwd)"
771 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
772 " Add/Del a SCTP type flow director filter.\n\n"
774 "flow_director_filter (port_id) mode IP (add|del|update)"
775 " flow l2_payload ether (ethertype)"
776 " flexbytes (flexbytes_value) (drop|fwd)"
777 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
778 " Add/Del a l2 payload type flow director filter.\n\n"
780 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
781 " mac (mac_address) vlan (vlan_value)"
782 " flexbytes (flexbytes_value) (drop|fwd)"
783 " queue (queue_id) fd_id (fd_id_value)\n"
784 " Add/Del a MAC-VLAN flow director filter.\n\n"
786 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
787 " mac (mac_address) vlan (vlan_value)"
788 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
789 " flexbytes (flexbytes_value) (drop|fwd)"
790 " queue (queue_id) fd_id (fd_id_value)\n"
791 " Add/Del a Tunnel flow director filter.\n\n"
793 "flush_flow_director (port_id)\n"
794 " Flush all flow director entries of a device.\n\n"
796 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
797 " src_mask (ipv4_src) (ipv6_src) (src_port)"
798 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
799 " Set flow director IP mask.\n\n"
801 "flow_director_mask (port_id) mode MAC-VLAN"
802 " vlan (vlan_value)\n"
803 " Set flow director MAC-VLAN mask.\n\n"
805 "flow_director_mask (port_id) mode Tunnel"
806 " vlan (vlan_value) mac (mac_value)"
807 " tunnel-type (tunnel_type_value)"
808 " tunnel-id (tunnel_id_value)\n"
809 " Set flow director Tunnel mask.\n\n"
811 "flow_director_flex_mask (port_id)"
812 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
813 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
815 " Configure mask of flex payload.\n\n"
817 "flow_director_flex_payload (port_id)"
818 " (raw|l2|l3|l4) (config)\n"
819 " Configure flex payload selection.\n\n"
821 "get_sym_hash_ena_per_port (port_id)\n"
822 " get symmetric hash enable configuration per port.\n\n"
824 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
825 " set symmetric hash enable configuration per port"
826 " to enable or disable.\n\n"
828 "get_hash_global_config (port_id)\n"
829 " Get the global configurations of hash filters.\n\n"
831 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
832 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
833 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
834 " (enable|disable)\n"
835 " Set the global configurations of hash filters.\n\n"
837 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
838 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
839 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
840 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
841 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
842 "ipv6-next-header|udp-src-port|udp-dst-port|"
843 "tcp-src-port|tcp-dst-port|sctp-src-port|"
844 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
845 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
846 "fld-8th|none) (select|add)\n"
847 " Set the input set for hash.\n\n"
849 "set_fdir_input_set (port_id) "
850 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
851 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
852 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
853 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
854 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
855 "udp-dst-port|tcp-src-port|tcp-dst-port|"
856 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
858 " Set the input set for FDir.\n\n"
860 "flow validate {port_id}"
861 " [group {group_id}] [priority {level}]"
862 " [ingress] [egress]"
863 " pattern {item} [/ {item} [...]] / end"
864 " actions {action} [/ {action} [...]] / end\n"
865 " Check whether a flow rule can be created.\n\n"
867 "flow create {port_id}"
868 " [group {group_id}] [priority {level}]"
869 " [ingress] [egress]"
870 " pattern {item} [/ {item} [...]] / end"
871 " actions {action} [/ {action} [...]] / end\n"
872 " Create a flow rule.\n\n"
874 "flow destroy {port_id} rule {rule_id} [...]\n"
875 " Destroy specific flow rules.\n\n"
877 "flow flush {port_id}\n"
878 " Destroy all flow rules.\n\n"
880 "flow query {port_id} {rule_id} {action}\n"
881 " Query an existing flow rule.\n\n"
883 "flow list {port_id} [group {group_id}] [...]\n"
884 " List existing flow rules sorted by priority,"
885 " filtered by group identifiers.\n\n"
890 cmdline_parse_token_string_t cmd_help_long_help =
891 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
893 cmdline_parse_token_string_t cmd_help_long_section =
894 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
895 "all#control#display#config#"
896 "ports#registers#filters");
898 cmdline_parse_inst_t cmd_help_long = {
899 .f = cmd_help_long_parsed,
901 .help_str = "help all|control|display|config|ports|register|filters: "
904 (void *)&cmd_help_long_help,
905 (void *)&cmd_help_long_section,
911 /* *** start/stop/close all ports *** */
912 struct cmd_operate_port_result {
913 cmdline_fixed_string_t keyword;
914 cmdline_fixed_string_t name;
915 cmdline_fixed_string_t value;
918 static void cmd_operate_port_parsed(void *parsed_result,
919 __attribute__((unused)) struct cmdline *cl,
920 __attribute__((unused)) void *data)
922 struct cmd_operate_port_result *res = parsed_result;
924 if (!strcmp(res->name, "start"))
925 start_port(RTE_PORT_ALL);
926 else if (!strcmp(res->name, "stop"))
927 stop_port(RTE_PORT_ALL);
928 else if (!strcmp(res->name, "close"))
929 close_port(RTE_PORT_ALL);
931 printf("Unknown parameter\n");
934 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
935 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
937 cmdline_parse_token_string_t cmd_operate_port_all_port =
938 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
940 cmdline_parse_token_string_t cmd_operate_port_all_all =
941 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
943 cmdline_parse_inst_t cmd_operate_port = {
944 .f = cmd_operate_port_parsed,
946 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
948 (void *)&cmd_operate_port_all_cmd,
949 (void *)&cmd_operate_port_all_port,
950 (void *)&cmd_operate_port_all_all,
955 /* *** start/stop/close specific port *** */
956 struct cmd_operate_specific_port_result {
957 cmdline_fixed_string_t keyword;
958 cmdline_fixed_string_t name;
962 static void cmd_operate_specific_port_parsed(void *parsed_result,
963 __attribute__((unused)) struct cmdline *cl,
964 __attribute__((unused)) void *data)
966 struct cmd_operate_specific_port_result *res = parsed_result;
968 if (!strcmp(res->name, "start"))
969 start_port(res->value);
970 else if (!strcmp(res->name, "stop"))
971 stop_port(res->value);
972 else if (!strcmp(res->name, "close"))
973 close_port(res->value);
975 printf("Unknown parameter\n");
978 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
979 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
981 cmdline_parse_token_string_t cmd_operate_specific_port_port =
982 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
983 name, "start#stop#close");
984 cmdline_parse_token_num_t cmd_operate_specific_port_id =
985 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
988 cmdline_parse_inst_t cmd_operate_specific_port = {
989 .f = cmd_operate_specific_port_parsed,
991 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
993 (void *)&cmd_operate_specific_port_cmd,
994 (void *)&cmd_operate_specific_port_port,
995 (void *)&cmd_operate_specific_port_id,
1000 /* *** attach a specified port *** */
1001 struct cmd_operate_attach_port_result {
1002 cmdline_fixed_string_t port;
1003 cmdline_fixed_string_t keyword;
1004 cmdline_fixed_string_t identifier;
1007 static void cmd_operate_attach_port_parsed(void *parsed_result,
1008 __attribute__((unused)) struct cmdline *cl,
1009 __attribute__((unused)) void *data)
1011 struct cmd_operate_attach_port_result *res = parsed_result;
1013 if (!strcmp(res->keyword, "attach"))
1014 attach_port(res->identifier);
1016 printf("Unknown parameter\n");
1019 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1020 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1022 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1023 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1025 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1026 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1029 cmdline_parse_inst_t cmd_operate_attach_port = {
1030 .f = cmd_operate_attach_port_parsed,
1032 .help_str = "port attach <identifier>: "
1033 "(identifier: pci address or virtual dev name)",
1035 (void *)&cmd_operate_attach_port_port,
1036 (void *)&cmd_operate_attach_port_keyword,
1037 (void *)&cmd_operate_attach_port_identifier,
1042 /* *** detach a specified port *** */
1043 struct cmd_operate_detach_port_result {
1044 cmdline_fixed_string_t port;
1045 cmdline_fixed_string_t keyword;
1049 static void cmd_operate_detach_port_parsed(void *parsed_result,
1050 __attribute__((unused)) struct cmdline *cl,
1051 __attribute__((unused)) void *data)
1053 struct cmd_operate_detach_port_result *res = parsed_result;
1055 if (!strcmp(res->keyword, "detach"))
1056 detach_port(res->port_id);
1058 printf("Unknown parameter\n");
1061 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1062 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1064 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1065 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1067 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1068 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1071 cmdline_parse_inst_t cmd_operate_detach_port = {
1072 .f = cmd_operate_detach_port_parsed,
1074 .help_str = "port detach <port_id>",
1076 (void *)&cmd_operate_detach_port_port,
1077 (void *)&cmd_operate_detach_port_keyword,
1078 (void *)&cmd_operate_detach_port_port_id,
1083 /* *** configure speed for all ports *** */
1084 struct cmd_config_speed_all {
1085 cmdline_fixed_string_t port;
1086 cmdline_fixed_string_t keyword;
1087 cmdline_fixed_string_t all;
1088 cmdline_fixed_string_t item1;
1089 cmdline_fixed_string_t item2;
1090 cmdline_fixed_string_t value1;
1091 cmdline_fixed_string_t value2;
1095 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1100 if (!strcmp(duplexstr, "half")) {
1101 duplex = ETH_LINK_HALF_DUPLEX;
1102 } else if (!strcmp(duplexstr, "full")) {
1103 duplex = ETH_LINK_FULL_DUPLEX;
1104 } else if (!strcmp(duplexstr, "auto")) {
1105 duplex = ETH_LINK_FULL_DUPLEX;
1107 printf("Unknown duplex parameter\n");
1111 if (!strcmp(speedstr, "10")) {
1112 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1113 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1114 } else if (!strcmp(speedstr, "100")) {
1115 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1116 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1118 if (duplex != ETH_LINK_FULL_DUPLEX) {
1119 printf("Invalid speed/duplex parameters\n");
1122 if (!strcmp(speedstr, "1000")) {
1123 *speed = ETH_LINK_SPEED_1G;
1124 } else if (!strcmp(speedstr, "10000")) {
1125 *speed = ETH_LINK_SPEED_10G;
1126 } else if (!strcmp(speedstr, "25000")) {
1127 *speed = ETH_LINK_SPEED_25G;
1128 } else if (!strcmp(speedstr, "40000")) {
1129 *speed = ETH_LINK_SPEED_40G;
1130 } else if (!strcmp(speedstr, "50000")) {
1131 *speed = ETH_LINK_SPEED_50G;
1132 } else if (!strcmp(speedstr, "100000")) {
1133 *speed = ETH_LINK_SPEED_100G;
1134 } else if (!strcmp(speedstr, "auto")) {
1135 *speed = ETH_LINK_SPEED_AUTONEG;
1137 printf("Unknown speed parameter\n");
1146 cmd_config_speed_all_parsed(void *parsed_result,
1147 __attribute__((unused)) struct cmdline *cl,
1148 __attribute__((unused)) void *data)
1150 struct cmd_config_speed_all *res = parsed_result;
1151 uint32_t link_speed;
1154 if (!all_ports_stopped()) {
1155 printf("Please stop all ports first\n");
1159 if (parse_and_check_speed_duplex(res->value1, res->value2,
1163 FOREACH_PORT(pid, ports) {
1164 ports[pid].dev_conf.link_speeds = link_speed;
1167 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1170 cmdline_parse_token_string_t cmd_config_speed_all_port =
1171 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1172 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1173 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1175 cmdline_parse_token_string_t cmd_config_speed_all_all =
1176 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1177 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1178 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1179 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1181 "10#100#1000#10000#25000#40000#50000#100000#auto");
1182 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1183 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1184 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1185 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1188 cmdline_parse_inst_t cmd_config_speed_all = {
1189 .f = cmd_config_speed_all_parsed,
1191 .help_str = "port config all speed "
1192 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1195 (void *)&cmd_config_speed_all_port,
1196 (void *)&cmd_config_speed_all_keyword,
1197 (void *)&cmd_config_speed_all_all,
1198 (void *)&cmd_config_speed_all_item1,
1199 (void *)&cmd_config_speed_all_value1,
1200 (void *)&cmd_config_speed_all_item2,
1201 (void *)&cmd_config_speed_all_value2,
1206 /* *** configure speed for specific port *** */
1207 struct cmd_config_speed_specific {
1208 cmdline_fixed_string_t port;
1209 cmdline_fixed_string_t keyword;
1211 cmdline_fixed_string_t item1;
1212 cmdline_fixed_string_t item2;
1213 cmdline_fixed_string_t value1;
1214 cmdline_fixed_string_t value2;
1218 cmd_config_speed_specific_parsed(void *parsed_result,
1219 __attribute__((unused)) struct cmdline *cl,
1220 __attribute__((unused)) void *data)
1222 struct cmd_config_speed_specific *res = parsed_result;
1223 uint32_t link_speed;
1225 if (!all_ports_stopped()) {
1226 printf("Please stop all ports first\n");
1230 if (port_id_is_invalid(res->id, ENABLED_WARN))
1233 if (parse_and_check_speed_duplex(res->value1, res->value2,
1237 ports[res->id].dev_conf.link_speeds = link_speed;
1239 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1243 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1244 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1246 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1247 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1249 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1250 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1251 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1252 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1254 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1255 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1256 "10#100#1000#10000#25000#40000#50000#100000#auto");
1257 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1258 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1260 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1261 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1264 cmdline_parse_inst_t cmd_config_speed_specific = {
1265 .f = cmd_config_speed_specific_parsed,
1267 .help_str = "port config <port_id> speed "
1268 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1271 (void *)&cmd_config_speed_specific_port,
1272 (void *)&cmd_config_speed_specific_keyword,
1273 (void *)&cmd_config_speed_specific_id,
1274 (void *)&cmd_config_speed_specific_item1,
1275 (void *)&cmd_config_speed_specific_value1,
1276 (void *)&cmd_config_speed_specific_item2,
1277 (void *)&cmd_config_speed_specific_value2,
1282 /* *** configure txq/rxq, txd/rxd *** */
1283 struct cmd_config_rx_tx {
1284 cmdline_fixed_string_t port;
1285 cmdline_fixed_string_t keyword;
1286 cmdline_fixed_string_t all;
1287 cmdline_fixed_string_t name;
1292 cmd_config_rx_tx_parsed(void *parsed_result,
1293 __attribute__((unused)) struct cmdline *cl,
1294 __attribute__((unused)) void *data)
1296 struct cmd_config_rx_tx *res = parsed_result;
1298 if (!all_ports_stopped()) {
1299 printf("Please stop all ports first\n");
1302 if (!strcmp(res->name, "rxq")) {
1303 if (!res->value && !nb_txq) {
1304 printf("Warning: Either rx or tx queues should be non zero\n");
1307 nb_rxq = res->value;
1309 else if (!strcmp(res->name, "txq")) {
1310 if (!res->value && !nb_rxq) {
1311 printf("Warning: Either rx or tx queues should be non zero\n");
1314 nb_txq = res->value;
1316 else if (!strcmp(res->name, "rxd")) {
1317 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1318 printf("rxd %d invalid - must be > 0 && <= %d\n",
1319 res->value, RTE_TEST_RX_DESC_MAX);
1322 nb_rxd = res->value;
1323 } else if (!strcmp(res->name, "txd")) {
1324 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1325 printf("txd %d invalid - must be > 0 && <= %d\n",
1326 res->value, RTE_TEST_TX_DESC_MAX);
1329 nb_txd = res->value;
1331 printf("Unknown parameter\n");
1339 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1342 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1343 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1344 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1345 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1346 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1347 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1348 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1349 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1351 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1352 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1354 cmdline_parse_inst_t cmd_config_rx_tx = {
1355 .f = cmd_config_rx_tx_parsed,
1357 .help_str = "port config all rxq|txq|rxd|txd <value>",
1359 (void *)&cmd_config_rx_tx_port,
1360 (void *)&cmd_config_rx_tx_keyword,
1361 (void *)&cmd_config_rx_tx_all,
1362 (void *)&cmd_config_rx_tx_name,
1363 (void *)&cmd_config_rx_tx_value,
1368 /* *** config max packet length *** */
1369 struct cmd_config_max_pkt_len_result {
1370 cmdline_fixed_string_t port;
1371 cmdline_fixed_string_t keyword;
1372 cmdline_fixed_string_t all;
1373 cmdline_fixed_string_t name;
1378 cmd_config_max_pkt_len_parsed(void *parsed_result,
1379 __attribute__((unused)) struct cmdline *cl,
1380 __attribute__((unused)) void *data)
1382 struct cmd_config_max_pkt_len_result *res = parsed_result;
1384 if (!all_ports_stopped()) {
1385 printf("Please stop all ports first\n");
1389 if (!strcmp(res->name, "max-pkt-len")) {
1390 if (res->value < ETHER_MIN_LEN) {
1391 printf("max-pkt-len can not be less than %d\n",
1395 if (res->value == rx_mode.max_rx_pkt_len)
1398 rx_mode.max_rx_pkt_len = res->value;
1399 if (res->value > ETHER_MAX_LEN)
1400 rx_mode.jumbo_frame = 1;
1402 rx_mode.jumbo_frame = 0;
1404 printf("Unknown parameter\n");
1410 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1413 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1416 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1419 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1420 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1422 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1425 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1426 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1429 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1430 .f = cmd_config_max_pkt_len_parsed,
1432 .help_str = "port config all max-pkt-len <value>",
1434 (void *)&cmd_config_max_pkt_len_port,
1435 (void *)&cmd_config_max_pkt_len_keyword,
1436 (void *)&cmd_config_max_pkt_len_all,
1437 (void *)&cmd_config_max_pkt_len_name,
1438 (void *)&cmd_config_max_pkt_len_value,
1443 /* *** configure port MTU *** */
1444 struct cmd_config_mtu_result {
1445 cmdline_fixed_string_t port;
1446 cmdline_fixed_string_t keyword;
1447 cmdline_fixed_string_t mtu;
1453 cmd_config_mtu_parsed(void *parsed_result,
1454 __attribute__((unused)) struct cmdline *cl,
1455 __attribute__((unused)) void *data)
1457 struct cmd_config_mtu_result *res = parsed_result;
1459 if (res->value < ETHER_MIN_LEN) {
1460 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1463 port_mtu_set(res->port_id, res->value);
1466 cmdline_parse_token_string_t cmd_config_mtu_port =
1467 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1469 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1470 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1472 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1473 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1475 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1476 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1477 cmdline_parse_token_num_t cmd_config_mtu_value =
1478 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1480 cmdline_parse_inst_t cmd_config_mtu = {
1481 .f = cmd_config_mtu_parsed,
1483 .help_str = "port config mtu <port_id> <value>",
1485 (void *)&cmd_config_mtu_port,
1486 (void *)&cmd_config_mtu_keyword,
1487 (void *)&cmd_config_mtu_mtu,
1488 (void *)&cmd_config_mtu_port_id,
1489 (void *)&cmd_config_mtu_value,
1494 /* *** configure rx mode *** */
1495 struct cmd_config_rx_mode_flag {
1496 cmdline_fixed_string_t port;
1497 cmdline_fixed_string_t keyword;
1498 cmdline_fixed_string_t all;
1499 cmdline_fixed_string_t name;
1500 cmdline_fixed_string_t value;
1504 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1505 __attribute__((unused)) struct cmdline *cl,
1506 __attribute__((unused)) void *data)
1508 struct cmd_config_rx_mode_flag *res = parsed_result;
1510 if (!all_ports_stopped()) {
1511 printf("Please stop all ports first\n");
1515 if (!strcmp(res->name, "crc-strip")) {
1516 if (!strcmp(res->value, "on"))
1517 rx_mode.hw_strip_crc = 1;
1518 else if (!strcmp(res->value, "off"))
1519 rx_mode.hw_strip_crc = 0;
1521 printf("Unknown parameter\n");
1524 } else if (!strcmp(res->name, "scatter")) {
1525 if (!strcmp(res->value, "on"))
1526 rx_mode.enable_scatter = 1;
1527 else if (!strcmp(res->value, "off"))
1528 rx_mode.enable_scatter = 0;
1530 printf("Unknown parameter\n");
1533 } else if (!strcmp(res->name, "rx-cksum")) {
1534 if (!strcmp(res->value, "on"))
1535 rx_mode.hw_ip_checksum = 1;
1536 else if (!strcmp(res->value, "off"))
1537 rx_mode.hw_ip_checksum = 0;
1539 printf("Unknown parameter\n");
1542 } else if (!strcmp(res->name, "hw-vlan")) {
1543 if (!strcmp(res->value, "on")) {
1544 rx_mode.hw_vlan_filter = 1;
1545 rx_mode.hw_vlan_strip = 1;
1547 else if (!strcmp(res->value, "off")) {
1548 rx_mode.hw_vlan_filter = 0;
1549 rx_mode.hw_vlan_strip = 0;
1552 printf("Unknown parameter\n");
1555 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1556 if (!strcmp(res->value, "on"))
1557 rx_mode.hw_vlan_filter = 1;
1558 else if (!strcmp(res->value, "off"))
1559 rx_mode.hw_vlan_filter = 0;
1561 printf("Unknown parameter\n");
1564 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1565 if (!strcmp(res->value, "on"))
1566 rx_mode.hw_vlan_strip = 1;
1567 else if (!strcmp(res->value, "off"))
1568 rx_mode.hw_vlan_strip = 0;
1570 printf("Unknown parameter\n");
1573 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1574 if (!strcmp(res->value, "on"))
1575 rx_mode.hw_vlan_extend = 1;
1576 else if (!strcmp(res->value, "off"))
1577 rx_mode.hw_vlan_extend = 0;
1579 printf("Unknown parameter\n");
1582 } else if (!strcmp(res->name, "drop-en")) {
1583 if (!strcmp(res->value, "on"))
1585 else if (!strcmp(res->value, "off"))
1588 printf("Unknown parameter\n");
1592 printf("Unknown parameter\n");
1598 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1601 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1602 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1603 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1604 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1606 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1607 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1608 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1609 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1610 "crc-strip#scatter#rx-cksum#hw-vlan#"
1611 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1612 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1613 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1616 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1617 .f = cmd_config_rx_mode_flag_parsed,
1619 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1620 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1622 (void *)&cmd_config_rx_mode_flag_port,
1623 (void *)&cmd_config_rx_mode_flag_keyword,
1624 (void *)&cmd_config_rx_mode_flag_all,
1625 (void *)&cmd_config_rx_mode_flag_name,
1626 (void *)&cmd_config_rx_mode_flag_value,
1631 /* *** configure rss *** */
1632 struct cmd_config_rss {
1633 cmdline_fixed_string_t port;
1634 cmdline_fixed_string_t keyword;
1635 cmdline_fixed_string_t all;
1636 cmdline_fixed_string_t name;
1637 cmdline_fixed_string_t value;
1641 cmd_config_rss_parsed(void *parsed_result,
1642 __attribute__((unused)) struct cmdline *cl,
1643 __attribute__((unused)) void *data)
1645 struct cmd_config_rss *res = parsed_result;
1646 struct rte_eth_rss_conf rss_conf;
1650 if (!strcmp(res->value, "all"))
1651 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1652 ETH_RSS_UDP | ETH_RSS_SCTP |
1654 else if (!strcmp(res->value, "ip"))
1655 rss_conf.rss_hf = ETH_RSS_IP;
1656 else if (!strcmp(res->value, "udp"))
1657 rss_conf.rss_hf = ETH_RSS_UDP;
1658 else if (!strcmp(res->value, "tcp"))
1659 rss_conf.rss_hf = ETH_RSS_TCP;
1660 else if (!strcmp(res->value, "sctp"))
1661 rss_conf.rss_hf = ETH_RSS_SCTP;
1662 else if (!strcmp(res->value, "ether"))
1663 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1664 else if (!strcmp(res->value, "port"))
1665 rss_conf.rss_hf = ETH_RSS_PORT;
1666 else if (!strcmp(res->value, "vxlan"))
1667 rss_conf.rss_hf = ETH_RSS_VXLAN;
1668 else if (!strcmp(res->value, "geneve"))
1669 rss_conf.rss_hf = ETH_RSS_GENEVE;
1670 else if (!strcmp(res->value, "nvgre"))
1671 rss_conf.rss_hf = ETH_RSS_NVGRE;
1672 else if (!strcmp(res->value, "none"))
1673 rss_conf.rss_hf = 0;
1675 printf("Unknown parameter\n");
1678 rss_conf.rss_key = NULL;
1679 for (i = 0; i < rte_eth_dev_count(); i++) {
1680 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1682 printf("Configuration of RSS hash at ethernet port %d "
1683 "failed with error (%d): %s.\n",
1684 i, -diag, strerror(-diag));
1688 cmdline_parse_token_string_t cmd_config_rss_port =
1689 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1690 cmdline_parse_token_string_t cmd_config_rss_keyword =
1691 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1692 cmdline_parse_token_string_t cmd_config_rss_all =
1693 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1694 cmdline_parse_token_string_t cmd_config_rss_name =
1695 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1696 cmdline_parse_token_string_t cmd_config_rss_value =
1697 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1698 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1700 cmdline_parse_inst_t cmd_config_rss = {
1701 .f = cmd_config_rss_parsed,
1703 .help_str = "port config all rss "
1704 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1706 (void *)&cmd_config_rss_port,
1707 (void *)&cmd_config_rss_keyword,
1708 (void *)&cmd_config_rss_all,
1709 (void *)&cmd_config_rss_name,
1710 (void *)&cmd_config_rss_value,
1715 /* *** configure rss hash key *** */
1716 struct cmd_config_rss_hash_key {
1717 cmdline_fixed_string_t port;
1718 cmdline_fixed_string_t config;
1720 cmdline_fixed_string_t rss_hash_key;
1721 cmdline_fixed_string_t rss_type;
1722 cmdline_fixed_string_t key;
1726 hexa_digit_to_value(char hexa_digit)
1728 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1729 return (uint8_t) (hexa_digit - '0');
1730 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1731 return (uint8_t) ((hexa_digit - 'a') + 10);
1732 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1733 return (uint8_t) ((hexa_digit - 'A') + 10);
1734 /* Invalid hexa digit */
1739 parse_and_check_key_hexa_digit(char *key, int idx)
1743 hexa_v = hexa_digit_to_value(key[idx]);
1745 printf("invalid key: character %c at position %d is not a "
1746 "valid hexa digit\n", key[idx], idx);
1751 cmd_config_rss_hash_key_parsed(void *parsed_result,
1752 __attribute__((unused)) struct cmdline *cl,
1753 __attribute__((unused)) void *data)
1755 struct cmd_config_rss_hash_key *res = parsed_result;
1756 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1760 struct rte_eth_dev_info dev_info;
1761 uint8_t hash_key_size;
1764 memset(&dev_info, 0, sizeof(dev_info));
1765 rte_eth_dev_info_get(res->port_id, &dev_info);
1766 if (dev_info.hash_key_size > 0 &&
1767 dev_info.hash_key_size <= sizeof(hash_key))
1768 hash_key_size = dev_info.hash_key_size;
1770 printf("dev_info did not provide a valid hash key size\n");
1773 /* Check the length of the RSS hash key */
1774 key_len = strlen(res->key);
1775 if (key_len != (hash_key_size * 2)) {
1776 printf("key length: %d invalid - key must be a string of %d"
1777 " hexa-decimal numbers\n",
1778 (int) key_len, hash_key_size * 2);
1781 /* Translate RSS hash key into binary representation */
1782 for (i = 0; i < hash_key_size; i++) {
1783 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1786 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1789 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1791 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1795 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1796 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1797 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1800 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1801 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1802 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1804 rss_hash_key, "rss-hash-key");
1805 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1806 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1807 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1808 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1809 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1810 "ipv6-tcp-ex#ipv6-udp-ex");
1811 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1812 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1814 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1815 .f = cmd_config_rss_hash_key_parsed,
1817 .help_str = "port config <port_id> rss-hash-key "
1818 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1819 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1820 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1821 "<string of hex digits (variable length, NIC dependent)>",
1823 (void *)&cmd_config_rss_hash_key_port,
1824 (void *)&cmd_config_rss_hash_key_config,
1825 (void *)&cmd_config_rss_hash_key_port_id,
1826 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1827 (void *)&cmd_config_rss_hash_key_rss_type,
1828 (void *)&cmd_config_rss_hash_key_value,
1833 /* *** configure port rxq/txq start/stop *** */
1834 struct cmd_config_rxtx_queue {
1835 cmdline_fixed_string_t port;
1837 cmdline_fixed_string_t rxtxq;
1839 cmdline_fixed_string_t opname;
1843 cmd_config_rxtx_queue_parsed(void *parsed_result,
1844 __attribute__((unused)) struct cmdline *cl,
1845 __attribute__((unused)) void *data)
1847 struct cmd_config_rxtx_queue *res = parsed_result;
1852 if (test_done == 0) {
1853 printf("Please stop forwarding first\n");
1857 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1860 if (port_is_started(res->portid) != 1) {
1861 printf("Please start port %u first\n", res->portid);
1865 if (!strcmp(res->rxtxq, "rxq"))
1867 else if (!strcmp(res->rxtxq, "txq"))
1870 printf("Unknown parameter\n");
1874 if (isrx && rx_queue_id_is_invalid(res->qid))
1876 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1879 if (!strcmp(res->opname, "start"))
1881 else if (!strcmp(res->opname, "stop"))
1884 printf("Unknown parameter\n");
1888 if (isstart && isrx)
1889 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1890 else if (!isstart && isrx)
1891 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1892 else if (isstart && !isrx)
1893 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1895 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1897 if (ret == -ENOTSUP)
1898 printf("Function not supported in PMD driver\n");
1901 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1902 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1903 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1904 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1905 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1906 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1907 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1908 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1909 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1910 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1913 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1914 .f = cmd_config_rxtx_queue_parsed,
1916 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1918 (void *)&cmd_config_speed_all_port,
1919 (void *)&cmd_config_rxtx_queue_portid,
1920 (void *)&cmd_config_rxtx_queue_rxtxq,
1921 (void *)&cmd_config_rxtx_queue_qid,
1922 (void *)&cmd_config_rxtx_queue_opname,
1927 /* *** Configure RSS RETA *** */
1928 struct cmd_config_rss_reta {
1929 cmdline_fixed_string_t port;
1930 cmdline_fixed_string_t keyword;
1932 cmdline_fixed_string_t name;
1933 cmdline_fixed_string_t list_name;
1934 cmdline_fixed_string_t list_of_items;
1938 parse_reta_config(const char *str,
1939 struct rte_eth_rss_reta_entry64 *reta_conf,
1940 uint16_t nb_entries)
1944 uint16_t hash_index, idx, shift;
1947 const char *p, *p0 = str;
1954 unsigned long int_fld[_NUM_FLD];
1955 char *str_fld[_NUM_FLD];
1957 while ((p = strchr(p0,'(')) != NULL) {
1959 if((p0 = strchr(p,')')) == NULL)
1963 if(size >= sizeof(s))
1966 snprintf(s, sizeof(s), "%.*s", size, p);
1967 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1969 for (i = 0; i < _NUM_FLD; i++) {
1971 int_fld[i] = strtoul(str_fld[i], &end, 0);
1972 if (errno != 0 || end == str_fld[i] ||
1977 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1978 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1980 if (hash_index >= nb_entries) {
1981 printf("Invalid RETA hash index=%d\n", hash_index);
1985 idx = hash_index / RTE_RETA_GROUP_SIZE;
1986 shift = hash_index % RTE_RETA_GROUP_SIZE;
1987 reta_conf[idx].mask |= (1ULL << shift);
1988 reta_conf[idx].reta[shift] = nb_queue;
1995 cmd_set_rss_reta_parsed(void *parsed_result,
1996 __attribute__((unused)) struct cmdline *cl,
1997 __attribute__((unused)) void *data)
2000 struct rte_eth_dev_info dev_info;
2001 struct rte_eth_rss_reta_entry64 reta_conf[8];
2002 struct cmd_config_rss_reta *res = parsed_result;
2004 memset(&dev_info, 0, sizeof(dev_info));
2005 rte_eth_dev_info_get(res->port_id, &dev_info);
2006 if (dev_info.reta_size == 0) {
2007 printf("Redirection table size is 0 which is "
2008 "invalid for RSS\n");
2011 printf("The reta size of port %d is %u\n",
2012 res->port_id, dev_info.reta_size);
2013 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2014 printf("Currently do not support more than %u entries of "
2015 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2019 memset(reta_conf, 0, sizeof(reta_conf));
2020 if (!strcmp(res->list_name, "reta")) {
2021 if (parse_reta_config(res->list_of_items, reta_conf,
2022 dev_info.reta_size)) {
2023 printf("Invalid RSS Redirection Table "
2024 "config entered\n");
2027 ret = rte_eth_dev_rss_reta_update(res->port_id,
2028 reta_conf, dev_info.reta_size);
2030 printf("Bad redirection table parameter, "
2031 "return code = %d \n", ret);
2035 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2037 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2038 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2039 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2040 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2041 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2042 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2043 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2044 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2045 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2046 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2048 cmdline_parse_inst_t cmd_config_rss_reta = {
2049 .f = cmd_set_rss_reta_parsed,
2051 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2053 (void *)&cmd_config_rss_reta_port,
2054 (void *)&cmd_config_rss_reta_keyword,
2055 (void *)&cmd_config_rss_reta_port_id,
2056 (void *)&cmd_config_rss_reta_name,
2057 (void *)&cmd_config_rss_reta_list_name,
2058 (void *)&cmd_config_rss_reta_list_of_items,
2063 /* *** SHOW PORT RETA INFO *** */
2064 struct cmd_showport_reta {
2065 cmdline_fixed_string_t show;
2066 cmdline_fixed_string_t port;
2068 cmdline_fixed_string_t rss;
2069 cmdline_fixed_string_t reta;
2071 cmdline_fixed_string_t list_of_items;
2075 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2076 uint16_t nb_entries,
2080 const char *p, *p0 = str;
2084 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2087 p = strchr(p0, '(');
2091 p0 = strchr(p, ')');
2095 if (size >= sizeof(s)) {
2096 printf("The string size exceeds the internal buffer size\n");
2099 snprintf(s, sizeof(s), "%.*s", size, p);
2100 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2101 if (ret <= 0 || ret != num) {
2102 printf("The bits of masks do not match the number of "
2103 "reta entries: %u\n", num);
2106 for (i = 0; i < ret; i++)
2107 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2113 cmd_showport_reta_parsed(void *parsed_result,
2114 __attribute__((unused)) struct cmdline *cl,
2115 __attribute__((unused)) void *data)
2117 struct cmd_showport_reta *res = parsed_result;
2118 struct rte_eth_rss_reta_entry64 reta_conf[8];
2119 struct rte_eth_dev_info dev_info;
2121 memset(&dev_info, 0, sizeof(dev_info));
2122 rte_eth_dev_info_get(res->port_id, &dev_info);
2123 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2124 res->size > ETH_RSS_RETA_SIZE_512) {
2125 printf("Invalid redirection table size: %u\n", res->size);
2129 memset(reta_conf, 0, sizeof(reta_conf));
2130 if (showport_parse_reta_config(reta_conf, res->size,
2131 res->list_of_items) < 0) {
2132 printf("Invalid string: %s for reta masks\n",
2133 res->list_of_items);
2136 port_rss_reta_info(res->port_id, reta_conf, res->size);
2139 cmdline_parse_token_string_t cmd_showport_reta_show =
2140 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2141 cmdline_parse_token_string_t cmd_showport_reta_port =
2142 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2143 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2144 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2145 cmdline_parse_token_string_t cmd_showport_reta_rss =
2146 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2147 cmdline_parse_token_string_t cmd_showport_reta_reta =
2148 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2149 cmdline_parse_token_num_t cmd_showport_reta_size =
2150 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2151 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2152 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2153 list_of_items, NULL);
2155 cmdline_parse_inst_t cmd_showport_reta = {
2156 .f = cmd_showport_reta_parsed,
2158 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2160 (void *)&cmd_showport_reta_show,
2161 (void *)&cmd_showport_reta_port,
2162 (void *)&cmd_showport_reta_port_id,
2163 (void *)&cmd_showport_reta_rss,
2164 (void *)&cmd_showport_reta_reta,
2165 (void *)&cmd_showport_reta_size,
2166 (void *)&cmd_showport_reta_list_of_items,
2171 /* *** Show RSS hash configuration *** */
2172 struct cmd_showport_rss_hash {
2173 cmdline_fixed_string_t show;
2174 cmdline_fixed_string_t port;
2176 cmdline_fixed_string_t rss_hash;
2177 cmdline_fixed_string_t rss_type;
2178 cmdline_fixed_string_t key; /* optional argument */
2181 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2182 __attribute__((unused)) struct cmdline *cl,
2185 struct cmd_showport_rss_hash *res = parsed_result;
2187 port_rss_hash_conf_show(res->port_id, res->rss_type,
2188 show_rss_key != NULL);
2191 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2192 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2193 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2194 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2195 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2196 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2197 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2198 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2200 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2201 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2202 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2203 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2204 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2205 "ipv6-tcp-ex#ipv6-udp-ex");
2206 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2207 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2209 cmdline_parse_inst_t cmd_showport_rss_hash = {
2210 .f = cmd_showport_rss_hash_parsed,
2212 .help_str = "show port <port_id> rss-hash "
2213 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2214 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2215 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2217 (void *)&cmd_showport_rss_hash_show,
2218 (void *)&cmd_showport_rss_hash_port,
2219 (void *)&cmd_showport_rss_hash_port_id,
2220 (void *)&cmd_showport_rss_hash_rss_hash,
2221 (void *)&cmd_showport_rss_hash_rss_hash_info,
2226 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2227 .f = cmd_showport_rss_hash_parsed,
2229 .help_str = "show port <port_id> rss-hash "
2230 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2231 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2232 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2234 (void *)&cmd_showport_rss_hash_show,
2235 (void *)&cmd_showport_rss_hash_port,
2236 (void *)&cmd_showport_rss_hash_port_id,
2237 (void *)&cmd_showport_rss_hash_rss_hash,
2238 (void *)&cmd_showport_rss_hash_rss_hash_info,
2239 (void *)&cmd_showport_rss_hash_rss_key,
2244 /* *** Configure DCB *** */
2245 struct cmd_config_dcb {
2246 cmdline_fixed_string_t port;
2247 cmdline_fixed_string_t config;
2249 cmdline_fixed_string_t dcb;
2250 cmdline_fixed_string_t vt;
2251 cmdline_fixed_string_t vt_en;
2253 cmdline_fixed_string_t pfc;
2254 cmdline_fixed_string_t pfc_en;
2258 cmd_config_dcb_parsed(void *parsed_result,
2259 __attribute__((unused)) struct cmdline *cl,
2260 __attribute__((unused)) void *data)
2262 struct cmd_config_dcb *res = parsed_result;
2263 portid_t port_id = res->port_id;
2264 struct rte_port *port;
2268 port = &ports[port_id];
2269 /** Check if the port is not started **/
2270 if (port->port_status != RTE_PORT_STOPPED) {
2271 printf("Please stop port %d first\n", port_id);
2275 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2276 printf("The invalid number of traffic class,"
2277 " only 4 or 8 allowed.\n");
2281 if (nb_fwd_lcores < res->num_tcs) {
2282 printf("nb_cores shouldn't be less than number of TCs.\n");
2285 if (!strncmp(res->pfc_en, "on", 2))
2290 /* DCB in VT mode */
2291 if (!strncmp(res->vt_en, "on", 2))
2292 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2293 (enum rte_eth_nb_tcs)res->num_tcs,
2296 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2297 (enum rte_eth_nb_tcs)res->num_tcs,
2302 printf("Cannot initialize network ports.\n");
2306 cmd_reconfig_device_queue(port_id, 1, 1);
2309 cmdline_parse_token_string_t cmd_config_dcb_port =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2311 cmdline_parse_token_string_t cmd_config_dcb_config =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2313 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2314 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2315 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2317 cmdline_parse_token_string_t cmd_config_dcb_vt =
2318 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2319 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2320 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2321 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2322 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2323 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2324 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2325 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2328 cmdline_parse_inst_t cmd_config_dcb = {
2329 .f = cmd_config_dcb_parsed,
2331 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2333 (void *)&cmd_config_dcb_port,
2334 (void *)&cmd_config_dcb_config,
2335 (void *)&cmd_config_dcb_port_id,
2336 (void *)&cmd_config_dcb_dcb,
2337 (void *)&cmd_config_dcb_vt,
2338 (void *)&cmd_config_dcb_vt_en,
2339 (void *)&cmd_config_dcb_num_tcs,
2340 (void *)&cmd_config_dcb_pfc,
2341 (void *)&cmd_config_dcb_pfc_en,
2346 /* *** configure number of packets per burst *** */
2347 struct cmd_config_burst {
2348 cmdline_fixed_string_t port;
2349 cmdline_fixed_string_t keyword;
2350 cmdline_fixed_string_t all;
2351 cmdline_fixed_string_t name;
2356 cmd_config_burst_parsed(void *parsed_result,
2357 __attribute__((unused)) struct cmdline *cl,
2358 __attribute__((unused)) void *data)
2360 struct cmd_config_burst *res = parsed_result;
2362 if (!all_ports_stopped()) {
2363 printf("Please stop all ports first\n");
2367 if (!strcmp(res->name, "burst")) {
2368 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2369 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2372 nb_pkt_per_burst = res->value;
2374 printf("Unknown parameter\n");
2380 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2383 cmdline_parse_token_string_t cmd_config_burst_port =
2384 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2385 cmdline_parse_token_string_t cmd_config_burst_keyword =
2386 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2387 cmdline_parse_token_string_t cmd_config_burst_all =
2388 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2389 cmdline_parse_token_string_t cmd_config_burst_name =
2390 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2391 cmdline_parse_token_num_t cmd_config_burst_value =
2392 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2394 cmdline_parse_inst_t cmd_config_burst = {
2395 .f = cmd_config_burst_parsed,
2397 .help_str = "port config all burst <value>",
2399 (void *)&cmd_config_burst_port,
2400 (void *)&cmd_config_burst_keyword,
2401 (void *)&cmd_config_burst_all,
2402 (void *)&cmd_config_burst_name,
2403 (void *)&cmd_config_burst_value,
2408 /* *** configure rx/tx queues *** */
2409 struct cmd_config_thresh {
2410 cmdline_fixed_string_t port;
2411 cmdline_fixed_string_t keyword;
2412 cmdline_fixed_string_t all;
2413 cmdline_fixed_string_t name;
2418 cmd_config_thresh_parsed(void *parsed_result,
2419 __attribute__((unused)) struct cmdline *cl,
2420 __attribute__((unused)) void *data)
2422 struct cmd_config_thresh *res = parsed_result;
2424 if (!all_ports_stopped()) {
2425 printf("Please stop all ports first\n");
2429 if (!strcmp(res->name, "txpt"))
2430 tx_pthresh = res->value;
2431 else if(!strcmp(res->name, "txht"))
2432 tx_hthresh = res->value;
2433 else if(!strcmp(res->name, "txwt"))
2434 tx_wthresh = res->value;
2435 else if(!strcmp(res->name, "rxpt"))
2436 rx_pthresh = res->value;
2437 else if(!strcmp(res->name, "rxht"))
2438 rx_hthresh = res->value;
2439 else if(!strcmp(res->name, "rxwt"))
2440 rx_wthresh = res->value;
2442 printf("Unknown parameter\n");
2448 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2451 cmdline_parse_token_string_t cmd_config_thresh_port =
2452 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2453 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2454 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2455 cmdline_parse_token_string_t cmd_config_thresh_all =
2456 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2457 cmdline_parse_token_string_t cmd_config_thresh_name =
2458 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2459 "txpt#txht#txwt#rxpt#rxht#rxwt");
2460 cmdline_parse_token_num_t cmd_config_thresh_value =
2461 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2463 cmdline_parse_inst_t cmd_config_thresh = {
2464 .f = cmd_config_thresh_parsed,
2466 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2468 (void *)&cmd_config_thresh_port,
2469 (void *)&cmd_config_thresh_keyword,
2470 (void *)&cmd_config_thresh_all,
2471 (void *)&cmd_config_thresh_name,
2472 (void *)&cmd_config_thresh_value,
2477 /* *** configure free/rs threshold *** */
2478 struct cmd_config_threshold {
2479 cmdline_fixed_string_t port;
2480 cmdline_fixed_string_t keyword;
2481 cmdline_fixed_string_t all;
2482 cmdline_fixed_string_t name;
2487 cmd_config_threshold_parsed(void *parsed_result,
2488 __attribute__((unused)) struct cmdline *cl,
2489 __attribute__((unused)) void *data)
2491 struct cmd_config_threshold *res = parsed_result;
2493 if (!all_ports_stopped()) {
2494 printf("Please stop all ports first\n");
2498 if (!strcmp(res->name, "txfreet"))
2499 tx_free_thresh = res->value;
2500 else if (!strcmp(res->name, "txrst"))
2501 tx_rs_thresh = res->value;
2502 else if (!strcmp(res->name, "rxfreet"))
2503 rx_free_thresh = res->value;
2505 printf("Unknown parameter\n");
2511 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2514 cmdline_parse_token_string_t cmd_config_threshold_port =
2515 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2516 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2517 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2519 cmdline_parse_token_string_t cmd_config_threshold_all =
2520 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2521 cmdline_parse_token_string_t cmd_config_threshold_name =
2522 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2523 "txfreet#txrst#rxfreet");
2524 cmdline_parse_token_num_t cmd_config_threshold_value =
2525 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2527 cmdline_parse_inst_t cmd_config_threshold = {
2528 .f = cmd_config_threshold_parsed,
2530 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2532 (void *)&cmd_config_threshold_port,
2533 (void *)&cmd_config_threshold_keyword,
2534 (void *)&cmd_config_threshold_all,
2535 (void *)&cmd_config_threshold_name,
2536 (void *)&cmd_config_threshold_value,
2542 struct cmd_stop_result {
2543 cmdline_fixed_string_t stop;
2546 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2547 __attribute__((unused)) struct cmdline *cl,
2548 __attribute__((unused)) void *data)
2550 stop_packet_forwarding();
2553 cmdline_parse_token_string_t cmd_stop_stop =
2554 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2556 cmdline_parse_inst_t cmd_stop = {
2557 .f = cmd_stop_parsed,
2559 .help_str = "stop: Stop packet forwarding",
2561 (void *)&cmd_stop_stop,
2566 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2569 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2570 unsigned int *parsed_items, int check_unique_values)
2572 unsigned int nb_item;
2580 * First parse all items in the list and store their value.
2585 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2587 if ((c >= '0') && (c <= '9')) {
2588 value = (unsigned int) (value * 10 + (c - '0'));
2593 printf("character %c is not a decimal digit\n", c);
2597 printf("No valid value before comma\n");
2600 if (nb_item < max_items) {
2601 parsed_items[nb_item] = value;
2607 if (nb_item >= max_items) {
2608 printf("Number of %s = %u > %u (maximum items)\n",
2609 item_name, nb_item + 1, max_items);
2612 parsed_items[nb_item++] = value;
2613 if (! check_unique_values)
2617 * Then, check that all values in the list are differents.
2618 * No optimization here...
2620 for (i = 0; i < nb_item; i++) {
2621 for (j = i + 1; j < nb_item; j++) {
2622 if (parsed_items[j] == parsed_items[i]) {
2623 printf("duplicated %s %u at index %u and %u\n",
2624 item_name, parsed_items[i], i, j);
2632 struct cmd_set_list_result {
2633 cmdline_fixed_string_t cmd_keyword;
2634 cmdline_fixed_string_t list_name;
2635 cmdline_fixed_string_t list_of_items;
2638 static void cmd_set_list_parsed(void *parsed_result,
2639 __attribute__((unused)) struct cmdline *cl,
2640 __attribute__((unused)) void *data)
2642 struct cmd_set_list_result *res;
2644 unsigned int lcorelist[RTE_MAX_LCORE];
2645 unsigned int portlist[RTE_MAX_ETHPORTS];
2647 unsigned int nb_item;
2649 if (test_done == 0) {
2650 printf("Please stop forwarding first\n");
2654 res = parsed_result;
2655 if (!strcmp(res->list_name, "corelist")) {
2656 nb_item = parse_item_list(res->list_of_items, "core",
2658 parsed_items.lcorelist, 1);
2660 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2665 if (!strcmp(res->list_name, "portlist")) {
2666 nb_item = parse_item_list(res->list_of_items, "port",
2668 parsed_items.portlist, 1);
2670 set_fwd_ports_list(parsed_items.portlist, nb_item);
2676 cmdline_parse_token_string_t cmd_set_list_keyword =
2677 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2679 cmdline_parse_token_string_t cmd_set_list_name =
2680 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2681 "corelist#portlist");
2682 cmdline_parse_token_string_t cmd_set_list_of_items =
2683 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2686 cmdline_parse_inst_t cmd_set_fwd_list = {
2687 .f = cmd_set_list_parsed,
2689 .help_str = "set corelist|portlist <list0[,list1]*>",
2691 (void *)&cmd_set_list_keyword,
2692 (void *)&cmd_set_list_name,
2693 (void *)&cmd_set_list_of_items,
2698 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2700 struct cmd_setmask_result {
2701 cmdline_fixed_string_t set;
2702 cmdline_fixed_string_t mask;
2706 static void cmd_set_mask_parsed(void *parsed_result,
2707 __attribute__((unused)) struct cmdline *cl,
2708 __attribute__((unused)) void *data)
2710 struct cmd_setmask_result *res = parsed_result;
2712 if (test_done == 0) {
2713 printf("Please stop forwarding first\n");
2716 if (!strcmp(res->mask, "coremask")) {
2717 set_fwd_lcores_mask(res->hexavalue);
2719 } else if (!strcmp(res->mask, "portmask")) {
2720 set_fwd_ports_mask(res->hexavalue);
2725 cmdline_parse_token_string_t cmd_setmask_set =
2726 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2727 cmdline_parse_token_string_t cmd_setmask_mask =
2728 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2729 "coremask#portmask");
2730 cmdline_parse_token_num_t cmd_setmask_value =
2731 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2733 cmdline_parse_inst_t cmd_set_fwd_mask = {
2734 .f = cmd_set_mask_parsed,
2736 .help_str = "set coremask|portmask <hexadecimal value>",
2738 (void *)&cmd_setmask_set,
2739 (void *)&cmd_setmask_mask,
2740 (void *)&cmd_setmask_value,
2746 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2748 struct cmd_set_result {
2749 cmdline_fixed_string_t set;
2750 cmdline_fixed_string_t what;
2754 static void cmd_set_parsed(void *parsed_result,
2755 __attribute__((unused)) struct cmdline *cl,
2756 __attribute__((unused)) void *data)
2758 struct cmd_set_result *res = parsed_result;
2759 if (!strcmp(res->what, "nbport")) {
2760 set_fwd_ports_number(res->value);
2762 } else if (!strcmp(res->what, "nbcore")) {
2763 set_fwd_lcores_number(res->value);
2765 } else if (!strcmp(res->what, "burst"))
2766 set_nb_pkt_per_burst(res->value);
2767 else if (!strcmp(res->what, "verbose"))
2768 set_verbose_level(res->value);
2771 cmdline_parse_token_string_t cmd_set_set =
2772 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2773 cmdline_parse_token_string_t cmd_set_what =
2774 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2775 "nbport#nbcore#burst#verbose");
2776 cmdline_parse_token_num_t cmd_set_value =
2777 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2779 cmdline_parse_inst_t cmd_set_numbers = {
2780 .f = cmd_set_parsed,
2782 .help_str = "set nbport|nbcore|burst|verbose <value>",
2784 (void *)&cmd_set_set,
2785 (void *)&cmd_set_what,
2786 (void *)&cmd_set_value,
2791 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2793 struct cmd_set_txpkts_result {
2794 cmdline_fixed_string_t cmd_keyword;
2795 cmdline_fixed_string_t txpkts;
2796 cmdline_fixed_string_t seg_lengths;
2800 cmd_set_txpkts_parsed(void *parsed_result,
2801 __attribute__((unused)) struct cmdline *cl,
2802 __attribute__((unused)) void *data)
2804 struct cmd_set_txpkts_result *res;
2805 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2806 unsigned int nb_segs;
2808 res = parsed_result;
2809 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2810 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2812 set_tx_pkt_segments(seg_lengths, nb_segs);
2815 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2816 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2817 cmd_keyword, "set");
2818 cmdline_parse_token_string_t cmd_set_txpkts_name =
2819 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2821 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2822 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2825 cmdline_parse_inst_t cmd_set_txpkts = {
2826 .f = cmd_set_txpkts_parsed,
2828 .help_str = "set txpkts <len0[,len1]*>",
2830 (void *)&cmd_set_txpkts_keyword,
2831 (void *)&cmd_set_txpkts_name,
2832 (void *)&cmd_set_txpkts_lengths,
2837 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2839 struct cmd_set_txsplit_result {
2840 cmdline_fixed_string_t cmd_keyword;
2841 cmdline_fixed_string_t txsplit;
2842 cmdline_fixed_string_t mode;
2846 cmd_set_txsplit_parsed(void *parsed_result,
2847 __attribute__((unused)) struct cmdline *cl,
2848 __attribute__((unused)) void *data)
2850 struct cmd_set_txsplit_result *res;
2852 res = parsed_result;
2853 set_tx_pkt_split(res->mode);
2856 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2857 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2858 cmd_keyword, "set");
2859 cmdline_parse_token_string_t cmd_set_txsplit_name =
2860 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2861 txsplit, "txsplit");
2862 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2863 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2866 cmdline_parse_inst_t cmd_set_txsplit = {
2867 .f = cmd_set_txsplit_parsed,
2869 .help_str = "set txsplit on|off|rand",
2871 (void *)&cmd_set_txsplit_keyword,
2872 (void *)&cmd_set_txsplit_name,
2873 (void *)&cmd_set_txsplit_mode,
2878 /* *** CONFIG TX QUEUE FLAGS *** */
2880 struct cmd_config_txqflags_result {
2881 cmdline_fixed_string_t port;
2882 cmdline_fixed_string_t config;
2883 cmdline_fixed_string_t all;
2884 cmdline_fixed_string_t what;
2888 static void cmd_config_txqflags_parsed(void *parsed_result,
2889 __attribute__((unused)) struct cmdline *cl,
2890 __attribute__((unused)) void *data)
2892 struct cmd_config_txqflags_result *res = parsed_result;
2894 if (!all_ports_stopped()) {
2895 printf("Please stop all ports first\n");
2899 if (strcmp(res->what, "txqflags")) {
2900 printf("Unknown parameter\n");
2904 if (res->hexvalue >= 0) {
2905 txq_flags = res->hexvalue;
2907 printf("txqflags must be >= 0\n");
2913 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2916 cmdline_parse_token_string_t cmd_config_txqflags_port =
2917 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2919 cmdline_parse_token_string_t cmd_config_txqflags_config =
2920 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2922 cmdline_parse_token_string_t cmd_config_txqflags_all =
2923 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2925 cmdline_parse_token_string_t cmd_config_txqflags_what =
2926 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2928 cmdline_parse_token_num_t cmd_config_txqflags_value =
2929 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2932 cmdline_parse_inst_t cmd_config_txqflags = {
2933 .f = cmd_config_txqflags_parsed,
2935 .help_str = "port config all txqflags <value>",
2937 (void *)&cmd_config_txqflags_port,
2938 (void *)&cmd_config_txqflags_config,
2939 (void *)&cmd_config_txqflags_all,
2940 (void *)&cmd_config_txqflags_what,
2941 (void *)&cmd_config_txqflags_value,
2946 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2947 struct cmd_rx_vlan_filter_all_result {
2948 cmdline_fixed_string_t rx_vlan;
2949 cmdline_fixed_string_t what;
2950 cmdline_fixed_string_t all;
2955 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2956 __attribute__((unused)) struct cmdline *cl,
2957 __attribute__((unused)) void *data)
2959 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2961 if (!strcmp(res->what, "add"))
2962 rx_vlan_all_filter_set(res->port_id, 1);
2964 rx_vlan_all_filter_set(res->port_id, 0);
2967 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2968 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2969 rx_vlan, "rx_vlan");
2970 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2971 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2973 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2974 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2976 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2977 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2980 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2981 .f = cmd_rx_vlan_filter_all_parsed,
2983 .help_str = "rx_vlan add|rm all <port_id>: "
2984 "Add/Remove all identifiers to/from the set of VLAN "
2985 "identifiers filtered by a port",
2987 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2988 (void *)&cmd_rx_vlan_filter_all_what,
2989 (void *)&cmd_rx_vlan_filter_all_all,
2990 (void *)&cmd_rx_vlan_filter_all_portid,
2995 /* *** VLAN OFFLOAD SET ON A PORT *** */
2996 struct cmd_vlan_offload_result {
2997 cmdline_fixed_string_t vlan;
2998 cmdline_fixed_string_t set;
2999 cmdline_fixed_string_t vlan_type;
3000 cmdline_fixed_string_t what;
3001 cmdline_fixed_string_t on;
3002 cmdline_fixed_string_t port_id;
3006 cmd_vlan_offload_parsed(void *parsed_result,
3007 __attribute__((unused)) struct cmdline *cl,
3008 __attribute__((unused)) void *data)
3011 struct cmd_vlan_offload_result *res = parsed_result;
3014 portid_t port_id = 0;
3018 len = strnlen(str, STR_TOKEN_SIZE);
3020 /* Get port_id first */
3028 tmp = strtoul(str, NULL, 0);
3029 /* If port_id greater that what portid_t can represent, return */
3030 if(tmp >= RTE_MAX_ETHPORTS)
3032 port_id = (portid_t)tmp;
3034 if (!strcmp(res->on, "on"))
3039 if (!strcmp(res->what, "strip"))
3040 rx_vlan_strip_set(port_id, on);
3041 else if(!strcmp(res->what, "stripq")){
3042 uint16_t queue_id = 0;
3044 /* No queue_id, return */
3046 printf("must specify (port,queue_id)\n");
3049 tmp = strtoul(str + i + 1, NULL, 0);
3050 /* If queue_id greater that what 16-bits can represent, return */
3054 queue_id = (uint16_t)tmp;
3055 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3057 else if (!strcmp(res->what, "filter"))
3058 rx_vlan_filter_set(port_id, on);
3060 vlan_extend_set(port_id, on);
3065 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3066 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3068 cmdline_parse_token_string_t cmd_vlan_offload_set =
3069 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3071 cmdline_parse_token_string_t cmd_vlan_offload_what =
3072 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3073 what, "strip#filter#qinq#stripq");
3074 cmdline_parse_token_string_t cmd_vlan_offload_on =
3075 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3077 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3078 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3081 cmdline_parse_inst_t cmd_vlan_offload = {
3082 .f = cmd_vlan_offload_parsed,
3084 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3085 "<port_id[,queue_id]>: "
3086 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3088 (void *)&cmd_vlan_offload_vlan,
3089 (void *)&cmd_vlan_offload_set,
3090 (void *)&cmd_vlan_offload_what,
3091 (void *)&cmd_vlan_offload_on,
3092 (void *)&cmd_vlan_offload_portid,
3097 /* *** VLAN TPID SET ON A PORT *** */
3098 struct cmd_vlan_tpid_result {
3099 cmdline_fixed_string_t vlan;
3100 cmdline_fixed_string_t set;
3101 cmdline_fixed_string_t vlan_type;
3102 cmdline_fixed_string_t what;
3108 cmd_vlan_tpid_parsed(void *parsed_result,
3109 __attribute__((unused)) struct cmdline *cl,
3110 __attribute__((unused)) void *data)
3112 struct cmd_vlan_tpid_result *res = parsed_result;
3113 enum rte_vlan_type vlan_type;
3115 if (!strcmp(res->vlan_type, "inner"))
3116 vlan_type = ETH_VLAN_TYPE_INNER;
3117 else if (!strcmp(res->vlan_type, "outer"))
3118 vlan_type = ETH_VLAN_TYPE_OUTER;
3120 printf("Unknown vlan type\n");
3123 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3126 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3127 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3129 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3130 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3132 cmdline_parse_token_string_t cmd_vlan_type =
3133 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3134 vlan_type, "inner#outer");
3135 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3136 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3138 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3139 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3141 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3142 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3145 cmdline_parse_inst_t cmd_vlan_tpid = {
3146 .f = cmd_vlan_tpid_parsed,
3148 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3149 "Set the VLAN Ether type",
3151 (void *)&cmd_vlan_tpid_vlan,
3152 (void *)&cmd_vlan_tpid_set,
3153 (void *)&cmd_vlan_type,
3154 (void *)&cmd_vlan_tpid_what,
3155 (void *)&cmd_vlan_tpid_tpid,
3156 (void *)&cmd_vlan_tpid_portid,
3161 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3162 struct cmd_rx_vlan_filter_result {
3163 cmdline_fixed_string_t rx_vlan;
3164 cmdline_fixed_string_t what;
3170 cmd_rx_vlan_filter_parsed(void *parsed_result,
3171 __attribute__((unused)) struct cmdline *cl,
3172 __attribute__((unused)) void *data)
3174 struct cmd_rx_vlan_filter_result *res = parsed_result;
3176 if (!strcmp(res->what, "add"))
3177 rx_vft_set(res->port_id, res->vlan_id, 1);
3179 rx_vft_set(res->port_id, res->vlan_id, 0);
3182 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3183 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3184 rx_vlan, "rx_vlan");
3185 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3186 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3188 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3189 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3191 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3192 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3195 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3196 .f = cmd_rx_vlan_filter_parsed,
3198 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3199 "Add/Remove a VLAN identifier to/from the set of VLAN "
3200 "identifiers filtered by a port",
3202 (void *)&cmd_rx_vlan_filter_rx_vlan,
3203 (void *)&cmd_rx_vlan_filter_what,
3204 (void *)&cmd_rx_vlan_filter_vlanid,
3205 (void *)&cmd_rx_vlan_filter_portid,
3210 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3211 struct cmd_tx_vlan_set_result {
3212 cmdline_fixed_string_t tx_vlan;
3213 cmdline_fixed_string_t set;
3219 cmd_tx_vlan_set_parsed(void *parsed_result,
3220 __attribute__((unused)) struct cmdline *cl,
3221 __attribute__((unused)) void *data)
3223 struct cmd_tx_vlan_set_result *res = parsed_result;
3225 tx_vlan_set(res->port_id, res->vlan_id);
3228 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3229 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3230 tx_vlan, "tx_vlan");
3231 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3232 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3234 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3235 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3237 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3238 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3241 cmdline_parse_inst_t cmd_tx_vlan_set = {
3242 .f = cmd_tx_vlan_set_parsed,
3244 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3245 "Enable hardware insertion of a single VLAN header "
3246 "with a given TAG Identifier in packets sent on a port",
3248 (void *)&cmd_tx_vlan_set_tx_vlan,
3249 (void *)&cmd_tx_vlan_set_set,
3250 (void *)&cmd_tx_vlan_set_portid,
3251 (void *)&cmd_tx_vlan_set_vlanid,
3256 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3257 struct cmd_tx_vlan_set_qinq_result {
3258 cmdline_fixed_string_t tx_vlan;
3259 cmdline_fixed_string_t set;
3262 uint16_t vlan_id_outer;
3266 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3267 __attribute__((unused)) struct cmdline *cl,
3268 __attribute__((unused)) void *data)
3270 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3272 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3275 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3276 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3277 tx_vlan, "tx_vlan");
3278 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3279 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3281 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3282 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3284 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3285 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3287 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3288 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3289 vlan_id_outer, UINT16);
3291 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3292 .f = cmd_tx_vlan_set_qinq_parsed,
3294 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3295 "Enable hardware insertion of double VLAN header "
3296 "with given TAG Identifiers in packets sent on a port",
3298 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3299 (void *)&cmd_tx_vlan_set_qinq_set,
3300 (void *)&cmd_tx_vlan_set_qinq_portid,
3301 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3302 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3307 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3308 struct cmd_tx_vlan_set_pvid_result {
3309 cmdline_fixed_string_t tx_vlan;
3310 cmdline_fixed_string_t set;
3311 cmdline_fixed_string_t pvid;
3314 cmdline_fixed_string_t mode;
3318 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3319 __attribute__((unused)) struct cmdline *cl,
3320 __attribute__((unused)) void *data)
3322 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3324 if (strcmp(res->mode, "on") == 0)
3325 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3327 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3330 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3331 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3332 tx_vlan, "tx_vlan");
3333 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3334 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3336 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3337 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3339 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3340 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3342 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3343 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3345 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3346 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3349 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3350 .f = cmd_tx_vlan_set_pvid_parsed,
3352 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3354 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3355 (void *)&cmd_tx_vlan_set_pvid_set,
3356 (void *)&cmd_tx_vlan_set_pvid_pvid,
3357 (void *)&cmd_tx_vlan_set_pvid_port_id,
3358 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3359 (void *)&cmd_tx_vlan_set_pvid_mode,
3364 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3365 struct cmd_tx_vlan_reset_result {
3366 cmdline_fixed_string_t tx_vlan;
3367 cmdline_fixed_string_t reset;
3372 cmd_tx_vlan_reset_parsed(void *parsed_result,
3373 __attribute__((unused)) struct cmdline *cl,
3374 __attribute__((unused)) void *data)
3376 struct cmd_tx_vlan_reset_result *res = parsed_result;
3378 tx_vlan_reset(res->port_id);
3381 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3382 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3383 tx_vlan, "tx_vlan");
3384 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3385 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3387 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3388 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3391 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3392 .f = cmd_tx_vlan_reset_parsed,
3394 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3395 "VLAN header in packets sent on a port",
3397 (void *)&cmd_tx_vlan_reset_tx_vlan,
3398 (void *)&cmd_tx_vlan_reset_reset,
3399 (void *)&cmd_tx_vlan_reset_portid,
3405 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3406 struct cmd_csum_result {
3407 cmdline_fixed_string_t csum;
3408 cmdline_fixed_string_t mode;
3409 cmdline_fixed_string_t proto;
3410 cmdline_fixed_string_t hwsw;
3415 csum_show(int port_id)
3417 struct rte_eth_dev_info dev_info;
3420 ol_flags = ports[port_id].tx_ol_flags;
3421 printf("Parse tunnel is %s\n",
3422 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3423 printf("IP checksum offload is %s\n",
3424 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3425 printf("UDP checksum offload is %s\n",
3426 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3427 printf("TCP checksum offload is %s\n",
3428 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3429 printf("SCTP checksum offload is %s\n",
3430 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3431 printf("Outer-Ip checksum offload is %s\n",
3432 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3434 /* display warnings if configuration is not supported by the NIC */
3435 rte_eth_dev_info_get(port_id, &dev_info);
3436 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3437 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3438 printf("Warning: hardware IP checksum enabled but not "
3439 "supported by port %d\n", port_id);
3441 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3442 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3443 printf("Warning: hardware UDP checksum enabled but not "
3444 "supported by port %d\n", port_id);
3446 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3447 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3448 printf("Warning: hardware TCP checksum enabled but not "
3449 "supported by port %d\n", port_id);
3451 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3452 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3453 printf("Warning: hardware SCTP checksum enabled but not "
3454 "supported by port %d\n", port_id);
3456 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3457 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3458 printf("Warning: hardware outer IP checksum enabled but not "
3459 "supported by port %d\n", port_id);
3464 cmd_csum_parsed(void *parsed_result,
3465 __attribute__((unused)) struct cmdline *cl,
3466 __attribute__((unused)) void *data)
3468 struct cmd_csum_result *res = parsed_result;
3472 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3473 printf("invalid port %d\n", res->port_id);
3477 if (!strcmp(res->mode, "set")) {
3479 if (!strcmp(res->hwsw, "hw"))
3482 if (!strcmp(res->proto, "ip")) {
3483 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3484 } else if (!strcmp(res->proto, "udp")) {
3485 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3486 } else if (!strcmp(res->proto, "tcp")) {
3487 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3488 } else if (!strcmp(res->proto, "sctp")) {
3489 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3490 } else if (!strcmp(res->proto, "outer-ip")) {
3491 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3495 ports[res->port_id].tx_ol_flags |= mask;
3497 ports[res->port_id].tx_ol_flags &= (~mask);
3499 csum_show(res->port_id);
3502 cmdline_parse_token_string_t cmd_csum_csum =
3503 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3505 cmdline_parse_token_string_t cmd_csum_mode =
3506 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3508 cmdline_parse_token_string_t cmd_csum_proto =
3509 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3510 proto, "ip#tcp#udp#sctp#outer-ip");
3511 cmdline_parse_token_string_t cmd_csum_hwsw =
3512 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3514 cmdline_parse_token_num_t cmd_csum_portid =
3515 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3518 cmdline_parse_inst_t cmd_csum_set = {
3519 .f = cmd_csum_parsed,
3521 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3522 "Enable/Disable hardware calculation of L3/L4 checksum when "
3523 "using csum forward engine",
3525 (void *)&cmd_csum_csum,
3526 (void *)&cmd_csum_mode,
3527 (void *)&cmd_csum_proto,
3528 (void *)&cmd_csum_hwsw,
3529 (void *)&cmd_csum_portid,
3534 cmdline_parse_token_string_t cmd_csum_mode_show =
3535 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3538 cmdline_parse_inst_t cmd_csum_show = {
3539 .f = cmd_csum_parsed,
3541 .help_str = "csum show <port_id>: Show checksum offload configuration",
3543 (void *)&cmd_csum_csum,
3544 (void *)&cmd_csum_mode_show,
3545 (void *)&cmd_csum_portid,
3550 /* Enable/disable tunnel parsing */
3551 struct cmd_csum_tunnel_result {
3552 cmdline_fixed_string_t csum;
3553 cmdline_fixed_string_t parse;
3554 cmdline_fixed_string_t onoff;
3559 cmd_csum_tunnel_parsed(void *parsed_result,
3560 __attribute__((unused)) struct cmdline *cl,
3561 __attribute__((unused)) void *data)
3563 struct cmd_csum_tunnel_result *res = parsed_result;
3565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3568 if (!strcmp(res->onoff, "on"))
3569 ports[res->port_id].tx_ol_flags |=
3570 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3572 ports[res->port_id].tx_ol_flags &=
3573 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3575 csum_show(res->port_id);
3578 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3579 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3581 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3582 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3583 parse, "parse_tunnel");
3584 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3585 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3587 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3588 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3591 cmdline_parse_inst_t cmd_csum_tunnel = {
3592 .f = cmd_csum_tunnel_parsed,
3594 .help_str = "csum parse_tunnel on|off <port_id>: "
3595 "Enable/Disable parsing of tunnels for csum engine",
3597 (void *)&cmd_csum_tunnel_csum,
3598 (void *)&cmd_csum_tunnel_parse,
3599 (void *)&cmd_csum_tunnel_onoff,
3600 (void *)&cmd_csum_tunnel_portid,
3605 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3606 struct cmd_tso_set_result {
3607 cmdline_fixed_string_t tso;
3608 cmdline_fixed_string_t mode;
3614 cmd_tso_set_parsed(void *parsed_result,
3615 __attribute__((unused)) struct cmdline *cl,
3616 __attribute__((unused)) void *data)
3618 struct cmd_tso_set_result *res = parsed_result;
3619 struct rte_eth_dev_info dev_info;
3621 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3624 if (!strcmp(res->mode, "set"))
3625 ports[res->port_id].tso_segsz = res->tso_segsz;
3627 if (ports[res->port_id].tso_segsz == 0)
3628 printf("TSO for non-tunneled packets is disabled\n");
3630 printf("TSO segment size for non-tunneled packets is %d\n",
3631 ports[res->port_id].tso_segsz);
3633 /* display warnings if configuration is not supported by the NIC */
3634 rte_eth_dev_info_get(res->port_id, &dev_info);
3635 if ((ports[res->port_id].tso_segsz != 0) &&
3636 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3637 printf("Warning: TSO enabled but not "
3638 "supported by port %d\n", res->port_id);
3642 cmdline_parse_token_string_t cmd_tso_set_tso =
3643 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3645 cmdline_parse_token_string_t cmd_tso_set_mode =
3646 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3648 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3649 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3651 cmdline_parse_token_num_t cmd_tso_set_portid =
3652 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3655 cmdline_parse_inst_t cmd_tso_set = {
3656 .f = cmd_tso_set_parsed,
3658 .help_str = "tso set <tso_segsz> <port_id>: "
3659 "Set TSO segment size of non-tunneled packets for csum engine "
3662 (void *)&cmd_tso_set_tso,
3663 (void *)&cmd_tso_set_mode,
3664 (void *)&cmd_tso_set_tso_segsz,
3665 (void *)&cmd_tso_set_portid,
3670 cmdline_parse_token_string_t cmd_tso_show_mode =
3671 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3675 cmdline_parse_inst_t cmd_tso_show = {
3676 .f = cmd_tso_set_parsed,
3678 .help_str = "tso show <port_id>: "
3679 "Show TSO segment size of non-tunneled packets for csum engine",
3681 (void *)&cmd_tso_set_tso,
3682 (void *)&cmd_tso_show_mode,
3683 (void *)&cmd_tso_set_portid,
3688 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3689 struct cmd_tunnel_tso_set_result {
3690 cmdline_fixed_string_t tso;
3691 cmdline_fixed_string_t mode;
3697 check_tunnel_tso_nic_support(uint8_t port_id)
3699 struct rte_eth_dev_info dev_info;
3701 rte_eth_dev_info_get(port_id, &dev_info);
3702 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3703 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3704 "supported by port %d\n", port_id);
3705 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3706 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3707 "supported by port %d\n", port_id);
3708 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3709 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3710 "supported by port %d\n", port_id);
3711 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3712 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3713 "supported by port %d\n", port_id);
3717 cmd_tunnel_tso_set_parsed(void *parsed_result,
3718 __attribute__((unused)) struct cmdline *cl,
3719 __attribute__((unused)) void *data)
3721 struct cmd_tunnel_tso_set_result *res = parsed_result;
3723 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3726 if (!strcmp(res->mode, "set"))
3727 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3729 if (ports[res->port_id].tunnel_tso_segsz == 0)
3730 printf("TSO for tunneled packets is disabled\n");
3732 printf("TSO segment size for tunneled packets is %d\n",
3733 ports[res->port_id].tunnel_tso_segsz);
3735 /* Below conditions are needed to make it work:
3736 * (1) tunnel TSO is supported by the NIC;
3737 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3739 * (3) for tunneled pkts with outer L3 of IPv4,
3740 * "csum set outer-ip" must be set to hw, because after tso,
3741 * total_len of outer IP header is changed, and the checksum
3742 * of outer IP header calculated by sw should be wrong; that
3743 * is not necessary for IPv6 tunneled pkts because there's no
3744 * checksum in IP header anymore.
3746 check_tunnel_tso_nic_support(res->port_id);
3748 if (!(ports[res->port_id].tx_ol_flags &
3749 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3750 printf("Warning: csum parse_tunnel must be set "
3751 "so that tunneled packets are recognized\n");
3752 if (!(ports[res->port_id].tx_ol_flags &
3753 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3754 printf("Warning: csum set outer-ip must be set to hw "
3755 "if outer L3 is IPv4; not necessary for IPv6\n");
3759 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3760 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3762 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3763 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3765 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3766 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3768 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3769 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3772 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3773 .f = cmd_tunnel_tso_set_parsed,
3775 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3776 "Set TSO segment size of tunneled packets for csum engine "
3779 (void *)&cmd_tunnel_tso_set_tso,
3780 (void *)&cmd_tunnel_tso_set_mode,
3781 (void *)&cmd_tunnel_tso_set_tso_segsz,
3782 (void *)&cmd_tunnel_tso_set_portid,
3787 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3788 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3792 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3793 .f = cmd_tunnel_tso_set_parsed,
3795 .help_str = "tunnel_tso show <port_id> "
3796 "Show TSO segment size of tunneled packets for csum engine",
3798 (void *)&cmd_tunnel_tso_set_tso,
3799 (void *)&cmd_tunnel_tso_show_mode,
3800 (void *)&cmd_tunnel_tso_set_portid,
3805 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3806 struct cmd_set_flush_rx {
3807 cmdline_fixed_string_t set;
3808 cmdline_fixed_string_t flush_rx;
3809 cmdline_fixed_string_t mode;
3813 cmd_set_flush_rx_parsed(void *parsed_result,
3814 __attribute__((unused)) struct cmdline *cl,
3815 __attribute__((unused)) void *data)
3817 struct cmd_set_flush_rx *res = parsed_result;
3818 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3821 cmdline_parse_token_string_t cmd_setflushrx_set =
3822 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3824 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3826 flush_rx, "flush_rx");
3827 cmdline_parse_token_string_t cmd_setflushrx_mode =
3828 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3832 cmdline_parse_inst_t cmd_set_flush_rx = {
3833 .f = cmd_set_flush_rx_parsed,
3834 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3837 (void *)&cmd_setflushrx_set,
3838 (void *)&cmd_setflushrx_flush_rx,
3839 (void *)&cmd_setflushrx_mode,
3844 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3845 struct cmd_set_link_check {
3846 cmdline_fixed_string_t set;
3847 cmdline_fixed_string_t link_check;
3848 cmdline_fixed_string_t mode;
3852 cmd_set_link_check_parsed(void *parsed_result,
3853 __attribute__((unused)) struct cmdline *cl,
3854 __attribute__((unused)) void *data)
3856 struct cmd_set_link_check *res = parsed_result;
3857 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3860 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3861 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3863 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3864 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3865 link_check, "link_check");
3866 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3867 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3871 cmdline_parse_inst_t cmd_set_link_check = {
3872 .f = cmd_set_link_check_parsed,
3873 .help_str = "set link_check on|off: Enable/Disable link status check "
3874 "when starting/stopping a port",
3877 (void *)&cmd_setlinkcheck_set,
3878 (void *)&cmd_setlinkcheck_link_check,
3879 (void *)&cmd_setlinkcheck_mode,
3884 #ifdef RTE_NIC_BYPASS
3885 /* *** SET NIC BYPASS MODE *** */
3886 struct cmd_set_bypass_mode_result {
3887 cmdline_fixed_string_t set;
3888 cmdline_fixed_string_t bypass;
3889 cmdline_fixed_string_t mode;
3890 cmdline_fixed_string_t value;
3895 cmd_set_bypass_mode_parsed(void *parsed_result,
3896 __attribute__((unused)) struct cmdline *cl,
3897 __attribute__((unused)) void *data)
3899 struct cmd_set_bypass_mode_result *res = parsed_result;
3900 portid_t port_id = res->port_id;
3901 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3903 if (!strcmp(res->value, "bypass"))
3904 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3905 else if (!strcmp(res->value, "isolate"))
3906 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3908 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3910 /* Set the bypass mode for the relevant port. */
3911 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3912 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3916 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3919 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3920 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3922 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3923 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3925 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3926 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3927 value, "normal#bypass#isolate");
3928 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3929 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3932 cmdline_parse_inst_t cmd_set_bypass_mode = {
3933 .f = cmd_set_bypass_mode_parsed,
3934 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3935 "Set the NIC bypass mode for port_id",
3938 (void *)&cmd_setbypass_mode_set,
3939 (void *)&cmd_setbypass_mode_bypass,
3940 (void *)&cmd_setbypass_mode_mode,
3941 (void *)&cmd_setbypass_mode_value,
3942 (void *)&cmd_setbypass_mode_port,
3947 /* *** SET NIC BYPASS EVENT *** */
3948 struct cmd_set_bypass_event_result {
3949 cmdline_fixed_string_t set;
3950 cmdline_fixed_string_t bypass;
3951 cmdline_fixed_string_t event;
3952 cmdline_fixed_string_t event_value;
3953 cmdline_fixed_string_t mode;
3954 cmdline_fixed_string_t mode_value;
3959 cmd_set_bypass_event_parsed(void *parsed_result,
3960 __attribute__((unused)) struct cmdline *cl,
3961 __attribute__((unused)) void *data)
3964 struct cmd_set_bypass_event_result *res = parsed_result;
3965 portid_t port_id = res->port_id;
3966 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3967 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3969 if (!strcmp(res->event_value, "timeout"))
3970 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3971 else if (!strcmp(res->event_value, "os_on"))
3972 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3973 else if (!strcmp(res->event_value, "os_off"))
3974 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3975 else if (!strcmp(res->event_value, "power_on"))
3976 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3977 else if (!strcmp(res->event_value, "power_off"))
3978 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3980 bypass_event = RTE_BYPASS_EVENT_NONE;
3982 if (!strcmp(res->mode_value, "bypass"))
3983 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3984 else if (!strcmp(res->mode_value, "isolate"))
3985 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3987 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3989 /* Set the watchdog timeout. */
3990 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3993 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3994 (rc = rte_eth_dev_wd_timeout_store(port_id,
3995 bypass_timeout)) != 0) {
3996 printf("Failed to set timeout value %u "
3997 "for port %d, errto code: %d.\n",
3998 bypass_timeout, port_id, rc);
4002 /* Set the bypass event to transition to bypass mode. */
4003 if (0 != rte_eth_dev_bypass_event_store(port_id,
4004 bypass_event, bypass_mode)) {
4005 printf("\t Failed to set bypass event for port = %d.\n", port_id);
4010 cmdline_parse_token_string_t cmd_setbypass_event_set =
4011 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4013 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4014 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4016 cmdline_parse_token_string_t cmd_setbypass_event_event =
4017 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4019 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4020 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4021 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4022 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4023 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4025 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4026 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4027 mode_value, "normal#bypass#isolate");
4028 cmdline_parse_token_num_t cmd_setbypass_event_port =
4029 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4032 cmdline_parse_inst_t cmd_set_bypass_event = {
4033 .f = cmd_set_bypass_event_parsed,
4034 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4035 "power_off mode normal|bypass|isolate <port_id>: "
4036 "Set the NIC bypass event mode for port_id",
4039 (void *)&cmd_setbypass_event_set,
4040 (void *)&cmd_setbypass_event_bypass,
4041 (void *)&cmd_setbypass_event_event,
4042 (void *)&cmd_setbypass_event_event_value,
4043 (void *)&cmd_setbypass_event_mode,
4044 (void *)&cmd_setbypass_event_mode_value,
4045 (void *)&cmd_setbypass_event_port,
4051 /* *** SET NIC BYPASS TIMEOUT *** */
4052 struct cmd_set_bypass_timeout_result {
4053 cmdline_fixed_string_t set;
4054 cmdline_fixed_string_t bypass;
4055 cmdline_fixed_string_t timeout;
4056 cmdline_fixed_string_t value;
4060 cmd_set_bypass_timeout_parsed(void *parsed_result,
4061 __attribute__((unused)) struct cmdline *cl,
4062 __attribute__((unused)) void *data)
4064 struct cmd_set_bypass_timeout_result *res = parsed_result;
4066 if (!strcmp(res->value, "1.5"))
4067 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4068 else if (!strcmp(res->value, "2"))
4069 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4070 else if (!strcmp(res->value, "3"))
4071 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4072 else if (!strcmp(res->value, "4"))
4073 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4074 else if (!strcmp(res->value, "8"))
4075 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4076 else if (!strcmp(res->value, "16"))
4077 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4078 else if (!strcmp(res->value, "32"))
4079 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4081 bypass_timeout = RTE_BYPASS_TMT_OFF;
4084 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4085 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4087 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4088 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4090 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4091 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4092 timeout, "timeout");
4093 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4094 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4095 value, "0#1.5#2#3#4#8#16#32");
4097 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4098 .f = cmd_set_bypass_timeout_parsed,
4099 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4100 "Set the NIC bypass watchdog timeout in seconds",
4103 (void *)&cmd_setbypass_timeout_set,
4104 (void *)&cmd_setbypass_timeout_bypass,
4105 (void *)&cmd_setbypass_timeout_timeout,
4106 (void *)&cmd_setbypass_timeout_value,
4111 /* *** SHOW NIC BYPASS MODE *** */
4112 struct cmd_show_bypass_config_result {
4113 cmdline_fixed_string_t show;
4114 cmdline_fixed_string_t bypass;
4115 cmdline_fixed_string_t config;
4120 cmd_show_bypass_config_parsed(void *parsed_result,
4121 __attribute__((unused)) struct cmdline *cl,
4122 __attribute__((unused)) void *data)
4124 struct cmd_show_bypass_config_result *res = parsed_result;
4125 uint32_t event_mode;
4126 uint32_t bypass_mode;
4127 portid_t port_id = res->port_id;
4128 uint32_t timeout = bypass_timeout;
4131 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4132 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4133 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4134 {"UNKNOWN", "normal", "bypass", "isolate"};
4135 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4142 int num_events = (sizeof events) / (sizeof events[0]);
4144 /* Display the bypass mode.*/
4145 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4146 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4150 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4151 bypass_mode = RTE_BYPASS_MODE_NONE;
4153 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4156 /* Display the bypass timeout.*/
4157 if (!RTE_BYPASS_TMT_VALID(timeout))
4158 timeout = RTE_BYPASS_TMT_OFF;
4160 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4162 /* Display the bypass events and associated modes. */
4163 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4165 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4166 printf("\tFailed to get bypass mode for event = %s\n",
4169 if (!RTE_BYPASS_MODE_VALID(event_mode))
4170 event_mode = RTE_BYPASS_MODE_NONE;
4172 printf("\tbypass event: %-16s = %s\n", events[i],
4178 cmdline_parse_token_string_t cmd_showbypass_config_show =
4179 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4181 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4182 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4184 cmdline_parse_token_string_t cmd_showbypass_config_config =
4185 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4187 cmdline_parse_token_num_t cmd_showbypass_config_port =
4188 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4191 cmdline_parse_inst_t cmd_show_bypass_config = {
4192 .f = cmd_show_bypass_config_parsed,
4193 .help_str = "show bypass config <port_id>: "
4194 "Show the NIC bypass config for port_id",
4197 (void *)&cmd_showbypass_config_show,
4198 (void *)&cmd_showbypass_config_bypass,
4199 (void *)&cmd_showbypass_config_config,
4200 (void *)&cmd_showbypass_config_port,
4206 #ifdef RTE_LIBRTE_PMD_BOND
4207 /* *** SET BONDING MODE *** */
4208 struct cmd_set_bonding_mode_result {
4209 cmdline_fixed_string_t set;
4210 cmdline_fixed_string_t bonding;
4211 cmdline_fixed_string_t mode;
4216 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4217 __attribute__((unused)) struct cmdline *cl,
4218 __attribute__((unused)) void *data)
4220 struct cmd_set_bonding_mode_result *res = parsed_result;
4221 portid_t port_id = res->port_id;
4223 /* Set the bonding mode for the relevant port. */
4224 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4225 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4228 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4229 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4231 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4232 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4233 bonding, "bonding");
4234 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4235 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4237 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4238 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4240 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4241 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4244 cmdline_parse_inst_t cmd_set_bonding_mode = {
4245 .f = cmd_set_bonding_mode_parsed,
4246 .help_str = "set bonding mode <mode_value> <port_id>: "
4247 "Set the bonding mode for port_id",
4250 (void *) &cmd_setbonding_mode_set,
4251 (void *) &cmd_setbonding_mode_bonding,
4252 (void *) &cmd_setbonding_mode_mode,
4253 (void *) &cmd_setbonding_mode_value,
4254 (void *) &cmd_setbonding_mode_port,
4259 /* *** SET BALANCE XMIT POLICY *** */
4260 struct cmd_set_bonding_balance_xmit_policy_result {
4261 cmdline_fixed_string_t set;
4262 cmdline_fixed_string_t bonding;
4263 cmdline_fixed_string_t balance_xmit_policy;
4265 cmdline_fixed_string_t policy;
4268 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4269 __attribute__((unused)) struct cmdline *cl,
4270 __attribute__((unused)) void *data)
4272 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4273 portid_t port_id = res->port_id;
4276 if (!strcmp(res->policy, "l2")) {
4277 policy = BALANCE_XMIT_POLICY_LAYER2;
4278 } else if (!strcmp(res->policy, "l23")) {
4279 policy = BALANCE_XMIT_POLICY_LAYER23;
4280 } else if (!strcmp(res->policy, "l34")) {
4281 policy = BALANCE_XMIT_POLICY_LAYER34;
4283 printf("\t Invalid xmit policy selection");
4287 /* Set the bonding mode for the relevant port. */
4288 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4289 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4294 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4295 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4297 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4298 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4299 bonding, "bonding");
4300 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4301 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4302 balance_xmit_policy, "balance_xmit_policy");
4303 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4304 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4306 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4307 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4308 policy, "l2#l23#l34");
4310 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4311 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4312 .help_str = "set bonding balance_xmit_policy <port_id> "
4314 "Set the bonding balance_xmit_policy for port_id",
4317 (void *)&cmd_setbonding_balance_xmit_policy_set,
4318 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4319 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4320 (void *)&cmd_setbonding_balance_xmit_policy_port,
4321 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4326 /* *** SHOW NIC BONDING CONFIGURATION *** */
4327 struct cmd_show_bonding_config_result {
4328 cmdline_fixed_string_t show;
4329 cmdline_fixed_string_t bonding;
4330 cmdline_fixed_string_t config;
4334 static void cmd_show_bonding_config_parsed(void *parsed_result,
4335 __attribute__((unused)) struct cmdline *cl,
4336 __attribute__((unused)) void *data)
4338 struct cmd_show_bonding_config_result *res = parsed_result;
4340 uint8_t slaves[RTE_MAX_ETHPORTS];
4341 int num_slaves, num_active_slaves;
4344 portid_t port_id = res->port_id;
4346 /* Display the bonding mode.*/
4347 bonding_mode = rte_eth_bond_mode_get(port_id);
4348 if (bonding_mode < 0) {
4349 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4352 printf("\tBonding mode: %d\n", bonding_mode);
4354 if (bonding_mode == BONDING_MODE_BALANCE) {
4355 int balance_xmit_policy;
4357 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4358 if (balance_xmit_policy < 0) {
4359 printf("\tFailed to get balance xmit policy for port = %d\n",
4363 printf("\tBalance Xmit Policy: ");
4365 switch (balance_xmit_policy) {
4366 case BALANCE_XMIT_POLICY_LAYER2:
4367 printf("BALANCE_XMIT_POLICY_LAYER2");
4369 case BALANCE_XMIT_POLICY_LAYER23:
4370 printf("BALANCE_XMIT_POLICY_LAYER23");
4372 case BALANCE_XMIT_POLICY_LAYER34:
4373 printf("BALANCE_XMIT_POLICY_LAYER34");
4380 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4382 if (num_slaves < 0) {
4383 printf("\tFailed to get slave list for port = %d\n", port_id);
4386 if (num_slaves > 0) {
4387 printf("\tSlaves (%d): [", num_slaves);
4388 for (i = 0; i < num_slaves - 1; i++)
4389 printf("%d ", slaves[i]);
4391 printf("%d]\n", slaves[num_slaves - 1]);
4393 printf("\tSlaves: []\n");
4397 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4400 if (num_active_slaves < 0) {
4401 printf("\tFailed to get active slave list for port = %d\n", port_id);
4404 if (num_active_slaves > 0) {
4405 printf("\tActive Slaves (%d): [", num_active_slaves);
4406 for (i = 0; i < num_active_slaves - 1; i++)
4407 printf("%d ", slaves[i]);
4409 printf("%d]\n", slaves[num_active_slaves - 1]);
4412 printf("\tActive Slaves: []\n");
4416 primary_id = rte_eth_bond_primary_get(port_id);
4417 if (primary_id < 0) {
4418 printf("\tFailed to get primary slave for port = %d\n", port_id);
4421 printf("\tPrimary: [%d]\n", primary_id);
4425 cmdline_parse_token_string_t cmd_showbonding_config_show =
4426 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4428 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4429 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4430 bonding, "bonding");
4431 cmdline_parse_token_string_t cmd_showbonding_config_config =
4432 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4434 cmdline_parse_token_num_t cmd_showbonding_config_port =
4435 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4438 cmdline_parse_inst_t cmd_show_bonding_config = {
4439 .f = cmd_show_bonding_config_parsed,
4440 .help_str = "show bonding config <port_id>: "
4441 "Show the bonding config for port_id",
4444 (void *)&cmd_showbonding_config_show,
4445 (void *)&cmd_showbonding_config_bonding,
4446 (void *)&cmd_showbonding_config_config,
4447 (void *)&cmd_showbonding_config_port,
4452 /* *** SET BONDING PRIMARY *** */
4453 struct cmd_set_bonding_primary_result {
4454 cmdline_fixed_string_t set;
4455 cmdline_fixed_string_t bonding;
4456 cmdline_fixed_string_t primary;
4461 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4462 __attribute__((unused)) struct cmdline *cl,
4463 __attribute__((unused)) void *data)
4465 struct cmd_set_bonding_primary_result *res = parsed_result;
4466 portid_t master_port_id = res->port_id;
4467 portid_t slave_port_id = res->slave_id;
4469 /* Set the primary slave for a bonded device. */
4470 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4471 printf("\t Failed to set primary slave for port = %d.\n",
4478 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4479 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4481 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4482 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4483 bonding, "bonding");
4484 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4485 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4486 primary, "primary");
4487 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4488 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4490 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4491 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4494 cmdline_parse_inst_t cmd_set_bonding_primary = {
4495 .f = cmd_set_bonding_primary_parsed,
4496 .help_str = "set bonding primary <slave_id> <port_id>: "
4497 "Set the primary slave for port_id",
4500 (void *)&cmd_setbonding_primary_set,
4501 (void *)&cmd_setbonding_primary_bonding,
4502 (void *)&cmd_setbonding_primary_primary,
4503 (void *)&cmd_setbonding_primary_slave,
4504 (void *)&cmd_setbonding_primary_port,
4509 /* *** ADD SLAVE *** */
4510 struct cmd_add_bonding_slave_result {
4511 cmdline_fixed_string_t add;
4512 cmdline_fixed_string_t bonding;
4513 cmdline_fixed_string_t slave;
4518 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4519 __attribute__((unused)) struct cmdline *cl,
4520 __attribute__((unused)) void *data)
4522 struct cmd_add_bonding_slave_result *res = parsed_result;
4523 portid_t master_port_id = res->port_id;
4524 portid_t slave_port_id = res->slave_id;
4526 /* Set the primary slave for a bonded device. */
4527 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4528 printf("\t Failed to add slave %d to master port = %d.\n",
4529 slave_port_id, master_port_id);
4533 set_port_slave_flag(slave_port_id);
4536 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4537 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4539 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4540 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4541 bonding, "bonding");
4542 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4543 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4545 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4546 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4548 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4549 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4552 cmdline_parse_inst_t cmd_add_bonding_slave = {
4553 .f = cmd_add_bonding_slave_parsed,
4554 .help_str = "add bonding slave <slave_id> <port_id>: "
4555 "Add a slave device to a bonded device",
4558 (void *)&cmd_addbonding_slave_add,
4559 (void *)&cmd_addbonding_slave_bonding,
4560 (void *)&cmd_addbonding_slave_slave,
4561 (void *)&cmd_addbonding_slave_slaveid,
4562 (void *)&cmd_addbonding_slave_port,
4567 /* *** REMOVE SLAVE *** */
4568 struct cmd_remove_bonding_slave_result {
4569 cmdline_fixed_string_t remove;
4570 cmdline_fixed_string_t bonding;
4571 cmdline_fixed_string_t slave;
4576 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4577 __attribute__((unused)) struct cmdline *cl,
4578 __attribute__((unused)) void *data)
4580 struct cmd_remove_bonding_slave_result *res = parsed_result;
4581 portid_t master_port_id = res->port_id;
4582 portid_t slave_port_id = res->slave_id;
4584 /* Set the primary slave for a bonded device. */
4585 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4586 printf("\t Failed to remove slave %d from master port = %d.\n",
4587 slave_port_id, master_port_id);
4591 clear_port_slave_flag(slave_port_id);
4594 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4595 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4597 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4598 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4599 bonding, "bonding");
4600 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4601 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4603 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4604 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4606 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4607 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4610 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4611 .f = cmd_remove_bonding_slave_parsed,
4612 .help_str = "remove bonding slave <slave_id> <port_id>: "
4613 "Remove a slave device from a bonded device",
4616 (void *)&cmd_removebonding_slave_remove,
4617 (void *)&cmd_removebonding_slave_bonding,
4618 (void *)&cmd_removebonding_slave_slave,
4619 (void *)&cmd_removebonding_slave_slaveid,
4620 (void *)&cmd_removebonding_slave_port,
4625 /* *** CREATE BONDED DEVICE *** */
4626 struct cmd_create_bonded_device_result {
4627 cmdline_fixed_string_t create;
4628 cmdline_fixed_string_t bonded;
4629 cmdline_fixed_string_t device;
4634 static int bond_dev_num = 0;
4636 static void cmd_create_bonded_device_parsed(void *parsed_result,
4637 __attribute__((unused)) struct cmdline *cl,
4638 __attribute__((unused)) void *data)
4640 struct cmd_create_bonded_device_result *res = parsed_result;
4641 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4644 if (test_done == 0) {
4645 printf("Please stop forwarding first\n");
4649 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4652 /* Create a new bonded device. */
4653 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4655 printf("\t Failed to create bonded device.\n");
4658 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4661 /* Update number of ports */
4662 nb_ports = rte_eth_dev_count();
4663 reconfig(port_id, res->socket);
4664 rte_eth_promiscuous_enable(port_id);
4665 ports[port_id].enabled = 1;
4670 cmdline_parse_token_string_t cmd_createbonded_device_create =
4671 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4673 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4674 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4676 cmdline_parse_token_string_t cmd_createbonded_device_device =
4677 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4679 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4680 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4682 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4683 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4686 cmdline_parse_inst_t cmd_create_bonded_device = {
4687 .f = cmd_create_bonded_device_parsed,
4688 .help_str = "create bonded device <mode> <socket>: "
4689 "Create a new bonded device with specific bonding mode and socket",
4692 (void *)&cmd_createbonded_device_create,
4693 (void *)&cmd_createbonded_device_bonded,
4694 (void *)&cmd_createbonded_device_device,
4695 (void *)&cmd_createbonded_device_mode,
4696 (void *)&cmd_createbonded_device_socket,
4701 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4702 struct cmd_set_bond_mac_addr_result {
4703 cmdline_fixed_string_t set;
4704 cmdline_fixed_string_t bonding;
4705 cmdline_fixed_string_t mac_addr;
4707 struct ether_addr address;
4710 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4711 __attribute__((unused)) struct cmdline *cl,
4712 __attribute__((unused)) void *data)
4714 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4717 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4720 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4722 /* check the return value and print it if is < 0 */
4724 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4727 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4728 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4729 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4730 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4732 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4733 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4735 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4736 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4737 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4738 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4740 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4741 .f = cmd_set_bond_mac_addr_parsed,
4743 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4745 (void *)&cmd_set_bond_mac_addr_set,
4746 (void *)&cmd_set_bond_mac_addr_bonding,
4747 (void *)&cmd_set_bond_mac_addr_mac,
4748 (void *)&cmd_set_bond_mac_addr_portnum,
4749 (void *)&cmd_set_bond_mac_addr_addr,
4755 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4756 struct cmd_set_bond_mon_period_result {
4757 cmdline_fixed_string_t set;
4758 cmdline_fixed_string_t bonding;
4759 cmdline_fixed_string_t mon_period;
4764 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4765 __attribute__((unused)) struct cmdline *cl,
4766 __attribute__((unused)) void *data)
4768 struct cmd_set_bond_mon_period_result *res = parsed_result;
4771 if (res->port_num >= nb_ports) {
4772 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4776 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4778 /* check the return value and print it if is < 0 */
4780 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4783 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4784 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4786 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4787 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4788 bonding, "bonding");
4789 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4790 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4791 mon_period, "mon_period");
4792 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4793 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4795 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4796 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4799 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4800 .f = cmd_set_bond_mon_period_parsed,
4802 .help_str = "set bonding mon_period <port_id> <period_ms>",
4804 (void *)&cmd_set_bond_mon_period_set,
4805 (void *)&cmd_set_bond_mon_period_bonding,
4806 (void *)&cmd_set_bond_mon_period_mon_period,
4807 (void *)&cmd_set_bond_mon_period_portnum,
4808 (void *)&cmd_set_bond_mon_period_period_ms,
4813 #endif /* RTE_LIBRTE_PMD_BOND */
4815 /* *** SET FORWARDING MODE *** */
4816 struct cmd_set_fwd_mode_result {
4817 cmdline_fixed_string_t set;
4818 cmdline_fixed_string_t fwd;
4819 cmdline_fixed_string_t mode;
4822 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4823 __attribute__((unused)) struct cmdline *cl,
4824 __attribute__((unused)) void *data)
4826 struct cmd_set_fwd_mode_result *res = parsed_result;
4829 set_pkt_forwarding_mode(res->mode);
4832 cmdline_parse_token_string_t cmd_setfwd_set =
4833 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4834 cmdline_parse_token_string_t cmd_setfwd_fwd =
4835 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4836 cmdline_parse_token_string_t cmd_setfwd_mode =
4837 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4838 "" /* defined at init */);
4840 cmdline_parse_inst_t cmd_set_fwd_mode = {
4841 .f = cmd_set_fwd_mode_parsed,
4843 .help_str = NULL, /* defined at init */
4845 (void *)&cmd_setfwd_set,
4846 (void *)&cmd_setfwd_fwd,
4847 (void *)&cmd_setfwd_mode,
4852 static void cmd_set_fwd_mode_init(void)
4855 static char token[128];
4856 static char help[256];
4857 cmdline_parse_token_string_t *token_struct;
4859 modes = list_pkt_forwarding_modes();
4860 snprintf(help, sizeof(help), "set fwd %s: "
4861 "Set packet forwarding mode", modes);
4862 cmd_set_fwd_mode.help_str = help;
4864 /* string token separator is # */
4865 for (c = token; *modes != '\0'; modes++)
4870 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4871 token_struct->string_data.str = token;
4874 /* *** SET RETRY FORWARDING MODE *** */
4875 struct cmd_set_fwd_retry_mode_result {
4876 cmdline_fixed_string_t set;
4877 cmdline_fixed_string_t fwd;
4878 cmdline_fixed_string_t mode;
4879 cmdline_fixed_string_t retry;
4882 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4883 __attribute__((unused)) struct cmdline *cl,
4884 __attribute__((unused)) void *data)
4886 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4889 set_pkt_forwarding_mode(res->mode);
4892 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4893 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4895 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4896 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4898 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4899 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4901 "" /* defined at init */);
4902 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4903 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4906 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4907 .f = cmd_set_fwd_retry_mode_parsed,
4909 .help_str = NULL, /* defined at init */
4911 (void *)&cmd_setfwd_retry_set,
4912 (void *)&cmd_setfwd_retry_fwd,
4913 (void *)&cmd_setfwd_retry_mode,
4914 (void *)&cmd_setfwd_retry_retry,
4919 static void cmd_set_fwd_retry_mode_init(void)
4922 static char token[128];
4923 static char help[256];
4924 cmdline_parse_token_string_t *token_struct;
4926 modes = list_pkt_forwarding_retry_modes();
4927 snprintf(help, sizeof(help), "set fwd %s retry: "
4928 "Set packet forwarding mode with retry", modes);
4929 cmd_set_fwd_retry_mode.help_str = help;
4931 /* string token separator is # */
4932 for (c = token; *modes != '\0'; modes++)
4937 token_struct = (cmdline_parse_token_string_t *)
4938 cmd_set_fwd_retry_mode.tokens[2];
4939 token_struct->string_data.str = token;
4942 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4943 struct cmd_set_burst_tx_retry_result {
4944 cmdline_fixed_string_t set;
4945 cmdline_fixed_string_t burst;
4946 cmdline_fixed_string_t tx;
4947 cmdline_fixed_string_t delay;
4949 cmdline_fixed_string_t retry;
4953 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4954 __attribute__((unused)) struct cmdline *cl,
4955 __attribute__((unused)) void *data)
4957 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4959 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4960 && !strcmp(res->tx, "tx")) {
4961 if (!strcmp(res->delay, "delay"))
4962 burst_tx_delay_time = res->time;
4963 if (!strcmp(res->retry, "retry"))
4964 burst_tx_retry_num = res->retry_num;
4969 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4970 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4971 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4972 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4974 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4975 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4976 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4977 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4978 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4979 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4980 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4981 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4982 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4983 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4985 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4986 .f = cmd_set_burst_tx_retry_parsed,
4987 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4989 (void *)&cmd_set_burst_tx_retry_set,
4990 (void *)&cmd_set_burst_tx_retry_burst,
4991 (void *)&cmd_set_burst_tx_retry_tx,
4992 (void *)&cmd_set_burst_tx_retry_delay,
4993 (void *)&cmd_set_burst_tx_retry_time,
4994 (void *)&cmd_set_burst_tx_retry_retry,
4995 (void *)&cmd_set_burst_tx_retry_retry_num,
5000 /* *** SET PROMISC MODE *** */
5001 struct cmd_set_promisc_mode_result {
5002 cmdline_fixed_string_t set;
5003 cmdline_fixed_string_t promisc;
5004 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5005 uint8_t port_num; /* valid if "allports" argument == 0 */
5006 cmdline_fixed_string_t mode;
5009 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5010 __attribute__((unused)) struct cmdline *cl,
5013 struct cmd_set_promisc_mode_result *res = parsed_result;
5017 if (!strcmp(res->mode, "on"))
5024 FOREACH_PORT(i, ports) {
5026 rte_eth_promiscuous_enable(i);
5028 rte_eth_promiscuous_disable(i);
5033 rte_eth_promiscuous_enable(res->port_num);
5035 rte_eth_promiscuous_disable(res->port_num);
5039 cmdline_parse_token_string_t cmd_setpromisc_set =
5040 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5041 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5042 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5044 cmdline_parse_token_string_t cmd_setpromisc_portall =
5045 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5047 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5048 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5050 cmdline_parse_token_string_t cmd_setpromisc_mode =
5051 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5054 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5055 .f = cmd_set_promisc_mode_parsed,
5057 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5059 (void *)&cmd_setpromisc_set,
5060 (void *)&cmd_setpromisc_promisc,
5061 (void *)&cmd_setpromisc_portall,
5062 (void *)&cmd_setpromisc_mode,
5067 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5068 .f = cmd_set_promisc_mode_parsed,
5070 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5072 (void *)&cmd_setpromisc_set,
5073 (void *)&cmd_setpromisc_promisc,
5074 (void *)&cmd_setpromisc_portnum,
5075 (void *)&cmd_setpromisc_mode,
5080 /* *** SET ALLMULTI MODE *** */
5081 struct cmd_set_allmulti_mode_result {
5082 cmdline_fixed_string_t set;
5083 cmdline_fixed_string_t allmulti;
5084 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5085 uint8_t port_num; /* valid if "allports" argument == 0 */
5086 cmdline_fixed_string_t mode;
5089 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5090 __attribute__((unused)) struct cmdline *cl,
5093 struct cmd_set_allmulti_mode_result *res = parsed_result;
5097 if (!strcmp(res->mode, "on"))
5104 FOREACH_PORT(i, ports) {
5106 rte_eth_allmulticast_enable(i);
5108 rte_eth_allmulticast_disable(i);
5113 rte_eth_allmulticast_enable(res->port_num);
5115 rte_eth_allmulticast_disable(res->port_num);
5119 cmdline_parse_token_string_t cmd_setallmulti_set =
5120 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5121 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5124 cmdline_parse_token_string_t cmd_setallmulti_portall =
5125 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5127 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5128 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5130 cmdline_parse_token_string_t cmd_setallmulti_mode =
5131 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5134 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5135 .f = cmd_set_allmulti_mode_parsed,
5137 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5139 (void *)&cmd_setallmulti_set,
5140 (void *)&cmd_setallmulti_allmulti,
5141 (void *)&cmd_setallmulti_portall,
5142 (void *)&cmd_setallmulti_mode,
5147 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5148 .f = cmd_set_allmulti_mode_parsed,
5150 .help_str = "set allmulti <port_id> on|off: "
5151 "Set allmulti mode on port_id",
5153 (void *)&cmd_setallmulti_set,
5154 (void *)&cmd_setallmulti_allmulti,
5155 (void *)&cmd_setallmulti_portnum,
5156 (void *)&cmd_setallmulti_mode,
5161 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5162 struct cmd_link_flow_ctrl_set_result {
5163 cmdline_fixed_string_t set;
5164 cmdline_fixed_string_t flow_ctrl;
5165 cmdline_fixed_string_t rx;
5166 cmdline_fixed_string_t rx_lfc_mode;
5167 cmdline_fixed_string_t tx;
5168 cmdline_fixed_string_t tx_lfc_mode;
5169 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5170 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5171 cmdline_fixed_string_t autoneg_str;
5172 cmdline_fixed_string_t autoneg;
5173 cmdline_fixed_string_t hw_str;
5174 uint32_t high_water;
5175 cmdline_fixed_string_t lw_str;
5177 cmdline_fixed_string_t pt_str;
5178 uint16_t pause_time;
5179 cmdline_fixed_string_t xon_str;
5184 cmdline_parse_token_string_t cmd_lfc_set_set =
5185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5187 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5188 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5189 flow_ctrl, "flow_ctrl");
5190 cmdline_parse_token_string_t cmd_lfc_set_rx =
5191 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5193 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5194 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5195 rx_lfc_mode, "on#off");
5196 cmdline_parse_token_string_t cmd_lfc_set_tx =
5197 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5199 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5200 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5201 tx_lfc_mode, "on#off");
5202 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5203 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 hw_str, "high_water");
5205 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5206 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5207 high_water, UINT32);
5208 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5209 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5210 lw_str, "low_water");
5211 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5212 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5214 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5215 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5216 pt_str, "pause_time");
5217 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5218 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5219 pause_time, UINT16);
5220 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5221 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5222 xon_str, "send_xon");
5223 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5224 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5226 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5227 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5228 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5229 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5230 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5231 mac_ctrl_frame_fwd_mode, "on#off");
5232 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5233 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5234 autoneg_str, "autoneg");
5235 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5236 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5238 cmdline_parse_token_num_t cmd_lfc_set_portid =
5239 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5242 /* forward declaration */
5244 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5247 cmdline_parse_inst_t cmd_link_flow_control_set = {
5248 .f = cmd_link_flow_ctrl_set_parsed,
5250 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5251 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5252 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5254 (void *)&cmd_lfc_set_set,
5255 (void *)&cmd_lfc_set_flow_ctrl,
5256 (void *)&cmd_lfc_set_rx,
5257 (void *)&cmd_lfc_set_rx_mode,
5258 (void *)&cmd_lfc_set_tx,
5259 (void *)&cmd_lfc_set_tx_mode,
5260 (void *)&cmd_lfc_set_high_water,
5261 (void *)&cmd_lfc_set_low_water,
5262 (void *)&cmd_lfc_set_pause_time,
5263 (void *)&cmd_lfc_set_send_xon,
5264 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5265 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5266 (void *)&cmd_lfc_set_autoneg_str,
5267 (void *)&cmd_lfc_set_autoneg,
5268 (void *)&cmd_lfc_set_portid,
5273 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5274 .f = cmd_link_flow_ctrl_set_parsed,
5275 .data = (void *)&cmd_link_flow_control_set_rx,
5276 .help_str = "set flow_ctrl rx on|off <port_id>: "
5277 "Change rx flow control parameter",
5279 (void *)&cmd_lfc_set_set,
5280 (void *)&cmd_lfc_set_flow_ctrl,
5281 (void *)&cmd_lfc_set_rx,
5282 (void *)&cmd_lfc_set_rx_mode,
5283 (void *)&cmd_lfc_set_portid,
5288 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5289 .f = cmd_link_flow_ctrl_set_parsed,
5290 .data = (void *)&cmd_link_flow_control_set_tx,
5291 .help_str = "set flow_ctrl tx on|off <port_id>: "
5292 "Change tx flow control parameter",
5294 (void *)&cmd_lfc_set_set,
5295 (void *)&cmd_lfc_set_flow_ctrl,
5296 (void *)&cmd_lfc_set_tx,
5297 (void *)&cmd_lfc_set_tx_mode,
5298 (void *)&cmd_lfc_set_portid,
5303 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5304 .f = cmd_link_flow_ctrl_set_parsed,
5305 .data = (void *)&cmd_link_flow_control_set_hw,
5306 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5307 "Change high water flow control parameter",
5309 (void *)&cmd_lfc_set_set,
5310 (void *)&cmd_lfc_set_flow_ctrl,
5311 (void *)&cmd_lfc_set_high_water_str,
5312 (void *)&cmd_lfc_set_high_water,
5313 (void *)&cmd_lfc_set_portid,
5318 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5319 .f = cmd_link_flow_ctrl_set_parsed,
5320 .data = (void *)&cmd_link_flow_control_set_lw,
5321 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5322 "Change low water flow control parameter",
5324 (void *)&cmd_lfc_set_set,
5325 (void *)&cmd_lfc_set_flow_ctrl,
5326 (void *)&cmd_lfc_set_low_water_str,
5327 (void *)&cmd_lfc_set_low_water,
5328 (void *)&cmd_lfc_set_portid,
5333 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5334 .f = cmd_link_flow_ctrl_set_parsed,
5335 .data = (void *)&cmd_link_flow_control_set_pt,
5336 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5337 "Change pause time flow control parameter",
5339 (void *)&cmd_lfc_set_set,
5340 (void *)&cmd_lfc_set_flow_ctrl,
5341 (void *)&cmd_lfc_set_pause_time_str,
5342 (void *)&cmd_lfc_set_pause_time,
5343 (void *)&cmd_lfc_set_portid,
5348 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5349 .f = cmd_link_flow_ctrl_set_parsed,
5350 .data = (void *)&cmd_link_flow_control_set_xon,
5351 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5352 "Change send_xon flow control parameter",
5354 (void *)&cmd_lfc_set_set,
5355 (void *)&cmd_lfc_set_flow_ctrl,
5356 (void *)&cmd_lfc_set_send_xon_str,
5357 (void *)&cmd_lfc_set_send_xon,
5358 (void *)&cmd_lfc_set_portid,
5363 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5364 .f = cmd_link_flow_ctrl_set_parsed,
5365 .data = (void *)&cmd_link_flow_control_set_macfwd,
5366 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5367 "Change mac ctrl fwd flow control parameter",
5369 (void *)&cmd_lfc_set_set,
5370 (void *)&cmd_lfc_set_flow_ctrl,
5371 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5372 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5373 (void *)&cmd_lfc_set_portid,
5378 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5379 .f = cmd_link_flow_ctrl_set_parsed,
5380 .data = (void *)&cmd_link_flow_control_set_autoneg,
5381 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5382 "Change autoneg flow control parameter",
5384 (void *)&cmd_lfc_set_set,
5385 (void *)&cmd_lfc_set_flow_ctrl,
5386 (void *)&cmd_lfc_set_autoneg_str,
5387 (void *)&cmd_lfc_set_autoneg,
5388 (void *)&cmd_lfc_set_portid,
5394 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5395 __attribute__((unused)) struct cmdline *cl,
5398 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5399 cmdline_parse_inst_t *cmd = data;
5400 struct rte_eth_fc_conf fc_conf;
5406 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5407 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5408 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5409 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5411 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5412 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5415 /* Partial command line, retrieve current configuration */
5417 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5419 printf("cannot get current flow ctrl parameters, return"
5420 "code = %d\n", ret);
5424 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5425 (fc_conf.mode == RTE_FC_FULL))
5427 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5428 (fc_conf.mode == RTE_FC_FULL))
5432 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5433 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5435 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5436 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5438 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5440 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5441 fc_conf.high_water = res->high_water;
5443 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5444 fc_conf.low_water = res->low_water;
5446 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5447 fc_conf.pause_time = res->pause_time;
5449 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5450 fc_conf.send_xon = res->send_xon;
5452 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5453 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5454 fc_conf.mac_ctrl_frame_fwd = 1;
5456 fc_conf.mac_ctrl_frame_fwd = 0;
5459 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5460 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5462 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5464 printf("bad flow contrl parameter, return code = %d \n", ret);
5467 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5468 struct cmd_priority_flow_ctrl_set_result {
5469 cmdline_fixed_string_t set;
5470 cmdline_fixed_string_t pfc_ctrl;
5471 cmdline_fixed_string_t rx;
5472 cmdline_fixed_string_t rx_pfc_mode;
5473 cmdline_fixed_string_t tx;
5474 cmdline_fixed_string_t tx_pfc_mode;
5475 uint32_t high_water;
5477 uint16_t pause_time;
5483 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5484 __attribute__((unused)) struct cmdline *cl,
5485 __attribute__((unused)) void *data)
5487 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5488 struct rte_eth_pfc_conf pfc_conf;
5489 int rx_fc_enable, tx_fc_enable;
5493 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5494 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5495 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5496 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5498 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5499 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5502 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5503 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5504 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5505 pfc_conf.fc.high_water = res->high_water;
5506 pfc_conf.fc.low_water = res->low_water;
5507 pfc_conf.fc.pause_time = res->pause_time;
5508 pfc_conf.priority = res->priority;
5510 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5512 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5515 cmdline_parse_token_string_t cmd_pfc_set_set =
5516 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5518 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5519 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5520 pfc_ctrl, "pfc_ctrl");
5521 cmdline_parse_token_string_t cmd_pfc_set_rx =
5522 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5524 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5525 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5526 rx_pfc_mode, "on#off");
5527 cmdline_parse_token_string_t cmd_pfc_set_tx =
5528 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5530 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5531 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5532 tx_pfc_mode, "on#off");
5533 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5534 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5535 high_water, UINT32);
5536 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5537 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5539 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5540 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5541 pause_time, UINT16);
5542 cmdline_parse_token_num_t cmd_pfc_set_priority =
5543 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5545 cmdline_parse_token_num_t cmd_pfc_set_portid =
5546 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5549 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5550 .f = cmd_priority_flow_ctrl_set_parsed,
5552 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5553 "<pause_time> <priority> <port_id>: "
5554 "Configure the Ethernet priority flow control",
5556 (void *)&cmd_pfc_set_set,
5557 (void *)&cmd_pfc_set_flow_ctrl,
5558 (void *)&cmd_pfc_set_rx,
5559 (void *)&cmd_pfc_set_rx_mode,
5560 (void *)&cmd_pfc_set_tx,
5561 (void *)&cmd_pfc_set_tx_mode,
5562 (void *)&cmd_pfc_set_high_water,
5563 (void *)&cmd_pfc_set_low_water,
5564 (void *)&cmd_pfc_set_pause_time,
5565 (void *)&cmd_pfc_set_priority,
5566 (void *)&cmd_pfc_set_portid,
5571 /* *** RESET CONFIGURATION *** */
5572 struct cmd_reset_result {
5573 cmdline_fixed_string_t reset;
5574 cmdline_fixed_string_t def;
5577 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5579 __attribute__((unused)) void *data)
5581 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5582 set_def_fwd_config();
5585 cmdline_parse_token_string_t cmd_reset_set =
5586 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5587 cmdline_parse_token_string_t cmd_reset_def =
5588 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5591 cmdline_parse_inst_t cmd_reset = {
5592 .f = cmd_reset_parsed,
5594 .help_str = "set default: Reset default forwarding configuration",
5596 (void *)&cmd_reset_set,
5597 (void *)&cmd_reset_def,
5602 /* *** START FORWARDING *** */
5603 struct cmd_start_result {
5604 cmdline_fixed_string_t start;
5607 cmdline_parse_token_string_t cmd_start_start =
5608 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5610 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5611 __attribute__((unused)) struct cmdline *cl,
5612 __attribute__((unused)) void *data)
5614 start_packet_forwarding(0);
5617 cmdline_parse_inst_t cmd_start = {
5618 .f = cmd_start_parsed,
5620 .help_str = "start: Start packet forwarding",
5622 (void *)&cmd_start_start,
5627 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5628 struct cmd_start_tx_first_result {
5629 cmdline_fixed_string_t start;
5630 cmdline_fixed_string_t tx_first;
5634 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5635 __attribute__((unused)) struct cmdline *cl,
5636 __attribute__((unused)) void *data)
5638 start_packet_forwarding(1);
5641 cmdline_parse_token_string_t cmd_start_tx_first_start =
5642 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5644 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5645 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5646 tx_first, "tx_first");
5648 cmdline_parse_inst_t cmd_start_tx_first = {
5649 .f = cmd_start_tx_first_parsed,
5651 .help_str = "start tx_first: Start packet forwarding, "
5652 "after sending 1 burst of packets",
5654 (void *)&cmd_start_tx_first_start,
5655 (void *)&cmd_start_tx_first_tx_first,
5660 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5661 struct cmd_start_tx_first_n_result {
5662 cmdline_fixed_string_t start;
5663 cmdline_fixed_string_t tx_first;
5668 cmd_start_tx_first_n_parsed(void *parsed_result,
5669 __attribute__((unused)) struct cmdline *cl,
5670 __attribute__((unused)) void *data)
5672 struct cmd_start_tx_first_n_result *res = parsed_result;
5674 start_packet_forwarding(res->tx_num);
5677 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5678 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5680 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5681 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5682 tx_first, "tx_first");
5683 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5684 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5687 cmdline_parse_inst_t cmd_start_tx_first_n = {
5688 .f = cmd_start_tx_first_n_parsed,
5690 .help_str = "start tx_first <num>: "
5691 "packet forwarding, after sending <num> bursts of packets",
5693 (void *)&cmd_start_tx_first_n_start,
5694 (void *)&cmd_start_tx_first_n_tx_first,
5695 (void *)&cmd_start_tx_first_n_tx_num,
5700 /* *** SET LINK UP *** */
5701 struct cmd_set_link_up_result {
5702 cmdline_fixed_string_t set;
5703 cmdline_fixed_string_t link_up;
5704 cmdline_fixed_string_t port;
5708 cmdline_parse_token_string_t cmd_set_link_up_set =
5709 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5710 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5711 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5713 cmdline_parse_token_string_t cmd_set_link_up_port =
5714 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5715 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5716 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5718 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5719 __attribute__((unused)) struct cmdline *cl,
5720 __attribute__((unused)) void *data)
5722 struct cmd_set_link_up_result *res = parsed_result;
5723 dev_set_link_up(res->port_id);
5726 cmdline_parse_inst_t cmd_set_link_up = {
5727 .f = cmd_set_link_up_parsed,
5729 .help_str = "set link-up port <port id>",
5731 (void *)&cmd_set_link_up_set,
5732 (void *)&cmd_set_link_up_link_up,
5733 (void *)&cmd_set_link_up_port,
5734 (void *)&cmd_set_link_up_port_id,
5739 /* *** SET LINK DOWN *** */
5740 struct cmd_set_link_down_result {
5741 cmdline_fixed_string_t set;
5742 cmdline_fixed_string_t link_down;
5743 cmdline_fixed_string_t port;
5747 cmdline_parse_token_string_t cmd_set_link_down_set =
5748 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5749 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5752 cmdline_parse_token_string_t cmd_set_link_down_port =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5754 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5755 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5757 static void cmd_set_link_down_parsed(
5758 __attribute__((unused)) void *parsed_result,
5759 __attribute__((unused)) struct cmdline *cl,
5760 __attribute__((unused)) void *data)
5762 struct cmd_set_link_down_result *res = parsed_result;
5763 dev_set_link_down(res->port_id);
5766 cmdline_parse_inst_t cmd_set_link_down = {
5767 .f = cmd_set_link_down_parsed,
5769 .help_str = "set link-down port <port id>",
5771 (void *)&cmd_set_link_down_set,
5772 (void *)&cmd_set_link_down_link_down,
5773 (void *)&cmd_set_link_down_port,
5774 (void *)&cmd_set_link_down_port_id,
5779 /* *** SHOW CFG *** */
5780 struct cmd_showcfg_result {
5781 cmdline_fixed_string_t show;
5782 cmdline_fixed_string_t cfg;
5783 cmdline_fixed_string_t what;
5786 static void cmd_showcfg_parsed(void *parsed_result,
5787 __attribute__((unused)) struct cmdline *cl,
5788 __attribute__((unused)) void *data)
5790 struct cmd_showcfg_result *res = parsed_result;
5791 if (!strcmp(res->what, "rxtx"))
5792 rxtx_config_display();
5793 else if (!strcmp(res->what, "cores"))
5794 fwd_lcores_config_display();
5795 else if (!strcmp(res->what, "fwd"))
5796 pkt_fwd_config_display(&cur_fwd_config);
5797 else if (!strcmp(res->what, "txpkts"))
5798 show_tx_pkt_segments();
5801 cmdline_parse_token_string_t cmd_showcfg_show =
5802 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5803 cmdline_parse_token_string_t cmd_showcfg_port =
5804 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5805 cmdline_parse_token_string_t cmd_showcfg_what =
5806 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5807 "rxtx#cores#fwd#txpkts");
5809 cmdline_parse_inst_t cmd_showcfg = {
5810 .f = cmd_showcfg_parsed,
5812 .help_str = "show config rxtx|cores|fwd|txpkts",
5814 (void *)&cmd_showcfg_show,
5815 (void *)&cmd_showcfg_port,
5816 (void *)&cmd_showcfg_what,
5821 /* *** SHOW ALL PORT INFO *** */
5822 struct cmd_showportall_result {
5823 cmdline_fixed_string_t show;
5824 cmdline_fixed_string_t port;
5825 cmdline_fixed_string_t what;
5826 cmdline_fixed_string_t all;
5829 static void cmd_showportall_parsed(void *parsed_result,
5830 __attribute__((unused)) struct cmdline *cl,
5831 __attribute__((unused)) void *data)
5835 struct cmd_showportall_result *res = parsed_result;
5836 if (!strcmp(res->show, "clear")) {
5837 if (!strcmp(res->what, "stats"))
5838 FOREACH_PORT(i, ports)
5840 else if (!strcmp(res->what, "xstats"))
5841 FOREACH_PORT(i, ports)
5842 nic_xstats_clear(i);
5843 } else if (!strcmp(res->what, "info"))
5844 FOREACH_PORT(i, ports)
5845 port_infos_display(i);
5846 else if (!strcmp(res->what, "stats"))
5847 FOREACH_PORT(i, ports)
5848 nic_stats_display(i);
5849 else if (!strcmp(res->what, "xstats"))
5850 FOREACH_PORT(i, ports)
5851 nic_xstats_display(i);
5852 else if (!strcmp(res->what, "fdir"))
5853 FOREACH_PORT(i, ports)
5855 else if (!strcmp(res->what, "stat_qmap"))
5856 FOREACH_PORT(i, ports)
5857 nic_stats_mapping_display(i);
5858 else if (!strcmp(res->what, "dcb_tc"))
5859 FOREACH_PORT(i, ports)
5860 port_dcb_info_display(i);
5861 else if (!strcmp(res->what, "cap"))
5862 FOREACH_PORT(i, ports)
5863 port_offload_cap_display(i);
5866 cmdline_parse_token_string_t cmd_showportall_show =
5867 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5869 cmdline_parse_token_string_t cmd_showportall_port =
5870 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5871 cmdline_parse_token_string_t cmd_showportall_what =
5872 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5873 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5874 cmdline_parse_token_string_t cmd_showportall_all =
5875 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5876 cmdline_parse_inst_t cmd_showportall = {
5877 .f = cmd_showportall_parsed,
5879 .help_str = "show|clear port "
5880 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5882 (void *)&cmd_showportall_show,
5883 (void *)&cmd_showportall_port,
5884 (void *)&cmd_showportall_what,
5885 (void *)&cmd_showportall_all,
5890 /* *** SHOW PORT INFO *** */
5891 struct cmd_showport_result {
5892 cmdline_fixed_string_t show;
5893 cmdline_fixed_string_t port;
5894 cmdline_fixed_string_t what;
5898 static void cmd_showport_parsed(void *parsed_result,
5899 __attribute__((unused)) struct cmdline *cl,
5900 __attribute__((unused)) void *data)
5902 struct cmd_showport_result *res = parsed_result;
5903 if (!strcmp(res->show, "clear")) {
5904 if (!strcmp(res->what, "stats"))
5905 nic_stats_clear(res->portnum);
5906 else if (!strcmp(res->what, "xstats"))
5907 nic_xstats_clear(res->portnum);
5908 } else if (!strcmp(res->what, "info"))
5909 port_infos_display(res->portnum);
5910 else if (!strcmp(res->what, "stats"))
5911 nic_stats_display(res->portnum);
5912 else if (!strcmp(res->what, "xstats"))
5913 nic_xstats_display(res->portnum);
5914 else if (!strcmp(res->what, "fdir"))
5915 fdir_get_infos(res->portnum);
5916 else if (!strcmp(res->what, "stat_qmap"))
5917 nic_stats_mapping_display(res->portnum);
5918 else if (!strcmp(res->what, "dcb_tc"))
5919 port_dcb_info_display(res->portnum);
5920 else if (!strcmp(res->what, "cap"))
5921 port_offload_cap_display(res->portnum);
5924 cmdline_parse_token_string_t cmd_showport_show =
5925 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5927 cmdline_parse_token_string_t cmd_showport_port =
5928 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5929 cmdline_parse_token_string_t cmd_showport_what =
5930 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5931 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5932 cmdline_parse_token_num_t cmd_showport_portnum =
5933 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5935 cmdline_parse_inst_t cmd_showport = {
5936 .f = cmd_showport_parsed,
5938 .help_str = "show|clear port "
5939 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5942 (void *)&cmd_showport_show,
5943 (void *)&cmd_showport_port,
5944 (void *)&cmd_showport_what,
5945 (void *)&cmd_showport_portnum,
5950 /* *** SHOW QUEUE INFO *** */
5951 struct cmd_showqueue_result {
5952 cmdline_fixed_string_t show;
5953 cmdline_fixed_string_t type;
5954 cmdline_fixed_string_t what;
5960 cmd_showqueue_parsed(void *parsed_result,
5961 __attribute__((unused)) struct cmdline *cl,
5962 __attribute__((unused)) void *data)
5964 struct cmd_showqueue_result *res = parsed_result;
5966 if (!strcmp(res->type, "rxq"))
5967 rx_queue_infos_display(res->portnum, res->queuenum);
5968 else if (!strcmp(res->type, "txq"))
5969 tx_queue_infos_display(res->portnum, res->queuenum);
5972 cmdline_parse_token_string_t cmd_showqueue_show =
5973 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5974 cmdline_parse_token_string_t cmd_showqueue_type =
5975 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5976 cmdline_parse_token_string_t cmd_showqueue_what =
5977 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5978 cmdline_parse_token_num_t cmd_showqueue_portnum =
5979 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5980 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5981 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5983 cmdline_parse_inst_t cmd_showqueue = {
5984 .f = cmd_showqueue_parsed,
5986 .help_str = "show rxq|txq info <port_id> <queue_id>",
5988 (void *)&cmd_showqueue_show,
5989 (void *)&cmd_showqueue_type,
5990 (void *)&cmd_showqueue_what,
5991 (void *)&cmd_showqueue_portnum,
5992 (void *)&cmd_showqueue_queuenum,
5997 /* *** READ PORT REGISTER *** */
5998 struct cmd_read_reg_result {
5999 cmdline_fixed_string_t read;
6000 cmdline_fixed_string_t reg;
6006 cmd_read_reg_parsed(void *parsed_result,
6007 __attribute__((unused)) struct cmdline *cl,
6008 __attribute__((unused)) void *data)
6010 struct cmd_read_reg_result *res = parsed_result;
6011 port_reg_display(res->port_id, res->reg_off);
6014 cmdline_parse_token_string_t cmd_read_reg_read =
6015 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6016 cmdline_parse_token_string_t cmd_read_reg_reg =
6017 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6018 cmdline_parse_token_num_t cmd_read_reg_port_id =
6019 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6020 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6021 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6023 cmdline_parse_inst_t cmd_read_reg = {
6024 .f = cmd_read_reg_parsed,
6026 .help_str = "read reg <port_id> <reg_off>",
6028 (void *)&cmd_read_reg_read,
6029 (void *)&cmd_read_reg_reg,
6030 (void *)&cmd_read_reg_port_id,
6031 (void *)&cmd_read_reg_reg_off,
6036 /* *** READ PORT REGISTER BIT FIELD *** */
6037 struct cmd_read_reg_bit_field_result {
6038 cmdline_fixed_string_t read;
6039 cmdline_fixed_string_t regfield;
6047 cmd_read_reg_bit_field_parsed(void *parsed_result,
6048 __attribute__((unused)) struct cmdline *cl,
6049 __attribute__((unused)) void *data)
6051 struct cmd_read_reg_bit_field_result *res = parsed_result;
6052 port_reg_bit_field_display(res->port_id, res->reg_off,
6053 res->bit1_pos, res->bit2_pos);
6056 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6057 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6059 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6060 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6061 regfield, "regfield");
6062 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6063 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6065 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6066 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6068 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6069 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6071 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6072 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6075 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6076 .f = cmd_read_reg_bit_field_parsed,
6078 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6079 "Read register bit field between bit_x and bit_y included",
6081 (void *)&cmd_read_reg_bit_field_read,
6082 (void *)&cmd_read_reg_bit_field_regfield,
6083 (void *)&cmd_read_reg_bit_field_port_id,
6084 (void *)&cmd_read_reg_bit_field_reg_off,
6085 (void *)&cmd_read_reg_bit_field_bit1_pos,
6086 (void *)&cmd_read_reg_bit_field_bit2_pos,
6091 /* *** READ PORT REGISTER BIT *** */
6092 struct cmd_read_reg_bit_result {
6093 cmdline_fixed_string_t read;
6094 cmdline_fixed_string_t regbit;
6101 cmd_read_reg_bit_parsed(void *parsed_result,
6102 __attribute__((unused)) struct cmdline *cl,
6103 __attribute__((unused)) void *data)
6105 struct cmd_read_reg_bit_result *res = parsed_result;
6106 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6109 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6110 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6111 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6112 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6114 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6115 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6116 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6117 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6118 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6119 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6121 cmdline_parse_inst_t cmd_read_reg_bit = {
6122 .f = cmd_read_reg_bit_parsed,
6124 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6126 (void *)&cmd_read_reg_bit_read,
6127 (void *)&cmd_read_reg_bit_regbit,
6128 (void *)&cmd_read_reg_bit_port_id,
6129 (void *)&cmd_read_reg_bit_reg_off,
6130 (void *)&cmd_read_reg_bit_bit_pos,
6135 /* *** WRITE PORT REGISTER *** */
6136 struct cmd_write_reg_result {
6137 cmdline_fixed_string_t write;
6138 cmdline_fixed_string_t reg;
6145 cmd_write_reg_parsed(void *parsed_result,
6146 __attribute__((unused)) struct cmdline *cl,
6147 __attribute__((unused)) void *data)
6149 struct cmd_write_reg_result *res = parsed_result;
6150 port_reg_set(res->port_id, res->reg_off, res->value);
6153 cmdline_parse_token_string_t cmd_write_reg_write =
6154 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6155 cmdline_parse_token_string_t cmd_write_reg_reg =
6156 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6157 cmdline_parse_token_num_t cmd_write_reg_port_id =
6158 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6159 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6160 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6161 cmdline_parse_token_num_t cmd_write_reg_value =
6162 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6164 cmdline_parse_inst_t cmd_write_reg = {
6165 .f = cmd_write_reg_parsed,
6167 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6169 (void *)&cmd_write_reg_write,
6170 (void *)&cmd_write_reg_reg,
6171 (void *)&cmd_write_reg_port_id,
6172 (void *)&cmd_write_reg_reg_off,
6173 (void *)&cmd_write_reg_value,
6178 /* *** WRITE PORT REGISTER BIT FIELD *** */
6179 struct cmd_write_reg_bit_field_result {
6180 cmdline_fixed_string_t write;
6181 cmdline_fixed_string_t regfield;
6190 cmd_write_reg_bit_field_parsed(void *parsed_result,
6191 __attribute__((unused)) struct cmdline *cl,
6192 __attribute__((unused)) void *data)
6194 struct cmd_write_reg_bit_field_result *res = parsed_result;
6195 port_reg_bit_field_set(res->port_id, res->reg_off,
6196 res->bit1_pos, res->bit2_pos, res->value);
6199 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6200 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6202 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6203 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6204 regfield, "regfield");
6205 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6206 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6208 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6209 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6211 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6212 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6214 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6215 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6217 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6218 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6221 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6222 .f = cmd_write_reg_bit_field_parsed,
6224 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6226 "Set register bit field between bit_x and bit_y included",
6228 (void *)&cmd_write_reg_bit_field_write,
6229 (void *)&cmd_write_reg_bit_field_regfield,
6230 (void *)&cmd_write_reg_bit_field_port_id,
6231 (void *)&cmd_write_reg_bit_field_reg_off,
6232 (void *)&cmd_write_reg_bit_field_bit1_pos,
6233 (void *)&cmd_write_reg_bit_field_bit2_pos,
6234 (void *)&cmd_write_reg_bit_field_value,
6239 /* *** WRITE PORT REGISTER BIT *** */
6240 struct cmd_write_reg_bit_result {
6241 cmdline_fixed_string_t write;
6242 cmdline_fixed_string_t regbit;
6250 cmd_write_reg_bit_parsed(void *parsed_result,
6251 __attribute__((unused)) struct cmdline *cl,
6252 __attribute__((unused)) void *data)
6254 struct cmd_write_reg_bit_result *res = parsed_result;
6255 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6258 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6259 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6261 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6262 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6264 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6265 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6266 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6267 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6268 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6269 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6270 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6271 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6273 cmdline_parse_inst_t cmd_write_reg_bit = {
6274 .f = cmd_write_reg_bit_parsed,
6276 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6279 (void *)&cmd_write_reg_bit_write,
6280 (void *)&cmd_write_reg_bit_regbit,
6281 (void *)&cmd_write_reg_bit_port_id,
6282 (void *)&cmd_write_reg_bit_reg_off,
6283 (void *)&cmd_write_reg_bit_bit_pos,
6284 (void *)&cmd_write_reg_bit_value,
6289 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6290 struct cmd_read_rxd_txd_result {
6291 cmdline_fixed_string_t read;
6292 cmdline_fixed_string_t rxd_txd;
6299 cmd_read_rxd_txd_parsed(void *parsed_result,
6300 __attribute__((unused)) struct cmdline *cl,
6301 __attribute__((unused)) void *data)
6303 struct cmd_read_rxd_txd_result *res = parsed_result;
6305 if (!strcmp(res->rxd_txd, "rxd"))
6306 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6307 else if (!strcmp(res->rxd_txd, "txd"))
6308 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6311 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6312 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6313 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6314 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6316 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6317 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6318 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6319 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6320 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6321 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6323 cmdline_parse_inst_t cmd_read_rxd_txd = {
6324 .f = cmd_read_rxd_txd_parsed,
6326 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6328 (void *)&cmd_read_rxd_txd_read,
6329 (void *)&cmd_read_rxd_txd_rxd_txd,
6330 (void *)&cmd_read_rxd_txd_port_id,
6331 (void *)&cmd_read_rxd_txd_queue_id,
6332 (void *)&cmd_read_rxd_txd_desc_id,
6338 struct cmd_quit_result {
6339 cmdline_fixed_string_t quit;
6342 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6344 __attribute__((unused)) void *data)
6350 cmdline_parse_token_string_t cmd_quit_quit =
6351 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6353 cmdline_parse_inst_t cmd_quit = {
6354 .f = cmd_quit_parsed,
6356 .help_str = "quit: Exit application",
6358 (void *)&cmd_quit_quit,
6363 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6364 struct cmd_mac_addr_result {
6365 cmdline_fixed_string_t mac_addr_cmd;
6366 cmdline_fixed_string_t what;
6368 struct ether_addr address;
6371 static void cmd_mac_addr_parsed(void *parsed_result,
6372 __attribute__((unused)) struct cmdline *cl,
6373 __attribute__((unused)) void *data)
6375 struct cmd_mac_addr_result *res = parsed_result;
6378 if (strcmp(res->what, "add") == 0)
6379 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6380 else if (strcmp(res->what, "set") == 0)
6381 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6384 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6386 /* check the return value and print it if is < 0 */
6388 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6392 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6393 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6395 cmdline_parse_token_string_t cmd_mac_addr_what =
6396 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6398 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6399 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6400 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6401 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6403 cmdline_parse_inst_t cmd_mac_addr = {
6404 .f = cmd_mac_addr_parsed,
6406 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6407 "Add/Remove/Set MAC address on port_id",
6409 (void *)&cmd_mac_addr_cmd,
6410 (void *)&cmd_mac_addr_what,
6411 (void *)&cmd_mac_addr_portnum,
6412 (void *)&cmd_mac_addr_addr,
6418 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6419 struct cmd_set_qmap_result {
6420 cmdline_fixed_string_t set;
6421 cmdline_fixed_string_t qmap;
6422 cmdline_fixed_string_t what;
6429 cmd_set_qmap_parsed(void *parsed_result,
6430 __attribute__((unused)) struct cmdline *cl,
6431 __attribute__((unused)) void *data)
6433 struct cmd_set_qmap_result *res = parsed_result;
6434 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6436 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6439 cmdline_parse_token_string_t cmd_setqmap_set =
6440 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6442 cmdline_parse_token_string_t cmd_setqmap_qmap =
6443 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6445 cmdline_parse_token_string_t cmd_setqmap_what =
6446 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6448 cmdline_parse_token_num_t cmd_setqmap_portid =
6449 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6451 cmdline_parse_token_num_t cmd_setqmap_queueid =
6452 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6454 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6455 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6458 cmdline_parse_inst_t cmd_set_qmap = {
6459 .f = cmd_set_qmap_parsed,
6461 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6462 "Set statistics mapping value on tx|rx queue_id of port_id",
6464 (void *)&cmd_setqmap_set,
6465 (void *)&cmd_setqmap_qmap,
6466 (void *)&cmd_setqmap_what,
6467 (void *)&cmd_setqmap_portid,
6468 (void *)&cmd_setqmap_queueid,
6469 (void *)&cmd_setqmap_mapvalue,
6474 /* *** CONFIGURE UNICAST HASH TABLE *** */
6475 struct cmd_set_uc_hash_table {
6476 cmdline_fixed_string_t set;
6477 cmdline_fixed_string_t port;
6479 cmdline_fixed_string_t what;
6480 struct ether_addr address;
6481 cmdline_fixed_string_t mode;
6485 cmd_set_uc_hash_parsed(void *parsed_result,
6486 __attribute__((unused)) struct cmdline *cl,
6487 __attribute__((unused)) void *data)
6490 struct cmd_set_uc_hash_table *res = parsed_result;
6492 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6494 if (strcmp(res->what, "uta") == 0)
6495 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6496 &res->address,(uint8_t)is_on);
6498 printf("bad unicast hash table parameter, return code = %d \n", ret);
6502 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6505 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6506 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6508 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6509 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6511 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6512 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6514 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6515 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6517 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6518 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6521 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6522 .f = cmd_set_uc_hash_parsed,
6524 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6526 (void *)&cmd_set_uc_hash_set,
6527 (void *)&cmd_set_uc_hash_port,
6528 (void *)&cmd_set_uc_hash_portid,
6529 (void *)&cmd_set_uc_hash_what,
6530 (void *)&cmd_set_uc_hash_mac,
6531 (void *)&cmd_set_uc_hash_mode,
6536 struct cmd_set_uc_all_hash_table {
6537 cmdline_fixed_string_t set;
6538 cmdline_fixed_string_t port;
6540 cmdline_fixed_string_t what;
6541 cmdline_fixed_string_t value;
6542 cmdline_fixed_string_t mode;
6546 cmd_set_uc_all_hash_parsed(void *parsed_result,
6547 __attribute__((unused)) struct cmdline *cl,
6548 __attribute__((unused)) void *data)
6551 struct cmd_set_uc_all_hash_table *res = parsed_result;
6553 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6555 if ((strcmp(res->what, "uta") == 0) &&
6556 (strcmp(res->value, "all") == 0))
6557 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6559 printf("bad unicast hash table parameter,"
6560 "return code = %d \n", ret);
6563 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6564 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6566 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6567 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6569 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6570 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6572 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6573 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6575 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6576 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6578 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6579 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6582 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6583 .f = cmd_set_uc_all_hash_parsed,
6585 .help_str = "set port <port_id> uta all on|off",
6587 (void *)&cmd_set_uc_all_hash_set,
6588 (void *)&cmd_set_uc_all_hash_port,
6589 (void *)&cmd_set_uc_all_hash_portid,
6590 (void *)&cmd_set_uc_all_hash_what,
6591 (void *)&cmd_set_uc_all_hash_value,
6592 (void *)&cmd_set_uc_all_hash_mode,
6597 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6598 struct cmd_set_vf_macvlan_filter {
6599 cmdline_fixed_string_t set;
6600 cmdline_fixed_string_t port;
6602 cmdline_fixed_string_t vf;
6604 struct ether_addr address;
6605 cmdline_fixed_string_t filter_type;
6606 cmdline_fixed_string_t mode;
6610 cmd_set_vf_macvlan_parsed(void *parsed_result,
6611 __attribute__((unused)) struct cmdline *cl,
6612 __attribute__((unused)) void *data)
6615 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6616 struct rte_eth_mac_filter filter;
6618 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6620 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6622 /* set VF MAC filter */
6626 filter.dst_id = res->vf_id;
6628 if (!strcmp(res->filter_type, "exact-mac"))
6629 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6630 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6631 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6632 else if (!strcmp(res->filter_type, "hashmac"))
6633 filter.filter_type = RTE_MAC_HASH_MATCH;
6634 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6635 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6637 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6640 ret = rte_eth_dev_filter_ctrl(res->port_id,
6641 RTE_ETH_FILTER_MACVLAN,
6645 ret = rte_eth_dev_filter_ctrl(res->port_id,
6646 RTE_ETH_FILTER_MACVLAN,
6647 RTE_ETH_FILTER_DELETE,
6651 printf("bad set MAC hash parameter, return code = %d\n", ret);
6655 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6656 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6658 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6659 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6661 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6662 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6664 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6665 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6667 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6668 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6670 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6671 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6673 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6674 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6675 filter_type, "exact-mac#exact-mac-vlan"
6676 "#hashmac#hashmac-vlan");
6677 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6678 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6681 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6682 .f = cmd_set_vf_macvlan_parsed,
6684 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6685 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6686 "Exact match rule: exact match of MAC or MAC and VLAN; "
6687 "hash match rule: hash match of MAC and exact match of VLAN",
6689 (void *)&cmd_set_vf_macvlan_set,
6690 (void *)&cmd_set_vf_macvlan_port,
6691 (void *)&cmd_set_vf_macvlan_portid,
6692 (void *)&cmd_set_vf_macvlan_vf,
6693 (void *)&cmd_set_vf_macvlan_vf_id,
6694 (void *)&cmd_set_vf_macvlan_mac,
6695 (void *)&cmd_set_vf_macvlan_filter_type,
6696 (void *)&cmd_set_vf_macvlan_mode,
6701 #ifdef RTE_LIBRTE_IXGBE_PMD
6702 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6703 struct cmd_set_vf_traffic {
6704 cmdline_fixed_string_t set;
6705 cmdline_fixed_string_t port;
6707 cmdline_fixed_string_t vf;
6709 cmdline_fixed_string_t what;
6710 cmdline_fixed_string_t mode;
6714 cmd_set_vf_traffic_parsed(void *parsed_result,
6715 __attribute__((unused)) struct cmdline *cl,
6716 __attribute__((unused)) void *data)
6718 struct cmd_set_vf_traffic *res = parsed_result;
6719 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6720 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6722 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6725 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6726 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6728 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6731 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6732 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6734 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6735 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6737 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6738 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6740 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6743 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6744 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6747 cmdline_parse_inst_t cmd_set_vf_traffic = {
6748 .f = cmd_set_vf_traffic_parsed,
6750 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6752 (void *)&cmd_setvf_traffic_set,
6753 (void *)&cmd_setvf_traffic_port,
6754 (void *)&cmd_setvf_traffic_portid,
6755 (void *)&cmd_setvf_traffic_vf,
6756 (void *)&cmd_setvf_traffic_vfid,
6757 (void *)&cmd_setvf_traffic_what,
6758 (void *)&cmd_setvf_traffic_mode,
6763 /* *** CONFIGURE VF RECEIVE MODE *** */
6764 struct cmd_set_vf_rxmode {
6765 cmdline_fixed_string_t set;
6766 cmdline_fixed_string_t port;
6768 cmdline_fixed_string_t vf;
6770 cmdline_fixed_string_t what;
6771 cmdline_fixed_string_t mode;
6772 cmdline_fixed_string_t on;
6776 cmd_set_vf_rxmode_parsed(void *parsed_result,
6777 __attribute__((unused)) struct cmdline *cl,
6778 __attribute__((unused)) void *data)
6781 uint16_t rx_mode = 0;
6782 struct cmd_set_vf_rxmode *res = parsed_result;
6784 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6785 if (!strcmp(res->what,"rxmode")) {
6786 if (!strcmp(res->mode, "AUPE"))
6787 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6788 else if (!strcmp(res->mode, "ROPE"))
6789 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6790 else if (!strcmp(res->mode, "BAM"))
6791 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6792 else if (!strncmp(res->mode, "MPE",3))
6793 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6796 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6798 printf("bad VF receive mode parameter, return code = %d \n",
6802 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6805 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6806 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6808 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6809 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6811 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6812 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6814 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6815 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6817 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6818 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6820 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6821 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6822 mode, "AUPE#ROPE#BAM#MPE");
6823 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6824 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6827 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6828 .f = cmd_set_vf_rxmode_parsed,
6830 .help_str = "set port <port_id> vf <vf_id> rxmode "
6831 "AUPE|ROPE|BAM|MPE on|off",
6833 (void *)&cmd_set_vf_rxmode_set,
6834 (void *)&cmd_set_vf_rxmode_port,
6835 (void *)&cmd_set_vf_rxmode_portid,
6836 (void *)&cmd_set_vf_rxmode_vf,
6837 (void *)&cmd_set_vf_rxmode_vfid,
6838 (void *)&cmd_set_vf_rxmode_what,
6839 (void *)&cmd_set_vf_rxmode_mode,
6840 (void *)&cmd_set_vf_rxmode_on,
6846 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6847 struct cmd_vf_mac_addr_result {
6848 cmdline_fixed_string_t mac_addr_cmd;
6849 cmdline_fixed_string_t what;
6850 cmdline_fixed_string_t port;
6852 cmdline_fixed_string_t vf;
6854 struct ether_addr address;
6857 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6858 __attribute__((unused)) struct cmdline *cl,
6859 __attribute__((unused)) void *data)
6861 struct cmd_vf_mac_addr_result *res = parsed_result;
6864 if (strcmp(res->what, "add") == 0)
6865 ret = rte_eth_dev_mac_addr_add(res->port_num,
6866 &res->address, res->vf_num);
6868 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6872 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6873 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6874 mac_addr_cmd,"mac_addr");
6875 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6876 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6878 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6879 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6881 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6882 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6884 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6885 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6887 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6888 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6890 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6891 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6894 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6895 .f = cmd_vf_mac_addr_parsed,
6897 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6898 "Add MAC address filtering for a VF on port_id",
6900 (void *)&cmd_vf_mac_addr_cmd,
6901 (void *)&cmd_vf_mac_addr_what,
6902 (void *)&cmd_vf_mac_addr_port,
6903 (void *)&cmd_vf_mac_addr_portnum,
6904 (void *)&cmd_vf_mac_addr_vf,
6905 (void *)&cmd_vf_mac_addr_vfnum,
6906 (void *)&cmd_vf_mac_addr_addr,
6911 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6912 struct cmd_vf_rx_vlan_filter {
6913 cmdline_fixed_string_t rx_vlan;
6914 cmdline_fixed_string_t what;
6916 cmdline_fixed_string_t port;
6918 cmdline_fixed_string_t vf;
6923 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6924 __attribute__((unused)) struct cmdline *cl,
6925 __attribute__((unused)) void *data)
6927 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6930 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6932 #ifdef RTE_LIBRTE_IXGBE_PMD
6933 if (ret == -ENOTSUP)
6934 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6935 res->vlan_id, res->vf_mask, is_add);
6937 #ifdef RTE_LIBRTE_I40E_PMD
6938 if (ret == -ENOTSUP)
6939 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6940 res->vlan_id, res->vf_mask, is_add);
6947 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6948 res->vlan_id, res->vf_mask);
6951 printf("invalid port_id %d\n", res->port_id);
6954 printf("function not implemented or supported\n");
6957 printf("programming error: (%s)\n", strerror(-ret));
6961 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6962 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6963 rx_vlan, "rx_vlan");
6964 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6965 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6967 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6968 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6970 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6971 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6973 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6974 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6976 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6977 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6979 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6980 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6983 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6984 .f = cmd_vf_rx_vlan_filter_parsed,
6986 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6987 "(vf_mask = hexadecimal VF mask)",
6989 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6990 (void *)&cmd_vf_rx_vlan_filter_what,
6991 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6992 (void *)&cmd_vf_rx_vlan_filter_port,
6993 (void *)&cmd_vf_rx_vlan_filter_portid,
6994 (void *)&cmd_vf_rx_vlan_filter_vf,
6995 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7000 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7001 struct cmd_queue_rate_limit_result {
7002 cmdline_fixed_string_t set;
7003 cmdline_fixed_string_t port;
7005 cmdline_fixed_string_t queue;
7007 cmdline_fixed_string_t rate;
7011 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7012 __attribute__((unused)) struct cmdline *cl,
7013 __attribute__((unused)) void *data)
7015 struct cmd_queue_rate_limit_result *res = parsed_result;
7018 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7019 && (strcmp(res->queue, "queue") == 0)
7020 && (strcmp(res->rate, "rate") == 0))
7021 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7024 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7028 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7029 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7031 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7032 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7034 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7035 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7037 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7038 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7040 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7041 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7043 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7044 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7046 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7047 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7050 cmdline_parse_inst_t cmd_queue_rate_limit = {
7051 .f = cmd_queue_rate_limit_parsed,
7053 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7054 "Set rate limit for a queue on port_id",
7056 (void *)&cmd_queue_rate_limit_set,
7057 (void *)&cmd_queue_rate_limit_port,
7058 (void *)&cmd_queue_rate_limit_portnum,
7059 (void *)&cmd_queue_rate_limit_queue,
7060 (void *)&cmd_queue_rate_limit_queuenum,
7061 (void *)&cmd_queue_rate_limit_rate,
7062 (void *)&cmd_queue_rate_limit_ratenum,
7067 #ifdef RTE_LIBRTE_IXGBE_PMD
7068 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7069 struct cmd_vf_rate_limit_result {
7070 cmdline_fixed_string_t set;
7071 cmdline_fixed_string_t port;
7073 cmdline_fixed_string_t vf;
7075 cmdline_fixed_string_t rate;
7077 cmdline_fixed_string_t q_msk;
7081 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7082 __attribute__((unused)) struct cmdline *cl,
7083 __attribute__((unused)) void *data)
7085 struct cmd_vf_rate_limit_result *res = parsed_result;
7088 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7089 && (strcmp(res->vf, "vf") == 0)
7090 && (strcmp(res->rate, "rate") == 0)
7091 && (strcmp(res->q_msk, "queue_mask") == 0))
7092 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7093 res->rate_num, res->q_msk_val);
7095 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7099 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7100 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7102 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7103 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7105 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7106 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7108 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7109 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7111 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7112 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7114 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7115 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7117 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7118 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7120 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7121 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7122 q_msk, "queue_mask");
7123 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7124 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7127 cmdline_parse_inst_t cmd_vf_rate_limit = {
7128 .f = cmd_vf_rate_limit_parsed,
7130 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7131 "queue_mask <queue_mask_value>: "
7132 "Set rate limit for queues of VF on port_id",
7134 (void *)&cmd_vf_rate_limit_set,
7135 (void *)&cmd_vf_rate_limit_port,
7136 (void *)&cmd_vf_rate_limit_portnum,
7137 (void *)&cmd_vf_rate_limit_vf,
7138 (void *)&cmd_vf_rate_limit_vfnum,
7139 (void *)&cmd_vf_rate_limit_rate,
7140 (void *)&cmd_vf_rate_limit_ratenum,
7141 (void *)&cmd_vf_rate_limit_q_msk,
7142 (void *)&cmd_vf_rate_limit_q_msk_val,
7148 /* *** ADD TUNNEL FILTER OF A PORT *** */
7149 struct cmd_tunnel_filter_result {
7150 cmdline_fixed_string_t cmd;
7151 cmdline_fixed_string_t what;
7153 struct ether_addr outer_mac;
7154 struct ether_addr inner_mac;
7155 cmdline_ipaddr_t ip_value;
7156 uint16_t inner_vlan;
7157 cmdline_fixed_string_t tunnel_type;
7158 cmdline_fixed_string_t filter_type;
7164 cmd_tunnel_filter_parsed(void *parsed_result,
7165 __attribute__((unused)) struct cmdline *cl,
7166 __attribute__((unused)) void *data)
7168 struct cmd_tunnel_filter_result *res = parsed_result;
7169 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7172 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7174 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7175 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7176 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7178 if (res->ip_value.family == AF_INET) {
7179 tunnel_filter_conf.ip_addr.ipv4_addr =
7180 res->ip_value.addr.ipv4.s_addr;
7181 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7183 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7184 &(res->ip_value.addr.ipv6),
7185 sizeof(struct in6_addr));
7186 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7189 if (!strcmp(res->filter_type, "imac-ivlan"))
7190 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7191 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7192 tunnel_filter_conf.filter_type =
7193 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7194 else if (!strcmp(res->filter_type, "imac-tenid"))
7195 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7196 else if (!strcmp(res->filter_type, "imac"))
7197 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7198 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7199 tunnel_filter_conf.filter_type =
7200 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7201 else if (!strcmp(res->filter_type, "oip"))
7202 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7203 else if (!strcmp(res->filter_type, "iip"))
7204 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7206 printf("The filter type is not supported");
7210 if (!strcmp(res->tunnel_type, "vxlan"))
7211 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7212 else if (!strcmp(res->tunnel_type, "nvgre"))
7213 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7214 else if (!strcmp(res->tunnel_type, "ipingre"))
7215 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7217 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7221 tunnel_filter_conf.tenant_id = res->tenant_id;
7222 tunnel_filter_conf.queue_id = res->queue_num;
7223 if (!strcmp(res->what, "add"))
7224 ret = rte_eth_dev_filter_ctrl(res->port_id,
7225 RTE_ETH_FILTER_TUNNEL,
7227 &tunnel_filter_conf);
7229 ret = rte_eth_dev_filter_ctrl(res->port_id,
7230 RTE_ETH_FILTER_TUNNEL,
7231 RTE_ETH_FILTER_DELETE,
7232 &tunnel_filter_conf);
7234 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7238 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7239 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7240 cmd, "tunnel_filter");
7241 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7242 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7244 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7245 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7247 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7248 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7250 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7251 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7253 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7254 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7255 inner_vlan, UINT16);
7256 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7257 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7259 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7260 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7261 tunnel_type, "vxlan#nvgre#ipingre");
7263 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7264 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7265 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7266 "imac#omac-imac-tenid");
7267 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7268 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7270 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7271 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7274 cmdline_parse_inst_t cmd_tunnel_filter = {
7275 .f = cmd_tunnel_filter_parsed,
7277 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7278 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7279 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7280 "<queue_id>: Add/Rm tunnel filter of a port",
7282 (void *)&cmd_tunnel_filter_cmd,
7283 (void *)&cmd_tunnel_filter_what,
7284 (void *)&cmd_tunnel_filter_port_id,
7285 (void *)&cmd_tunnel_filter_outer_mac,
7286 (void *)&cmd_tunnel_filter_inner_mac,
7287 (void *)&cmd_tunnel_filter_ip_value,
7288 (void *)&cmd_tunnel_filter_innner_vlan,
7289 (void *)&cmd_tunnel_filter_tunnel_type,
7290 (void *)&cmd_tunnel_filter_filter_type,
7291 (void *)&cmd_tunnel_filter_tenant_id,
7292 (void *)&cmd_tunnel_filter_queue_num,
7297 /* *** CONFIGURE TUNNEL UDP PORT *** */
7298 struct cmd_tunnel_udp_config {
7299 cmdline_fixed_string_t cmd;
7300 cmdline_fixed_string_t what;
7306 cmd_tunnel_udp_config_parsed(void *parsed_result,
7307 __attribute__((unused)) struct cmdline *cl,
7308 __attribute__((unused)) void *data)
7310 struct cmd_tunnel_udp_config *res = parsed_result;
7311 struct rte_eth_udp_tunnel tunnel_udp;
7314 tunnel_udp.udp_port = res->udp_port;
7316 if (!strcmp(res->cmd, "rx_vxlan_port"))
7317 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7319 if (!strcmp(res->what, "add"))
7320 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7323 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7327 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7330 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7331 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7332 cmd, "rx_vxlan_port");
7333 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7334 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7336 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7337 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7339 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7340 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7343 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7344 .f = cmd_tunnel_udp_config_parsed,
7346 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7347 "Add/Remove a tunneling UDP port filter",
7349 (void *)&cmd_tunnel_udp_config_cmd,
7350 (void *)&cmd_tunnel_udp_config_what,
7351 (void *)&cmd_tunnel_udp_config_udp_port,
7352 (void *)&cmd_tunnel_udp_config_port_id,
7357 /* *** GLOBAL CONFIG *** */
7358 struct cmd_global_config_result {
7359 cmdline_fixed_string_t cmd;
7361 cmdline_fixed_string_t cfg_type;
7366 cmd_global_config_parsed(void *parsed_result,
7367 __attribute__((unused)) struct cmdline *cl,
7368 __attribute__((unused)) void *data)
7370 struct cmd_global_config_result *res = parsed_result;
7371 struct rte_eth_global_cfg conf;
7374 memset(&conf, 0, sizeof(conf));
7375 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7376 conf.cfg.gre_key_len = res->len;
7377 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7378 RTE_ETH_FILTER_SET, &conf);
7380 printf("Global config error\n");
7383 cmdline_parse_token_string_t cmd_global_config_cmd =
7384 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7386 cmdline_parse_token_num_t cmd_global_config_port_id =
7387 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7388 cmdline_parse_token_string_t cmd_global_config_type =
7389 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7390 cfg_type, "gre-key-len");
7391 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7392 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7395 cmdline_parse_inst_t cmd_global_config = {
7396 .f = cmd_global_config_parsed,
7397 .data = (void *)NULL,
7398 .help_str = "global_config <port_id> gre-key-len <key_len>",
7400 (void *)&cmd_global_config_cmd,
7401 (void *)&cmd_global_config_port_id,
7402 (void *)&cmd_global_config_type,
7403 (void *)&cmd_global_config_gre_key_len,
7408 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7409 struct cmd_set_mirror_mask_result {
7410 cmdline_fixed_string_t set;
7411 cmdline_fixed_string_t port;
7413 cmdline_fixed_string_t mirror;
7415 cmdline_fixed_string_t what;
7416 cmdline_fixed_string_t value;
7417 cmdline_fixed_string_t dstpool;
7419 cmdline_fixed_string_t on;
7422 cmdline_parse_token_string_t cmd_mirror_mask_set =
7423 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7425 cmdline_parse_token_string_t cmd_mirror_mask_port =
7426 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7428 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7429 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7431 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7433 mirror, "mirror-rule");
7434 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7435 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7437 cmdline_parse_token_string_t cmd_mirror_mask_what =
7438 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7439 what, "pool-mirror-up#pool-mirror-down"
7441 cmdline_parse_token_string_t cmd_mirror_mask_value =
7442 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7444 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7445 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7446 dstpool, "dst-pool");
7447 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7448 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7450 cmdline_parse_token_string_t cmd_mirror_mask_on =
7451 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7455 cmd_set_mirror_mask_parsed(void *parsed_result,
7456 __attribute__((unused)) struct cmdline *cl,
7457 __attribute__((unused)) void *data)
7460 struct cmd_set_mirror_mask_result *res = parsed_result;
7461 struct rte_eth_mirror_conf mr_conf;
7463 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7465 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7467 mr_conf.dst_pool = res->dstpool_id;
7469 if (!strcmp(res->what, "pool-mirror-up")) {
7470 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7471 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7472 } else if (!strcmp(res->what, "pool-mirror-down")) {
7473 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7474 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7475 } else if (!strcmp(res->what, "vlan-mirror")) {
7476 mr_conf.rule_type = ETH_MIRROR_VLAN;
7477 nb_item = parse_item_list(res->value, "vlan",
7478 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7482 for (i = 0; i < nb_item; i++) {
7483 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7484 printf("Invalid vlan_id: must be < 4096\n");
7488 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7489 mr_conf.vlan.vlan_mask |= 1ULL << i;
7493 if (!strcmp(res->on, "on"))
7494 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7497 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7500 printf("mirror rule add error: (%s)\n", strerror(-ret));
7503 cmdline_parse_inst_t cmd_set_mirror_mask = {
7504 .f = cmd_set_mirror_mask_parsed,
7506 .help_str = "set port <port_id> mirror-rule <rule_id> "
7507 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7508 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7510 (void *)&cmd_mirror_mask_set,
7511 (void *)&cmd_mirror_mask_port,
7512 (void *)&cmd_mirror_mask_portid,
7513 (void *)&cmd_mirror_mask_mirror,
7514 (void *)&cmd_mirror_mask_ruleid,
7515 (void *)&cmd_mirror_mask_what,
7516 (void *)&cmd_mirror_mask_value,
7517 (void *)&cmd_mirror_mask_dstpool,
7518 (void *)&cmd_mirror_mask_poolid,
7519 (void *)&cmd_mirror_mask_on,
7524 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7525 struct cmd_set_mirror_link_result {
7526 cmdline_fixed_string_t set;
7527 cmdline_fixed_string_t port;
7529 cmdline_fixed_string_t mirror;
7531 cmdline_fixed_string_t what;
7532 cmdline_fixed_string_t dstpool;
7534 cmdline_fixed_string_t on;
7537 cmdline_parse_token_string_t cmd_mirror_link_set =
7538 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7540 cmdline_parse_token_string_t cmd_mirror_link_port =
7541 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7543 cmdline_parse_token_num_t cmd_mirror_link_portid =
7544 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7546 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7547 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7548 mirror, "mirror-rule");
7549 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7550 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7552 cmdline_parse_token_string_t cmd_mirror_link_what =
7553 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7554 what, "uplink-mirror#downlink-mirror");
7555 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7556 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7557 dstpool, "dst-pool");
7558 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7559 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7561 cmdline_parse_token_string_t cmd_mirror_link_on =
7562 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7566 cmd_set_mirror_link_parsed(void *parsed_result,
7567 __attribute__((unused)) struct cmdline *cl,
7568 __attribute__((unused)) void *data)
7571 struct cmd_set_mirror_link_result *res = parsed_result;
7572 struct rte_eth_mirror_conf mr_conf;
7574 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7575 if (!strcmp(res->what, "uplink-mirror"))
7576 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7578 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7580 mr_conf.dst_pool = res->dstpool_id;
7582 if (!strcmp(res->on, "on"))
7583 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7586 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7589 /* check the return value and print it if is < 0 */
7591 printf("mirror rule add error: (%s)\n", strerror(-ret));
7595 cmdline_parse_inst_t cmd_set_mirror_link = {
7596 .f = cmd_set_mirror_link_parsed,
7598 .help_str = "set port <port_id> mirror-rule <rule_id> "
7599 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7601 (void *)&cmd_mirror_link_set,
7602 (void *)&cmd_mirror_link_port,
7603 (void *)&cmd_mirror_link_portid,
7604 (void *)&cmd_mirror_link_mirror,
7605 (void *)&cmd_mirror_link_ruleid,
7606 (void *)&cmd_mirror_link_what,
7607 (void *)&cmd_mirror_link_dstpool,
7608 (void *)&cmd_mirror_link_poolid,
7609 (void *)&cmd_mirror_link_on,
7614 /* *** RESET VM MIRROR RULE *** */
7615 struct cmd_rm_mirror_rule_result {
7616 cmdline_fixed_string_t reset;
7617 cmdline_fixed_string_t port;
7619 cmdline_fixed_string_t mirror;
7623 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7624 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7626 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7627 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7629 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7630 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7632 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7633 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7634 mirror, "mirror-rule");
7635 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7636 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7640 cmd_reset_mirror_rule_parsed(void *parsed_result,
7641 __attribute__((unused)) struct cmdline *cl,
7642 __attribute__((unused)) void *data)
7645 struct cmd_set_mirror_link_result *res = parsed_result;
7647 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7649 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7652 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7653 .f = cmd_reset_mirror_rule_parsed,
7655 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7657 (void *)&cmd_rm_mirror_rule_reset,
7658 (void *)&cmd_rm_mirror_rule_port,
7659 (void *)&cmd_rm_mirror_rule_portid,
7660 (void *)&cmd_rm_mirror_rule_mirror,
7661 (void *)&cmd_rm_mirror_rule_ruleid,
7666 /* ******************************************************************************** */
7668 struct cmd_dump_result {
7669 cmdline_fixed_string_t dump;
7673 dump_struct_sizes(void)
7675 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7676 DUMP_SIZE(struct rte_mbuf);
7677 DUMP_SIZE(struct rte_mempool);
7678 DUMP_SIZE(struct rte_ring);
7682 static void cmd_dump_parsed(void *parsed_result,
7683 __attribute__((unused)) struct cmdline *cl,
7684 __attribute__((unused)) void *data)
7686 struct cmd_dump_result *res = parsed_result;
7688 if (!strcmp(res->dump, "dump_physmem"))
7689 rte_dump_physmem_layout(stdout);
7690 else if (!strcmp(res->dump, "dump_memzone"))
7691 rte_memzone_dump(stdout);
7692 else if (!strcmp(res->dump, "dump_struct_sizes"))
7693 dump_struct_sizes();
7694 else if (!strcmp(res->dump, "dump_ring"))
7695 rte_ring_list_dump(stdout);
7696 else if (!strcmp(res->dump, "dump_mempool"))
7697 rte_mempool_list_dump(stdout);
7698 else if (!strcmp(res->dump, "dump_devargs"))
7699 rte_eal_devargs_dump(stdout);
7702 cmdline_parse_token_string_t cmd_dump_dump =
7703 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7706 "dump_struct_sizes#"
7711 cmdline_parse_inst_t cmd_dump = {
7712 .f = cmd_dump_parsed, /* function to call */
7713 .data = NULL, /* 2nd arg of func */
7714 .help_str = "Dump status",
7715 .tokens = { /* token list, NULL terminated */
7716 (void *)&cmd_dump_dump,
7721 /* ******************************************************************************** */
7723 struct cmd_dump_one_result {
7724 cmdline_fixed_string_t dump;
7725 cmdline_fixed_string_t name;
7728 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7729 __attribute__((unused)) void *data)
7731 struct cmd_dump_one_result *res = parsed_result;
7733 if (!strcmp(res->dump, "dump_ring")) {
7735 r = rte_ring_lookup(res->name);
7737 cmdline_printf(cl, "Cannot find ring\n");
7740 rte_ring_dump(stdout, r);
7741 } else if (!strcmp(res->dump, "dump_mempool")) {
7742 struct rte_mempool *mp;
7743 mp = rte_mempool_lookup(res->name);
7745 cmdline_printf(cl, "Cannot find mempool\n");
7748 rte_mempool_dump(stdout, mp);
7752 cmdline_parse_token_string_t cmd_dump_one_dump =
7753 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7754 "dump_ring#dump_mempool");
7756 cmdline_parse_token_string_t cmd_dump_one_name =
7757 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7759 cmdline_parse_inst_t cmd_dump_one = {
7760 .f = cmd_dump_one_parsed, /* function to call */
7761 .data = NULL, /* 2nd arg of func */
7762 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7763 .tokens = { /* token list, NULL terminated */
7764 (void *)&cmd_dump_one_dump,
7765 (void *)&cmd_dump_one_name,
7770 /* *** Add/Del syn filter *** */
7771 struct cmd_syn_filter_result {
7772 cmdline_fixed_string_t filter;
7774 cmdline_fixed_string_t ops;
7775 cmdline_fixed_string_t priority;
7776 cmdline_fixed_string_t high;
7777 cmdline_fixed_string_t queue;
7782 cmd_syn_filter_parsed(void *parsed_result,
7783 __attribute__((unused)) struct cmdline *cl,
7784 __attribute__((unused)) void *data)
7786 struct cmd_syn_filter_result *res = parsed_result;
7787 struct rte_eth_syn_filter syn_filter;
7790 ret = rte_eth_dev_filter_supported(res->port_id,
7791 RTE_ETH_FILTER_SYN);
7793 printf("syn filter is not supported on port %u.\n",
7798 memset(&syn_filter, 0, sizeof(syn_filter));
7800 if (!strcmp(res->ops, "add")) {
7801 if (!strcmp(res->high, "high"))
7802 syn_filter.hig_pri = 1;
7804 syn_filter.hig_pri = 0;
7806 syn_filter.queue = res->queue_id;
7807 ret = rte_eth_dev_filter_ctrl(res->port_id,
7812 ret = rte_eth_dev_filter_ctrl(res->port_id,
7814 RTE_ETH_FILTER_DELETE,
7818 printf("syn filter programming error: (%s)\n",
7822 cmdline_parse_token_string_t cmd_syn_filter_filter =
7823 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7824 filter, "syn_filter");
7825 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7826 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7828 cmdline_parse_token_string_t cmd_syn_filter_ops =
7829 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7831 cmdline_parse_token_string_t cmd_syn_filter_priority =
7832 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7833 priority, "priority");
7834 cmdline_parse_token_string_t cmd_syn_filter_high =
7835 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7837 cmdline_parse_token_string_t cmd_syn_filter_queue =
7838 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7840 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7841 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7844 cmdline_parse_inst_t cmd_syn_filter = {
7845 .f = cmd_syn_filter_parsed,
7847 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7848 "<queue_id>: Add/Delete syn filter",
7850 (void *)&cmd_syn_filter_filter,
7851 (void *)&cmd_syn_filter_port_id,
7852 (void *)&cmd_syn_filter_ops,
7853 (void *)&cmd_syn_filter_priority,
7854 (void *)&cmd_syn_filter_high,
7855 (void *)&cmd_syn_filter_queue,
7856 (void *)&cmd_syn_filter_queue_id,
7861 /* *** ADD/REMOVE A 2tuple FILTER *** */
7862 struct cmd_2tuple_filter_result {
7863 cmdline_fixed_string_t filter;
7865 cmdline_fixed_string_t ops;
7866 cmdline_fixed_string_t dst_port;
7867 uint16_t dst_port_value;
7868 cmdline_fixed_string_t protocol;
7869 uint8_t protocol_value;
7870 cmdline_fixed_string_t mask;
7872 cmdline_fixed_string_t tcp_flags;
7873 uint8_t tcp_flags_value;
7874 cmdline_fixed_string_t priority;
7875 uint8_t priority_value;
7876 cmdline_fixed_string_t queue;
7881 cmd_2tuple_filter_parsed(void *parsed_result,
7882 __attribute__((unused)) struct cmdline *cl,
7883 __attribute__((unused)) void *data)
7885 struct rte_eth_ntuple_filter filter;
7886 struct cmd_2tuple_filter_result *res = parsed_result;
7889 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7891 printf("ntuple filter is not supported on port %u.\n",
7896 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7898 filter.flags = RTE_2TUPLE_FLAGS;
7899 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7900 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7901 filter.proto = res->protocol_value;
7902 filter.priority = res->priority_value;
7903 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7904 printf("nonzero tcp_flags is only meaningful"
7905 " when protocol is TCP.\n");
7908 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7909 printf("invalid TCP flags.\n");
7913 if (res->tcp_flags_value != 0) {
7914 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7915 filter.tcp_flags = res->tcp_flags_value;
7918 /* need convert to big endian. */
7919 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7920 filter.queue = res->queue_id;
7922 if (!strcmp(res->ops, "add"))
7923 ret = rte_eth_dev_filter_ctrl(res->port_id,
7924 RTE_ETH_FILTER_NTUPLE,
7928 ret = rte_eth_dev_filter_ctrl(res->port_id,
7929 RTE_ETH_FILTER_NTUPLE,
7930 RTE_ETH_FILTER_DELETE,
7933 printf("2tuple filter programming error: (%s)\n",
7938 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7939 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7940 filter, "2tuple_filter");
7941 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7942 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7944 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7945 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7947 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7948 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7949 dst_port, "dst_port");
7950 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7951 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7952 dst_port_value, UINT16);
7953 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7954 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7955 protocol, "protocol");
7956 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7957 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7958 protocol_value, UINT8);
7959 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7960 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7962 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7963 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7965 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7966 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7967 tcp_flags, "tcp_flags");
7968 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7969 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7970 tcp_flags_value, UINT8);
7971 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7972 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7973 priority, "priority");
7974 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7975 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7976 priority_value, UINT8);
7977 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7978 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7980 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7981 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7984 cmdline_parse_inst_t cmd_2tuple_filter = {
7985 .f = cmd_2tuple_filter_parsed,
7987 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7988 "<value> mask <value> tcp_flags <value> priority <value> queue "
7989 "<queue_id>: Add a 2tuple filter",
7991 (void *)&cmd_2tuple_filter_filter,
7992 (void *)&cmd_2tuple_filter_port_id,
7993 (void *)&cmd_2tuple_filter_ops,
7994 (void *)&cmd_2tuple_filter_dst_port,
7995 (void *)&cmd_2tuple_filter_dst_port_value,
7996 (void *)&cmd_2tuple_filter_protocol,
7997 (void *)&cmd_2tuple_filter_protocol_value,
7998 (void *)&cmd_2tuple_filter_mask,
7999 (void *)&cmd_2tuple_filter_mask_value,
8000 (void *)&cmd_2tuple_filter_tcp_flags,
8001 (void *)&cmd_2tuple_filter_tcp_flags_value,
8002 (void *)&cmd_2tuple_filter_priority,
8003 (void *)&cmd_2tuple_filter_priority_value,
8004 (void *)&cmd_2tuple_filter_queue,
8005 (void *)&cmd_2tuple_filter_queue_id,
8010 /* *** ADD/REMOVE A 5tuple FILTER *** */
8011 struct cmd_5tuple_filter_result {
8012 cmdline_fixed_string_t filter;
8014 cmdline_fixed_string_t ops;
8015 cmdline_fixed_string_t dst_ip;
8016 cmdline_ipaddr_t dst_ip_value;
8017 cmdline_fixed_string_t src_ip;
8018 cmdline_ipaddr_t src_ip_value;
8019 cmdline_fixed_string_t dst_port;
8020 uint16_t dst_port_value;
8021 cmdline_fixed_string_t src_port;
8022 uint16_t src_port_value;
8023 cmdline_fixed_string_t protocol;
8024 uint8_t protocol_value;
8025 cmdline_fixed_string_t mask;
8027 cmdline_fixed_string_t tcp_flags;
8028 uint8_t tcp_flags_value;
8029 cmdline_fixed_string_t priority;
8030 uint8_t priority_value;
8031 cmdline_fixed_string_t queue;
8036 cmd_5tuple_filter_parsed(void *parsed_result,
8037 __attribute__((unused)) struct cmdline *cl,
8038 __attribute__((unused)) void *data)
8040 struct rte_eth_ntuple_filter filter;
8041 struct cmd_5tuple_filter_result *res = parsed_result;
8044 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8046 printf("ntuple filter is not supported on port %u.\n",
8051 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8053 filter.flags = RTE_5TUPLE_FLAGS;
8054 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8055 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8056 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8057 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8058 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8059 filter.proto = res->protocol_value;
8060 filter.priority = res->priority_value;
8061 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8062 printf("nonzero tcp_flags is only meaningful"
8063 " when protocol is TCP.\n");
8066 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8067 printf("invalid TCP flags.\n");
8071 if (res->tcp_flags_value != 0) {
8072 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8073 filter.tcp_flags = res->tcp_flags_value;
8076 if (res->dst_ip_value.family == AF_INET)
8077 /* no need to convert, already big endian. */
8078 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8080 if (filter.dst_ip_mask == 0) {
8081 printf("can not support ipv6 involved compare.\n");
8087 if (res->src_ip_value.family == AF_INET)
8088 /* no need to convert, already big endian. */
8089 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8091 if (filter.src_ip_mask == 0) {
8092 printf("can not support ipv6 involved compare.\n");
8097 /* need convert to big endian. */
8098 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8099 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8100 filter.queue = res->queue_id;
8102 if (!strcmp(res->ops, "add"))
8103 ret = rte_eth_dev_filter_ctrl(res->port_id,
8104 RTE_ETH_FILTER_NTUPLE,
8108 ret = rte_eth_dev_filter_ctrl(res->port_id,
8109 RTE_ETH_FILTER_NTUPLE,
8110 RTE_ETH_FILTER_DELETE,
8113 printf("5tuple filter programming error: (%s)\n",
8117 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8118 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8119 filter, "5tuple_filter");
8120 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8121 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8123 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8124 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8126 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8127 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8129 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8130 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8132 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8133 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8135 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8136 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8138 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8139 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8140 dst_port, "dst_port");
8141 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8142 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8143 dst_port_value, UINT16);
8144 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8145 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8146 src_port, "src_port");
8147 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8148 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8149 src_port_value, UINT16);
8150 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8151 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8152 protocol, "protocol");
8153 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8154 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8155 protocol_value, UINT8);
8156 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8157 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8159 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8160 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8162 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8163 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8164 tcp_flags, "tcp_flags");
8165 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8166 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8167 tcp_flags_value, UINT8);
8168 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8169 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8170 priority, "priority");
8171 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8172 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8173 priority_value, UINT8);
8174 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8175 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8177 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8178 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8181 cmdline_parse_inst_t cmd_5tuple_filter = {
8182 .f = cmd_5tuple_filter_parsed,
8184 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8185 "src_ip <value> dst_port <value> src_port <value> "
8186 "protocol <value> mask <value> tcp_flags <value> "
8187 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8189 (void *)&cmd_5tuple_filter_filter,
8190 (void *)&cmd_5tuple_filter_port_id,
8191 (void *)&cmd_5tuple_filter_ops,
8192 (void *)&cmd_5tuple_filter_dst_ip,
8193 (void *)&cmd_5tuple_filter_dst_ip_value,
8194 (void *)&cmd_5tuple_filter_src_ip,
8195 (void *)&cmd_5tuple_filter_src_ip_value,
8196 (void *)&cmd_5tuple_filter_dst_port,
8197 (void *)&cmd_5tuple_filter_dst_port_value,
8198 (void *)&cmd_5tuple_filter_src_port,
8199 (void *)&cmd_5tuple_filter_src_port_value,
8200 (void *)&cmd_5tuple_filter_protocol,
8201 (void *)&cmd_5tuple_filter_protocol_value,
8202 (void *)&cmd_5tuple_filter_mask,
8203 (void *)&cmd_5tuple_filter_mask_value,
8204 (void *)&cmd_5tuple_filter_tcp_flags,
8205 (void *)&cmd_5tuple_filter_tcp_flags_value,
8206 (void *)&cmd_5tuple_filter_priority,
8207 (void *)&cmd_5tuple_filter_priority_value,
8208 (void *)&cmd_5tuple_filter_queue,
8209 (void *)&cmd_5tuple_filter_queue_id,
8214 /* *** ADD/REMOVE A flex FILTER *** */
8215 struct cmd_flex_filter_result {
8216 cmdline_fixed_string_t filter;
8217 cmdline_fixed_string_t ops;
8219 cmdline_fixed_string_t len;
8221 cmdline_fixed_string_t bytes;
8222 cmdline_fixed_string_t bytes_value;
8223 cmdline_fixed_string_t mask;
8224 cmdline_fixed_string_t mask_value;
8225 cmdline_fixed_string_t priority;
8226 uint8_t priority_value;
8227 cmdline_fixed_string_t queue;
8231 static int xdigit2val(unsigned char c)
8236 else if (isupper(c))
8244 cmd_flex_filter_parsed(void *parsed_result,
8245 __attribute__((unused)) struct cmdline *cl,
8246 __attribute__((unused)) void *data)
8249 struct rte_eth_flex_filter filter;
8250 struct cmd_flex_filter_result *res = parsed_result;
8251 char *bytes_ptr, *mask_ptr;
8252 uint16_t len, i, j = 0;
8257 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8258 printf("the len exceed the max length 128\n");
8261 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8262 filter.len = res->len_value;
8263 filter.priority = res->priority_value;
8264 filter.queue = res->queue_id;
8265 bytes_ptr = res->bytes_value;
8266 mask_ptr = res->mask_value;
8268 /* translate bytes string to array. */
8269 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8270 (bytes_ptr[1] == 'X')))
8272 len = strnlen(bytes_ptr, res->len_value * 2);
8273 if (len == 0 || (len % 8 != 0)) {
8274 printf("please check len and bytes input\n");
8277 for (i = 0; i < len; i++) {
8279 if (isxdigit(c) == 0) {
8280 /* invalid characters. */
8281 printf("invalid input\n");
8284 val = xdigit2val(c);
8287 filter.bytes[j] = byte;
8288 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8295 /* translate mask string to uint8_t array. */
8296 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8297 (mask_ptr[1] == 'X')))
8299 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8301 printf("invalid input\n");
8306 for (i = 0; i < len; i++) {
8308 if (isxdigit(c) == 0) {
8309 /* invalid characters. */
8310 printf("invalid input\n");
8313 val = xdigit2val(c);
8316 filter.mask[j] = byte;
8317 printf("mask[%d]:%02x ", j, filter.mask[j]);
8325 if (!strcmp(res->ops, "add"))
8326 ret = rte_eth_dev_filter_ctrl(res->port_id,
8327 RTE_ETH_FILTER_FLEXIBLE,
8331 ret = rte_eth_dev_filter_ctrl(res->port_id,
8332 RTE_ETH_FILTER_FLEXIBLE,
8333 RTE_ETH_FILTER_DELETE,
8337 printf("flex filter setting error: (%s)\n", strerror(-ret));
8340 cmdline_parse_token_string_t cmd_flex_filter_filter =
8341 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8342 filter, "flex_filter");
8343 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8344 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8346 cmdline_parse_token_string_t cmd_flex_filter_ops =
8347 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8349 cmdline_parse_token_string_t cmd_flex_filter_len =
8350 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8352 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8353 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8355 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8356 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8358 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8359 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8361 cmdline_parse_token_string_t cmd_flex_filter_mask =
8362 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8364 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8365 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8367 cmdline_parse_token_string_t cmd_flex_filter_priority =
8368 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8369 priority, "priority");
8370 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8371 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8372 priority_value, UINT8);
8373 cmdline_parse_token_string_t cmd_flex_filter_queue =
8374 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8376 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8377 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8379 cmdline_parse_inst_t cmd_flex_filter = {
8380 .f = cmd_flex_filter_parsed,
8382 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8383 "<value> mask <value> priority <value> queue <queue_id>: "
8384 "Add/Del a flex filter",
8386 (void *)&cmd_flex_filter_filter,
8387 (void *)&cmd_flex_filter_port_id,
8388 (void *)&cmd_flex_filter_ops,
8389 (void *)&cmd_flex_filter_len,
8390 (void *)&cmd_flex_filter_len_value,
8391 (void *)&cmd_flex_filter_bytes,
8392 (void *)&cmd_flex_filter_bytes_value,
8393 (void *)&cmd_flex_filter_mask,
8394 (void *)&cmd_flex_filter_mask_value,
8395 (void *)&cmd_flex_filter_priority,
8396 (void *)&cmd_flex_filter_priority_value,
8397 (void *)&cmd_flex_filter_queue,
8398 (void *)&cmd_flex_filter_queue_id,
8403 /* *** Filters Control *** */
8405 /* *** deal with ethertype filter *** */
8406 struct cmd_ethertype_filter_result {
8407 cmdline_fixed_string_t filter;
8409 cmdline_fixed_string_t ops;
8410 cmdline_fixed_string_t mac;
8411 struct ether_addr mac_addr;
8412 cmdline_fixed_string_t ethertype;
8413 uint16_t ethertype_value;
8414 cmdline_fixed_string_t drop;
8415 cmdline_fixed_string_t queue;
8419 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8420 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8421 filter, "ethertype_filter");
8422 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8423 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8425 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8426 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8428 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8429 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8430 mac, "mac_addr#mac_ignr");
8431 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8432 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8434 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8435 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8436 ethertype, "ethertype");
8437 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8438 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8439 ethertype_value, UINT16);
8440 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8441 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8443 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8444 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8446 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8447 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8451 cmd_ethertype_filter_parsed(void *parsed_result,
8452 __attribute__((unused)) struct cmdline *cl,
8453 __attribute__((unused)) void *data)
8455 struct cmd_ethertype_filter_result *res = parsed_result;
8456 struct rte_eth_ethertype_filter filter;
8459 ret = rte_eth_dev_filter_supported(res->port_id,
8460 RTE_ETH_FILTER_ETHERTYPE);
8462 printf("ethertype filter is not supported on port %u.\n",
8467 memset(&filter, 0, sizeof(filter));
8468 if (!strcmp(res->mac, "mac_addr")) {
8469 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8470 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8471 sizeof(struct ether_addr));
8473 if (!strcmp(res->drop, "drop"))
8474 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8475 filter.ether_type = res->ethertype_value;
8476 filter.queue = res->queue_id;
8478 if (!strcmp(res->ops, "add"))
8479 ret = rte_eth_dev_filter_ctrl(res->port_id,
8480 RTE_ETH_FILTER_ETHERTYPE,
8484 ret = rte_eth_dev_filter_ctrl(res->port_id,
8485 RTE_ETH_FILTER_ETHERTYPE,
8486 RTE_ETH_FILTER_DELETE,
8489 printf("ethertype filter programming error: (%s)\n",
8493 cmdline_parse_inst_t cmd_ethertype_filter = {
8494 .f = cmd_ethertype_filter_parsed,
8496 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8497 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8498 "Add or delete an ethertype filter entry",
8500 (void *)&cmd_ethertype_filter_filter,
8501 (void *)&cmd_ethertype_filter_port_id,
8502 (void *)&cmd_ethertype_filter_ops,
8503 (void *)&cmd_ethertype_filter_mac,
8504 (void *)&cmd_ethertype_filter_mac_addr,
8505 (void *)&cmd_ethertype_filter_ethertype,
8506 (void *)&cmd_ethertype_filter_ethertype_value,
8507 (void *)&cmd_ethertype_filter_drop,
8508 (void *)&cmd_ethertype_filter_queue,
8509 (void *)&cmd_ethertype_filter_queue_id,
8514 /* *** deal with flow director filter *** */
8515 struct cmd_flow_director_result {
8516 cmdline_fixed_string_t flow_director_filter;
8518 cmdline_fixed_string_t mode;
8519 cmdline_fixed_string_t mode_value;
8520 cmdline_fixed_string_t ops;
8521 cmdline_fixed_string_t flow;
8522 cmdline_fixed_string_t flow_type;
8523 cmdline_fixed_string_t ether;
8524 uint16_t ether_type;
8525 cmdline_fixed_string_t src;
8526 cmdline_ipaddr_t ip_src;
8528 cmdline_fixed_string_t dst;
8529 cmdline_ipaddr_t ip_dst;
8531 cmdline_fixed_string_t verify_tag;
8532 uint32_t verify_tag_value;
8533 cmdline_ipaddr_t tos;
8535 cmdline_ipaddr_t proto;
8536 uint8_t proto_value;
8537 cmdline_ipaddr_t ttl;
8539 cmdline_fixed_string_t vlan;
8540 uint16_t vlan_value;
8541 cmdline_fixed_string_t flexbytes;
8542 cmdline_fixed_string_t flexbytes_value;
8543 cmdline_fixed_string_t pf_vf;
8544 cmdline_fixed_string_t drop;
8545 cmdline_fixed_string_t queue;
8547 cmdline_fixed_string_t fd_id;
8548 uint32_t fd_id_value;
8549 cmdline_fixed_string_t mac;
8550 struct ether_addr mac_addr;
8551 cmdline_fixed_string_t tunnel;
8552 cmdline_fixed_string_t tunnel_type;
8553 cmdline_fixed_string_t tunnel_id;
8554 uint32_t tunnel_id_value;
8558 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8561 const char *p, *p0 = q_arg;
8563 unsigned long int_fld;
8564 char *str_fld[max_num];
8569 p = strchr(p0, '(');
8573 p0 = strchr(p, ')');
8578 if (size >= sizeof(s))
8581 snprintf(s, sizeof(s), "%.*s", size, p);
8582 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8583 if (ret < 0 || ret > max_num)
8585 for (i = 0; i < ret; i++) {
8587 int_fld = strtoul(str_fld[i], &end, 0);
8588 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8590 flexbytes[i] = (uint8_t)int_fld;
8596 str2flowtype(char *string)
8599 static const struct {
8602 } flowtype_str[] = {
8603 {"raw", RTE_ETH_FLOW_RAW},
8604 {"ipv4", RTE_ETH_FLOW_IPV4},
8605 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8606 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8607 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8608 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8609 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8610 {"ipv6", RTE_ETH_FLOW_IPV6},
8611 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8612 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8613 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8614 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8615 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8616 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8619 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8620 if (!strcmp(flowtype_str[i].str, string))
8621 return flowtype_str[i].type;
8623 return RTE_ETH_FLOW_UNKNOWN;
8626 static enum rte_eth_fdir_tunnel_type
8627 str2fdir_tunneltype(char *string)
8631 static const struct {
8633 enum rte_eth_fdir_tunnel_type type;
8634 } tunneltype_str[] = {
8635 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8636 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8639 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8640 if (!strcmp(tunneltype_str[i].str, string))
8641 return tunneltype_str[i].type;
8643 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8646 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8648 if ((ip_addr).family == AF_INET) \
8649 (ip) = (ip_addr).addr.ipv4.s_addr; \
8651 printf("invalid parameter.\n"); \
8656 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8658 if ((ip_addr).family == AF_INET6) \
8659 (void)rte_memcpy(&(ip), \
8660 &((ip_addr).addr.ipv6), \
8661 sizeof(struct in6_addr)); \
8663 printf("invalid parameter.\n"); \
8669 cmd_flow_director_filter_parsed(void *parsed_result,
8670 __attribute__((unused)) struct cmdline *cl,
8671 __attribute__((unused)) void *data)
8673 struct cmd_flow_director_result *res = parsed_result;
8674 struct rte_eth_fdir_filter entry;
8675 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8677 unsigned long vf_id;
8680 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8682 printf("flow director is not supported on port %u.\n",
8686 memset(flexbytes, 0, sizeof(flexbytes));
8687 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8689 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8690 if (strcmp(res->mode_value, "MAC-VLAN")) {
8691 printf("Please set mode to MAC-VLAN.\n");
8694 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8695 if (strcmp(res->mode_value, "Tunnel")) {
8696 printf("Please set mode to Tunnel.\n");
8700 if (strcmp(res->mode_value, "IP")) {
8701 printf("Please set mode to IP.\n");
8704 entry.input.flow_type = str2flowtype(res->flow_type);
8707 ret = parse_flexbytes(res->flexbytes_value,
8709 RTE_ETH_FDIR_MAX_FLEXLEN);
8711 printf("error: Cannot parse flexbytes input.\n");
8715 switch (entry.input.flow_type) {
8716 case RTE_ETH_FLOW_FRAG_IPV4:
8717 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8718 entry.input.flow.ip4_flow.proto = res->proto_value;
8719 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8720 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8721 IPV4_ADDR_TO_UINT(res->ip_dst,
8722 entry.input.flow.ip4_flow.dst_ip);
8723 IPV4_ADDR_TO_UINT(res->ip_src,
8724 entry.input.flow.ip4_flow.src_ip);
8725 entry.input.flow.ip4_flow.tos = res->tos_value;
8726 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8727 /* need convert to big endian. */
8728 entry.input.flow.udp4_flow.dst_port =
8729 rte_cpu_to_be_16(res->port_dst);
8730 entry.input.flow.udp4_flow.src_port =
8731 rte_cpu_to_be_16(res->port_src);
8733 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8734 IPV4_ADDR_TO_UINT(res->ip_dst,
8735 entry.input.flow.sctp4_flow.ip.dst_ip);
8736 IPV4_ADDR_TO_UINT(res->ip_src,
8737 entry.input.flow.sctp4_flow.ip.src_ip);
8738 entry.input.flow.ip4_flow.tos = res->tos_value;
8739 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8740 /* need convert to big endian. */
8741 entry.input.flow.sctp4_flow.dst_port =
8742 rte_cpu_to_be_16(res->port_dst);
8743 entry.input.flow.sctp4_flow.src_port =
8744 rte_cpu_to_be_16(res->port_src);
8745 entry.input.flow.sctp4_flow.verify_tag =
8746 rte_cpu_to_be_32(res->verify_tag_value);
8748 case RTE_ETH_FLOW_FRAG_IPV6:
8749 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8750 entry.input.flow.ipv6_flow.proto = res->proto_value;
8751 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8752 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8753 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8754 entry.input.flow.ipv6_flow.dst_ip);
8755 IPV6_ADDR_TO_ARRAY(res->ip_src,
8756 entry.input.flow.ipv6_flow.src_ip);
8757 entry.input.flow.ipv6_flow.tc = res->tos_value;
8758 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8759 /* need convert to big endian. */
8760 entry.input.flow.udp6_flow.dst_port =
8761 rte_cpu_to_be_16(res->port_dst);
8762 entry.input.flow.udp6_flow.src_port =
8763 rte_cpu_to_be_16(res->port_src);
8765 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8766 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8767 entry.input.flow.sctp6_flow.ip.dst_ip);
8768 IPV6_ADDR_TO_ARRAY(res->ip_src,
8769 entry.input.flow.sctp6_flow.ip.src_ip);
8770 entry.input.flow.ipv6_flow.tc = res->tos_value;
8771 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8772 /* need convert to big endian. */
8773 entry.input.flow.sctp6_flow.dst_port =
8774 rte_cpu_to_be_16(res->port_dst);
8775 entry.input.flow.sctp6_flow.src_port =
8776 rte_cpu_to_be_16(res->port_src);
8777 entry.input.flow.sctp6_flow.verify_tag =
8778 rte_cpu_to_be_32(res->verify_tag_value);
8780 case RTE_ETH_FLOW_L2_PAYLOAD:
8781 entry.input.flow.l2_flow.ether_type =
8782 rte_cpu_to_be_16(res->ether_type);
8788 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8789 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8791 sizeof(struct ether_addr));
8793 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8794 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8796 sizeof(struct ether_addr));
8797 entry.input.flow.tunnel_flow.tunnel_type =
8798 str2fdir_tunneltype(res->tunnel_type);
8799 entry.input.flow.tunnel_flow.tunnel_id =
8800 rte_cpu_to_be_32(res->tunnel_id_value);
8803 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8805 RTE_ETH_FDIR_MAX_FLEXLEN);
8807 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8809 entry.action.flex_off = 0; /*use 0 by default */
8810 if (!strcmp(res->drop, "drop"))
8811 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8813 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8815 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8816 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8817 if (!strcmp(res->pf_vf, "pf"))
8818 entry.input.flow_ext.is_vf = 0;
8819 else if (!strncmp(res->pf_vf, "vf", 2)) {
8820 struct rte_eth_dev_info dev_info;
8822 memset(&dev_info, 0, sizeof(dev_info));
8823 rte_eth_dev_info_get(res->port_id, &dev_info);
8825 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8826 if (errno != 0 || *end != '\0' ||
8827 vf_id >= dev_info.max_vfs) {
8828 printf("invalid parameter %s.\n", res->pf_vf);
8831 entry.input.flow_ext.is_vf = 1;
8832 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8834 printf("invalid parameter %s.\n", res->pf_vf);
8839 /* set to report FD ID by default */
8840 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8841 entry.action.rx_queue = res->queue_id;
8842 entry.soft_id = res->fd_id_value;
8843 if (!strcmp(res->ops, "add"))
8844 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8845 RTE_ETH_FILTER_ADD, &entry);
8846 else if (!strcmp(res->ops, "del"))
8847 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8848 RTE_ETH_FILTER_DELETE, &entry);
8850 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8851 RTE_ETH_FILTER_UPDATE, &entry);
8853 printf("flow director programming error: (%s)\n",
8857 cmdline_parse_token_string_t cmd_flow_director_filter =
8858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8859 flow_director_filter, "flow_director_filter");
8860 cmdline_parse_token_num_t cmd_flow_director_port_id =
8861 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8863 cmdline_parse_token_string_t cmd_flow_director_ops =
8864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8865 ops, "add#del#update");
8866 cmdline_parse_token_string_t cmd_flow_director_flow =
8867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8869 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8871 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8872 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8873 cmdline_parse_token_string_t cmd_flow_director_ether =
8874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8876 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8877 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8878 ether_type, UINT16);
8879 cmdline_parse_token_string_t cmd_flow_director_src =
8880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8882 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8883 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8885 cmdline_parse_token_num_t cmd_flow_director_port_src =
8886 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8888 cmdline_parse_token_string_t cmd_flow_director_dst =
8889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8891 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8892 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8894 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8895 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8897 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8899 verify_tag, "verify_tag");
8900 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8901 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8902 verify_tag_value, UINT32);
8903 cmdline_parse_token_string_t cmd_flow_director_tos =
8904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8906 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8907 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8909 cmdline_parse_token_string_t cmd_flow_director_proto =
8910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8912 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8913 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8914 proto_value, UINT8);
8915 cmdline_parse_token_string_t cmd_flow_director_ttl =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8918 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8919 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8921 cmdline_parse_token_string_t cmd_flow_director_vlan =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8925 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8926 vlan_value, UINT16);
8927 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8929 flexbytes, "flexbytes");
8930 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8932 flexbytes_value, NULL);
8933 cmdline_parse_token_string_t cmd_flow_director_drop =
8934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8936 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8939 cmdline_parse_token_string_t cmd_flow_director_queue =
8940 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8942 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8943 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8945 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8948 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8949 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8950 fd_id_value, UINT32);
8952 cmdline_parse_token_string_t cmd_flow_director_mode =
8953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8955 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8958 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8960 mode_value, "MAC-VLAN");
8961 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8963 mode_value, "Tunnel");
8964 cmdline_parse_token_string_t cmd_flow_director_mac =
8965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8967 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8968 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8970 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8973 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8975 tunnel_type, "NVGRE#VxLAN");
8976 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8978 tunnel_id, "tunnel-id");
8979 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8980 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8981 tunnel_id_value, UINT32);
8983 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8984 .f = cmd_flow_director_filter_parsed,
8986 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8987 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8988 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8989 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8990 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8991 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8992 "fd_id <fd_id_value>: "
8993 "Add or delete an ip flow director entry on NIC",
8995 (void *)&cmd_flow_director_filter,
8996 (void *)&cmd_flow_director_port_id,
8997 (void *)&cmd_flow_director_mode,
8998 (void *)&cmd_flow_director_mode_ip,
8999 (void *)&cmd_flow_director_ops,
9000 (void *)&cmd_flow_director_flow,
9001 (void *)&cmd_flow_director_flow_type,
9002 (void *)&cmd_flow_director_src,
9003 (void *)&cmd_flow_director_ip_src,
9004 (void *)&cmd_flow_director_dst,
9005 (void *)&cmd_flow_director_ip_dst,
9006 (void *)&cmd_flow_director_tos,
9007 (void *)&cmd_flow_director_tos_value,
9008 (void *)&cmd_flow_director_proto,
9009 (void *)&cmd_flow_director_proto_value,
9010 (void *)&cmd_flow_director_ttl,
9011 (void *)&cmd_flow_director_ttl_value,
9012 (void *)&cmd_flow_director_vlan,
9013 (void *)&cmd_flow_director_vlan_value,
9014 (void *)&cmd_flow_director_flexbytes,
9015 (void *)&cmd_flow_director_flexbytes_value,
9016 (void *)&cmd_flow_director_drop,
9017 (void *)&cmd_flow_director_pf_vf,
9018 (void *)&cmd_flow_director_queue,
9019 (void *)&cmd_flow_director_queue_id,
9020 (void *)&cmd_flow_director_fd_id,
9021 (void *)&cmd_flow_director_fd_id_value,
9026 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9027 .f = cmd_flow_director_filter_parsed,
9029 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9030 "director entry on NIC",
9032 (void *)&cmd_flow_director_filter,
9033 (void *)&cmd_flow_director_port_id,
9034 (void *)&cmd_flow_director_mode,
9035 (void *)&cmd_flow_director_mode_ip,
9036 (void *)&cmd_flow_director_ops,
9037 (void *)&cmd_flow_director_flow,
9038 (void *)&cmd_flow_director_flow_type,
9039 (void *)&cmd_flow_director_src,
9040 (void *)&cmd_flow_director_ip_src,
9041 (void *)&cmd_flow_director_port_src,
9042 (void *)&cmd_flow_director_dst,
9043 (void *)&cmd_flow_director_ip_dst,
9044 (void *)&cmd_flow_director_port_dst,
9045 (void *)&cmd_flow_director_tos,
9046 (void *)&cmd_flow_director_tos_value,
9047 (void *)&cmd_flow_director_ttl,
9048 (void *)&cmd_flow_director_ttl_value,
9049 (void *)&cmd_flow_director_vlan,
9050 (void *)&cmd_flow_director_vlan_value,
9051 (void *)&cmd_flow_director_flexbytes,
9052 (void *)&cmd_flow_director_flexbytes_value,
9053 (void *)&cmd_flow_director_drop,
9054 (void *)&cmd_flow_director_pf_vf,
9055 (void *)&cmd_flow_director_queue,
9056 (void *)&cmd_flow_director_queue_id,
9057 (void *)&cmd_flow_director_fd_id,
9058 (void *)&cmd_flow_director_fd_id_value,
9063 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9064 .f = cmd_flow_director_filter_parsed,
9066 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9067 "director entry on NIC",
9069 (void *)&cmd_flow_director_filter,
9070 (void *)&cmd_flow_director_port_id,
9071 (void *)&cmd_flow_director_mode,
9072 (void *)&cmd_flow_director_mode_ip,
9073 (void *)&cmd_flow_director_ops,
9074 (void *)&cmd_flow_director_flow,
9075 (void *)&cmd_flow_director_flow_type,
9076 (void *)&cmd_flow_director_src,
9077 (void *)&cmd_flow_director_ip_src,
9078 (void *)&cmd_flow_director_port_dst,
9079 (void *)&cmd_flow_director_dst,
9080 (void *)&cmd_flow_director_ip_dst,
9081 (void *)&cmd_flow_director_port_dst,
9082 (void *)&cmd_flow_director_verify_tag,
9083 (void *)&cmd_flow_director_verify_tag_value,
9084 (void *)&cmd_flow_director_tos,
9085 (void *)&cmd_flow_director_tos_value,
9086 (void *)&cmd_flow_director_ttl,
9087 (void *)&cmd_flow_director_ttl_value,
9088 (void *)&cmd_flow_director_vlan,
9089 (void *)&cmd_flow_director_vlan_value,
9090 (void *)&cmd_flow_director_flexbytes,
9091 (void *)&cmd_flow_director_flexbytes_value,
9092 (void *)&cmd_flow_director_drop,
9093 (void *)&cmd_flow_director_pf_vf,
9094 (void *)&cmd_flow_director_queue,
9095 (void *)&cmd_flow_director_queue_id,
9096 (void *)&cmd_flow_director_fd_id,
9097 (void *)&cmd_flow_director_fd_id_value,
9102 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9103 .f = cmd_flow_director_filter_parsed,
9105 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9106 "director entry on NIC",
9108 (void *)&cmd_flow_director_filter,
9109 (void *)&cmd_flow_director_port_id,
9110 (void *)&cmd_flow_director_mode,
9111 (void *)&cmd_flow_director_mode_ip,
9112 (void *)&cmd_flow_director_ops,
9113 (void *)&cmd_flow_director_flow,
9114 (void *)&cmd_flow_director_flow_type,
9115 (void *)&cmd_flow_director_ether,
9116 (void *)&cmd_flow_director_ether_type,
9117 (void *)&cmd_flow_director_flexbytes,
9118 (void *)&cmd_flow_director_flexbytes_value,
9119 (void *)&cmd_flow_director_drop,
9120 (void *)&cmd_flow_director_pf_vf,
9121 (void *)&cmd_flow_director_queue,
9122 (void *)&cmd_flow_director_queue_id,
9123 (void *)&cmd_flow_director_fd_id,
9124 (void *)&cmd_flow_director_fd_id_value,
9129 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9130 .f = cmd_flow_director_filter_parsed,
9132 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9133 "director entry on NIC",
9135 (void *)&cmd_flow_director_filter,
9136 (void *)&cmd_flow_director_port_id,
9137 (void *)&cmd_flow_director_mode,
9138 (void *)&cmd_flow_director_mode_mac_vlan,
9139 (void *)&cmd_flow_director_ops,
9140 (void *)&cmd_flow_director_mac,
9141 (void *)&cmd_flow_director_mac_addr,
9142 (void *)&cmd_flow_director_vlan,
9143 (void *)&cmd_flow_director_vlan_value,
9144 (void *)&cmd_flow_director_flexbytes,
9145 (void *)&cmd_flow_director_flexbytes_value,
9146 (void *)&cmd_flow_director_drop,
9147 (void *)&cmd_flow_director_queue,
9148 (void *)&cmd_flow_director_queue_id,
9149 (void *)&cmd_flow_director_fd_id,
9150 (void *)&cmd_flow_director_fd_id_value,
9155 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9156 .f = cmd_flow_director_filter_parsed,
9158 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9159 "director entry on NIC",
9161 (void *)&cmd_flow_director_filter,
9162 (void *)&cmd_flow_director_port_id,
9163 (void *)&cmd_flow_director_mode,
9164 (void *)&cmd_flow_director_mode_tunnel,
9165 (void *)&cmd_flow_director_ops,
9166 (void *)&cmd_flow_director_mac,
9167 (void *)&cmd_flow_director_mac_addr,
9168 (void *)&cmd_flow_director_vlan,
9169 (void *)&cmd_flow_director_vlan_value,
9170 (void *)&cmd_flow_director_tunnel,
9171 (void *)&cmd_flow_director_tunnel_type,
9172 (void *)&cmd_flow_director_tunnel_id,
9173 (void *)&cmd_flow_director_tunnel_id_value,
9174 (void *)&cmd_flow_director_flexbytes,
9175 (void *)&cmd_flow_director_flexbytes_value,
9176 (void *)&cmd_flow_director_drop,
9177 (void *)&cmd_flow_director_queue,
9178 (void *)&cmd_flow_director_queue_id,
9179 (void *)&cmd_flow_director_fd_id,
9180 (void *)&cmd_flow_director_fd_id_value,
9185 struct cmd_flush_flow_director_result {
9186 cmdline_fixed_string_t flush_flow_director;
9190 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9191 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9192 flush_flow_director, "flush_flow_director");
9193 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9194 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9198 cmd_flush_flow_director_parsed(void *parsed_result,
9199 __attribute__((unused)) struct cmdline *cl,
9200 __attribute__((unused)) void *data)
9202 struct cmd_flow_director_result *res = parsed_result;
9205 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9207 printf("flow director is not supported on port %u.\n",
9212 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9213 RTE_ETH_FILTER_FLUSH, NULL);
9215 printf("flow director table flushing error: (%s)\n",
9219 cmdline_parse_inst_t cmd_flush_flow_director = {
9220 .f = cmd_flush_flow_director_parsed,
9222 .help_str = "flush_flow_director <port_id>: "
9223 "Flush all flow director entries of a device on NIC",
9225 (void *)&cmd_flush_flow_director_flush,
9226 (void *)&cmd_flush_flow_director_port_id,
9231 /* *** deal with flow director mask *** */
9232 struct cmd_flow_director_mask_result {
9233 cmdline_fixed_string_t flow_director_mask;
9235 cmdline_fixed_string_t mode;
9236 cmdline_fixed_string_t mode_value;
9237 cmdline_fixed_string_t vlan;
9239 cmdline_fixed_string_t src_mask;
9240 cmdline_ipaddr_t ipv4_src;
9241 cmdline_ipaddr_t ipv6_src;
9243 cmdline_fixed_string_t dst_mask;
9244 cmdline_ipaddr_t ipv4_dst;
9245 cmdline_ipaddr_t ipv6_dst;
9247 cmdline_fixed_string_t mac;
9248 uint8_t mac_addr_byte_mask;
9249 cmdline_fixed_string_t tunnel_id;
9250 uint32_t tunnel_id_mask;
9251 cmdline_fixed_string_t tunnel_type;
9252 uint8_t tunnel_type_mask;
9256 cmd_flow_director_mask_parsed(void *parsed_result,
9257 __attribute__((unused)) struct cmdline *cl,
9258 __attribute__((unused)) void *data)
9260 struct cmd_flow_director_mask_result *res = parsed_result;
9261 struct rte_eth_fdir_masks *mask;
9262 struct rte_port *port;
9264 if (res->port_id > nb_ports) {
9265 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9269 port = &ports[res->port_id];
9270 /** Check if the port is not started **/
9271 if (port->port_status != RTE_PORT_STOPPED) {
9272 printf("Please stop port %d first\n", res->port_id);
9276 mask = &port->dev_conf.fdir_conf.mask;
9278 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9279 if (strcmp(res->mode_value, "MAC-VLAN")) {
9280 printf("Please set mode to MAC-VLAN.\n");
9284 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9285 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9286 if (strcmp(res->mode_value, "Tunnel")) {
9287 printf("Please set mode to Tunnel.\n");
9291 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9292 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9293 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9294 mask->tunnel_type_mask = res->tunnel_type_mask;
9296 if (strcmp(res->mode_value, "IP")) {
9297 printf("Please set mode to IP.\n");
9301 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9302 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9303 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9304 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9305 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9306 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9307 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9310 cmd_reconfig_device_queue(res->port_id, 1, 1);
9313 cmdline_parse_token_string_t cmd_flow_director_mask =
9314 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9315 flow_director_mask, "flow_director_mask");
9316 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9317 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9319 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9322 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9323 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9325 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9327 src_mask, "src_mask");
9328 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9329 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9331 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9332 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9334 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9335 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9337 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9339 dst_mask, "dst_mask");
9340 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9341 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9343 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9344 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9346 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9347 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9350 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9353 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9356 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9358 mode_value, "MAC-VLAN");
9359 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9361 mode_value, "Tunnel");
9362 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9365 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9366 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9367 mac_addr_byte_mask, UINT8);
9368 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9369 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9370 tunnel_type, "tunnel-type");
9371 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9372 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9373 tunnel_type_mask, UINT8);
9374 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9375 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9376 tunnel_id, "tunnel-id");
9377 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9378 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9379 tunnel_id_mask, UINT32);
9381 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9382 .f = cmd_flow_director_mask_parsed,
9384 .help_str = "flow_director_mask ... : "
9385 "Set IP mode flow director's mask on NIC",
9387 (void *)&cmd_flow_director_mask,
9388 (void *)&cmd_flow_director_mask_port_id,
9389 (void *)&cmd_flow_director_mask_mode,
9390 (void *)&cmd_flow_director_mask_mode_ip,
9391 (void *)&cmd_flow_director_mask_vlan,
9392 (void *)&cmd_flow_director_mask_vlan_value,
9393 (void *)&cmd_flow_director_mask_src,
9394 (void *)&cmd_flow_director_mask_ipv4_src,
9395 (void *)&cmd_flow_director_mask_ipv6_src,
9396 (void *)&cmd_flow_director_mask_port_src,
9397 (void *)&cmd_flow_director_mask_dst,
9398 (void *)&cmd_flow_director_mask_ipv4_dst,
9399 (void *)&cmd_flow_director_mask_ipv6_dst,
9400 (void *)&cmd_flow_director_mask_port_dst,
9405 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9406 .f = cmd_flow_director_mask_parsed,
9408 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9409 "flow director's mask on NIC",
9411 (void *)&cmd_flow_director_mask,
9412 (void *)&cmd_flow_director_mask_port_id,
9413 (void *)&cmd_flow_director_mask_mode,
9414 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9415 (void *)&cmd_flow_director_mask_vlan,
9416 (void *)&cmd_flow_director_mask_vlan_value,
9421 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9422 .f = cmd_flow_director_mask_parsed,
9424 .help_str = "flow_director_mask ... : Set tunnel mode "
9425 "flow director's mask on NIC",
9427 (void *)&cmd_flow_director_mask,
9428 (void *)&cmd_flow_director_mask_port_id,
9429 (void *)&cmd_flow_director_mask_mode,
9430 (void *)&cmd_flow_director_mask_mode_tunnel,
9431 (void *)&cmd_flow_director_mask_vlan,
9432 (void *)&cmd_flow_director_mask_vlan_value,
9433 (void *)&cmd_flow_director_mask_mac,
9434 (void *)&cmd_flow_director_mask_mac_value,
9435 (void *)&cmd_flow_director_mask_tunnel_type,
9436 (void *)&cmd_flow_director_mask_tunnel_type_value,
9437 (void *)&cmd_flow_director_mask_tunnel_id,
9438 (void *)&cmd_flow_director_mask_tunnel_id_value,
9443 /* *** deal with flow director mask on flexible payload *** */
9444 struct cmd_flow_director_flex_mask_result {
9445 cmdline_fixed_string_t flow_director_flexmask;
9447 cmdline_fixed_string_t flow;
9448 cmdline_fixed_string_t flow_type;
9449 cmdline_fixed_string_t mask;
9453 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9454 __attribute__((unused)) struct cmdline *cl,
9455 __attribute__((unused)) void *data)
9457 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9458 struct rte_eth_fdir_info fdir_info;
9459 struct rte_eth_fdir_flex_mask flex_mask;
9460 struct rte_port *port;
9461 uint32_t flow_type_mask;
9465 if (res->port_id > nb_ports) {
9466 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9470 port = &ports[res->port_id];
9471 /** Check if the port is not started **/
9472 if (port->port_status != RTE_PORT_STOPPED) {
9473 printf("Please stop port %d first\n", res->port_id);
9477 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9478 ret = parse_flexbytes(res->mask,
9480 RTE_ETH_FDIR_MAX_FLEXLEN);
9482 printf("error: Cannot parse mask input.\n");
9486 memset(&fdir_info, 0, sizeof(fdir_info));
9487 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9488 RTE_ETH_FILTER_INFO, &fdir_info);
9490 printf("Cannot get FDir filter info\n");
9494 if (!strcmp(res->flow_type, "none")) {
9495 /* means don't specify the flow type */
9496 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9497 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9498 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9499 0, sizeof(struct rte_eth_fdir_flex_mask));
9500 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9501 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9503 sizeof(struct rte_eth_fdir_flex_mask));
9504 cmd_reconfig_device_queue(res->port_id, 1, 1);
9507 flow_type_mask = fdir_info.flow_types_mask[0];
9508 if (!strcmp(res->flow_type, "all")) {
9509 if (!flow_type_mask) {
9510 printf("No flow type supported\n");
9513 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9514 if (flow_type_mask & (1 << i)) {
9515 flex_mask.flow_type = i;
9516 fdir_set_flex_mask(res->port_id, &flex_mask);
9519 cmd_reconfig_device_queue(res->port_id, 1, 1);
9522 flex_mask.flow_type = str2flowtype(res->flow_type);
9523 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9524 printf("Flow type %s not supported on port %d\n",
9525 res->flow_type, res->port_id);
9528 fdir_set_flex_mask(res->port_id, &flex_mask);
9529 cmd_reconfig_device_queue(res->port_id, 1, 1);
9532 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9533 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9534 flow_director_flexmask,
9535 "flow_director_flex_mask");
9536 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9537 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9539 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9540 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9542 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9543 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9544 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9545 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9546 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9547 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9550 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9551 .f = cmd_flow_director_flex_mask_parsed,
9553 .help_str = "flow_director_flex_mask ... : "
9554 "Set flow director's flex mask on NIC",
9556 (void *)&cmd_flow_director_flexmask,
9557 (void *)&cmd_flow_director_flexmask_port_id,
9558 (void *)&cmd_flow_director_flexmask_flow,
9559 (void *)&cmd_flow_director_flexmask_flow_type,
9560 (void *)&cmd_flow_director_flexmask_mask,
9565 /* *** deal with flow director flexible payload configuration *** */
9566 struct cmd_flow_director_flexpayload_result {
9567 cmdline_fixed_string_t flow_director_flexpayload;
9569 cmdline_fixed_string_t payload_layer;
9570 cmdline_fixed_string_t payload_cfg;
9574 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9577 const char *p, *p0 = q_arg;
9579 unsigned long int_fld;
9580 char *str_fld[max_num];
9585 p = strchr(p0, '(');
9589 p0 = strchr(p, ')');
9594 if (size >= sizeof(s))
9597 snprintf(s, sizeof(s), "%.*s", size, p);
9598 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9599 if (ret < 0 || ret > max_num)
9601 for (i = 0; i < ret; i++) {
9603 int_fld = strtoul(str_fld[i], &end, 0);
9604 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9606 offsets[i] = (uint16_t)int_fld;
9612 cmd_flow_director_flxpld_parsed(void *parsed_result,
9613 __attribute__((unused)) struct cmdline *cl,
9614 __attribute__((unused)) void *data)
9616 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9617 struct rte_eth_flex_payload_cfg flex_cfg;
9618 struct rte_port *port;
9621 if (res->port_id > nb_ports) {
9622 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9626 port = &ports[res->port_id];
9627 /** Check if the port is not started **/
9628 if (port->port_status != RTE_PORT_STOPPED) {
9629 printf("Please stop port %d first\n", res->port_id);
9633 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9635 if (!strcmp(res->payload_layer, "raw"))
9636 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9637 else if (!strcmp(res->payload_layer, "l2"))
9638 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9639 else if (!strcmp(res->payload_layer, "l3"))
9640 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9641 else if (!strcmp(res->payload_layer, "l4"))
9642 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9644 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9645 RTE_ETH_FDIR_MAX_FLEXLEN);
9647 printf("error: Cannot parse flex payload input.\n");
9651 fdir_set_flex_payload(res->port_id, &flex_cfg);
9652 cmd_reconfig_device_queue(res->port_id, 1, 1);
9655 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9656 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9657 flow_director_flexpayload,
9658 "flow_director_flex_payload");
9659 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9660 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9662 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9663 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9664 payload_layer, "raw#l2#l3#l4");
9665 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9666 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9669 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9670 .f = cmd_flow_director_flxpld_parsed,
9672 .help_str = "flow_director_flexpayload ... : "
9673 "Set flow director's flex payload on NIC",
9675 (void *)&cmd_flow_director_flexpayload,
9676 (void *)&cmd_flow_director_flexpayload_port_id,
9677 (void *)&cmd_flow_director_flexpayload_payload_layer,
9678 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9683 /* Generic flow interface command. */
9684 extern cmdline_parse_inst_t cmd_flow;
9686 /* *** Classification Filters Control *** */
9687 /* *** Get symmetric hash enable per port *** */
9688 struct cmd_get_sym_hash_ena_per_port_result {
9689 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9694 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9695 __rte_unused struct cmdline *cl,
9696 __rte_unused void *data)
9698 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9699 struct rte_eth_hash_filter_info info;
9702 if (rte_eth_dev_filter_supported(res->port_id,
9703 RTE_ETH_FILTER_HASH) < 0) {
9704 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9709 memset(&info, 0, sizeof(info));
9710 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9711 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9712 RTE_ETH_FILTER_GET, &info);
9715 printf("Cannot get symmetric hash enable per port "
9716 "on port %u\n", res->port_id);
9720 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9721 "enabled" : "disabled", res->port_id);
9724 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9725 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9726 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9727 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9728 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9731 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9732 .f = cmd_get_sym_hash_per_port_parsed,
9734 .help_str = "get_sym_hash_ena_per_port <port_id>",
9736 (void *)&cmd_get_sym_hash_ena_per_port_all,
9737 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9742 /* *** Set symmetric hash enable per port *** */
9743 struct cmd_set_sym_hash_ena_per_port_result {
9744 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9745 cmdline_fixed_string_t enable;
9750 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9751 __rte_unused struct cmdline *cl,
9752 __rte_unused void *data)
9754 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9755 struct rte_eth_hash_filter_info info;
9758 if (rte_eth_dev_filter_supported(res->port_id,
9759 RTE_ETH_FILTER_HASH) < 0) {
9760 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9765 memset(&info, 0, sizeof(info));
9766 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9767 if (!strcmp(res->enable, "enable"))
9768 info.info.enable = 1;
9769 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9770 RTE_ETH_FILTER_SET, &info);
9772 printf("Cannot set symmetric hash enable per port on "
9773 "port %u\n", res->port_id);
9776 printf("Symmetric hash has been set to %s on port %u\n",
9777 res->enable, res->port_id);
9780 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9781 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9782 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9783 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9784 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9786 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9787 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9788 enable, "enable#disable");
9790 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9791 .f = cmd_set_sym_hash_per_port_parsed,
9793 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9795 (void *)&cmd_set_sym_hash_ena_per_port_all,
9796 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9797 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9802 /* Get global config of hash function */
9803 struct cmd_get_hash_global_config_result {
9804 cmdline_fixed_string_t get_hash_global_config;
9809 flowtype_to_str(uint16_t ftype)
9816 {"ipv4", RTE_ETH_FLOW_IPV4},
9817 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9818 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9819 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9820 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9821 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9822 {"ipv6", RTE_ETH_FLOW_IPV6},
9823 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9824 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9825 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9826 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9827 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9828 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9829 {"port", RTE_ETH_FLOW_PORT},
9830 {"vxlan", RTE_ETH_FLOW_VXLAN},
9831 {"geneve", RTE_ETH_FLOW_GENEVE},
9832 {"nvgre", RTE_ETH_FLOW_NVGRE},
9835 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9836 if (ftype_table[i].ftype == ftype)
9837 return ftype_table[i].str;
9844 cmd_get_hash_global_config_parsed(void *parsed_result,
9845 __rte_unused struct cmdline *cl,
9846 __rte_unused void *data)
9848 struct cmd_get_hash_global_config_result *res = parsed_result;
9849 struct rte_eth_hash_filter_info info;
9850 uint32_t idx, offset;
9855 if (rte_eth_dev_filter_supported(res->port_id,
9856 RTE_ETH_FILTER_HASH) < 0) {
9857 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9862 memset(&info, 0, sizeof(info));
9863 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9864 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9865 RTE_ETH_FILTER_GET, &info);
9867 printf("Cannot get hash global configurations by port %d\n",
9872 switch (info.info.global_conf.hash_func) {
9873 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9874 printf("Hash function is Toeplitz\n");
9876 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9877 printf("Hash function is Simple XOR\n");
9880 printf("Unknown hash function\n");
9884 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9885 idx = i / UINT32_BIT;
9886 offset = i % UINT32_BIT;
9887 if (!(info.info.global_conf.valid_bit_mask[idx] &
9890 str = flowtype_to_str(i);
9893 printf("Symmetric hash is %s globally for flow type %s "
9895 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9896 (1UL << offset)) ? "enabled" : "disabled"), str,
9901 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9902 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9903 get_hash_global_config, "get_hash_global_config");
9904 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9905 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9908 cmdline_parse_inst_t cmd_get_hash_global_config = {
9909 .f = cmd_get_hash_global_config_parsed,
9911 .help_str = "get_hash_global_config <port_id>",
9913 (void *)&cmd_get_hash_global_config_all,
9914 (void *)&cmd_get_hash_global_config_port_id,
9919 /* Set global config of hash function */
9920 struct cmd_set_hash_global_config_result {
9921 cmdline_fixed_string_t set_hash_global_config;
9923 cmdline_fixed_string_t hash_func;
9924 cmdline_fixed_string_t flow_type;
9925 cmdline_fixed_string_t enable;
9929 cmd_set_hash_global_config_parsed(void *parsed_result,
9930 __rte_unused struct cmdline *cl,
9931 __rte_unused void *data)
9933 struct cmd_set_hash_global_config_result *res = parsed_result;
9934 struct rte_eth_hash_filter_info info;
9935 uint32_t ftype, idx, offset;
9938 if (rte_eth_dev_filter_supported(res->port_id,
9939 RTE_ETH_FILTER_HASH) < 0) {
9940 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9944 memset(&info, 0, sizeof(info));
9945 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9946 if (!strcmp(res->hash_func, "toeplitz"))
9947 info.info.global_conf.hash_func =
9948 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9949 else if (!strcmp(res->hash_func, "simple_xor"))
9950 info.info.global_conf.hash_func =
9951 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9952 else if (!strcmp(res->hash_func, "default"))
9953 info.info.global_conf.hash_func =
9954 RTE_ETH_HASH_FUNCTION_DEFAULT;
9956 ftype = str2flowtype(res->flow_type);
9957 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9958 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9959 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9960 if (!strcmp(res->enable, "enable"))
9961 info.info.global_conf.sym_hash_enable_mask[idx] |=
9963 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9964 RTE_ETH_FILTER_SET, &info);
9966 printf("Cannot set global hash configurations by port %d\n",
9969 printf("Global hash configurations have been set "
9970 "succcessfully by port %d\n", res->port_id);
9973 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9974 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9975 set_hash_global_config, "set_hash_global_config");
9976 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9977 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9979 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9980 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9981 hash_func, "toeplitz#simple_xor#default");
9982 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9983 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9985 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9986 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9987 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9988 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9989 enable, "enable#disable");
9991 cmdline_parse_inst_t cmd_set_hash_global_config = {
9992 .f = cmd_set_hash_global_config_parsed,
9994 .help_str = "set_hash_global_config <port_id> "
9995 "toeplitz|simple_xor|default "
9996 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9997 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9998 "l2_payload enable|disable",
10000 (void *)&cmd_set_hash_global_config_all,
10001 (void *)&cmd_set_hash_global_config_port_id,
10002 (void *)&cmd_set_hash_global_config_hash_func,
10003 (void *)&cmd_set_hash_global_config_flow_type,
10004 (void *)&cmd_set_hash_global_config_enable,
10009 /* Set hash input set */
10010 struct cmd_set_hash_input_set_result {
10011 cmdline_fixed_string_t set_hash_input_set;
10013 cmdline_fixed_string_t flow_type;
10014 cmdline_fixed_string_t inset_field;
10015 cmdline_fixed_string_t select;
10018 static enum rte_eth_input_set_field
10019 str2inset(char *string)
10023 static const struct {
10025 enum rte_eth_input_set_field inset;
10026 } inset_table[] = {
10027 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10028 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10029 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10030 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10031 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10032 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10033 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10034 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10035 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10036 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10037 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10038 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10039 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10040 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10041 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10042 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10043 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10044 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10045 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10046 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10047 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10048 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10049 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10050 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10051 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10052 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10053 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10054 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10055 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10056 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10057 {"none", RTE_ETH_INPUT_SET_NONE},
10060 for (i = 0; i < RTE_DIM(inset_table); i++) {
10061 if (!strcmp(string, inset_table[i].str))
10062 return inset_table[i].inset;
10065 return RTE_ETH_INPUT_SET_UNKNOWN;
10069 cmd_set_hash_input_set_parsed(void *parsed_result,
10070 __rte_unused struct cmdline *cl,
10071 __rte_unused void *data)
10073 struct cmd_set_hash_input_set_result *res = parsed_result;
10074 struct rte_eth_hash_filter_info info;
10076 memset(&info, 0, sizeof(info));
10077 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10078 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10079 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10080 info.info.input_set_conf.inset_size = 1;
10081 if (!strcmp(res->select, "select"))
10082 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10083 else if (!strcmp(res->select, "add"))
10084 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10085 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10086 RTE_ETH_FILTER_SET, &info);
10089 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10090 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10091 set_hash_input_set, "set_hash_input_set");
10092 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10093 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10095 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10096 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10098 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10099 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10100 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10101 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10103 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10104 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10105 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10106 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10107 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10109 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10110 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10111 select, "select#add");
10113 cmdline_parse_inst_t cmd_set_hash_input_set = {
10114 .f = cmd_set_hash_input_set_parsed,
10116 .help_str = "set_hash_input_set <port_id> "
10117 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10118 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10119 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10120 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10121 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10122 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10123 "fld-7th|fld-8th|none select|add",
10125 (void *)&cmd_set_hash_input_set_cmd,
10126 (void *)&cmd_set_hash_input_set_port_id,
10127 (void *)&cmd_set_hash_input_set_flow_type,
10128 (void *)&cmd_set_hash_input_set_field,
10129 (void *)&cmd_set_hash_input_set_select,
10134 /* Set flow director input set */
10135 struct cmd_set_fdir_input_set_result {
10136 cmdline_fixed_string_t set_fdir_input_set;
10138 cmdline_fixed_string_t flow_type;
10139 cmdline_fixed_string_t inset_field;
10140 cmdline_fixed_string_t select;
10144 cmd_set_fdir_input_set_parsed(void *parsed_result,
10145 __rte_unused struct cmdline *cl,
10146 __rte_unused void *data)
10148 struct cmd_set_fdir_input_set_result *res = parsed_result;
10149 struct rte_eth_fdir_filter_info info;
10151 memset(&info, 0, sizeof(info));
10152 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10153 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10154 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10155 info.info.input_set_conf.inset_size = 1;
10156 if (!strcmp(res->select, "select"))
10157 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10158 else if (!strcmp(res->select, "add"))
10159 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10160 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10161 RTE_ETH_FILTER_SET, &info);
10164 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10165 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10166 set_fdir_input_set, "set_fdir_input_set");
10167 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10168 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10170 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10171 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10173 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10174 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10175 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10176 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10178 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10179 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10180 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10181 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10182 "sctp-veri-tag#none");
10183 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10184 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10185 select, "select#add");
10187 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10188 .f = cmd_set_fdir_input_set_parsed,
10190 .help_str = "set_fdir_input_set <port_id> "
10191 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10192 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10193 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10194 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10195 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10196 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10197 "sctp-veri-tag|none select|add",
10199 (void *)&cmd_set_fdir_input_set_cmd,
10200 (void *)&cmd_set_fdir_input_set_port_id,
10201 (void *)&cmd_set_fdir_input_set_flow_type,
10202 (void *)&cmd_set_fdir_input_set_field,
10203 (void *)&cmd_set_fdir_input_set_select,
10208 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10209 struct cmd_mcast_addr_result {
10210 cmdline_fixed_string_t mcast_addr_cmd;
10211 cmdline_fixed_string_t what;
10213 struct ether_addr mc_addr;
10216 static void cmd_mcast_addr_parsed(void *parsed_result,
10217 __attribute__((unused)) struct cmdline *cl,
10218 __attribute__((unused)) void *data)
10220 struct cmd_mcast_addr_result *res = parsed_result;
10222 if (!is_multicast_ether_addr(&res->mc_addr)) {
10223 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10224 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10225 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10226 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10229 if (strcmp(res->what, "add") == 0)
10230 mcast_addr_add(res->port_num, &res->mc_addr);
10232 mcast_addr_remove(res->port_num, &res->mc_addr);
10235 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10236 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10237 mcast_addr_cmd, "mcast_addr");
10238 cmdline_parse_token_string_t cmd_mcast_addr_what =
10239 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10241 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10242 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10243 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10244 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10246 cmdline_parse_inst_t cmd_mcast_addr = {
10247 .f = cmd_mcast_addr_parsed,
10249 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10250 "Add/Remove multicast MAC address on port_id",
10252 (void *)&cmd_mcast_addr_cmd,
10253 (void *)&cmd_mcast_addr_what,
10254 (void *)&cmd_mcast_addr_portnum,
10255 (void *)&cmd_mcast_addr_addr,
10260 /* l2 tunnel config
10261 * only support E-tag now.
10264 /* Ether type config */
10265 struct cmd_config_l2_tunnel_eth_type_result {
10266 cmdline_fixed_string_t port;
10267 cmdline_fixed_string_t config;
10268 cmdline_fixed_string_t all;
10270 cmdline_fixed_string_t l2_tunnel;
10271 cmdline_fixed_string_t l2_tunnel_type;
10272 cmdline_fixed_string_t eth_type;
10273 uint16_t eth_type_val;
10276 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10277 TOKEN_STRING_INITIALIZER
10278 (struct cmd_config_l2_tunnel_eth_type_result,
10280 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10281 TOKEN_STRING_INITIALIZER
10282 (struct cmd_config_l2_tunnel_eth_type_result,
10284 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10285 TOKEN_STRING_INITIALIZER
10286 (struct cmd_config_l2_tunnel_eth_type_result,
10288 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10289 TOKEN_NUM_INITIALIZER
10290 (struct cmd_config_l2_tunnel_eth_type_result,
10292 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10293 TOKEN_STRING_INITIALIZER
10294 (struct cmd_config_l2_tunnel_eth_type_result,
10295 l2_tunnel, "l2-tunnel");
10296 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10297 TOKEN_STRING_INITIALIZER
10298 (struct cmd_config_l2_tunnel_eth_type_result,
10299 l2_tunnel_type, "E-tag");
10300 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10301 TOKEN_STRING_INITIALIZER
10302 (struct cmd_config_l2_tunnel_eth_type_result,
10303 eth_type, "ether-type");
10304 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10305 TOKEN_NUM_INITIALIZER
10306 (struct cmd_config_l2_tunnel_eth_type_result,
10307 eth_type_val, UINT16);
10309 static enum rte_eth_tunnel_type
10310 str2fdir_l2_tunnel_type(char *string)
10314 static const struct {
10316 enum rte_eth_tunnel_type type;
10317 } l2_tunnel_type_str[] = {
10318 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10321 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10322 if (!strcmp(l2_tunnel_type_str[i].str, string))
10323 return l2_tunnel_type_str[i].type;
10325 return RTE_TUNNEL_TYPE_NONE;
10328 /* ether type config for all ports */
10330 cmd_config_l2_tunnel_eth_type_all_parsed
10331 (void *parsed_result,
10332 __attribute__((unused)) struct cmdline *cl,
10333 __attribute__((unused)) void *data)
10335 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10336 struct rte_eth_l2_tunnel_conf entry;
10339 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10340 entry.ether_type = res->eth_type_val;
10342 FOREACH_PORT(pid, ports) {
10343 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10347 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10348 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10350 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10352 (void *)&cmd_config_l2_tunnel_eth_type_port,
10353 (void *)&cmd_config_l2_tunnel_eth_type_config,
10354 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10355 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10356 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10357 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10358 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10363 /* ether type config for a specific port */
10365 cmd_config_l2_tunnel_eth_type_specific_parsed(
10366 void *parsed_result,
10367 __attribute__((unused)) struct cmdline *cl,
10368 __attribute__((unused)) void *data)
10370 struct cmd_config_l2_tunnel_eth_type_result *res =
10372 struct rte_eth_l2_tunnel_conf entry;
10374 if (port_id_is_invalid(res->id, ENABLED_WARN))
10377 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10378 entry.ether_type = res->eth_type_val;
10380 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10383 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10384 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10386 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10388 (void *)&cmd_config_l2_tunnel_eth_type_port,
10389 (void *)&cmd_config_l2_tunnel_eth_type_config,
10390 (void *)&cmd_config_l2_tunnel_eth_type_id,
10391 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10392 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10393 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10394 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10399 /* Enable/disable l2 tunnel */
10400 struct cmd_config_l2_tunnel_en_dis_result {
10401 cmdline_fixed_string_t port;
10402 cmdline_fixed_string_t config;
10403 cmdline_fixed_string_t all;
10405 cmdline_fixed_string_t l2_tunnel;
10406 cmdline_fixed_string_t l2_tunnel_type;
10407 cmdline_fixed_string_t en_dis;
10410 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10411 TOKEN_STRING_INITIALIZER
10412 (struct cmd_config_l2_tunnel_en_dis_result,
10414 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10415 TOKEN_STRING_INITIALIZER
10416 (struct cmd_config_l2_tunnel_en_dis_result,
10418 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10419 TOKEN_STRING_INITIALIZER
10420 (struct cmd_config_l2_tunnel_en_dis_result,
10422 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10423 TOKEN_NUM_INITIALIZER
10424 (struct cmd_config_l2_tunnel_en_dis_result,
10426 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10427 TOKEN_STRING_INITIALIZER
10428 (struct cmd_config_l2_tunnel_en_dis_result,
10429 l2_tunnel, "l2-tunnel");
10430 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10431 TOKEN_STRING_INITIALIZER
10432 (struct cmd_config_l2_tunnel_en_dis_result,
10433 l2_tunnel_type, "E-tag");
10434 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10435 TOKEN_STRING_INITIALIZER
10436 (struct cmd_config_l2_tunnel_en_dis_result,
10437 en_dis, "enable#disable");
10439 /* enable/disable l2 tunnel for all ports */
10441 cmd_config_l2_tunnel_en_dis_all_parsed(
10442 void *parsed_result,
10443 __attribute__((unused)) struct cmdline *cl,
10444 __attribute__((unused)) void *data)
10446 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10447 struct rte_eth_l2_tunnel_conf entry;
10451 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10453 if (!strcmp("enable", res->en_dis))
10458 FOREACH_PORT(pid, ports) {
10459 rte_eth_dev_l2_tunnel_offload_set(pid,
10461 ETH_L2_TUNNEL_ENABLE_MASK,
10466 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10467 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10469 .help_str = "port config all l2-tunnel E-tag enable|disable",
10471 (void *)&cmd_config_l2_tunnel_en_dis_port,
10472 (void *)&cmd_config_l2_tunnel_en_dis_config,
10473 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10474 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10475 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10476 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10481 /* enable/disable l2 tunnel for a port */
10483 cmd_config_l2_tunnel_en_dis_specific_parsed(
10484 void *parsed_result,
10485 __attribute__((unused)) struct cmdline *cl,
10486 __attribute__((unused)) void *data)
10488 struct cmd_config_l2_tunnel_en_dis_result *res =
10490 struct rte_eth_l2_tunnel_conf entry;
10492 if (port_id_is_invalid(res->id, ENABLED_WARN))
10495 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10497 if (!strcmp("enable", res->en_dis))
10498 rte_eth_dev_l2_tunnel_offload_set(res->id,
10500 ETH_L2_TUNNEL_ENABLE_MASK,
10503 rte_eth_dev_l2_tunnel_offload_set(res->id,
10505 ETH_L2_TUNNEL_ENABLE_MASK,
10509 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10510 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10512 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10514 (void *)&cmd_config_l2_tunnel_en_dis_port,
10515 (void *)&cmd_config_l2_tunnel_en_dis_config,
10516 (void *)&cmd_config_l2_tunnel_en_dis_id,
10517 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10518 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10519 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10524 /* E-tag configuration */
10526 /* Common result structure for all E-tag configuration */
10527 struct cmd_config_e_tag_result {
10528 cmdline_fixed_string_t e_tag;
10529 cmdline_fixed_string_t set;
10530 cmdline_fixed_string_t insertion;
10531 cmdline_fixed_string_t stripping;
10532 cmdline_fixed_string_t forwarding;
10533 cmdline_fixed_string_t filter;
10534 cmdline_fixed_string_t add;
10535 cmdline_fixed_string_t del;
10536 cmdline_fixed_string_t on;
10537 cmdline_fixed_string_t off;
10538 cmdline_fixed_string_t on_off;
10539 cmdline_fixed_string_t port_tag_id;
10540 uint32_t port_tag_id_val;
10541 cmdline_fixed_string_t e_tag_id;
10542 uint16_t e_tag_id_val;
10543 cmdline_fixed_string_t dst_pool;
10544 uint8_t dst_pool_val;
10545 cmdline_fixed_string_t port;
10547 cmdline_fixed_string_t vf;
10551 /* Common CLI fields for all E-tag configuration */
10552 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10553 TOKEN_STRING_INITIALIZER
10554 (struct cmd_config_e_tag_result,
10556 cmdline_parse_token_string_t cmd_config_e_tag_set =
10557 TOKEN_STRING_INITIALIZER
10558 (struct cmd_config_e_tag_result,
10560 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10561 TOKEN_STRING_INITIALIZER
10562 (struct cmd_config_e_tag_result,
10563 insertion, "insertion");
10564 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10565 TOKEN_STRING_INITIALIZER
10566 (struct cmd_config_e_tag_result,
10567 stripping, "stripping");
10568 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10569 TOKEN_STRING_INITIALIZER
10570 (struct cmd_config_e_tag_result,
10571 forwarding, "forwarding");
10572 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10573 TOKEN_STRING_INITIALIZER
10574 (struct cmd_config_e_tag_result,
10576 cmdline_parse_token_string_t cmd_config_e_tag_add =
10577 TOKEN_STRING_INITIALIZER
10578 (struct cmd_config_e_tag_result,
10580 cmdline_parse_token_string_t cmd_config_e_tag_del =
10581 TOKEN_STRING_INITIALIZER
10582 (struct cmd_config_e_tag_result,
10584 cmdline_parse_token_string_t cmd_config_e_tag_on =
10585 TOKEN_STRING_INITIALIZER
10586 (struct cmd_config_e_tag_result,
10588 cmdline_parse_token_string_t cmd_config_e_tag_off =
10589 TOKEN_STRING_INITIALIZER
10590 (struct cmd_config_e_tag_result,
10592 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10593 TOKEN_STRING_INITIALIZER
10594 (struct cmd_config_e_tag_result,
10596 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10597 TOKEN_STRING_INITIALIZER
10598 (struct cmd_config_e_tag_result,
10599 port_tag_id, "port-tag-id");
10600 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10601 TOKEN_NUM_INITIALIZER
10602 (struct cmd_config_e_tag_result,
10603 port_tag_id_val, UINT32);
10604 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10605 TOKEN_STRING_INITIALIZER
10606 (struct cmd_config_e_tag_result,
10607 e_tag_id, "e-tag-id");
10608 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10609 TOKEN_NUM_INITIALIZER
10610 (struct cmd_config_e_tag_result,
10611 e_tag_id_val, UINT16);
10612 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10613 TOKEN_STRING_INITIALIZER
10614 (struct cmd_config_e_tag_result,
10615 dst_pool, "dst-pool");
10616 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10617 TOKEN_NUM_INITIALIZER
10618 (struct cmd_config_e_tag_result,
10619 dst_pool_val, UINT8);
10620 cmdline_parse_token_string_t cmd_config_e_tag_port =
10621 TOKEN_STRING_INITIALIZER
10622 (struct cmd_config_e_tag_result,
10624 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10625 TOKEN_NUM_INITIALIZER
10626 (struct cmd_config_e_tag_result,
10628 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10629 TOKEN_STRING_INITIALIZER
10630 (struct cmd_config_e_tag_result,
10632 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10633 TOKEN_NUM_INITIALIZER
10634 (struct cmd_config_e_tag_result,
10637 /* E-tag insertion configuration */
10639 cmd_config_e_tag_insertion_en_parsed(
10640 void *parsed_result,
10641 __attribute__((unused)) struct cmdline *cl,
10642 __attribute__((unused)) void *data)
10644 struct cmd_config_e_tag_result *res =
10646 struct rte_eth_l2_tunnel_conf entry;
10648 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10651 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10652 entry.tunnel_id = res->port_tag_id_val;
10653 entry.vf_id = res->vf_id;
10654 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10656 ETH_L2_TUNNEL_INSERTION_MASK,
10661 cmd_config_e_tag_insertion_dis_parsed(
10662 void *parsed_result,
10663 __attribute__((unused)) struct cmdline *cl,
10664 __attribute__((unused)) void *data)
10666 struct cmd_config_e_tag_result *res =
10668 struct rte_eth_l2_tunnel_conf entry;
10670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10673 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10674 entry.vf_id = res->vf_id;
10676 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10678 ETH_L2_TUNNEL_INSERTION_MASK,
10682 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10683 .f = cmd_config_e_tag_insertion_en_parsed,
10685 .help_str = "E-tag ... : E-tag insertion enable",
10687 (void *)&cmd_config_e_tag_e_tag,
10688 (void *)&cmd_config_e_tag_set,
10689 (void *)&cmd_config_e_tag_insertion,
10690 (void *)&cmd_config_e_tag_on,
10691 (void *)&cmd_config_e_tag_port_tag_id,
10692 (void *)&cmd_config_e_tag_port_tag_id_val,
10693 (void *)&cmd_config_e_tag_port,
10694 (void *)&cmd_config_e_tag_port_id,
10695 (void *)&cmd_config_e_tag_vf,
10696 (void *)&cmd_config_e_tag_vf_id,
10701 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10702 .f = cmd_config_e_tag_insertion_dis_parsed,
10704 .help_str = "E-tag ... : E-tag insertion disable",
10706 (void *)&cmd_config_e_tag_e_tag,
10707 (void *)&cmd_config_e_tag_set,
10708 (void *)&cmd_config_e_tag_insertion,
10709 (void *)&cmd_config_e_tag_off,
10710 (void *)&cmd_config_e_tag_port,
10711 (void *)&cmd_config_e_tag_port_id,
10712 (void *)&cmd_config_e_tag_vf,
10713 (void *)&cmd_config_e_tag_vf_id,
10718 /* E-tag stripping configuration */
10720 cmd_config_e_tag_stripping_parsed(
10721 void *parsed_result,
10722 __attribute__((unused)) struct cmdline *cl,
10723 __attribute__((unused)) void *data)
10725 struct cmd_config_e_tag_result *res =
10727 struct rte_eth_l2_tunnel_conf entry;
10729 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10732 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10734 if (!strcmp(res->on_off, "on"))
10735 rte_eth_dev_l2_tunnel_offload_set
10738 ETH_L2_TUNNEL_STRIPPING_MASK,
10741 rte_eth_dev_l2_tunnel_offload_set
10744 ETH_L2_TUNNEL_STRIPPING_MASK,
10748 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10749 .f = cmd_config_e_tag_stripping_parsed,
10751 .help_str = "E-tag ... : E-tag stripping enable/disable",
10753 (void *)&cmd_config_e_tag_e_tag,
10754 (void *)&cmd_config_e_tag_set,
10755 (void *)&cmd_config_e_tag_stripping,
10756 (void *)&cmd_config_e_tag_on_off,
10757 (void *)&cmd_config_e_tag_port,
10758 (void *)&cmd_config_e_tag_port_id,
10763 /* E-tag forwarding configuration */
10765 cmd_config_e_tag_forwarding_parsed(
10766 void *parsed_result,
10767 __attribute__((unused)) struct cmdline *cl,
10768 __attribute__((unused)) void *data)
10770 struct cmd_config_e_tag_result *res = parsed_result;
10771 struct rte_eth_l2_tunnel_conf entry;
10773 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10776 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10778 if (!strcmp(res->on_off, "on"))
10779 rte_eth_dev_l2_tunnel_offload_set
10782 ETH_L2_TUNNEL_FORWARDING_MASK,
10785 rte_eth_dev_l2_tunnel_offload_set
10788 ETH_L2_TUNNEL_FORWARDING_MASK,
10792 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10793 .f = cmd_config_e_tag_forwarding_parsed,
10795 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10797 (void *)&cmd_config_e_tag_e_tag,
10798 (void *)&cmd_config_e_tag_set,
10799 (void *)&cmd_config_e_tag_forwarding,
10800 (void *)&cmd_config_e_tag_on_off,
10801 (void *)&cmd_config_e_tag_port,
10802 (void *)&cmd_config_e_tag_port_id,
10807 /* E-tag filter configuration */
10809 cmd_config_e_tag_filter_add_parsed(
10810 void *parsed_result,
10811 __attribute__((unused)) struct cmdline *cl,
10812 __attribute__((unused)) void *data)
10814 struct cmd_config_e_tag_result *res = parsed_result;
10815 struct rte_eth_l2_tunnel_conf entry;
10818 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10821 if (res->e_tag_id_val > 0x3fff) {
10822 printf("e-tag-id must be equal or less than 0x3fff.\n");
10826 ret = rte_eth_dev_filter_supported(res->port_id,
10827 RTE_ETH_FILTER_L2_TUNNEL);
10829 printf("E-tag filter is not supported on port %u.\n",
10834 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10835 entry.tunnel_id = res->e_tag_id_val;
10836 entry.pool = res->dst_pool_val;
10838 ret = rte_eth_dev_filter_ctrl(res->port_id,
10839 RTE_ETH_FILTER_L2_TUNNEL,
10840 RTE_ETH_FILTER_ADD,
10843 printf("E-tag filter programming error: (%s)\n",
10847 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10848 .f = cmd_config_e_tag_filter_add_parsed,
10850 .help_str = "E-tag ... : E-tag filter add",
10852 (void *)&cmd_config_e_tag_e_tag,
10853 (void *)&cmd_config_e_tag_set,
10854 (void *)&cmd_config_e_tag_filter,
10855 (void *)&cmd_config_e_tag_add,
10856 (void *)&cmd_config_e_tag_e_tag_id,
10857 (void *)&cmd_config_e_tag_e_tag_id_val,
10858 (void *)&cmd_config_e_tag_dst_pool,
10859 (void *)&cmd_config_e_tag_dst_pool_val,
10860 (void *)&cmd_config_e_tag_port,
10861 (void *)&cmd_config_e_tag_port_id,
10867 cmd_config_e_tag_filter_del_parsed(
10868 void *parsed_result,
10869 __attribute__((unused)) struct cmdline *cl,
10870 __attribute__((unused)) void *data)
10872 struct cmd_config_e_tag_result *res = parsed_result;
10873 struct rte_eth_l2_tunnel_conf entry;
10876 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10879 if (res->e_tag_id_val > 0x3fff) {
10880 printf("e-tag-id must be less than 0x3fff.\n");
10884 ret = rte_eth_dev_filter_supported(res->port_id,
10885 RTE_ETH_FILTER_L2_TUNNEL);
10887 printf("E-tag filter is not supported on port %u.\n",
10892 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10893 entry.tunnel_id = res->e_tag_id_val;
10895 ret = rte_eth_dev_filter_ctrl(res->port_id,
10896 RTE_ETH_FILTER_L2_TUNNEL,
10897 RTE_ETH_FILTER_DELETE,
10900 printf("E-tag filter programming error: (%s)\n",
10904 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10905 .f = cmd_config_e_tag_filter_del_parsed,
10907 .help_str = "E-tag ... : E-tag filter delete",
10909 (void *)&cmd_config_e_tag_e_tag,
10910 (void *)&cmd_config_e_tag_set,
10911 (void *)&cmd_config_e_tag_filter,
10912 (void *)&cmd_config_e_tag_del,
10913 (void *)&cmd_config_e_tag_e_tag_id,
10914 (void *)&cmd_config_e_tag_e_tag_id_val,
10915 (void *)&cmd_config_e_tag_port,
10916 (void *)&cmd_config_e_tag_port_id,
10921 /* vf vlan anti spoof configuration */
10923 /* Common result structure for vf vlan anti spoof */
10924 struct cmd_vf_vlan_anti_spoof_result {
10925 cmdline_fixed_string_t set;
10926 cmdline_fixed_string_t vf;
10927 cmdline_fixed_string_t vlan;
10928 cmdline_fixed_string_t antispoof;
10931 cmdline_fixed_string_t on_off;
10934 /* Common CLI fields for vf vlan anti spoof enable disable */
10935 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10936 TOKEN_STRING_INITIALIZER
10937 (struct cmd_vf_vlan_anti_spoof_result,
10939 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10940 TOKEN_STRING_INITIALIZER
10941 (struct cmd_vf_vlan_anti_spoof_result,
10943 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10944 TOKEN_STRING_INITIALIZER
10945 (struct cmd_vf_vlan_anti_spoof_result,
10947 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10948 TOKEN_STRING_INITIALIZER
10949 (struct cmd_vf_vlan_anti_spoof_result,
10950 antispoof, "antispoof");
10951 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10952 TOKEN_NUM_INITIALIZER
10953 (struct cmd_vf_vlan_anti_spoof_result,
10955 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10956 TOKEN_NUM_INITIALIZER
10957 (struct cmd_vf_vlan_anti_spoof_result,
10959 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10960 TOKEN_STRING_INITIALIZER
10961 (struct cmd_vf_vlan_anti_spoof_result,
10965 cmd_set_vf_vlan_anti_spoof_parsed(
10966 void *parsed_result,
10967 __attribute__((unused)) struct cmdline *cl,
10968 __attribute__((unused)) void *data)
10970 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10971 int ret = -ENOTSUP;
10973 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10975 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10978 #ifdef RTE_LIBRTE_IXGBE_PMD
10979 if (ret == -ENOTSUP)
10980 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10981 res->vf_id, is_on);
10983 #ifdef RTE_LIBRTE_I40E_PMD
10984 if (ret == -ENOTSUP)
10985 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10986 res->vf_id, is_on);
10993 printf("invalid vf_id %d\n", res->vf_id);
10996 printf("invalid port_id %d\n", res->port_id);
10999 printf("function not implemented\n");
11002 printf("programming error: (%s)\n", strerror(-ret));
11006 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11007 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11009 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11011 (void *)&cmd_vf_vlan_anti_spoof_set,
11012 (void *)&cmd_vf_vlan_anti_spoof_vf,
11013 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11014 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11015 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11016 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11017 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11022 /* vf mac anti spoof configuration */
11024 /* Common result structure for vf mac anti spoof */
11025 struct cmd_vf_mac_anti_spoof_result {
11026 cmdline_fixed_string_t set;
11027 cmdline_fixed_string_t vf;
11028 cmdline_fixed_string_t mac;
11029 cmdline_fixed_string_t antispoof;
11032 cmdline_fixed_string_t on_off;
11035 /* Common CLI fields for vf mac anti spoof enable disable */
11036 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11037 TOKEN_STRING_INITIALIZER
11038 (struct cmd_vf_mac_anti_spoof_result,
11040 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11041 TOKEN_STRING_INITIALIZER
11042 (struct cmd_vf_mac_anti_spoof_result,
11044 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11045 TOKEN_STRING_INITIALIZER
11046 (struct cmd_vf_mac_anti_spoof_result,
11048 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11049 TOKEN_STRING_INITIALIZER
11050 (struct cmd_vf_mac_anti_spoof_result,
11051 antispoof, "antispoof");
11052 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11053 TOKEN_NUM_INITIALIZER
11054 (struct cmd_vf_mac_anti_spoof_result,
11056 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11057 TOKEN_NUM_INITIALIZER
11058 (struct cmd_vf_mac_anti_spoof_result,
11060 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11061 TOKEN_STRING_INITIALIZER
11062 (struct cmd_vf_mac_anti_spoof_result,
11066 cmd_set_vf_mac_anti_spoof_parsed(
11067 void *parsed_result,
11068 __attribute__((unused)) struct cmdline *cl,
11069 __attribute__((unused)) void *data)
11071 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11072 int ret = -ENOTSUP;
11074 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11076 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11079 #ifdef RTE_LIBRTE_IXGBE_PMD
11080 if (ret == -ENOTSUP)
11081 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11082 res->vf_id, is_on);
11084 #ifdef RTE_LIBRTE_I40E_PMD
11085 if (ret == -ENOTSUP)
11086 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11087 res->vf_id, is_on);
11094 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11097 printf("invalid port_id %d\n", res->port_id);
11100 printf("function not implemented\n");
11103 printf("programming error: (%s)\n", strerror(-ret));
11107 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11108 .f = cmd_set_vf_mac_anti_spoof_parsed,
11110 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11112 (void *)&cmd_vf_mac_anti_spoof_set,
11113 (void *)&cmd_vf_mac_anti_spoof_vf,
11114 (void *)&cmd_vf_mac_anti_spoof_mac,
11115 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11116 (void *)&cmd_vf_mac_anti_spoof_port_id,
11117 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11118 (void *)&cmd_vf_mac_anti_spoof_on_off,
11123 /* vf vlan strip queue configuration */
11125 /* Common result structure for vf mac anti spoof */
11126 struct cmd_vf_vlan_stripq_result {
11127 cmdline_fixed_string_t set;
11128 cmdline_fixed_string_t vf;
11129 cmdline_fixed_string_t vlan;
11130 cmdline_fixed_string_t stripq;
11133 cmdline_fixed_string_t on_off;
11136 /* Common CLI fields for vf vlan strip enable disable */
11137 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11138 TOKEN_STRING_INITIALIZER
11139 (struct cmd_vf_vlan_stripq_result,
11141 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11142 TOKEN_STRING_INITIALIZER
11143 (struct cmd_vf_vlan_stripq_result,
11145 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11146 TOKEN_STRING_INITIALIZER
11147 (struct cmd_vf_vlan_stripq_result,
11149 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11150 TOKEN_STRING_INITIALIZER
11151 (struct cmd_vf_vlan_stripq_result,
11153 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11154 TOKEN_NUM_INITIALIZER
11155 (struct cmd_vf_vlan_stripq_result,
11157 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11158 TOKEN_NUM_INITIALIZER
11159 (struct cmd_vf_vlan_stripq_result,
11161 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11162 TOKEN_STRING_INITIALIZER
11163 (struct cmd_vf_vlan_stripq_result,
11167 cmd_set_vf_vlan_stripq_parsed(
11168 void *parsed_result,
11169 __attribute__((unused)) struct cmdline *cl,
11170 __attribute__((unused)) void *data)
11172 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11173 int ret = -ENOTSUP;
11175 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11177 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11180 #ifdef RTE_LIBRTE_IXGBE_PMD
11181 if (ret == -ENOTSUP)
11182 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11183 res->vf_id, is_on);
11185 #ifdef RTE_LIBRTE_I40E_PMD
11186 if (ret == -ENOTSUP)
11187 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11188 res->vf_id, is_on);
11195 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11198 printf("invalid port_id %d\n", res->port_id);
11201 printf("function not implemented\n");
11204 printf("programming error: (%s)\n", strerror(-ret));
11208 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11209 .f = cmd_set_vf_vlan_stripq_parsed,
11211 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11213 (void *)&cmd_vf_vlan_stripq_set,
11214 (void *)&cmd_vf_vlan_stripq_vf,
11215 (void *)&cmd_vf_vlan_stripq_vlan,
11216 (void *)&cmd_vf_vlan_stripq_stripq,
11217 (void *)&cmd_vf_vlan_stripq_port_id,
11218 (void *)&cmd_vf_vlan_stripq_vf_id,
11219 (void *)&cmd_vf_vlan_stripq_on_off,
11224 /* vf vlan insert configuration */
11226 /* Common result structure for vf vlan insert */
11227 struct cmd_vf_vlan_insert_result {
11228 cmdline_fixed_string_t set;
11229 cmdline_fixed_string_t vf;
11230 cmdline_fixed_string_t vlan;
11231 cmdline_fixed_string_t insert;
11237 /* Common CLI fields for vf vlan insert enable disable */
11238 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11239 TOKEN_STRING_INITIALIZER
11240 (struct cmd_vf_vlan_insert_result,
11242 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11243 TOKEN_STRING_INITIALIZER
11244 (struct cmd_vf_vlan_insert_result,
11246 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11247 TOKEN_STRING_INITIALIZER
11248 (struct cmd_vf_vlan_insert_result,
11250 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11251 TOKEN_STRING_INITIALIZER
11252 (struct cmd_vf_vlan_insert_result,
11254 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11255 TOKEN_NUM_INITIALIZER
11256 (struct cmd_vf_vlan_insert_result,
11258 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11259 TOKEN_NUM_INITIALIZER
11260 (struct cmd_vf_vlan_insert_result,
11262 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11263 TOKEN_NUM_INITIALIZER
11264 (struct cmd_vf_vlan_insert_result,
11268 cmd_set_vf_vlan_insert_parsed(
11269 void *parsed_result,
11270 __attribute__((unused)) struct cmdline *cl,
11271 __attribute__((unused)) void *data)
11273 struct cmd_vf_vlan_insert_result *res = parsed_result;
11274 int ret = -ENOTSUP;
11276 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11279 #ifdef RTE_LIBRTE_IXGBE_PMD
11280 if (ret == -ENOTSUP)
11281 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11284 #ifdef RTE_LIBRTE_I40E_PMD
11285 if (ret == -ENOTSUP)
11286 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11294 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11297 printf("invalid port_id %d\n", res->port_id);
11300 printf("function not implemented\n");
11303 printf("programming error: (%s)\n", strerror(-ret));
11307 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11308 .f = cmd_set_vf_vlan_insert_parsed,
11310 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11312 (void *)&cmd_vf_vlan_insert_set,
11313 (void *)&cmd_vf_vlan_insert_vf,
11314 (void *)&cmd_vf_vlan_insert_vlan,
11315 (void *)&cmd_vf_vlan_insert_insert,
11316 (void *)&cmd_vf_vlan_insert_port_id,
11317 (void *)&cmd_vf_vlan_insert_vf_id,
11318 (void *)&cmd_vf_vlan_insert_vlan_id,
11323 /* tx loopback configuration */
11325 /* Common result structure for tx loopback */
11326 struct cmd_tx_loopback_result {
11327 cmdline_fixed_string_t set;
11328 cmdline_fixed_string_t tx;
11329 cmdline_fixed_string_t loopback;
11331 cmdline_fixed_string_t on_off;
11334 /* Common CLI fields for tx loopback enable disable */
11335 cmdline_parse_token_string_t cmd_tx_loopback_set =
11336 TOKEN_STRING_INITIALIZER
11337 (struct cmd_tx_loopback_result,
11339 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11340 TOKEN_STRING_INITIALIZER
11341 (struct cmd_tx_loopback_result,
11343 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11344 TOKEN_STRING_INITIALIZER
11345 (struct cmd_tx_loopback_result,
11346 loopback, "loopback");
11347 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11348 TOKEN_NUM_INITIALIZER
11349 (struct cmd_tx_loopback_result,
11351 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11352 TOKEN_STRING_INITIALIZER
11353 (struct cmd_tx_loopback_result,
11357 cmd_set_tx_loopback_parsed(
11358 void *parsed_result,
11359 __attribute__((unused)) struct cmdline *cl,
11360 __attribute__((unused)) void *data)
11362 struct cmd_tx_loopback_result *res = parsed_result;
11363 int ret = -ENOTSUP;
11365 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11367 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11370 #ifdef RTE_LIBRTE_IXGBE_PMD
11371 if (ret == -ENOTSUP)
11372 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11374 #ifdef RTE_LIBRTE_I40E_PMD
11375 if (ret == -ENOTSUP)
11376 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11383 printf("invalid is_on %d\n", is_on);
11386 printf("invalid port_id %d\n", res->port_id);
11389 printf("function not implemented\n");
11392 printf("programming error: (%s)\n", strerror(-ret));
11396 cmdline_parse_inst_t cmd_set_tx_loopback = {
11397 .f = cmd_set_tx_loopback_parsed,
11399 .help_str = "set tx loopback <port_id> on|off",
11401 (void *)&cmd_tx_loopback_set,
11402 (void *)&cmd_tx_loopback_tx,
11403 (void *)&cmd_tx_loopback_loopback,
11404 (void *)&cmd_tx_loopback_port_id,
11405 (void *)&cmd_tx_loopback_on_off,
11410 #ifdef RTE_LIBRTE_IXGBE_PMD
11411 /* all queues drop enable configuration */
11413 /* Common result structure for all queues drop enable */
11414 struct cmd_all_queues_drop_en_result {
11415 cmdline_fixed_string_t set;
11416 cmdline_fixed_string_t all;
11417 cmdline_fixed_string_t queues;
11418 cmdline_fixed_string_t drop;
11420 cmdline_fixed_string_t on_off;
11423 /* Common CLI fields for tx loopback enable disable */
11424 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11425 TOKEN_STRING_INITIALIZER
11426 (struct cmd_all_queues_drop_en_result,
11428 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11429 TOKEN_STRING_INITIALIZER
11430 (struct cmd_all_queues_drop_en_result,
11432 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11433 TOKEN_STRING_INITIALIZER
11434 (struct cmd_all_queues_drop_en_result,
11436 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11437 TOKEN_STRING_INITIALIZER
11438 (struct cmd_all_queues_drop_en_result,
11440 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11441 TOKEN_NUM_INITIALIZER
11442 (struct cmd_all_queues_drop_en_result,
11444 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11445 TOKEN_STRING_INITIALIZER
11446 (struct cmd_all_queues_drop_en_result,
11450 cmd_set_all_queues_drop_en_parsed(
11451 void *parsed_result,
11452 __attribute__((unused)) struct cmdline *cl,
11453 __attribute__((unused)) void *data)
11455 struct cmd_all_queues_drop_en_result *res = parsed_result;
11457 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11459 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11462 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11467 printf("invalid is_on %d\n", is_on);
11470 printf("invalid port_id %d\n", res->port_id);
11473 printf("function not implemented\n");
11476 printf("programming error: (%s)\n", strerror(-ret));
11480 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11481 .f = cmd_set_all_queues_drop_en_parsed,
11483 .help_str = "set all queues drop <port_id> on|off",
11485 (void *)&cmd_all_queues_drop_en_set,
11486 (void *)&cmd_all_queues_drop_en_all,
11487 (void *)&cmd_all_queues_drop_en_queues,
11488 (void *)&cmd_all_queues_drop_en_drop,
11489 (void *)&cmd_all_queues_drop_en_port_id,
11490 (void *)&cmd_all_queues_drop_en_on_off,
11495 /* vf split drop enable configuration */
11497 /* Common result structure for vf split drop enable */
11498 struct cmd_vf_split_drop_en_result {
11499 cmdline_fixed_string_t set;
11500 cmdline_fixed_string_t vf;
11501 cmdline_fixed_string_t split;
11502 cmdline_fixed_string_t drop;
11505 cmdline_fixed_string_t on_off;
11508 /* Common CLI fields for vf split drop enable disable */
11509 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11510 TOKEN_STRING_INITIALIZER
11511 (struct cmd_vf_split_drop_en_result,
11513 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11514 TOKEN_STRING_INITIALIZER
11515 (struct cmd_vf_split_drop_en_result,
11517 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11518 TOKEN_STRING_INITIALIZER
11519 (struct cmd_vf_split_drop_en_result,
11521 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11522 TOKEN_STRING_INITIALIZER
11523 (struct cmd_vf_split_drop_en_result,
11525 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11526 TOKEN_NUM_INITIALIZER
11527 (struct cmd_vf_split_drop_en_result,
11529 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11530 TOKEN_NUM_INITIALIZER
11531 (struct cmd_vf_split_drop_en_result,
11533 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11534 TOKEN_STRING_INITIALIZER
11535 (struct cmd_vf_split_drop_en_result,
11539 cmd_set_vf_split_drop_en_parsed(
11540 void *parsed_result,
11541 __attribute__((unused)) struct cmdline *cl,
11542 __attribute__((unused)) void *data)
11544 struct cmd_vf_split_drop_en_result *res = parsed_result;
11546 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11548 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11551 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11557 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11560 printf("invalid port_id %d\n", res->port_id);
11563 printf("programming error: (%s)\n", strerror(-ret));
11567 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11568 .f = cmd_set_vf_split_drop_en_parsed,
11570 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11572 (void *)&cmd_vf_split_drop_en_set,
11573 (void *)&cmd_vf_split_drop_en_vf,
11574 (void *)&cmd_vf_split_drop_en_split,
11575 (void *)&cmd_vf_split_drop_en_drop,
11576 (void *)&cmd_vf_split_drop_en_port_id,
11577 (void *)&cmd_vf_split_drop_en_vf_id,
11578 (void *)&cmd_vf_split_drop_en_on_off,
11584 /* vf mac address configuration */
11586 /* Common result structure for vf mac address */
11587 struct cmd_set_vf_mac_addr_result {
11588 cmdline_fixed_string_t set;
11589 cmdline_fixed_string_t vf;
11590 cmdline_fixed_string_t mac;
11591 cmdline_fixed_string_t addr;
11594 struct ether_addr mac_addr;
11598 /* Common CLI fields for vf split drop enable disable */
11599 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11600 TOKEN_STRING_INITIALIZER
11601 (struct cmd_set_vf_mac_addr_result,
11603 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11604 TOKEN_STRING_INITIALIZER
11605 (struct cmd_set_vf_mac_addr_result,
11607 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11608 TOKEN_STRING_INITIALIZER
11609 (struct cmd_set_vf_mac_addr_result,
11611 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11612 TOKEN_STRING_INITIALIZER
11613 (struct cmd_set_vf_mac_addr_result,
11615 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11616 TOKEN_NUM_INITIALIZER
11617 (struct cmd_set_vf_mac_addr_result,
11619 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11620 TOKEN_NUM_INITIALIZER
11621 (struct cmd_set_vf_mac_addr_result,
11623 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11624 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11628 cmd_set_vf_mac_addr_parsed(
11629 void *parsed_result,
11630 __attribute__((unused)) struct cmdline *cl,
11631 __attribute__((unused)) void *data)
11633 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11634 int ret = -ENOTSUP;
11636 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11639 #ifdef RTE_LIBRTE_IXGBE_PMD
11640 if (ret == -ENOTSUP)
11641 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11644 #ifdef RTE_LIBRTE_I40E_PMD
11645 if (ret == -ENOTSUP)
11646 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11654 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11657 printf("invalid port_id %d\n", res->port_id);
11660 printf("function not implemented\n");
11663 printf("programming error: (%s)\n", strerror(-ret));
11667 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11668 .f = cmd_set_vf_mac_addr_parsed,
11670 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11672 (void *)&cmd_set_vf_mac_addr_set,
11673 (void *)&cmd_set_vf_mac_addr_vf,
11674 (void *)&cmd_set_vf_mac_addr_mac,
11675 (void *)&cmd_set_vf_mac_addr_addr,
11676 (void *)&cmd_set_vf_mac_addr_port_id,
11677 (void *)&cmd_set_vf_mac_addr_vf_id,
11678 (void *)&cmd_set_vf_mac_addr_mac_addr,
11683 #ifdef RTE_LIBRTE_IXGBE_PMD
11684 /* MACsec configuration */
11686 /* Common result structure for MACsec offload enable */
11687 struct cmd_macsec_offload_on_result {
11688 cmdline_fixed_string_t set;
11689 cmdline_fixed_string_t macsec;
11690 cmdline_fixed_string_t offload;
11692 cmdline_fixed_string_t on;
11693 cmdline_fixed_string_t encrypt;
11694 cmdline_fixed_string_t en_on_off;
11695 cmdline_fixed_string_t replay_protect;
11696 cmdline_fixed_string_t rp_on_off;
11699 /* Common CLI fields for MACsec offload disable */
11700 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11701 TOKEN_STRING_INITIALIZER
11702 (struct cmd_macsec_offload_on_result,
11704 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11705 TOKEN_STRING_INITIALIZER
11706 (struct cmd_macsec_offload_on_result,
11708 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11709 TOKEN_STRING_INITIALIZER
11710 (struct cmd_macsec_offload_on_result,
11711 offload, "offload");
11712 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11713 TOKEN_NUM_INITIALIZER
11714 (struct cmd_macsec_offload_on_result,
11716 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11717 TOKEN_STRING_INITIALIZER
11718 (struct cmd_macsec_offload_on_result,
11720 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11721 TOKEN_STRING_INITIALIZER
11722 (struct cmd_macsec_offload_on_result,
11723 encrypt, "encrypt");
11724 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11725 TOKEN_STRING_INITIALIZER
11726 (struct cmd_macsec_offload_on_result,
11727 en_on_off, "on#off");
11728 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11729 TOKEN_STRING_INITIALIZER
11730 (struct cmd_macsec_offload_on_result,
11731 replay_protect, "replay-protect");
11732 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11733 TOKEN_STRING_INITIALIZER
11734 (struct cmd_macsec_offload_on_result,
11735 rp_on_off, "on#off");
11738 cmd_set_macsec_offload_on_parsed(
11739 void *parsed_result,
11740 __attribute__((unused)) struct cmdline *cl,
11741 __attribute__((unused)) void *data)
11743 struct cmd_macsec_offload_on_result *res = parsed_result;
11745 portid_t port_id = res->port_id;
11746 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11747 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11749 if (port_id_is_invalid(port_id, ENABLED_WARN))
11752 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11753 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11759 printf("invalid port_id %d\n", port_id);
11762 printf("programming error: (%s)\n", strerror(-ret));
11766 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11767 .f = cmd_set_macsec_offload_on_parsed,
11769 .help_str = "set macsec offload <port_id> on "
11770 "encrypt on|off replay-protect on|off",
11772 (void *)&cmd_macsec_offload_on_set,
11773 (void *)&cmd_macsec_offload_on_macsec,
11774 (void *)&cmd_macsec_offload_on_offload,
11775 (void *)&cmd_macsec_offload_on_port_id,
11776 (void *)&cmd_macsec_offload_on_on,
11777 (void *)&cmd_macsec_offload_on_encrypt,
11778 (void *)&cmd_macsec_offload_on_en_on_off,
11779 (void *)&cmd_macsec_offload_on_replay_protect,
11780 (void *)&cmd_macsec_offload_on_rp_on_off,
11785 /* Common result structure for MACsec offload disable */
11786 struct cmd_macsec_offload_off_result {
11787 cmdline_fixed_string_t set;
11788 cmdline_fixed_string_t macsec;
11789 cmdline_fixed_string_t offload;
11791 cmdline_fixed_string_t off;
11794 /* Common CLI fields for MACsec offload disable */
11795 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11796 TOKEN_STRING_INITIALIZER
11797 (struct cmd_macsec_offload_off_result,
11799 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11800 TOKEN_STRING_INITIALIZER
11801 (struct cmd_macsec_offload_off_result,
11803 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11804 TOKEN_STRING_INITIALIZER
11805 (struct cmd_macsec_offload_off_result,
11806 offload, "offload");
11807 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11808 TOKEN_NUM_INITIALIZER
11809 (struct cmd_macsec_offload_off_result,
11811 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11812 TOKEN_STRING_INITIALIZER
11813 (struct cmd_macsec_offload_off_result,
11817 cmd_set_macsec_offload_off_parsed(
11818 void *parsed_result,
11819 __attribute__((unused)) struct cmdline *cl,
11820 __attribute__((unused)) void *data)
11822 struct cmd_macsec_offload_off_result *res = parsed_result;
11824 portid_t port_id = res->port_id;
11826 if (port_id_is_invalid(port_id, ENABLED_WARN))
11829 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11830 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11836 printf("invalid port_id %d\n", port_id);
11839 printf("programming error: (%s)\n", strerror(-ret));
11843 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11844 .f = cmd_set_macsec_offload_off_parsed,
11846 .help_str = "set macsec offload <port_id> off",
11848 (void *)&cmd_macsec_offload_off_set,
11849 (void *)&cmd_macsec_offload_off_macsec,
11850 (void *)&cmd_macsec_offload_off_offload,
11851 (void *)&cmd_macsec_offload_off_port_id,
11852 (void *)&cmd_macsec_offload_off_off,
11857 /* Common result structure for MACsec secure connection configure */
11858 struct cmd_macsec_sc_result {
11859 cmdline_fixed_string_t set;
11860 cmdline_fixed_string_t macsec;
11861 cmdline_fixed_string_t sc;
11862 cmdline_fixed_string_t tx_rx;
11864 struct ether_addr mac;
11868 /* Common CLI fields for MACsec secure connection configure */
11869 cmdline_parse_token_string_t cmd_macsec_sc_set =
11870 TOKEN_STRING_INITIALIZER
11871 (struct cmd_macsec_sc_result,
11873 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11874 TOKEN_STRING_INITIALIZER
11875 (struct cmd_macsec_sc_result,
11877 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11878 TOKEN_STRING_INITIALIZER
11879 (struct cmd_macsec_sc_result,
11881 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11882 TOKEN_STRING_INITIALIZER
11883 (struct cmd_macsec_sc_result,
11885 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11886 TOKEN_NUM_INITIALIZER
11887 (struct cmd_macsec_sc_result,
11889 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11890 TOKEN_ETHERADDR_INITIALIZER
11891 (struct cmd_macsec_sc_result,
11893 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11894 TOKEN_NUM_INITIALIZER
11895 (struct cmd_macsec_sc_result,
11899 cmd_set_macsec_sc_parsed(
11900 void *parsed_result,
11901 __attribute__((unused)) struct cmdline *cl,
11902 __attribute__((unused)) void *data)
11904 struct cmd_macsec_sc_result *res = parsed_result;
11906 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11909 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11910 res->mac.addr_bytes) :
11911 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11912 res->mac.addr_bytes, res->pi);
11917 printf("invalid port_id %d\n", res->port_id);
11920 printf("programming error: (%s)\n", strerror(-ret));
11924 cmdline_parse_inst_t cmd_set_macsec_sc = {
11925 .f = cmd_set_macsec_sc_parsed,
11927 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11929 (void *)&cmd_macsec_sc_set,
11930 (void *)&cmd_macsec_sc_macsec,
11931 (void *)&cmd_macsec_sc_sc,
11932 (void *)&cmd_macsec_sc_tx_rx,
11933 (void *)&cmd_macsec_sc_port_id,
11934 (void *)&cmd_macsec_sc_mac,
11935 (void *)&cmd_macsec_sc_pi,
11940 /* Common result structure for MACsec secure connection configure */
11941 struct cmd_macsec_sa_result {
11942 cmdline_fixed_string_t set;
11943 cmdline_fixed_string_t macsec;
11944 cmdline_fixed_string_t sa;
11945 cmdline_fixed_string_t tx_rx;
11950 cmdline_fixed_string_t key;
11953 /* Common CLI fields for MACsec secure connection configure */
11954 cmdline_parse_token_string_t cmd_macsec_sa_set =
11955 TOKEN_STRING_INITIALIZER
11956 (struct cmd_macsec_sa_result,
11958 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11959 TOKEN_STRING_INITIALIZER
11960 (struct cmd_macsec_sa_result,
11962 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11963 TOKEN_STRING_INITIALIZER
11964 (struct cmd_macsec_sa_result,
11966 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11967 TOKEN_STRING_INITIALIZER
11968 (struct cmd_macsec_sa_result,
11970 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11971 TOKEN_NUM_INITIALIZER
11972 (struct cmd_macsec_sa_result,
11974 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11975 TOKEN_NUM_INITIALIZER
11976 (struct cmd_macsec_sa_result,
11978 cmdline_parse_token_num_t cmd_macsec_sa_an =
11979 TOKEN_NUM_INITIALIZER
11980 (struct cmd_macsec_sa_result,
11982 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11983 TOKEN_NUM_INITIALIZER
11984 (struct cmd_macsec_sa_result,
11986 cmdline_parse_token_string_t cmd_macsec_sa_key =
11987 TOKEN_STRING_INITIALIZER
11988 (struct cmd_macsec_sa_result,
11992 cmd_set_macsec_sa_parsed(
11993 void *parsed_result,
11994 __attribute__((unused)) struct cmdline *cl,
11995 __attribute__((unused)) void *data)
11997 struct cmd_macsec_sa_result *res = parsed_result;
11999 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12000 uint8_t key[16] = { 0 };
12006 key_len = strlen(res->key) / 2;
12010 for (i = 0; i < key_len; i++) {
12011 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12014 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12017 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12021 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12022 res->idx, res->an, res->pn, key) :
12023 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12024 res->idx, res->an, res->pn, key);
12029 printf("invalid idx %d or an %d\n", res->idx, res->an);
12032 printf("invalid port_id %d\n", res->port_id);
12035 printf("programming error: (%s)\n", strerror(-ret));
12039 cmdline_parse_inst_t cmd_set_macsec_sa = {
12040 .f = cmd_set_macsec_sa_parsed,
12042 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12044 (void *)&cmd_macsec_sa_set,
12045 (void *)&cmd_macsec_sa_macsec,
12046 (void *)&cmd_macsec_sa_sa,
12047 (void *)&cmd_macsec_sa_tx_rx,
12048 (void *)&cmd_macsec_sa_port_id,
12049 (void *)&cmd_macsec_sa_idx,
12050 (void *)&cmd_macsec_sa_an,
12051 (void *)&cmd_macsec_sa_pn,
12052 (void *)&cmd_macsec_sa_key,
12058 /* VF unicast promiscuous mode configuration */
12060 /* Common result structure for VF unicast promiscuous mode */
12061 struct cmd_vf_promisc_result {
12062 cmdline_fixed_string_t set;
12063 cmdline_fixed_string_t vf;
12064 cmdline_fixed_string_t promisc;
12067 cmdline_fixed_string_t on_off;
12070 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12071 cmdline_parse_token_string_t cmd_vf_promisc_set =
12072 TOKEN_STRING_INITIALIZER
12073 (struct cmd_vf_promisc_result,
12075 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12076 TOKEN_STRING_INITIALIZER
12077 (struct cmd_vf_promisc_result,
12079 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12080 TOKEN_STRING_INITIALIZER
12081 (struct cmd_vf_promisc_result,
12082 promisc, "promisc");
12083 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12084 TOKEN_NUM_INITIALIZER
12085 (struct cmd_vf_promisc_result,
12087 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12088 TOKEN_NUM_INITIALIZER
12089 (struct cmd_vf_promisc_result,
12091 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12092 TOKEN_STRING_INITIALIZER
12093 (struct cmd_vf_promisc_result,
12097 cmd_set_vf_promisc_parsed(
12098 void *parsed_result,
12099 __attribute__((unused)) struct cmdline *cl,
12100 __attribute__((unused)) void *data)
12102 struct cmd_vf_promisc_result *res = parsed_result;
12103 int ret = -ENOTSUP;
12105 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12107 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12110 #ifdef RTE_LIBRTE_I40E_PMD
12111 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12112 res->vf_id, is_on);
12119 printf("invalid vf_id %d\n", res->vf_id);
12122 printf("invalid port_id %d\n", res->port_id);
12125 printf("function not implemented\n");
12128 printf("programming error: (%s)\n", strerror(-ret));
12132 cmdline_parse_inst_t cmd_set_vf_promisc = {
12133 .f = cmd_set_vf_promisc_parsed,
12135 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12136 "Set unicast promiscuous mode for a VF from the PF",
12138 (void *)&cmd_vf_promisc_set,
12139 (void *)&cmd_vf_promisc_vf,
12140 (void *)&cmd_vf_promisc_promisc,
12141 (void *)&cmd_vf_promisc_port_id,
12142 (void *)&cmd_vf_promisc_vf_id,
12143 (void *)&cmd_vf_promisc_on_off,
12148 /* VF multicast promiscuous mode configuration */
12150 /* Common result structure for VF multicast promiscuous mode */
12151 struct cmd_vf_allmulti_result {
12152 cmdline_fixed_string_t set;
12153 cmdline_fixed_string_t vf;
12154 cmdline_fixed_string_t allmulti;
12157 cmdline_fixed_string_t on_off;
12160 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12161 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12162 TOKEN_STRING_INITIALIZER
12163 (struct cmd_vf_allmulti_result,
12165 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12166 TOKEN_STRING_INITIALIZER
12167 (struct cmd_vf_allmulti_result,
12169 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_vf_allmulti_result,
12172 allmulti, "allmulti");
12173 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12174 TOKEN_NUM_INITIALIZER
12175 (struct cmd_vf_allmulti_result,
12177 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12178 TOKEN_NUM_INITIALIZER
12179 (struct cmd_vf_allmulti_result,
12181 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12182 TOKEN_STRING_INITIALIZER
12183 (struct cmd_vf_allmulti_result,
12187 cmd_set_vf_allmulti_parsed(
12188 void *parsed_result,
12189 __attribute__((unused)) struct cmdline *cl,
12190 __attribute__((unused)) void *data)
12192 struct cmd_vf_allmulti_result *res = parsed_result;
12193 int ret = -ENOTSUP;
12195 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12197 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12200 #ifdef RTE_LIBRTE_I40E_PMD
12201 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12202 res->vf_id, is_on);
12209 printf("invalid vf_id %d\n", res->vf_id);
12212 printf("invalid port_id %d\n", res->port_id);
12215 printf("function not implemented\n");
12218 printf("programming error: (%s)\n", strerror(-ret));
12222 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12223 .f = cmd_set_vf_allmulti_parsed,
12225 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12226 "Set multicast promiscuous mode for a VF from the PF",
12228 (void *)&cmd_vf_allmulti_set,
12229 (void *)&cmd_vf_allmulti_vf,
12230 (void *)&cmd_vf_allmulti_allmulti,
12231 (void *)&cmd_vf_allmulti_port_id,
12232 (void *)&cmd_vf_allmulti_vf_id,
12233 (void *)&cmd_vf_allmulti_on_off,
12238 /* vf broadcast mode configuration */
12240 /* Common result structure for vf broadcast */
12241 struct cmd_set_vf_broadcast_result {
12242 cmdline_fixed_string_t set;
12243 cmdline_fixed_string_t vf;
12244 cmdline_fixed_string_t broadcast;
12247 cmdline_fixed_string_t on_off;
12250 /* Common CLI fields for vf broadcast enable disable */
12251 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12252 TOKEN_STRING_INITIALIZER
12253 (struct cmd_set_vf_broadcast_result,
12255 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12256 TOKEN_STRING_INITIALIZER
12257 (struct cmd_set_vf_broadcast_result,
12259 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12260 TOKEN_STRING_INITIALIZER
12261 (struct cmd_set_vf_broadcast_result,
12262 broadcast, "broadcast");
12263 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12264 TOKEN_NUM_INITIALIZER
12265 (struct cmd_set_vf_broadcast_result,
12267 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12268 TOKEN_NUM_INITIALIZER
12269 (struct cmd_set_vf_broadcast_result,
12271 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12272 TOKEN_STRING_INITIALIZER
12273 (struct cmd_set_vf_broadcast_result,
12277 cmd_set_vf_broadcast_parsed(
12278 void *parsed_result,
12279 __attribute__((unused)) struct cmdline *cl,
12280 __attribute__((unused)) void *data)
12282 struct cmd_set_vf_broadcast_result *res = parsed_result;
12283 int ret = -ENOTSUP;
12285 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12287 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12290 #ifdef RTE_LIBRTE_I40E_PMD
12291 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12292 res->vf_id, is_on);
12299 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12302 printf("invalid port_id %d\n", res->port_id);
12305 printf("function not implemented\n");
12308 printf("programming error: (%s)\n", strerror(-ret));
12312 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12313 .f = cmd_set_vf_broadcast_parsed,
12315 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12317 (void *)&cmd_set_vf_broadcast_set,
12318 (void *)&cmd_set_vf_broadcast_vf,
12319 (void *)&cmd_set_vf_broadcast_broadcast,
12320 (void *)&cmd_set_vf_broadcast_port_id,
12321 (void *)&cmd_set_vf_broadcast_vf_id,
12322 (void *)&cmd_set_vf_broadcast_on_off,
12327 /* vf vlan tag configuration */
12329 /* Common result structure for vf vlan tag */
12330 struct cmd_set_vf_vlan_tag_result {
12331 cmdline_fixed_string_t set;
12332 cmdline_fixed_string_t vf;
12333 cmdline_fixed_string_t vlan;
12334 cmdline_fixed_string_t tag;
12337 cmdline_fixed_string_t on_off;
12340 /* Common CLI fields for vf vlan tag enable disable */
12341 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12342 TOKEN_STRING_INITIALIZER
12343 (struct cmd_set_vf_vlan_tag_result,
12345 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12346 TOKEN_STRING_INITIALIZER
12347 (struct cmd_set_vf_vlan_tag_result,
12349 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12350 TOKEN_STRING_INITIALIZER
12351 (struct cmd_set_vf_vlan_tag_result,
12353 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12354 TOKEN_STRING_INITIALIZER
12355 (struct cmd_set_vf_vlan_tag_result,
12357 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12358 TOKEN_NUM_INITIALIZER
12359 (struct cmd_set_vf_vlan_tag_result,
12361 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12362 TOKEN_NUM_INITIALIZER
12363 (struct cmd_set_vf_vlan_tag_result,
12365 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12366 TOKEN_STRING_INITIALIZER
12367 (struct cmd_set_vf_vlan_tag_result,
12371 cmd_set_vf_vlan_tag_parsed(
12372 void *parsed_result,
12373 __attribute__((unused)) struct cmdline *cl,
12374 __attribute__((unused)) void *data)
12376 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12377 int ret = -ENOTSUP;
12379 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12381 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12384 #ifdef RTE_LIBRTE_I40E_PMD
12385 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12386 res->vf_id, is_on);
12393 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12396 printf("invalid port_id %d\n", res->port_id);
12399 printf("function not implemented\n");
12402 printf("programming error: (%s)\n", strerror(-ret));
12406 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12407 .f = cmd_set_vf_vlan_tag_parsed,
12409 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12411 (void *)&cmd_set_vf_vlan_tag_set,
12412 (void *)&cmd_set_vf_vlan_tag_vf,
12413 (void *)&cmd_set_vf_vlan_tag_vlan,
12414 (void *)&cmd_set_vf_vlan_tag_tag,
12415 (void *)&cmd_set_vf_vlan_tag_port_id,
12416 (void *)&cmd_set_vf_vlan_tag_vf_id,
12417 (void *)&cmd_set_vf_vlan_tag_on_off,
12422 /* Common definition of VF and TC TX bandwidth configuration */
12423 struct cmd_vf_tc_bw_result {
12424 cmdline_fixed_string_t set;
12425 cmdline_fixed_string_t vf;
12426 cmdline_fixed_string_t tc;
12427 cmdline_fixed_string_t tx;
12428 cmdline_fixed_string_t min_bw;
12429 cmdline_fixed_string_t max_bw;
12430 cmdline_fixed_string_t strict_link_prio;
12435 cmdline_fixed_string_t bw_list;
12439 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12440 TOKEN_STRING_INITIALIZER
12441 (struct cmd_vf_tc_bw_result,
12443 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12444 TOKEN_STRING_INITIALIZER
12445 (struct cmd_vf_tc_bw_result,
12447 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12448 TOKEN_STRING_INITIALIZER
12449 (struct cmd_vf_tc_bw_result,
12451 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12452 TOKEN_STRING_INITIALIZER
12453 (struct cmd_vf_tc_bw_result,
12455 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12456 TOKEN_STRING_INITIALIZER
12457 (struct cmd_vf_tc_bw_result,
12458 strict_link_prio, "strict-link-priority");
12459 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12460 TOKEN_STRING_INITIALIZER
12461 (struct cmd_vf_tc_bw_result,
12462 min_bw, "min-bandwidth");
12463 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12464 TOKEN_STRING_INITIALIZER
12465 (struct cmd_vf_tc_bw_result,
12466 max_bw, "max-bandwidth");
12467 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12468 TOKEN_NUM_INITIALIZER
12469 (struct cmd_vf_tc_bw_result,
12471 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12472 TOKEN_NUM_INITIALIZER
12473 (struct cmd_vf_tc_bw_result,
12475 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12476 TOKEN_NUM_INITIALIZER
12477 (struct cmd_vf_tc_bw_result,
12479 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12480 TOKEN_NUM_INITIALIZER
12481 (struct cmd_vf_tc_bw_result,
12483 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12484 TOKEN_STRING_INITIALIZER
12485 (struct cmd_vf_tc_bw_result,
12487 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12488 TOKEN_NUM_INITIALIZER
12489 (struct cmd_vf_tc_bw_result,
12492 /* VF max bandwidth setting */
12494 cmd_vf_max_bw_parsed(
12495 void *parsed_result,
12496 __attribute__((unused)) struct cmdline *cl,
12497 __attribute__((unused)) void *data)
12499 struct cmd_vf_tc_bw_result *res = parsed_result;
12500 int ret = -ENOTSUP;
12502 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12505 #ifdef RTE_LIBRTE_I40E_PMD
12506 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12507 res->vf_id, res->bw);
12514 printf("invalid vf_id %d or bandwidth %d\n",
12515 res->vf_id, res->bw);
12518 printf("invalid port_id %d\n", res->port_id);
12521 printf("function not implemented\n");
12524 printf("programming error: (%s)\n", strerror(-ret));
12528 cmdline_parse_inst_t cmd_vf_max_bw = {
12529 .f = cmd_vf_max_bw_parsed,
12531 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12533 (void *)&cmd_vf_tc_bw_set,
12534 (void *)&cmd_vf_tc_bw_vf,
12535 (void *)&cmd_vf_tc_bw_tx,
12536 (void *)&cmd_vf_tc_bw_max_bw,
12537 (void *)&cmd_vf_tc_bw_port_id,
12538 (void *)&cmd_vf_tc_bw_vf_id,
12539 (void *)&cmd_vf_tc_bw_bw,
12545 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12550 const char *p, *p0 = str;
12557 p = strchr(p0, '(');
12559 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12563 p0 = strchr(p, ')');
12565 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12569 if (size >= sizeof(s)) {
12570 printf("The string size exceeds the internal buffer size\n");
12573 snprintf(s, sizeof(s), "%.*s", size, p);
12574 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12576 printf("Failed to get the bandwidth list. ");
12580 for (i = 0; i < ret; i++)
12581 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12586 /* TC min bandwidth setting */
12588 cmd_vf_tc_min_bw_parsed(
12589 void *parsed_result,
12590 __attribute__((unused)) struct cmdline *cl,
12591 __attribute__((unused)) void *data)
12593 struct cmd_vf_tc_bw_result *res = parsed_result;
12596 int ret = -ENOTSUP;
12598 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12601 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12605 #ifdef RTE_LIBRTE_I40E_PMD
12606 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12614 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12617 printf("invalid port_id %d\n", res->port_id);
12620 printf("function not implemented\n");
12623 printf("programming error: (%s)\n", strerror(-ret));
12627 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12628 .f = cmd_vf_tc_min_bw_parsed,
12630 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12631 " <bw1, bw2, ...>",
12633 (void *)&cmd_vf_tc_bw_set,
12634 (void *)&cmd_vf_tc_bw_vf,
12635 (void *)&cmd_vf_tc_bw_tc,
12636 (void *)&cmd_vf_tc_bw_tx,
12637 (void *)&cmd_vf_tc_bw_min_bw,
12638 (void *)&cmd_vf_tc_bw_port_id,
12639 (void *)&cmd_vf_tc_bw_vf_id,
12640 (void *)&cmd_vf_tc_bw_bw_list,
12645 /* TC max bandwidth setting */
12647 cmd_vf_tc_max_bw_parsed(
12648 void *parsed_result,
12649 __attribute__((unused)) struct cmdline *cl,
12650 __attribute__((unused)) void *data)
12652 struct cmd_vf_tc_bw_result *res = parsed_result;
12653 int ret = -ENOTSUP;
12655 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12658 #ifdef RTE_LIBRTE_I40E_PMD
12659 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12660 res->tc_no, res->bw);
12667 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12668 res->vf_id, res->tc_no, res->bw);
12671 printf("invalid port_id %d\n", res->port_id);
12674 printf("function not implemented\n");
12677 printf("programming error: (%s)\n", strerror(-ret));
12681 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12682 .f = cmd_vf_tc_max_bw_parsed,
12684 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12687 (void *)&cmd_vf_tc_bw_set,
12688 (void *)&cmd_vf_tc_bw_vf,
12689 (void *)&cmd_vf_tc_bw_tc,
12690 (void *)&cmd_vf_tc_bw_tx,
12691 (void *)&cmd_vf_tc_bw_max_bw,
12692 (void *)&cmd_vf_tc_bw_port_id,
12693 (void *)&cmd_vf_tc_bw_vf_id,
12694 (void *)&cmd_vf_tc_bw_tc_no,
12695 (void *)&cmd_vf_tc_bw_bw,
12700 /* Strict link priority scheduling mode setting */
12702 cmd_strict_link_prio_parsed(
12703 void *parsed_result,
12704 __attribute__((unused)) struct cmdline *cl,
12705 __attribute__((unused)) void *data)
12707 struct cmd_vf_tc_bw_result *res = parsed_result;
12708 int ret = -ENOTSUP;
12710 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12713 #ifdef RTE_LIBRTE_I40E_PMD
12714 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12721 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12724 printf("invalid port_id %d\n", res->port_id);
12727 printf("function not implemented\n");
12730 printf("programming error: (%s)\n", strerror(-ret));
12734 cmdline_parse_inst_t cmd_strict_link_prio = {
12735 .f = cmd_strict_link_prio_parsed,
12737 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12739 (void *)&cmd_vf_tc_bw_set,
12740 (void *)&cmd_vf_tc_bw_tx,
12741 (void *)&cmd_vf_tc_bw_strict_link_prio,
12742 (void *)&cmd_vf_tc_bw_port_id,
12743 (void *)&cmd_vf_tc_bw_tc_map,
12748 /* Load dynamic device personalization*/
12749 struct cmd_ddp_add_result {
12750 cmdline_fixed_string_t ddp;
12751 cmdline_fixed_string_t add;
12756 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12757 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12758 cmdline_parse_token_string_t cmd_ddp_add_add =
12759 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12760 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12761 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12762 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12763 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12766 cmd_ddp_add_parsed(
12767 void *parsed_result,
12768 __attribute__((unused)) struct cmdline *cl,
12769 __attribute__((unused)) void *data)
12771 struct cmd_ddp_add_result *res = parsed_result;
12774 int ret = -ENOTSUP;
12776 if (res->port_id > nb_ports) {
12777 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12781 if (!all_ports_stopped()) {
12782 printf("Please stop all ports first\n");
12786 buff = open_ddp_package_file(res->filepath, &size);
12790 #ifdef RTE_LIBRTE_I40E_PMD
12791 if (ret == -ENOTSUP)
12792 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12794 RTE_PMD_I40E_PKG_OP_WR_ADD);
12798 printf("Failed to load profile.\n");
12800 printf("Profile has already existed.\n");
12802 close_ddp_package_file(buff);
12805 cmdline_parse_inst_t cmd_ddp_add = {
12806 .f = cmd_ddp_add_parsed,
12808 .help_str = "ddp add <port_id> <profile_path>",
12810 (void *)&cmd_ddp_add_ddp,
12811 (void *)&cmd_ddp_add_add,
12812 (void *)&cmd_ddp_add_port_id,
12813 (void *)&cmd_ddp_add_filepath,
12818 /* Get dynamic device personalization profile info list*/
12819 #define PROFILE_INFO_SIZE 48
12820 #define MAX_PROFILE_NUM 16
12822 struct cmd_ddp_get_list_result {
12823 cmdline_fixed_string_t ddp;
12824 cmdline_fixed_string_t get;
12825 cmdline_fixed_string_t list;
12829 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
12830 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
12831 cmdline_parse_token_string_t cmd_ddp_get_list_get =
12832 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
12833 cmdline_parse_token_string_t cmd_ddp_get_list_list =
12834 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
12835 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
12836 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
12839 cmd_ddp_get_list_parsed(
12840 void *parsed_result,
12841 __attribute__((unused)) struct cmdline *cl,
12842 __attribute__((unused)) void *data)
12844 struct cmd_ddp_get_list_result *res = parsed_result;
12845 #ifdef RTE_LIBRTE_I40E_PMD
12846 struct rte_pmd_i40e_profile_list *p_list;
12847 struct rte_pmd_i40e_profile_info *p_info;
12852 int ret = -ENOTSUP;
12854 if (res->port_id > nb_ports) {
12855 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12859 #ifdef RTE_LIBRTE_I40E_PMD
12860 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
12861 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
12863 printf("%s: Failed to malloc buffer\n", __func__);
12865 if (ret == -ENOTSUP)
12866 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
12867 (uint8_t *)p_list, size);
12870 p_num = p_list->p_count;
12871 printf("Profile number is: %d\n\n", p_num);
12873 for (i = 0; i < p_num; i++) {
12874 p_info = &p_list->p_info[i];
12875 printf("Profile %d:\n", i);
12876 printf("Track id: 0x%x\n", p_info->track_id);
12877 printf("Version: %d.%d.%d.%d\n",
12878 p_info->version.major,
12879 p_info->version.minor,
12880 p_info->version.update,
12881 p_info->version.draft);
12882 printf("Profile name: %s\n\n", p_info->name);
12890 printf("Failed to get ddp list\n");
12893 cmdline_parse_inst_t cmd_ddp_get_list = {
12894 .f = cmd_ddp_get_list_parsed,
12896 .help_str = "ddp get list <port_id>",
12898 (void *)&cmd_ddp_get_list_ddp,
12899 (void *)&cmd_ddp_get_list_get,
12900 (void *)&cmd_ddp_get_list_list,
12901 (void *)&cmd_ddp_get_list_port_id,
12905 /* ******************************************************************************** */
12907 /* list of instructions */
12908 cmdline_parse_ctx_t main_ctx[] = {
12909 (cmdline_parse_inst_t *)&cmd_help_brief,
12910 (cmdline_parse_inst_t *)&cmd_help_long,
12911 (cmdline_parse_inst_t *)&cmd_quit,
12912 (cmdline_parse_inst_t *)&cmd_showport,
12913 (cmdline_parse_inst_t *)&cmd_showqueue,
12914 (cmdline_parse_inst_t *)&cmd_showportall,
12915 (cmdline_parse_inst_t *)&cmd_showcfg,
12916 (cmdline_parse_inst_t *)&cmd_start,
12917 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12918 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12919 (cmdline_parse_inst_t *)&cmd_set_link_up,
12920 (cmdline_parse_inst_t *)&cmd_set_link_down,
12921 (cmdline_parse_inst_t *)&cmd_reset,
12922 (cmdline_parse_inst_t *)&cmd_set_numbers,
12923 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12924 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12925 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12926 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12927 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12928 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12929 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12930 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12931 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12932 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12933 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12934 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12935 (cmdline_parse_inst_t *)&cmd_set_link_check,
12936 #ifdef RTE_NIC_BYPASS
12937 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12938 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12939 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12940 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12942 #ifdef RTE_LIBRTE_PMD_BOND
12943 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12944 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12945 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12946 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12947 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12948 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12949 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12950 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12951 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12953 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12954 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12955 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12956 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12957 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12958 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12959 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12960 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12961 (cmdline_parse_inst_t *)&cmd_csum_set,
12962 (cmdline_parse_inst_t *)&cmd_csum_show,
12963 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12964 (cmdline_parse_inst_t *)&cmd_tso_set,
12965 (cmdline_parse_inst_t *)&cmd_tso_show,
12966 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12967 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12968 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12969 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12970 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12971 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12972 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12973 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12974 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12975 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12976 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12977 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12978 (cmdline_parse_inst_t *)&cmd_config_dcb,
12979 (cmdline_parse_inst_t *)&cmd_read_reg,
12980 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12981 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12982 (cmdline_parse_inst_t *)&cmd_write_reg,
12983 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12984 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12985 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12986 (cmdline_parse_inst_t *)&cmd_stop,
12987 (cmdline_parse_inst_t *)&cmd_mac_addr,
12988 (cmdline_parse_inst_t *)&cmd_set_qmap,
12989 (cmdline_parse_inst_t *)&cmd_operate_port,
12990 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12991 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12992 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12993 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12994 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12995 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12996 (cmdline_parse_inst_t *)&cmd_config_mtu,
12997 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12998 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12999 (cmdline_parse_inst_t *)&cmd_config_rss,
13000 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13001 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13002 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13003 (cmdline_parse_inst_t *)&cmd_showport_reta,
13004 (cmdline_parse_inst_t *)&cmd_config_burst,
13005 (cmdline_parse_inst_t *)&cmd_config_thresh,
13006 (cmdline_parse_inst_t *)&cmd_config_threshold,
13007 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13008 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13009 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13010 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13011 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13012 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13013 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13014 (cmdline_parse_inst_t *)&cmd_global_config,
13015 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13016 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13017 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13018 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13019 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13020 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13021 (cmdline_parse_inst_t *)&cmd_dump,
13022 (cmdline_parse_inst_t *)&cmd_dump_one,
13023 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13024 (cmdline_parse_inst_t *)&cmd_syn_filter,
13025 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13026 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13027 (cmdline_parse_inst_t *)&cmd_flex_filter,
13028 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13029 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13030 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13031 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13032 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13033 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13034 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13035 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13036 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13037 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13038 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13039 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13040 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13041 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13042 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13043 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13044 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13045 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13046 (cmdline_parse_inst_t *)&cmd_flow,
13047 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13048 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13049 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13050 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13051 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13052 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13053 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13054 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13055 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13056 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13057 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13058 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13059 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13060 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13061 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13062 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13063 #ifdef RTE_LIBRTE_IXGBE_PMD
13064 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13065 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13066 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13067 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13068 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13069 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13070 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13071 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13072 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13074 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13075 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13076 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13077 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13078 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13079 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13080 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13081 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13082 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13083 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13084 (cmdline_parse_inst_t *)&cmd_ddp_add,
13085 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13089 /* prompt function, called from main on MASTER lcore */
13093 /* initialize non-constant commands */
13094 cmd_set_fwd_mode_init();
13095 cmd_set_fwd_retry_mode_init();
13097 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13098 if (testpmd_cl == NULL)
13100 cmdline_interact(testpmd_cl);
13101 cmdline_stdin_exit(testpmd_cl);
13107 if (testpmd_cl != NULL)
13108 cmdline_quit(testpmd_cl);
13112 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13114 if (id == (portid_t)RTE_PORT_ALL) {
13117 FOREACH_PORT(pid, ports) {
13118 /* check if need_reconfig has been set to 1 */
13119 if (ports[pid].need_reconfig == 0)
13120 ports[pid].need_reconfig = dev;
13121 /* check if need_reconfig_queues has been set to 1 */
13122 if (ports[pid].need_reconfig_queues == 0)
13123 ports[pid].need_reconfig_queues = queue;
13125 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13126 /* check if need_reconfig has been set to 1 */
13127 if (ports[id].need_reconfig == 0)
13128 ports[id].need_reconfig = dev;
13129 /* check if need_reconfig_queues has been set to 1 */
13130 if (ports[id].need_reconfig_queues == 0)
13131 ports[id].need_reconfig_queues = queue;