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"
221 "show vf stats (port_id) (vf_id)\n"
222 " Display a VF's statistics.\n\n"
224 "clear vf stats (port_id) (vf_id)\n"
225 " Reset a VF's statistics.\n\n"
229 if (show_all || !strcmp(res->section, "config")) {
235 "Configuration changes only become active when"
236 " forwarding is started/restarted.\n\n"
239 " Reset forwarding to the default configuration.\n\n"
241 "set verbose (level)\n"
242 " Set the debug verbosity level X.\n\n"
245 " Set number of ports.\n\n"
248 " Set number of cores.\n\n"
250 "set coremask (mask)\n"
251 " Set the forwarding cores hexadecimal mask.\n\n"
253 "set portmask (mask)\n"
254 " Set the forwarding ports hexadecimal mask.\n\n"
257 " Set number of packets per burst.\n\n"
259 "set burst tx delay (microseconds) retry (num)\n"
260 " Set the transmit delay time and number of retries,"
261 " effective when retry is enabled.\n\n"
263 "set txpkts (x[,y]*)\n"
264 " Set the length of each segment of TXONLY"
265 " and optionally CSUM packets.\n\n"
267 "set txsplit (off|on|rand)\n"
268 " Set the split policy for the TX packets."
269 " Right now only applicable for CSUM and TXONLY"
272 "set corelist (x[,y]*)\n"
273 " Set the list of forwarding cores.\n\n"
275 "set portlist (x[,y]*)\n"
276 " Set the list of forwarding ports.\n\n"
278 "set tx loopback (port_id) (on|off)\n"
279 " Enable or disable tx loopback.\n\n"
281 #ifdef RTE_LIBRTE_IXGBE_PMD
282 "set all queues drop (port_id) (on|off)\n"
283 " Set drop enable bit for all queues.\n\n"
285 "set vf split drop (port_id) (vf_id) (on|off)\n"
286 " Set split drop enable bit for a VF from the PF.\n\n"
289 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
290 " Set MAC antispoof for a VF from the PF.\n\n"
292 #ifdef RTE_LIBRTE_IXGBE_PMD
293 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
294 " Enable MACsec offload.\n\n"
296 "set macsec offload (port_id) off\n"
297 " Disable MACsec offload.\n\n"
299 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
300 " Configure MACsec secure connection (SC).\n\n"
302 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
303 " Configure MACsec secure association (SA).\n\n"
306 "set vf broadcast (port_id) (vf_id) (on|off)\n"
307 " Set VF broadcast for a VF from the PF.\n\n"
309 "vlan set strip (on|off) (port_id)\n"
310 " Set the VLAN strip on a port.\n\n"
312 "vlan set stripq (on|off) (port_id,queue_id)\n"
313 " Set the VLAN strip for a queue on a port.\n\n"
315 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
316 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
318 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
319 " Set VLAN insert for a VF from the PF.\n\n"
321 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
322 " Set VLAN antispoof for a VF from the PF.\n\n"
324 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
325 " Set VLAN tag for a VF from the PF.\n\n"
327 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
328 " Set a VF's max bandwidth(Mbps).\n\n"
330 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
331 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
333 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
334 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
336 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
337 " Set some TCs' strict link priority mode on a physical port.\n\n"
339 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
340 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
342 "vlan set filter (on|off) (port_id)\n"
343 " Set the VLAN filter on a port.\n\n"
345 "vlan set qinq (on|off) (port_id)\n"
346 " Set the VLAN QinQ (extended queue in queue)"
349 "vlan set (inner|outer) tpid (value) (port_id)\n"
350 " Set the VLAN TPID for Packet Filtering on"
353 "rx_vlan add (vlan_id|all) (port_id)\n"
354 " Add a vlan_id, or all identifiers, to the set"
355 " of VLAN identifiers filtered by port_id.\n\n"
357 "rx_vlan rm (vlan_id|all) (port_id)\n"
358 " Remove a vlan_id, or all identifiers, from the set"
359 " of VLAN identifiers filtered by port_id.\n\n"
361 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
362 " Add a vlan_id, to the set of VLAN identifiers"
363 "filtered for VF(s) from port_id.\n\n"
365 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
366 " Remove a vlan_id, to the set of VLAN identifiers"
367 "filtered for VF(s) from port_id.\n\n"
369 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
370 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
371 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
372 " add a tunnel filter of a port.\n\n"
374 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
375 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
376 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
377 " remove a tunnel filter of a port.\n\n"
379 "rx_vxlan_port add (udp_port) (port_id)\n"
380 " Add an UDP port for VXLAN packet filter on a port\n\n"
382 "rx_vxlan_port rm (udp_port) (port_id)\n"
383 " Remove an UDP port for VXLAN packet filter on a port\n\n"
385 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
386 " Set hardware insertion of VLAN IDs (single or double VLAN "
387 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
389 "tx_vlan set pvid port_id vlan_id (on|off)\n"
390 " Set port based TX VLAN insertion.\n\n"
392 "tx_vlan reset (port_id)\n"
393 " Disable hardware insertion of a VLAN header in"
394 " packets sent on a port.\n\n"
396 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
397 " Select hardware or software calculation of the"
398 " checksum when transmitting a packet using the"
399 " csum forward engine.\n"
400 " ip|udp|tcp|sctp always concern the inner layer.\n"
401 " outer-ip concerns the outer IP layer in"
402 " case the packet is recognized as a tunnel packet by"
403 " the forward engine (vxlan, gre and ipip are supported)\n"
404 " Please check the NIC datasheet for HW limits.\n\n"
406 "csum parse-tunnel (on|off) (tx_port_id)\n"
407 " If disabled, treat tunnel packets as non-tunneled"
408 " packets (treat inner headers as payload). The port\n"
409 " argument is the port used for TX in csum forward"
412 "csum show (port_id)\n"
413 " Display tx checksum offload configuration\n\n"
415 "tso set (segsize) (portid)\n"
416 " Enable TCP Segmentation Offload in csum forward"
418 " Please check the NIC datasheet for HW limits.\n\n"
421 " Display the status of TCP Segmentation Offload.\n\n"
424 " Set packet forwarding mode.\n\n"
426 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
427 " Add a MAC address on port_id.\n\n"
429 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
430 " Remove a MAC address from port_id.\n\n"
432 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
433 " Set the default MAC address for port_id.\n\n"
435 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
436 " Add a MAC address for a VF on the port.\n\n"
438 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
439 " Set the MAC address for a VF from the PF.\n\n"
441 "set port (port_id) uta (mac_address|all) (on|off)\n"
442 " Add/Remove a or all unicast hash filter(s)"
445 "set promisc (port_id|all) (on|off)\n"
446 " Set the promiscuous mode on port_id, or all.\n\n"
448 "set allmulti (port_id|all) (on|off)\n"
449 " Set the allmulti mode on port_id, or all.\n\n"
451 "set vf promisc (port_id) (vf_id) (on|off)\n"
452 " Set unicast promiscuous mode for a VF from the PF.\n\n"
454 "set vf allmulti (port_id) (vf_id) (on|off)\n"
455 " Set multicast promiscuous mode for a VF from the PF.\n\n"
457 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
458 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
459 " (on|off) autoneg (on|off) (port_id)\n"
460 "set flow_ctrl rx (on|off) (portid)\n"
461 "set flow_ctrl tx (on|off) (portid)\n"
462 "set flow_ctrl high_water (high_water) (portid)\n"
463 "set flow_ctrl low_water (low_water) (portid)\n"
464 "set flow_ctrl pause_time (pause_time) (portid)\n"
465 "set flow_ctrl send_xon (send_xon) (portid)\n"
466 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
467 "set flow_ctrl autoneg (on|off) (port_id)\n"
468 " Set the link flow control parameter on a port.\n\n"
470 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
471 " (low_water) (pause_time) (priority) (port_id)\n"
472 " Set the priority flow control parameter on a"
475 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
476 " Set statistics mapping (qmapping 0..15) for RX/TX"
478 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
479 " on port 0 to mapping 5.\n\n"
481 "set port (port_id) vf (vf_id) rx|tx on|off\n"
482 " Enable/Disable a VF receive/tranmit from a port\n\n"
484 "set port (port_id) vf (vf_id) (mac_addr)"
485 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
486 " Add/Remove unicast or multicast MAC addr filter"
489 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
491 " AUPE:accepts untagged VLAN;"
492 "ROPE:accept unicast hash\n\n"
493 " BAM:accepts broadcast packets;"
494 "MPE:accepts all multicast packets\n\n"
495 " Enable/Disable a VF receive mode of a port\n\n"
497 "set port (port_id) queue (queue_id) rate (rate_num)\n"
498 " Set rate limit for a queue of a port\n\n"
500 "set port (port_id) vf (vf_id) rate (rate_num) "
501 "queue_mask (queue_mask_value)\n"
502 " Set rate limit for queues in VF of a port\n\n"
504 "set port (port_id) mirror-rule (rule_id)"
505 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
506 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
507 " Set pool or vlan type mirror rule on a port.\n"
508 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
509 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
512 "set port (port_id) mirror-rule (rule_id)"
513 " (uplink-mirror|downlink-mirror) dst-pool"
514 " (pool_id) (on|off)\n"
515 " Set uplink or downlink type mirror rule on a port.\n"
516 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
517 " 0 on' enable mirror income traffic to pool 0.\n\n"
519 "reset port (port_id) mirror-rule (rule_id)\n"
520 " Reset a mirror rule.\n\n"
522 "set flush_rx (on|off)\n"
523 " Flush (default) or don't flush RX streams before"
524 " forwarding. Mainly used with PCAP drivers.\n\n"
526 #ifdef RTE_NIC_BYPASS
527 "set bypass mode (normal|bypass|isolate) (port_id)\n"
528 " Set the bypass mode for the lowest port on bypass enabled"
531 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
532 "mode (normal|bypass|isolate) (port_id)\n"
533 " Set the event required to initiate specified bypass mode for"
534 " the lowest port on a bypass enabled NIC where:\n"
535 " timeout = enable bypass after watchdog timeout.\n"
536 " os_on = enable bypass when OS/board is powered on.\n"
537 " os_off = enable bypass when OS/board is powered off.\n"
538 " power_on = enable bypass when power supply is turned on.\n"
539 " power_off = enable bypass when power supply is turned off."
542 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
543 " Set the bypass watchdog timeout to 'n' seconds"
544 " where 0 = instant.\n\n"
546 "show bypass config (port_id)\n"
547 " Show the bypass configuration for a bypass enabled NIC"
548 " using the lowest port on the NIC.\n\n"
550 #ifdef RTE_LIBRTE_PMD_BOND
551 "create bonded device (mode) (socket)\n"
552 " Create a new bonded device with specific bonding mode and socket.\n\n"
554 "add bonding slave (slave_id) (port_id)\n"
555 " Add a slave device to a bonded device.\n\n"
557 "remove bonding slave (slave_id) (port_id)\n"
558 " Remove a slave device from a bonded device.\n\n"
560 "set bonding mode (value) (port_id)\n"
561 " Set the bonding mode on a bonded device.\n\n"
563 "set bonding primary (slave_id) (port_id)\n"
564 " Set the primary slave for a bonded device.\n\n"
566 "show bonding config (port_id)\n"
567 " Show the bonding config for port_id.\n\n"
569 "set bonding mac_addr (port_id) (address)\n"
570 " Set the MAC address of a bonded device.\n\n"
572 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
573 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
575 "set bonding mon_period (port_id) (value)\n"
576 " Set the bonding link status monitoring polling period in ms.\n\n"
578 "set link-up port (port_id)\n"
579 " Set link up for a port.\n\n"
581 "set link-down port (port_id)\n"
582 " Set link down for a port.\n\n"
584 "E-tag set insertion on port-tag-id (value)"
585 " port (port_id) vf (vf_id)\n"
586 " Enable E-tag insertion for a VF on a port\n\n"
588 "E-tag set insertion off port (port_id) vf (vf_id)\n"
589 " Disable E-tag insertion for a VF on a port\n\n"
591 "E-tag set stripping (on|off) port (port_id)\n"
592 " Enable/disable E-tag stripping on a port\n\n"
594 "E-tag set forwarding (on|off) port (port_id)\n"
595 " Enable/disable E-tag based forwarding"
598 "E-tag set filter add e-tag-id (value) dst-pool"
599 " (pool_id) port (port_id)\n"
600 " Add an E-tag forwarding filter on a port\n\n"
602 "E-tag set filter del e-tag-id (value) port (port_id)\n"
603 " Delete an E-tag forwarding filter on a port\n\n"
605 "ddp add (port_id) (profile_path)\n"
606 " Load a profile package on a port\n\n"
608 , list_pkt_forwarding_modes()
612 if (show_all || !strcmp(res->section, "ports")) {
618 "----------------\n\n"
620 "port start (port_id|all)\n"
621 " Start all ports or port_id.\n\n"
623 "port stop (port_id|all)\n"
624 " Stop all ports or port_id.\n\n"
626 "port close (port_id|all)\n"
627 " Close all ports or port_id.\n\n"
629 "port attach (ident)\n"
630 " Attach physical or virtual dev by pci address or virtual device name\n\n"
632 "port detach (port_id)\n"
633 " Detach physical or virtual dev by port_id\n\n"
635 "port config (port_id|all)"
636 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
637 " duplex (half|full|auto)\n"
638 " Set speed and duplex for all ports or port_id\n\n"
640 "port config all (rxq|txq|rxd|txd) (value)\n"
641 " Set number for rxq/txq/rxd/txd.\n\n"
643 "port config all max-pkt-len (value)\n"
644 " Set the max packet length.\n\n"
646 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
647 "hw-vlan-strip|hw-vlan-extend|drop-en)"
649 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
652 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
653 " Set the RSS mode.\n\n"
655 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
656 " Set the RSS redirection table.\n\n"
658 "port config (port_id) dcb vt (on|off) (traffic_class)"
660 " Set the DCB mode.\n\n"
662 "port config all burst (value)\n"
663 " Set the number of packets per burst.\n\n"
665 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
667 " Set the ring prefetch/host/writeback threshold"
668 " for tx/rx queue.\n\n"
670 "port config all (txfreet|txrst|rxfreet) (value)\n"
671 " Set free threshold for rx/tx, or set"
672 " tx rs bit threshold.\n\n"
673 "port config mtu X value\n"
674 " Set the MTU of port X to a given value\n\n"
676 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
677 " Start/stop a rx/tx queue of port X. Only take effect"
678 " when port X is started\n\n"
680 "port config (port_id|all) l2-tunnel E-tag ether-type"
682 " Set the value of E-tag ether-type.\n\n"
684 "port config (port_id|all) l2-tunnel E-tag"
685 " (enable|disable)\n"
686 " Enable/disable the E-tag support.\n\n"
690 if (show_all || !strcmp(res->section, "registers")) {
698 "read reg (port_id) (address)\n"
699 " Display value of a port register.\n\n"
701 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
702 " Display a port register bit field.\n\n"
704 "read regbit (port_id) (address) (bit_x)\n"
705 " Display a single port register bit.\n\n"
707 "write reg (port_id) (address) (value)\n"
708 " Set value of a port register.\n\n"
710 "write regfield (port_id) (address) (bit_x) (bit_y)"
712 " Set bit field of a port register.\n\n"
714 "write regbit (port_id) (address) (bit_x) (value)\n"
715 " Set single bit value of a port register.\n\n"
718 if (show_all || !strcmp(res->section, "filters")) {
726 "ethertype_filter (port_id) (add|del)"
727 " (mac_addr|mac_ignr) (mac_address) ethertype"
728 " (ether_type) (drop|fwd) queue (queue_id)\n"
729 " Add/Del an ethertype filter.\n\n"
731 "2tuple_filter (port_id) (add|del)"
732 " dst_port (dst_port_value) protocol (protocol_value)"
733 " mask (mask_value) tcp_flags (tcp_flags_value)"
734 " priority (prio_value) queue (queue_id)\n"
735 " Add/Del a 2tuple filter.\n\n"
737 "5tuple_filter (port_id) (add|del)"
738 " dst_ip (dst_address) src_ip (src_address)"
739 " dst_port (dst_port_value) src_port (src_port_value)"
740 " protocol (protocol_value)"
741 " mask (mask_value) tcp_flags (tcp_flags_value)"
742 " priority (prio_value) queue (queue_id)\n"
743 " Add/Del a 5tuple filter.\n\n"
745 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
746 " Add/Del syn filter.\n\n"
748 "flex_filter (port_id) (add|del) len (len_value)"
749 " bytes (bytes_value) mask (mask_value)"
750 " priority (prio_value) queue (queue_id)\n"
751 " Add/Del a flex filter.\n\n"
753 "flow_director_filter (port_id) mode IP (add|del|update)"
754 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
755 " src (src_ip_address) dst (dst_ip_address)"
756 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
757 " vlan (vlan_value) flexbytes (flexbytes_value)"
758 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
759 " fd_id (fd_id_value)\n"
760 " Add/Del an IP type flow director filter.\n\n"
762 "flow_director_filter (port_id) mode IP (add|del|update)"
763 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
764 " src (src_ip_address) (src_port)"
765 " dst (dst_ip_address) (dst_port)"
766 " tos (tos_value) ttl (ttl_value)"
767 " vlan (vlan_value) flexbytes (flexbytes_value)"
768 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
769 " fd_id (fd_id_value)\n"
770 " Add/Del an UDP/TCP type flow director filter.\n\n"
772 "flow_director_filter (port_id) mode IP (add|del|update)"
773 " flow (ipv4-sctp|ipv6-sctp)"
774 " src (src_ip_address) (src_port)"
775 " dst (dst_ip_address) (dst_port)"
776 " tag (verification_tag) "
777 " tos (tos_value) ttl (ttl_value)"
779 " flexbytes (flexbytes_value) (drop|fwd)"
780 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
781 " Add/Del a SCTP type flow director filter.\n\n"
783 "flow_director_filter (port_id) mode IP (add|del|update)"
784 " flow l2_payload ether (ethertype)"
785 " flexbytes (flexbytes_value) (drop|fwd)"
786 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
787 " Add/Del a l2 payload type flow director filter.\n\n"
789 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
790 " mac (mac_address) vlan (vlan_value)"
791 " flexbytes (flexbytes_value) (drop|fwd)"
792 " queue (queue_id) fd_id (fd_id_value)\n"
793 " Add/Del a MAC-VLAN flow director filter.\n\n"
795 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
796 " mac (mac_address) vlan (vlan_value)"
797 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
798 " flexbytes (flexbytes_value) (drop|fwd)"
799 " queue (queue_id) fd_id (fd_id_value)\n"
800 " Add/Del a Tunnel flow director filter.\n\n"
802 "flush_flow_director (port_id)\n"
803 " Flush all flow director entries of a device.\n\n"
805 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
806 " src_mask (ipv4_src) (ipv6_src) (src_port)"
807 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
808 " Set flow director IP mask.\n\n"
810 "flow_director_mask (port_id) mode MAC-VLAN"
811 " vlan (vlan_value)\n"
812 " Set flow director MAC-VLAN mask.\n\n"
814 "flow_director_mask (port_id) mode Tunnel"
815 " vlan (vlan_value) mac (mac_value)"
816 " tunnel-type (tunnel_type_value)"
817 " tunnel-id (tunnel_id_value)\n"
818 " Set flow director Tunnel mask.\n\n"
820 "flow_director_flex_mask (port_id)"
821 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
822 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
824 " Configure mask of flex payload.\n\n"
826 "flow_director_flex_payload (port_id)"
827 " (raw|l2|l3|l4) (config)\n"
828 " Configure flex payload selection.\n\n"
830 "get_sym_hash_ena_per_port (port_id)\n"
831 " get symmetric hash enable configuration per port.\n\n"
833 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
834 " set symmetric hash enable configuration per port"
835 " to enable or disable.\n\n"
837 "get_hash_global_config (port_id)\n"
838 " Get the global configurations of hash filters.\n\n"
840 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
841 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
842 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
843 " (enable|disable)\n"
844 " Set the global configurations of hash filters.\n\n"
846 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
847 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
848 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
849 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
850 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
851 "ipv6-next-header|udp-src-port|udp-dst-port|"
852 "tcp-src-port|tcp-dst-port|sctp-src-port|"
853 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
854 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
855 "fld-8th|none) (select|add)\n"
856 " Set the input set for hash.\n\n"
858 "set_fdir_input_set (port_id) "
859 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
860 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
861 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
862 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
863 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
864 "udp-dst-port|tcp-src-port|tcp-dst-port|"
865 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
867 " Set the input set for FDir.\n\n"
869 "flow validate {port_id}"
870 " [group {group_id}] [priority {level}]"
871 " [ingress] [egress]"
872 " pattern {item} [/ {item} [...]] / end"
873 " actions {action} [/ {action} [...]] / end\n"
874 " Check whether a flow rule can be created.\n\n"
876 "flow create {port_id}"
877 " [group {group_id}] [priority {level}]"
878 " [ingress] [egress]"
879 " pattern {item} [/ {item} [...]] / end"
880 " actions {action} [/ {action} [...]] / end\n"
881 " Create a flow rule.\n\n"
883 "flow destroy {port_id} rule {rule_id} [...]\n"
884 " Destroy specific flow rules.\n\n"
886 "flow flush {port_id}\n"
887 " Destroy all flow rules.\n\n"
889 "flow query {port_id} {rule_id} {action}\n"
890 " Query an existing flow rule.\n\n"
892 "flow list {port_id} [group {group_id}] [...]\n"
893 " List existing flow rules sorted by priority,"
894 " filtered by group identifiers.\n\n"
899 cmdline_parse_token_string_t cmd_help_long_help =
900 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
902 cmdline_parse_token_string_t cmd_help_long_section =
903 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
904 "all#control#display#config#"
905 "ports#registers#filters");
907 cmdline_parse_inst_t cmd_help_long = {
908 .f = cmd_help_long_parsed,
910 .help_str = "help all|control|display|config|ports|register|filters: "
913 (void *)&cmd_help_long_help,
914 (void *)&cmd_help_long_section,
920 /* *** start/stop/close all ports *** */
921 struct cmd_operate_port_result {
922 cmdline_fixed_string_t keyword;
923 cmdline_fixed_string_t name;
924 cmdline_fixed_string_t value;
927 static void cmd_operate_port_parsed(void *parsed_result,
928 __attribute__((unused)) struct cmdline *cl,
929 __attribute__((unused)) void *data)
931 struct cmd_operate_port_result *res = parsed_result;
933 if (!strcmp(res->name, "start"))
934 start_port(RTE_PORT_ALL);
935 else if (!strcmp(res->name, "stop"))
936 stop_port(RTE_PORT_ALL);
937 else if (!strcmp(res->name, "close"))
938 close_port(RTE_PORT_ALL);
940 printf("Unknown parameter\n");
943 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
944 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
946 cmdline_parse_token_string_t cmd_operate_port_all_port =
947 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
949 cmdline_parse_token_string_t cmd_operate_port_all_all =
950 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
952 cmdline_parse_inst_t cmd_operate_port = {
953 .f = cmd_operate_port_parsed,
955 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
957 (void *)&cmd_operate_port_all_cmd,
958 (void *)&cmd_operate_port_all_port,
959 (void *)&cmd_operate_port_all_all,
964 /* *** start/stop/close specific port *** */
965 struct cmd_operate_specific_port_result {
966 cmdline_fixed_string_t keyword;
967 cmdline_fixed_string_t name;
971 static void cmd_operate_specific_port_parsed(void *parsed_result,
972 __attribute__((unused)) struct cmdline *cl,
973 __attribute__((unused)) void *data)
975 struct cmd_operate_specific_port_result *res = parsed_result;
977 if (!strcmp(res->name, "start"))
978 start_port(res->value);
979 else if (!strcmp(res->name, "stop"))
980 stop_port(res->value);
981 else if (!strcmp(res->name, "close"))
982 close_port(res->value);
984 printf("Unknown parameter\n");
987 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
988 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
990 cmdline_parse_token_string_t cmd_operate_specific_port_port =
991 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
992 name, "start#stop#close");
993 cmdline_parse_token_num_t cmd_operate_specific_port_id =
994 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
997 cmdline_parse_inst_t cmd_operate_specific_port = {
998 .f = cmd_operate_specific_port_parsed,
1000 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1002 (void *)&cmd_operate_specific_port_cmd,
1003 (void *)&cmd_operate_specific_port_port,
1004 (void *)&cmd_operate_specific_port_id,
1009 /* *** attach a specified port *** */
1010 struct cmd_operate_attach_port_result {
1011 cmdline_fixed_string_t port;
1012 cmdline_fixed_string_t keyword;
1013 cmdline_fixed_string_t identifier;
1016 static void cmd_operate_attach_port_parsed(void *parsed_result,
1017 __attribute__((unused)) struct cmdline *cl,
1018 __attribute__((unused)) void *data)
1020 struct cmd_operate_attach_port_result *res = parsed_result;
1022 if (!strcmp(res->keyword, "attach"))
1023 attach_port(res->identifier);
1025 printf("Unknown parameter\n");
1028 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1029 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1031 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1032 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1034 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1035 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1038 cmdline_parse_inst_t cmd_operate_attach_port = {
1039 .f = cmd_operate_attach_port_parsed,
1041 .help_str = "port attach <identifier>: "
1042 "(identifier: pci address or virtual dev name)",
1044 (void *)&cmd_operate_attach_port_port,
1045 (void *)&cmd_operate_attach_port_keyword,
1046 (void *)&cmd_operate_attach_port_identifier,
1051 /* *** detach a specified port *** */
1052 struct cmd_operate_detach_port_result {
1053 cmdline_fixed_string_t port;
1054 cmdline_fixed_string_t keyword;
1058 static void cmd_operate_detach_port_parsed(void *parsed_result,
1059 __attribute__((unused)) struct cmdline *cl,
1060 __attribute__((unused)) void *data)
1062 struct cmd_operate_detach_port_result *res = parsed_result;
1064 if (!strcmp(res->keyword, "detach"))
1065 detach_port(res->port_id);
1067 printf("Unknown parameter\n");
1070 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1071 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1073 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1074 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1076 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1077 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1080 cmdline_parse_inst_t cmd_operate_detach_port = {
1081 .f = cmd_operate_detach_port_parsed,
1083 .help_str = "port detach <port_id>",
1085 (void *)&cmd_operate_detach_port_port,
1086 (void *)&cmd_operate_detach_port_keyword,
1087 (void *)&cmd_operate_detach_port_port_id,
1092 /* *** configure speed for all ports *** */
1093 struct cmd_config_speed_all {
1094 cmdline_fixed_string_t port;
1095 cmdline_fixed_string_t keyword;
1096 cmdline_fixed_string_t all;
1097 cmdline_fixed_string_t item1;
1098 cmdline_fixed_string_t item2;
1099 cmdline_fixed_string_t value1;
1100 cmdline_fixed_string_t value2;
1104 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1109 if (!strcmp(duplexstr, "half")) {
1110 duplex = ETH_LINK_HALF_DUPLEX;
1111 } else if (!strcmp(duplexstr, "full")) {
1112 duplex = ETH_LINK_FULL_DUPLEX;
1113 } else if (!strcmp(duplexstr, "auto")) {
1114 duplex = ETH_LINK_FULL_DUPLEX;
1116 printf("Unknown duplex parameter\n");
1120 if (!strcmp(speedstr, "10")) {
1121 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1122 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1123 } else if (!strcmp(speedstr, "100")) {
1124 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1125 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1127 if (duplex != ETH_LINK_FULL_DUPLEX) {
1128 printf("Invalid speed/duplex parameters\n");
1131 if (!strcmp(speedstr, "1000")) {
1132 *speed = ETH_LINK_SPEED_1G;
1133 } else if (!strcmp(speedstr, "10000")) {
1134 *speed = ETH_LINK_SPEED_10G;
1135 } else if (!strcmp(speedstr, "25000")) {
1136 *speed = ETH_LINK_SPEED_25G;
1137 } else if (!strcmp(speedstr, "40000")) {
1138 *speed = ETH_LINK_SPEED_40G;
1139 } else if (!strcmp(speedstr, "50000")) {
1140 *speed = ETH_LINK_SPEED_50G;
1141 } else if (!strcmp(speedstr, "100000")) {
1142 *speed = ETH_LINK_SPEED_100G;
1143 } else if (!strcmp(speedstr, "auto")) {
1144 *speed = ETH_LINK_SPEED_AUTONEG;
1146 printf("Unknown speed parameter\n");
1155 cmd_config_speed_all_parsed(void *parsed_result,
1156 __attribute__((unused)) struct cmdline *cl,
1157 __attribute__((unused)) void *data)
1159 struct cmd_config_speed_all *res = parsed_result;
1160 uint32_t link_speed;
1163 if (!all_ports_stopped()) {
1164 printf("Please stop all ports first\n");
1168 if (parse_and_check_speed_duplex(res->value1, res->value2,
1172 RTE_ETH_FOREACH_DEV(pid) {
1173 ports[pid].dev_conf.link_speeds = link_speed;
1176 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1179 cmdline_parse_token_string_t cmd_config_speed_all_port =
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1181 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1182 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1184 cmdline_parse_token_string_t cmd_config_speed_all_all =
1185 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1186 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1187 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1188 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1189 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1190 "10#100#1000#10000#25000#40000#50000#100000#auto");
1191 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1192 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1193 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1194 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1197 cmdline_parse_inst_t cmd_config_speed_all = {
1198 .f = cmd_config_speed_all_parsed,
1200 .help_str = "port config all speed "
1201 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1204 (void *)&cmd_config_speed_all_port,
1205 (void *)&cmd_config_speed_all_keyword,
1206 (void *)&cmd_config_speed_all_all,
1207 (void *)&cmd_config_speed_all_item1,
1208 (void *)&cmd_config_speed_all_value1,
1209 (void *)&cmd_config_speed_all_item2,
1210 (void *)&cmd_config_speed_all_value2,
1215 /* *** configure speed for specific port *** */
1216 struct cmd_config_speed_specific {
1217 cmdline_fixed_string_t port;
1218 cmdline_fixed_string_t keyword;
1220 cmdline_fixed_string_t item1;
1221 cmdline_fixed_string_t item2;
1222 cmdline_fixed_string_t value1;
1223 cmdline_fixed_string_t value2;
1227 cmd_config_speed_specific_parsed(void *parsed_result,
1228 __attribute__((unused)) struct cmdline *cl,
1229 __attribute__((unused)) void *data)
1231 struct cmd_config_speed_specific *res = parsed_result;
1232 uint32_t link_speed;
1234 if (!all_ports_stopped()) {
1235 printf("Please stop all ports first\n");
1239 if (port_id_is_invalid(res->id, ENABLED_WARN))
1242 if (parse_and_check_speed_duplex(res->value1, res->value2,
1246 ports[res->id].dev_conf.link_speeds = link_speed;
1248 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1252 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1253 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1255 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1256 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1258 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1259 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1260 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1261 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1263 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1264 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1265 "10#100#1000#10000#25000#40000#50000#100000#auto");
1266 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1267 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1269 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1270 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1273 cmdline_parse_inst_t cmd_config_speed_specific = {
1274 .f = cmd_config_speed_specific_parsed,
1276 .help_str = "port config <port_id> speed "
1277 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1280 (void *)&cmd_config_speed_specific_port,
1281 (void *)&cmd_config_speed_specific_keyword,
1282 (void *)&cmd_config_speed_specific_id,
1283 (void *)&cmd_config_speed_specific_item1,
1284 (void *)&cmd_config_speed_specific_value1,
1285 (void *)&cmd_config_speed_specific_item2,
1286 (void *)&cmd_config_speed_specific_value2,
1291 /* *** configure txq/rxq, txd/rxd *** */
1292 struct cmd_config_rx_tx {
1293 cmdline_fixed_string_t port;
1294 cmdline_fixed_string_t keyword;
1295 cmdline_fixed_string_t all;
1296 cmdline_fixed_string_t name;
1301 cmd_config_rx_tx_parsed(void *parsed_result,
1302 __attribute__((unused)) struct cmdline *cl,
1303 __attribute__((unused)) void *data)
1305 struct cmd_config_rx_tx *res = parsed_result;
1307 if (!all_ports_stopped()) {
1308 printf("Please stop all ports first\n");
1311 if (!strcmp(res->name, "rxq")) {
1312 if (!res->value && !nb_txq) {
1313 printf("Warning: Either rx or tx queues should be non zero\n");
1316 nb_rxq = res->value;
1318 else if (!strcmp(res->name, "txq")) {
1319 if (!res->value && !nb_rxq) {
1320 printf("Warning: Either rx or tx queues should be non zero\n");
1323 nb_txq = res->value;
1325 else if (!strcmp(res->name, "rxd")) {
1326 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1327 printf("rxd %d invalid - must be > 0 && <= %d\n",
1328 res->value, RTE_TEST_RX_DESC_MAX);
1331 nb_rxd = res->value;
1332 } else if (!strcmp(res->name, "txd")) {
1333 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1334 printf("txd %d invalid - must be > 0 && <= %d\n",
1335 res->value, RTE_TEST_TX_DESC_MAX);
1338 nb_txd = res->value;
1340 printf("Unknown parameter\n");
1348 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1351 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1352 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1353 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1355 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1356 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1357 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1358 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1360 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1361 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1363 cmdline_parse_inst_t cmd_config_rx_tx = {
1364 .f = cmd_config_rx_tx_parsed,
1366 .help_str = "port config all rxq|txq|rxd|txd <value>",
1368 (void *)&cmd_config_rx_tx_port,
1369 (void *)&cmd_config_rx_tx_keyword,
1370 (void *)&cmd_config_rx_tx_all,
1371 (void *)&cmd_config_rx_tx_name,
1372 (void *)&cmd_config_rx_tx_value,
1377 /* *** config max packet length *** */
1378 struct cmd_config_max_pkt_len_result {
1379 cmdline_fixed_string_t port;
1380 cmdline_fixed_string_t keyword;
1381 cmdline_fixed_string_t all;
1382 cmdline_fixed_string_t name;
1387 cmd_config_max_pkt_len_parsed(void *parsed_result,
1388 __attribute__((unused)) struct cmdline *cl,
1389 __attribute__((unused)) void *data)
1391 struct cmd_config_max_pkt_len_result *res = parsed_result;
1393 if (!all_ports_stopped()) {
1394 printf("Please stop all ports first\n");
1398 if (!strcmp(res->name, "max-pkt-len")) {
1399 if (res->value < ETHER_MIN_LEN) {
1400 printf("max-pkt-len can not be less than %d\n",
1404 if (res->value == rx_mode.max_rx_pkt_len)
1407 rx_mode.max_rx_pkt_len = res->value;
1408 if (res->value > ETHER_MAX_LEN)
1409 rx_mode.jumbo_frame = 1;
1411 rx_mode.jumbo_frame = 0;
1413 printf("Unknown parameter\n");
1419 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1422 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1425 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1428 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1429 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1431 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1432 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1434 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1435 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1438 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1439 .f = cmd_config_max_pkt_len_parsed,
1441 .help_str = "port config all max-pkt-len <value>",
1443 (void *)&cmd_config_max_pkt_len_port,
1444 (void *)&cmd_config_max_pkt_len_keyword,
1445 (void *)&cmd_config_max_pkt_len_all,
1446 (void *)&cmd_config_max_pkt_len_name,
1447 (void *)&cmd_config_max_pkt_len_value,
1452 /* *** configure port MTU *** */
1453 struct cmd_config_mtu_result {
1454 cmdline_fixed_string_t port;
1455 cmdline_fixed_string_t keyword;
1456 cmdline_fixed_string_t mtu;
1462 cmd_config_mtu_parsed(void *parsed_result,
1463 __attribute__((unused)) struct cmdline *cl,
1464 __attribute__((unused)) void *data)
1466 struct cmd_config_mtu_result *res = parsed_result;
1468 if (res->value < ETHER_MIN_LEN) {
1469 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1472 port_mtu_set(res->port_id, res->value);
1475 cmdline_parse_token_string_t cmd_config_mtu_port =
1476 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1478 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1479 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1481 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1482 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1484 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1485 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1486 cmdline_parse_token_num_t cmd_config_mtu_value =
1487 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1489 cmdline_parse_inst_t cmd_config_mtu = {
1490 .f = cmd_config_mtu_parsed,
1492 .help_str = "port config mtu <port_id> <value>",
1494 (void *)&cmd_config_mtu_port,
1495 (void *)&cmd_config_mtu_keyword,
1496 (void *)&cmd_config_mtu_mtu,
1497 (void *)&cmd_config_mtu_port_id,
1498 (void *)&cmd_config_mtu_value,
1503 /* *** configure rx mode *** */
1504 struct cmd_config_rx_mode_flag {
1505 cmdline_fixed_string_t port;
1506 cmdline_fixed_string_t keyword;
1507 cmdline_fixed_string_t all;
1508 cmdline_fixed_string_t name;
1509 cmdline_fixed_string_t value;
1513 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1514 __attribute__((unused)) struct cmdline *cl,
1515 __attribute__((unused)) void *data)
1517 struct cmd_config_rx_mode_flag *res = parsed_result;
1519 if (!all_ports_stopped()) {
1520 printf("Please stop all ports first\n");
1524 if (!strcmp(res->name, "crc-strip")) {
1525 if (!strcmp(res->value, "on"))
1526 rx_mode.hw_strip_crc = 1;
1527 else if (!strcmp(res->value, "off"))
1528 rx_mode.hw_strip_crc = 0;
1530 printf("Unknown parameter\n");
1533 } else if (!strcmp(res->name, "scatter")) {
1534 if (!strcmp(res->value, "on"))
1535 rx_mode.enable_scatter = 1;
1536 else if (!strcmp(res->value, "off"))
1537 rx_mode.enable_scatter = 0;
1539 printf("Unknown parameter\n");
1542 } else if (!strcmp(res->name, "rx-cksum")) {
1543 if (!strcmp(res->value, "on"))
1544 rx_mode.hw_ip_checksum = 1;
1545 else if (!strcmp(res->value, "off"))
1546 rx_mode.hw_ip_checksum = 0;
1548 printf("Unknown parameter\n");
1551 } else if (!strcmp(res->name, "hw-vlan")) {
1552 if (!strcmp(res->value, "on")) {
1553 rx_mode.hw_vlan_filter = 1;
1554 rx_mode.hw_vlan_strip = 1;
1556 else if (!strcmp(res->value, "off")) {
1557 rx_mode.hw_vlan_filter = 0;
1558 rx_mode.hw_vlan_strip = 0;
1561 printf("Unknown parameter\n");
1564 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1565 if (!strcmp(res->value, "on"))
1566 rx_mode.hw_vlan_filter = 1;
1567 else if (!strcmp(res->value, "off"))
1568 rx_mode.hw_vlan_filter = 0;
1570 printf("Unknown parameter\n");
1573 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1574 if (!strcmp(res->value, "on"))
1575 rx_mode.hw_vlan_strip = 1;
1576 else if (!strcmp(res->value, "off"))
1577 rx_mode.hw_vlan_strip = 0;
1579 printf("Unknown parameter\n");
1582 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1583 if (!strcmp(res->value, "on"))
1584 rx_mode.hw_vlan_extend = 1;
1585 else if (!strcmp(res->value, "off"))
1586 rx_mode.hw_vlan_extend = 0;
1588 printf("Unknown parameter\n");
1591 } else if (!strcmp(res->name, "drop-en")) {
1592 if (!strcmp(res->value, "on"))
1594 else if (!strcmp(res->value, "off"))
1597 printf("Unknown parameter\n");
1601 printf("Unknown parameter\n");
1607 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1610 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1611 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1612 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1613 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1615 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1616 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1617 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1618 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1619 "crc-strip#scatter#rx-cksum#hw-vlan#"
1620 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1621 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1625 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1626 .f = cmd_config_rx_mode_flag_parsed,
1628 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1629 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1631 (void *)&cmd_config_rx_mode_flag_port,
1632 (void *)&cmd_config_rx_mode_flag_keyword,
1633 (void *)&cmd_config_rx_mode_flag_all,
1634 (void *)&cmd_config_rx_mode_flag_name,
1635 (void *)&cmd_config_rx_mode_flag_value,
1640 /* *** configure rss *** */
1641 struct cmd_config_rss {
1642 cmdline_fixed_string_t port;
1643 cmdline_fixed_string_t keyword;
1644 cmdline_fixed_string_t all;
1645 cmdline_fixed_string_t name;
1646 cmdline_fixed_string_t value;
1650 cmd_config_rss_parsed(void *parsed_result,
1651 __attribute__((unused)) struct cmdline *cl,
1652 __attribute__((unused)) void *data)
1654 struct cmd_config_rss *res = parsed_result;
1655 struct rte_eth_rss_conf rss_conf;
1659 if (!strcmp(res->value, "all"))
1660 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1661 ETH_RSS_UDP | ETH_RSS_SCTP |
1663 else if (!strcmp(res->value, "ip"))
1664 rss_conf.rss_hf = ETH_RSS_IP;
1665 else if (!strcmp(res->value, "udp"))
1666 rss_conf.rss_hf = ETH_RSS_UDP;
1667 else if (!strcmp(res->value, "tcp"))
1668 rss_conf.rss_hf = ETH_RSS_TCP;
1669 else if (!strcmp(res->value, "sctp"))
1670 rss_conf.rss_hf = ETH_RSS_SCTP;
1671 else if (!strcmp(res->value, "ether"))
1672 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1673 else if (!strcmp(res->value, "port"))
1674 rss_conf.rss_hf = ETH_RSS_PORT;
1675 else if (!strcmp(res->value, "vxlan"))
1676 rss_conf.rss_hf = ETH_RSS_VXLAN;
1677 else if (!strcmp(res->value, "geneve"))
1678 rss_conf.rss_hf = ETH_RSS_GENEVE;
1679 else if (!strcmp(res->value, "nvgre"))
1680 rss_conf.rss_hf = ETH_RSS_NVGRE;
1681 else if (!strcmp(res->value, "none"))
1682 rss_conf.rss_hf = 0;
1684 printf("Unknown parameter\n");
1687 rss_conf.rss_key = NULL;
1688 for (i = 0; i < rte_eth_dev_count(); i++) {
1689 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1691 printf("Configuration of RSS hash at ethernet port %d "
1692 "failed with error (%d): %s.\n",
1693 i, -diag, strerror(-diag));
1697 cmdline_parse_token_string_t cmd_config_rss_port =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1699 cmdline_parse_token_string_t cmd_config_rss_keyword =
1700 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1701 cmdline_parse_token_string_t cmd_config_rss_all =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1703 cmdline_parse_token_string_t cmd_config_rss_name =
1704 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1705 cmdline_parse_token_string_t cmd_config_rss_value =
1706 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1707 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1709 cmdline_parse_inst_t cmd_config_rss = {
1710 .f = cmd_config_rss_parsed,
1712 .help_str = "port config all rss "
1713 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1715 (void *)&cmd_config_rss_port,
1716 (void *)&cmd_config_rss_keyword,
1717 (void *)&cmd_config_rss_all,
1718 (void *)&cmd_config_rss_name,
1719 (void *)&cmd_config_rss_value,
1724 /* *** configure rss hash key *** */
1725 struct cmd_config_rss_hash_key {
1726 cmdline_fixed_string_t port;
1727 cmdline_fixed_string_t config;
1729 cmdline_fixed_string_t rss_hash_key;
1730 cmdline_fixed_string_t rss_type;
1731 cmdline_fixed_string_t key;
1735 hexa_digit_to_value(char hexa_digit)
1737 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1738 return (uint8_t) (hexa_digit - '0');
1739 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1740 return (uint8_t) ((hexa_digit - 'a') + 10);
1741 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1742 return (uint8_t) ((hexa_digit - 'A') + 10);
1743 /* Invalid hexa digit */
1748 parse_and_check_key_hexa_digit(char *key, int idx)
1752 hexa_v = hexa_digit_to_value(key[idx]);
1754 printf("invalid key: character %c at position %d is not a "
1755 "valid hexa digit\n", key[idx], idx);
1760 cmd_config_rss_hash_key_parsed(void *parsed_result,
1761 __attribute__((unused)) struct cmdline *cl,
1762 __attribute__((unused)) void *data)
1764 struct cmd_config_rss_hash_key *res = parsed_result;
1765 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1769 struct rte_eth_dev_info dev_info;
1770 uint8_t hash_key_size;
1773 memset(&dev_info, 0, sizeof(dev_info));
1774 rte_eth_dev_info_get(res->port_id, &dev_info);
1775 if (dev_info.hash_key_size > 0 &&
1776 dev_info.hash_key_size <= sizeof(hash_key))
1777 hash_key_size = dev_info.hash_key_size;
1779 printf("dev_info did not provide a valid hash key size\n");
1782 /* Check the length of the RSS hash key */
1783 key_len = strlen(res->key);
1784 if (key_len != (hash_key_size * 2)) {
1785 printf("key length: %d invalid - key must be a string of %d"
1786 " hexa-decimal numbers\n",
1787 (int) key_len, hash_key_size * 2);
1790 /* Translate RSS hash key into binary representation */
1791 for (i = 0; i < hash_key_size; i++) {
1792 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1795 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1798 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1800 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1804 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1806 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1807 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1809 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1810 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1811 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1812 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1813 rss_hash_key, "rss-hash-key");
1814 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1815 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1816 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1817 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1818 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1819 "ipv6-tcp-ex#ipv6-udp-ex");
1820 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1821 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1823 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1824 .f = cmd_config_rss_hash_key_parsed,
1826 .help_str = "port config <port_id> rss-hash-key "
1827 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1828 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1829 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1830 "<string of hex digits (variable length, NIC dependent)>",
1832 (void *)&cmd_config_rss_hash_key_port,
1833 (void *)&cmd_config_rss_hash_key_config,
1834 (void *)&cmd_config_rss_hash_key_port_id,
1835 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1836 (void *)&cmd_config_rss_hash_key_rss_type,
1837 (void *)&cmd_config_rss_hash_key_value,
1842 /* *** configure port rxq/txq start/stop *** */
1843 struct cmd_config_rxtx_queue {
1844 cmdline_fixed_string_t port;
1846 cmdline_fixed_string_t rxtxq;
1848 cmdline_fixed_string_t opname;
1852 cmd_config_rxtx_queue_parsed(void *parsed_result,
1853 __attribute__((unused)) struct cmdline *cl,
1854 __attribute__((unused)) void *data)
1856 struct cmd_config_rxtx_queue *res = parsed_result;
1861 if (test_done == 0) {
1862 printf("Please stop forwarding first\n");
1866 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1869 if (port_is_started(res->portid) != 1) {
1870 printf("Please start port %u first\n", res->portid);
1874 if (!strcmp(res->rxtxq, "rxq"))
1876 else if (!strcmp(res->rxtxq, "txq"))
1879 printf("Unknown parameter\n");
1883 if (isrx && rx_queue_id_is_invalid(res->qid))
1885 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1888 if (!strcmp(res->opname, "start"))
1890 else if (!strcmp(res->opname, "stop"))
1893 printf("Unknown parameter\n");
1897 if (isstart && isrx)
1898 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1899 else if (!isstart && isrx)
1900 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1901 else if (isstart && !isrx)
1902 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1904 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1906 if (ret == -ENOTSUP)
1907 printf("Function not supported in PMD driver\n");
1910 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1911 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1912 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1913 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1914 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1915 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1916 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1917 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1918 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1919 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1922 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1923 .f = cmd_config_rxtx_queue_parsed,
1925 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1927 (void *)&cmd_config_speed_all_port,
1928 (void *)&cmd_config_rxtx_queue_portid,
1929 (void *)&cmd_config_rxtx_queue_rxtxq,
1930 (void *)&cmd_config_rxtx_queue_qid,
1931 (void *)&cmd_config_rxtx_queue_opname,
1936 /* *** Configure RSS RETA *** */
1937 struct cmd_config_rss_reta {
1938 cmdline_fixed_string_t port;
1939 cmdline_fixed_string_t keyword;
1941 cmdline_fixed_string_t name;
1942 cmdline_fixed_string_t list_name;
1943 cmdline_fixed_string_t list_of_items;
1947 parse_reta_config(const char *str,
1948 struct rte_eth_rss_reta_entry64 *reta_conf,
1949 uint16_t nb_entries)
1953 uint16_t hash_index, idx, shift;
1956 const char *p, *p0 = str;
1963 unsigned long int_fld[_NUM_FLD];
1964 char *str_fld[_NUM_FLD];
1966 while ((p = strchr(p0,'(')) != NULL) {
1968 if((p0 = strchr(p,')')) == NULL)
1972 if(size >= sizeof(s))
1975 snprintf(s, sizeof(s), "%.*s", size, p);
1976 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1978 for (i = 0; i < _NUM_FLD; i++) {
1980 int_fld[i] = strtoul(str_fld[i], &end, 0);
1981 if (errno != 0 || end == str_fld[i] ||
1986 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1987 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1989 if (hash_index >= nb_entries) {
1990 printf("Invalid RETA hash index=%d\n", hash_index);
1994 idx = hash_index / RTE_RETA_GROUP_SIZE;
1995 shift = hash_index % RTE_RETA_GROUP_SIZE;
1996 reta_conf[idx].mask |= (1ULL << shift);
1997 reta_conf[idx].reta[shift] = nb_queue;
2004 cmd_set_rss_reta_parsed(void *parsed_result,
2005 __attribute__((unused)) struct cmdline *cl,
2006 __attribute__((unused)) void *data)
2009 struct rte_eth_dev_info dev_info;
2010 struct rte_eth_rss_reta_entry64 reta_conf[8];
2011 struct cmd_config_rss_reta *res = parsed_result;
2013 memset(&dev_info, 0, sizeof(dev_info));
2014 rte_eth_dev_info_get(res->port_id, &dev_info);
2015 if (dev_info.reta_size == 0) {
2016 printf("Redirection table size is 0 which is "
2017 "invalid for RSS\n");
2020 printf("The reta size of port %d is %u\n",
2021 res->port_id, dev_info.reta_size);
2022 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2023 printf("Currently do not support more than %u entries of "
2024 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2028 memset(reta_conf, 0, sizeof(reta_conf));
2029 if (!strcmp(res->list_name, "reta")) {
2030 if (parse_reta_config(res->list_of_items, reta_conf,
2031 dev_info.reta_size)) {
2032 printf("Invalid RSS Redirection Table "
2033 "config entered\n");
2036 ret = rte_eth_dev_rss_reta_update(res->port_id,
2037 reta_conf, dev_info.reta_size);
2039 printf("Bad redirection table parameter, "
2040 "return code = %d \n", ret);
2044 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2046 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2047 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2048 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2049 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2050 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2052 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2054 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2057 cmdline_parse_inst_t cmd_config_rss_reta = {
2058 .f = cmd_set_rss_reta_parsed,
2060 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2062 (void *)&cmd_config_rss_reta_port,
2063 (void *)&cmd_config_rss_reta_keyword,
2064 (void *)&cmd_config_rss_reta_port_id,
2065 (void *)&cmd_config_rss_reta_name,
2066 (void *)&cmd_config_rss_reta_list_name,
2067 (void *)&cmd_config_rss_reta_list_of_items,
2072 /* *** SHOW PORT RETA INFO *** */
2073 struct cmd_showport_reta {
2074 cmdline_fixed_string_t show;
2075 cmdline_fixed_string_t port;
2077 cmdline_fixed_string_t rss;
2078 cmdline_fixed_string_t reta;
2080 cmdline_fixed_string_t list_of_items;
2084 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2085 uint16_t nb_entries,
2089 const char *p, *p0 = str;
2094 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2095 RTE_RETA_GROUP_SIZE;
2098 p = strchr(p0, '(');
2102 p0 = strchr(p, ')');
2106 if (size >= sizeof(s)) {
2107 printf("The string size exceeds the internal buffer size\n");
2110 snprintf(s, sizeof(s), "%.*s", size, p);
2111 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2112 if (ret <= 0 || ret != num) {
2113 printf("The bits of masks do not match the number of "
2114 "reta entries: %u\n", num);
2117 for (i = 0; i < ret; i++)
2118 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2124 cmd_showport_reta_parsed(void *parsed_result,
2125 __attribute__((unused)) struct cmdline *cl,
2126 __attribute__((unused)) void *data)
2128 struct cmd_showport_reta *res = parsed_result;
2129 struct rte_eth_rss_reta_entry64 reta_conf[8];
2130 struct rte_eth_dev_info dev_info;
2132 memset(&dev_info, 0, sizeof(dev_info));
2133 rte_eth_dev_info_get(res->port_id, &dev_info);
2134 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2135 res->size > ETH_RSS_RETA_SIZE_512) {
2136 printf("Invalid redirection table size: %u\n", res->size);
2140 memset(reta_conf, 0, sizeof(reta_conf));
2141 if (showport_parse_reta_config(reta_conf, res->size,
2142 res->list_of_items) < 0) {
2143 printf("Invalid string: %s for reta masks\n",
2144 res->list_of_items);
2147 port_rss_reta_info(res->port_id, reta_conf, res->size);
2150 cmdline_parse_token_string_t cmd_showport_reta_show =
2151 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2152 cmdline_parse_token_string_t cmd_showport_reta_port =
2153 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2154 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2155 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2156 cmdline_parse_token_string_t cmd_showport_reta_rss =
2157 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2158 cmdline_parse_token_string_t cmd_showport_reta_reta =
2159 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2160 cmdline_parse_token_num_t cmd_showport_reta_size =
2161 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2162 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2163 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2164 list_of_items, NULL);
2166 cmdline_parse_inst_t cmd_showport_reta = {
2167 .f = cmd_showport_reta_parsed,
2169 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2171 (void *)&cmd_showport_reta_show,
2172 (void *)&cmd_showport_reta_port,
2173 (void *)&cmd_showport_reta_port_id,
2174 (void *)&cmd_showport_reta_rss,
2175 (void *)&cmd_showport_reta_reta,
2176 (void *)&cmd_showport_reta_size,
2177 (void *)&cmd_showport_reta_list_of_items,
2182 /* *** Show RSS hash configuration *** */
2183 struct cmd_showport_rss_hash {
2184 cmdline_fixed_string_t show;
2185 cmdline_fixed_string_t port;
2187 cmdline_fixed_string_t rss_hash;
2188 cmdline_fixed_string_t rss_type;
2189 cmdline_fixed_string_t key; /* optional argument */
2192 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2193 __attribute__((unused)) struct cmdline *cl,
2196 struct cmd_showport_rss_hash *res = parsed_result;
2198 port_rss_hash_conf_show(res->port_id, res->rss_type,
2199 show_rss_key != NULL);
2202 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2203 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2204 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2205 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2206 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2207 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2208 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2209 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2211 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2212 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2213 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2214 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2215 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2216 "ipv6-tcp-ex#ipv6-udp-ex");
2217 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2218 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2220 cmdline_parse_inst_t cmd_showport_rss_hash = {
2221 .f = cmd_showport_rss_hash_parsed,
2223 .help_str = "show port <port_id> rss-hash "
2224 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2225 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2226 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2228 (void *)&cmd_showport_rss_hash_show,
2229 (void *)&cmd_showport_rss_hash_port,
2230 (void *)&cmd_showport_rss_hash_port_id,
2231 (void *)&cmd_showport_rss_hash_rss_hash,
2232 (void *)&cmd_showport_rss_hash_rss_hash_info,
2237 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2238 .f = cmd_showport_rss_hash_parsed,
2240 .help_str = "show port <port_id> rss-hash "
2241 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2242 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2243 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2245 (void *)&cmd_showport_rss_hash_show,
2246 (void *)&cmd_showport_rss_hash_port,
2247 (void *)&cmd_showport_rss_hash_port_id,
2248 (void *)&cmd_showport_rss_hash_rss_hash,
2249 (void *)&cmd_showport_rss_hash_rss_hash_info,
2250 (void *)&cmd_showport_rss_hash_rss_key,
2255 /* *** Configure DCB *** */
2256 struct cmd_config_dcb {
2257 cmdline_fixed_string_t port;
2258 cmdline_fixed_string_t config;
2260 cmdline_fixed_string_t dcb;
2261 cmdline_fixed_string_t vt;
2262 cmdline_fixed_string_t vt_en;
2264 cmdline_fixed_string_t pfc;
2265 cmdline_fixed_string_t pfc_en;
2269 cmd_config_dcb_parsed(void *parsed_result,
2270 __attribute__((unused)) struct cmdline *cl,
2271 __attribute__((unused)) void *data)
2273 struct cmd_config_dcb *res = parsed_result;
2274 portid_t port_id = res->port_id;
2275 struct rte_port *port;
2279 port = &ports[port_id];
2280 /** Check if the port is not started **/
2281 if (port->port_status != RTE_PORT_STOPPED) {
2282 printf("Please stop port %d first\n", port_id);
2286 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2287 printf("The invalid number of traffic class,"
2288 " only 4 or 8 allowed.\n");
2292 if (nb_fwd_lcores < res->num_tcs) {
2293 printf("nb_cores shouldn't be less than number of TCs.\n");
2296 if (!strncmp(res->pfc_en, "on", 2))
2301 /* DCB in VT mode */
2302 if (!strncmp(res->vt_en, "on", 2))
2303 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2304 (enum rte_eth_nb_tcs)res->num_tcs,
2307 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2308 (enum rte_eth_nb_tcs)res->num_tcs,
2313 printf("Cannot initialize network ports.\n");
2317 cmd_reconfig_device_queue(port_id, 1, 1);
2320 cmdline_parse_token_string_t cmd_config_dcb_port =
2321 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2322 cmdline_parse_token_string_t cmd_config_dcb_config =
2323 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2324 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2325 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2326 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2327 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2328 cmdline_parse_token_string_t cmd_config_dcb_vt =
2329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2330 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2331 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2332 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2333 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2334 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2336 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2337 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2339 cmdline_parse_inst_t cmd_config_dcb = {
2340 .f = cmd_config_dcb_parsed,
2342 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2344 (void *)&cmd_config_dcb_port,
2345 (void *)&cmd_config_dcb_config,
2346 (void *)&cmd_config_dcb_port_id,
2347 (void *)&cmd_config_dcb_dcb,
2348 (void *)&cmd_config_dcb_vt,
2349 (void *)&cmd_config_dcb_vt_en,
2350 (void *)&cmd_config_dcb_num_tcs,
2351 (void *)&cmd_config_dcb_pfc,
2352 (void *)&cmd_config_dcb_pfc_en,
2357 /* *** configure number of packets per burst *** */
2358 struct cmd_config_burst {
2359 cmdline_fixed_string_t port;
2360 cmdline_fixed_string_t keyword;
2361 cmdline_fixed_string_t all;
2362 cmdline_fixed_string_t name;
2367 cmd_config_burst_parsed(void *parsed_result,
2368 __attribute__((unused)) struct cmdline *cl,
2369 __attribute__((unused)) void *data)
2371 struct cmd_config_burst *res = parsed_result;
2373 if (!all_ports_stopped()) {
2374 printf("Please stop all ports first\n");
2378 if (!strcmp(res->name, "burst")) {
2379 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2380 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2383 nb_pkt_per_burst = res->value;
2385 printf("Unknown parameter\n");
2391 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2394 cmdline_parse_token_string_t cmd_config_burst_port =
2395 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2396 cmdline_parse_token_string_t cmd_config_burst_keyword =
2397 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2398 cmdline_parse_token_string_t cmd_config_burst_all =
2399 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2400 cmdline_parse_token_string_t cmd_config_burst_name =
2401 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2402 cmdline_parse_token_num_t cmd_config_burst_value =
2403 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2405 cmdline_parse_inst_t cmd_config_burst = {
2406 .f = cmd_config_burst_parsed,
2408 .help_str = "port config all burst <value>",
2410 (void *)&cmd_config_burst_port,
2411 (void *)&cmd_config_burst_keyword,
2412 (void *)&cmd_config_burst_all,
2413 (void *)&cmd_config_burst_name,
2414 (void *)&cmd_config_burst_value,
2419 /* *** configure rx/tx queues *** */
2420 struct cmd_config_thresh {
2421 cmdline_fixed_string_t port;
2422 cmdline_fixed_string_t keyword;
2423 cmdline_fixed_string_t all;
2424 cmdline_fixed_string_t name;
2429 cmd_config_thresh_parsed(void *parsed_result,
2430 __attribute__((unused)) struct cmdline *cl,
2431 __attribute__((unused)) void *data)
2433 struct cmd_config_thresh *res = parsed_result;
2435 if (!all_ports_stopped()) {
2436 printf("Please stop all ports first\n");
2440 if (!strcmp(res->name, "txpt"))
2441 tx_pthresh = res->value;
2442 else if(!strcmp(res->name, "txht"))
2443 tx_hthresh = res->value;
2444 else if(!strcmp(res->name, "txwt"))
2445 tx_wthresh = res->value;
2446 else if(!strcmp(res->name, "rxpt"))
2447 rx_pthresh = res->value;
2448 else if(!strcmp(res->name, "rxht"))
2449 rx_hthresh = res->value;
2450 else if(!strcmp(res->name, "rxwt"))
2451 rx_wthresh = res->value;
2453 printf("Unknown parameter\n");
2459 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2462 cmdline_parse_token_string_t cmd_config_thresh_port =
2463 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2464 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2465 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2466 cmdline_parse_token_string_t cmd_config_thresh_all =
2467 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2468 cmdline_parse_token_string_t cmd_config_thresh_name =
2469 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2470 "txpt#txht#txwt#rxpt#rxht#rxwt");
2471 cmdline_parse_token_num_t cmd_config_thresh_value =
2472 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2474 cmdline_parse_inst_t cmd_config_thresh = {
2475 .f = cmd_config_thresh_parsed,
2477 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2479 (void *)&cmd_config_thresh_port,
2480 (void *)&cmd_config_thresh_keyword,
2481 (void *)&cmd_config_thresh_all,
2482 (void *)&cmd_config_thresh_name,
2483 (void *)&cmd_config_thresh_value,
2488 /* *** configure free/rs threshold *** */
2489 struct cmd_config_threshold {
2490 cmdline_fixed_string_t port;
2491 cmdline_fixed_string_t keyword;
2492 cmdline_fixed_string_t all;
2493 cmdline_fixed_string_t name;
2498 cmd_config_threshold_parsed(void *parsed_result,
2499 __attribute__((unused)) struct cmdline *cl,
2500 __attribute__((unused)) void *data)
2502 struct cmd_config_threshold *res = parsed_result;
2504 if (!all_ports_stopped()) {
2505 printf("Please stop all ports first\n");
2509 if (!strcmp(res->name, "txfreet"))
2510 tx_free_thresh = res->value;
2511 else if (!strcmp(res->name, "txrst"))
2512 tx_rs_thresh = res->value;
2513 else if (!strcmp(res->name, "rxfreet"))
2514 rx_free_thresh = res->value;
2516 printf("Unknown parameter\n");
2522 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2525 cmdline_parse_token_string_t cmd_config_threshold_port =
2526 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2527 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2528 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2530 cmdline_parse_token_string_t cmd_config_threshold_all =
2531 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2532 cmdline_parse_token_string_t cmd_config_threshold_name =
2533 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2534 "txfreet#txrst#rxfreet");
2535 cmdline_parse_token_num_t cmd_config_threshold_value =
2536 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2538 cmdline_parse_inst_t cmd_config_threshold = {
2539 .f = cmd_config_threshold_parsed,
2541 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2543 (void *)&cmd_config_threshold_port,
2544 (void *)&cmd_config_threshold_keyword,
2545 (void *)&cmd_config_threshold_all,
2546 (void *)&cmd_config_threshold_name,
2547 (void *)&cmd_config_threshold_value,
2553 struct cmd_stop_result {
2554 cmdline_fixed_string_t stop;
2557 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2558 __attribute__((unused)) struct cmdline *cl,
2559 __attribute__((unused)) void *data)
2561 stop_packet_forwarding();
2564 cmdline_parse_token_string_t cmd_stop_stop =
2565 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2567 cmdline_parse_inst_t cmd_stop = {
2568 .f = cmd_stop_parsed,
2570 .help_str = "stop: Stop packet forwarding",
2572 (void *)&cmd_stop_stop,
2577 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2580 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2581 unsigned int *parsed_items, int check_unique_values)
2583 unsigned int nb_item;
2591 * First parse all items in the list and store their value.
2596 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2598 if ((c >= '0') && (c <= '9')) {
2599 value = (unsigned int) (value * 10 + (c - '0'));
2604 printf("character %c is not a decimal digit\n", c);
2608 printf("No valid value before comma\n");
2611 if (nb_item < max_items) {
2612 parsed_items[nb_item] = value;
2618 if (nb_item >= max_items) {
2619 printf("Number of %s = %u > %u (maximum items)\n",
2620 item_name, nb_item + 1, max_items);
2623 parsed_items[nb_item++] = value;
2624 if (! check_unique_values)
2628 * Then, check that all values in the list are differents.
2629 * No optimization here...
2631 for (i = 0; i < nb_item; i++) {
2632 for (j = i + 1; j < nb_item; j++) {
2633 if (parsed_items[j] == parsed_items[i]) {
2634 printf("duplicated %s %u at index %u and %u\n",
2635 item_name, parsed_items[i], i, j);
2643 struct cmd_set_list_result {
2644 cmdline_fixed_string_t cmd_keyword;
2645 cmdline_fixed_string_t list_name;
2646 cmdline_fixed_string_t list_of_items;
2649 static void cmd_set_list_parsed(void *parsed_result,
2650 __attribute__((unused)) struct cmdline *cl,
2651 __attribute__((unused)) void *data)
2653 struct cmd_set_list_result *res;
2655 unsigned int lcorelist[RTE_MAX_LCORE];
2656 unsigned int portlist[RTE_MAX_ETHPORTS];
2658 unsigned int nb_item;
2660 if (test_done == 0) {
2661 printf("Please stop forwarding first\n");
2665 res = parsed_result;
2666 if (!strcmp(res->list_name, "corelist")) {
2667 nb_item = parse_item_list(res->list_of_items, "core",
2669 parsed_items.lcorelist, 1);
2671 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2676 if (!strcmp(res->list_name, "portlist")) {
2677 nb_item = parse_item_list(res->list_of_items, "port",
2679 parsed_items.portlist, 1);
2681 set_fwd_ports_list(parsed_items.portlist, nb_item);
2687 cmdline_parse_token_string_t cmd_set_list_keyword =
2688 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2690 cmdline_parse_token_string_t cmd_set_list_name =
2691 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2692 "corelist#portlist");
2693 cmdline_parse_token_string_t cmd_set_list_of_items =
2694 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2697 cmdline_parse_inst_t cmd_set_fwd_list = {
2698 .f = cmd_set_list_parsed,
2700 .help_str = "set corelist|portlist <list0[,list1]*>",
2702 (void *)&cmd_set_list_keyword,
2703 (void *)&cmd_set_list_name,
2704 (void *)&cmd_set_list_of_items,
2709 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2711 struct cmd_setmask_result {
2712 cmdline_fixed_string_t set;
2713 cmdline_fixed_string_t mask;
2717 static void cmd_set_mask_parsed(void *parsed_result,
2718 __attribute__((unused)) struct cmdline *cl,
2719 __attribute__((unused)) void *data)
2721 struct cmd_setmask_result *res = parsed_result;
2723 if (test_done == 0) {
2724 printf("Please stop forwarding first\n");
2727 if (!strcmp(res->mask, "coremask")) {
2728 set_fwd_lcores_mask(res->hexavalue);
2730 } else if (!strcmp(res->mask, "portmask")) {
2731 set_fwd_ports_mask(res->hexavalue);
2736 cmdline_parse_token_string_t cmd_setmask_set =
2737 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2738 cmdline_parse_token_string_t cmd_setmask_mask =
2739 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2740 "coremask#portmask");
2741 cmdline_parse_token_num_t cmd_setmask_value =
2742 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2744 cmdline_parse_inst_t cmd_set_fwd_mask = {
2745 .f = cmd_set_mask_parsed,
2747 .help_str = "set coremask|portmask <hexadecimal value>",
2749 (void *)&cmd_setmask_set,
2750 (void *)&cmd_setmask_mask,
2751 (void *)&cmd_setmask_value,
2757 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2759 struct cmd_set_result {
2760 cmdline_fixed_string_t set;
2761 cmdline_fixed_string_t what;
2765 static void cmd_set_parsed(void *parsed_result,
2766 __attribute__((unused)) struct cmdline *cl,
2767 __attribute__((unused)) void *data)
2769 struct cmd_set_result *res = parsed_result;
2770 if (!strcmp(res->what, "nbport")) {
2771 set_fwd_ports_number(res->value);
2773 } else if (!strcmp(res->what, "nbcore")) {
2774 set_fwd_lcores_number(res->value);
2776 } else if (!strcmp(res->what, "burst"))
2777 set_nb_pkt_per_burst(res->value);
2778 else if (!strcmp(res->what, "verbose"))
2779 set_verbose_level(res->value);
2782 cmdline_parse_token_string_t cmd_set_set =
2783 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2784 cmdline_parse_token_string_t cmd_set_what =
2785 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2786 "nbport#nbcore#burst#verbose");
2787 cmdline_parse_token_num_t cmd_set_value =
2788 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2790 cmdline_parse_inst_t cmd_set_numbers = {
2791 .f = cmd_set_parsed,
2793 .help_str = "set nbport|nbcore|burst|verbose <value>",
2795 (void *)&cmd_set_set,
2796 (void *)&cmd_set_what,
2797 (void *)&cmd_set_value,
2802 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2804 struct cmd_set_txpkts_result {
2805 cmdline_fixed_string_t cmd_keyword;
2806 cmdline_fixed_string_t txpkts;
2807 cmdline_fixed_string_t seg_lengths;
2811 cmd_set_txpkts_parsed(void *parsed_result,
2812 __attribute__((unused)) struct cmdline *cl,
2813 __attribute__((unused)) void *data)
2815 struct cmd_set_txpkts_result *res;
2816 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2817 unsigned int nb_segs;
2819 res = parsed_result;
2820 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2821 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2823 set_tx_pkt_segments(seg_lengths, nb_segs);
2826 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2827 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2828 cmd_keyword, "set");
2829 cmdline_parse_token_string_t cmd_set_txpkts_name =
2830 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2832 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2833 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2836 cmdline_parse_inst_t cmd_set_txpkts = {
2837 .f = cmd_set_txpkts_parsed,
2839 .help_str = "set txpkts <len0[,len1]*>",
2841 (void *)&cmd_set_txpkts_keyword,
2842 (void *)&cmd_set_txpkts_name,
2843 (void *)&cmd_set_txpkts_lengths,
2848 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2850 struct cmd_set_txsplit_result {
2851 cmdline_fixed_string_t cmd_keyword;
2852 cmdline_fixed_string_t txsplit;
2853 cmdline_fixed_string_t mode;
2857 cmd_set_txsplit_parsed(void *parsed_result,
2858 __attribute__((unused)) struct cmdline *cl,
2859 __attribute__((unused)) void *data)
2861 struct cmd_set_txsplit_result *res;
2863 res = parsed_result;
2864 set_tx_pkt_split(res->mode);
2867 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2868 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2869 cmd_keyword, "set");
2870 cmdline_parse_token_string_t cmd_set_txsplit_name =
2871 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2872 txsplit, "txsplit");
2873 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2874 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2877 cmdline_parse_inst_t cmd_set_txsplit = {
2878 .f = cmd_set_txsplit_parsed,
2880 .help_str = "set txsplit on|off|rand",
2882 (void *)&cmd_set_txsplit_keyword,
2883 (void *)&cmd_set_txsplit_name,
2884 (void *)&cmd_set_txsplit_mode,
2889 /* *** CONFIG TX QUEUE FLAGS *** */
2891 struct cmd_config_txqflags_result {
2892 cmdline_fixed_string_t port;
2893 cmdline_fixed_string_t config;
2894 cmdline_fixed_string_t all;
2895 cmdline_fixed_string_t what;
2899 static void cmd_config_txqflags_parsed(void *parsed_result,
2900 __attribute__((unused)) struct cmdline *cl,
2901 __attribute__((unused)) void *data)
2903 struct cmd_config_txqflags_result *res = parsed_result;
2905 if (!all_ports_stopped()) {
2906 printf("Please stop all ports first\n");
2910 if (strcmp(res->what, "txqflags")) {
2911 printf("Unknown parameter\n");
2915 if (res->hexvalue >= 0) {
2916 txq_flags = res->hexvalue;
2918 printf("txqflags must be >= 0\n");
2924 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2927 cmdline_parse_token_string_t cmd_config_txqflags_port =
2928 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2930 cmdline_parse_token_string_t cmd_config_txqflags_config =
2931 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2933 cmdline_parse_token_string_t cmd_config_txqflags_all =
2934 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2936 cmdline_parse_token_string_t cmd_config_txqflags_what =
2937 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2939 cmdline_parse_token_num_t cmd_config_txqflags_value =
2940 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2943 cmdline_parse_inst_t cmd_config_txqflags = {
2944 .f = cmd_config_txqflags_parsed,
2946 .help_str = "port config all txqflags <value>",
2948 (void *)&cmd_config_txqflags_port,
2949 (void *)&cmd_config_txqflags_config,
2950 (void *)&cmd_config_txqflags_all,
2951 (void *)&cmd_config_txqflags_what,
2952 (void *)&cmd_config_txqflags_value,
2957 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2958 struct cmd_rx_vlan_filter_all_result {
2959 cmdline_fixed_string_t rx_vlan;
2960 cmdline_fixed_string_t what;
2961 cmdline_fixed_string_t all;
2966 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2967 __attribute__((unused)) struct cmdline *cl,
2968 __attribute__((unused)) void *data)
2970 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2972 if (!strcmp(res->what, "add"))
2973 rx_vlan_all_filter_set(res->port_id, 1);
2975 rx_vlan_all_filter_set(res->port_id, 0);
2978 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2979 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2980 rx_vlan, "rx_vlan");
2981 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2982 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2984 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2985 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2987 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2988 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2991 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2992 .f = cmd_rx_vlan_filter_all_parsed,
2994 .help_str = "rx_vlan add|rm all <port_id>: "
2995 "Add/Remove all identifiers to/from the set of VLAN "
2996 "identifiers filtered by a port",
2998 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2999 (void *)&cmd_rx_vlan_filter_all_what,
3000 (void *)&cmd_rx_vlan_filter_all_all,
3001 (void *)&cmd_rx_vlan_filter_all_portid,
3006 /* *** VLAN OFFLOAD SET ON A PORT *** */
3007 struct cmd_vlan_offload_result {
3008 cmdline_fixed_string_t vlan;
3009 cmdline_fixed_string_t set;
3010 cmdline_fixed_string_t vlan_type;
3011 cmdline_fixed_string_t what;
3012 cmdline_fixed_string_t on;
3013 cmdline_fixed_string_t port_id;
3017 cmd_vlan_offload_parsed(void *parsed_result,
3018 __attribute__((unused)) struct cmdline *cl,
3019 __attribute__((unused)) void *data)
3022 struct cmd_vlan_offload_result *res = parsed_result;
3025 portid_t port_id = 0;
3029 len = strnlen(str, STR_TOKEN_SIZE);
3031 /* Get port_id first */
3039 tmp = strtoul(str, NULL, 0);
3040 /* If port_id greater that what portid_t can represent, return */
3041 if(tmp >= RTE_MAX_ETHPORTS)
3043 port_id = (portid_t)tmp;
3045 if (!strcmp(res->on, "on"))
3050 if (!strcmp(res->what, "strip"))
3051 rx_vlan_strip_set(port_id, on);
3052 else if(!strcmp(res->what, "stripq")){
3053 uint16_t queue_id = 0;
3055 /* No queue_id, return */
3057 printf("must specify (port,queue_id)\n");
3060 tmp = strtoul(str + i + 1, NULL, 0);
3061 /* If queue_id greater that what 16-bits can represent, return */
3065 queue_id = (uint16_t)tmp;
3066 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3068 else if (!strcmp(res->what, "filter"))
3069 rx_vlan_filter_set(port_id, on);
3071 vlan_extend_set(port_id, on);
3076 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3077 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3079 cmdline_parse_token_string_t cmd_vlan_offload_set =
3080 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3082 cmdline_parse_token_string_t cmd_vlan_offload_what =
3083 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3084 what, "strip#filter#qinq#stripq");
3085 cmdline_parse_token_string_t cmd_vlan_offload_on =
3086 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3088 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3089 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3092 cmdline_parse_inst_t cmd_vlan_offload = {
3093 .f = cmd_vlan_offload_parsed,
3095 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3096 "<port_id[,queue_id]>: "
3097 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3099 (void *)&cmd_vlan_offload_vlan,
3100 (void *)&cmd_vlan_offload_set,
3101 (void *)&cmd_vlan_offload_what,
3102 (void *)&cmd_vlan_offload_on,
3103 (void *)&cmd_vlan_offload_portid,
3108 /* *** VLAN TPID SET ON A PORT *** */
3109 struct cmd_vlan_tpid_result {
3110 cmdline_fixed_string_t vlan;
3111 cmdline_fixed_string_t set;
3112 cmdline_fixed_string_t vlan_type;
3113 cmdline_fixed_string_t what;
3119 cmd_vlan_tpid_parsed(void *parsed_result,
3120 __attribute__((unused)) struct cmdline *cl,
3121 __attribute__((unused)) void *data)
3123 struct cmd_vlan_tpid_result *res = parsed_result;
3124 enum rte_vlan_type vlan_type;
3126 if (!strcmp(res->vlan_type, "inner"))
3127 vlan_type = ETH_VLAN_TYPE_INNER;
3128 else if (!strcmp(res->vlan_type, "outer"))
3129 vlan_type = ETH_VLAN_TYPE_OUTER;
3131 printf("Unknown vlan type\n");
3134 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3137 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3138 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3140 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3141 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3143 cmdline_parse_token_string_t cmd_vlan_type =
3144 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3145 vlan_type, "inner#outer");
3146 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3147 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3149 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3150 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3152 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3153 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3156 cmdline_parse_inst_t cmd_vlan_tpid = {
3157 .f = cmd_vlan_tpid_parsed,
3159 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3160 "Set the VLAN Ether type",
3162 (void *)&cmd_vlan_tpid_vlan,
3163 (void *)&cmd_vlan_tpid_set,
3164 (void *)&cmd_vlan_type,
3165 (void *)&cmd_vlan_tpid_what,
3166 (void *)&cmd_vlan_tpid_tpid,
3167 (void *)&cmd_vlan_tpid_portid,
3172 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3173 struct cmd_rx_vlan_filter_result {
3174 cmdline_fixed_string_t rx_vlan;
3175 cmdline_fixed_string_t what;
3181 cmd_rx_vlan_filter_parsed(void *parsed_result,
3182 __attribute__((unused)) struct cmdline *cl,
3183 __attribute__((unused)) void *data)
3185 struct cmd_rx_vlan_filter_result *res = parsed_result;
3187 if (!strcmp(res->what, "add"))
3188 rx_vft_set(res->port_id, res->vlan_id, 1);
3190 rx_vft_set(res->port_id, res->vlan_id, 0);
3193 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3194 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3195 rx_vlan, "rx_vlan");
3196 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3197 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3199 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3200 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3202 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3203 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3206 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3207 .f = cmd_rx_vlan_filter_parsed,
3209 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3210 "Add/Remove a VLAN identifier to/from the set of VLAN "
3211 "identifiers filtered by a port",
3213 (void *)&cmd_rx_vlan_filter_rx_vlan,
3214 (void *)&cmd_rx_vlan_filter_what,
3215 (void *)&cmd_rx_vlan_filter_vlanid,
3216 (void *)&cmd_rx_vlan_filter_portid,
3221 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3222 struct cmd_tx_vlan_set_result {
3223 cmdline_fixed_string_t tx_vlan;
3224 cmdline_fixed_string_t set;
3230 cmd_tx_vlan_set_parsed(void *parsed_result,
3231 __attribute__((unused)) struct cmdline *cl,
3232 __attribute__((unused)) void *data)
3234 struct cmd_tx_vlan_set_result *res = parsed_result;
3236 tx_vlan_set(res->port_id, res->vlan_id);
3239 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3240 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3241 tx_vlan, "tx_vlan");
3242 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3243 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3245 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3246 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3248 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3249 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3252 cmdline_parse_inst_t cmd_tx_vlan_set = {
3253 .f = cmd_tx_vlan_set_parsed,
3255 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3256 "Enable hardware insertion of a single VLAN header "
3257 "with a given TAG Identifier in packets sent on a port",
3259 (void *)&cmd_tx_vlan_set_tx_vlan,
3260 (void *)&cmd_tx_vlan_set_set,
3261 (void *)&cmd_tx_vlan_set_portid,
3262 (void *)&cmd_tx_vlan_set_vlanid,
3267 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3268 struct cmd_tx_vlan_set_qinq_result {
3269 cmdline_fixed_string_t tx_vlan;
3270 cmdline_fixed_string_t set;
3273 uint16_t vlan_id_outer;
3277 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3278 __attribute__((unused)) struct cmdline *cl,
3279 __attribute__((unused)) void *data)
3281 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3283 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3286 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3287 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3288 tx_vlan, "tx_vlan");
3289 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3290 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3292 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3293 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3295 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3296 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3298 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3299 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3300 vlan_id_outer, UINT16);
3302 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3303 .f = cmd_tx_vlan_set_qinq_parsed,
3305 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3306 "Enable hardware insertion of double VLAN header "
3307 "with given TAG Identifiers in packets sent on a port",
3309 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3310 (void *)&cmd_tx_vlan_set_qinq_set,
3311 (void *)&cmd_tx_vlan_set_qinq_portid,
3312 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3313 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3318 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3319 struct cmd_tx_vlan_set_pvid_result {
3320 cmdline_fixed_string_t tx_vlan;
3321 cmdline_fixed_string_t set;
3322 cmdline_fixed_string_t pvid;
3325 cmdline_fixed_string_t mode;
3329 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3330 __attribute__((unused)) struct cmdline *cl,
3331 __attribute__((unused)) void *data)
3333 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3335 if (strcmp(res->mode, "on") == 0)
3336 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3338 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3341 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3342 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3343 tx_vlan, "tx_vlan");
3344 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3345 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3347 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3348 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3350 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3351 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3353 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3354 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3356 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3357 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3360 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3361 .f = cmd_tx_vlan_set_pvid_parsed,
3363 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3365 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3366 (void *)&cmd_tx_vlan_set_pvid_set,
3367 (void *)&cmd_tx_vlan_set_pvid_pvid,
3368 (void *)&cmd_tx_vlan_set_pvid_port_id,
3369 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3370 (void *)&cmd_tx_vlan_set_pvid_mode,
3375 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3376 struct cmd_tx_vlan_reset_result {
3377 cmdline_fixed_string_t tx_vlan;
3378 cmdline_fixed_string_t reset;
3383 cmd_tx_vlan_reset_parsed(void *parsed_result,
3384 __attribute__((unused)) struct cmdline *cl,
3385 __attribute__((unused)) void *data)
3387 struct cmd_tx_vlan_reset_result *res = parsed_result;
3389 tx_vlan_reset(res->port_id);
3392 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3393 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3394 tx_vlan, "tx_vlan");
3395 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3396 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3398 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3399 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3402 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3403 .f = cmd_tx_vlan_reset_parsed,
3405 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3406 "VLAN header in packets sent on a port",
3408 (void *)&cmd_tx_vlan_reset_tx_vlan,
3409 (void *)&cmd_tx_vlan_reset_reset,
3410 (void *)&cmd_tx_vlan_reset_portid,
3416 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3417 struct cmd_csum_result {
3418 cmdline_fixed_string_t csum;
3419 cmdline_fixed_string_t mode;
3420 cmdline_fixed_string_t proto;
3421 cmdline_fixed_string_t hwsw;
3426 csum_show(int port_id)
3428 struct rte_eth_dev_info dev_info;
3431 ol_flags = ports[port_id].tx_ol_flags;
3432 printf("Parse tunnel is %s\n",
3433 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3434 printf("IP checksum offload is %s\n",
3435 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3436 printf("UDP checksum offload is %s\n",
3437 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3438 printf("TCP checksum offload is %s\n",
3439 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3440 printf("SCTP checksum offload is %s\n",
3441 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3442 printf("Outer-Ip checksum offload is %s\n",
3443 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3445 /* display warnings if configuration is not supported by the NIC */
3446 rte_eth_dev_info_get(port_id, &dev_info);
3447 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3448 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3449 printf("Warning: hardware IP checksum enabled but not "
3450 "supported by port %d\n", port_id);
3452 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3453 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3454 printf("Warning: hardware UDP checksum enabled but not "
3455 "supported by port %d\n", port_id);
3457 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3458 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3459 printf("Warning: hardware TCP checksum enabled but not "
3460 "supported by port %d\n", port_id);
3462 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3463 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3464 printf("Warning: hardware SCTP checksum enabled but not "
3465 "supported by port %d\n", port_id);
3467 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3468 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3469 printf("Warning: hardware outer IP checksum enabled but not "
3470 "supported by port %d\n", port_id);
3475 cmd_csum_parsed(void *parsed_result,
3476 __attribute__((unused)) struct cmdline *cl,
3477 __attribute__((unused)) void *data)
3479 struct cmd_csum_result *res = parsed_result;
3483 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3484 printf("invalid port %d\n", res->port_id);
3488 if (!strcmp(res->mode, "set")) {
3490 if (!strcmp(res->hwsw, "hw"))
3493 if (!strcmp(res->proto, "ip")) {
3494 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3495 } else if (!strcmp(res->proto, "udp")) {
3496 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3497 } else if (!strcmp(res->proto, "tcp")) {
3498 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3499 } else if (!strcmp(res->proto, "sctp")) {
3500 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3501 } else if (!strcmp(res->proto, "outer-ip")) {
3502 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3506 ports[res->port_id].tx_ol_flags |= mask;
3508 ports[res->port_id].tx_ol_flags &= (~mask);
3510 csum_show(res->port_id);
3513 cmdline_parse_token_string_t cmd_csum_csum =
3514 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3516 cmdline_parse_token_string_t cmd_csum_mode =
3517 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3519 cmdline_parse_token_string_t cmd_csum_proto =
3520 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3521 proto, "ip#tcp#udp#sctp#outer-ip");
3522 cmdline_parse_token_string_t cmd_csum_hwsw =
3523 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3525 cmdline_parse_token_num_t cmd_csum_portid =
3526 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3529 cmdline_parse_inst_t cmd_csum_set = {
3530 .f = cmd_csum_parsed,
3532 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3533 "Enable/Disable hardware calculation of L3/L4 checksum when "
3534 "using csum forward engine",
3536 (void *)&cmd_csum_csum,
3537 (void *)&cmd_csum_mode,
3538 (void *)&cmd_csum_proto,
3539 (void *)&cmd_csum_hwsw,
3540 (void *)&cmd_csum_portid,
3545 cmdline_parse_token_string_t cmd_csum_mode_show =
3546 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3549 cmdline_parse_inst_t cmd_csum_show = {
3550 .f = cmd_csum_parsed,
3552 .help_str = "csum show <port_id>: Show checksum offload configuration",
3554 (void *)&cmd_csum_csum,
3555 (void *)&cmd_csum_mode_show,
3556 (void *)&cmd_csum_portid,
3561 /* Enable/disable tunnel parsing */
3562 struct cmd_csum_tunnel_result {
3563 cmdline_fixed_string_t csum;
3564 cmdline_fixed_string_t parse;
3565 cmdline_fixed_string_t onoff;
3570 cmd_csum_tunnel_parsed(void *parsed_result,
3571 __attribute__((unused)) struct cmdline *cl,
3572 __attribute__((unused)) void *data)
3574 struct cmd_csum_tunnel_result *res = parsed_result;
3576 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3579 if (!strcmp(res->onoff, "on"))
3580 ports[res->port_id].tx_ol_flags |=
3581 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3583 ports[res->port_id].tx_ol_flags &=
3584 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3586 csum_show(res->port_id);
3589 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3590 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3592 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3593 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3594 parse, "parse_tunnel");
3595 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3596 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3598 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3599 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3602 cmdline_parse_inst_t cmd_csum_tunnel = {
3603 .f = cmd_csum_tunnel_parsed,
3605 .help_str = "csum parse_tunnel on|off <port_id>: "
3606 "Enable/Disable parsing of tunnels for csum engine",
3608 (void *)&cmd_csum_tunnel_csum,
3609 (void *)&cmd_csum_tunnel_parse,
3610 (void *)&cmd_csum_tunnel_onoff,
3611 (void *)&cmd_csum_tunnel_portid,
3616 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3617 struct cmd_tso_set_result {
3618 cmdline_fixed_string_t tso;
3619 cmdline_fixed_string_t mode;
3625 cmd_tso_set_parsed(void *parsed_result,
3626 __attribute__((unused)) struct cmdline *cl,
3627 __attribute__((unused)) void *data)
3629 struct cmd_tso_set_result *res = parsed_result;
3630 struct rte_eth_dev_info dev_info;
3632 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3635 if (!strcmp(res->mode, "set"))
3636 ports[res->port_id].tso_segsz = res->tso_segsz;
3638 if (ports[res->port_id].tso_segsz == 0)
3639 printf("TSO for non-tunneled packets is disabled\n");
3641 printf("TSO segment size for non-tunneled packets is %d\n",
3642 ports[res->port_id].tso_segsz);
3644 /* display warnings if configuration is not supported by the NIC */
3645 rte_eth_dev_info_get(res->port_id, &dev_info);
3646 if ((ports[res->port_id].tso_segsz != 0) &&
3647 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3648 printf("Warning: TSO enabled but not "
3649 "supported by port %d\n", res->port_id);
3653 cmdline_parse_token_string_t cmd_tso_set_tso =
3654 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3656 cmdline_parse_token_string_t cmd_tso_set_mode =
3657 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3659 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3660 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3662 cmdline_parse_token_num_t cmd_tso_set_portid =
3663 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3666 cmdline_parse_inst_t cmd_tso_set = {
3667 .f = cmd_tso_set_parsed,
3669 .help_str = "tso set <tso_segsz> <port_id>: "
3670 "Set TSO segment size of non-tunneled packets for csum engine "
3673 (void *)&cmd_tso_set_tso,
3674 (void *)&cmd_tso_set_mode,
3675 (void *)&cmd_tso_set_tso_segsz,
3676 (void *)&cmd_tso_set_portid,
3681 cmdline_parse_token_string_t cmd_tso_show_mode =
3682 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3686 cmdline_parse_inst_t cmd_tso_show = {
3687 .f = cmd_tso_set_parsed,
3689 .help_str = "tso show <port_id>: "
3690 "Show TSO segment size of non-tunneled packets for csum engine",
3692 (void *)&cmd_tso_set_tso,
3693 (void *)&cmd_tso_show_mode,
3694 (void *)&cmd_tso_set_portid,
3699 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3700 struct cmd_tunnel_tso_set_result {
3701 cmdline_fixed_string_t tso;
3702 cmdline_fixed_string_t mode;
3708 check_tunnel_tso_nic_support(uint8_t port_id)
3710 struct rte_eth_dev_info dev_info;
3712 rte_eth_dev_info_get(port_id, &dev_info);
3713 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3714 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3715 "supported by port %d\n", port_id);
3716 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3717 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3718 "supported by port %d\n", port_id);
3719 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3720 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3721 "supported by port %d\n", port_id);
3722 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3723 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3724 "supported by port %d\n", port_id);
3728 cmd_tunnel_tso_set_parsed(void *parsed_result,
3729 __attribute__((unused)) struct cmdline *cl,
3730 __attribute__((unused)) void *data)
3732 struct cmd_tunnel_tso_set_result *res = parsed_result;
3734 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3737 if (!strcmp(res->mode, "set"))
3738 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3740 if (ports[res->port_id].tunnel_tso_segsz == 0)
3741 printf("TSO for tunneled packets is disabled\n");
3743 printf("TSO segment size for tunneled packets is %d\n",
3744 ports[res->port_id].tunnel_tso_segsz);
3746 /* Below conditions are needed to make it work:
3747 * (1) tunnel TSO is supported by the NIC;
3748 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3750 * (3) for tunneled pkts with outer L3 of IPv4,
3751 * "csum set outer-ip" must be set to hw, because after tso,
3752 * total_len of outer IP header is changed, and the checksum
3753 * of outer IP header calculated by sw should be wrong; that
3754 * is not necessary for IPv6 tunneled pkts because there's no
3755 * checksum in IP header anymore.
3757 check_tunnel_tso_nic_support(res->port_id);
3759 if (!(ports[res->port_id].tx_ol_flags &
3760 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3761 printf("Warning: csum parse_tunnel must be set "
3762 "so that tunneled packets are recognized\n");
3763 if (!(ports[res->port_id].tx_ol_flags &
3764 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3765 printf("Warning: csum set outer-ip must be set to hw "
3766 "if outer L3 is IPv4; not necessary for IPv6\n");
3770 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3771 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3773 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3774 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3776 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3777 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3779 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3780 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3783 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3784 .f = cmd_tunnel_tso_set_parsed,
3786 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3787 "Set TSO segment size of tunneled packets for csum engine "
3790 (void *)&cmd_tunnel_tso_set_tso,
3791 (void *)&cmd_tunnel_tso_set_mode,
3792 (void *)&cmd_tunnel_tso_set_tso_segsz,
3793 (void *)&cmd_tunnel_tso_set_portid,
3798 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3799 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3803 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3804 .f = cmd_tunnel_tso_set_parsed,
3806 .help_str = "tunnel_tso show <port_id> "
3807 "Show TSO segment size of tunneled packets for csum engine",
3809 (void *)&cmd_tunnel_tso_set_tso,
3810 (void *)&cmd_tunnel_tso_show_mode,
3811 (void *)&cmd_tunnel_tso_set_portid,
3816 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3817 struct cmd_set_flush_rx {
3818 cmdline_fixed_string_t set;
3819 cmdline_fixed_string_t flush_rx;
3820 cmdline_fixed_string_t mode;
3824 cmd_set_flush_rx_parsed(void *parsed_result,
3825 __attribute__((unused)) struct cmdline *cl,
3826 __attribute__((unused)) void *data)
3828 struct cmd_set_flush_rx *res = parsed_result;
3829 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3832 cmdline_parse_token_string_t cmd_setflushrx_set =
3833 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3835 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3836 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3837 flush_rx, "flush_rx");
3838 cmdline_parse_token_string_t cmd_setflushrx_mode =
3839 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3843 cmdline_parse_inst_t cmd_set_flush_rx = {
3844 .f = cmd_set_flush_rx_parsed,
3845 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3848 (void *)&cmd_setflushrx_set,
3849 (void *)&cmd_setflushrx_flush_rx,
3850 (void *)&cmd_setflushrx_mode,
3855 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3856 struct cmd_set_link_check {
3857 cmdline_fixed_string_t set;
3858 cmdline_fixed_string_t link_check;
3859 cmdline_fixed_string_t mode;
3863 cmd_set_link_check_parsed(void *parsed_result,
3864 __attribute__((unused)) struct cmdline *cl,
3865 __attribute__((unused)) void *data)
3867 struct cmd_set_link_check *res = parsed_result;
3868 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3871 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3874 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3875 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3876 link_check, "link_check");
3877 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3878 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3882 cmdline_parse_inst_t cmd_set_link_check = {
3883 .f = cmd_set_link_check_parsed,
3884 .help_str = "set link_check on|off: Enable/Disable link status check "
3885 "when starting/stopping a port",
3888 (void *)&cmd_setlinkcheck_set,
3889 (void *)&cmd_setlinkcheck_link_check,
3890 (void *)&cmd_setlinkcheck_mode,
3895 #ifdef RTE_NIC_BYPASS
3896 /* *** SET NIC BYPASS MODE *** */
3897 struct cmd_set_bypass_mode_result {
3898 cmdline_fixed_string_t set;
3899 cmdline_fixed_string_t bypass;
3900 cmdline_fixed_string_t mode;
3901 cmdline_fixed_string_t value;
3906 cmd_set_bypass_mode_parsed(void *parsed_result,
3907 __attribute__((unused)) struct cmdline *cl,
3908 __attribute__((unused)) void *data)
3910 struct cmd_set_bypass_mode_result *res = parsed_result;
3911 portid_t port_id = res->port_id;
3912 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3914 if (!strcmp(res->value, "bypass"))
3915 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3916 else if (!strcmp(res->value, "isolate"))
3917 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3919 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3921 /* Set the bypass mode for the relevant port. */
3922 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3923 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3927 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3928 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3930 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3931 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3933 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3934 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3936 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3937 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3938 value, "normal#bypass#isolate");
3939 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3940 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3943 cmdline_parse_inst_t cmd_set_bypass_mode = {
3944 .f = cmd_set_bypass_mode_parsed,
3945 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3946 "Set the NIC bypass mode for port_id",
3949 (void *)&cmd_setbypass_mode_set,
3950 (void *)&cmd_setbypass_mode_bypass,
3951 (void *)&cmd_setbypass_mode_mode,
3952 (void *)&cmd_setbypass_mode_value,
3953 (void *)&cmd_setbypass_mode_port,
3958 /* *** SET NIC BYPASS EVENT *** */
3959 struct cmd_set_bypass_event_result {
3960 cmdline_fixed_string_t set;
3961 cmdline_fixed_string_t bypass;
3962 cmdline_fixed_string_t event;
3963 cmdline_fixed_string_t event_value;
3964 cmdline_fixed_string_t mode;
3965 cmdline_fixed_string_t mode_value;
3970 cmd_set_bypass_event_parsed(void *parsed_result,
3971 __attribute__((unused)) struct cmdline *cl,
3972 __attribute__((unused)) void *data)
3975 struct cmd_set_bypass_event_result *res = parsed_result;
3976 portid_t port_id = res->port_id;
3977 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3978 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3980 if (!strcmp(res->event_value, "timeout"))
3981 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3982 else if (!strcmp(res->event_value, "os_on"))
3983 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3984 else if (!strcmp(res->event_value, "os_off"))
3985 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3986 else if (!strcmp(res->event_value, "power_on"))
3987 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3988 else if (!strcmp(res->event_value, "power_off"))
3989 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3991 bypass_event = RTE_BYPASS_EVENT_NONE;
3993 if (!strcmp(res->mode_value, "bypass"))
3994 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3995 else if (!strcmp(res->mode_value, "isolate"))
3996 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3998 bypass_mode = RTE_BYPASS_MODE_NORMAL;
4000 /* Set the watchdog timeout. */
4001 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
4004 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
4005 (rc = rte_eth_dev_wd_timeout_store(port_id,
4006 bypass_timeout)) != 0) {
4007 printf("Failed to set timeout value %u "
4008 "for port %d, errto code: %d.\n",
4009 bypass_timeout, port_id, rc);
4013 /* Set the bypass event to transition to bypass mode. */
4014 if (0 != rte_eth_dev_bypass_event_store(port_id,
4015 bypass_event, bypass_mode)) {
4016 printf("\t Failed to set bypass event for port = %d.\n", port_id);
4021 cmdline_parse_token_string_t cmd_setbypass_event_set =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4024 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4027 cmdline_parse_token_string_t cmd_setbypass_event_event =
4028 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4030 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4031 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4032 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4033 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4034 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4036 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4037 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4038 mode_value, "normal#bypass#isolate");
4039 cmdline_parse_token_num_t cmd_setbypass_event_port =
4040 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4043 cmdline_parse_inst_t cmd_set_bypass_event = {
4044 .f = cmd_set_bypass_event_parsed,
4045 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4046 "power_off mode normal|bypass|isolate <port_id>: "
4047 "Set the NIC bypass event mode for port_id",
4050 (void *)&cmd_setbypass_event_set,
4051 (void *)&cmd_setbypass_event_bypass,
4052 (void *)&cmd_setbypass_event_event,
4053 (void *)&cmd_setbypass_event_event_value,
4054 (void *)&cmd_setbypass_event_mode,
4055 (void *)&cmd_setbypass_event_mode_value,
4056 (void *)&cmd_setbypass_event_port,
4062 /* *** SET NIC BYPASS TIMEOUT *** */
4063 struct cmd_set_bypass_timeout_result {
4064 cmdline_fixed_string_t set;
4065 cmdline_fixed_string_t bypass;
4066 cmdline_fixed_string_t timeout;
4067 cmdline_fixed_string_t value;
4071 cmd_set_bypass_timeout_parsed(void *parsed_result,
4072 __attribute__((unused)) struct cmdline *cl,
4073 __attribute__((unused)) void *data)
4075 struct cmd_set_bypass_timeout_result *res = parsed_result;
4077 if (!strcmp(res->value, "1.5"))
4078 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4079 else if (!strcmp(res->value, "2"))
4080 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4081 else if (!strcmp(res->value, "3"))
4082 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4083 else if (!strcmp(res->value, "4"))
4084 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4085 else if (!strcmp(res->value, "8"))
4086 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4087 else if (!strcmp(res->value, "16"))
4088 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4089 else if (!strcmp(res->value, "32"))
4090 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4092 bypass_timeout = RTE_BYPASS_TMT_OFF;
4095 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4096 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4098 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4099 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4101 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4102 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4103 timeout, "timeout");
4104 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4105 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4106 value, "0#1.5#2#3#4#8#16#32");
4108 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4109 .f = cmd_set_bypass_timeout_parsed,
4110 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4111 "Set the NIC bypass watchdog timeout in seconds",
4114 (void *)&cmd_setbypass_timeout_set,
4115 (void *)&cmd_setbypass_timeout_bypass,
4116 (void *)&cmd_setbypass_timeout_timeout,
4117 (void *)&cmd_setbypass_timeout_value,
4122 /* *** SHOW NIC BYPASS MODE *** */
4123 struct cmd_show_bypass_config_result {
4124 cmdline_fixed_string_t show;
4125 cmdline_fixed_string_t bypass;
4126 cmdline_fixed_string_t config;
4131 cmd_show_bypass_config_parsed(void *parsed_result,
4132 __attribute__((unused)) struct cmdline *cl,
4133 __attribute__((unused)) void *data)
4135 struct cmd_show_bypass_config_result *res = parsed_result;
4136 uint32_t event_mode;
4137 uint32_t bypass_mode;
4138 portid_t port_id = res->port_id;
4139 uint32_t timeout = bypass_timeout;
4142 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4143 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4144 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4145 {"UNKNOWN", "normal", "bypass", "isolate"};
4146 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4153 int num_events = (sizeof events) / (sizeof events[0]);
4155 /* Display the bypass mode.*/
4156 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4157 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4161 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4162 bypass_mode = RTE_BYPASS_MODE_NONE;
4164 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4167 /* Display the bypass timeout.*/
4168 if (!RTE_BYPASS_TMT_VALID(timeout))
4169 timeout = RTE_BYPASS_TMT_OFF;
4171 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4173 /* Display the bypass events and associated modes. */
4174 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4176 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4177 printf("\tFailed to get bypass mode for event = %s\n",
4180 if (!RTE_BYPASS_MODE_VALID(event_mode))
4181 event_mode = RTE_BYPASS_MODE_NONE;
4183 printf("\tbypass event: %-16s = %s\n", events[i],
4189 cmdline_parse_token_string_t cmd_showbypass_config_show =
4190 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4192 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4193 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4195 cmdline_parse_token_string_t cmd_showbypass_config_config =
4196 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4198 cmdline_parse_token_num_t cmd_showbypass_config_port =
4199 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4202 cmdline_parse_inst_t cmd_show_bypass_config = {
4203 .f = cmd_show_bypass_config_parsed,
4204 .help_str = "show bypass config <port_id>: "
4205 "Show the NIC bypass config for port_id",
4208 (void *)&cmd_showbypass_config_show,
4209 (void *)&cmd_showbypass_config_bypass,
4210 (void *)&cmd_showbypass_config_config,
4211 (void *)&cmd_showbypass_config_port,
4217 #ifdef RTE_LIBRTE_PMD_BOND
4218 /* *** SET BONDING MODE *** */
4219 struct cmd_set_bonding_mode_result {
4220 cmdline_fixed_string_t set;
4221 cmdline_fixed_string_t bonding;
4222 cmdline_fixed_string_t mode;
4227 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4228 __attribute__((unused)) struct cmdline *cl,
4229 __attribute__((unused)) void *data)
4231 struct cmd_set_bonding_mode_result *res = parsed_result;
4232 portid_t port_id = res->port_id;
4234 /* Set the bonding mode for the relevant port. */
4235 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4236 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4239 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4240 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4242 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4243 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4244 bonding, "bonding");
4245 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4246 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4248 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4249 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4251 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4252 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4255 cmdline_parse_inst_t cmd_set_bonding_mode = {
4256 .f = cmd_set_bonding_mode_parsed,
4257 .help_str = "set bonding mode <mode_value> <port_id>: "
4258 "Set the bonding mode for port_id",
4261 (void *) &cmd_setbonding_mode_set,
4262 (void *) &cmd_setbonding_mode_bonding,
4263 (void *) &cmd_setbonding_mode_mode,
4264 (void *) &cmd_setbonding_mode_value,
4265 (void *) &cmd_setbonding_mode_port,
4270 /* *** SET BALANCE XMIT POLICY *** */
4271 struct cmd_set_bonding_balance_xmit_policy_result {
4272 cmdline_fixed_string_t set;
4273 cmdline_fixed_string_t bonding;
4274 cmdline_fixed_string_t balance_xmit_policy;
4276 cmdline_fixed_string_t policy;
4279 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4280 __attribute__((unused)) struct cmdline *cl,
4281 __attribute__((unused)) void *data)
4283 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4284 portid_t port_id = res->port_id;
4287 if (!strcmp(res->policy, "l2")) {
4288 policy = BALANCE_XMIT_POLICY_LAYER2;
4289 } else if (!strcmp(res->policy, "l23")) {
4290 policy = BALANCE_XMIT_POLICY_LAYER23;
4291 } else if (!strcmp(res->policy, "l34")) {
4292 policy = BALANCE_XMIT_POLICY_LAYER34;
4294 printf("\t Invalid xmit policy selection");
4298 /* Set the bonding mode for the relevant port. */
4299 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4300 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4305 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4306 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4308 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4309 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4310 bonding, "bonding");
4311 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4312 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4313 balance_xmit_policy, "balance_xmit_policy");
4314 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4315 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4317 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4318 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4319 policy, "l2#l23#l34");
4321 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4322 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4323 .help_str = "set bonding balance_xmit_policy <port_id> "
4325 "Set the bonding balance_xmit_policy for port_id",
4328 (void *)&cmd_setbonding_balance_xmit_policy_set,
4329 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4330 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4331 (void *)&cmd_setbonding_balance_xmit_policy_port,
4332 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4337 /* *** SHOW NIC BONDING CONFIGURATION *** */
4338 struct cmd_show_bonding_config_result {
4339 cmdline_fixed_string_t show;
4340 cmdline_fixed_string_t bonding;
4341 cmdline_fixed_string_t config;
4345 static void cmd_show_bonding_config_parsed(void *parsed_result,
4346 __attribute__((unused)) struct cmdline *cl,
4347 __attribute__((unused)) void *data)
4349 struct cmd_show_bonding_config_result *res = parsed_result;
4351 uint8_t slaves[RTE_MAX_ETHPORTS];
4352 int num_slaves, num_active_slaves;
4355 portid_t port_id = res->port_id;
4357 /* Display the bonding mode.*/
4358 bonding_mode = rte_eth_bond_mode_get(port_id);
4359 if (bonding_mode < 0) {
4360 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4363 printf("\tBonding mode: %d\n", bonding_mode);
4365 if (bonding_mode == BONDING_MODE_BALANCE) {
4366 int balance_xmit_policy;
4368 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4369 if (balance_xmit_policy < 0) {
4370 printf("\tFailed to get balance xmit policy for port = %d\n",
4374 printf("\tBalance Xmit Policy: ");
4376 switch (balance_xmit_policy) {
4377 case BALANCE_XMIT_POLICY_LAYER2:
4378 printf("BALANCE_XMIT_POLICY_LAYER2");
4380 case BALANCE_XMIT_POLICY_LAYER23:
4381 printf("BALANCE_XMIT_POLICY_LAYER23");
4383 case BALANCE_XMIT_POLICY_LAYER34:
4384 printf("BALANCE_XMIT_POLICY_LAYER34");
4391 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4393 if (num_slaves < 0) {
4394 printf("\tFailed to get slave list for port = %d\n", port_id);
4397 if (num_slaves > 0) {
4398 printf("\tSlaves (%d): [", num_slaves);
4399 for (i = 0; i < num_slaves - 1; i++)
4400 printf("%d ", slaves[i]);
4402 printf("%d]\n", slaves[num_slaves - 1]);
4404 printf("\tSlaves: []\n");
4408 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4411 if (num_active_slaves < 0) {
4412 printf("\tFailed to get active slave list for port = %d\n", port_id);
4415 if (num_active_slaves > 0) {
4416 printf("\tActive Slaves (%d): [", num_active_slaves);
4417 for (i = 0; i < num_active_slaves - 1; i++)
4418 printf("%d ", slaves[i]);
4420 printf("%d]\n", slaves[num_active_slaves - 1]);
4423 printf("\tActive Slaves: []\n");
4427 primary_id = rte_eth_bond_primary_get(port_id);
4428 if (primary_id < 0) {
4429 printf("\tFailed to get primary slave for port = %d\n", port_id);
4432 printf("\tPrimary: [%d]\n", primary_id);
4436 cmdline_parse_token_string_t cmd_showbonding_config_show =
4437 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4439 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4440 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4441 bonding, "bonding");
4442 cmdline_parse_token_string_t cmd_showbonding_config_config =
4443 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4445 cmdline_parse_token_num_t cmd_showbonding_config_port =
4446 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4449 cmdline_parse_inst_t cmd_show_bonding_config = {
4450 .f = cmd_show_bonding_config_parsed,
4451 .help_str = "show bonding config <port_id>: "
4452 "Show the bonding config for port_id",
4455 (void *)&cmd_showbonding_config_show,
4456 (void *)&cmd_showbonding_config_bonding,
4457 (void *)&cmd_showbonding_config_config,
4458 (void *)&cmd_showbonding_config_port,
4463 /* *** SET BONDING PRIMARY *** */
4464 struct cmd_set_bonding_primary_result {
4465 cmdline_fixed_string_t set;
4466 cmdline_fixed_string_t bonding;
4467 cmdline_fixed_string_t primary;
4472 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4473 __attribute__((unused)) struct cmdline *cl,
4474 __attribute__((unused)) void *data)
4476 struct cmd_set_bonding_primary_result *res = parsed_result;
4477 portid_t master_port_id = res->port_id;
4478 portid_t slave_port_id = res->slave_id;
4480 /* Set the primary slave for a bonded device. */
4481 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4482 printf("\t Failed to set primary slave for port = %d.\n",
4489 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4490 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4492 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4493 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4494 bonding, "bonding");
4495 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4496 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4497 primary, "primary");
4498 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4499 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4501 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4502 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4505 cmdline_parse_inst_t cmd_set_bonding_primary = {
4506 .f = cmd_set_bonding_primary_parsed,
4507 .help_str = "set bonding primary <slave_id> <port_id>: "
4508 "Set the primary slave for port_id",
4511 (void *)&cmd_setbonding_primary_set,
4512 (void *)&cmd_setbonding_primary_bonding,
4513 (void *)&cmd_setbonding_primary_primary,
4514 (void *)&cmd_setbonding_primary_slave,
4515 (void *)&cmd_setbonding_primary_port,
4520 /* *** ADD SLAVE *** */
4521 struct cmd_add_bonding_slave_result {
4522 cmdline_fixed_string_t add;
4523 cmdline_fixed_string_t bonding;
4524 cmdline_fixed_string_t slave;
4529 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4530 __attribute__((unused)) struct cmdline *cl,
4531 __attribute__((unused)) void *data)
4533 struct cmd_add_bonding_slave_result *res = parsed_result;
4534 portid_t master_port_id = res->port_id;
4535 portid_t slave_port_id = res->slave_id;
4537 /* Set the primary slave for a bonded device. */
4538 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4539 printf("\t Failed to add slave %d to master port = %d.\n",
4540 slave_port_id, master_port_id);
4544 set_port_slave_flag(slave_port_id);
4547 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4548 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4550 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4551 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4552 bonding, "bonding");
4553 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4554 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4556 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4557 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4559 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4560 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4563 cmdline_parse_inst_t cmd_add_bonding_slave = {
4564 .f = cmd_add_bonding_slave_parsed,
4565 .help_str = "add bonding slave <slave_id> <port_id>: "
4566 "Add a slave device to a bonded device",
4569 (void *)&cmd_addbonding_slave_add,
4570 (void *)&cmd_addbonding_slave_bonding,
4571 (void *)&cmd_addbonding_slave_slave,
4572 (void *)&cmd_addbonding_slave_slaveid,
4573 (void *)&cmd_addbonding_slave_port,
4578 /* *** REMOVE SLAVE *** */
4579 struct cmd_remove_bonding_slave_result {
4580 cmdline_fixed_string_t remove;
4581 cmdline_fixed_string_t bonding;
4582 cmdline_fixed_string_t slave;
4587 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4588 __attribute__((unused)) struct cmdline *cl,
4589 __attribute__((unused)) void *data)
4591 struct cmd_remove_bonding_slave_result *res = parsed_result;
4592 portid_t master_port_id = res->port_id;
4593 portid_t slave_port_id = res->slave_id;
4595 /* Set the primary slave for a bonded device. */
4596 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4597 printf("\t Failed to remove slave %d from master port = %d.\n",
4598 slave_port_id, master_port_id);
4602 clear_port_slave_flag(slave_port_id);
4605 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4606 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4608 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4609 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4610 bonding, "bonding");
4611 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4612 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4614 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4615 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4617 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4618 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4621 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4622 .f = cmd_remove_bonding_slave_parsed,
4623 .help_str = "remove bonding slave <slave_id> <port_id>: "
4624 "Remove a slave device from a bonded device",
4627 (void *)&cmd_removebonding_slave_remove,
4628 (void *)&cmd_removebonding_slave_bonding,
4629 (void *)&cmd_removebonding_slave_slave,
4630 (void *)&cmd_removebonding_slave_slaveid,
4631 (void *)&cmd_removebonding_slave_port,
4636 /* *** CREATE BONDED DEVICE *** */
4637 struct cmd_create_bonded_device_result {
4638 cmdline_fixed_string_t create;
4639 cmdline_fixed_string_t bonded;
4640 cmdline_fixed_string_t device;
4645 static int bond_dev_num = 0;
4647 static void cmd_create_bonded_device_parsed(void *parsed_result,
4648 __attribute__((unused)) struct cmdline *cl,
4649 __attribute__((unused)) void *data)
4651 struct cmd_create_bonded_device_result *res = parsed_result;
4652 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4655 if (test_done == 0) {
4656 printf("Please stop forwarding first\n");
4660 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4663 /* Create a new bonded device. */
4664 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4666 printf("\t Failed to create bonded device.\n");
4669 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4672 /* Update number of ports */
4673 nb_ports = rte_eth_dev_count();
4674 reconfig(port_id, res->socket);
4675 rte_eth_promiscuous_enable(port_id);
4680 cmdline_parse_token_string_t cmd_createbonded_device_create =
4681 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4683 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4684 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4686 cmdline_parse_token_string_t cmd_createbonded_device_device =
4687 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4689 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4690 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4692 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4693 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4696 cmdline_parse_inst_t cmd_create_bonded_device = {
4697 .f = cmd_create_bonded_device_parsed,
4698 .help_str = "create bonded device <mode> <socket>: "
4699 "Create a new bonded device with specific bonding mode and socket",
4702 (void *)&cmd_createbonded_device_create,
4703 (void *)&cmd_createbonded_device_bonded,
4704 (void *)&cmd_createbonded_device_device,
4705 (void *)&cmd_createbonded_device_mode,
4706 (void *)&cmd_createbonded_device_socket,
4711 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4712 struct cmd_set_bond_mac_addr_result {
4713 cmdline_fixed_string_t set;
4714 cmdline_fixed_string_t bonding;
4715 cmdline_fixed_string_t mac_addr;
4717 struct ether_addr address;
4720 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4721 __attribute__((unused)) struct cmdline *cl,
4722 __attribute__((unused)) void *data)
4724 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4727 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4730 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4732 /* check the return value and print it if is < 0 */
4734 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4737 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4738 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4739 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4740 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4742 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4743 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4745 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4746 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4747 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4748 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4750 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4751 .f = cmd_set_bond_mac_addr_parsed,
4753 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4755 (void *)&cmd_set_bond_mac_addr_set,
4756 (void *)&cmd_set_bond_mac_addr_bonding,
4757 (void *)&cmd_set_bond_mac_addr_mac,
4758 (void *)&cmd_set_bond_mac_addr_portnum,
4759 (void *)&cmd_set_bond_mac_addr_addr,
4765 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4766 struct cmd_set_bond_mon_period_result {
4767 cmdline_fixed_string_t set;
4768 cmdline_fixed_string_t bonding;
4769 cmdline_fixed_string_t mon_period;
4774 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4775 __attribute__((unused)) struct cmdline *cl,
4776 __attribute__((unused)) void *data)
4778 struct cmd_set_bond_mon_period_result *res = parsed_result;
4781 if (res->port_num >= nb_ports) {
4782 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4786 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4788 /* check the return value and print it if is < 0 */
4790 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4793 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4794 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4796 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4797 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4798 bonding, "bonding");
4799 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4800 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4801 mon_period, "mon_period");
4802 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4803 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4805 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4806 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4809 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4810 .f = cmd_set_bond_mon_period_parsed,
4812 .help_str = "set bonding mon_period <port_id> <period_ms>",
4814 (void *)&cmd_set_bond_mon_period_set,
4815 (void *)&cmd_set_bond_mon_period_bonding,
4816 (void *)&cmd_set_bond_mon_period_mon_period,
4817 (void *)&cmd_set_bond_mon_period_portnum,
4818 (void *)&cmd_set_bond_mon_period_period_ms,
4823 #endif /* RTE_LIBRTE_PMD_BOND */
4825 /* *** SET FORWARDING MODE *** */
4826 struct cmd_set_fwd_mode_result {
4827 cmdline_fixed_string_t set;
4828 cmdline_fixed_string_t fwd;
4829 cmdline_fixed_string_t mode;
4832 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4833 __attribute__((unused)) struct cmdline *cl,
4834 __attribute__((unused)) void *data)
4836 struct cmd_set_fwd_mode_result *res = parsed_result;
4839 set_pkt_forwarding_mode(res->mode);
4842 cmdline_parse_token_string_t cmd_setfwd_set =
4843 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4844 cmdline_parse_token_string_t cmd_setfwd_fwd =
4845 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4846 cmdline_parse_token_string_t cmd_setfwd_mode =
4847 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4848 "" /* defined at init */);
4850 cmdline_parse_inst_t cmd_set_fwd_mode = {
4851 .f = cmd_set_fwd_mode_parsed,
4853 .help_str = NULL, /* defined at init */
4855 (void *)&cmd_setfwd_set,
4856 (void *)&cmd_setfwd_fwd,
4857 (void *)&cmd_setfwd_mode,
4862 static void cmd_set_fwd_mode_init(void)
4865 static char token[128];
4866 static char help[256];
4867 cmdline_parse_token_string_t *token_struct;
4869 modes = list_pkt_forwarding_modes();
4870 snprintf(help, sizeof(help), "set fwd %s: "
4871 "Set packet forwarding mode", modes);
4872 cmd_set_fwd_mode.help_str = help;
4874 /* string token separator is # */
4875 for (c = token; *modes != '\0'; modes++)
4880 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4881 token_struct->string_data.str = token;
4884 /* *** SET RETRY FORWARDING MODE *** */
4885 struct cmd_set_fwd_retry_mode_result {
4886 cmdline_fixed_string_t set;
4887 cmdline_fixed_string_t fwd;
4888 cmdline_fixed_string_t mode;
4889 cmdline_fixed_string_t retry;
4892 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4893 __attribute__((unused)) struct cmdline *cl,
4894 __attribute__((unused)) void *data)
4896 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4899 set_pkt_forwarding_mode(res->mode);
4902 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4903 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4905 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4906 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4908 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4909 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4911 "" /* defined at init */);
4912 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4913 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4916 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4917 .f = cmd_set_fwd_retry_mode_parsed,
4919 .help_str = NULL, /* defined at init */
4921 (void *)&cmd_setfwd_retry_set,
4922 (void *)&cmd_setfwd_retry_fwd,
4923 (void *)&cmd_setfwd_retry_mode,
4924 (void *)&cmd_setfwd_retry_retry,
4929 static void cmd_set_fwd_retry_mode_init(void)
4932 static char token[128];
4933 static char help[256];
4934 cmdline_parse_token_string_t *token_struct;
4936 modes = list_pkt_forwarding_retry_modes();
4937 snprintf(help, sizeof(help), "set fwd %s retry: "
4938 "Set packet forwarding mode with retry", modes);
4939 cmd_set_fwd_retry_mode.help_str = help;
4941 /* string token separator is # */
4942 for (c = token; *modes != '\0'; modes++)
4947 token_struct = (cmdline_parse_token_string_t *)
4948 cmd_set_fwd_retry_mode.tokens[2];
4949 token_struct->string_data.str = token;
4952 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4953 struct cmd_set_burst_tx_retry_result {
4954 cmdline_fixed_string_t set;
4955 cmdline_fixed_string_t burst;
4956 cmdline_fixed_string_t tx;
4957 cmdline_fixed_string_t delay;
4959 cmdline_fixed_string_t retry;
4963 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4964 __attribute__((unused)) struct cmdline *cl,
4965 __attribute__((unused)) void *data)
4967 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4969 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4970 && !strcmp(res->tx, "tx")) {
4971 if (!strcmp(res->delay, "delay"))
4972 burst_tx_delay_time = res->time;
4973 if (!strcmp(res->retry, "retry"))
4974 burst_tx_retry_num = res->retry_num;
4979 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4980 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4981 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4984 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4986 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4987 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4988 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4989 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4990 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4991 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4992 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4993 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4995 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4996 .f = cmd_set_burst_tx_retry_parsed,
4997 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4999 (void *)&cmd_set_burst_tx_retry_set,
5000 (void *)&cmd_set_burst_tx_retry_burst,
5001 (void *)&cmd_set_burst_tx_retry_tx,
5002 (void *)&cmd_set_burst_tx_retry_delay,
5003 (void *)&cmd_set_burst_tx_retry_time,
5004 (void *)&cmd_set_burst_tx_retry_retry,
5005 (void *)&cmd_set_burst_tx_retry_retry_num,
5010 /* *** SET PROMISC MODE *** */
5011 struct cmd_set_promisc_mode_result {
5012 cmdline_fixed_string_t set;
5013 cmdline_fixed_string_t promisc;
5014 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5015 uint8_t port_num; /* valid if "allports" argument == 0 */
5016 cmdline_fixed_string_t mode;
5019 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5020 __attribute__((unused)) struct cmdline *cl,
5023 struct cmd_set_promisc_mode_result *res = parsed_result;
5027 if (!strcmp(res->mode, "on"))
5034 RTE_ETH_FOREACH_DEV(i) {
5036 rte_eth_promiscuous_enable(i);
5038 rte_eth_promiscuous_disable(i);
5043 rte_eth_promiscuous_enable(res->port_num);
5045 rte_eth_promiscuous_disable(res->port_num);
5049 cmdline_parse_token_string_t cmd_setpromisc_set =
5050 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5051 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5052 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5054 cmdline_parse_token_string_t cmd_setpromisc_portall =
5055 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5057 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5058 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5060 cmdline_parse_token_string_t cmd_setpromisc_mode =
5061 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5064 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5065 .f = cmd_set_promisc_mode_parsed,
5067 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5069 (void *)&cmd_setpromisc_set,
5070 (void *)&cmd_setpromisc_promisc,
5071 (void *)&cmd_setpromisc_portall,
5072 (void *)&cmd_setpromisc_mode,
5077 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5078 .f = cmd_set_promisc_mode_parsed,
5080 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5082 (void *)&cmd_setpromisc_set,
5083 (void *)&cmd_setpromisc_promisc,
5084 (void *)&cmd_setpromisc_portnum,
5085 (void *)&cmd_setpromisc_mode,
5090 /* *** SET ALLMULTI MODE *** */
5091 struct cmd_set_allmulti_mode_result {
5092 cmdline_fixed_string_t set;
5093 cmdline_fixed_string_t allmulti;
5094 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5095 uint8_t port_num; /* valid if "allports" argument == 0 */
5096 cmdline_fixed_string_t mode;
5099 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5100 __attribute__((unused)) struct cmdline *cl,
5103 struct cmd_set_allmulti_mode_result *res = parsed_result;
5107 if (!strcmp(res->mode, "on"))
5114 RTE_ETH_FOREACH_DEV(i) {
5116 rte_eth_allmulticast_enable(i);
5118 rte_eth_allmulticast_disable(i);
5123 rte_eth_allmulticast_enable(res->port_num);
5125 rte_eth_allmulticast_disable(res->port_num);
5129 cmdline_parse_token_string_t cmd_setallmulti_set =
5130 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5131 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5132 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5134 cmdline_parse_token_string_t cmd_setallmulti_portall =
5135 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5137 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5138 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5140 cmdline_parse_token_string_t cmd_setallmulti_mode =
5141 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5144 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5145 .f = cmd_set_allmulti_mode_parsed,
5147 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5149 (void *)&cmd_setallmulti_set,
5150 (void *)&cmd_setallmulti_allmulti,
5151 (void *)&cmd_setallmulti_portall,
5152 (void *)&cmd_setallmulti_mode,
5157 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5158 .f = cmd_set_allmulti_mode_parsed,
5160 .help_str = "set allmulti <port_id> on|off: "
5161 "Set allmulti mode on port_id",
5163 (void *)&cmd_setallmulti_set,
5164 (void *)&cmd_setallmulti_allmulti,
5165 (void *)&cmd_setallmulti_portnum,
5166 (void *)&cmd_setallmulti_mode,
5171 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5172 struct cmd_link_flow_ctrl_set_result {
5173 cmdline_fixed_string_t set;
5174 cmdline_fixed_string_t flow_ctrl;
5175 cmdline_fixed_string_t rx;
5176 cmdline_fixed_string_t rx_lfc_mode;
5177 cmdline_fixed_string_t tx;
5178 cmdline_fixed_string_t tx_lfc_mode;
5179 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5180 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5181 cmdline_fixed_string_t autoneg_str;
5182 cmdline_fixed_string_t autoneg;
5183 cmdline_fixed_string_t hw_str;
5184 uint32_t high_water;
5185 cmdline_fixed_string_t lw_str;
5187 cmdline_fixed_string_t pt_str;
5188 uint16_t pause_time;
5189 cmdline_fixed_string_t xon_str;
5194 cmdline_parse_token_string_t cmd_lfc_set_set =
5195 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5197 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5198 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5199 flow_ctrl, "flow_ctrl");
5200 cmdline_parse_token_string_t cmd_lfc_set_rx =
5201 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5203 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5204 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5205 rx_lfc_mode, "on#off");
5206 cmdline_parse_token_string_t cmd_lfc_set_tx =
5207 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5209 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5210 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5211 tx_lfc_mode, "on#off");
5212 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5213 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5214 hw_str, "high_water");
5215 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5216 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5217 high_water, UINT32);
5218 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5219 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5220 lw_str, "low_water");
5221 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5222 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5224 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5225 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5226 pt_str, "pause_time");
5227 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5228 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5229 pause_time, UINT16);
5230 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5231 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5232 xon_str, "send_xon");
5233 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5234 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5236 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5237 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5238 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5239 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5240 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5241 mac_ctrl_frame_fwd_mode, "on#off");
5242 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5243 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5244 autoneg_str, "autoneg");
5245 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5246 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5248 cmdline_parse_token_num_t cmd_lfc_set_portid =
5249 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5252 /* forward declaration */
5254 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5257 cmdline_parse_inst_t cmd_link_flow_control_set = {
5258 .f = cmd_link_flow_ctrl_set_parsed,
5260 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5261 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5262 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5264 (void *)&cmd_lfc_set_set,
5265 (void *)&cmd_lfc_set_flow_ctrl,
5266 (void *)&cmd_lfc_set_rx,
5267 (void *)&cmd_lfc_set_rx_mode,
5268 (void *)&cmd_lfc_set_tx,
5269 (void *)&cmd_lfc_set_tx_mode,
5270 (void *)&cmd_lfc_set_high_water,
5271 (void *)&cmd_lfc_set_low_water,
5272 (void *)&cmd_lfc_set_pause_time,
5273 (void *)&cmd_lfc_set_send_xon,
5274 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5275 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5276 (void *)&cmd_lfc_set_autoneg_str,
5277 (void *)&cmd_lfc_set_autoneg,
5278 (void *)&cmd_lfc_set_portid,
5283 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5284 .f = cmd_link_flow_ctrl_set_parsed,
5285 .data = (void *)&cmd_link_flow_control_set_rx,
5286 .help_str = "set flow_ctrl rx on|off <port_id>: "
5287 "Change rx flow control parameter",
5289 (void *)&cmd_lfc_set_set,
5290 (void *)&cmd_lfc_set_flow_ctrl,
5291 (void *)&cmd_lfc_set_rx,
5292 (void *)&cmd_lfc_set_rx_mode,
5293 (void *)&cmd_lfc_set_portid,
5298 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5299 .f = cmd_link_flow_ctrl_set_parsed,
5300 .data = (void *)&cmd_link_flow_control_set_tx,
5301 .help_str = "set flow_ctrl tx on|off <port_id>: "
5302 "Change tx flow control parameter",
5304 (void *)&cmd_lfc_set_set,
5305 (void *)&cmd_lfc_set_flow_ctrl,
5306 (void *)&cmd_lfc_set_tx,
5307 (void *)&cmd_lfc_set_tx_mode,
5308 (void *)&cmd_lfc_set_portid,
5313 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5314 .f = cmd_link_flow_ctrl_set_parsed,
5315 .data = (void *)&cmd_link_flow_control_set_hw,
5316 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5317 "Change high water flow control parameter",
5319 (void *)&cmd_lfc_set_set,
5320 (void *)&cmd_lfc_set_flow_ctrl,
5321 (void *)&cmd_lfc_set_high_water_str,
5322 (void *)&cmd_lfc_set_high_water,
5323 (void *)&cmd_lfc_set_portid,
5328 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5329 .f = cmd_link_flow_ctrl_set_parsed,
5330 .data = (void *)&cmd_link_flow_control_set_lw,
5331 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5332 "Change low water flow control parameter",
5334 (void *)&cmd_lfc_set_set,
5335 (void *)&cmd_lfc_set_flow_ctrl,
5336 (void *)&cmd_lfc_set_low_water_str,
5337 (void *)&cmd_lfc_set_low_water,
5338 (void *)&cmd_lfc_set_portid,
5343 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5344 .f = cmd_link_flow_ctrl_set_parsed,
5345 .data = (void *)&cmd_link_flow_control_set_pt,
5346 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5347 "Change pause time flow control parameter",
5349 (void *)&cmd_lfc_set_set,
5350 (void *)&cmd_lfc_set_flow_ctrl,
5351 (void *)&cmd_lfc_set_pause_time_str,
5352 (void *)&cmd_lfc_set_pause_time,
5353 (void *)&cmd_lfc_set_portid,
5358 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5359 .f = cmd_link_flow_ctrl_set_parsed,
5360 .data = (void *)&cmd_link_flow_control_set_xon,
5361 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5362 "Change send_xon flow control parameter",
5364 (void *)&cmd_lfc_set_set,
5365 (void *)&cmd_lfc_set_flow_ctrl,
5366 (void *)&cmd_lfc_set_send_xon_str,
5367 (void *)&cmd_lfc_set_send_xon,
5368 (void *)&cmd_lfc_set_portid,
5373 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5374 .f = cmd_link_flow_ctrl_set_parsed,
5375 .data = (void *)&cmd_link_flow_control_set_macfwd,
5376 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5377 "Change mac ctrl fwd flow control parameter",
5379 (void *)&cmd_lfc_set_set,
5380 (void *)&cmd_lfc_set_flow_ctrl,
5381 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5382 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5383 (void *)&cmd_lfc_set_portid,
5388 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5389 .f = cmd_link_flow_ctrl_set_parsed,
5390 .data = (void *)&cmd_link_flow_control_set_autoneg,
5391 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5392 "Change autoneg flow control parameter",
5394 (void *)&cmd_lfc_set_set,
5395 (void *)&cmd_lfc_set_flow_ctrl,
5396 (void *)&cmd_lfc_set_autoneg_str,
5397 (void *)&cmd_lfc_set_autoneg,
5398 (void *)&cmd_lfc_set_portid,
5404 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5405 __attribute__((unused)) struct cmdline *cl,
5408 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5409 cmdline_parse_inst_t *cmd = data;
5410 struct rte_eth_fc_conf fc_conf;
5416 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5417 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5418 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5419 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5421 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5422 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5425 /* Partial command line, retrieve current configuration */
5427 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5429 printf("cannot get current flow ctrl parameters, return"
5430 "code = %d\n", ret);
5434 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5435 (fc_conf.mode == RTE_FC_FULL))
5437 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5438 (fc_conf.mode == RTE_FC_FULL))
5442 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5443 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5445 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5446 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5448 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5450 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5451 fc_conf.high_water = res->high_water;
5453 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5454 fc_conf.low_water = res->low_water;
5456 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5457 fc_conf.pause_time = res->pause_time;
5459 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5460 fc_conf.send_xon = res->send_xon;
5462 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5463 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5464 fc_conf.mac_ctrl_frame_fwd = 1;
5466 fc_conf.mac_ctrl_frame_fwd = 0;
5469 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5470 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5472 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5474 printf("bad flow contrl parameter, return code = %d \n", ret);
5477 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5478 struct cmd_priority_flow_ctrl_set_result {
5479 cmdline_fixed_string_t set;
5480 cmdline_fixed_string_t pfc_ctrl;
5481 cmdline_fixed_string_t rx;
5482 cmdline_fixed_string_t rx_pfc_mode;
5483 cmdline_fixed_string_t tx;
5484 cmdline_fixed_string_t tx_pfc_mode;
5485 uint32_t high_water;
5487 uint16_t pause_time;
5493 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5494 __attribute__((unused)) struct cmdline *cl,
5495 __attribute__((unused)) void *data)
5497 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5498 struct rte_eth_pfc_conf pfc_conf;
5499 int rx_fc_enable, tx_fc_enable;
5503 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5504 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5505 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5506 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5508 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5509 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5512 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5513 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5514 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5515 pfc_conf.fc.high_water = res->high_water;
5516 pfc_conf.fc.low_water = res->low_water;
5517 pfc_conf.fc.pause_time = res->pause_time;
5518 pfc_conf.priority = res->priority;
5520 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5522 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5525 cmdline_parse_token_string_t cmd_pfc_set_set =
5526 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5528 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5529 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5530 pfc_ctrl, "pfc_ctrl");
5531 cmdline_parse_token_string_t cmd_pfc_set_rx =
5532 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5534 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5535 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5536 rx_pfc_mode, "on#off");
5537 cmdline_parse_token_string_t cmd_pfc_set_tx =
5538 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5540 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5541 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5542 tx_pfc_mode, "on#off");
5543 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5544 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5545 high_water, UINT32);
5546 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5547 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5549 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5550 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5551 pause_time, UINT16);
5552 cmdline_parse_token_num_t cmd_pfc_set_priority =
5553 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5555 cmdline_parse_token_num_t cmd_pfc_set_portid =
5556 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5559 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5560 .f = cmd_priority_flow_ctrl_set_parsed,
5562 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5563 "<pause_time> <priority> <port_id>: "
5564 "Configure the Ethernet priority flow control",
5566 (void *)&cmd_pfc_set_set,
5567 (void *)&cmd_pfc_set_flow_ctrl,
5568 (void *)&cmd_pfc_set_rx,
5569 (void *)&cmd_pfc_set_rx_mode,
5570 (void *)&cmd_pfc_set_tx,
5571 (void *)&cmd_pfc_set_tx_mode,
5572 (void *)&cmd_pfc_set_high_water,
5573 (void *)&cmd_pfc_set_low_water,
5574 (void *)&cmd_pfc_set_pause_time,
5575 (void *)&cmd_pfc_set_priority,
5576 (void *)&cmd_pfc_set_portid,
5581 /* *** RESET CONFIGURATION *** */
5582 struct cmd_reset_result {
5583 cmdline_fixed_string_t reset;
5584 cmdline_fixed_string_t def;
5587 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5589 __attribute__((unused)) void *data)
5591 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5592 set_def_fwd_config();
5595 cmdline_parse_token_string_t cmd_reset_set =
5596 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5597 cmdline_parse_token_string_t cmd_reset_def =
5598 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5601 cmdline_parse_inst_t cmd_reset = {
5602 .f = cmd_reset_parsed,
5604 .help_str = "set default: Reset default forwarding configuration",
5606 (void *)&cmd_reset_set,
5607 (void *)&cmd_reset_def,
5612 /* *** START FORWARDING *** */
5613 struct cmd_start_result {
5614 cmdline_fixed_string_t start;
5617 cmdline_parse_token_string_t cmd_start_start =
5618 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5620 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5621 __attribute__((unused)) struct cmdline *cl,
5622 __attribute__((unused)) void *data)
5624 start_packet_forwarding(0);
5627 cmdline_parse_inst_t cmd_start = {
5628 .f = cmd_start_parsed,
5630 .help_str = "start: Start packet forwarding",
5632 (void *)&cmd_start_start,
5637 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5638 struct cmd_start_tx_first_result {
5639 cmdline_fixed_string_t start;
5640 cmdline_fixed_string_t tx_first;
5644 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5645 __attribute__((unused)) struct cmdline *cl,
5646 __attribute__((unused)) void *data)
5648 start_packet_forwarding(1);
5651 cmdline_parse_token_string_t cmd_start_tx_first_start =
5652 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5654 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5655 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5656 tx_first, "tx_first");
5658 cmdline_parse_inst_t cmd_start_tx_first = {
5659 .f = cmd_start_tx_first_parsed,
5661 .help_str = "start tx_first: Start packet forwarding, "
5662 "after sending 1 burst of packets",
5664 (void *)&cmd_start_tx_first_start,
5665 (void *)&cmd_start_tx_first_tx_first,
5670 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5671 struct cmd_start_tx_first_n_result {
5672 cmdline_fixed_string_t start;
5673 cmdline_fixed_string_t tx_first;
5678 cmd_start_tx_first_n_parsed(void *parsed_result,
5679 __attribute__((unused)) struct cmdline *cl,
5680 __attribute__((unused)) void *data)
5682 struct cmd_start_tx_first_n_result *res = parsed_result;
5684 start_packet_forwarding(res->tx_num);
5687 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5688 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5690 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5691 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5692 tx_first, "tx_first");
5693 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5694 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5697 cmdline_parse_inst_t cmd_start_tx_first_n = {
5698 .f = cmd_start_tx_first_n_parsed,
5700 .help_str = "start tx_first <num>: "
5701 "packet forwarding, after sending <num> bursts of packets",
5703 (void *)&cmd_start_tx_first_n_start,
5704 (void *)&cmd_start_tx_first_n_tx_first,
5705 (void *)&cmd_start_tx_first_n_tx_num,
5710 /* *** SET LINK UP *** */
5711 struct cmd_set_link_up_result {
5712 cmdline_fixed_string_t set;
5713 cmdline_fixed_string_t link_up;
5714 cmdline_fixed_string_t port;
5718 cmdline_parse_token_string_t cmd_set_link_up_set =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5720 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5721 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5723 cmdline_parse_token_string_t cmd_set_link_up_port =
5724 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5725 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5726 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5728 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5729 __attribute__((unused)) struct cmdline *cl,
5730 __attribute__((unused)) void *data)
5732 struct cmd_set_link_up_result *res = parsed_result;
5733 dev_set_link_up(res->port_id);
5736 cmdline_parse_inst_t cmd_set_link_up = {
5737 .f = cmd_set_link_up_parsed,
5739 .help_str = "set link-up port <port id>",
5741 (void *)&cmd_set_link_up_set,
5742 (void *)&cmd_set_link_up_link_up,
5743 (void *)&cmd_set_link_up_port,
5744 (void *)&cmd_set_link_up_port_id,
5749 /* *** SET LINK DOWN *** */
5750 struct cmd_set_link_down_result {
5751 cmdline_fixed_string_t set;
5752 cmdline_fixed_string_t link_down;
5753 cmdline_fixed_string_t port;
5757 cmdline_parse_token_string_t cmd_set_link_down_set =
5758 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5759 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5760 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5762 cmdline_parse_token_string_t cmd_set_link_down_port =
5763 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5764 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5765 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5767 static void cmd_set_link_down_parsed(
5768 __attribute__((unused)) void *parsed_result,
5769 __attribute__((unused)) struct cmdline *cl,
5770 __attribute__((unused)) void *data)
5772 struct cmd_set_link_down_result *res = parsed_result;
5773 dev_set_link_down(res->port_id);
5776 cmdline_parse_inst_t cmd_set_link_down = {
5777 .f = cmd_set_link_down_parsed,
5779 .help_str = "set link-down port <port id>",
5781 (void *)&cmd_set_link_down_set,
5782 (void *)&cmd_set_link_down_link_down,
5783 (void *)&cmd_set_link_down_port,
5784 (void *)&cmd_set_link_down_port_id,
5789 /* *** SHOW CFG *** */
5790 struct cmd_showcfg_result {
5791 cmdline_fixed_string_t show;
5792 cmdline_fixed_string_t cfg;
5793 cmdline_fixed_string_t what;
5796 static void cmd_showcfg_parsed(void *parsed_result,
5797 __attribute__((unused)) struct cmdline *cl,
5798 __attribute__((unused)) void *data)
5800 struct cmd_showcfg_result *res = parsed_result;
5801 if (!strcmp(res->what, "rxtx"))
5802 rxtx_config_display();
5803 else if (!strcmp(res->what, "cores"))
5804 fwd_lcores_config_display();
5805 else if (!strcmp(res->what, "fwd"))
5806 pkt_fwd_config_display(&cur_fwd_config);
5807 else if (!strcmp(res->what, "txpkts"))
5808 show_tx_pkt_segments();
5811 cmdline_parse_token_string_t cmd_showcfg_show =
5812 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5813 cmdline_parse_token_string_t cmd_showcfg_port =
5814 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5815 cmdline_parse_token_string_t cmd_showcfg_what =
5816 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5817 "rxtx#cores#fwd#txpkts");
5819 cmdline_parse_inst_t cmd_showcfg = {
5820 .f = cmd_showcfg_parsed,
5822 .help_str = "show config rxtx|cores|fwd|txpkts",
5824 (void *)&cmd_showcfg_show,
5825 (void *)&cmd_showcfg_port,
5826 (void *)&cmd_showcfg_what,
5831 /* *** SHOW ALL PORT INFO *** */
5832 struct cmd_showportall_result {
5833 cmdline_fixed_string_t show;
5834 cmdline_fixed_string_t port;
5835 cmdline_fixed_string_t what;
5836 cmdline_fixed_string_t all;
5839 static void cmd_showportall_parsed(void *parsed_result,
5840 __attribute__((unused)) struct cmdline *cl,
5841 __attribute__((unused)) void *data)
5845 struct cmd_showportall_result *res = parsed_result;
5846 if (!strcmp(res->show, "clear")) {
5847 if (!strcmp(res->what, "stats"))
5848 RTE_ETH_FOREACH_DEV(i)
5850 else if (!strcmp(res->what, "xstats"))
5851 RTE_ETH_FOREACH_DEV(i)
5852 nic_xstats_clear(i);
5853 } else if (!strcmp(res->what, "info"))
5854 RTE_ETH_FOREACH_DEV(i)
5855 port_infos_display(i);
5856 else if (!strcmp(res->what, "stats"))
5857 RTE_ETH_FOREACH_DEV(i)
5858 nic_stats_display(i);
5859 else if (!strcmp(res->what, "xstats"))
5860 RTE_ETH_FOREACH_DEV(i)
5861 nic_xstats_display(i);
5862 else if (!strcmp(res->what, "fdir"))
5863 RTE_ETH_FOREACH_DEV(i)
5865 else if (!strcmp(res->what, "stat_qmap"))
5866 RTE_ETH_FOREACH_DEV(i)
5867 nic_stats_mapping_display(i);
5868 else if (!strcmp(res->what, "dcb_tc"))
5869 RTE_ETH_FOREACH_DEV(i)
5870 port_dcb_info_display(i);
5871 else if (!strcmp(res->what, "cap"))
5872 RTE_ETH_FOREACH_DEV(i)
5873 port_offload_cap_display(i);
5876 cmdline_parse_token_string_t cmd_showportall_show =
5877 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5879 cmdline_parse_token_string_t cmd_showportall_port =
5880 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5881 cmdline_parse_token_string_t cmd_showportall_what =
5882 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5883 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5884 cmdline_parse_token_string_t cmd_showportall_all =
5885 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5886 cmdline_parse_inst_t cmd_showportall = {
5887 .f = cmd_showportall_parsed,
5889 .help_str = "show|clear port "
5890 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5892 (void *)&cmd_showportall_show,
5893 (void *)&cmd_showportall_port,
5894 (void *)&cmd_showportall_what,
5895 (void *)&cmd_showportall_all,
5900 /* *** SHOW PORT INFO *** */
5901 struct cmd_showport_result {
5902 cmdline_fixed_string_t show;
5903 cmdline_fixed_string_t port;
5904 cmdline_fixed_string_t what;
5908 static void cmd_showport_parsed(void *parsed_result,
5909 __attribute__((unused)) struct cmdline *cl,
5910 __attribute__((unused)) void *data)
5912 struct cmd_showport_result *res = parsed_result;
5913 if (!strcmp(res->show, "clear")) {
5914 if (!strcmp(res->what, "stats"))
5915 nic_stats_clear(res->portnum);
5916 else if (!strcmp(res->what, "xstats"))
5917 nic_xstats_clear(res->portnum);
5918 } else if (!strcmp(res->what, "info"))
5919 port_infos_display(res->portnum);
5920 else if (!strcmp(res->what, "stats"))
5921 nic_stats_display(res->portnum);
5922 else if (!strcmp(res->what, "xstats"))
5923 nic_xstats_display(res->portnum);
5924 else if (!strcmp(res->what, "fdir"))
5925 fdir_get_infos(res->portnum);
5926 else if (!strcmp(res->what, "stat_qmap"))
5927 nic_stats_mapping_display(res->portnum);
5928 else if (!strcmp(res->what, "dcb_tc"))
5929 port_dcb_info_display(res->portnum);
5930 else if (!strcmp(res->what, "cap"))
5931 port_offload_cap_display(res->portnum);
5934 cmdline_parse_token_string_t cmd_showport_show =
5935 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5937 cmdline_parse_token_string_t cmd_showport_port =
5938 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5939 cmdline_parse_token_string_t cmd_showport_what =
5940 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5941 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5942 cmdline_parse_token_num_t cmd_showport_portnum =
5943 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5945 cmdline_parse_inst_t cmd_showport = {
5946 .f = cmd_showport_parsed,
5948 .help_str = "show|clear port "
5949 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5952 (void *)&cmd_showport_show,
5953 (void *)&cmd_showport_port,
5954 (void *)&cmd_showport_what,
5955 (void *)&cmd_showport_portnum,
5960 /* *** SHOW QUEUE INFO *** */
5961 struct cmd_showqueue_result {
5962 cmdline_fixed_string_t show;
5963 cmdline_fixed_string_t type;
5964 cmdline_fixed_string_t what;
5970 cmd_showqueue_parsed(void *parsed_result,
5971 __attribute__((unused)) struct cmdline *cl,
5972 __attribute__((unused)) void *data)
5974 struct cmd_showqueue_result *res = parsed_result;
5976 if (!strcmp(res->type, "rxq"))
5977 rx_queue_infos_display(res->portnum, res->queuenum);
5978 else if (!strcmp(res->type, "txq"))
5979 tx_queue_infos_display(res->portnum, res->queuenum);
5982 cmdline_parse_token_string_t cmd_showqueue_show =
5983 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5984 cmdline_parse_token_string_t cmd_showqueue_type =
5985 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5986 cmdline_parse_token_string_t cmd_showqueue_what =
5987 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5988 cmdline_parse_token_num_t cmd_showqueue_portnum =
5989 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5990 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5991 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5993 cmdline_parse_inst_t cmd_showqueue = {
5994 .f = cmd_showqueue_parsed,
5996 .help_str = "show rxq|txq info <port_id> <queue_id>",
5998 (void *)&cmd_showqueue_show,
5999 (void *)&cmd_showqueue_type,
6000 (void *)&cmd_showqueue_what,
6001 (void *)&cmd_showqueue_portnum,
6002 (void *)&cmd_showqueue_queuenum,
6007 /* *** READ PORT REGISTER *** */
6008 struct cmd_read_reg_result {
6009 cmdline_fixed_string_t read;
6010 cmdline_fixed_string_t reg;
6016 cmd_read_reg_parsed(void *parsed_result,
6017 __attribute__((unused)) struct cmdline *cl,
6018 __attribute__((unused)) void *data)
6020 struct cmd_read_reg_result *res = parsed_result;
6021 port_reg_display(res->port_id, res->reg_off);
6024 cmdline_parse_token_string_t cmd_read_reg_read =
6025 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6026 cmdline_parse_token_string_t cmd_read_reg_reg =
6027 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6028 cmdline_parse_token_num_t cmd_read_reg_port_id =
6029 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6030 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6031 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6033 cmdline_parse_inst_t cmd_read_reg = {
6034 .f = cmd_read_reg_parsed,
6036 .help_str = "read reg <port_id> <reg_off>",
6038 (void *)&cmd_read_reg_read,
6039 (void *)&cmd_read_reg_reg,
6040 (void *)&cmd_read_reg_port_id,
6041 (void *)&cmd_read_reg_reg_off,
6046 /* *** READ PORT REGISTER BIT FIELD *** */
6047 struct cmd_read_reg_bit_field_result {
6048 cmdline_fixed_string_t read;
6049 cmdline_fixed_string_t regfield;
6057 cmd_read_reg_bit_field_parsed(void *parsed_result,
6058 __attribute__((unused)) struct cmdline *cl,
6059 __attribute__((unused)) void *data)
6061 struct cmd_read_reg_bit_field_result *res = parsed_result;
6062 port_reg_bit_field_display(res->port_id, res->reg_off,
6063 res->bit1_pos, res->bit2_pos);
6066 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6067 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6069 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6070 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6071 regfield, "regfield");
6072 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6073 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6075 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6076 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6078 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6079 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6081 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6082 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6085 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6086 .f = cmd_read_reg_bit_field_parsed,
6088 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6089 "Read register bit field between bit_x and bit_y included",
6091 (void *)&cmd_read_reg_bit_field_read,
6092 (void *)&cmd_read_reg_bit_field_regfield,
6093 (void *)&cmd_read_reg_bit_field_port_id,
6094 (void *)&cmd_read_reg_bit_field_reg_off,
6095 (void *)&cmd_read_reg_bit_field_bit1_pos,
6096 (void *)&cmd_read_reg_bit_field_bit2_pos,
6101 /* *** READ PORT REGISTER BIT *** */
6102 struct cmd_read_reg_bit_result {
6103 cmdline_fixed_string_t read;
6104 cmdline_fixed_string_t regbit;
6111 cmd_read_reg_bit_parsed(void *parsed_result,
6112 __attribute__((unused)) struct cmdline *cl,
6113 __attribute__((unused)) void *data)
6115 struct cmd_read_reg_bit_result *res = parsed_result;
6116 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6119 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6120 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6121 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6122 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6124 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6125 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6126 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6127 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6128 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6129 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6131 cmdline_parse_inst_t cmd_read_reg_bit = {
6132 .f = cmd_read_reg_bit_parsed,
6134 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6136 (void *)&cmd_read_reg_bit_read,
6137 (void *)&cmd_read_reg_bit_regbit,
6138 (void *)&cmd_read_reg_bit_port_id,
6139 (void *)&cmd_read_reg_bit_reg_off,
6140 (void *)&cmd_read_reg_bit_bit_pos,
6145 /* *** WRITE PORT REGISTER *** */
6146 struct cmd_write_reg_result {
6147 cmdline_fixed_string_t write;
6148 cmdline_fixed_string_t reg;
6155 cmd_write_reg_parsed(void *parsed_result,
6156 __attribute__((unused)) struct cmdline *cl,
6157 __attribute__((unused)) void *data)
6159 struct cmd_write_reg_result *res = parsed_result;
6160 port_reg_set(res->port_id, res->reg_off, res->value);
6163 cmdline_parse_token_string_t cmd_write_reg_write =
6164 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6165 cmdline_parse_token_string_t cmd_write_reg_reg =
6166 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6167 cmdline_parse_token_num_t cmd_write_reg_port_id =
6168 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6169 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6170 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6171 cmdline_parse_token_num_t cmd_write_reg_value =
6172 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6174 cmdline_parse_inst_t cmd_write_reg = {
6175 .f = cmd_write_reg_parsed,
6177 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6179 (void *)&cmd_write_reg_write,
6180 (void *)&cmd_write_reg_reg,
6181 (void *)&cmd_write_reg_port_id,
6182 (void *)&cmd_write_reg_reg_off,
6183 (void *)&cmd_write_reg_value,
6188 /* *** WRITE PORT REGISTER BIT FIELD *** */
6189 struct cmd_write_reg_bit_field_result {
6190 cmdline_fixed_string_t write;
6191 cmdline_fixed_string_t regfield;
6200 cmd_write_reg_bit_field_parsed(void *parsed_result,
6201 __attribute__((unused)) struct cmdline *cl,
6202 __attribute__((unused)) void *data)
6204 struct cmd_write_reg_bit_field_result *res = parsed_result;
6205 port_reg_bit_field_set(res->port_id, res->reg_off,
6206 res->bit1_pos, res->bit2_pos, res->value);
6209 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6210 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6212 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6213 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6214 regfield, "regfield");
6215 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6216 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6218 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6219 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6221 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6222 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6224 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6225 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6227 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6228 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6231 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6232 .f = cmd_write_reg_bit_field_parsed,
6234 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6236 "Set register bit field between bit_x and bit_y included",
6238 (void *)&cmd_write_reg_bit_field_write,
6239 (void *)&cmd_write_reg_bit_field_regfield,
6240 (void *)&cmd_write_reg_bit_field_port_id,
6241 (void *)&cmd_write_reg_bit_field_reg_off,
6242 (void *)&cmd_write_reg_bit_field_bit1_pos,
6243 (void *)&cmd_write_reg_bit_field_bit2_pos,
6244 (void *)&cmd_write_reg_bit_field_value,
6249 /* *** WRITE PORT REGISTER BIT *** */
6250 struct cmd_write_reg_bit_result {
6251 cmdline_fixed_string_t write;
6252 cmdline_fixed_string_t regbit;
6260 cmd_write_reg_bit_parsed(void *parsed_result,
6261 __attribute__((unused)) struct cmdline *cl,
6262 __attribute__((unused)) void *data)
6264 struct cmd_write_reg_bit_result *res = parsed_result;
6265 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6268 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6269 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6271 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6272 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6274 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6275 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6276 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6277 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6278 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6279 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6280 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6281 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6283 cmdline_parse_inst_t cmd_write_reg_bit = {
6284 .f = cmd_write_reg_bit_parsed,
6286 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6289 (void *)&cmd_write_reg_bit_write,
6290 (void *)&cmd_write_reg_bit_regbit,
6291 (void *)&cmd_write_reg_bit_port_id,
6292 (void *)&cmd_write_reg_bit_reg_off,
6293 (void *)&cmd_write_reg_bit_bit_pos,
6294 (void *)&cmd_write_reg_bit_value,
6299 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6300 struct cmd_read_rxd_txd_result {
6301 cmdline_fixed_string_t read;
6302 cmdline_fixed_string_t rxd_txd;
6309 cmd_read_rxd_txd_parsed(void *parsed_result,
6310 __attribute__((unused)) struct cmdline *cl,
6311 __attribute__((unused)) void *data)
6313 struct cmd_read_rxd_txd_result *res = parsed_result;
6315 if (!strcmp(res->rxd_txd, "rxd"))
6316 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6317 else if (!strcmp(res->rxd_txd, "txd"))
6318 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6321 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6322 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6323 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6324 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6326 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6327 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6328 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6329 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6330 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6331 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6333 cmdline_parse_inst_t cmd_read_rxd_txd = {
6334 .f = cmd_read_rxd_txd_parsed,
6336 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6338 (void *)&cmd_read_rxd_txd_read,
6339 (void *)&cmd_read_rxd_txd_rxd_txd,
6340 (void *)&cmd_read_rxd_txd_port_id,
6341 (void *)&cmd_read_rxd_txd_queue_id,
6342 (void *)&cmd_read_rxd_txd_desc_id,
6348 struct cmd_quit_result {
6349 cmdline_fixed_string_t quit;
6352 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6354 __attribute__((unused)) void *data)
6360 cmdline_parse_token_string_t cmd_quit_quit =
6361 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6363 cmdline_parse_inst_t cmd_quit = {
6364 .f = cmd_quit_parsed,
6366 .help_str = "quit: Exit application",
6368 (void *)&cmd_quit_quit,
6373 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6374 struct cmd_mac_addr_result {
6375 cmdline_fixed_string_t mac_addr_cmd;
6376 cmdline_fixed_string_t what;
6378 struct ether_addr address;
6381 static void cmd_mac_addr_parsed(void *parsed_result,
6382 __attribute__((unused)) struct cmdline *cl,
6383 __attribute__((unused)) void *data)
6385 struct cmd_mac_addr_result *res = parsed_result;
6388 if (strcmp(res->what, "add") == 0)
6389 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6390 else if (strcmp(res->what, "set") == 0)
6391 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6394 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6396 /* check the return value and print it if is < 0 */
6398 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6402 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6403 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6405 cmdline_parse_token_string_t cmd_mac_addr_what =
6406 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6408 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6409 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6410 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6411 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6413 cmdline_parse_inst_t cmd_mac_addr = {
6414 .f = cmd_mac_addr_parsed,
6416 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6417 "Add/Remove/Set MAC address on port_id",
6419 (void *)&cmd_mac_addr_cmd,
6420 (void *)&cmd_mac_addr_what,
6421 (void *)&cmd_mac_addr_portnum,
6422 (void *)&cmd_mac_addr_addr,
6428 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6429 struct cmd_set_qmap_result {
6430 cmdline_fixed_string_t set;
6431 cmdline_fixed_string_t qmap;
6432 cmdline_fixed_string_t what;
6439 cmd_set_qmap_parsed(void *parsed_result,
6440 __attribute__((unused)) struct cmdline *cl,
6441 __attribute__((unused)) void *data)
6443 struct cmd_set_qmap_result *res = parsed_result;
6444 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6446 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6449 cmdline_parse_token_string_t cmd_setqmap_set =
6450 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6452 cmdline_parse_token_string_t cmd_setqmap_qmap =
6453 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6455 cmdline_parse_token_string_t cmd_setqmap_what =
6456 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6458 cmdline_parse_token_num_t cmd_setqmap_portid =
6459 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6461 cmdline_parse_token_num_t cmd_setqmap_queueid =
6462 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6464 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6465 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6468 cmdline_parse_inst_t cmd_set_qmap = {
6469 .f = cmd_set_qmap_parsed,
6471 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6472 "Set statistics mapping value on tx|rx queue_id of port_id",
6474 (void *)&cmd_setqmap_set,
6475 (void *)&cmd_setqmap_qmap,
6476 (void *)&cmd_setqmap_what,
6477 (void *)&cmd_setqmap_portid,
6478 (void *)&cmd_setqmap_queueid,
6479 (void *)&cmd_setqmap_mapvalue,
6484 /* *** CONFIGURE UNICAST HASH TABLE *** */
6485 struct cmd_set_uc_hash_table {
6486 cmdline_fixed_string_t set;
6487 cmdline_fixed_string_t port;
6489 cmdline_fixed_string_t what;
6490 struct ether_addr address;
6491 cmdline_fixed_string_t mode;
6495 cmd_set_uc_hash_parsed(void *parsed_result,
6496 __attribute__((unused)) struct cmdline *cl,
6497 __attribute__((unused)) void *data)
6500 struct cmd_set_uc_hash_table *res = parsed_result;
6502 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6504 if (strcmp(res->what, "uta") == 0)
6505 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6506 &res->address,(uint8_t)is_on);
6508 printf("bad unicast hash table parameter, return code = %d \n", ret);
6512 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6513 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6515 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6516 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6518 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6519 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6521 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6522 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6524 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6525 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6527 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6531 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6532 .f = cmd_set_uc_hash_parsed,
6534 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6536 (void *)&cmd_set_uc_hash_set,
6537 (void *)&cmd_set_uc_hash_port,
6538 (void *)&cmd_set_uc_hash_portid,
6539 (void *)&cmd_set_uc_hash_what,
6540 (void *)&cmd_set_uc_hash_mac,
6541 (void *)&cmd_set_uc_hash_mode,
6546 struct cmd_set_uc_all_hash_table {
6547 cmdline_fixed_string_t set;
6548 cmdline_fixed_string_t port;
6550 cmdline_fixed_string_t what;
6551 cmdline_fixed_string_t value;
6552 cmdline_fixed_string_t mode;
6556 cmd_set_uc_all_hash_parsed(void *parsed_result,
6557 __attribute__((unused)) struct cmdline *cl,
6558 __attribute__((unused)) void *data)
6561 struct cmd_set_uc_all_hash_table *res = parsed_result;
6563 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6565 if ((strcmp(res->what, "uta") == 0) &&
6566 (strcmp(res->value, "all") == 0))
6567 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6569 printf("bad unicast hash table parameter,"
6570 "return code = %d \n", ret);
6573 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6574 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6576 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6577 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6579 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6580 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6582 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6583 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6585 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6586 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6588 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6589 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6592 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6593 .f = cmd_set_uc_all_hash_parsed,
6595 .help_str = "set port <port_id> uta all on|off",
6597 (void *)&cmd_set_uc_all_hash_set,
6598 (void *)&cmd_set_uc_all_hash_port,
6599 (void *)&cmd_set_uc_all_hash_portid,
6600 (void *)&cmd_set_uc_all_hash_what,
6601 (void *)&cmd_set_uc_all_hash_value,
6602 (void *)&cmd_set_uc_all_hash_mode,
6607 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6608 struct cmd_set_vf_macvlan_filter {
6609 cmdline_fixed_string_t set;
6610 cmdline_fixed_string_t port;
6612 cmdline_fixed_string_t vf;
6614 struct ether_addr address;
6615 cmdline_fixed_string_t filter_type;
6616 cmdline_fixed_string_t mode;
6620 cmd_set_vf_macvlan_parsed(void *parsed_result,
6621 __attribute__((unused)) struct cmdline *cl,
6622 __attribute__((unused)) void *data)
6625 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6626 struct rte_eth_mac_filter filter;
6628 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6630 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6632 /* set VF MAC filter */
6636 filter.dst_id = res->vf_id;
6638 if (!strcmp(res->filter_type, "exact-mac"))
6639 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6640 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6641 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6642 else if (!strcmp(res->filter_type, "hashmac"))
6643 filter.filter_type = RTE_MAC_HASH_MATCH;
6644 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6645 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6647 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6650 ret = rte_eth_dev_filter_ctrl(res->port_id,
6651 RTE_ETH_FILTER_MACVLAN,
6655 ret = rte_eth_dev_filter_ctrl(res->port_id,
6656 RTE_ETH_FILTER_MACVLAN,
6657 RTE_ETH_FILTER_DELETE,
6661 printf("bad set MAC hash parameter, return code = %d\n", ret);
6665 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6666 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6668 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6671 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6672 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6674 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6675 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6677 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6678 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6680 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6681 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6683 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6684 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6685 filter_type, "exact-mac#exact-mac-vlan"
6686 "#hashmac#hashmac-vlan");
6687 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6688 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6691 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6692 .f = cmd_set_vf_macvlan_parsed,
6694 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6695 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6696 "Exact match rule: exact match of MAC or MAC and VLAN; "
6697 "hash match rule: hash match of MAC and exact match of VLAN",
6699 (void *)&cmd_set_vf_macvlan_set,
6700 (void *)&cmd_set_vf_macvlan_port,
6701 (void *)&cmd_set_vf_macvlan_portid,
6702 (void *)&cmd_set_vf_macvlan_vf,
6703 (void *)&cmd_set_vf_macvlan_vf_id,
6704 (void *)&cmd_set_vf_macvlan_mac,
6705 (void *)&cmd_set_vf_macvlan_filter_type,
6706 (void *)&cmd_set_vf_macvlan_mode,
6711 #ifdef RTE_LIBRTE_IXGBE_PMD
6712 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6713 struct cmd_set_vf_traffic {
6714 cmdline_fixed_string_t set;
6715 cmdline_fixed_string_t port;
6717 cmdline_fixed_string_t vf;
6719 cmdline_fixed_string_t what;
6720 cmdline_fixed_string_t mode;
6724 cmd_set_vf_traffic_parsed(void *parsed_result,
6725 __attribute__((unused)) struct cmdline *cl,
6726 __attribute__((unused)) void *data)
6728 struct cmd_set_vf_traffic *res = parsed_result;
6729 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6730 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6732 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6735 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6736 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6738 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6739 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6741 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6742 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6744 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6745 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6747 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6748 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6750 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6751 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6753 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6754 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6757 cmdline_parse_inst_t cmd_set_vf_traffic = {
6758 .f = cmd_set_vf_traffic_parsed,
6760 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6762 (void *)&cmd_setvf_traffic_set,
6763 (void *)&cmd_setvf_traffic_port,
6764 (void *)&cmd_setvf_traffic_portid,
6765 (void *)&cmd_setvf_traffic_vf,
6766 (void *)&cmd_setvf_traffic_vfid,
6767 (void *)&cmd_setvf_traffic_what,
6768 (void *)&cmd_setvf_traffic_mode,
6773 /* *** CONFIGURE VF RECEIVE MODE *** */
6774 struct cmd_set_vf_rxmode {
6775 cmdline_fixed_string_t set;
6776 cmdline_fixed_string_t port;
6778 cmdline_fixed_string_t vf;
6780 cmdline_fixed_string_t what;
6781 cmdline_fixed_string_t mode;
6782 cmdline_fixed_string_t on;
6786 cmd_set_vf_rxmode_parsed(void *parsed_result,
6787 __attribute__((unused)) struct cmdline *cl,
6788 __attribute__((unused)) void *data)
6791 uint16_t rx_mode = 0;
6792 struct cmd_set_vf_rxmode *res = parsed_result;
6794 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6795 if (!strcmp(res->what,"rxmode")) {
6796 if (!strcmp(res->mode, "AUPE"))
6797 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6798 else if (!strcmp(res->mode, "ROPE"))
6799 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6800 else if (!strcmp(res->mode, "BAM"))
6801 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6802 else if (!strncmp(res->mode, "MPE",3))
6803 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6806 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6808 printf("bad VF receive mode parameter, return code = %d \n",
6812 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6813 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6815 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6816 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6818 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6819 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6821 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6822 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6824 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6825 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6827 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6828 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6830 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6831 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6832 mode, "AUPE#ROPE#BAM#MPE");
6833 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6834 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6837 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6838 .f = cmd_set_vf_rxmode_parsed,
6840 .help_str = "set port <port_id> vf <vf_id> rxmode "
6841 "AUPE|ROPE|BAM|MPE on|off",
6843 (void *)&cmd_set_vf_rxmode_set,
6844 (void *)&cmd_set_vf_rxmode_port,
6845 (void *)&cmd_set_vf_rxmode_portid,
6846 (void *)&cmd_set_vf_rxmode_vf,
6847 (void *)&cmd_set_vf_rxmode_vfid,
6848 (void *)&cmd_set_vf_rxmode_what,
6849 (void *)&cmd_set_vf_rxmode_mode,
6850 (void *)&cmd_set_vf_rxmode_on,
6856 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6857 struct cmd_vf_mac_addr_result {
6858 cmdline_fixed_string_t mac_addr_cmd;
6859 cmdline_fixed_string_t what;
6860 cmdline_fixed_string_t port;
6862 cmdline_fixed_string_t vf;
6864 struct ether_addr address;
6867 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6868 __attribute__((unused)) struct cmdline *cl,
6869 __attribute__((unused)) void *data)
6871 struct cmd_vf_mac_addr_result *res = parsed_result;
6874 if (strcmp(res->what, "add") == 0)
6875 ret = rte_eth_dev_mac_addr_add(res->port_num,
6876 &res->address, res->vf_num);
6878 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6882 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6883 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6884 mac_addr_cmd,"mac_addr");
6885 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6886 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6888 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6889 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6891 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6892 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6894 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6895 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6897 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6898 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6900 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6901 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6904 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6905 .f = cmd_vf_mac_addr_parsed,
6907 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6908 "Add MAC address filtering for a VF on port_id",
6910 (void *)&cmd_vf_mac_addr_cmd,
6911 (void *)&cmd_vf_mac_addr_what,
6912 (void *)&cmd_vf_mac_addr_port,
6913 (void *)&cmd_vf_mac_addr_portnum,
6914 (void *)&cmd_vf_mac_addr_vf,
6915 (void *)&cmd_vf_mac_addr_vfnum,
6916 (void *)&cmd_vf_mac_addr_addr,
6921 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6922 struct cmd_vf_rx_vlan_filter {
6923 cmdline_fixed_string_t rx_vlan;
6924 cmdline_fixed_string_t what;
6926 cmdline_fixed_string_t port;
6928 cmdline_fixed_string_t vf;
6933 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6934 __attribute__((unused)) struct cmdline *cl,
6935 __attribute__((unused)) void *data)
6937 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6940 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6942 #ifdef RTE_LIBRTE_IXGBE_PMD
6943 if (ret == -ENOTSUP)
6944 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6945 res->vlan_id, res->vf_mask, is_add);
6947 #ifdef RTE_LIBRTE_I40E_PMD
6948 if (ret == -ENOTSUP)
6949 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6950 res->vlan_id, res->vf_mask, is_add);
6957 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6958 res->vlan_id, res->vf_mask);
6961 printf("invalid port_id %d\n", res->port_id);
6964 printf("function not implemented or supported\n");
6967 printf("programming error: (%s)\n", strerror(-ret));
6971 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6972 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6973 rx_vlan, "rx_vlan");
6974 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6975 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6977 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6978 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6980 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6981 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6983 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6984 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6986 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6987 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6989 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6990 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6993 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6994 .f = cmd_vf_rx_vlan_filter_parsed,
6996 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6997 "(vf_mask = hexadecimal VF mask)",
6999 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7000 (void *)&cmd_vf_rx_vlan_filter_what,
7001 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7002 (void *)&cmd_vf_rx_vlan_filter_port,
7003 (void *)&cmd_vf_rx_vlan_filter_portid,
7004 (void *)&cmd_vf_rx_vlan_filter_vf,
7005 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7010 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7011 struct cmd_queue_rate_limit_result {
7012 cmdline_fixed_string_t set;
7013 cmdline_fixed_string_t port;
7015 cmdline_fixed_string_t queue;
7017 cmdline_fixed_string_t rate;
7021 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7022 __attribute__((unused)) struct cmdline *cl,
7023 __attribute__((unused)) void *data)
7025 struct cmd_queue_rate_limit_result *res = parsed_result;
7028 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7029 && (strcmp(res->queue, "queue") == 0)
7030 && (strcmp(res->rate, "rate") == 0))
7031 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7034 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7038 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7039 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7041 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7042 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7044 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7045 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7047 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7048 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7050 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7051 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7053 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7054 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7056 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7057 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7060 cmdline_parse_inst_t cmd_queue_rate_limit = {
7061 .f = cmd_queue_rate_limit_parsed,
7063 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7064 "Set rate limit for a queue on port_id",
7066 (void *)&cmd_queue_rate_limit_set,
7067 (void *)&cmd_queue_rate_limit_port,
7068 (void *)&cmd_queue_rate_limit_portnum,
7069 (void *)&cmd_queue_rate_limit_queue,
7070 (void *)&cmd_queue_rate_limit_queuenum,
7071 (void *)&cmd_queue_rate_limit_rate,
7072 (void *)&cmd_queue_rate_limit_ratenum,
7077 #ifdef RTE_LIBRTE_IXGBE_PMD
7078 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7079 struct cmd_vf_rate_limit_result {
7080 cmdline_fixed_string_t set;
7081 cmdline_fixed_string_t port;
7083 cmdline_fixed_string_t vf;
7085 cmdline_fixed_string_t rate;
7087 cmdline_fixed_string_t q_msk;
7091 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7092 __attribute__((unused)) struct cmdline *cl,
7093 __attribute__((unused)) void *data)
7095 struct cmd_vf_rate_limit_result *res = parsed_result;
7098 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7099 && (strcmp(res->vf, "vf") == 0)
7100 && (strcmp(res->rate, "rate") == 0)
7101 && (strcmp(res->q_msk, "queue_mask") == 0))
7102 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7103 res->rate_num, res->q_msk_val);
7105 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7109 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7110 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7112 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7113 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7115 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7116 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7118 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7119 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7121 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7122 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7124 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7125 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7127 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7128 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7130 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7131 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7132 q_msk, "queue_mask");
7133 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7134 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7137 cmdline_parse_inst_t cmd_vf_rate_limit = {
7138 .f = cmd_vf_rate_limit_parsed,
7140 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7141 "queue_mask <queue_mask_value>: "
7142 "Set rate limit for queues of VF on port_id",
7144 (void *)&cmd_vf_rate_limit_set,
7145 (void *)&cmd_vf_rate_limit_port,
7146 (void *)&cmd_vf_rate_limit_portnum,
7147 (void *)&cmd_vf_rate_limit_vf,
7148 (void *)&cmd_vf_rate_limit_vfnum,
7149 (void *)&cmd_vf_rate_limit_rate,
7150 (void *)&cmd_vf_rate_limit_ratenum,
7151 (void *)&cmd_vf_rate_limit_q_msk,
7152 (void *)&cmd_vf_rate_limit_q_msk_val,
7158 /* *** ADD TUNNEL FILTER OF A PORT *** */
7159 struct cmd_tunnel_filter_result {
7160 cmdline_fixed_string_t cmd;
7161 cmdline_fixed_string_t what;
7163 struct ether_addr outer_mac;
7164 struct ether_addr inner_mac;
7165 cmdline_ipaddr_t ip_value;
7166 uint16_t inner_vlan;
7167 cmdline_fixed_string_t tunnel_type;
7168 cmdline_fixed_string_t filter_type;
7174 cmd_tunnel_filter_parsed(void *parsed_result,
7175 __attribute__((unused)) struct cmdline *cl,
7176 __attribute__((unused)) void *data)
7178 struct cmd_tunnel_filter_result *res = parsed_result;
7179 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7182 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7184 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7185 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7186 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7188 if (res->ip_value.family == AF_INET) {
7189 tunnel_filter_conf.ip_addr.ipv4_addr =
7190 res->ip_value.addr.ipv4.s_addr;
7191 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7193 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7194 &(res->ip_value.addr.ipv6),
7195 sizeof(struct in6_addr));
7196 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7199 if (!strcmp(res->filter_type, "imac-ivlan"))
7200 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7201 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7202 tunnel_filter_conf.filter_type =
7203 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7204 else if (!strcmp(res->filter_type, "imac-tenid"))
7205 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7206 else if (!strcmp(res->filter_type, "imac"))
7207 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7208 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7209 tunnel_filter_conf.filter_type =
7210 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7211 else if (!strcmp(res->filter_type, "oip"))
7212 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7213 else if (!strcmp(res->filter_type, "iip"))
7214 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7216 printf("The filter type is not supported");
7220 if (!strcmp(res->tunnel_type, "vxlan"))
7221 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7222 else if (!strcmp(res->tunnel_type, "nvgre"))
7223 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7224 else if (!strcmp(res->tunnel_type, "ipingre"))
7225 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7227 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7231 tunnel_filter_conf.tenant_id = res->tenant_id;
7232 tunnel_filter_conf.queue_id = res->queue_num;
7233 if (!strcmp(res->what, "add"))
7234 ret = rte_eth_dev_filter_ctrl(res->port_id,
7235 RTE_ETH_FILTER_TUNNEL,
7237 &tunnel_filter_conf);
7239 ret = rte_eth_dev_filter_ctrl(res->port_id,
7240 RTE_ETH_FILTER_TUNNEL,
7241 RTE_ETH_FILTER_DELETE,
7242 &tunnel_filter_conf);
7244 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7248 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7249 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7250 cmd, "tunnel_filter");
7251 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7252 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7254 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7255 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7257 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7258 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7260 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7261 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7263 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7264 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7265 inner_vlan, UINT16);
7266 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7267 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7269 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7270 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7271 tunnel_type, "vxlan#nvgre#ipingre");
7273 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7274 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7275 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7276 "imac#omac-imac-tenid");
7277 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7278 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7280 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7281 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7284 cmdline_parse_inst_t cmd_tunnel_filter = {
7285 .f = cmd_tunnel_filter_parsed,
7287 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7288 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7289 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7290 "<queue_id>: Add/Rm tunnel filter of a port",
7292 (void *)&cmd_tunnel_filter_cmd,
7293 (void *)&cmd_tunnel_filter_what,
7294 (void *)&cmd_tunnel_filter_port_id,
7295 (void *)&cmd_tunnel_filter_outer_mac,
7296 (void *)&cmd_tunnel_filter_inner_mac,
7297 (void *)&cmd_tunnel_filter_ip_value,
7298 (void *)&cmd_tunnel_filter_innner_vlan,
7299 (void *)&cmd_tunnel_filter_tunnel_type,
7300 (void *)&cmd_tunnel_filter_filter_type,
7301 (void *)&cmd_tunnel_filter_tenant_id,
7302 (void *)&cmd_tunnel_filter_queue_num,
7307 /* *** CONFIGURE TUNNEL UDP PORT *** */
7308 struct cmd_tunnel_udp_config {
7309 cmdline_fixed_string_t cmd;
7310 cmdline_fixed_string_t what;
7316 cmd_tunnel_udp_config_parsed(void *parsed_result,
7317 __attribute__((unused)) struct cmdline *cl,
7318 __attribute__((unused)) void *data)
7320 struct cmd_tunnel_udp_config *res = parsed_result;
7321 struct rte_eth_udp_tunnel tunnel_udp;
7324 tunnel_udp.udp_port = res->udp_port;
7326 if (!strcmp(res->cmd, "rx_vxlan_port"))
7327 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7329 if (!strcmp(res->what, "add"))
7330 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7333 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7337 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7340 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7341 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7342 cmd, "rx_vxlan_port");
7343 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7344 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7346 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7347 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7349 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7350 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7353 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7354 .f = cmd_tunnel_udp_config_parsed,
7356 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7357 "Add/Remove a tunneling UDP port filter",
7359 (void *)&cmd_tunnel_udp_config_cmd,
7360 (void *)&cmd_tunnel_udp_config_what,
7361 (void *)&cmd_tunnel_udp_config_udp_port,
7362 (void *)&cmd_tunnel_udp_config_port_id,
7367 /* *** GLOBAL CONFIG *** */
7368 struct cmd_global_config_result {
7369 cmdline_fixed_string_t cmd;
7371 cmdline_fixed_string_t cfg_type;
7376 cmd_global_config_parsed(void *parsed_result,
7377 __attribute__((unused)) struct cmdline *cl,
7378 __attribute__((unused)) void *data)
7380 struct cmd_global_config_result *res = parsed_result;
7381 struct rte_eth_global_cfg conf;
7384 memset(&conf, 0, sizeof(conf));
7385 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7386 conf.cfg.gre_key_len = res->len;
7387 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7388 RTE_ETH_FILTER_SET, &conf);
7390 printf("Global config error\n");
7393 cmdline_parse_token_string_t cmd_global_config_cmd =
7394 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7396 cmdline_parse_token_num_t cmd_global_config_port_id =
7397 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7398 cmdline_parse_token_string_t cmd_global_config_type =
7399 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7400 cfg_type, "gre-key-len");
7401 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7402 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7405 cmdline_parse_inst_t cmd_global_config = {
7406 .f = cmd_global_config_parsed,
7407 .data = (void *)NULL,
7408 .help_str = "global_config <port_id> gre-key-len <key_len>",
7410 (void *)&cmd_global_config_cmd,
7411 (void *)&cmd_global_config_port_id,
7412 (void *)&cmd_global_config_type,
7413 (void *)&cmd_global_config_gre_key_len,
7418 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7419 struct cmd_set_mirror_mask_result {
7420 cmdline_fixed_string_t set;
7421 cmdline_fixed_string_t port;
7423 cmdline_fixed_string_t mirror;
7425 cmdline_fixed_string_t what;
7426 cmdline_fixed_string_t value;
7427 cmdline_fixed_string_t dstpool;
7429 cmdline_fixed_string_t on;
7432 cmdline_parse_token_string_t cmd_mirror_mask_set =
7433 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7435 cmdline_parse_token_string_t cmd_mirror_mask_port =
7436 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7438 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7439 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7441 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7442 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7443 mirror, "mirror-rule");
7444 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7445 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7447 cmdline_parse_token_string_t cmd_mirror_mask_what =
7448 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7449 what, "pool-mirror-up#pool-mirror-down"
7451 cmdline_parse_token_string_t cmd_mirror_mask_value =
7452 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7454 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7455 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7456 dstpool, "dst-pool");
7457 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7458 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7460 cmdline_parse_token_string_t cmd_mirror_mask_on =
7461 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7465 cmd_set_mirror_mask_parsed(void *parsed_result,
7466 __attribute__((unused)) struct cmdline *cl,
7467 __attribute__((unused)) void *data)
7470 struct cmd_set_mirror_mask_result *res = parsed_result;
7471 struct rte_eth_mirror_conf mr_conf;
7473 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7475 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7477 mr_conf.dst_pool = res->dstpool_id;
7479 if (!strcmp(res->what, "pool-mirror-up")) {
7480 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7481 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7482 } else if (!strcmp(res->what, "pool-mirror-down")) {
7483 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7484 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7485 } else if (!strcmp(res->what, "vlan-mirror")) {
7486 mr_conf.rule_type = ETH_MIRROR_VLAN;
7487 nb_item = parse_item_list(res->value, "vlan",
7488 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7492 for (i = 0; i < nb_item; i++) {
7493 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7494 printf("Invalid vlan_id: must be < 4096\n");
7498 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7499 mr_conf.vlan.vlan_mask |= 1ULL << i;
7503 if (!strcmp(res->on, "on"))
7504 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7507 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7510 printf("mirror rule add error: (%s)\n", strerror(-ret));
7513 cmdline_parse_inst_t cmd_set_mirror_mask = {
7514 .f = cmd_set_mirror_mask_parsed,
7516 .help_str = "set port <port_id> mirror-rule <rule_id> "
7517 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7518 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7520 (void *)&cmd_mirror_mask_set,
7521 (void *)&cmd_mirror_mask_port,
7522 (void *)&cmd_mirror_mask_portid,
7523 (void *)&cmd_mirror_mask_mirror,
7524 (void *)&cmd_mirror_mask_ruleid,
7525 (void *)&cmd_mirror_mask_what,
7526 (void *)&cmd_mirror_mask_value,
7527 (void *)&cmd_mirror_mask_dstpool,
7528 (void *)&cmd_mirror_mask_poolid,
7529 (void *)&cmd_mirror_mask_on,
7534 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7535 struct cmd_set_mirror_link_result {
7536 cmdline_fixed_string_t set;
7537 cmdline_fixed_string_t port;
7539 cmdline_fixed_string_t mirror;
7541 cmdline_fixed_string_t what;
7542 cmdline_fixed_string_t dstpool;
7544 cmdline_fixed_string_t on;
7547 cmdline_parse_token_string_t cmd_mirror_link_set =
7548 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7550 cmdline_parse_token_string_t cmd_mirror_link_port =
7551 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7553 cmdline_parse_token_num_t cmd_mirror_link_portid =
7554 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7556 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7557 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7558 mirror, "mirror-rule");
7559 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7560 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7562 cmdline_parse_token_string_t cmd_mirror_link_what =
7563 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7564 what, "uplink-mirror#downlink-mirror");
7565 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7566 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7567 dstpool, "dst-pool");
7568 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7569 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7571 cmdline_parse_token_string_t cmd_mirror_link_on =
7572 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7576 cmd_set_mirror_link_parsed(void *parsed_result,
7577 __attribute__((unused)) struct cmdline *cl,
7578 __attribute__((unused)) void *data)
7581 struct cmd_set_mirror_link_result *res = parsed_result;
7582 struct rte_eth_mirror_conf mr_conf;
7584 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7585 if (!strcmp(res->what, "uplink-mirror"))
7586 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7588 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7590 mr_conf.dst_pool = res->dstpool_id;
7592 if (!strcmp(res->on, "on"))
7593 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7596 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7599 /* check the return value and print it if is < 0 */
7601 printf("mirror rule add error: (%s)\n", strerror(-ret));
7605 cmdline_parse_inst_t cmd_set_mirror_link = {
7606 .f = cmd_set_mirror_link_parsed,
7608 .help_str = "set port <port_id> mirror-rule <rule_id> "
7609 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7611 (void *)&cmd_mirror_link_set,
7612 (void *)&cmd_mirror_link_port,
7613 (void *)&cmd_mirror_link_portid,
7614 (void *)&cmd_mirror_link_mirror,
7615 (void *)&cmd_mirror_link_ruleid,
7616 (void *)&cmd_mirror_link_what,
7617 (void *)&cmd_mirror_link_dstpool,
7618 (void *)&cmd_mirror_link_poolid,
7619 (void *)&cmd_mirror_link_on,
7624 /* *** RESET VM MIRROR RULE *** */
7625 struct cmd_rm_mirror_rule_result {
7626 cmdline_fixed_string_t reset;
7627 cmdline_fixed_string_t port;
7629 cmdline_fixed_string_t mirror;
7633 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7634 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7636 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7637 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7639 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7640 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7642 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7643 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7644 mirror, "mirror-rule");
7645 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7646 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7650 cmd_reset_mirror_rule_parsed(void *parsed_result,
7651 __attribute__((unused)) struct cmdline *cl,
7652 __attribute__((unused)) void *data)
7655 struct cmd_set_mirror_link_result *res = parsed_result;
7657 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7659 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7662 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7663 .f = cmd_reset_mirror_rule_parsed,
7665 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7667 (void *)&cmd_rm_mirror_rule_reset,
7668 (void *)&cmd_rm_mirror_rule_port,
7669 (void *)&cmd_rm_mirror_rule_portid,
7670 (void *)&cmd_rm_mirror_rule_mirror,
7671 (void *)&cmd_rm_mirror_rule_ruleid,
7676 /* ******************************************************************************** */
7678 struct cmd_dump_result {
7679 cmdline_fixed_string_t dump;
7683 dump_struct_sizes(void)
7685 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7686 DUMP_SIZE(struct rte_mbuf);
7687 DUMP_SIZE(struct rte_mempool);
7688 DUMP_SIZE(struct rte_ring);
7692 static void cmd_dump_parsed(void *parsed_result,
7693 __attribute__((unused)) struct cmdline *cl,
7694 __attribute__((unused)) void *data)
7696 struct cmd_dump_result *res = parsed_result;
7698 if (!strcmp(res->dump, "dump_physmem"))
7699 rte_dump_physmem_layout(stdout);
7700 else if (!strcmp(res->dump, "dump_memzone"))
7701 rte_memzone_dump(stdout);
7702 else if (!strcmp(res->dump, "dump_struct_sizes"))
7703 dump_struct_sizes();
7704 else if (!strcmp(res->dump, "dump_ring"))
7705 rte_ring_list_dump(stdout);
7706 else if (!strcmp(res->dump, "dump_mempool"))
7707 rte_mempool_list_dump(stdout);
7708 else if (!strcmp(res->dump, "dump_devargs"))
7709 rte_eal_devargs_dump(stdout);
7710 else if (!strcmp(res->dump, "dump_log_types"))
7711 rte_log_dump(stdout);
7714 cmdline_parse_token_string_t cmd_dump_dump =
7715 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7718 "dump_struct_sizes#"
7724 cmdline_parse_inst_t cmd_dump = {
7725 .f = cmd_dump_parsed, /* function to call */
7726 .data = NULL, /* 2nd arg of func */
7727 .help_str = "Dump status",
7728 .tokens = { /* token list, NULL terminated */
7729 (void *)&cmd_dump_dump,
7734 /* ******************************************************************************** */
7736 struct cmd_dump_one_result {
7737 cmdline_fixed_string_t dump;
7738 cmdline_fixed_string_t name;
7741 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7742 __attribute__((unused)) void *data)
7744 struct cmd_dump_one_result *res = parsed_result;
7746 if (!strcmp(res->dump, "dump_ring")) {
7748 r = rte_ring_lookup(res->name);
7750 cmdline_printf(cl, "Cannot find ring\n");
7753 rte_ring_dump(stdout, r);
7754 } else if (!strcmp(res->dump, "dump_mempool")) {
7755 struct rte_mempool *mp;
7756 mp = rte_mempool_lookup(res->name);
7758 cmdline_printf(cl, "Cannot find mempool\n");
7761 rte_mempool_dump(stdout, mp);
7765 cmdline_parse_token_string_t cmd_dump_one_dump =
7766 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7767 "dump_ring#dump_mempool");
7769 cmdline_parse_token_string_t cmd_dump_one_name =
7770 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7772 cmdline_parse_inst_t cmd_dump_one = {
7773 .f = cmd_dump_one_parsed, /* function to call */
7774 .data = NULL, /* 2nd arg of func */
7775 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7776 .tokens = { /* token list, NULL terminated */
7777 (void *)&cmd_dump_one_dump,
7778 (void *)&cmd_dump_one_name,
7783 /* *** Add/Del syn filter *** */
7784 struct cmd_syn_filter_result {
7785 cmdline_fixed_string_t filter;
7787 cmdline_fixed_string_t ops;
7788 cmdline_fixed_string_t priority;
7789 cmdline_fixed_string_t high;
7790 cmdline_fixed_string_t queue;
7795 cmd_syn_filter_parsed(void *parsed_result,
7796 __attribute__((unused)) struct cmdline *cl,
7797 __attribute__((unused)) void *data)
7799 struct cmd_syn_filter_result *res = parsed_result;
7800 struct rte_eth_syn_filter syn_filter;
7803 ret = rte_eth_dev_filter_supported(res->port_id,
7804 RTE_ETH_FILTER_SYN);
7806 printf("syn filter is not supported on port %u.\n",
7811 memset(&syn_filter, 0, sizeof(syn_filter));
7813 if (!strcmp(res->ops, "add")) {
7814 if (!strcmp(res->high, "high"))
7815 syn_filter.hig_pri = 1;
7817 syn_filter.hig_pri = 0;
7819 syn_filter.queue = res->queue_id;
7820 ret = rte_eth_dev_filter_ctrl(res->port_id,
7825 ret = rte_eth_dev_filter_ctrl(res->port_id,
7827 RTE_ETH_FILTER_DELETE,
7831 printf("syn filter programming error: (%s)\n",
7835 cmdline_parse_token_string_t cmd_syn_filter_filter =
7836 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7837 filter, "syn_filter");
7838 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7839 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7841 cmdline_parse_token_string_t cmd_syn_filter_ops =
7842 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7844 cmdline_parse_token_string_t cmd_syn_filter_priority =
7845 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7846 priority, "priority");
7847 cmdline_parse_token_string_t cmd_syn_filter_high =
7848 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7850 cmdline_parse_token_string_t cmd_syn_filter_queue =
7851 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7853 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7854 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7857 cmdline_parse_inst_t cmd_syn_filter = {
7858 .f = cmd_syn_filter_parsed,
7860 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7861 "<queue_id>: Add/Delete syn filter",
7863 (void *)&cmd_syn_filter_filter,
7864 (void *)&cmd_syn_filter_port_id,
7865 (void *)&cmd_syn_filter_ops,
7866 (void *)&cmd_syn_filter_priority,
7867 (void *)&cmd_syn_filter_high,
7868 (void *)&cmd_syn_filter_queue,
7869 (void *)&cmd_syn_filter_queue_id,
7874 /* *** ADD/REMOVE A 2tuple FILTER *** */
7875 struct cmd_2tuple_filter_result {
7876 cmdline_fixed_string_t filter;
7878 cmdline_fixed_string_t ops;
7879 cmdline_fixed_string_t dst_port;
7880 uint16_t dst_port_value;
7881 cmdline_fixed_string_t protocol;
7882 uint8_t protocol_value;
7883 cmdline_fixed_string_t mask;
7885 cmdline_fixed_string_t tcp_flags;
7886 uint8_t tcp_flags_value;
7887 cmdline_fixed_string_t priority;
7888 uint8_t priority_value;
7889 cmdline_fixed_string_t queue;
7894 cmd_2tuple_filter_parsed(void *parsed_result,
7895 __attribute__((unused)) struct cmdline *cl,
7896 __attribute__((unused)) void *data)
7898 struct rte_eth_ntuple_filter filter;
7899 struct cmd_2tuple_filter_result *res = parsed_result;
7902 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7904 printf("ntuple filter is not supported on port %u.\n",
7909 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7911 filter.flags = RTE_2TUPLE_FLAGS;
7912 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7913 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7914 filter.proto = res->protocol_value;
7915 filter.priority = res->priority_value;
7916 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7917 printf("nonzero tcp_flags is only meaningful"
7918 " when protocol is TCP.\n");
7921 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7922 printf("invalid TCP flags.\n");
7926 if (res->tcp_flags_value != 0) {
7927 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7928 filter.tcp_flags = res->tcp_flags_value;
7931 /* need convert to big endian. */
7932 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7933 filter.queue = res->queue_id;
7935 if (!strcmp(res->ops, "add"))
7936 ret = rte_eth_dev_filter_ctrl(res->port_id,
7937 RTE_ETH_FILTER_NTUPLE,
7941 ret = rte_eth_dev_filter_ctrl(res->port_id,
7942 RTE_ETH_FILTER_NTUPLE,
7943 RTE_ETH_FILTER_DELETE,
7946 printf("2tuple filter programming error: (%s)\n",
7951 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7952 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7953 filter, "2tuple_filter");
7954 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7955 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7957 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7958 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7960 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7961 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7962 dst_port, "dst_port");
7963 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7964 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7965 dst_port_value, UINT16);
7966 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7967 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7968 protocol, "protocol");
7969 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7970 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7971 protocol_value, UINT8);
7972 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7973 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7975 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7976 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7978 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7979 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7980 tcp_flags, "tcp_flags");
7981 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7982 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7983 tcp_flags_value, UINT8);
7984 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7985 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7986 priority, "priority");
7987 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7988 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7989 priority_value, UINT8);
7990 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7991 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7993 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7994 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7997 cmdline_parse_inst_t cmd_2tuple_filter = {
7998 .f = cmd_2tuple_filter_parsed,
8000 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8001 "<value> mask <value> tcp_flags <value> priority <value> queue "
8002 "<queue_id>: Add a 2tuple filter",
8004 (void *)&cmd_2tuple_filter_filter,
8005 (void *)&cmd_2tuple_filter_port_id,
8006 (void *)&cmd_2tuple_filter_ops,
8007 (void *)&cmd_2tuple_filter_dst_port,
8008 (void *)&cmd_2tuple_filter_dst_port_value,
8009 (void *)&cmd_2tuple_filter_protocol,
8010 (void *)&cmd_2tuple_filter_protocol_value,
8011 (void *)&cmd_2tuple_filter_mask,
8012 (void *)&cmd_2tuple_filter_mask_value,
8013 (void *)&cmd_2tuple_filter_tcp_flags,
8014 (void *)&cmd_2tuple_filter_tcp_flags_value,
8015 (void *)&cmd_2tuple_filter_priority,
8016 (void *)&cmd_2tuple_filter_priority_value,
8017 (void *)&cmd_2tuple_filter_queue,
8018 (void *)&cmd_2tuple_filter_queue_id,
8023 /* *** ADD/REMOVE A 5tuple FILTER *** */
8024 struct cmd_5tuple_filter_result {
8025 cmdline_fixed_string_t filter;
8027 cmdline_fixed_string_t ops;
8028 cmdline_fixed_string_t dst_ip;
8029 cmdline_ipaddr_t dst_ip_value;
8030 cmdline_fixed_string_t src_ip;
8031 cmdline_ipaddr_t src_ip_value;
8032 cmdline_fixed_string_t dst_port;
8033 uint16_t dst_port_value;
8034 cmdline_fixed_string_t src_port;
8035 uint16_t src_port_value;
8036 cmdline_fixed_string_t protocol;
8037 uint8_t protocol_value;
8038 cmdline_fixed_string_t mask;
8040 cmdline_fixed_string_t tcp_flags;
8041 uint8_t tcp_flags_value;
8042 cmdline_fixed_string_t priority;
8043 uint8_t priority_value;
8044 cmdline_fixed_string_t queue;
8049 cmd_5tuple_filter_parsed(void *parsed_result,
8050 __attribute__((unused)) struct cmdline *cl,
8051 __attribute__((unused)) void *data)
8053 struct rte_eth_ntuple_filter filter;
8054 struct cmd_5tuple_filter_result *res = parsed_result;
8057 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8059 printf("ntuple filter is not supported on port %u.\n",
8064 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8066 filter.flags = RTE_5TUPLE_FLAGS;
8067 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8068 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8069 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8070 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8071 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8072 filter.proto = res->protocol_value;
8073 filter.priority = res->priority_value;
8074 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8075 printf("nonzero tcp_flags is only meaningful"
8076 " when protocol is TCP.\n");
8079 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8080 printf("invalid TCP flags.\n");
8084 if (res->tcp_flags_value != 0) {
8085 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8086 filter.tcp_flags = res->tcp_flags_value;
8089 if (res->dst_ip_value.family == AF_INET)
8090 /* no need to convert, already big endian. */
8091 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8093 if (filter.dst_ip_mask == 0) {
8094 printf("can not support ipv6 involved compare.\n");
8100 if (res->src_ip_value.family == AF_INET)
8101 /* no need to convert, already big endian. */
8102 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8104 if (filter.src_ip_mask == 0) {
8105 printf("can not support ipv6 involved compare.\n");
8110 /* need convert to big endian. */
8111 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8112 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8113 filter.queue = res->queue_id;
8115 if (!strcmp(res->ops, "add"))
8116 ret = rte_eth_dev_filter_ctrl(res->port_id,
8117 RTE_ETH_FILTER_NTUPLE,
8121 ret = rte_eth_dev_filter_ctrl(res->port_id,
8122 RTE_ETH_FILTER_NTUPLE,
8123 RTE_ETH_FILTER_DELETE,
8126 printf("5tuple filter programming error: (%s)\n",
8130 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8131 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8132 filter, "5tuple_filter");
8133 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8134 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8136 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8137 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8139 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8140 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8142 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8143 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8145 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8146 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8148 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8149 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8151 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8152 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8153 dst_port, "dst_port");
8154 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8155 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8156 dst_port_value, UINT16);
8157 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8158 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8159 src_port, "src_port");
8160 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8161 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8162 src_port_value, UINT16);
8163 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8164 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8165 protocol, "protocol");
8166 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8167 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8168 protocol_value, UINT8);
8169 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8170 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8172 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8173 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8175 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8176 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8177 tcp_flags, "tcp_flags");
8178 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8179 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8180 tcp_flags_value, UINT8);
8181 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8182 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8183 priority, "priority");
8184 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8185 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8186 priority_value, UINT8);
8187 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8188 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8190 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8191 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8194 cmdline_parse_inst_t cmd_5tuple_filter = {
8195 .f = cmd_5tuple_filter_parsed,
8197 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8198 "src_ip <value> dst_port <value> src_port <value> "
8199 "protocol <value> mask <value> tcp_flags <value> "
8200 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8202 (void *)&cmd_5tuple_filter_filter,
8203 (void *)&cmd_5tuple_filter_port_id,
8204 (void *)&cmd_5tuple_filter_ops,
8205 (void *)&cmd_5tuple_filter_dst_ip,
8206 (void *)&cmd_5tuple_filter_dst_ip_value,
8207 (void *)&cmd_5tuple_filter_src_ip,
8208 (void *)&cmd_5tuple_filter_src_ip_value,
8209 (void *)&cmd_5tuple_filter_dst_port,
8210 (void *)&cmd_5tuple_filter_dst_port_value,
8211 (void *)&cmd_5tuple_filter_src_port,
8212 (void *)&cmd_5tuple_filter_src_port_value,
8213 (void *)&cmd_5tuple_filter_protocol,
8214 (void *)&cmd_5tuple_filter_protocol_value,
8215 (void *)&cmd_5tuple_filter_mask,
8216 (void *)&cmd_5tuple_filter_mask_value,
8217 (void *)&cmd_5tuple_filter_tcp_flags,
8218 (void *)&cmd_5tuple_filter_tcp_flags_value,
8219 (void *)&cmd_5tuple_filter_priority,
8220 (void *)&cmd_5tuple_filter_priority_value,
8221 (void *)&cmd_5tuple_filter_queue,
8222 (void *)&cmd_5tuple_filter_queue_id,
8227 /* *** ADD/REMOVE A flex FILTER *** */
8228 struct cmd_flex_filter_result {
8229 cmdline_fixed_string_t filter;
8230 cmdline_fixed_string_t ops;
8232 cmdline_fixed_string_t len;
8234 cmdline_fixed_string_t bytes;
8235 cmdline_fixed_string_t bytes_value;
8236 cmdline_fixed_string_t mask;
8237 cmdline_fixed_string_t mask_value;
8238 cmdline_fixed_string_t priority;
8239 uint8_t priority_value;
8240 cmdline_fixed_string_t queue;
8244 static int xdigit2val(unsigned char c)
8249 else if (isupper(c))
8257 cmd_flex_filter_parsed(void *parsed_result,
8258 __attribute__((unused)) struct cmdline *cl,
8259 __attribute__((unused)) void *data)
8262 struct rte_eth_flex_filter filter;
8263 struct cmd_flex_filter_result *res = parsed_result;
8264 char *bytes_ptr, *mask_ptr;
8265 uint16_t len, i, j = 0;
8270 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8271 printf("the len exceed the max length 128\n");
8274 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8275 filter.len = res->len_value;
8276 filter.priority = res->priority_value;
8277 filter.queue = res->queue_id;
8278 bytes_ptr = res->bytes_value;
8279 mask_ptr = res->mask_value;
8281 /* translate bytes string to array. */
8282 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8283 (bytes_ptr[1] == 'X')))
8285 len = strnlen(bytes_ptr, res->len_value * 2);
8286 if (len == 0 || (len % 8 != 0)) {
8287 printf("please check len and bytes input\n");
8290 for (i = 0; i < len; i++) {
8292 if (isxdigit(c) == 0) {
8293 /* invalid characters. */
8294 printf("invalid input\n");
8297 val = xdigit2val(c);
8300 filter.bytes[j] = byte;
8301 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8308 /* translate mask string to uint8_t array. */
8309 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8310 (mask_ptr[1] == 'X')))
8312 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8314 printf("invalid input\n");
8319 for (i = 0; i < len; i++) {
8321 if (isxdigit(c) == 0) {
8322 /* invalid characters. */
8323 printf("invalid input\n");
8326 val = xdigit2val(c);
8329 filter.mask[j] = byte;
8330 printf("mask[%d]:%02x ", j, filter.mask[j]);
8338 if (!strcmp(res->ops, "add"))
8339 ret = rte_eth_dev_filter_ctrl(res->port_id,
8340 RTE_ETH_FILTER_FLEXIBLE,
8344 ret = rte_eth_dev_filter_ctrl(res->port_id,
8345 RTE_ETH_FILTER_FLEXIBLE,
8346 RTE_ETH_FILTER_DELETE,
8350 printf("flex filter setting error: (%s)\n", strerror(-ret));
8353 cmdline_parse_token_string_t cmd_flex_filter_filter =
8354 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8355 filter, "flex_filter");
8356 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8357 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8359 cmdline_parse_token_string_t cmd_flex_filter_ops =
8360 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8362 cmdline_parse_token_string_t cmd_flex_filter_len =
8363 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8365 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8366 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8368 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8369 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8371 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8372 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8374 cmdline_parse_token_string_t cmd_flex_filter_mask =
8375 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8377 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8378 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8380 cmdline_parse_token_string_t cmd_flex_filter_priority =
8381 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8382 priority, "priority");
8383 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8384 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8385 priority_value, UINT8);
8386 cmdline_parse_token_string_t cmd_flex_filter_queue =
8387 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8389 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8390 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8392 cmdline_parse_inst_t cmd_flex_filter = {
8393 .f = cmd_flex_filter_parsed,
8395 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8396 "<value> mask <value> priority <value> queue <queue_id>: "
8397 "Add/Del a flex filter",
8399 (void *)&cmd_flex_filter_filter,
8400 (void *)&cmd_flex_filter_port_id,
8401 (void *)&cmd_flex_filter_ops,
8402 (void *)&cmd_flex_filter_len,
8403 (void *)&cmd_flex_filter_len_value,
8404 (void *)&cmd_flex_filter_bytes,
8405 (void *)&cmd_flex_filter_bytes_value,
8406 (void *)&cmd_flex_filter_mask,
8407 (void *)&cmd_flex_filter_mask_value,
8408 (void *)&cmd_flex_filter_priority,
8409 (void *)&cmd_flex_filter_priority_value,
8410 (void *)&cmd_flex_filter_queue,
8411 (void *)&cmd_flex_filter_queue_id,
8416 /* *** Filters Control *** */
8418 /* *** deal with ethertype filter *** */
8419 struct cmd_ethertype_filter_result {
8420 cmdline_fixed_string_t filter;
8422 cmdline_fixed_string_t ops;
8423 cmdline_fixed_string_t mac;
8424 struct ether_addr mac_addr;
8425 cmdline_fixed_string_t ethertype;
8426 uint16_t ethertype_value;
8427 cmdline_fixed_string_t drop;
8428 cmdline_fixed_string_t queue;
8432 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8433 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8434 filter, "ethertype_filter");
8435 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8436 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8438 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8439 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8441 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8442 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8443 mac, "mac_addr#mac_ignr");
8444 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8445 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8447 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8448 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8449 ethertype, "ethertype");
8450 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8451 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8452 ethertype_value, UINT16);
8453 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8454 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8456 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8457 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8459 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8460 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8464 cmd_ethertype_filter_parsed(void *parsed_result,
8465 __attribute__((unused)) struct cmdline *cl,
8466 __attribute__((unused)) void *data)
8468 struct cmd_ethertype_filter_result *res = parsed_result;
8469 struct rte_eth_ethertype_filter filter;
8472 ret = rte_eth_dev_filter_supported(res->port_id,
8473 RTE_ETH_FILTER_ETHERTYPE);
8475 printf("ethertype filter is not supported on port %u.\n",
8480 memset(&filter, 0, sizeof(filter));
8481 if (!strcmp(res->mac, "mac_addr")) {
8482 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8483 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8484 sizeof(struct ether_addr));
8486 if (!strcmp(res->drop, "drop"))
8487 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8488 filter.ether_type = res->ethertype_value;
8489 filter.queue = res->queue_id;
8491 if (!strcmp(res->ops, "add"))
8492 ret = rte_eth_dev_filter_ctrl(res->port_id,
8493 RTE_ETH_FILTER_ETHERTYPE,
8497 ret = rte_eth_dev_filter_ctrl(res->port_id,
8498 RTE_ETH_FILTER_ETHERTYPE,
8499 RTE_ETH_FILTER_DELETE,
8502 printf("ethertype filter programming error: (%s)\n",
8506 cmdline_parse_inst_t cmd_ethertype_filter = {
8507 .f = cmd_ethertype_filter_parsed,
8509 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8510 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8511 "Add or delete an ethertype filter entry",
8513 (void *)&cmd_ethertype_filter_filter,
8514 (void *)&cmd_ethertype_filter_port_id,
8515 (void *)&cmd_ethertype_filter_ops,
8516 (void *)&cmd_ethertype_filter_mac,
8517 (void *)&cmd_ethertype_filter_mac_addr,
8518 (void *)&cmd_ethertype_filter_ethertype,
8519 (void *)&cmd_ethertype_filter_ethertype_value,
8520 (void *)&cmd_ethertype_filter_drop,
8521 (void *)&cmd_ethertype_filter_queue,
8522 (void *)&cmd_ethertype_filter_queue_id,
8527 /* *** deal with flow director filter *** */
8528 struct cmd_flow_director_result {
8529 cmdline_fixed_string_t flow_director_filter;
8531 cmdline_fixed_string_t mode;
8532 cmdline_fixed_string_t mode_value;
8533 cmdline_fixed_string_t ops;
8534 cmdline_fixed_string_t flow;
8535 cmdline_fixed_string_t flow_type;
8536 cmdline_fixed_string_t ether;
8537 uint16_t ether_type;
8538 cmdline_fixed_string_t src;
8539 cmdline_ipaddr_t ip_src;
8541 cmdline_fixed_string_t dst;
8542 cmdline_ipaddr_t ip_dst;
8544 cmdline_fixed_string_t verify_tag;
8545 uint32_t verify_tag_value;
8546 cmdline_ipaddr_t tos;
8548 cmdline_ipaddr_t proto;
8549 uint8_t proto_value;
8550 cmdline_ipaddr_t ttl;
8552 cmdline_fixed_string_t vlan;
8553 uint16_t vlan_value;
8554 cmdline_fixed_string_t flexbytes;
8555 cmdline_fixed_string_t flexbytes_value;
8556 cmdline_fixed_string_t pf_vf;
8557 cmdline_fixed_string_t drop;
8558 cmdline_fixed_string_t queue;
8560 cmdline_fixed_string_t fd_id;
8561 uint32_t fd_id_value;
8562 cmdline_fixed_string_t mac;
8563 struct ether_addr mac_addr;
8564 cmdline_fixed_string_t tunnel;
8565 cmdline_fixed_string_t tunnel_type;
8566 cmdline_fixed_string_t tunnel_id;
8567 uint32_t tunnel_id_value;
8571 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8574 const char *p, *p0 = q_arg;
8576 unsigned long int_fld;
8577 char *str_fld[max_num];
8582 p = strchr(p0, '(');
8586 p0 = strchr(p, ')');
8591 if (size >= sizeof(s))
8594 snprintf(s, sizeof(s), "%.*s", size, p);
8595 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8596 if (ret < 0 || ret > max_num)
8598 for (i = 0; i < ret; i++) {
8600 int_fld = strtoul(str_fld[i], &end, 0);
8601 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8603 flexbytes[i] = (uint8_t)int_fld;
8609 str2flowtype(char *string)
8612 static const struct {
8615 } flowtype_str[] = {
8616 {"raw", RTE_ETH_FLOW_RAW},
8617 {"ipv4", RTE_ETH_FLOW_IPV4},
8618 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8619 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8620 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8621 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8622 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8623 {"ipv6", RTE_ETH_FLOW_IPV6},
8624 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8625 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8626 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8627 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8628 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8629 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8632 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8633 if (!strcmp(flowtype_str[i].str, string))
8634 return flowtype_str[i].type;
8636 return RTE_ETH_FLOW_UNKNOWN;
8639 static enum rte_eth_fdir_tunnel_type
8640 str2fdir_tunneltype(char *string)
8644 static const struct {
8646 enum rte_eth_fdir_tunnel_type type;
8647 } tunneltype_str[] = {
8648 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8649 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8652 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8653 if (!strcmp(tunneltype_str[i].str, string))
8654 return tunneltype_str[i].type;
8656 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8659 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8661 if ((ip_addr).family == AF_INET) \
8662 (ip) = (ip_addr).addr.ipv4.s_addr; \
8664 printf("invalid parameter.\n"); \
8669 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8671 if ((ip_addr).family == AF_INET6) \
8672 (void)rte_memcpy(&(ip), \
8673 &((ip_addr).addr.ipv6), \
8674 sizeof(struct in6_addr)); \
8676 printf("invalid parameter.\n"); \
8682 cmd_flow_director_filter_parsed(void *parsed_result,
8683 __attribute__((unused)) struct cmdline *cl,
8684 __attribute__((unused)) void *data)
8686 struct cmd_flow_director_result *res = parsed_result;
8687 struct rte_eth_fdir_filter entry;
8688 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8690 unsigned long vf_id;
8693 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8695 printf("flow director is not supported on port %u.\n",
8699 memset(flexbytes, 0, sizeof(flexbytes));
8700 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8702 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8703 if (strcmp(res->mode_value, "MAC-VLAN")) {
8704 printf("Please set mode to MAC-VLAN.\n");
8707 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8708 if (strcmp(res->mode_value, "Tunnel")) {
8709 printf("Please set mode to Tunnel.\n");
8713 if (strcmp(res->mode_value, "IP")) {
8714 printf("Please set mode to IP.\n");
8717 entry.input.flow_type = str2flowtype(res->flow_type);
8720 ret = parse_flexbytes(res->flexbytes_value,
8722 RTE_ETH_FDIR_MAX_FLEXLEN);
8724 printf("error: Cannot parse flexbytes input.\n");
8728 switch (entry.input.flow_type) {
8729 case RTE_ETH_FLOW_FRAG_IPV4:
8730 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8731 entry.input.flow.ip4_flow.proto = res->proto_value;
8732 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8733 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8734 IPV4_ADDR_TO_UINT(res->ip_dst,
8735 entry.input.flow.ip4_flow.dst_ip);
8736 IPV4_ADDR_TO_UINT(res->ip_src,
8737 entry.input.flow.ip4_flow.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.udp4_flow.dst_port =
8742 rte_cpu_to_be_16(res->port_dst);
8743 entry.input.flow.udp4_flow.src_port =
8744 rte_cpu_to_be_16(res->port_src);
8746 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8747 IPV4_ADDR_TO_UINT(res->ip_dst,
8748 entry.input.flow.sctp4_flow.ip.dst_ip);
8749 IPV4_ADDR_TO_UINT(res->ip_src,
8750 entry.input.flow.sctp4_flow.ip.src_ip);
8751 entry.input.flow.ip4_flow.tos = res->tos_value;
8752 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8753 /* need convert to big endian. */
8754 entry.input.flow.sctp4_flow.dst_port =
8755 rte_cpu_to_be_16(res->port_dst);
8756 entry.input.flow.sctp4_flow.src_port =
8757 rte_cpu_to_be_16(res->port_src);
8758 entry.input.flow.sctp4_flow.verify_tag =
8759 rte_cpu_to_be_32(res->verify_tag_value);
8761 case RTE_ETH_FLOW_FRAG_IPV6:
8762 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8763 entry.input.flow.ipv6_flow.proto = res->proto_value;
8764 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8765 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8766 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8767 entry.input.flow.ipv6_flow.dst_ip);
8768 IPV6_ADDR_TO_ARRAY(res->ip_src,
8769 entry.input.flow.ipv6_flow.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.udp6_flow.dst_port =
8774 rte_cpu_to_be_16(res->port_dst);
8775 entry.input.flow.udp6_flow.src_port =
8776 rte_cpu_to_be_16(res->port_src);
8778 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8779 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8780 entry.input.flow.sctp6_flow.ip.dst_ip);
8781 IPV6_ADDR_TO_ARRAY(res->ip_src,
8782 entry.input.flow.sctp6_flow.ip.src_ip);
8783 entry.input.flow.ipv6_flow.tc = res->tos_value;
8784 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8785 /* need convert to big endian. */
8786 entry.input.flow.sctp6_flow.dst_port =
8787 rte_cpu_to_be_16(res->port_dst);
8788 entry.input.flow.sctp6_flow.src_port =
8789 rte_cpu_to_be_16(res->port_src);
8790 entry.input.flow.sctp6_flow.verify_tag =
8791 rte_cpu_to_be_32(res->verify_tag_value);
8793 case RTE_ETH_FLOW_L2_PAYLOAD:
8794 entry.input.flow.l2_flow.ether_type =
8795 rte_cpu_to_be_16(res->ether_type);
8801 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8802 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8804 sizeof(struct ether_addr));
8806 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8807 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8809 sizeof(struct ether_addr));
8810 entry.input.flow.tunnel_flow.tunnel_type =
8811 str2fdir_tunneltype(res->tunnel_type);
8812 entry.input.flow.tunnel_flow.tunnel_id =
8813 rte_cpu_to_be_32(res->tunnel_id_value);
8816 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8818 RTE_ETH_FDIR_MAX_FLEXLEN);
8820 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8822 entry.action.flex_off = 0; /*use 0 by default */
8823 if (!strcmp(res->drop, "drop"))
8824 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8826 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8828 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8829 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8830 if (!strcmp(res->pf_vf, "pf"))
8831 entry.input.flow_ext.is_vf = 0;
8832 else if (!strncmp(res->pf_vf, "vf", 2)) {
8833 struct rte_eth_dev_info dev_info;
8835 memset(&dev_info, 0, sizeof(dev_info));
8836 rte_eth_dev_info_get(res->port_id, &dev_info);
8838 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8839 if (errno != 0 || *end != '\0' ||
8840 vf_id >= dev_info.max_vfs) {
8841 printf("invalid parameter %s.\n", res->pf_vf);
8844 entry.input.flow_ext.is_vf = 1;
8845 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8847 printf("invalid parameter %s.\n", res->pf_vf);
8852 /* set to report FD ID by default */
8853 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8854 entry.action.rx_queue = res->queue_id;
8855 entry.soft_id = res->fd_id_value;
8856 if (!strcmp(res->ops, "add"))
8857 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8858 RTE_ETH_FILTER_ADD, &entry);
8859 else if (!strcmp(res->ops, "del"))
8860 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8861 RTE_ETH_FILTER_DELETE, &entry);
8863 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8864 RTE_ETH_FILTER_UPDATE, &entry);
8866 printf("flow director programming error: (%s)\n",
8870 cmdline_parse_token_string_t cmd_flow_director_filter =
8871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8872 flow_director_filter, "flow_director_filter");
8873 cmdline_parse_token_num_t cmd_flow_director_port_id =
8874 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8876 cmdline_parse_token_string_t cmd_flow_director_ops =
8877 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8878 ops, "add#del#update");
8879 cmdline_parse_token_string_t cmd_flow_director_flow =
8880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8882 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8883 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8884 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8885 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8886 cmdline_parse_token_string_t cmd_flow_director_ether =
8887 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8889 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8890 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8891 ether_type, UINT16);
8892 cmdline_parse_token_string_t cmd_flow_director_src =
8893 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8895 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8896 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8898 cmdline_parse_token_num_t cmd_flow_director_port_src =
8899 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8901 cmdline_parse_token_string_t cmd_flow_director_dst =
8902 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8904 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8905 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8907 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8908 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8910 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8911 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8912 verify_tag, "verify_tag");
8913 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8914 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8915 verify_tag_value, UINT32);
8916 cmdline_parse_token_string_t cmd_flow_director_tos =
8917 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8919 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8920 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8922 cmdline_parse_token_string_t cmd_flow_director_proto =
8923 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8925 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8926 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8927 proto_value, UINT8);
8928 cmdline_parse_token_string_t cmd_flow_director_ttl =
8929 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8931 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8932 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8934 cmdline_parse_token_string_t cmd_flow_director_vlan =
8935 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8937 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8938 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8939 vlan_value, UINT16);
8940 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8942 flexbytes, "flexbytes");
8943 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8944 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8945 flexbytes_value, NULL);
8946 cmdline_parse_token_string_t cmd_flow_director_drop =
8947 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8949 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8952 cmdline_parse_token_string_t cmd_flow_director_queue =
8953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8955 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8956 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8958 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8961 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8962 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8963 fd_id_value, UINT32);
8965 cmdline_parse_token_string_t cmd_flow_director_mode =
8966 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8968 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8969 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8971 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8972 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8973 mode_value, "MAC-VLAN");
8974 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8975 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8976 mode_value, "Tunnel");
8977 cmdline_parse_token_string_t cmd_flow_director_mac =
8978 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8980 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8981 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8983 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8984 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8986 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8987 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8988 tunnel_type, "NVGRE#VxLAN");
8989 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8990 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8991 tunnel_id, "tunnel-id");
8992 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8993 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8994 tunnel_id_value, UINT32);
8996 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8997 .f = cmd_flow_director_filter_parsed,
8999 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9000 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9001 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9002 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9003 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9004 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9005 "fd_id <fd_id_value>: "
9006 "Add or delete an ip flow director entry on NIC",
9008 (void *)&cmd_flow_director_filter,
9009 (void *)&cmd_flow_director_port_id,
9010 (void *)&cmd_flow_director_mode,
9011 (void *)&cmd_flow_director_mode_ip,
9012 (void *)&cmd_flow_director_ops,
9013 (void *)&cmd_flow_director_flow,
9014 (void *)&cmd_flow_director_flow_type,
9015 (void *)&cmd_flow_director_src,
9016 (void *)&cmd_flow_director_ip_src,
9017 (void *)&cmd_flow_director_dst,
9018 (void *)&cmd_flow_director_ip_dst,
9019 (void *)&cmd_flow_director_tos,
9020 (void *)&cmd_flow_director_tos_value,
9021 (void *)&cmd_flow_director_proto,
9022 (void *)&cmd_flow_director_proto_value,
9023 (void *)&cmd_flow_director_ttl,
9024 (void *)&cmd_flow_director_ttl_value,
9025 (void *)&cmd_flow_director_vlan,
9026 (void *)&cmd_flow_director_vlan_value,
9027 (void *)&cmd_flow_director_flexbytes,
9028 (void *)&cmd_flow_director_flexbytes_value,
9029 (void *)&cmd_flow_director_drop,
9030 (void *)&cmd_flow_director_pf_vf,
9031 (void *)&cmd_flow_director_queue,
9032 (void *)&cmd_flow_director_queue_id,
9033 (void *)&cmd_flow_director_fd_id,
9034 (void *)&cmd_flow_director_fd_id_value,
9039 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9040 .f = cmd_flow_director_filter_parsed,
9042 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9043 "director entry on NIC",
9045 (void *)&cmd_flow_director_filter,
9046 (void *)&cmd_flow_director_port_id,
9047 (void *)&cmd_flow_director_mode,
9048 (void *)&cmd_flow_director_mode_ip,
9049 (void *)&cmd_flow_director_ops,
9050 (void *)&cmd_flow_director_flow,
9051 (void *)&cmd_flow_director_flow_type,
9052 (void *)&cmd_flow_director_src,
9053 (void *)&cmd_flow_director_ip_src,
9054 (void *)&cmd_flow_director_port_src,
9055 (void *)&cmd_flow_director_dst,
9056 (void *)&cmd_flow_director_ip_dst,
9057 (void *)&cmd_flow_director_port_dst,
9058 (void *)&cmd_flow_director_tos,
9059 (void *)&cmd_flow_director_tos_value,
9060 (void *)&cmd_flow_director_ttl,
9061 (void *)&cmd_flow_director_ttl_value,
9062 (void *)&cmd_flow_director_vlan,
9063 (void *)&cmd_flow_director_vlan_value,
9064 (void *)&cmd_flow_director_flexbytes,
9065 (void *)&cmd_flow_director_flexbytes_value,
9066 (void *)&cmd_flow_director_drop,
9067 (void *)&cmd_flow_director_pf_vf,
9068 (void *)&cmd_flow_director_queue,
9069 (void *)&cmd_flow_director_queue_id,
9070 (void *)&cmd_flow_director_fd_id,
9071 (void *)&cmd_flow_director_fd_id_value,
9076 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9077 .f = cmd_flow_director_filter_parsed,
9079 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9080 "director entry on NIC",
9082 (void *)&cmd_flow_director_filter,
9083 (void *)&cmd_flow_director_port_id,
9084 (void *)&cmd_flow_director_mode,
9085 (void *)&cmd_flow_director_mode_ip,
9086 (void *)&cmd_flow_director_ops,
9087 (void *)&cmd_flow_director_flow,
9088 (void *)&cmd_flow_director_flow_type,
9089 (void *)&cmd_flow_director_src,
9090 (void *)&cmd_flow_director_ip_src,
9091 (void *)&cmd_flow_director_port_dst,
9092 (void *)&cmd_flow_director_dst,
9093 (void *)&cmd_flow_director_ip_dst,
9094 (void *)&cmd_flow_director_port_dst,
9095 (void *)&cmd_flow_director_verify_tag,
9096 (void *)&cmd_flow_director_verify_tag_value,
9097 (void *)&cmd_flow_director_tos,
9098 (void *)&cmd_flow_director_tos_value,
9099 (void *)&cmd_flow_director_ttl,
9100 (void *)&cmd_flow_director_ttl_value,
9101 (void *)&cmd_flow_director_vlan,
9102 (void *)&cmd_flow_director_vlan_value,
9103 (void *)&cmd_flow_director_flexbytes,
9104 (void *)&cmd_flow_director_flexbytes_value,
9105 (void *)&cmd_flow_director_drop,
9106 (void *)&cmd_flow_director_pf_vf,
9107 (void *)&cmd_flow_director_queue,
9108 (void *)&cmd_flow_director_queue_id,
9109 (void *)&cmd_flow_director_fd_id,
9110 (void *)&cmd_flow_director_fd_id_value,
9115 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9116 .f = cmd_flow_director_filter_parsed,
9118 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9119 "director entry on NIC",
9121 (void *)&cmd_flow_director_filter,
9122 (void *)&cmd_flow_director_port_id,
9123 (void *)&cmd_flow_director_mode,
9124 (void *)&cmd_flow_director_mode_ip,
9125 (void *)&cmd_flow_director_ops,
9126 (void *)&cmd_flow_director_flow,
9127 (void *)&cmd_flow_director_flow_type,
9128 (void *)&cmd_flow_director_ether,
9129 (void *)&cmd_flow_director_ether_type,
9130 (void *)&cmd_flow_director_flexbytes,
9131 (void *)&cmd_flow_director_flexbytes_value,
9132 (void *)&cmd_flow_director_drop,
9133 (void *)&cmd_flow_director_pf_vf,
9134 (void *)&cmd_flow_director_queue,
9135 (void *)&cmd_flow_director_queue_id,
9136 (void *)&cmd_flow_director_fd_id,
9137 (void *)&cmd_flow_director_fd_id_value,
9142 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9143 .f = cmd_flow_director_filter_parsed,
9145 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9146 "director entry on NIC",
9148 (void *)&cmd_flow_director_filter,
9149 (void *)&cmd_flow_director_port_id,
9150 (void *)&cmd_flow_director_mode,
9151 (void *)&cmd_flow_director_mode_mac_vlan,
9152 (void *)&cmd_flow_director_ops,
9153 (void *)&cmd_flow_director_mac,
9154 (void *)&cmd_flow_director_mac_addr,
9155 (void *)&cmd_flow_director_vlan,
9156 (void *)&cmd_flow_director_vlan_value,
9157 (void *)&cmd_flow_director_flexbytes,
9158 (void *)&cmd_flow_director_flexbytes_value,
9159 (void *)&cmd_flow_director_drop,
9160 (void *)&cmd_flow_director_queue,
9161 (void *)&cmd_flow_director_queue_id,
9162 (void *)&cmd_flow_director_fd_id,
9163 (void *)&cmd_flow_director_fd_id_value,
9168 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9169 .f = cmd_flow_director_filter_parsed,
9171 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9172 "director entry on NIC",
9174 (void *)&cmd_flow_director_filter,
9175 (void *)&cmd_flow_director_port_id,
9176 (void *)&cmd_flow_director_mode,
9177 (void *)&cmd_flow_director_mode_tunnel,
9178 (void *)&cmd_flow_director_ops,
9179 (void *)&cmd_flow_director_mac,
9180 (void *)&cmd_flow_director_mac_addr,
9181 (void *)&cmd_flow_director_vlan,
9182 (void *)&cmd_flow_director_vlan_value,
9183 (void *)&cmd_flow_director_tunnel,
9184 (void *)&cmd_flow_director_tunnel_type,
9185 (void *)&cmd_flow_director_tunnel_id,
9186 (void *)&cmd_flow_director_tunnel_id_value,
9187 (void *)&cmd_flow_director_flexbytes,
9188 (void *)&cmd_flow_director_flexbytes_value,
9189 (void *)&cmd_flow_director_drop,
9190 (void *)&cmd_flow_director_queue,
9191 (void *)&cmd_flow_director_queue_id,
9192 (void *)&cmd_flow_director_fd_id,
9193 (void *)&cmd_flow_director_fd_id_value,
9198 struct cmd_flush_flow_director_result {
9199 cmdline_fixed_string_t flush_flow_director;
9203 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9204 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9205 flush_flow_director, "flush_flow_director");
9206 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9207 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9211 cmd_flush_flow_director_parsed(void *parsed_result,
9212 __attribute__((unused)) struct cmdline *cl,
9213 __attribute__((unused)) void *data)
9215 struct cmd_flow_director_result *res = parsed_result;
9218 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9220 printf("flow director is not supported on port %u.\n",
9225 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9226 RTE_ETH_FILTER_FLUSH, NULL);
9228 printf("flow director table flushing error: (%s)\n",
9232 cmdline_parse_inst_t cmd_flush_flow_director = {
9233 .f = cmd_flush_flow_director_parsed,
9235 .help_str = "flush_flow_director <port_id>: "
9236 "Flush all flow director entries of a device on NIC",
9238 (void *)&cmd_flush_flow_director_flush,
9239 (void *)&cmd_flush_flow_director_port_id,
9244 /* *** deal with flow director mask *** */
9245 struct cmd_flow_director_mask_result {
9246 cmdline_fixed_string_t flow_director_mask;
9248 cmdline_fixed_string_t mode;
9249 cmdline_fixed_string_t mode_value;
9250 cmdline_fixed_string_t vlan;
9252 cmdline_fixed_string_t src_mask;
9253 cmdline_ipaddr_t ipv4_src;
9254 cmdline_ipaddr_t ipv6_src;
9256 cmdline_fixed_string_t dst_mask;
9257 cmdline_ipaddr_t ipv4_dst;
9258 cmdline_ipaddr_t ipv6_dst;
9260 cmdline_fixed_string_t mac;
9261 uint8_t mac_addr_byte_mask;
9262 cmdline_fixed_string_t tunnel_id;
9263 uint32_t tunnel_id_mask;
9264 cmdline_fixed_string_t tunnel_type;
9265 uint8_t tunnel_type_mask;
9269 cmd_flow_director_mask_parsed(void *parsed_result,
9270 __attribute__((unused)) struct cmdline *cl,
9271 __attribute__((unused)) void *data)
9273 struct cmd_flow_director_mask_result *res = parsed_result;
9274 struct rte_eth_fdir_masks *mask;
9275 struct rte_port *port;
9277 if (res->port_id > nb_ports) {
9278 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9282 port = &ports[res->port_id];
9283 /** Check if the port is not started **/
9284 if (port->port_status != RTE_PORT_STOPPED) {
9285 printf("Please stop port %d first\n", res->port_id);
9289 mask = &port->dev_conf.fdir_conf.mask;
9291 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9292 if (strcmp(res->mode_value, "MAC-VLAN")) {
9293 printf("Please set mode to MAC-VLAN.\n");
9297 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9298 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9299 if (strcmp(res->mode_value, "Tunnel")) {
9300 printf("Please set mode to Tunnel.\n");
9304 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9305 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9306 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9307 mask->tunnel_type_mask = res->tunnel_type_mask;
9309 if (strcmp(res->mode_value, "IP")) {
9310 printf("Please set mode to IP.\n");
9314 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9315 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9316 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9317 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9318 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9319 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9320 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9323 cmd_reconfig_device_queue(res->port_id, 1, 1);
9326 cmdline_parse_token_string_t cmd_flow_director_mask =
9327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9328 flow_director_mask, "flow_director_mask");
9329 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9330 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9332 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9335 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9336 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9338 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9340 src_mask, "src_mask");
9341 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9342 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9344 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9345 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9347 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9348 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9350 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9352 dst_mask, "dst_mask");
9353 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9354 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9356 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9357 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9359 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9360 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9363 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9366 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9369 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9371 mode_value, "MAC-VLAN");
9372 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9373 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9374 mode_value, "Tunnel");
9375 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9378 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9379 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9380 mac_addr_byte_mask, UINT8);
9381 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9383 tunnel_type, "tunnel-type");
9384 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9385 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9386 tunnel_type_mask, UINT8);
9387 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9389 tunnel_id, "tunnel-id");
9390 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9391 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9392 tunnel_id_mask, UINT32);
9394 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9395 .f = cmd_flow_director_mask_parsed,
9397 .help_str = "flow_director_mask ... : "
9398 "Set IP mode flow director's mask on NIC",
9400 (void *)&cmd_flow_director_mask,
9401 (void *)&cmd_flow_director_mask_port_id,
9402 (void *)&cmd_flow_director_mask_mode,
9403 (void *)&cmd_flow_director_mask_mode_ip,
9404 (void *)&cmd_flow_director_mask_vlan,
9405 (void *)&cmd_flow_director_mask_vlan_value,
9406 (void *)&cmd_flow_director_mask_src,
9407 (void *)&cmd_flow_director_mask_ipv4_src,
9408 (void *)&cmd_flow_director_mask_ipv6_src,
9409 (void *)&cmd_flow_director_mask_port_src,
9410 (void *)&cmd_flow_director_mask_dst,
9411 (void *)&cmd_flow_director_mask_ipv4_dst,
9412 (void *)&cmd_flow_director_mask_ipv6_dst,
9413 (void *)&cmd_flow_director_mask_port_dst,
9418 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9419 .f = cmd_flow_director_mask_parsed,
9421 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9422 "flow director's mask on NIC",
9424 (void *)&cmd_flow_director_mask,
9425 (void *)&cmd_flow_director_mask_port_id,
9426 (void *)&cmd_flow_director_mask_mode,
9427 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9428 (void *)&cmd_flow_director_mask_vlan,
9429 (void *)&cmd_flow_director_mask_vlan_value,
9434 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9435 .f = cmd_flow_director_mask_parsed,
9437 .help_str = "flow_director_mask ... : Set tunnel mode "
9438 "flow director's mask on NIC",
9440 (void *)&cmd_flow_director_mask,
9441 (void *)&cmd_flow_director_mask_port_id,
9442 (void *)&cmd_flow_director_mask_mode,
9443 (void *)&cmd_flow_director_mask_mode_tunnel,
9444 (void *)&cmd_flow_director_mask_vlan,
9445 (void *)&cmd_flow_director_mask_vlan_value,
9446 (void *)&cmd_flow_director_mask_mac,
9447 (void *)&cmd_flow_director_mask_mac_value,
9448 (void *)&cmd_flow_director_mask_tunnel_type,
9449 (void *)&cmd_flow_director_mask_tunnel_type_value,
9450 (void *)&cmd_flow_director_mask_tunnel_id,
9451 (void *)&cmd_flow_director_mask_tunnel_id_value,
9456 /* *** deal with flow director mask on flexible payload *** */
9457 struct cmd_flow_director_flex_mask_result {
9458 cmdline_fixed_string_t flow_director_flexmask;
9460 cmdline_fixed_string_t flow;
9461 cmdline_fixed_string_t flow_type;
9462 cmdline_fixed_string_t mask;
9466 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9467 __attribute__((unused)) struct cmdline *cl,
9468 __attribute__((unused)) void *data)
9470 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9471 struct rte_eth_fdir_info fdir_info;
9472 struct rte_eth_fdir_flex_mask flex_mask;
9473 struct rte_port *port;
9474 uint32_t flow_type_mask;
9478 if (res->port_id > nb_ports) {
9479 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9483 port = &ports[res->port_id];
9484 /** Check if the port is not started **/
9485 if (port->port_status != RTE_PORT_STOPPED) {
9486 printf("Please stop port %d first\n", res->port_id);
9490 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9491 ret = parse_flexbytes(res->mask,
9493 RTE_ETH_FDIR_MAX_FLEXLEN);
9495 printf("error: Cannot parse mask input.\n");
9499 memset(&fdir_info, 0, sizeof(fdir_info));
9500 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9501 RTE_ETH_FILTER_INFO, &fdir_info);
9503 printf("Cannot get FDir filter info\n");
9507 if (!strcmp(res->flow_type, "none")) {
9508 /* means don't specify the flow type */
9509 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9510 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9511 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9512 0, sizeof(struct rte_eth_fdir_flex_mask));
9513 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9514 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9516 sizeof(struct rte_eth_fdir_flex_mask));
9517 cmd_reconfig_device_queue(res->port_id, 1, 1);
9520 flow_type_mask = fdir_info.flow_types_mask[0];
9521 if (!strcmp(res->flow_type, "all")) {
9522 if (!flow_type_mask) {
9523 printf("No flow type supported\n");
9526 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9527 if (flow_type_mask & (1 << i)) {
9528 flex_mask.flow_type = i;
9529 fdir_set_flex_mask(res->port_id, &flex_mask);
9532 cmd_reconfig_device_queue(res->port_id, 1, 1);
9535 flex_mask.flow_type = str2flowtype(res->flow_type);
9536 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9537 printf("Flow type %s not supported on port %d\n",
9538 res->flow_type, res->port_id);
9541 fdir_set_flex_mask(res->port_id, &flex_mask);
9542 cmd_reconfig_device_queue(res->port_id, 1, 1);
9545 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9546 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9547 flow_director_flexmask,
9548 "flow_director_flex_mask");
9549 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9550 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9552 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9553 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9555 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9556 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9557 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9558 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9559 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9563 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9564 .f = cmd_flow_director_flex_mask_parsed,
9566 .help_str = "flow_director_flex_mask ... : "
9567 "Set flow director's flex mask on NIC",
9569 (void *)&cmd_flow_director_flexmask,
9570 (void *)&cmd_flow_director_flexmask_port_id,
9571 (void *)&cmd_flow_director_flexmask_flow,
9572 (void *)&cmd_flow_director_flexmask_flow_type,
9573 (void *)&cmd_flow_director_flexmask_mask,
9578 /* *** deal with flow director flexible payload configuration *** */
9579 struct cmd_flow_director_flexpayload_result {
9580 cmdline_fixed_string_t flow_director_flexpayload;
9582 cmdline_fixed_string_t payload_layer;
9583 cmdline_fixed_string_t payload_cfg;
9587 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9590 const char *p, *p0 = q_arg;
9592 unsigned long int_fld;
9593 char *str_fld[max_num];
9598 p = strchr(p0, '(');
9602 p0 = strchr(p, ')');
9607 if (size >= sizeof(s))
9610 snprintf(s, sizeof(s), "%.*s", size, p);
9611 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9612 if (ret < 0 || ret > max_num)
9614 for (i = 0; i < ret; i++) {
9616 int_fld = strtoul(str_fld[i], &end, 0);
9617 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9619 offsets[i] = (uint16_t)int_fld;
9625 cmd_flow_director_flxpld_parsed(void *parsed_result,
9626 __attribute__((unused)) struct cmdline *cl,
9627 __attribute__((unused)) void *data)
9629 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9630 struct rte_eth_flex_payload_cfg flex_cfg;
9631 struct rte_port *port;
9634 if (res->port_id > nb_ports) {
9635 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9639 port = &ports[res->port_id];
9640 /** Check if the port is not started **/
9641 if (port->port_status != RTE_PORT_STOPPED) {
9642 printf("Please stop port %d first\n", res->port_id);
9646 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9648 if (!strcmp(res->payload_layer, "raw"))
9649 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9650 else if (!strcmp(res->payload_layer, "l2"))
9651 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9652 else if (!strcmp(res->payload_layer, "l3"))
9653 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9654 else if (!strcmp(res->payload_layer, "l4"))
9655 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9657 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9658 RTE_ETH_FDIR_MAX_FLEXLEN);
9660 printf("error: Cannot parse flex payload input.\n");
9664 fdir_set_flex_payload(res->port_id, &flex_cfg);
9665 cmd_reconfig_device_queue(res->port_id, 1, 1);
9668 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9669 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9670 flow_director_flexpayload,
9671 "flow_director_flex_payload");
9672 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9673 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9675 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9676 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9677 payload_layer, "raw#l2#l3#l4");
9678 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9679 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9682 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9683 .f = cmd_flow_director_flxpld_parsed,
9685 .help_str = "flow_director_flexpayload ... : "
9686 "Set flow director's flex payload on NIC",
9688 (void *)&cmd_flow_director_flexpayload,
9689 (void *)&cmd_flow_director_flexpayload_port_id,
9690 (void *)&cmd_flow_director_flexpayload_payload_layer,
9691 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9696 /* Generic flow interface command. */
9697 extern cmdline_parse_inst_t cmd_flow;
9699 /* *** Classification Filters Control *** */
9700 /* *** Get symmetric hash enable per port *** */
9701 struct cmd_get_sym_hash_ena_per_port_result {
9702 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9707 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9708 __rte_unused struct cmdline *cl,
9709 __rte_unused void *data)
9711 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9712 struct rte_eth_hash_filter_info info;
9715 if (rte_eth_dev_filter_supported(res->port_id,
9716 RTE_ETH_FILTER_HASH) < 0) {
9717 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9722 memset(&info, 0, sizeof(info));
9723 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9724 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9725 RTE_ETH_FILTER_GET, &info);
9728 printf("Cannot get symmetric hash enable per port "
9729 "on port %u\n", res->port_id);
9733 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9734 "enabled" : "disabled", res->port_id);
9737 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9738 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9739 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9740 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9741 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9744 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9745 .f = cmd_get_sym_hash_per_port_parsed,
9747 .help_str = "get_sym_hash_ena_per_port <port_id>",
9749 (void *)&cmd_get_sym_hash_ena_per_port_all,
9750 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9755 /* *** Set symmetric hash enable per port *** */
9756 struct cmd_set_sym_hash_ena_per_port_result {
9757 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9758 cmdline_fixed_string_t enable;
9763 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9764 __rte_unused struct cmdline *cl,
9765 __rte_unused void *data)
9767 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9768 struct rte_eth_hash_filter_info info;
9771 if (rte_eth_dev_filter_supported(res->port_id,
9772 RTE_ETH_FILTER_HASH) < 0) {
9773 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9778 memset(&info, 0, sizeof(info));
9779 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9780 if (!strcmp(res->enable, "enable"))
9781 info.info.enable = 1;
9782 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9783 RTE_ETH_FILTER_SET, &info);
9785 printf("Cannot set symmetric hash enable per port on "
9786 "port %u\n", res->port_id);
9789 printf("Symmetric hash has been set to %s on port %u\n",
9790 res->enable, res->port_id);
9793 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9794 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9795 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9796 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9797 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9799 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9800 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9801 enable, "enable#disable");
9803 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9804 .f = cmd_set_sym_hash_per_port_parsed,
9806 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9808 (void *)&cmd_set_sym_hash_ena_per_port_all,
9809 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9810 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9815 /* Get global config of hash function */
9816 struct cmd_get_hash_global_config_result {
9817 cmdline_fixed_string_t get_hash_global_config;
9822 flowtype_to_str(uint16_t ftype)
9829 {"ipv4", RTE_ETH_FLOW_IPV4},
9830 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9831 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9832 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9833 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9834 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9835 {"ipv6", RTE_ETH_FLOW_IPV6},
9836 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9837 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9838 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9839 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9840 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9841 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9842 {"port", RTE_ETH_FLOW_PORT},
9843 {"vxlan", RTE_ETH_FLOW_VXLAN},
9844 {"geneve", RTE_ETH_FLOW_GENEVE},
9845 {"nvgre", RTE_ETH_FLOW_NVGRE},
9848 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9849 if (ftype_table[i].ftype == ftype)
9850 return ftype_table[i].str;
9857 cmd_get_hash_global_config_parsed(void *parsed_result,
9858 __rte_unused struct cmdline *cl,
9859 __rte_unused void *data)
9861 struct cmd_get_hash_global_config_result *res = parsed_result;
9862 struct rte_eth_hash_filter_info info;
9863 uint32_t idx, offset;
9868 if (rte_eth_dev_filter_supported(res->port_id,
9869 RTE_ETH_FILTER_HASH) < 0) {
9870 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9875 memset(&info, 0, sizeof(info));
9876 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9877 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9878 RTE_ETH_FILTER_GET, &info);
9880 printf("Cannot get hash global configurations by port %d\n",
9885 switch (info.info.global_conf.hash_func) {
9886 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9887 printf("Hash function is Toeplitz\n");
9889 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9890 printf("Hash function is Simple XOR\n");
9893 printf("Unknown hash function\n");
9897 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9898 idx = i / UINT32_BIT;
9899 offset = i % UINT32_BIT;
9900 if (!(info.info.global_conf.valid_bit_mask[idx] &
9903 str = flowtype_to_str(i);
9906 printf("Symmetric hash is %s globally for flow type %s "
9908 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9909 (1UL << offset)) ? "enabled" : "disabled"), str,
9914 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9915 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9916 get_hash_global_config, "get_hash_global_config");
9917 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9918 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9921 cmdline_parse_inst_t cmd_get_hash_global_config = {
9922 .f = cmd_get_hash_global_config_parsed,
9924 .help_str = "get_hash_global_config <port_id>",
9926 (void *)&cmd_get_hash_global_config_all,
9927 (void *)&cmd_get_hash_global_config_port_id,
9932 /* Set global config of hash function */
9933 struct cmd_set_hash_global_config_result {
9934 cmdline_fixed_string_t set_hash_global_config;
9936 cmdline_fixed_string_t hash_func;
9937 cmdline_fixed_string_t flow_type;
9938 cmdline_fixed_string_t enable;
9942 cmd_set_hash_global_config_parsed(void *parsed_result,
9943 __rte_unused struct cmdline *cl,
9944 __rte_unused void *data)
9946 struct cmd_set_hash_global_config_result *res = parsed_result;
9947 struct rte_eth_hash_filter_info info;
9948 uint32_t ftype, idx, offset;
9951 if (rte_eth_dev_filter_supported(res->port_id,
9952 RTE_ETH_FILTER_HASH) < 0) {
9953 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9957 memset(&info, 0, sizeof(info));
9958 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9959 if (!strcmp(res->hash_func, "toeplitz"))
9960 info.info.global_conf.hash_func =
9961 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9962 else if (!strcmp(res->hash_func, "simple_xor"))
9963 info.info.global_conf.hash_func =
9964 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9965 else if (!strcmp(res->hash_func, "default"))
9966 info.info.global_conf.hash_func =
9967 RTE_ETH_HASH_FUNCTION_DEFAULT;
9969 ftype = str2flowtype(res->flow_type);
9970 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9971 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9972 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9973 if (!strcmp(res->enable, "enable"))
9974 info.info.global_conf.sym_hash_enable_mask[idx] |=
9976 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9977 RTE_ETH_FILTER_SET, &info);
9979 printf("Cannot set global hash configurations by port %d\n",
9982 printf("Global hash configurations have been set "
9983 "succcessfully by port %d\n", res->port_id);
9986 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9987 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9988 set_hash_global_config, "set_hash_global_config");
9989 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9990 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9992 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9993 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9994 hash_func, "toeplitz#simple_xor#default");
9995 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9996 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9998 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9999 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10000 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10001 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10002 enable, "enable#disable");
10004 cmdline_parse_inst_t cmd_set_hash_global_config = {
10005 .f = cmd_set_hash_global_config_parsed,
10007 .help_str = "set_hash_global_config <port_id> "
10008 "toeplitz|simple_xor|default "
10009 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10010 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10011 "l2_payload enable|disable",
10013 (void *)&cmd_set_hash_global_config_all,
10014 (void *)&cmd_set_hash_global_config_port_id,
10015 (void *)&cmd_set_hash_global_config_hash_func,
10016 (void *)&cmd_set_hash_global_config_flow_type,
10017 (void *)&cmd_set_hash_global_config_enable,
10022 /* Set hash input set */
10023 struct cmd_set_hash_input_set_result {
10024 cmdline_fixed_string_t set_hash_input_set;
10026 cmdline_fixed_string_t flow_type;
10027 cmdline_fixed_string_t inset_field;
10028 cmdline_fixed_string_t select;
10031 static enum rte_eth_input_set_field
10032 str2inset(char *string)
10036 static const struct {
10038 enum rte_eth_input_set_field inset;
10039 } inset_table[] = {
10040 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10041 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10042 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10043 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10044 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10045 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10046 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10047 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10048 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10049 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10050 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10051 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10052 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10053 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10054 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10055 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10056 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10057 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10058 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10059 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10060 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10061 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10062 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10063 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10064 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10065 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10066 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10067 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10068 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10069 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10070 {"none", RTE_ETH_INPUT_SET_NONE},
10073 for (i = 0; i < RTE_DIM(inset_table); i++) {
10074 if (!strcmp(string, inset_table[i].str))
10075 return inset_table[i].inset;
10078 return RTE_ETH_INPUT_SET_UNKNOWN;
10082 cmd_set_hash_input_set_parsed(void *parsed_result,
10083 __rte_unused struct cmdline *cl,
10084 __rte_unused void *data)
10086 struct cmd_set_hash_input_set_result *res = parsed_result;
10087 struct rte_eth_hash_filter_info info;
10089 memset(&info, 0, sizeof(info));
10090 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10091 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10092 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10093 info.info.input_set_conf.inset_size = 1;
10094 if (!strcmp(res->select, "select"))
10095 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10096 else if (!strcmp(res->select, "add"))
10097 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10098 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10099 RTE_ETH_FILTER_SET, &info);
10102 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10103 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10104 set_hash_input_set, "set_hash_input_set");
10105 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10106 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10108 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10109 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10111 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10112 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10113 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10114 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10116 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10117 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10118 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10119 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10120 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10122 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10123 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10124 select, "select#add");
10126 cmdline_parse_inst_t cmd_set_hash_input_set = {
10127 .f = cmd_set_hash_input_set_parsed,
10129 .help_str = "set_hash_input_set <port_id> "
10130 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10131 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10132 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10133 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10134 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10135 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10136 "fld-7th|fld-8th|none select|add",
10138 (void *)&cmd_set_hash_input_set_cmd,
10139 (void *)&cmd_set_hash_input_set_port_id,
10140 (void *)&cmd_set_hash_input_set_flow_type,
10141 (void *)&cmd_set_hash_input_set_field,
10142 (void *)&cmd_set_hash_input_set_select,
10147 /* Set flow director input set */
10148 struct cmd_set_fdir_input_set_result {
10149 cmdline_fixed_string_t set_fdir_input_set;
10151 cmdline_fixed_string_t flow_type;
10152 cmdline_fixed_string_t inset_field;
10153 cmdline_fixed_string_t select;
10157 cmd_set_fdir_input_set_parsed(void *parsed_result,
10158 __rte_unused struct cmdline *cl,
10159 __rte_unused void *data)
10161 struct cmd_set_fdir_input_set_result *res = parsed_result;
10162 struct rte_eth_fdir_filter_info info;
10164 memset(&info, 0, sizeof(info));
10165 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10166 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10167 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10168 info.info.input_set_conf.inset_size = 1;
10169 if (!strcmp(res->select, "select"))
10170 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10171 else if (!strcmp(res->select, "add"))
10172 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10173 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10174 RTE_ETH_FILTER_SET, &info);
10177 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10178 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10179 set_fdir_input_set, "set_fdir_input_set");
10180 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10181 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10183 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10184 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10186 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10187 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10188 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10189 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10191 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10192 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10193 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10194 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10195 "sctp-veri-tag#none");
10196 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10197 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10198 select, "select#add");
10200 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10201 .f = cmd_set_fdir_input_set_parsed,
10203 .help_str = "set_fdir_input_set <port_id> "
10204 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10205 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10206 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10207 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10208 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10209 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10210 "sctp-veri-tag|none select|add",
10212 (void *)&cmd_set_fdir_input_set_cmd,
10213 (void *)&cmd_set_fdir_input_set_port_id,
10214 (void *)&cmd_set_fdir_input_set_flow_type,
10215 (void *)&cmd_set_fdir_input_set_field,
10216 (void *)&cmd_set_fdir_input_set_select,
10221 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10222 struct cmd_mcast_addr_result {
10223 cmdline_fixed_string_t mcast_addr_cmd;
10224 cmdline_fixed_string_t what;
10226 struct ether_addr mc_addr;
10229 static void cmd_mcast_addr_parsed(void *parsed_result,
10230 __attribute__((unused)) struct cmdline *cl,
10231 __attribute__((unused)) void *data)
10233 struct cmd_mcast_addr_result *res = parsed_result;
10235 if (!is_multicast_ether_addr(&res->mc_addr)) {
10236 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10237 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10238 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10239 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10242 if (strcmp(res->what, "add") == 0)
10243 mcast_addr_add(res->port_num, &res->mc_addr);
10245 mcast_addr_remove(res->port_num, &res->mc_addr);
10248 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10249 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10250 mcast_addr_cmd, "mcast_addr");
10251 cmdline_parse_token_string_t cmd_mcast_addr_what =
10252 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10254 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10255 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10256 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10257 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10259 cmdline_parse_inst_t cmd_mcast_addr = {
10260 .f = cmd_mcast_addr_parsed,
10262 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10263 "Add/Remove multicast MAC address on port_id",
10265 (void *)&cmd_mcast_addr_cmd,
10266 (void *)&cmd_mcast_addr_what,
10267 (void *)&cmd_mcast_addr_portnum,
10268 (void *)&cmd_mcast_addr_addr,
10273 /* l2 tunnel config
10274 * only support E-tag now.
10277 /* Ether type config */
10278 struct cmd_config_l2_tunnel_eth_type_result {
10279 cmdline_fixed_string_t port;
10280 cmdline_fixed_string_t config;
10281 cmdline_fixed_string_t all;
10283 cmdline_fixed_string_t l2_tunnel;
10284 cmdline_fixed_string_t l2_tunnel_type;
10285 cmdline_fixed_string_t eth_type;
10286 uint16_t eth_type_val;
10289 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10290 TOKEN_STRING_INITIALIZER
10291 (struct cmd_config_l2_tunnel_eth_type_result,
10293 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10294 TOKEN_STRING_INITIALIZER
10295 (struct cmd_config_l2_tunnel_eth_type_result,
10297 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10298 TOKEN_STRING_INITIALIZER
10299 (struct cmd_config_l2_tunnel_eth_type_result,
10301 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10302 TOKEN_NUM_INITIALIZER
10303 (struct cmd_config_l2_tunnel_eth_type_result,
10305 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10306 TOKEN_STRING_INITIALIZER
10307 (struct cmd_config_l2_tunnel_eth_type_result,
10308 l2_tunnel, "l2-tunnel");
10309 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10310 TOKEN_STRING_INITIALIZER
10311 (struct cmd_config_l2_tunnel_eth_type_result,
10312 l2_tunnel_type, "E-tag");
10313 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10314 TOKEN_STRING_INITIALIZER
10315 (struct cmd_config_l2_tunnel_eth_type_result,
10316 eth_type, "ether-type");
10317 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10318 TOKEN_NUM_INITIALIZER
10319 (struct cmd_config_l2_tunnel_eth_type_result,
10320 eth_type_val, UINT16);
10322 static enum rte_eth_tunnel_type
10323 str2fdir_l2_tunnel_type(char *string)
10327 static const struct {
10329 enum rte_eth_tunnel_type type;
10330 } l2_tunnel_type_str[] = {
10331 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10334 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10335 if (!strcmp(l2_tunnel_type_str[i].str, string))
10336 return l2_tunnel_type_str[i].type;
10338 return RTE_TUNNEL_TYPE_NONE;
10341 /* ether type config for all ports */
10343 cmd_config_l2_tunnel_eth_type_all_parsed
10344 (void *parsed_result,
10345 __attribute__((unused)) struct cmdline *cl,
10346 __attribute__((unused)) void *data)
10348 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10349 struct rte_eth_l2_tunnel_conf entry;
10352 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10353 entry.ether_type = res->eth_type_val;
10355 RTE_ETH_FOREACH_DEV(pid) {
10356 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10360 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10361 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10363 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10365 (void *)&cmd_config_l2_tunnel_eth_type_port,
10366 (void *)&cmd_config_l2_tunnel_eth_type_config,
10367 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10368 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10369 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10370 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10371 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10376 /* ether type config for a specific port */
10378 cmd_config_l2_tunnel_eth_type_specific_parsed(
10379 void *parsed_result,
10380 __attribute__((unused)) struct cmdline *cl,
10381 __attribute__((unused)) void *data)
10383 struct cmd_config_l2_tunnel_eth_type_result *res =
10385 struct rte_eth_l2_tunnel_conf entry;
10387 if (port_id_is_invalid(res->id, ENABLED_WARN))
10390 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10391 entry.ether_type = res->eth_type_val;
10393 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10396 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10397 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10399 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10401 (void *)&cmd_config_l2_tunnel_eth_type_port,
10402 (void *)&cmd_config_l2_tunnel_eth_type_config,
10403 (void *)&cmd_config_l2_tunnel_eth_type_id,
10404 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10405 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10406 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10407 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10412 /* Enable/disable l2 tunnel */
10413 struct cmd_config_l2_tunnel_en_dis_result {
10414 cmdline_fixed_string_t port;
10415 cmdline_fixed_string_t config;
10416 cmdline_fixed_string_t all;
10418 cmdline_fixed_string_t l2_tunnel;
10419 cmdline_fixed_string_t l2_tunnel_type;
10420 cmdline_fixed_string_t en_dis;
10423 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10424 TOKEN_STRING_INITIALIZER
10425 (struct cmd_config_l2_tunnel_en_dis_result,
10427 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10428 TOKEN_STRING_INITIALIZER
10429 (struct cmd_config_l2_tunnel_en_dis_result,
10431 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10432 TOKEN_STRING_INITIALIZER
10433 (struct cmd_config_l2_tunnel_en_dis_result,
10435 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10436 TOKEN_NUM_INITIALIZER
10437 (struct cmd_config_l2_tunnel_en_dis_result,
10439 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10440 TOKEN_STRING_INITIALIZER
10441 (struct cmd_config_l2_tunnel_en_dis_result,
10442 l2_tunnel, "l2-tunnel");
10443 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10444 TOKEN_STRING_INITIALIZER
10445 (struct cmd_config_l2_tunnel_en_dis_result,
10446 l2_tunnel_type, "E-tag");
10447 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10448 TOKEN_STRING_INITIALIZER
10449 (struct cmd_config_l2_tunnel_en_dis_result,
10450 en_dis, "enable#disable");
10452 /* enable/disable l2 tunnel for all ports */
10454 cmd_config_l2_tunnel_en_dis_all_parsed(
10455 void *parsed_result,
10456 __attribute__((unused)) struct cmdline *cl,
10457 __attribute__((unused)) void *data)
10459 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10460 struct rte_eth_l2_tunnel_conf entry;
10464 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10466 if (!strcmp("enable", res->en_dis))
10471 RTE_ETH_FOREACH_DEV(pid) {
10472 rte_eth_dev_l2_tunnel_offload_set(pid,
10474 ETH_L2_TUNNEL_ENABLE_MASK,
10479 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10480 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10482 .help_str = "port config all l2-tunnel E-tag enable|disable",
10484 (void *)&cmd_config_l2_tunnel_en_dis_port,
10485 (void *)&cmd_config_l2_tunnel_en_dis_config,
10486 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10487 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10488 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10489 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10494 /* enable/disable l2 tunnel for a port */
10496 cmd_config_l2_tunnel_en_dis_specific_parsed(
10497 void *parsed_result,
10498 __attribute__((unused)) struct cmdline *cl,
10499 __attribute__((unused)) void *data)
10501 struct cmd_config_l2_tunnel_en_dis_result *res =
10503 struct rte_eth_l2_tunnel_conf entry;
10505 if (port_id_is_invalid(res->id, ENABLED_WARN))
10508 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10510 if (!strcmp("enable", res->en_dis))
10511 rte_eth_dev_l2_tunnel_offload_set(res->id,
10513 ETH_L2_TUNNEL_ENABLE_MASK,
10516 rte_eth_dev_l2_tunnel_offload_set(res->id,
10518 ETH_L2_TUNNEL_ENABLE_MASK,
10522 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10523 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10525 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10527 (void *)&cmd_config_l2_tunnel_en_dis_port,
10528 (void *)&cmd_config_l2_tunnel_en_dis_config,
10529 (void *)&cmd_config_l2_tunnel_en_dis_id,
10530 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10531 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10532 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10537 /* E-tag configuration */
10539 /* Common result structure for all E-tag configuration */
10540 struct cmd_config_e_tag_result {
10541 cmdline_fixed_string_t e_tag;
10542 cmdline_fixed_string_t set;
10543 cmdline_fixed_string_t insertion;
10544 cmdline_fixed_string_t stripping;
10545 cmdline_fixed_string_t forwarding;
10546 cmdline_fixed_string_t filter;
10547 cmdline_fixed_string_t add;
10548 cmdline_fixed_string_t del;
10549 cmdline_fixed_string_t on;
10550 cmdline_fixed_string_t off;
10551 cmdline_fixed_string_t on_off;
10552 cmdline_fixed_string_t port_tag_id;
10553 uint32_t port_tag_id_val;
10554 cmdline_fixed_string_t e_tag_id;
10555 uint16_t e_tag_id_val;
10556 cmdline_fixed_string_t dst_pool;
10557 uint8_t dst_pool_val;
10558 cmdline_fixed_string_t port;
10560 cmdline_fixed_string_t vf;
10564 /* Common CLI fields for all E-tag configuration */
10565 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10566 TOKEN_STRING_INITIALIZER
10567 (struct cmd_config_e_tag_result,
10569 cmdline_parse_token_string_t cmd_config_e_tag_set =
10570 TOKEN_STRING_INITIALIZER
10571 (struct cmd_config_e_tag_result,
10573 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10574 TOKEN_STRING_INITIALIZER
10575 (struct cmd_config_e_tag_result,
10576 insertion, "insertion");
10577 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10578 TOKEN_STRING_INITIALIZER
10579 (struct cmd_config_e_tag_result,
10580 stripping, "stripping");
10581 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10582 TOKEN_STRING_INITIALIZER
10583 (struct cmd_config_e_tag_result,
10584 forwarding, "forwarding");
10585 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10586 TOKEN_STRING_INITIALIZER
10587 (struct cmd_config_e_tag_result,
10589 cmdline_parse_token_string_t cmd_config_e_tag_add =
10590 TOKEN_STRING_INITIALIZER
10591 (struct cmd_config_e_tag_result,
10593 cmdline_parse_token_string_t cmd_config_e_tag_del =
10594 TOKEN_STRING_INITIALIZER
10595 (struct cmd_config_e_tag_result,
10597 cmdline_parse_token_string_t cmd_config_e_tag_on =
10598 TOKEN_STRING_INITIALIZER
10599 (struct cmd_config_e_tag_result,
10601 cmdline_parse_token_string_t cmd_config_e_tag_off =
10602 TOKEN_STRING_INITIALIZER
10603 (struct cmd_config_e_tag_result,
10605 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10606 TOKEN_STRING_INITIALIZER
10607 (struct cmd_config_e_tag_result,
10609 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10610 TOKEN_STRING_INITIALIZER
10611 (struct cmd_config_e_tag_result,
10612 port_tag_id, "port-tag-id");
10613 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10614 TOKEN_NUM_INITIALIZER
10615 (struct cmd_config_e_tag_result,
10616 port_tag_id_val, UINT32);
10617 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10618 TOKEN_STRING_INITIALIZER
10619 (struct cmd_config_e_tag_result,
10620 e_tag_id, "e-tag-id");
10621 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10622 TOKEN_NUM_INITIALIZER
10623 (struct cmd_config_e_tag_result,
10624 e_tag_id_val, UINT16);
10625 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10626 TOKEN_STRING_INITIALIZER
10627 (struct cmd_config_e_tag_result,
10628 dst_pool, "dst-pool");
10629 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10630 TOKEN_NUM_INITIALIZER
10631 (struct cmd_config_e_tag_result,
10632 dst_pool_val, UINT8);
10633 cmdline_parse_token_string_t cmd_config_e_tag_port =
10634 TOKEN_STRING_INITIALIZER
10635 (struct cmd_config_e_tag_result,
10637 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10638 TOKEN_NUM_INITIALIZER
10639 (struct cmd_config_e_tag_result,
10641 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10642 TOKEN_STRING_INITIALIZER
10643 (struct cmd_config_e_tag_result,
10645 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10646 TOKEN_NUM_INITIALIZER
10647 (struct cmd_config_e_tag_result,
10650 /* E-tag insertion configuration */
10652 cmd_config_e_tag_insertion_en_parsed(
10653 void *parsed_result,
10654 __attribute__((unused)) struct cmdline *cl,
10655 __attribute__((unused)) void *data)
10657 struct cmd_config_e_tag_result *res =
10659 struct rte_eth_l2_tunnel_conf entry;
10661 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10664 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10665 entry.tunnel_id = res->port_tag_id_val;
10666 entry.vf_id = res->vf_id;
10667 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10669 ETH_L2_TUNNEL_INSERTION_MASK,
10674 cmd_config_e_tag_insertion_dis_parsed(
10675 void *parsed_result,
10676 __attribute__((unused)) struct cmdline *cl,
10677 __attribute__((unused)) void *data)
10679 struct cmd_config_e_tag_result *res =
10681 struct rte_eth_l2_tunnel_conf entry;
10683 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10686 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10687 entry.vf_id = res->vf_id;
10689 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10691 ETH_L2_TUNNEL_INSERTION_MASK,
10695 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10696 .f = cmd_config_e_tag_insertion_en_parsed,
10698 .help_str = "E-tag ... : E-tag insertion enable",
10700 (void *)&cmd_config_e_tag_e_tag,
10701 (void *)&cmd_config_e_tag_set,
10702 (void *)&cmd_config_e_tag_insertion,
10703 (void *)&cmd_config_e_tag_on,
10704 (void *)&cmd_config_e_tag_port_tag_id,
10705 (void *)&cmd_config_e_tag_port_tag_id_val,
10706 (void *)&cmd_config_e_tag_port,
10707 (void *)&cmd_config_e_tag_port_id,
10708 (void *)&cmd_config_e_tag_vf,
10709 (void *)&cmd_config_e_tag_vf_id,
10714 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10715 .f = cmd_config_e_tag_insertion_dis_parsed,
10717 .help_str = "E-tag ... : E-tag insertion disable",
10719 (void *)&cmd_config_e_tag_e_tag,
10720 (void *)&cmd_config_e_tag_set,
10721 (void *)&cmd_config_e_tag_insertion,
10722 (void *)&cmd_config_e_tag_off,
10723 (void *)&cmd_config_e_tag_port,
10724 (void *)&cmd_config_e_tag_port_id,
10725 (void *)&cmd_config_e_tag_vf,
10726 (void *)&cmd_config_e_tag_vf_id,
10731 /* E-tag stripping configuration */
10733 cmd_config_e_tag_stripping_parsed(
10734 void *parsed_result,
10735 __attribute__((unused)) struct cmdline *cl,
10736 __attribute__((unused)) void *data)
10738 struct cmd_config_e_tag_result *res =
10740 struct rte_eth_l2_tunnel_conf entry;
10742 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10745 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10747 if (!strcmp(res->on_off, "on"))
10748 rte_eth_dev_l2_tunnel_offload_set
10751 ETH_L2_TUNNEL_STRIPPING_MASK,
10754 rte_eth_dev_l2_tunnel_offload_set
10757 ETH_L2_TUNNEL_STRIPPING_MASK,
10761 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10762 .f = cmd_config_e_tag_stripping_parsed,
10764 .help_str = "E-tag ... : E-tag stripping enable/disable",
10766 (void *)&cmd_config_e_tag_e_tag,
10767 (void *)&cmd_config_e_tag_set,
10768 (void *)&cmd_config_e_tag_stripping,
10769 (void *)&cmd_config_e_tag_on_off,
10770 (void *)&cmd_config_e_tag_port,
10771 (void *)&cmd_config_e_tag_port_id,
10776 /* E-tag forwarding configuration */
10778 cmd_config_e_tag_forwarding_parsed(
10779 void *parsed_result,
10780 __attribute__((unused)) struct cmdline *cl,
10781 __attribute__((unused)) void *data)
10783 struct cmd_config_e_tag_result *res = parsed_result;
10784 struct rte_eth_l2_tunnel_conf entry;
10786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10789 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10791 if (!strcmp(res->on_off, "on"))
10792 rte_eth_dev_l2_tunnel_offload_set
10795 ETH_L2_TUNNEL_FORWARDING_MASK,
10798 rte_eth_dev_l2_tunnel_offload_set
10801 ETH_L2_TUNNEL_FORWARDING_MASK,
10805 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10806 .f = cmd_config_e_tag_forwarding_parsed,
10808 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10810 (void *)&cmd_config_e_tag_e_tag,
10811 (void *)&cmd_config_e_tag_set,
10812 (void *)&cmd_config_e_tag_forwarding,
10813 (void *)&cmd_config_e_tag_on_off,
10814 (void *)&cmd_config_e_tag_port,
10815 (void *)&cmd_config_e_tag_port_id,
10820 /* E-tag filter configuration */
10822 cmd_config_e_tag_filter_add_parsed(
10823 void *parsed_result,
10824 __attribute__((unused)) struct cmdline *cl,
10825 __attribute__((unused)) void *data)
10827 struct cmd_config_e_tag_result *res = parsed_result;
10828 struct rte_eth_l2_tunnel_conf entry;
10831 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10834 if (res->e_tag_id_val > 0x3fff) {
10835 printf("e-tag-id must be equal or less than 0x3fff.\n");
10839 ret = rte_eth_dev_filter_supported(res->port_id,
10840 RTE_ETH_FILTER_L2_TUNNEL);
10842 printf("E-tag filter is not supported on port %u.\n",
10847 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10848 entry.tunnel_id = res->e_tag_id_val;
10849 entry.pool = res->dst_pool_val;
10851 ret = rte_eth_dev_filter_ctrl(res->port_id,
10852 RTE_ETH_FILTER_L2_TUNNEL,
10853 RTE_ETH_FILTER_ADD,
10856 printf("E-tag filter programming error: (%s)\n",
10860 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10861 .f = cmd_config_e_tag_filter_add_parsed,
10863 .help_str = "E-tag ... : E-tag filter add",
10865 (void *)&cmd_config_e_tag_e_tag,
10866 (void *)&cmd_config_e_tag_set,
10867 (void *)&cmd_config_e_tag_filter,
10868 (void *)&cmd_config_e_tag_add,
10869 (void *)&cmd_config_e_tag_e_tag_id,
10870 (void *)&cmd_config_e_tag_e_tag_id_val,
10871 (void *)&cmd_config_e_tag_dst_pool,
10872 (void *)&cmd_config_e_tag_dst_pool_val,
10873 (void *)&cmd_config_e_tag_port,
10874 (void *)&cmd_config_e_tag_port_id,
10880 cmd_config_e_tag_filter_del_parsed(
10881 void *parsed_result,
10882 __attribute__((unused)) struct cmdline *cl,
10883 __attribute__((unused)) void *data)
10885 struct cmd_config_e_tag_result *res = parsed_result;
10886 struct rte_eth_l2_tunnel_conf entry;
10889 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10892 if (res->e_tag_id_val > 0x3fff) {
10893 printf("e-tag-id must be less than 0x3fff.\n");
10897 ret = rte_eth_dev_filter_supported(res->port_id,
10898 RTE_ETH_FILTER_L2_TUNNEL);
10900 printf("E-tag filter is not supported on port %u.\n",
10905 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10906 entry.tunnel_id = res->e_tag_id_val;
10908 ret = rte_eth_dev_filter_ctrl(res->port_id,
10909 RTE_ETH_FILTER_L2_TUNNEL,
10910 RTE_ETH_FILTER_DELETE,
10913 printf("E-tag filter programming error: (%s)\n",
10917 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10918 .f = cmd_config_e_tag_filter_del_parsed,
10920 .help_str = "E-tag ... : E-tag filter delete",
10922 (void *)&cmd_config_e_tag_e_tag,
10923 (void *)&cmd_config_e_tag_set,
10924 (void *)&cmd_config_e_tag_filter,
10925 (void *)&cmd_config_e_tag_del,
10926 (void *)&cmd_config_e_tag_e_tag_id,
10927 (void *)&cmd_config_e_tag_e_tag_id_val,
10928 (void *)&cmd_config_e_tag_port,
10929 (void *)&cmd_config_e_tag_port_id,
10934 /* vf vlan anti spoof configuration */
10936 /* Common result structure for vf vlan anti spoof */
10937 struct cmd_vf_vlan_anti_spoof_result {
10938 cmdline_fixed_string_t set;
10939 cmdline_fixed_string_t vf;
10940 cmdline_fixed_string_t vlan;
10941 cmdline_fixed_string_t antispoof;
10944 cmdline_fixed_string_t on_off;
10947 /* Common CLI fields for vf vlan anti spoof enable disable */
10948 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10949 TOKEN_STRING_INITIALIZER
10950 (struct cmd_vf_vlan_anti_spoof_result,
10952 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10953 TOKEN_STRING_INITIALIZER
10954 (struct cmd_vf_vlan_anti_spoof_result,
10956 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10957 TOKEN_STRING_INITIALIZER
10958 (struct cmd_vf_vlan_anti_spoof_result,
10960 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10961 TOKEN_STRING_INITIALIZER
10962 (struct cmd_vf_vlan_anti_spoof_result,
10963 antispoof, "antispoof");
10964 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10965 TOKEN_NUM_INITIALIZER
10966 (struct cmd_vf_vlan_anti_spoof_result,
10968 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10969 TOKEN_NUM_INITIALIZER
10970 (struct cmd_vf_vlan_anti_spoof_result,
10972 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10973 TOKEN_STRING_INITIALIZER
10974 (struct cmd_vf_vlan_anti_spoof_result,
10978 cmd_set_vf_vlan_anti_spoof_parsed(
10979 void *parsed_result,
10980 __attribute__((unused)) struct cmdline *cl,
10981 __attribute__((unused)) void *data)
10983 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10984 int ret = -ENOTSUP;
10986 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10988 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10991 #ifdef RTE_LIBRTE_IXGBE_PMD
10992 if (ret == -ENOTSUP)
10993 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10994 res->vf_id, is_on);
10996 #ifdef RTE_LIBRTE_I40E_PMD
10997 if (ret == -ENOTSUP)
10998 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10999 res->vf_id, is_on);
11006 printf("invalid vf_id %d\n", res->vf_id);
11009 printf("invalid port_id %d\n", res->port_id);
11012 printf("function not implemented\n");
11015 printf("programming error: (%s)\n", strerror(-ret));
11019 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11020 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11022 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11024 (void *)&cmd_vf_vlan_anti_spoof_set,
11025 (void *)&cmd_vf_vlan_anti_spoof_vf,
11026 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11027 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11028 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11029 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11030 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11035 /* vf mac anti spoof configuration */
11037 /* Common result structure for vf mac anti spoof */
11038 struct cmd_vf_mac_anti_spoof_result {
11039 cmdline_fixed_string_t set;
11040 cmdline_fixed_string_t vf;
11041 cmdline_fixed_string_t mac;
11042 cmdline_fixed_string_t antispoof;
11045 cmdline_fixed_string_t on_off;
11048 /* Common CLI fields for vf mac anti spoof enable disable */
11049 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11050 TOKEN_STRING_INITIALIZER
11051 (struct cmd_vf_mac_anti_spoof_result,
11053 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11054 TOKEN_STRING_INITIALIZER
11055 (struct cmd_vf_mac_anti_spoof_result,
11057 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11058 TOKEN_STRING_INITIALIZER
11059 (struct cmd_vf_mac_anti_spoof_result,
11061 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11062 TOKEN_STRING_INITIALIZER
11063 (struct cmd_vf_mac_anti_spoof_result,
11064 antispoof, "antispoof");
11065 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11066 TOKEN_NUM_INITIALIZER
11067 (struct cmd_vf_mac_anti_spoof_result,
11069 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11070 TOKEN_NUM_INITIALIZER
11071 (struct cmd_vf_mac_anti_spoof_result,
11073 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11074 TOKEN_STRING_INITIALIZER
11075 (struct cmd_vf_mac_anti_spoof_result,
11079 cmd_set_vf_mac_anti_spoof_parsed(
11080 void *parsed_result,
11081 __attribute__((unused)) struct cmdline *cl,
11082 __attribute__((unused)) void *data)
11084 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11085 int ret = -ENOTSUP;
11087 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11089 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11092 #ifdef RTE_LIBRTE_IXGBE_PMD
11093 if (ret == -ENOTSUP)
11094 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11095 res->vf_id, is_on);
11097 #ifdef RTE_LIBRTE_I40E_PMD
11098 if (ret == -ENOTSUP)
11099 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11100 res->vf_id, is_on);
11107 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11110 printf("invalid port_id %d\n", res->port_id);
11113 printf("function not implemented\n");
11116 printf("programming error: (%s)\n", strerror(-ret));
11120 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11121 .f = cmd_set_vf_mac_anti_spoof_parsed,
11123 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11125 (void *)&cmd_vf_mac_anti_spoof_set,
11126 (void *)&cmd_vf_mac_anti_spoof_vf,
11127 (void *)&cmd_vf_mac_anti_spoof_mac,
11128 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11129 (void *)&cmd_vf_mac_anti_spoof_port_id,
11130 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11131 (void *)&cmd_vf_mac_anti_spoof_on_off,
11136 /* vf vlan strip queue configuration */
11138 /* Common result structure for vf mac anti spoof */
11139 struct cmd_vf_vlan_stripq_result {
11140 cmdline_fixed_string_t set;
11141 cmdline_fixed_string_t vf;
11142 cmdline_fixed_string_t vlan;
11143 cmdline_fixed_string_t stripq;
11146 cmdline_fixed_string_t on_off;
11149 /* Common CLI fields for vf vlan strip enable disable */
11150 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11151 TOKEN_STRING_INITIALIZER
11152 (struct cmd_vf_vlan_stripq_result,
11154 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11155 TOKEN_STRING_INITIALIZER
11156 (struct cmd_vf_vlan_stripq_result,
11158 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11159 TOKEN_STRING_INITIALIZER
11160 (struct cmd_vf_vlan_stripq_result,
11162 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11163 TOKEN_STRING_INITIALIZER
11164 (struct cmd_vf_vlan_stripq_result,
11166 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11167 TOKEN_NUM_INITIALIZER
11168 (struct cmd_vf_vlan_stripq_result,
11170 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11171 TOKEN_NUM_INITIALIZER
11172 (struct cmd_vf_vlan_stripq_result,
11174 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11175 TOKEN_STRING_INITIALIZER
11176 (struct cmd_vf_vlan_stripq_result,
11180 cmd_set_vf_vlan_stripq_parsed(
11181 void *parsed_result,
11182 __attribute__((unused)) struct cmdline *cl,
11183 __attribute__((unused)) void *data)
11185 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11186 int ret = -ENOTSUP;
11188 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11190 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11193 #ifdef RTE_LIBRTE_IXGBE_PMD
11194 if (ret == -ENOTSUP)
11195 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11196 res->vf_id, is_on);
11198 #ifdef RTE_LIBRTE_I40E_PMD
11199 if (ret == -ENOTSUP)
11200 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11201 res->vf_id, is_on);
11208 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11211 printf("invalid port_id %d\n", res->port_id);
11214 printf("function not implemented\n");
11217 printf("programming error: (%s)\n", strerror(-ret));
11221 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11222 .f = cmd_set_vf_vlan_stripq_parsed,
11224 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11226 (void *)&cmd_vf_vlan_stripq_set,
11227 (void *)&cmd_vf_vlan_stripq_vf,
11228 (void *)&cmd_vf_vlan_stripq_vlan,
11229 (void *)&cmd_vf_vlan_stripq_stripq,
11230 (void *)&cmd_vf_vlan_stripq_port_id,
11231 (void *)&cmd_vf_vlan_stripq_vf_id,
11232 (void *)&cmd_vf_vlan_stripq_on_off,
11237 /* vf vlan insert configuration */
11239 /* Common result structure for vf vlan insert */
11240 struct cmd_vf_vlan_insert_result {
11241 cmdline_fixed_string_t set;
11242 cmdline_fixed_string_t vf;
11243 cmdline_fixed_string_t vlan;
11244 cmdline_fixed_string_t insert;
11250 /* Common CLI fields for vf vlan insert enable disable */
11251 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11252 TOKEN_STRING_INITIALIZER
11253 (struct cmd_vf_vlan_insert_result,
11255 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11256 TOKEN_STRING_INITIALIZER
11257 (struct cmd_vf_vlan_insert_result,
11259 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11260 TOKEN_STRING_INITIALIZER
11261 (struct cmd_vf_vlan_insert_result,
11263 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11264 TOKEN_STRING_INITIALIZER
11265 (struct cmd_vf_vlan_insert_result,
11267 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11268 TOKEN_NUM_INITIALIZER
11269 (struct cmd_vf_vlan_insert_result,
11271 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11272 TOKEN_NUM_INITIALIZER
11273 (struct cmd_vf_vlan_insert_result,
11275 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11276 TOKEN_NUM_INITIALIZER
11277 (struct cmd_vf_vlan_insert_result,
11281 cmd_set_vf_vlan_insert_parsed(
11282 void *parsed_result,
11283 __attribute__((unused)) struct cmdline *cl,
11284 __attribute__((unused)) void *data)
11286 struct cmd_vf_vlan_insert_result *res = parsed_result;
11287 int ret = -ENOTSUP;
11289 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11292 #ifdef RTE_LIBRTE_IXGBE_PMD
11293 if (ret == -ENOTSUP)
11294 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11297 #ifdef RTE_LIBRTE_I40E_PMD
11298 if (ret == -ENOTSUP)
11299 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11307 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11310 printf("invalid port_id %d\n", res->port_id);
11313 printf("function not implemented\n");
11316 printf("programming error: (%s)\n", strerror(-ret));
11320 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11321 .f = cmd_set_vf_vlan_insert_parsed,
11323 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11325 (void *)&cmd_vf_vlan_insert_set,
11326 (void *)&cmd_vf_vlan_insert_vf,
11327 (void *)&cmd_vf_vlan_insert_vlan,
11328 (void *)&cmd_vf_vlan_insert_insert,
11329 (void *)&cmd_vf_vlan_insert_port_id,
11330 (void *)&cmd_vf_vlan_insert_vf_id,
11331 (void *)&cmd_vf_vlan_insert_vlan_id,
11336 /* tx loopback configuration */
11338 /* Common result structure for tx loopback */
11339 struct cmd_tx_loopback_result {
11340 cmdline_fixed_string_t set;
11341 cmdline_fixed_string_t tx;
11342 cmdline_fixed_string_t loopback;
11344 cmdline_fixed_string_t on_off;
11347 /* Common CLI fields for tx loopback enable disable */
11348 cmdline_parse_token_string_t cmd_tx_loopback_set =
11349 TOKEN_STRING_INITIALIZER
11350 (struct cmd_tx_loopback_result,
11352 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11353 TOKEN_STRING_INITIALIZER
11354 (struct cmd_tx_loopback_result,
11356 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11357 TOKEN_STRING_INITIALIZER
11358 (struct cmd_tx_loopback_result,
11359 loopback, "loopback");
11360 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11361 TOKEN_NUM_INITIALIZER
11362 (struct cmd_tx_loopback_result,
11364 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11365 TOKEN_STRING_INITIALIZER
11366 (struct cmd_tx_loopback_result,
11370 cmd_set_tx_loopback_parsed(
11371 void *parsed_result,
11372 __attribute__((unused)) struct cmdline *cl,
11373 __attribute__((unused)) void *data)
11375 struct cmd_tx_loopback_result *res = parsed_result;
11376 int ret = -ENOTSUP;
11378 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11380 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11383 #ifdef RTE_LIBRTE_IXGBE_PMD
11384 if (ret == -ENOTSUP)
11385 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11387 #ifdef RTE_LIBRTE_I40E_PMD
11388 if (ret == -ENOTSUP)
11389 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11396 printf("invalid is_on %d\n", is_on);
11399 printf("invalid port_id %d\n", res->port_id);
11402 printf("function not implemented\n");
11405 printf("programming error: (%s)\n", strerror(-ret));
11409 cmdline_parse_inst_t cmd_set_tx_loopback = {
11410 .f = cmd_set_tx_loopback_parsed,
11412 .help_str = "set tx loopback <port_id> on|off",
11414 (void *)&cmd_tx_loopback_set,
11415 (void *)&cmd_tx_loopback_tx,
11416 (void *)&cmd_tx_loopback_loopback,
11417 (void *)&cmd_tx_loopback_port_id,
11418 (void *)&cmd_tx_loopback_on_off,
11423 #ifdef RTE_LIBRTE_IXGBE_PMD
11424 /* all queues drop enable configuration */
11426 /* Common result structure for all queues drop enable */
11427 struct cmd_all_queues_drop_en_result {
11428 cmdline_fixed_string_t set;
11429 cmdline_fixed_string_t all;
11430 cmdline_fixed_string_t queues;
11431 cmdline_fixed_string_t drop;
11433 cmdline_fixed_string_t on_off;
11436 /* Common CLI fields for tx loopback enable disable */
11437 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11438 TOKEN_STRING_INITIALIZER
11439 (struct cmd_all_queues_drop_en_result,
11441 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11442 TOKEN_STRING_INITIALIZER
11443 (struct cmd_all_queues_drop_en_result,
11445 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11446 TOKEN_STRING_INITIALIZER
11447 (struct cmd_all_queues_drop_en_result,
11449 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11450 TOKEN_STRING_INITIALIZER
11451 (struct cmd_all_queues_drop_en_result,
11453 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11454 TOKEN_NUM_INITIALIZER
11455 (struct cmd_all_queues_drop_en_result,
11457 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11458 TOKEN_STRING_INITIALIZER
11459 (struct cmd_all_queues_drop_en_result,
11463 cmd_set_all_queues_drop_en_parsed(
11464 void *parsed_result,
11465 __attribute__((unused)) struct cmdline *cl,
11466 __attribute__((unused)) void *data)
11468 struct cmd_all_queues_drop_en_result *res = parsed_result;
11470 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11472 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11475 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11480 printf("invalid is_on %d\n", is_on);
11483 printf("invalid port_id %d\n", res->port_id);
11486 printf("function not implemented\n");
11489 printf("programming error: (%s)\n", strerror(-ret));
11493 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11494 .f = cmd_set_all_queues_drop_en_parsed,
11496 .help_str = "set all queues drop <port_id> on|off",
11498 (void *)&cmd_all_queues_drop_en_set,
11499 (void *)&cmd_all_queues_drop_en_all,
11500 (void *)&cmd_all_queues_drop_en_queues,
11501 (void *)&cmd_all_queues_drop_en_drop,
11502 (void *)&cmd_all_queues_drop_en_port_id,
11503 (void *)&cmd_all_queues_drop_en_on_off,
11508 /* vf split drop enable configuration */
11510 /* Common result structure for vf split drop enable */
11511 struct cmd_vf_split_drop_en_result {
11512 cmdline_fixed_string_t set;
11513 cmdline_fixed_string_t vf;
11514 cmdline_fixed_string_t split;
11515 cmdline_fixed_string_t drop;
11518 cmdline_fixed_string_t on_off;
11521 /* Common CLI fields for vf split drop enable disable */
11522 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11523 TOKEN_STRING_INITIALIZER
11524 (struct cmd_vf_split_drop_en_result,
11526 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11527 TOKEN_STRING_INITIALIZER
11528 (struct cmd_vf_split_drop_en_result,
11530 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11531 TOKEN_STRING_INITIALIZER
11532 (struct cmd_vf_split_drop_en_result,
11534 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11535 TOKEN_STRING_INITIALIZER
11536 (struct cmd_vf_split_drop_en_result,
11538 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11539 TOKEN_NUM_INITIALIZER
11540 (struct cmd_vf_split_drop_en_result,
11542 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11543 TOKEN_NUM_INITIALIZER
11544 (struct cmd_vf_split_drop_en_result,
11546 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11547 TOKEN_STRING_INITIALIZER
11548 (struct cmd_vf_split_drop_en_result,
11552 cmd_set_vf_split_drop_en_parsed(
11553 void *parsed_result,
11554 __attribute__((unused)) struct cmdline *cl,
11555 __attribute__((unused)) void *data)
11557 struct cmd_vf_split_drop_en_result *res = parsed_result;
11559 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11561 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11564 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11570 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11573 printf("invalid port_id %d\n", res->port_id);
11576 printf("programming error: (%s)\n", strerror(-ret));
11580 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11581 .f = cmd_set_vf_split_drop_en_parsed,
11583 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11585 (void *)&cmd_vf_split_drop_en_set,
11586 (void *)&cmd_vf_split_drop_en_vf,
11587 (void *)&cmd_vf_split_drop_en_split,
11588 (void *)&cmd_vf_split_drop_en_drop,
11589 (void *)&cmd_vf_split_drop_en_port_id,
11590 (void *)&cmd_vf_split_drop_en_vf_id,
11591 (void *)&cmd_vf_split_drop_en_on_off,
11597 /* vf mac address configuration */
11599 /* Common result structure for vf mac address */
11600 struct cmd_set_vf_mac_addr_result {
11601 cmdline_fixed_string_t set;
11602 cmdline_fixed_string_t vf;
11603 cmdline_fixed_string_t mac;
11604 cmdline_fixed_string_t addr;
11607 struct ether_addr mac_addr;
11611 /* Common CLI fields for vf split drop enable disable */
11612 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11613 TOKEN_STRING_INITIALIZER
11614 (struct cmd_set_vf_mac_addr_result,
11616 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11617 TOKEN_STRING_INITIALIZER
11618 (struct cmd_set_vf_mac_addr_result,
11620 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11621 TOKEN_STRING_INITIALIZER
11622 (struct cmd_set_vf_mac_addr_result,
11624 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11625 TOKEN_STRING_INITIALIZER
11626 (struct cmd_set_vf_mac_addr_result,
11628 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11629 TOKEN_NUM_INITIALIZER
11630 (struct cmd_set_vf_mac_addr_result,
11632 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11633 TOKEN_NUM_INITIALIZER
11634 (struct cmd_set_vf_mac_addr_result,
11636 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11637 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11641 cmd_set_vf_mac_addr_parsed(
11642 void *parsed_result,
11643 __attribute__((unused)) struct cmdline *cl,
11644 __attribute__((unused)) void *data)
11646 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11647 int ret = -ENOTSUP;
11649 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11652 #ifdef RTE_LIBRTE_IXGBE_PMD
11653 if (ret == -ENOTSUP)
11654 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11657 #ifdef RTE_LIBRTE_I40E_PMD
11658 if (ret == -ENOTSUP)
11659 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11667 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11670 printf("invalid port_id %d\n", res->port_id);
11673 printf("function not implemented\n");
11676 printf("programming error: (%s)\n", strerror(-ret));
11680 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11681 .f = cmd_set_vf_mac_addr_parsed,
11683 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11685 (void *)&cmd_set_vf_mac_addr_set,
11686 (void *)&cmd_set_vf_mac_addr_vf,
11687 (void *)&cmd_set_vf_mac_addr_mac,
11688 (void *)&cmd_set_vf_mac_addr_addr,
11689 (void *)&cmd_set_vf_mac_addr_port_id,
11690 (void *)&cmd_set_vf_mac_addr_vf_id,
11691 (void *)&cmd_set_vf_mac_addr_mac_addr,
11696 #ifdef RTE_LIBRTE_IXGBE_PMD
11697 /* MACsec configuration */
11699 /* Common result structure for MACsec offload enable */
11700 struct cmd_macsec_offload_on_result {
11701 cmdline_fixed_string_t set;
11702 cmdline_fixed_string_t macsec;
11703 cmdline_fixed_string_t offload;
11705 cmdline_fixed_string_t on;
11706 cmdline_fixed_string_t encrypt;
11707 cmdline_fixed_string_t en_on_off;
11708 cmdline_fixed_string_t replay_protect;
11709 cmdline_fixed_string_t rp_on_off;
11712 /* Common CLI fields for MACsec offload disable */
11713 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11714 TOKEN_STRING_INITIALIZER
11715 (struct cmd_macsec_offload_on_result,
11717 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11718 TOKEN_STRING_INITIALIZER
11719 (struct cmd_macsec_offload_on_result,
11721 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11722 TOKEN_STRING_INITIALIZER
11723 (struct cmd_macsec_offload_on_result,
11724 offload, "offload");
11725 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11726 TOKEN_NUM_INITIALIZER
11727 (struct cmd_macsec_offload_on_result,
11729 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11730 TOKEN_STRING_INITIALIZER
11731 (struct cmd_macsec_offload_on_result,
11733 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11734 TOKEN_STRING_INITIALIZER
11735 (struct cmd_macsec_offload_on_result,
11736 encrypt, "encrypt");
11737 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11738 TOKEN_STRING_INITIALIZER
11739 (struct cmd_macsec_offload_on_result,
11740 en_on_off, "on#off");
11741 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11742 TOKEN_STRING_INITIALIZER
11743 (struct cmd_macsec_offload_on_result,
11744 replay_protect, "replay-protect");
11745 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11746 TOKEN_STRING_INITIALIZER
11747 (struct cmd_macsec_offload_on_result,
11748 rp_on_off, "on#off");
11751 cmd_set_macsec_offload_on_parsed(
11752 void *parsed_result,
11753 __attribute__((unused)) struct cmdline *cl,
11754 __attribute__((unused)) void *data)
11756 struct cmd_macsec_offload_on_result *res = parsed_result;
11758 portid_t port_id = res->port_id;
11759 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11760 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11762 if (port_id_is_invalid(port_id, ENABLED_WARN))
11765 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11766 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11772 printf("invalid port_id %d\n", port_id);
11775 printf("programming error: (%s)\n", strerror(-ret));
11779 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11780 .f = cmd_set_macsec_offload_on_parsed,
11782 .help_str = "set macsec offload <port_id> on "
11783 "encrypt on|off replay-protect on|off",
11785 (void *)&cmd_macsec_offload_on_set,
11786 (void *)&cmd_macsec_offload_on_macsec,
11787 (void *)&cmd_macsec_offload_on_offload,
11788 (void *)&cmd_macsec_offload_on_port_id,
11789 (void *)&cmd_macsec_offload_on_on,
11790 (void *)&cmd_macsec_offload_on_encrypt,
11791 (void *)&cmd_macsec_offload_on_en_on_off,
11792 (void *)&cmd_macsec_offload_on_replay_protect,
11793 (void *)&cmd_macsec_offload_on_rp_on_off,
11798 /* Common result structure for MACsec offload disable */
11799 struct cmd_macsec_offload_off_result {
11800 cmdline_fixed_string_t set;
11801 cmdline_fixed_string_t macsec;
11802 cmdline_fixed_string_t offload;
11804 cmdline_fixed_string_t off;
11807 /* Common CLI fields for MACsec offload disable */
11808 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11809 TOKEN_STRING_INITIALIZER
11810 (struct cmd_macsec_offload_off_result,
11812 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11813 TOKEN_STRING_INITIALIZER
11814 (struct cmd_macsec_offload_off_result,
11816 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11817 TOKEN_STRING_INITIALIZER
11818 (struct cmd_macsec_offload_off_result,
11819 offload, "offload");
11820 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11821 TOKEN_NUM_INITIALIZER
11822 (struct cmd_macsec_offload_off_result,
11824 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11825 TOKEN_STRING_INITIALIZER
11826 (struct cmd_macsec_offload_off_result,
11830 cmd_set_macsec_offload_off_parsed(
11831 void *parsed_result,
11832 __attribute__((unused)) struct cmdline *cl,
11833 __attribute__((unused)) void *data)
11835 struct cmd_macsec_offload_off_result *res = parsed_result;
11837 portid_t port_id = res->port_id;
11839 if (port_id_is_invalid(port_id, ENABLED_WARN))
11842 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11843 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11849 printf("invalid port_id %d\n", port_id);
11852 printf("programming error: (%s)\n", strerror(-ret));
11856 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11857 .f = cmd_set_macsec_offload_off_parsed,
11859 .help_str = "set macsec offload <port_id> off",
11861 (void *)&cmd_macsec_offload_off_set,
11862 (void *)&cmd_macsec_offload_off_macsec,
11863 (void *)&cmd_macsec_offload_off_offload,
11864 (void *)&cmd_macsec_offload_off_port_id,
11865 (void *)&cmd_macsec_offload_off_off,
11870 /* Common result structure for MACsec secure connection configure */
11871 struct cmd_macsec_sc_result {
11872 cmdline_fixed_string_t set;
11873 cmdline_fixed_string_t macsec;
11874 cmdline_fixed_string_t sc;
11875 cmdline_fixed_string_t tx_rx;
11877 struct ether_addr mac;
11881 /* Common CLI fields for MACsec secure connection configure */
11882 cmdline_parse_token_string_t cmd_macsec_sc_set =
11883 TOKEN_STRING_INITIALIZER
11884 (struct cmd_macsec_sc_result,
11886 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11887 TOKEN_STRING_INITIALIZER
11888 (struct cmd_macsec_sc_result,
11890 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11891 TOKEN_STRING_INITIALIZER
11892 (struct cmd_macsec_sc_result,
11894 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11895 TOKEN_STRING_INITIALIZER
11896 (struct cmd_macsec_sc_result,
11898 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11899 TOKEN_NUM_INITIALIZER
11900 (struct cmd_macsec_sc_result,
11902 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11903 TOKEN_ETHERADDR_INITIALIZER
11904 (struct cmd_macsec_sc_result,
11906 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11907 TOKEN_NUM_INITIALIZER
11908 (struct cmd_macsec_sc_result,
11912 cmd_set_macsec_sc_parsed(
11913 void *parsed_result,
11914 __attribute__((unused)) struct cmdline *cl,
11915 __attribute__((unused)) void *data)
11917 struct cmd_macsec_sc_result *res = parsed_result;
11919 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11922 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11923 res->mac.addr_bytes) :
11924 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11925 res->mac.addr_bytes, res->pi);
11930 printf("invalid port_id %d\n", res->port_id);
11933 printf("programming error: (%s)\n", strerror(-ret));
11937 cmdline_parse_inst_t cmd_set_macsec_sc = {
11938 .f = cmd_set_macsec_sc_parsed,
11940 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11942 (void *)&cmd_macsec_sc_set,
11943 (void *)&cmd_macsec_sc_macsec,
11944 (void *)&cmd_macsec_sc_sc,
11945 (void *)&cmd_macsec_sc_tx_rx,
11946 (void *)&cmd_macsec_sc_port_id,
11947 (void *)&cmd_macsec_sc_mac,
11948 (void *)&cmd_macsec_sc_pi,
11953 /* Common result structure for MACsec secure connection configure */
11954 struct cmd_macsec_sa_result {
11955 cmdline_fixed_string_t set;
11956 cmdline_fixed_string_t macsec;
11957 cmdline_fixed_string_t sa;
11958 cmdline_fixed_string_t tx_rx;
11963 cmdline_fixed_string_t key;
11966 /* Common CLI fields for MACsec secure connection configure */
11967 cmdline_parse_token_string_t cmd_macsec_sa_set =
11968 TOKEN_STRING_INITIALIZER
11969 (struct cmd_macsec_sa_result,
11971 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11972 TOKEN_STRING_INITIALIZER
11973 (struct cmd_macsec_sa_result,
11975 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11976 TOKEN_STRING_INITIALIZER
11977 (struct cmd_macsec_sa_result,
11979 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11980 TOKEN_STRING_INITIALIZER
11981 (struct cmd_macsec_sa_result,
11983 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11984 TOKEN_NUM_INITIALIZER
11985 (struct cmd_macsec_sa_result,
11987 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11988 TOKEN_NUM_INITIALIZER
11989 (struct cmd_macsec_sa_result,
11991 cmdline_parse_token_num_t cmd_macsec_sa_an =
11992 TOKEN_NUM_INITIALIZER
11993 (struct cmd_macsec_sa_result,
11995 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11996 TOKEN_NUM_INITIALIZER
11997 (struct cmd_macsec_sa_result,
11999 cmdline_parse_token_string_t cmd_macsec_sa_key =
12000 TOKEN_STRING_INITIALIZER
12001 (struct cmd_macsec_sa_result,
12005 cmd_set_macsec_sa_parsed(
12006 void *parsed_result,
12007 __attribute__((unused)) struct cmdline *cl,
12008 __attribute__((unused)) void *data)
12010 struct cmd_macsec_sa_result *res = parsed_result;
12012 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12013 uint8_t key[16] = { 0 };
12019 key_len = strlen(res->key) / 2;
12023 for (i = 0; i < key_len; i++) {
12024 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12027 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12030 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12034 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12035 res->idx, res->an, res->pn, key) :
12036 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12037 res->idx, res->an, res->pn, key);
12042 printf("invalid idx %d or an %d\n", res->idx, res->an);
12045 printf("invalid port_id %d\n", res->port_id);
12048 printf("programming error: (%s)\n", strerror(-ret));
12052 cmdline_parse_inst_t cmd_set_macsec_sa = {
12053 .f = cmd_set_macsec_sa_parsed,
12055 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12057 (void *)&cmd_macsec_sa_set,
12058 (void *)&cmd_macsec_sa_macsec,
12059 (void *)&cmd_macsec_sa_sa,
12060 (void *)&cmd_macsec_sa_tx_rx,
12061 (void *)&cmd_macsec_sa_port_id,
12062 (void *)&cmd_macsec_sa_idx,
12063 (void *)&cmd_macsec_sa_an,
12064 (void *)&cmd_macsec_sa_pn,
12065 (void *)&cmd_macsec_sa_key,
12071 /* VF unicast promiscuous mode configuration */
12073 /* Common result structure for VF unicast promiscuous mode */
12074 struct cmd_vf_promisc_result {
12075 cmdline_fixed_string_t set;
12076 cmdline_fixed_string_t vf;
12077 cmdline_fixed_string_t promisc;
12080 cmdline_fixed_string_t on_off;
12083 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12084 cmdline_parse_token_string_t cmd_vf_promisc_set =
12085 TOKEN_STRING_INITIALIZER
12086 (struct cmd_vf_promisc_result,
12088 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12089 TOKEN_STRING_INITIALIZER
12090 (struct cmd_vf_promisc_result,
12092 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12093 TOKEN_STRING_INITIALIZER
12094 (struct cmd_vf_promisc_result,
12095 promisc, "promisc");
12096 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12097 TOKEN_NUM_INITIALIZER
12098 (struct cmd_vf_promisc_result,
12100 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12101 TOKEN_NUM_INITIALIZER
12102 (struct cmd_vf_promisc_result,
12104 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_vf_promisc_result,
12110 cmd_set_vf_promisc_parsed(
12111 void *parsed_result,
12112 __attribute__((unused)) struct cmdline *cl,
12113 __attribute__((unused)) void *data)
12115 struct cmd_vf_promisc_result *res = parsed_result;
12116 int ret = -ENOTSUP;
12118 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12120 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12123 #ifdef RTE_LIBRTE_I40E_PMD
12124 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12125 res->vf_id, is_on);
12132 printf("invalid vf_id %d\n", res->vf_id);
12135 printf("invalid port_id %d\n", res->port_id);
12138 printf("function not implemented\n");
12141 printf("programming error: (%s)\n", strerror(-ret));
12145 cmdline_parse_inst_t cmd_set_vf_promisc = {
12146 .f = cmd_set_vf_promisc_parsed,
12148 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12149 "Set unicast promiscuous mode for a VF from the PF",
12151 (void *)&cmd_vf_promisc_set,
12152 (void *)&cmd_vf_promisc_vf,
12153 (void *)&cmd_vf_promisc_promisc,
12154 (void *)&cmd_vf_promisc_port_id,
12155 (void *)&cmd_vf_promisc_vf_id,
12156 (void *)&cmd_vf_promisc_on_off,
12161 /* VF multicast promiscuous mode configuration */
12163 /* Common result structure for VF multicast promiscuous mode */
12164 struct cmd_vf_allmulti_result {
12165 cmdline_fixed_string_t set;
12166 cmdline_fixed_string_t vf;
12167 cmdline_fixed_string_t allmulti;
12170 cmdline_fixed_string_t on_off;
12173 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12174 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12175 TOKEN_STRING_INITIALIZER
12176 (struct cmd_vf_allmulti_result,
12178 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12179 TOKEN_STRING_INITIALIZER
12180 (struct cmd_vf_allmulti_result,
12182 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12183 TOKEN_STRING_INITIALIZER
12184 (struct cmd_vf_allmulti_result,
12185 allmulti, "allmulti");
12186 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12187 TOKEN_NUM_INITIALIZER
12188 (struct cmd_vf_allmulti_result,
12190 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12191 TOKEN_NUM_INITIALIZER
12192 (struct cmd_vf_allmulti_result,
12194 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12195 TOKEN_STRING_INITIALIZER
12196 (struct cmd_vf_allmulti_result,
12200 cmd_set_vf_allmulti_parsed(
12201 void *parsed_result,
12202 __attribute__((unused)) struct cmdline *cl,
12203 __attribute__((unused)) void *data)
12205 struct cmd_vf_allmulti_result *res = parsed_result;
12206 int ret = -ENOTSUP;
12208 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12210 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12213 #ifdef RTE_LIBRTE_I40E_PMD
12214 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12215 res->vf_id, is_on);
12222 printf("invalid vf_id %d\n", res->vf_id);
12225 printf("invalid port_id %d\n", res->port_id);
12228 printf("function not implemented\n");
12231 printf("programming error: (%s)\n", strerror(-ret));
12235 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12236 .f = cmd_set_vf_allmulti_parsed,
12238 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12239 "Set multicast promiscuous mode for a VF from the PF",
12241 (void *)&cmd_vf_allmulti_set,
12242 (void *)&cmd_vf_allmulti_vf,
12243 (void *)&cmd_vf_allmulti_allmulti,
12244 (void *)&cmd_vf_allmulti_port_id,
12245 (void *)&cmd_vf_allmulti_vf_id,
12246 (void *)&cmd_vf_allmulti_on_off,
12251 /* vf broadcast mode configuration */
12253 /* Common result structure for vf broadcast */
12254 struct cmd_set_vf_broadcast_result {
12255 cmdline_fixed_string_t set;
12256 cmdline_fixed_string_t vf;
12257 cmdline_fixed_string_t broadcast;
12260 cmdline_fixed_string_t on_off;
12263 /* Common CLI fields for vf broadcast enable disable */
12264 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12265 TOKEN_STRING_INITIALIZER
12266 (struct cmd_set_vf_broadcast_result,
12268 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12269 TOKEN_STRING_INITIALIZER
12270 (struct cmd_set_vf_broadcast_result,
12272 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12273 TOKEN_STRING_INITIALIZER
12274 (struct cmd_set_vf_broadcast_result,
12275 broadcast, "broadcast");
12276 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12277 TOKEN_NUM_INITIALIZER
12278 (struct cmd_set_vf_broadcast_result,
12280 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12281 TOKEN_NUM_INITIALIZER
12282 (struct cmd_set_vf_broadcast_result,
12284 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12285 TOKEN_STRING_INITIALIZER
12286 (struct cmd_set_vf_broadcast_result,
12290 cmd_set_vf_broadcast_parsed(
12291 void *parsed_result,
12292 __attribute__((unused)) struct cmdline *cl,
12293 __attribute__((unused)) void *data)
12295 struct cmd_set_vf_broadcast_result *res = parsed_result;
12296 int ret = -ENOTSUP;
12298 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12300 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12303 #ifdef RTE_LIBRTE_I40E_PMD
12304 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12305 res->vf_id, is_on);
12312 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12315 printf("invalid port_id %d\n", res->port_id);
12318 printf("function not implemented\n");
12321 printf("programming error: (%s)\n", strerror(-ret));
12325 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12326 .f = cmd_set_vf_broadcast_parsed,
12328 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12330 (void *)&cmd_set_vf_broadcast_set,
12331 (void *)&cmd_set_vf_broadcast_vf,
12332 (void *)&cmd_set_vf_broadcast_broadcast,
12333 (void *)&cmd_set_vf_broadcast_port_id,
12334 (void *)&cmd_set_vf_broadcast_vf_id,
12335 (void *)&cmd_set_vf_broadcast_on_off,
12340 /* vf vlan tag configuration */
12342 /* Common result structure for vf vlan tag */
12343 struct cmd_set_vf_vlan_tag_result {
12344 cmdline_fixed_string_t set;
12345 cmdline_fixed_string_t vf;
12346 cmdline_fixed_string_t vlan;
12347 cmdline_fixed_string_t tag;
12350 cmdline_fixed_string_t on_off;
12353 /* Common CLI fields for vf vlan tag enable disable */
12354 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12355 TOKEN_STRING_INITIALIZER
12356 (struct cmd_set_vf_vlan_tag_result,
12358 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12359 TOKEN_STRING_INITIALIZER
12360 (struct cmd_set_vf_vlan_tag_result,
12362 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12363 TOKEN_STRING_INITIALIZER
12364 (struct cmd_set_vf_vlan_tag_result,
12366 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12367 TOKEN_STRING_INITIALIZER
12368 (struct cmd_set_vf_vlan_tag_result,
12370 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12371 TOKEN_NUM_INITIALIZER
12372 (struct cmd_set_vf_vlan_tag_result,
12374 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12375 TOKEN_NUM_INITIALIZER
12376 (struct cmd_set_vf_vlan_tag_result,
12378 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_set_vf_vlan_tag_result,
12384 cmd_set_vf_vlan_tag_parsed(
12385 void *parsed_result,
12386 __attribute__((unused)) struct cmdline *cl,
12387 __attribute__((unused)) void *data)
12389 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12390 int ret = -ENOTSUP;
12392 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12397 #ifdef RTE_LIBRTE_I40E_PMD
12398 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12399 res->vf_id, is_on);
12406 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12409 printf("invalid port_id %d\n", res->port_id);
12412 printf("function not implemented\n");
12415 printf("programming error: (%s)\n", strerror(-ret));
12419 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12420 .f = cmd_set_vf_vlan_tag_parsed,
12422 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12424 (void *)&cmd_set_vf_vlan_tag_set,
12425 (void *)&cmd_set_vf_vlan_tag_vf,
12426 (void *)&cmd_set_vf_vlan_tag_vlan,
12427 (void *)&cmd_set_vf_vlan_tag_tag,
12428 (void *)&cmd_set_vf_vlan_tag_port_id,
12429 (void *)&cmd_set_vf_vlan_tag_vf_id,
12430 (void *)&cmd_set_vf_vlan_tag_on_off,
12435 /* Common definition of VF and TC TX bandwidth configuration */
12436 struct cmd_vf_tc_bw_result {
12437 cmdline_fixed_string_t set;
12438 cmdline_fixed_string_t vf;
12439 cmdline_fixed_string_t tc;
12440 cmdline_fixed_string_t tx;
12441 cmdline_fixed_string_t min_bw;
12442 cmdline_fixed_string_t max_bw;
12443 cmdline_fixed_string_t strict_link_prio;
12448 cmdline_fixed_string_t bw_list;
12452 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12453 TOKEN_STRING_INITIALIZER
12454 (struct cmd_vf_tc_bw_result,
12456 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12457 TOKEN_STRING_INITIALIZER
12458 (struct cmd_vf_tc_bw_result,
12460 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12461 TOKEN_STRING_INITIALIZER
12462 (struct cmd_vf_tc_bw_result,
12464 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_vf_tc_bw_result,
12468 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_vf_tc_bw_result,
12471 strict_link_prio, "strict-link-priority");
12472 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_vf_tc_bw_result,
12475 min_bw, "min-bandwidth");
12476 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_vf_tc_bw_result,
12479 max_bw, "max-bandwidth");
12480 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12481 TOKEN_NUM_INITIALIZER
12482 (struct cmd_vf_tc_bw_result,
12484 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12485 TOKEN_NUM_INITIALIZER
12486 (struct cmd_vf_tc_bw_result,
12488 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12489 TOKEN_NUM_INITIALIZER
12490 (struct cmd_vf_tc_bw_result,
12492 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12493 TOKEN_NUM_INITIALIZER
12494 (struct cmd_vf_tc_bw_result,
12496 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12497 TOKEN_STRING_INITIALIZER
12498 (struct cmd_vf_tc_bw_result,
12500 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12501 TOKEN_NUM_INITIALIZER
12502 (struct cmd_vf_tc_bw_result,
12505 /* VF max bandwidth setting */
12507 cmd_vf_max_bw_parsed(
12508 void *parsed_result,
12509 __attribute__((unused)) struct cmdline *cl,
12510 __attribute__((unused)) void *data)
12512 struct cmd_vf_tc_bw_result *res = parsed_result;
12513 int ret = -ENOTSUP;
12515 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12518 #ifdef RTE_LIBRTE_I40E_PMD
12519 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12520 res->vf_id, res->bw);
12527 printf("invalid vf_id %d or bandwidth %d\n",
12528 res->vf_id, res->bw);
12531 printf("invalid port_id %d\n", res->port_id);
12534 printf("function not implemented\n");
12537 printf("programming error: (%s)\n", strerror(-ret));
12541 cmdline_parse_inst_t cmd_vf_max_bw = {
12542 .f = cmd_vf_max_bw_parsed,
12544 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12546 (void *)&cmd_vf_tc_bw_set,
12547 (void *)&cmd_vf_tc_bw_vf,
12548 (void *)&cmd_vf_tc_bw_tx,
12549 (void *)&cmd_vf_tc_bw_max_bw,
12550 (void *)&cmd_vf_tc_bw_port_id,
12551 (void *)&cmd_vf_tc_bw_vf_id,
12552 (void *)&cmd_vf_tc_bw_bw,
12558 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12563 const char *p, *p0 = str;
12570 p = strchr(p0, '(');
12572 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12576 p0 = strchr(p, ')');
12578 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12582 if (size >= sizeof(s)) {
12583 printf("The string size exceeds the internal buffer size\n");
12586 snprintf(s, sizeof(s), "%.*s", size, p);
12587 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12589 printf("Failed to get the bandwidth list. ");
12593 for (i = 0; i < ret; i++)
12594 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12599 /* TC min bandwidth setting */
12601 cmd_vf_tc_min_bw_parsed(
12602 void *parsed_result,
12603 __attribute__((unused)) struct cmdline *cl,
12604 __attribute__((unused)) void *data)
12606 struct cmd_vf_tc_bw_result *res = parsed_result;
12609 int ret = -ENOTSUP;
12611 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12614 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12618 #ifdef RTE_LIBRTE_I40E_PMD
12619 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12627 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12630 printf("invalid port_id %d\n", res->port_id);
12633 printf("function not implemented\n");
12636 printf("programming error: (%s)\n", strerror(-ret));
12640 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12641 .f = cmd_vf_tc_min_bw_parsed,
12643 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12644 " <bw1, bw2, ...>",
12646 (void *)&cmd_vf_tc_bw_set,
12647 (void *)&cmd_vf_tc_bw_vf,
12648 (void *)&cmd_vf_tc_bw_tc,
12649 (void *)&cmd_vf_tc_bw_tx,
12650 (void *)&cmd_vf_tc_bw_min_bw,
12651 (void *)&cmd_vf_tc_bw_port_id,
12652 (void *)&cmd_vf_tc_bw_vf_id,
12653 (void *)&cmd_vf_tc_bw_bw_list,
12659 cmd_tc_min_bw_parsed(
12660 void *parsed_result,
12661 __attribute__((unused)) struct cmdline *cl,
12662 __attribute__((unused)) void *data)
12664 struct cmd_vf_tc_bw_result *res = parsed_result;
12665 struct rte_port *port;
12668 int ret = -ENOTSUP;
12670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12673 port = &ports[res->port_id];
12674 /** Check if the port is not started **/
12675 if (port->port_status != RTE_PORT_STOPPED) {
12676 printf("Please stop port %d first\n", res->port_id);
12680 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12684 #ifdef RTE_LIBRTE_IXGBE_PMD
12685 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12692 printf("invalid bandwidth\n");
12695 printf("invalid port_id %d\n", res->port_id);
12698 printf("function not implemented\n");
12701 printf("programming error: (%s)\n", strerror(-ret));
12705 cmdline_parse_inst_t cmd_tc_min_bw = {
12706 .f = cmd_tc_min_bw_parsed,
12708 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12710 (void *)&cmd_vf_tc_bw_set,
12711 (void *)&cmd_vf_tc_bw_tc,
12712 (void *)&cmd_vf_tc_bw_tx,
12713 (void *)&cmd_vf_tc_bw_min_bw,
12714 (void *)&cmd_vf_tc_bw_port_id,
12715 (void *)&cmd_vf_tc_bw_bw_list,
12720 /* TC max bandwidth setting */
12722 cmd_vf_tc_max_bw_parsed(
12723 void *parsed_result,
12724 __attribute__((unused)) struct cmdline *cl,
12725 __attribute__((unused)) void *data)
12727 struct cmd_vf_tc_bw_result *res = parsed_result;
12728 int ret = -ENOTSUP;
12730 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12733 #ifdef RTE_LIBRTE_I40E_PMD
12734 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12735 res->tc_no, res->bw);
12742 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12743 res->vf_id, res->tc_no, res->bw);
12746 printf("invalid port_id %d\n", res->port_id);
12749 printf("function not implemented\n");
12752 printf("programming error: (%s)\n", strerror(-ret));
12756 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12757 .f = cmd_vf_tc_max_bw_parsed,
12759 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12762 (void *)&cmd_vf_tc_bw_set,
12763 (void *)&cmd_vf_tc_bw_vf,
12764 (void *)&cmd_vf_tc_bw_tc,
12765 (void *)&cmd_vf_tc_bw_tx,
12766 (void *)&cmd_vf_tc_bw_max_bw,
12767 (void *)&cmd_vf_tc_bw_port_id,
12768 (void *)&cmd_vf_tc_bw_vf_id,
12769 (void *)&cmd_vf_tc_bw_tc_no,
12770 (void *)&cmd_vf_tc_bw_bw,
12775 /* Strict link priority scheduling mode setting */
12777 cmd_strict_link_prio_parsed(
12778 void *parsed_result,
12779 __attribute__((unused)) struct cmdline *cl,
12780 __attribute__((unused)) void *data)
12782 struct cmd_vf_tc_bw_result *res = parsed_result;
12783 int ret = -ENOTSUP;
12785 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12788 #ifdef RTE_LIBRTE_I40E_PMD
12789 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12796 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12799 printf("invalid port_id %d\n", res->port_id);
12802 printf("function not implemented\n");
12805 printf("programming error: (%s)\n", strerror(-ret));
12809 cmdline_parse_inst_t cmd_strict_link_prio = {
12810 .f = cmd_strict_link_prio_parsed,
12812 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12814 (void *)&cmd_vf_tc_bw_set,
12815 (void *)&cmd_vf_tc_bw_tx,
12816 (void *)&cmd_vf_tc_bw_strict_link_prio,
12817 (void *)&cmd_vf_tc_bw_port_id,
12818 (void *)&cmd_vf_tc_bw_tc_map,
12823 /* Load dynamic device personalization*/
12824 struct cmd_ddp_add_result {
12825 cmdline_fixed_string_t ddp;
12826 cmdline_fixed_string_t add;
12831 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12832 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12833 cmdline_parse_token_string_t cmd_ddp_add_add =
12834 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12835 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12836 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12837 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12838 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12841 cmd_ddp_add_parsed(
12842 void *parsed_result,
12843 __attribute__((unused)) struct cmdline *cl,
12844 __attribute__((unused)) void *data)
12846 struct cmd_ddp_add_result *res = parsed_result;
12849 int ret = -ENOTSUP;
12851 if (res->port_id > nb_ports) {
12852 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12856 if (!all_ports_stopped()) {
12857 printf("Please stop all ports first\n");
12861 buff = open_ddp_package_file(res->filepath, &size);
12865 #ifdef RTE_LIBRTE_I40E_PMD
12866 if (ret == -ENOTSUP)
12867 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12869 RTE_PMD_I40E_PKG_OP_WR_ADD);
12873 printf("Failed to load profile.\n");
12875 printf("Profile has already existed.\n");
12877 close_ddp_package_file(buff);
12880 cmdline_parse_inst_t cmd_ddp_add = {
12881 .f = cmd_ddp_add_parsed,
12883 .help_str = "ddp add <port_id> <profile_path>",
12885 (void *)&cmd_ddp_add_ddp,
12886 (void *)&cmd_ddp_add_add,
12887 (void *)&cmd_ddp_add_port_id,
12888 (void *)&cmd_ddp_add_filepath,
12893 /* Get dynamic device personalization profile info list*/
12894 #define PROFILE_INFO_SIZE 48
12895 #define MAX_PROFILE_NUM 16
12897 struct cmd_ddp_get_list_result {
12898 cmdline_fixed_string_t ddp;
12899 cmdline_fixed_string_t get;
12900 cmdline_fixed_string_t list;
12904 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
12905 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
12906 cmdline_parse_token_string_t cmd_ddp_get_list_get =
12907 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
12908 cmdline_parse_token_string_t cmd_ddp_get_list_list =
12909 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
12910 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
12911 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
12914 cmd_ddp_get_list_parsed(
12915 void *parsed_result,
12916 __attribute__((unused)) struct cmdline *cl,
12917 __attribute__((unused)) void *data)
12919 struct cmd_ddp_get_list_result *res = parsed_result;
12920 #ifdef RTE_LIBRTE_I40E_PMD
12921 struct rte_pmd_i40e_profile_list *p_list;
12922 struct rte_pmd_i40e_profile_info *p_info;
12927 int ret = -ENOTSUP;
12929 if (res->port_id > nb_ports) {
12930 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12934 #ifdef RTE_LIBRTE_I40E_PMD
12935 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
12936 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
12938 printf("%s: Failed to malloc buffer\n", __func__);
12940 if (ret == -ENOTSUP)
12941 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
12942 (uint8_t *)p_list, size);
12945 p_num = p_list->p_count;
12946 printf("Profile number is: %d\n\n", p_num);
12948 for (i = 0; i < p_num; i++) {
12949 p_info = &p_list->p_info[i];
12950 printf("Profile %d:\n", i);
12951 printf("Track id: 0x%x\n", p_info->track_id);
12952 printf("Version: %d.%d.%d.%d\n",
12953 p_info->version.major,
12954 p_info->version.minor,
12955 p_info->version.update,
12956 p_info->version.draft);
12957 printf("Profile name: %s\n\n", p_info->name);
12965 printf("Failed to get ddp list\n");
12968 cmdline_parse_inst_t cmd_ddp_get_list = {
12969 .f = cmd_ddp_get_list_parsed,
12971 .help_str = "ddp get list <port_id>",
12973 (void *)&cmd_ddp_get_list_ddp,
12974 (void *)&cmd_ddp_get_list_get,
12975 (void *)&cmd_ddp_get_list_list,
12976 (void *)&cmd_ddp_get_list_port_id,
12981 /* show vf stats */
12983 /* Common result structure for show vf stats */
12984 struct cmd_show_vf_stats_result {
12985 cmdline_fixed_string_t show;
12986 cmdline_fixed_string_t vf;
12987 cmdline_fixed_string_t stats;
12992 /* Common CLI fields show vf stats*/
12993 cmdline_parse_token_string_t cmd_show_vf_stats_show =
12994 TOKEN_STRING_INITIALIZER
12995 (struct cmd_show_vf_stats_result,
12997 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
12998 TOKEN_STRING_INITIALIZER
12999 (struct cmd_show_vf_stats_result,
13001 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13002 TOKEN_STRING_INITIALIZER
13003 (struct cmd_show_vf_stats_result,
13005 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13006 TOKEN_NUM_INITIALIZER
13007 (struct cmd_show_vf_stats_result,
13009 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13010 TOKEN_NUM_INITIALIZER
13011 (struct cmd_show_vf_stats_result,
13015 cmd_show_vf_stats_parsed(
13016 void *parsed_result,
13017 __attribute__((unused)) struct cmdline *cl,
13018 __attribute__((unused)) void *data)
13020 struct cmd_show_vf_stats_result *res = parsed_result;
13021 struct rte_eth_stats stats;
13022 int ret = -ENOTSUP;
13023 static const char *nic_stats_border = "########################";
13025 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13028 memset(&stats, 0, sizeof(stats));
13030 #ifdef RTE_LIBRTE_I40E_PMD
13031 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13040 printf("invalid vf_id %d\n", res->vf_id);
13043 printf("invalid port_id %d\n", res->port_id);
13046 printf("function not implemented\n");
13049 printf("programming error: (%s)\n", strerror(-ret));
13052 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13053 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13055 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13057 stats.ipackets, stats.imissed, stats.ibytes);
13058 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13059 printf(" RX-nombuf: %-10"PRIu64"\n",
13061 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13063 stats.opackets, stats.oerrors, stats.obytes);
13065 printf(" %s############################%s\n",
13066 nic_stats_border, nic_stats_border);
13069 cmdline_parse_inst_t cmd_show_vf_stats = {
13070 .f = cmd_show_vf_stats_parsed,
13072 .help_str = "show vf stats <port_id> <vf_id>",
13074 (void *)&cmd_show_vf_stats_show,
13075 (void *)&cmd_show_vf_stats_vf,
13076 (void *)&cmd_show_vf_stats_stats,
13077 (void *)&cmd_show_vf_stats_port_id,
13078 (void *)&cmd_show_vf_stats_vf_id,
13083 /* clear vf stats */
13085 /* Common result structure for clear vf stats */
13086 struct cmd_clear_vf_stats_result {
13087 cmdline_fixed_string_t clear;
13088 cmdline_fixed_string_t vf;
13089 cmdline_fixed_string_t stats;
13094 /* Common CLI fields clear vf stats*/
13095 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13096 TOKEN_STRING_INITIALIZER
13097 (struct cmd_clear_vf_stats_result,
13099 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13100 TOKEN_STRING_INITIALIZER
13101 (struct cmd_clear_vf_stats_result,
13103 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13104 TOKEN_STRING_INITIALIZER
13105 (struct cmd_clear_vf_stats_result,
13107 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13108 TOKEN_NUM_INITIALIZER
13109 (struct cmd_clear_vf_stats_result,
13111 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13112 TOKEN_NUM_INITIALIZER
13113 (struct cmd_clear_vf_stats_result,
13117 cmd_clear_vf_stats_parsed(
13118 void *parsed_result,
13119 __attribute__((unused)) struct cmdline *cl,
13120 __attribute__((unused)) void *data)
13122 struct cmd_clear_vf_stats_result *res = parsed_result;
13123 int ret = -ENOTSUP;
13125 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13128 #ifdef RTE_LIBRTE_I40E_PMD
13129 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13137 printf("invalid vf_id %d\n", res->vf_id);
13140 printf("invalid port_id %d\n", res->port_id);
13143 printf("function not implemented\n");
13146 printf("programming error: (%s)\n", strerror(-ret));
13150 cmdline_parse_inst_t cmd_clear_vf_stats = {
13151 .f = cmd_clear_vf_stats_parsed,
13153 .help_str = "clear vf stats <port_id> <vf_id>",
13155 (void *)&cmd_clear_vf_stats_clear,
13156 (void *)&cmd_clear_vf_stats_vf,
13157 (void *)&cmd_clear_vf_stats_stats,
13158 (void *)&cmd_clear_vf_stats_port_id,
13159 (void *)&cmd_clear_vf_stats_vf_id,
13164 /* ******************************************************************************** */
13166 /* list of instructions */
13167 cmdline_parse_ctx_t main_ctx[] = {
13168 (cmdline_parse_inst_t *)&cmd_help_brief,
13169 (cmdline_parse_inst_t *)&cmd_help_long,
13170 (cmdline_parse_inst_t *)&cmd_quit,
13171 (cmdline_parse_inst_t *)&cmd_showport,
13172 (cmdline_parse_inst_t *)&cmd_showqueue,
13173 (cmdline_parse_inst_t *)&cmd_showportall,
13174 (cmdline_parse_inst_t *)&cmd_showcfg,
13175 (cmdline_parse_inst_t *)&cmd_start,
13176 (cmdline_parse_inst_t *)&cmd_start_tx_first,
13177 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13178 (cmdline_parse_inst_t *)&cmd_set_link_up,
13179 (cmdline_parse_inst_t *)&cmd_set_link_down,
13180 (cmdline_parse_inst_t *)&cmd_reset,
13181 (cmdline_parse_inst_t *)&cmd_set_numbers,
13182 (cmdline_parse_inst_t *)&cmd_set_txpkts,
13183 (cmdline_parse_inst_t *)&cmd_set_txsplit,
13184 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13185 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13186 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13187 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13188 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13189 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13190 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13191 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13192 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13193 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13194 (cmdline_parse_inst_t *)&cmd_set_link_check,
13195 #ifdef RTE_NIC_BYPASS
13196 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13197 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13198 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13199 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13201 #ifdef RTE_LIBRTE_PMD_BOND
13202 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13203 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13204 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13205 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13206 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13207 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13208 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13209 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13210 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13212 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13213 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13214 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13215 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13216 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13217 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13218 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13219 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13220 (cmdline_parse_inst_t *)&cmd_csum_set,
13221 (cmdline_parse_inst_t *)&cmd_csum_show,
13222 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13223 (cmdline_parse_inst_t *)&cmd_tso_set,
13224 (cmdline_parse_inst_t *)&cmd_tso_show,
13225 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13226 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13227 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13228 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13229 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13230 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13231 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13232 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13233 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13234 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13235 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13236 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13237 (cmdline_parse_inst_t *)&cmd_config_dcb,
13238 (cmdline_parse_inst_t *)&cmd_read_reg,
13239 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13240 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13241 (cmdline_parse_inst_t *)&cmd_write_reg,
13242 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13243 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13244 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13245 (cmdline_parse_inst_t *)&cmd_stop,
13246 (cmdline_parse_inst_t *)&cmd_mac_addr,
13247 (cmdline_parse_inst_t *)&cmd_set_qmap,
13248 (cmdline_parse_inst_t *)&cmd_operate_port,
13249 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13250 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13251 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13252 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13253 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13254 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13255 (cmdline_parse_inst_t *)&cmd_config_mtu,
13256 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13257 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13258 (cmdline_parse_inst_t *)&cmd_config_rss,
13259 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13260 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13261 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13262 (cmdline_parse_inst_t *)&cmd_showport_reta,
13263 (cmdline_parse_inst_t *)&cmd_config_burst,
13264 (cmdline_parse_inst_t *)&cmd_config_thresh,
13265 (cmdline_parse_inst_t *)&cmd_config_threshold,
13266 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13267 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13268 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13269 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13270 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13271 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13272 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13273 (cmdline_parse_inst_t *)&cmd_global_config,
13274 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13275 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13276 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13277 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13278 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13279 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13280 (cmdline_parse_inst_t *)&cmd_dump,
13281 (cmdline_parse_inst_t *)&cmd_dump_one,
13282 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13283 (cmdline_parse_inst_t *)&cmd_syn_filter,
13284 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13285 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13286 (cmdline_parse_inst_t *)&cmd_flex_filter,
13287 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13288 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13289 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13290 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13291 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13292 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13293 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13294 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13295 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13296 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13297 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13298 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13299 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13300 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13301 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13302 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13303 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13304 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13305 (cmdline_parse_inst_t *)&cmd_flow,
13306 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13307 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13308 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13309 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13310 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13311 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13312 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13313 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13314 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13315 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13316 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13317 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13318 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13319 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13320 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13321 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13322 #ifdef RTE_LIBRTE_IXGBE_PMD
13323 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13324 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13325 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13326 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13327 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13328 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13329 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13330 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13331 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13333 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13334 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13335 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13336 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13337 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13338 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13339 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13340 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13341 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13342 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13343 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
13344 (cmdline_parse_inst_t *)&cmd_ddp_add,
13345 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13346 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13347 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13351 /* prompt function, called from main on MASTER lcore */
13355 /* initialize non-constant commands */
13356 cmd_set_fwd_mode_init();
13357 cmd_set_fwd_retry_mode_init();
13359 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13360 if (testpmd_cl == NULL)
13362 cmdline_interact(testpmd_cl);
13363 cmdline_stdin_exit(testpmd_cl);
13369 if (testpmd_cl != NULL)
13370 cmdline_quit(testpmd_cl);
13374 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13376 if (id == (portid_t)RTE_PORT_ALL) {
13379 RTE_ETH_FOREACH_DEV(pid) {
13380 /* check if need_reconfig has been set to 1 */
13381 if (ports[pid].need_reconfig == 0)
13382 ports[pid].need_reconfig = dev;
13383 /* check if need_reconfig_queues has been set to 1 */
13384 if (ports[pid].need_reconfig_queues == 0)
13385 ports[pid].need_reconfig_queues = queue;
13387 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13388 /* check if need_reconfig has been set to 1 */
13389 if (ports[id].need_reconfig == 0)
13390 ports[id].need_reconfig = dev;
13391 /* check if need_reconfig_queues has been set to 1 */
13392 if (ports[id].need_reconfig_queues == 0)
13393 ports[id].need_reconfig_queues = queue;