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 "ptype mapping get (port_id) (valid_only)\n"
609 " Get ptype mapping on a port\n\n"
611 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
612 " Replace target with the pkt_type in ptype mapping\n\n"
614 "ptype mapping reset (port_id)\n"
615 " Reset ptype mapping on a port\n\n"
617 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
618 " Update a ptype mapping item on a port\n\n"
620 , list_pkt_forwarding_modes()
624 if (show_all || !strcmp(res->section, "ports")) {
630 "----------------\n\n"
632 "port start (port_id|all)\n"
633 " Start all ports or port_id.\n\n"
635 "port stop (port_id|all)\n"
636 " Stop all ports or port_id.\n\n"
638 "port close (port_id|all)\n"
639 " Close all ports or port_id.\n\n"
641 "port attach (ident)\n"
642 " Attach physical or virtual dev by pci address or virtual device name\n\n"
644 "port detach (port_id)\n"
645 " Detach physical or virtual dev by port_id\n\n"
647 "port config (port_id|all)"
648 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
649 " duplex (half|full|auto)\n"
650 " Set speed and duplex for all ports or port_id\n\n"
652 "port config all (rxq|txq|rxd|txd) (value)\n"
653 " Set number for rxq/txq/rxd/txd.\n\n"
655 "port config all max-pkt-len (value)\n"
656 " Set the max packet length.\n\n"
658 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
659 "hw-vlan-strip|hw-vlan-extend|drop-en)"
661 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
664 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
665 " Set the RSS mode.\n\n"
667 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
668 " Set the RSS redirection table.\n\n"
670 "port config (port_id) dcb vt (on|off) (traffic_class)"
672 " Set the DCB mode.\n\n"
674 "port config all burst (value)\n"
675 " Set the number of packets per burst.\n\n"
677 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
679 " Set the ring prefetch/host/writeback threshold"
680 " for tx/rx queue.\n\n"
682 "port config all (txfreet|txrst|rxfreet) (value)\n"
683 " Set free threshold for rx/tx, or set"
684 " tx rs bit threshold.\n\n"
685 "port config mtu X value\n"
686 " Set the MTU of port X to a given value\n\n"
688 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
689 " Start/stop a rx/tx queue of port X. Only take effect"
690 " when port X is started\n\n"
692 "port config (port_id|all) l2-tunnel E-tag ether-type"
694 " Set the value of E-tag ether-type.\n\n"
696 "port config (port_id|all) l2-tunnel E-tag"
697 " (enable|disable)\n"
698 " Enable/disable the E-tag support.\n\n"
702 if (show_all || !strcmp(res->section, "registers")) {
710 "read reg (port_id) (address)\n"
711 " Display value of a port register.\n\n"
713 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
714 " Display a port register bit field.\n\n"
716 "read regbit (port_id) (address) (bit_x)\n"
717 " Display a single port register bit.\n\n"
719 "write reg (port_id) (address) (value)\n"
720 " Set value of a port register.\n\n"
722 "write regfield (port_id) (address) (bit_x) (bit_y)"
724 " Set bit field of a port register.\n\n"
726 "write regbit (port_id) (address) (bit_x) (value)\n"
727 " Set single bit value of a port register.\n\n"
730 if (show_all || !strcmp(res->section, "filters")) {
738 "ethertype_filter (port_id) (add|del)"
739 " (mac_addr|mac_ignr) (mac_address) ethertype"
740 " (ether_type) (drop|fwd) queue (queue_id)\n"
741 " Add/Del an ethertype filter.\n\n"
743 "2tuple_filter (port_id) (add|del)"
744 " dst_port (dst_port_value) protocol (protocol_value)"
745 " mask (mask_value) tcp_flags (tcp_flags_value)"
746 " priority (prio_value) queue (queue_id)\n"
747 " Add/Del a 2tuple filter.\n\n"
749 "5tuple_filter (port_id) (add|del)"
750 " dst_ip (dst_address) src_ip (src_address)"
751 " dst_port (dst_port_value) src_port (src_port_value)"
752 " protocol (protocol_value)"
753 " mask (mask_value) tcp_flags (tcp_flags_value)"
754 " priority (prio_value) queue (queue_id)\n"
755 " Add/Del a 5tuple filter.\n\n"
757 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
758 " Add/Del syn filter.\n\n"
760 "flex_filter (port_id) (add|del) len (len_value)"
761 " bytes (bytes_value) mask (mask_value)"
762 " priority (prio_value) queue (queue_id)\n"
763 " Add/Del a flex filter.\n\n"
765 "flow_director_filter (port_id) mode IP (add|del|update)"
766 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
767 " src (src_ip_address) dst (dst_ip_address)"
768 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
769 " vlan (vlan_value) flexbytes (flexbytes_value)"
770 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
771 " fd_id (fd_id_value)\n"
772 " Add/Del an IP type flow director filter.\n\n"
774 "flow_director_filter (port_id) mode IP (add|del|update)"
775 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
776 " src (src_ip_address) (src_port)"
777 " dst (dst_ip_address) (dst_port)"
778 " tos (tos_value) ttl (ttl_value)"
779 " vlan (vlan_value) flexbytes (flexbytes_value)"
780 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
781 " fd_id (fd_id_value)\n"
782 " Add/Del an UDP/TCP type flow director filter.\n\n"
784 "flow_director_filter (port_id) mode IP (add|del|update)"
785 " flow (ipv4-sctp|ipv6-sctp)"
786 " src (src_ip_address) (src_port)"
787 " dst (dst_ip_address) (dst_port)"
788 " tag (verification_tag) "
789 " tos (tos_value) ttl (ttl_value)"
791 " flexbytes (flexbytes_value) (drop|fwd)"
792 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
793 " Add/Del a SCTP type flow director filter.\n\n"
795 "flow_director_filter (port_id) mode IP (add|del|update)"
796 " flow l2_payload ether (ethertype)"
797 " flexbytes (flexbytes_value) (drop|fwd)"
798 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
799 " Add/Del a l2 payload type flow director filter.\n\n"
801 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
802 " mac (mac_address) vlan (vlan_value)"
803 " flexbytes (flexbytes_value) (drop|fwd)"
804 " queue (queue_id) fd_id (fd_id_value)\n"
805 " Add/Del a MAC-VLAN flow director filter.\n\n"
807 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
808 " mac (mac_address) vlan (vlan_value)"
809 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
810 " flexbytes (flexbytes_value) (drop|fwd)"
811 " queue (queue_id) fd_id (fd_id_value)\n"
812 " Add/Del a Tunnel flow director filter.\n\n"
814 "flush_flow_director (port_id)\n"
815 " Flush all flow director entries of a device.\n\n"
817 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
818 " src_mask (ipv4_src) (ipv6_src) (src_port)"
819 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
820 " Set flow director IP mask.\n\n"
822 "flow_director_mask (port_id) mode MAC-VLAN"
823 " vlan (vlan_value)\n"
824 " Set flow director MAC-VLAN mask.\n\n"
826 "flow_director_mask (port_id) mode Tunnel"
827 " vlan (vlan_value) mac (mac_value)"
828 " tunnel-type (tunnel_type_value)"
829 " tunnel-id (tunnel_id_value)\n"
830 " Set flow director Tunnel mask.\n\n"
832 "flow_director_flex_mask (port_id)"
833 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
834 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
836 " Configure mask of flex payload.\n\n"
838 "flow_director_flex_payload (port_id)"
839 " (raw|l2|l3|l4) (config)\n"
840 " Configure flex payload selection.\n\n"
842 "get_sym_hash_ena_per_port (port_id)\n"
843 " get symmetric hash enable configuration per port.\n\n"
845 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
846 " set symmetric hash enable configuration per port"
847 " to enable or disable.\n\n"
849 "get_hash_global_config (port_id)\n"
850 " Get the global configurations of hash filters.\n\n"
852 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
853 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
854 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
855 " (enable|disable)\n"
856 " Set the global configurations of hash filters.\n\n"
858 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
859 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
860 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
861 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
862 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
863 "ipv6-next-header|udp-src-port|udp-dst-port|"
864 "tcp-src-port|tcp-dst-port|sctp-src-port|"
865 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
866 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
867 "fld-8th|none) (select|add)\n"
868 " Set the input set for hash.\n\n"
870 "set_fdir_input_set (port_id) "
871 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
872 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
873 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
874 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
875 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
876 "udp-dst-port|tcp-src-port|tcp-dst-port|"
877 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
879 " Set the input set for FDir.\n\n"
881 "flow validate {port_id}"
882 " [group {group_id}] [priority {level}]"
883 " [ingress] [egress]"
884 " pattern {item} [/ {item} [...]] / end"
885 " actions {action} [/ {action} [...]] / end\n"
886 " Check whether a flow rule can be created.\n\n"
888 "flow create {port_id}"
889 " [group {group_id}] [priority {level}]"
890 " [ingress] [egress]"
891 " pattern {item} [/ {item} [...]] / end"
892 " actions {action} [/ {action} [...]] / end\n"
893 " Create a flow rule.\n\n"
895 "flow destroy {port_id} rule {rule_id} [...]\n"
896 " Destroy specific flow rules.\n\n"
898 "flow flush {port_id}\n"
899 " Destroy all flow rules.\n\n"
901 "flow query {port_id} {rule_id} {action}\n"
902 " Query an existing flow rule.\n\n"
904 "flow list {port_id} [group {group_id}] [...]\n"
905 " List existing flow rules sorted by priority,"
906 " filtered by group identifiers.\n\n"
911 cmdline_parse_token_string_t cmd_help_long_help =
912 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
914 cmdline_parse_token_string_t cmd_help_long_section =
915 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
916 "all#control#display#config#"
917 "ports#registers#filters");
919 cmdline_parse_inst_t cmd_help_long = {
920 .f = cmd_help_long_parsed,
922 .help_str = "help all|control|display|config|ports|register|filters: "
925 (void *)&cmd_help_long_help,
926 (void *)&cmd_help_long_section,
932 /* *** start/stop/close all ports *** */
933 struct cmd_operate_port_result {
934 cmdline_fixed_string_t keyword;
935 cmdline_fixed_string_t name;
936 cmdline_fixed_string_t value;
939 static void cmd_operate_port_parsed(void *parsed_result,
940 __attribute__((unused)) struct cmdline *cl,
941 __attribute__((unused)) void *data)
943 struct cmd_operate_port_result *res = parsed_result;
945 if (!strcmp(res->name, "start"))
946 start_port(RTE_PORT_ALL);
947 else if (!strcmp(res->name, "stop"))
948 stop_port(RTE_PORT_ALL);
949 else if (!strcmp(res->name, "close"))
950 close_port(RTE_PORT_ALL);
952 printf("Unknown parameter\n");
955 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
956 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
958 cmdline_parse_token_string_t cmd_operate_port_all_port =
959 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
961 cmdline_parse_token_string_t cmd_operate_port_all_all =
962 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
964 cmdline_parse_inst_t cmd_operate_port = {
965 .f = cmd_operate_port_parsed,
967 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
969 (void *)&cmd_operate_port_all_cmd,
970 (void *)&cmd_operate_port_all_port,
971 (void *)&cmd_operate_port_all_all,
976 /* *** start/stop/close specific port *** */
977 struct cmd_operate_specific_port_result {
978 cmdline_fixed_string_t keyword;
979 cmdline_fixed_string_t name;
983 static void cmd_operate_specific_port_parsed(void *parsed_result,
984 __attribute__((unused)) struct cmdline *cl,
985 __attribute__((unused)) void *data)
987 struct cmd_operate_specific_port_result *res = parsed_result;
989 if (!strcmp(res->name, "start"))
990 start_port(res->value);
991 else if (!strcmp(res->name, "stop"))
992 stop_port(res->value);
993 else if (!strcmp(res->name, "close"))
994 close_port(res->value);
996 printf("Unknown parameter\n");
999 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1000 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1002 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1003 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1004 name, "start#stop#close");
1005 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1006 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1009 cmdline_parse_inst_t cmd_operate_specific_port = {
1010 .f = cmd_operate_specific_port_parsed,
1012 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1014 (void *)&cmd_operate_specific_port_cmd,
1015 (void *)&cmd_operate_specific_port_port,
1016 (void *)&cmd_operate_specific_port_id,
1021 /* *** attach a specified port *** */
1022 struct cmd_operate_attach_port_result {
1023 cmdline_fixed_string_t port;
1024 cmdline_fixed_string_t keyword;
1025 cmdline_fixed_string_t identifier;
1028 static void cmd_operate_attach_port_parsed(void *parsed_result,
1029 __attribute__((unused)) struct cmdline *cl,
1030 __attribute__((unused)) void *data)
1032 struct cmd_operate_attach_port_result *res = parsed_result;
1034 if (!strcmp(res->keyword, "attach"))
1035 attach_port(res->identifier);
1037 printf("Unknown parameter\n");
1040 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1041 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1043 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1044 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1046 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1047 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1050 cmdline_parse_inst_t cmd_operate_attach_port = {
1051 .f = cmd_operate_attach_port_parsed,
1053 .help_str = "port attach <identifier>: "
1054 "(identifier: pci address or virtual dev name)",
1056 (void *)&cmd_operate_attach_port_port,
1057 (void *)&cmd_operate_attach_port_keyword,
1058 (void *)&cmd_operate_attach_port_identifier,
1063 /* *** detach a specified port *** */
1064 struct cmd_operate_detach_port_result {
1065 cmdline_fixed_string_t port;
1066 cmdline_fixed_string_t keyword;
1070 static void cmd_operate_detach_port_parsed(void *parsed_result,
1071 __attribute__((unused)) struct cmdline *cl,
1072 __attribute__((unused)) void *data)
1074 struct cmd_operate_detach_port_result *res = parsed_result;
1076 if (!strcmp(res->keyword, "detach"))
1077 detach_port(res->port_id);
1079 printf("Unknown parameter\n");
1082 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1083 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1085 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1086 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1088 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1089 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1092 cmdline_parse_inst_t cmd_operate_detach_port = {
1093 .f = cmd_operate_detach_port_parsed,
1095 .help_str = "port detach <port_id>",
1097 (void *)&cmd_operate_detach_port_port,
1098 (void *)&cmd_operate_detach_port_keyword,
1099 (void *)&cmd_operate_detach_port_port_id,
1104 /* *** configure speed for all ports *** */
1105 struct cmd_config_speed_all {
1106 cmdline_fixed_string_t port;
1107 cmdline_fixed_string_t keyword;
1108 cmdline_fixed_string_t all;
1109 cmdline_fixed_string_t item1;
1110 cmdline_fixed_string_t item2;
1111 cmdline_fixed_string_t value1;
1112 cmdline_fixed_string_t value2;
1116 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1121 if (!strcmp(duplexstr, "half")) {
1122 duplex = ETH_LINK_HALF_DUPLEX;
1123 } else if (!strcmp(duplexstr, "full")) {
1124 duplex = ETH_LINK_FULL_DUPLEX;
1125 } else if (!strcmp(duplexstr, "auto")) {
1126 duplex = ETH_LINK_FULL_DUPLEX;
1128 printf("Unknown duplex parameter\n");
1132 if (!strcmp(speedstr, "10")) {
1133 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1134 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1135 } else if (!strcmp(speedstr, "100")) {
1136 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1137 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1139 if (duplex != ETH_LINK_FULL_DUPLEX) {
1140 printf("Invalid speed/duplex parameters\n");
1143 if (!strcmp(speedstr, "1000")) {
1144 *speed = ETH_LINK_SPEED_1G;
1145 } else if (!strcmp(speedstr, "10000")) {
1146 *speed = ETH_LINK_SPEED_10G;
1147 } else if (!strcmp(speedstr, "25000")) {
1148 *speed = ETH_LINK_SPEED_25G;
1149 } else if (!strcmp(speedstr, "40000")) {
1150 *speed = ETH_LINK_SPEED_40G;
1151 } else if (!strcmp(speedstr, "50000")) {
1152 *speed = ETH_LINK_SPEED_50G;
1153 } else if (!strcmp(speedstr, "100000")) {
1154 *speed = ETH_LINK_SPEED_100G;
1155 } else if (!strcmp(speedstr, "auto")) {
1156 *speed = ETH_LINK_SPEED_AUTONEG;
1158 printf("Unknown speed parameter\n");
1167 cmd_config_speed_all_parsed(void *parsed_result,
1168 __attribute__((unused)) struct cmdline *cl,
1169 __attribute__((unused)) void *data)
1171 struct cmd_config_speed_all *res = parsed_result;
1172 uint32_t link_speed;
1175 if (!all_ports_stopped()) {
1176 printf("Please stop all ports first\n");
1180 if (parse_and_check_speed_duplex(res->value1, res->value2,
1184 RTE_ETH_FOREACH_DEV(pid) {
1185 ports[pid].dev_conf.link_speeds = link_speed;
1188 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1191 cmdline_parse_token_string_t cmd_config_speed_all_port =
1192 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1193 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1194 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1196 cmdline_parse_token_string_t cmd_config_speed_all_all =
1197 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1198 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1199 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1200 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1201 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1202 "10#100#1000#10000#25000#40000#50000#100000#auto");
1203 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1204 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1205 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1206 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1209 cmdline_parse_inst_t cmd_config_speed_all = {
1210 .f = cmd_config_speed_all_parsed,
1212 .help_str = "port config all speed "
1213 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1216 (void *)&cmd_config_speed_all_port,
1217 (void *)&cmd_config_speed_all_keyword,
1218 (void *)&cmd_config_speed_all_all,
1219 (void *)&cmd_config_speed_all_item1,
1220 (void *)&cmd_config_speed_all_value1,
1221 (void *)&cmd_config_speed_all_item2,
1222 (void *)&cmd_config_speed_all_value2,
1227 /* *** configure speed for specific port *** */
1228 struct cmd_config_speed_specific {
1229 cmdline_fixed_string_t port;
1230 cmdline_fixed_string_t keyword;
1232 cmdline_fixed_string_t item1;
1233 cmdline_fixed_string_t item2;
1234 cmdline_fixed_string_t value1;
1235 cmdline_fixed_string_t value2;
1239 cmd_config_speed_specific_parsed(void *parsed_result,
1240 __attribute__((unused)) struct cmdline *cl,
1241 __attribute__((unused)) void *data)
1243 struct cmd_config_speed_specific *res = parsed_result;
1244 uint32_t link_speed;
1246 if (!all_ports_stopped()) {
1247 printf("Please stop all ports first\n");
1251 if (port_id_is_invalid(res->id, ENABLED_WARN))
1254 if (parse_and_check_speed_duplex(res->value1, res->value2,
1258 ports[res->id].dev_conf.link_speeds = link_speed;
1260 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1264 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1265 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1267 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1268 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1270 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1271 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1272 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1273 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1275 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1276 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1277 "10#100#1000#10000#25000#40000#50000#100000#auto");
1278 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1279 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1281 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1282 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1285 cmdline_parse_inst_t cmd_config_speed_specific = {
1286 .f = cmd_config_speed_specific_parsed,
1288 .help_str = "port config <port_id> speed "
1289 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1292 (void *)&cmd_config_speed_specific_port,
1293 (void *)&cmd_config_speed_specific_keyword,
1294 (void *)&cmd_config_speed_specific_id,
1295 (void *)&cmd_config_speed_specific_item1,
1296 (void *)&cmd_config_speed_specific_value1,
1297 (void *)&cmd_config_speed_specific_item2,
1298 (void *)&cmd_config_speed_specific_value2,
1303 /* *** configure txq/rxq, txd/rxd *** */
1304 struct cmd_config_rx_tx {
1305 cmdline_fixed_string_t port;
1306 cmdline_fixed_string_t keyword;
1307 cmdline_fixed_string_t all;
1308 cmdline_fixed_string_t name;
1313 cmd_config_rx_tx_parsed(void *parsed_result,
1314 __attribute__((unused)) struct cmdline *cl,
1315 __attribute__((unused)) void *data)
1317 struct cmd_config_rx_tx *res = parsed_result;
1319 if (!all_ports_stopped()) {
1320 printf("Please stop all ports first\n");
1323 if (!strcmp(res->name, "rxq")) {
1324 if (!res->value && !nb_txq) {
1325 printf("Warning: Either rx or tx queues should be non zero\n");
1328 nb_rxq = res->value;
1330 else if (!strcmp(res->name, "txq")) {
1331 if (!res->value && !nb_rxq) {
1332 printf("Warning: Either rx or tx queues should be non zero\n");
1335 nb_txq = res->value;
1337 else if (!strcmp(res->name, "rxd")) {
1338 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1339 printf("rxd %d invalid - must be > 0 && <= %d\n",
1340 res->value, RTE_TEST_RX_DESC_MAX);
1343 nb_rxd = res->value;
1344 } else if (!strcmp(res->name, "txd")) {
1345 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1346 printf("txd %d invalid - must be > 0 && <= %d\n",
1347 res->value, RTE_TEST_TX_DESC_MAX);
1350 nb_txd = res->value;
1352 printf("Unknown parameter\n");
1360 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1363 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1364 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1365 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1366 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1367 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1368 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1369 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1370 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1372 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1373 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1375 cmdline_parse_inst_t cmd_config_rx_tx = {
1376 .f = cmd_config_rx_tx_parsed,
1378 .help_str = "port config all rxq|txq|rxd|txd <value>",
1380 (void *)&cmd_config_rx_tx_port,
1381 (void *)&cmd_config_rx_tx_keyword,
1382 (void *)&cmd_config_rx_tx_all,
1383 (void *)&cmd_config_rx_tx_name,
1384 (void *)&cmd_config_rx_tx_value,
1389 /* *** config max packet length *** */
1390 struct cmd_config_max_pkt_len_result {
1391 cmdline_fixed_string_t port;
1392 cmdline_fixed_string_t keyword;
1393 cmdline_fixed_string_t all;
1394 cmdline_fixed_string_t name;
1399 cmd_config_max_pkt_len_parsed(void *parsed_result,
1400 __attribute__((unused)) struct cmdline *cl,
1401 __attribute__((unused)) void *data)
1403 struct cmd_config_max_pkt_len_result *res = parsed_result;
1405 if (!all_ports_stopped()) {
1406 printf("Please stop all ports first\n");
1410 if (!strcmp(res->name, "max-pkt-len")) {
1411 if (res->value < ETHER_MIN_LEN) {
1412 printf("max-pkt-len can not be less than %d\n",
1416 if (res->value == rx_mode.max_rx_pkt_len)
1419 rx_mode.max_rx_pkt_len = res->value;
1420 if (res->value > ETHER_MAX_LEN)
1421 rx_mode.jumbo_frame = 1;
1423 rx_mode.jumbo_frame = 0;
1425 printf("Unknown parameter\n");
1431 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1434 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1435 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1437 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1438 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1440 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1441 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1443 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1444 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1446 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1447 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1450 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1451 .f = cmd_config_max_pkt_len_parsed,
1453 .help_str = "port config all max-pkt-len <value>",
1455 (void *)&cmd_config_max_pkt_len_port,
1456 (void *)&cmd_config_max_pkt_len_keyword,
1457 (void *)&cmd_config_max_pkt_len_all,
1458 (void *)&cmd_config_max_pkt_len_name,
1459 (void *)&cmd_config_max_pkt_len_value,
1464 /* *** configure port MTU *** */
1465 struct cmd_config_mtu_result {
1466 cmdline_fixed_string_t port;
1467 cmdline_fixed_string_t keyword;
1468 cmdline_fixed_string_t mtu;
1474 cmd_config_mtu_parsed(void *parsed_result,
1475 __attribute__((unused)) struct cmdline *cl,
1476 __attribute__((unused)) void *data)
1478 struct cmd_config_mtu_result *res = parsed_result;
1480 if (res->value < ETHER_MIN_LEN) {
1481 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1484 port_mtu_set(res->port_id, res->value);
1487 cmdline_parse_token_string_t cmd_config_mtu_port =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1490 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1491 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1493 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1496 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1497 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1498 cmdline_parse_token_num_t cmd_config_mtu_value =
1499 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1501 cmdline_parse_inst_t cmd_config_mtu = {
1502 .f = cmd_config_mtu_parsed,
1504 .help_str = "port config mtu <port_id> <value>",
1506 (void *)&cmd_config_mtu_port,
1507 (void *)&cmd_config_mtu_keyword,
1508 (void *)&cmd_config_mtu_mtu,
1509 (void *)&cmd_config_mtu_port_id,
1510 (void *)&cmd_config_mtu_value,
1515 /* *** configure rx mode *** */
1516 struct cmd_config_rx_mode_flag {
1517 cmdline_fixed_string_t port;
1518 cmdline_fixed_string_t keyword;
1519 cmdline_fixed_string_t all;
1520 cmdline_fixed_string_t name;
1521 cmdline_fixed_string_t value;
1525 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1526 __attribute__((unused)) struct cmdline *cl,
1527 __attribute__((unused)) void *data)
1529 struct cmd_config_rx_mode_flag *res = parsed_result;
1531 if (!all_ports_stopped()) {
1532 printf("Please stop all ports first\n");
1536 if (!strcmp(res->name, "crc-strip")) {
1537 if (!strcmp(res->value, "on"))
1538 rx_mode.hw_strip_crc = 1;
1539 else if (!strcmp(res->value, "off"))
1540 rx_mode.hw_strip_crc = 0;
1542 printf("Unknown parameter\n");
1545 } else if (!strcmp(res->name, "scatter")) {
1546 if (!strcmp(res->value, "on"))
1547 rx_mode.enable_scatter = 1;
1548 else if (!strcmp(res->value, "off"))
1549 rx_mode.enable_scatter = 0;
1551 printf("Unknown parameter\n");
1554 } else if (!strcmp(res->name, "rx-cksum")) {
1555 if (!strcmp(res->value, "on"))
1556 rx_mode.hw_ip_checksum = 1;
1557 else if (!strcmp(res->value, "off"))
1558 rx_mode.hw_ip_checksum = 0;
1560 printf("Unknown parameter\n");
1563 } else if (!strcmp(res->name, "hw-vlan")) {
1564 if (!strcmp(res->value, "on")) {
1565 rx_mode.hw_vlan_filter = 1;
1566 rx_mode.hw_vlan_strip = 1;
1568 else if (!strcmp(res->value, "off")) {
1569 rx_mode.hw_vlan_filter = 0;
1570 rx_mode.hw_vlan_strip = 0;
1573 printf("Unknown parameter\n");
1576 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1577 if (!strcmp(res->value, "on"))
1578 rx_mode.hw_vlan_filter = 1;
1579 else if (!strcmp(res->value, "off"))
1580 rx_mode.hw_vlan_filter = 0;
1582 printf("Unknown parameter\n");
1585 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1586 if (!strcmp(res->value, "on"))
1587 rx_mode.hw_vlan_strip = 1;
1588 else if (!strcmp(res->value, "off"))
1589 rx_mode.hw_vlan_strip = 0;
1591 printf("Unknown parameter\n");
1594 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1595 if (!strcmp(res->value, "on"))
1596 rx_mode.hw_vlan_extend = 1;
1597 else if (!strcmp(res->value, "off"))
1598 rx_mode.hw_vlan_extend = 0;
1600 printf("Unknown parameter\n");
1603 } else if (!strcmp(res->name, "drop-en")) {
1604 if (!strcmp(res->value, "on"))
1606 else if (!strcmp(res->value, "off"))
1609 printf("Unknown parameter\n");
1613 printf("Unknown parameter\n");
1619 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1622 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1623 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1624 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1625 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1627 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1629 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1630 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1631 "crc-strip#scatter#rx-cksum#hw-vlan#"
1632 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1633 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1637 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1638 .f = cmd_config_rx_mode_flag_parsed,
1640 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1641 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1643 (void *)&cmd_config_rx_mode_flag_port,
1644 (void *)&cmd_config_rx_mode_flag_keyword,
1645 (void *)&cmd_config_rx_mode_flag_all,
1646 (void *)&cmd_config_rx_mode_flag_name,
1647 (void *)&cmd_config_rx_mode_flag_value,
1652 /* *** configure rss *** */
1653 struct cmd_config_rss {
1654 cmdline_fixed_string_t port;
1655 cmdline_fixed_string_t keyword;
1656 cmdline_fixed_string_t all;
1657 cmdline_fixed_string_t name;
1658 cmdline_fixed_string_t value;
1662 cmd_config_rss_parsed(void *parsed_result,
1663 __attribute__((unused)) struct cmdline *cl,
1664 __attribute__((unused)) void *data)
1666 struct cmd_config_rss *res = parsed_result;
1667 struct rte_eth_rss_conf rss_conf;
1671 if (!strcmp(res->value, "all"))
1672 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1673 ETH_RSS_UDP | ETH_RSS_SCTP |
1675 else if (!strcmp(res->value, "ip"))
1676 rss_conf.rss_hf = ETH_RSS_IP;
1677 else if (!strcmp(res->value, "udp"))
1678 rss_conf.rss_hf = ETH_RSS_UDP;
1679 else if (!strcmp(res->value, "tcp"))
1680 rss_conf.rss_hf = ETH_RSS_TCP;
1681 else if (!strcmp(res->value, "sctp"))
1682 rss_conf.rss_hf = ETH_RSS_SCTP;
1683 else if (!strcmp(res->value, "ether"))
1684 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1685 else if (!strcmp(res->value, "port"))
1686 rss_conf.rss_hf = ETH_RSS_PORT;
1687 else if (!strcmp(res->value, "vxlan"))
1688 rss_conf.rss_hf = ETH_RSS_VXLAN;
1689 else if (!strcmp(res->value, "geneve"))
1690 rss_conf.rss_hf = ETH_RSS_GENEVE;
1691 else if (!strcmp(res->value, "nvgre"))
1692 rss_conf.rss_hf = ETH_RSS_NVGRE;
1693 else if (!strcmp(res->value, "none"))
1694 rss_conf.rss_hf = 0;
1696 printf("Unknown parameter\n");
1699 rss_conf.rss_key = NULL;
1700 for (i = 0; i < rte_eth_dev_count(); i++) {
1701 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1703 printf("Configuration of RSS hash at ethernet port %d "
1704 "failed with error (%d): %s.\n",
1705 i, -diag, strerror(-diag));
1709 cmdline_parse_token_string_t cmd_config_rss_port =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1711 cmdline_parse_token_string_t cmd_config_rss_keyword =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1713 cmdline_parse_token_string_t cmd_config_rss_all =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1715 cmdline_parse_token_string_t cmd_config_rss_name =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1717 cmdline_parse_token_string_t cmd_config_rss_value =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1719 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1721 cmdline_parse_inst_t cmd_config_rss = {
1722 .f = cmd_config_rss_parsed,
1724 .help_str = "port config all rss "
1725 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1727 (void *)&cmd_config_rss_port,
1728 (void *)&cmd_config_rss_keyword,
1729 (void *)&cmd_config_rss_all,
1730 (void *)&cmd_config_rss_name,
1731 (void *)&cmd_config_rss_value,
1736 /* *** configure rss hash key *** */
1737 struct cmd_config_rss_hash_key {
1738 cmdline_fixed_string_t port;
1739 cmdline_fixed_string_t config;
1741 cmdline_fixed_string_t rss_hash_key;
1742 cmdline_fixed_string_t rss_type;
1743 cmdline_fixed_string_t key;
1747 hexa_digit_to_value(char hexa_digit)
1749 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1750 return (uint8_t) (hexa_digit - '0');
1751 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1752 return (uint8_t) ((hexa_digit - 'a') + 10);
1753 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1754 return (uint8_t) ((hexa_digit - 'A') + 10);
1755 /* Invalid hexa digit */
1760 parse_and_check_key_hexa_digit(char *key, int idx)
1764 hexa_v = hexa_digit_to_value(key[idx]);
1766 printf("invalid key: character %c at position %d is not a "
1767 "valid hexa digit\n", key[idx], idx);
1772 cmd_config_rss_hash_key_parsed(void *parsed_result,
1773 __attribute__((unused)) struct cmdline *cl,
1774 __attribute__((unused)) void *data)
1776 struct cmd_config_rss_hash_key *res = parsed_result;
1777 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1781 struct rte_eth_dev_info dev_info;
1782 uint8_t hash_key_size;
1785 memset(&dev_info, 0, sizeof(dev_info));
1786 rte_eth_dev_info_get(res->port_id, &dev_info);
1787 if (dev_info.hash_key_size > 0 &&
1788 dev_info.hash_key_size <= sizeof(hash_key))
1789 hash_key_size = dev_info.hash_key_size;
1791 printf("dev_info did not provide a valid hash key size\n");
1794 /* Check the length of the RSS hash key */
1795 key_len = strlen(res->key);
1796 if (key_len != (hash_key_size * 2)) {
1797 printf("key length: %d invalid - key must be a string of %d"
1798 " hexa-decimal numbers\n",
1799 (int) key_len, hash_key_size * 2);
1802 /* Translate RSS hash key into binary representation */
1803 for (i = 0; i < hash_key_size; i++) {
1804 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1807 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1810 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1812 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1816 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1817 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1818 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1819 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1821 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1822 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1823 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1824 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1825 rss_hash_key, "rss-hash-key");
1826 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1827 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1828 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1829 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1830 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1831 "ipv6-tcp-ex#ipv6-udp-ex");
1832 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1833 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1835 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1836 .f = cmd_config_rss_hash_key_parsed,
1838 .help_str = "port config <port_id> rss-hash-key "
1839 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1840 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1841 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1842 "<string of hex digits (variable length, NIC dependent)>",
1844 (void *)&cmd_config_rss_hash_key_port,
1845 (void *)&cmd_config_rss_hash_key_config,
1846 (void *)&cmd_config_rss_hash_key_port_id,
1847 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1848 (void *)&cmd_config_rss_hash_key_rss_type,
1849 (void *)&cmd_config_rss_hash_key_value,
1854 /* *** configure port rxq/txq start/stop *** */
1855 struct cmd_config_rxtx_queue {
1856 cmdline_fixed_string_t port;
1858 cmdline_fixed_string_t rxtxq;
1860 cmdline_fixed_string_t opname;
1864 cmd_config_rxtx_queue_parsed(void *parsed_result,
1865 __attribute__((unused)) struct cmdline *cl,
1866 __attribute__((unused)) void *data)
1868 struct cmd_config_rxtx_queue *res = parsed_result;
1873 if (test_done == 0) {
1874 printf("Please stop forwarding first\n");
1878 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1881 if (port_is_started(res->portid) != 1) {
1882 printf("Please start port %u first\n", res->portid);
1886 if (!strcmp(res->rxtxq, "rxq"))
1888 else if (!strcmp(res->rxtxq, "txq"))
1891 printf("Unknown parameter\n");
1895 if (isrx && rx_queue_id_is_invalid(res->qid))
1897 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1900 if (!strcmp(res->opname, "start"))
1902 else if (!strcmp(res->opname, "stop"))
1905 printf("Unknown parameter\n");
1909 if (isstart && isrx)
1910 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1911 else if (!isstart && isrx)
1912 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1913 else if (isstart && !isrx)
1914 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1916 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1918 if (ret == -ENOTSUP)
1919 printf("Function not supported in PMD driver\n");
1922 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1923 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1924 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1925 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1926 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1927 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1928 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1929 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1930 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1934 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1935 .f = cmd_config_rxtx_queue_parsed,
1937 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1939 (void *)&cmd_config_speed_all_port,
1940 (void *)&cmd_config_rxtx_queue_portid,
1941 (void *)&cmd_config_rxtx_queue_rxtxq,
1942 (void *)&cmd_config_rxtx_queue_qid,
1943 (void *)&cmd_config_rxtx_queue_opname,
1948 /* *** Configure RSS RETA *** */
1949 struct cmd_config_rss_reta {
1950 cmdline_fixed_string_t port;
1951 cmdline_fixed_string_t keyword;
1953 cmdline_fixed_string_t name;
1954 cmdline_fixed_string_t list_name;
1955 cmdline_fixed_string_t list_of_items;
1959 parse_reta_config(const char *str,
1960 struct rte_eth_rss_reta_entry64 *reta_conf,
1961 uint16_t nb_entries)
1965 uint16_t hash_index, idx, shift;
1968 const char *p, *p0 = str;
1975 unsigned long int_fld[_NUM_FLD];
1976 char *str_fld[_NUM_FLD];
1978 while ((p = strchr(p0,'(')) != NULL) {
1980 if((p0 = strchr(p,')')) == NULL)
1984 if(size >= sizeof(s))
1987 snprintf(s, sizeof(s), "%.*s", size, p);
1988 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1990 for (i = 0; i < _NUM_FLD; i++) {
1992 int_fld[i] = strtoul(str_fld[i], &end, 0);
1993 if (errno != 0 || end == str_fld[i] ||
1998 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1999 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2001 if (hash_index >= nb_entries) {
2002 printf("Invalid RETA hash index=%d\n", hash_index);
2006 idx = hash_index / RTE_RETA_GROUP_SIZE;
2007 shift = hash_index % RTE_RETA_GROUP_SIZE;
2008 reta_conf[idx].mask |= (1ULL << shift);
2009 reta_conf[idx].reta[shift] = nb_queue;
2016 cmd_set_rss_reta_parsed(void *parsed_result,
2017 __attribute__((unused)) struct cmdline *cl,
2018 __attribute__((unused)) void *data)
2021 struct rte_eth_dev_info dev_info;
2022 struct rte_eth_rss_reta_entry64 reta_conf[8];
2023 struct cmd_config_rss_reta *res = parsed_result;
2025 memset(&dev_info, 0, sizeof(dev_info));
2026 rte_eth_dev_info_get(res->port_id, &dev_info);
2027 if (dev_info.reta_size == 0) {
2028 printf("Redirection table size is 0 which is "
2029 "invalid for RSS\n");
2032 printf("The reta size of port %d is %u\n",
2033 res->port_id, dev_info.reta_size);
2034 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2035 printf("Currently do not support more than %u entries of "
2036 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2040 memset(reta_conf, 0, sizeof(reta_conf));
2041 if (!strcmp(res->list_name, "reta")) {
2042 if (parse_reta_config(res->list_of_items, reta_conf,
2043 dev_info.reta_size)) {
2044 printf("Invalid RSS Redirection Table "
2045 "config entered\n");
2048 ret = rte_eth_dev_rss_reta_update(res->port_id,
2049 reta_conf, dev_info.reta_size);
2051 printf("Bad redirection table parameter, "
2052 "return code = %d \n", ret);
2056 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2058 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2060 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2061 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2062 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2064 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2066 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2069 cmdline_parse_inst_t cmd_config_rss_reta = {
2070 .f = cmd_set_rss_reta_parsed,
2072 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2074 (void *)&cmd_config_rss_reta_port,
2075 (void *)&cmd_config_rss_reta_keyword,
2076 (void *)&cmd_config_rss_reta_port_id,
2077 (void *)&cmd_config_rss_reta_name,
2078 (void *)&cmd_config_rss_reta_list_name,
2079 (void *)&cmd_config_rss_reta_list_of_items,
2084 /* *** SHOW PORT RETA INFO *** */
2085 struct cmd_showport_reta {
2086 cmdline_fixed_string_t show;
2087 cmdline_fixed_string_t port;
2089 cmdline_fixed_string_t rss;
2090 cmdline_fixed_string_t reta;
2092 cmdline_fixed_string_t list_of_items;
2096 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2097 uint16_t nb_entries,
2101 const char *p, *p0 = str;
2106 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2107 RTE_RETA_GROUP_SIZE;
2110 p = strchr(p0, '(');
2114 p0 = strchr(p, ')');
2118 if (size >= sizeof(s)) {
2119 printf("The string size exceeds the internal buffer size\n");
2122 snprintf(s, sizeof(s), "%.*s", size, p);
2123 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2124 if (ret <= 0 || ret != num) {
2125 printf("The bits of masks do not match the number of "
2126 "reta entries: %u\n", num);
2129 for (i = 0; i < ret; i++)
2130 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2136 cmd_showport_reta_parsed(void *parsed_result,
2137 __attribute__((unused)) struct cmdline *cl,
2138 __attribute__((unused)) void *data)
2140 struct cmd_showport_reta *res = parsed_result;
2141 struct rte_eth_rss_reta_entry64 reta_conf[8];
2142 struct rte_eth_dev_info dev_info;
2144 memset(&dev_info, 0, sizeof(dev_info));
2145 rte_eth_dev_info_get(res->port_id, &dev_info);
2146 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2147 res->size > ETH_RSS_RETA_SIZE_512) {
2148 printf("Invalid redirection table size: %u\n", res->size);
2152 memset(reta_conf, 0, sizeof(reta_conf));
2153 if (showport_parse_reta_config(reta_conf, res->size,
2154 res->list_of_items) < 0) {
2155 printf("Invalid string: %s for reta masks\n",
2156 res->list_of_items);
2159 port_rss_reta_info(res->port_id, reta_conf, res->size);
2162 cmdline_parse_token_string_t cmd_showport_reta_show =
2163 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2164 cmdline_parse_token_string_t cmd_showport_reta_port =
2165 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2166 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2167 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2168 cmdline_parse_token_string_t cmd_showport_reta_rss =
2169 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2170 cmdline_parse_token_string_t cmd_showport_reta_reta =
2171 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2172 cmdline_parse_token_num_t cmd_showport_reta_size =
2173 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2174 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2175 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2176 list_of_items, NULL);
2178 cmdline_parse_inst_t cmd_showport_reta = {
2179 .f = cmd_showport_reta_parsed,
2181 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2183 (void *)&cmd_showport_reta_show,
2184 (void *)&cmd_showport_reta_port,
2185 (void *)&cmd_showport_reta_port_id,
2186 (void *)&cmd_showport_reta_rss,
2187 (void *)&cmd_showport_reta_reta,
2188 (void *)&cmd_showport_reta_size,
2189 (void *)&cmd_showport_reta_list_of_items,
2194 /* *** Show RSS hash configuration *** */
2195 struct cmd_showport_rss_hash {
2196 cmdline_fixed_string_t show;
2197 cmdline_fixed_string_t port;
2199 cmdline_fixed_string_t rss_hash;
2200 cmdline_fixed_string_t rss_type;
2201 cmdline_fixed_string_t key; /* optional argument */
2204 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2205 __attribute__((unused)) struct cmdline *cl,
2208 struct cmd_showport_rss_hash *res = parsed_result;
2210 port_rss_hash_conf_show(res->port_id, res->rss_type,
2211 show_rss_key != NULL);
2214 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2215 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2216 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2217 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2218 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2219 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2220 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2221 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2223 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2224 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2225 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2226 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2227 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2228 "ipv6-tcp-ex#ipv6-udp-ex");
2229 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2230 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2232 cmdline_parse_inst_t cmd_showport_rss_hash = {
2233 .f = cmd_showport_rss_hash_parsed,
2235 .help_str = "show port <port_id> rss-hash "
2236 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2237 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2238 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2240 (void *)&cmd_showport_rss_hash_show,
2241 (void *)&cmd_showport_rss_hash_port,
2242 (void *)&cmd_showport_rss_hash_port_id,
2243 (void *)&cmd_showport_rss_hash_rss_hash,
2244 (void *)&cmd_showport_rss_hash_rss_hash_info,
2249 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2250 .f = cmd_showport_rss_hash_parsed,
2252 .help_str = "show port <port_id> rss-hash "
2253 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2254 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2255 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2257 (void *)&cmd_showport_rss_hash_show,
2258 (void *)&cmd_showport_rss_hash_port,
2259 (void *)&cmd_showport_rss_hash_port_id,
2260 (void *)&cmd_showport_rss_hash_rss_hash,
2261 (void *)&cmd_showport_rss_hash_rss_hash_info,
2262 (void *)&cmd_showport_rss_hash_rss_key,
2267 /* *** Configure DCB *** */
2268 struct cmd_config_dcb {
2269 cmdline_fixed_string_t port;
2270 cmdline_fixed_string_t config;
2272 cmdline_fixed_string_t dcb;
2273 cmdline_fixed_string_t vt;
2274 cmdline_fixed_string_t vt_en;
2276 cmdline_fixed_string_t pfc;
2277 cmdline_fixed_string_t pfc_en;
2281 cmd_config_dcb_parsed(void *parsed_result,
2282 __attribute__((unused)) struct cmdline *cl,
2283 __attribute__((unused)) void *data)
2285 struct cmd_config_dcb *res = parsed_result;
2286 portid_t port_id = res->port_id;
2287 struct rte_port *port;
2291 port = &ports[port_id];
2292 /** Check if the port is not started **/
2293 if (port->port_status != RTE_PORT_STOPPED) {
2294 printf("Please stop port %d first\n", port_id);
2298 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2299 printf("The invalid number of traffic class,"
2300 " only 4 or 8 allowed.\n");
2304 if (nb_fwd_lcores < res->num_tcs) {
2305 printf("nb_cores shouldn't be less than number of TCs.\n");
2308 if (!strncmp(res->pfc_en, "on", 2))
2313 /* DCB in VT mode */
2314 if (!strncmp(res->vt_en, "on", 2))
2315 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2316 (enum rte_eth_nb_tcs)res->num_tcs,
2319 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2320 (enum rte_eth_nb_tcs)res->num_tcs,
2325 printf("Cannot initialize network ports.\n");
2329 cmd_reconfig_device_queue(port_id, 1, 1);
2332 cmdline_parse_token_string_t cmd_config_dcb_port =
2333 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2334 cmdline_parse_token_string_t cmd_config_dcb_config =
2335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2336 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2337 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2338 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2339 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2340 cmdline_parse_token_string_t cmd_config_dcb_vt =
2341 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2342 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2343 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2344 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2345 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2346 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2347 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2348 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2349 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2351 cmdline_parse_inst_t cmd_config_dcb = {
2352 .f = cmd_config_dcb_parsed,
2354 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2356 (void *)&cmd_config_dcb_port,
2357 (void *)&cmd_config_dcb_config,
2358 (void *)&cmd_config_dcb_port_id,
2359 (void *)&cmd_config_dcb_dcb,
2360 (void *)&cmd_config_dcb_vt,
2361 (void *)&cmd_config_dcb_vt_en,
2362 (void *)&cmd_config_dcb_num_tcs,
2363 (void *)&cmd_config_dcb_pfc,
2364 (void *)&cmd_config_dcb_pfc_en,
2369 /* *** configure number of packets per burst *** */
2370 struct cmd_config_burst {
2371 cmdline_fixed_string_t port;
2372 cmdline_fixed_string_t keyword;
2373 cmdline_fixed_string_t all;
2374 cmdline_fixed_string_t name;
2379 cmd_config_burst_parsed(void *parsed_result,
2380 __attribute__((unused)) struct cmdline *cl,
2381 __attribute__((unused)) void *data)
2383 struct cmd_config_burst *res = parsed_result;
2385 if (!all_ports_stopped()) {
2386 printf("Please stop all ports first\n");
2390 if (!strcmp(res->name, "burst")) {
2391 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2392 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2395 nb_pkt_per_burst = res->value;
2397 printf("Unknown parameter\n");
2403 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2406 cmdline_parse_token_string_t cmd_config_burst_port =
2407 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2408 cmdline_parse_token_string_t cmd_config_burst_keyword =
2409 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2410 cmdline_parse_token_string_t cmd_config_burst_all =
2411 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2412 cmdline_parse_token_string_t cmd_config_burst_name =
2413 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2414 cmdline_parse_token_num_t cmd_config_burst_value =
2415 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2417 cmdline_parse_inst_t cmd_config_burst = {
2418 .f = cmd_config_burst_parsed,
2420 .help_str = "port config all burst <value>",
2422 (void *)&cmd_config_burst_port,
2423 (void *)&cmd_config_burst_keyword,
2424 (void *)&cmd_config_burst_all,
2425 (void *)&cmd_config_burst_name,
2426 (void *)&cmd_config_burst_value,
2431 /* *** configure rx/tx queues *** */
2432 struct cmd_config_thresh {
2433 cmdline_fixed_string_t port;
2434 cmdline_fixed_string_t keyword;
2435 cmdline_fixed_string_t all;
2436 cmdline_fixed_string_t name;
2441 cmd_config_thresh_parsed(void *parsed_result,
2442 __attribute__((unused)) struct cmdline *cl,
2443 __attribute__((unused)) void *data)
2445 struct cmd_config_thresh *res = parsed_result;
2447 if (!all_ports_stopped()) {
2448 printf("Please stop all ports first\n");
2452 if (!strcmp(res->name, "txpt"))
2453 tx_pthresh = res->value;
2454 else if(!strcmp(res->name, "txht"))
2455 tx_hthresh = res->value;
2456 else if(!strcmp(res->name, "txwt"))
2457 tx_wthresh = res->value;
2458 else if(!strcmp(res->name, "rxpt"))
2459 rx_pthresh = res->value;
2460 else if(!strcmp(res->name, "rxht"))
2461 rx_hthresh = res->value;
2462 else if(!strcmp(res->name, "rxwt"))
2463 rx_wthresh = res->value;
2465 printf("Unknown parameter\n");
2471 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2474 cmdline_parse_token_string_t cmd_config_thresh_port =
2475 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2476 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2477 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2478 cmdline_parse_token_string_t cmd_config_thresh_all =
2479 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2480 cmdline_parse_token_string_t cmd_config_thresh_name =
2481 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2482 "txpt#txht#txwt#rxpt#rxht#rxwt");
2483 cmdline_parse_token_num_t cmd_config_thresh_value =
2484 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2486 cmdline_parse_inst_t cmd_config_thresh = {
2487 .f = cmd_config_thresh_parsed,
2489 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2491 (void *)&cmd_config_thresh_port,
2492 (void *)&cmd_config_thresh_keyword,
2493 (void *)&cmd_config_thresh_all,
2494 (void *)&cmd_config_thresh_name,
2495 (void *)&cmd_config_thresh_value,
2500 /* *** configure free/rs threshold *** */
2501 struct cmd_config_threshold {
2502 cmdline_fixed_string_t port;
2503 cmdline_fixed_string_t keyword;
2504 cmdline_fixed_string_t all;
2505 cmdline_fixed_string_t name;
2510 cmd_config_threshold_parsed(void *parsed_result,
2511 __attribute__((unused)) struct cmdline *cl,
2512 __attribute__((unused)) void *data)
2514 struct cmd_config_threshold *res = parsed_result;
2516 if (!all_ports_stopped()) {
2517 printf("Please stop all ports first\n");
2521 if (!strcmp(res->name, "txfreet"))
2522 tx_free_thresh = res->value;
2523 else if (!strcmp(res->name, "txrst"))
2524 tx_rs_thresh = res->value;
2525 else if (!strcmp(res->name, "rxfreet"))
2526 rx_free_thresh = res->value;
2528 printf("Unknown parameter\n");
2534 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2537 cmdline_parse_token_string_t cmd_config_threshold_port =
2538 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2539 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2540 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2542 cmdline_parse_token_string_t cmd_config_threshold_all =
2543 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2544 cmdline_parse_token_string_t cmd_config_threshold_name =
2545 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2546 "txfreet#txrst#rxfreet");
2547 cmdline_parse_token_num_t cmd_config_threshold_value =
2548 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2550 cmdline_parse_inst_t cmd_config_threshold = {
2551 .f = cmd_config_threshold_parsed,
2553 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2555 (void *)&cmd_config_threshold_port,
2556 (void *)&cmd_config_threshold_keyword,
2557 (void *)&cmd_config_threshold_all,
2558 (void *)&cmd_config_threshold_name,
2559 (void *)&cmd_config_threshold_value,
2565 struct cmd_stop_result {
2566 cmdline_fixed_string_t stop;
2569 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2570 __attribute__((unused)) struct cmdline *cl,
2571 __attribute__((unused)) void *data)
2573 stop_packet_forwarding();
2576 cmdline_parse_token_string_t cmd_stop_stop =
2577 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2579 cmdline_parse_inst_t cmd_stop = {
2580 .f = cmd_stop_parsed,
2582 .help_str = "stop: Stop packet forwarding",
2584 (void *)&cmd_stop_stop,
2589 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2592 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2593 unsigned int *parsed_items, int check_unique_values)
2595 unsigned int nb_item;
2603 * First parse all items in the list and store their value.
2608 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2610 if ((c >= '0') && (c <= '9')) {
2611 value = (unsigned int) (value * 10 + (c - '0'));
2616 printf("character %c is not a decimal digit\n", c);
2620 printf("No valid value before comma\n");
2623 if (nb_item < max_items) {
2624 parsed_items[nb_item] = value;
2630 if (nb_item >= max_items) {
2631 printf("Number of %s = %u > %u (maximum items)\n",
2632 item_name, nb_item + 1, max_items);
2635 parsed_items[nb_item++] = value;
2636 if (! check_unique_values)
2640 * Then, check that all values in the list are differents.
2641 * No optimization here...
2643 for (i = 0; i < nb_item; i++) {
2644 for (j = i + 1; j < nb_item; j++) {
2645 if (parsed_items[j] == parsed_items[i]) {
2646 printf("duplicated %s %u at index %u and %u\n",
2647 item_name, parsed_items[i], i, j);
2655 struct cmd_set_list_result {
2656 cmdline_fixed_string_t cmd_keyword;
2657 cmdline_fixed_string_t list_name;
2658 cmdline_fixed_string_t list_of_items;
2661 static void cmd_set_list_parsed(void *parsed_result,
2662 __attribute__((unused)) struct cmdline *cl,
2663 __attribute__((unused)) void *data)
2665 struct cmd_set_list_result *res;
2667 unsigned int lcorelist[RTE_MAX_LCORE];
2668 unsigned int portlist[RTE_MAX_ETHPORTS];
2670 unsigned int nb_item;
2672 if (test_done == 0) {
2673 printf("Please stop forwarding first\n");
2677 res = parsed_result;
2678 if (!strcmp(res->list_name, "corelist")) {
2679 nb_item = parse_item_list(res->list_of_items, "core",
2681 parsed_items.lcorelist, 1);
2683 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2688 if (!strcmp(res->list_name, "portlist")) {
2689 nb_item = parse_item_list(res->list_of_items, "port",
2691 parsed_items.portlist, 1);
2693 set_fwd_ports_list(parsed_items.portlist, nb_item);
2699 cmdline_parse_token_string_t cmd_set_list_keyword =
2700 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2702 cmdline_parse_token_string_t cmd_set_list_name =
2703 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2704 "corelist#portlist");
2705 cmdline_parse_token_string_t cmd_set_list_of_items =
2706 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2709 cmdline_parse_inst_t cmd_set_fwd_list = {
2710 .f = cmd_set_list_parsed,
2712 .help_str = "set corelist|portlist <list0[,list1]*>",
2714 (void *)&cmd_set_list_keyword,
2715 (void *)&cmd_set_list_name,
2716 (void *)&cmd_set_list_of_items,
2721 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2723 struct cmd_setmask_result {
2724 cmdline_fixed_string_t set;
2725 cmdline_fixed_string_t mask;
2729 static void cmd_set_mask_parsed(void *parsed_result,
2730 __attribute__((unused)) struct cmdline *cl,
2731 __attribute__((unused)) void *data)
2733 struct cmd_setmask_result *res = parsed_result;
2735 if (test_done == 0) {
2736 printf("Please stop forwarding first\n");
2739 if (!strcmp(res->mask, "coremask")) {
2740 set_fwd_lcores_mask(res->hexavalue);
2742 } else if (!strcmp(res->mask, "portmask")) {
2743 set_fwd_ports_mask(res->hexavalue);
2748 cmdline_parse_token_string_t cmd_setmask_set =
2749 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2750 cmdline_parse_token_string_t cmd_setmask_mask =
2751 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2752 "coremask#portmask");
2753 cmdline_parse_token_num_t cmd_setmask_value =
2754 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2756 cmdline_parse_inst_t cmd_set_fwd_mask = {
2757 .f = cmd_set_mask_parsed,
2759 .help_str = "set coremask|portmask <hexadecimal value>",
2761 (void *)&cmd_setmask_set,
2762 (void *)&cmd_setmask_mask,
2763 (void *)&cmd_setmask_value,
2769 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2771 struct cmd_set_result {
2772 cmdline_fixed_string_t set;
2773 cmdline_fixed_string_t what;
2777 static void cmd_set_parsed(void *parsed_result,
2778 __attribute__((unused)) struct cmdline *cl,
2779 __attribute__((unused)) void *data)
2781 struct cmd_set_result *res = parsed_result;
2782 if (!strcmp(res->what, "nbport")) {
2783 set_fwd_ports_number(res->value);
2785 } else if (!strcmp(res->what, "nbcore")) {
2786 set_fwd_lcores_number(res->value);
2788 } else if (!strcmp(res->what, "burst"))
2789 set_nb_pkt_per_burst(res->value);
2790 else if (!strcmp(res->what, "verbose"))
2791 set_verbose_level(res->value);
2794 cmdline_parse_token_string_t cmd_set_set =
2795 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2796 cmdline_parse_token_string_t cmd_set_what =
2797 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2798 "nbport#nbcore#burst#verbose");
2799 cmdline_parse_token_num_t cmd_set_value =
2800 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2802 cmdline_parse_inst_t cmd_set_numbers = {
2803 .f = cmd_set_parsed,
2805 .help_str = "set nbport|nbcore|burst|verbose <value>",
2807 (void *)&cmd_set_set,
2808 (void *)&cmd_set_what,
2809 (void *)&cmd_set_value,
2814 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2816 struct cmd_set_txpkts_result {
2817 cmdline_fixed_string_t cmd_keyword;
2818 cmdline_fixed_string_t txpkts;
2819 cmdline_fixed_string_t seg_lengths;
2823 cmd_set_txpkts_parsed(void *parsed_result,
2824 __attribute__((unused)) struct cmdline *cl,
2825 __attribute__((unused)) void *data)
2827 struct cmd_set_txpkts_result *res;
2828 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2829 unsigned int nb_segs;
2831 res = parsed_result;
2832 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2833 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2835 set_tx_pkt_segments(seg_lengths, nb_segs);
2838 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2839 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2840 cmd_keyword, "set");
2841 cmdline_parse_token_string_t cmd_set_txpkts_name =
2842 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2844 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2845 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2848 cmdline_parse_inst_t cmd_set_txpkts = {
2849 .f = cmd_set_txpkts_parsed,
2851 .help_str = "set txpkts <len0[,len1]*>",
2853 (void *)&cmd_set_txpkts_keyword,
2854 (void *)&cmd_set_txpkts_name,
2855 (void *)&cmd_set_txpkts_lengths,
2860 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2862 struct cmd_set_txsplit_result {
2863 cmdline_fixed_string_t cmd_keyword;
2864 cmdline_fixed_string_t txsplit;
2865 cmdline_fixed_string_t mode;
2869 cmd_set_txsplit_parsed(void *parsed_result,
2870 __attribute__((unused)) struct cmdline *cl,
2871 __attribute__((unused)) void *data)
2873 struct cmd_set_txsplit_result *res;
2875 res = parsed_result;
2876 set_tx_pkt_split(res->mode);
2879 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2880 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2881 cmd_keyword, "set");
2882 cmdline_parse_token_string_t cmd_set_txsplit_name =
2883 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2884 txsplit, "txsplit");
2885 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2886 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2889 cmdline_parse_inst_t cmd_set_txsplit = {
2890 .f = cmd_set_txsplit_parsed,
2892 .help_str = "set txsplit on|off|rand",
2894 (void *)&cmd_set_txsplit_keyword,
2895 (void *)&cmd_set_txsplit_name,
2896 (void *)&cmd_set_txsplit_mode,
2901 /* *** CONFIG TX QUEUE FLAGS *** */
2903 struct cmd_config_txqflags_result {
2904 cmdline_fixed_string_t port;
2905 cmdline_fixed_string_t config;
2906 cmdline_fixed_string_t all;
2907 cmdline_fixed_string_t what;
2911 static void cmd_config_txqflags_parsed(void *parsed_result,
2912 __attribute__((unused)) struct cmdline *cl,
2913 __attribute__((unused)) void *data)
2915 struct cmd_config_txqflags_result *res = parsed_result;
2917 if (!all_ports_stopped()) {
2918 printf("Please stop all ports first\n");
2922 if (strcmp(res->what, "txqflags")) {
2923 printf("Unknown parameter\n");
2927 if (res->hexvalue >= 0) {
2928 txq_flags = res->hexvalue;
2930 printf("txqflags must be >= 0\n");
2936 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2939 cmdline_parse_token_string_t cmd_config_txqflags_port =
2940 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2942 cmdline_parse_token_string_t cmd_config_txqflags_config =
2943 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2945 cmdline_parse_token_string_t cmd_config_txqflags_all =
2946 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2948 cmdline_parse_token_string_t cmd_config_txqflags_what =
2949 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2951 cmdline_parse_token_num_t cmd_config_txqflags_value =
2952 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2955 cmdline_parse_inst_t cmd_config_txqflags = {
2956 .f = cmd_config_txqflags_parsed,
2958 .help_str = "port config all txqflags <value>",
2960 (void *)&cmd_config_txqflags_port,
2961 (void *)&cmd_config_txqflags_config,
2962 (void *)&cmd_config_txqflags_all,
2963 (void *)&cmd_config_txqflags_what,
2964 (void *)&cmd_config_txqflags_value,
2969 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2970 struct cmd_rx_vlan_filter_all_result {
2971 cmdline_fixed_string_t rx_vlan;
2972 cmdline_fixed_string_t what;
2973 cmdline_fixed_string_t all;
2978 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2979 __attribute__((unused)) struct cmdline *cl,
2980 __attribute__((unused)) void *data)
2982 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2984 if (!strcmp(res->what, "add"))
2985 rx_vlan_all_filter_set(res->port_id, 1);
2987 rx_vlan_all_filter_set(res->port_id, 0);
2990 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2991 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2992 rx_vlan, "rx_vlan");
2993 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2994 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2996 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2997 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2999 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3000 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3003 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3004 .f = cmd_rx_vlan_filter_all_parsed,
3006 .help_str = "rx_vlan add|rm all <port_id>: "
3007 "Add/Remove all identifiers to/from the set of VLAN "
3008 "identifiers filtered by a port",
3010 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3011 (void *)&cmd_rx_vlan_filter_all_what,
3012 (void *)&cmd_rx_vlan_filter_all_all,
3013 (void *)&cmd_rx_vlan_filter_all_portid,
3018 /* *** VLAN OFFLOAD SET ON A PORT *** */
3019 struct cmd_vlan_offload_result {
3020 cmdline_fixed_string_t vlan;
3021 cmdline_fixed_string_t set;
3022 cmdline_fixed_string_t vlan_type;
3023 cmdline_fixed_string_t what;
3024 cmdline_fixed_string_t on;
3025 cmdline_fixed_string_t port_id;
3029 cmd_vlan_offload_parsed(void *parsed_result,
3030 __attribute__((unused)) struct cmdline *cl,
3031 __attribute__((unused)) void *data)
3034 struct cmd_vlan_offload_result *res = parsed_result;
3037 portid_t port_id = 0;
3041 len = strnlen(str, STR_TOKEN_SIZE);
3043 /* Get port_id first */
3051 tmp = strtoul(str, NULL, 0);
3052 /* If port_id greater that what portid_t can represent, return */
3053 if(tmp >= RTE_MAX_ETHPORTS)
3055 port_id = (portid_t)tmp;
3057 if (!strcmp(res->on, "on"))
3062 if (!strcmp(res->what, "strip"))
3063 rx_vlan_strip_set(port_id, on);
3064 else if(!strcmp(res->what, "stripq")){
3065 uint16_t queue_id = 0;
3067 /* No queue_id, return */
3069 printf("must specify (port,queue_id)\n");
3072 tmp = strtoul(str + i + 1, NULL, 0);
3073 /* If queue_id greater that what 16-bits can represent, return */
3077 queue_id = (uint16_t)tmp;
3078 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3080 else if (!strcmp(res->what, "filter"))
3081 rx_vlan_filter_set(port_id, on);
3083 vlan_extend_set(port_id, on);
3088 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3089 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3091 cmdline_parse_token_string_t cmd_vlan_offload_set =
3092 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3094 cmdline_parse_token_string_t cmd_vlan_offload_what =
3095 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3096 what, "strip#filter#qinq#stripq");
3097 cmdline_parse_token_string_t cmd_vlan_offload_on =
3098 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3100 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3101 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3104 cmdline_parse_inst_t cmd_vlan_offload = {
3105 .f = cmd_vlan_offload_parsed,
3107 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3108 "<port_id[,queue_id]>: "
3109 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3111 (void *)&cmd_vlan_offload_vlan,
3112 (void *)&cmd_vlan_offload_set,
3113 (void *)&cmd_vlan_offload_what,
3114 (void *)&cmd_vlan_offload_on,
3115 (void *)&cmd_vlan_offload_portid,
3120 /* *** VLAN TPID SET ON A PORT *** */
3121 struct cmd_vlan_tpid_result {
3122 cmdline_fixed_string_t vlan;
3123 cmdline_fixed_string_t set;
3124 cmdline_fixed_string_t vlan_type;
3125 cmdline_fixed_string_t what;
3131 cmd_vlan_tpid_parsed(void *parsed_result,
3132 __attribute__((unused)) struct cmdline *cl,
3133 __attribute__((unused)) void *data)
3135 struct cmd_vlan_tpid_result *res = parsed_result;
3136 enum rte_vlan_type vlan_type;
3138 if (!strcmp(res->vlan_type, "inner"))
3139 vlan_type = ETH_VLAN_TYPE_INNER;
3140 else if (!strcmp(res->vlan_type, "outer"))
3141 vlan_type = ETH_VLAN_TYPE_OUTER;
3143 printf("Unknown vlan type\n");
3146 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3149 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3150 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3152 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3153 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3155 cmdline_parse_token_string_t cmd_vlan_type =
3156 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3157 vlan_type, "inner#outer");
3158 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3159 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3161 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3162 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3164 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3165 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3168 cmdline_parse_inst_t cmd_vlan_tpid = {
3169 .f = cmd_vlan_tpid_parsed,
3171 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3172 "Set the VLAN Ether type",
3174 (void *)&cmd_vlan_tpid_vlan,
3175 (void *)&cmd_vlan_tpid_set,
3176 (void *)&cmd_vlan_type,
3177 (void *)&cmd_vlan_tpid_what,
3178 (void *)&cmd_vlan_tpid_tpid,
3179 (void *)&cmd_vlan_tpid_portid,
3184 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3185 struct cmd_rx_vlan_filter_result {
3186 cmdline_fixed_string_t rx_vlan;
3187 cmdline_fixed_string_t what;
3193 cmd_rx_vlan_filter_parsed(void *parsed_result,
3194 __attribute__((unused)) struct cmdline *cl,
3195 __attribute__((unused)) void *data)
3197 struct cmd_rx_vlan_filter_result *res = parsed_result;
3199 if (!strcmp(res->what, "add"))
3200 rx_vft_set(res->port_id, res->vlan_id, 1);
3202 rx_vft_set(res->port_id, res->vlan_id, 0);
3205 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3206 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3207 rx_vlan, "rx_vlan");
3208 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3209 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3211 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3212 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3214 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3215 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3218 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3219 .f = cmd_rx_vlan_filter_parsed,
3221 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3222 "Add/Remove a VLAN identifier to/from the set of VLAN "
3223 "identifiers filtered by a port",
3225 (void *)&cmd_rx_vlan_filter_rx_vlan,
3226 (void *)&cmd_rx_vlan_filter_what,
3227 (void *)&cmd_rx_vlan_filter_vlanid,
3228 (void *)&cmd_rx_vlan_filter_portid,
3233 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3234 struct cmd_tx_vlan_set_result {
3235 cmdline_fixed_string_t tx_vlan;
3236 cmdline_fixed_string_t set;
3242 cmd_tx_vlan_set_parsed(void *parsed_result,
3243 __attribute__((unused)) struct cmdline *cl,
3244 __attribute__((unused)) void *data)
3246 struct cmd_tx_vlan_set_result *res = parsed_result;
3248 tx_vlan_set(res->port_id, res->vlan_id);
3251 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3252 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3253 tx_vlan, "tx_vlan");
3254 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3255 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3257 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3258 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3260 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3261 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3264 cmdline_parse_inst_t cmd_tx_vlan_set = {
3265 .f = cmd_tx_vlan_set_parsed,
3267 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3268 "Enable hardware insertion of a single VLAN header "
3269 "with a given TAG Identifier in packets sent on a port",
3271 (void *)&cmd_tx_vlan_set_tx_vlan,
3272 (void *)&cmd_tx_vlan_set_set,
3273 (void *)&cmd_tx_vlan_set_portid,
3274 (void *)&cmd_tx_vlan_set_vlanid,
3279 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3280 struct cmd_tx_vlan_set_qinq_result {
3281 cmdline_fixed_string_t tx_vlan;
3282 cmdline_fixed_string_t set;
3285 uint16_t vlan_id_outer;
3289 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3290 __attribute__((unused)) struct cmdline *cl,
3291 __attribute__((unused)) void *data)
3293 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3295 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3298 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3299 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3300 tx_vlan, "tx_vlan");
3301 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3302 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3304 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3305 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3307 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3308 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3310 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3311 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3312 vlan_id_outer, UINT16);
3314 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3315 .f = cmd_tx_vlan_set_qinq_parsed,
3317 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3318 "Enable hardware insertion of double VLAN header "
3319 "with given TAG Identifiers in packets sent on a port",
3321 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3322 (void *)&cmd_tx_vlan_set_qinq_set,
3323 (void *)&cmd_tx_vlan_set_qinq_portid,
3324 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3325 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3330 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3331 struct cmd_tx_vlan_set_pvid_result {
3332 cmdline_fixed_string_t tx_vlan;
3333 cmdline_fixed_string_t set;
3334 cmdline_fixed_string_t pvid;
3337 cmdline_fixed_string_t mode;
3341 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3342 __attribute__((unused)) struct cmdline *cl,
3343 __attribute__((unused)) void *data)
3345 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3347 if (strcmp(res->mode, "on") == 0)
3348 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3350 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3353 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3354 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3355 tx_vlan, "tx_vlan");
3356 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3357 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3359 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3360 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3362 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3363 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3365 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3366 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3368 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3369 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3372 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3373 .f = cmd_tx_vlan_set_pvid_parsed,
3375 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3377 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3378 (void *)&cmd_tx_vlan_set_pvid_set,
3379 (void *)&cmd_tx_vlan_set_pvid_pvid,
3380 (void *)&cmd_tx_vlan_set_pvid_port_id,
3381 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3382 (void *)&cmd_tx_vlan_set_pvid_mode,
3387 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3388 struct cmd_tx_vlan_reset_result {
3389 cmdline_fixed_string_t tx_vlan;
3390 cmdline_fixed_string_t reset;
3395 cmd_tx_vlan_reset_parsed(void *parsed_result,
3396 __attribute__((unused)) struct cmdline *cl,
3397 __attribute__((unused)) void *data)
3399 struct cmd_tx_vlan_reset_result *res = parsed_result;
3401 tx_vlan_reset(res->port_id);
3404 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3405 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3406 tx_vlan, "tx_vlan");
3407 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3408 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3410 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3411 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3414 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3415 .f = cmd_tx_vlan_reset_parsed,
3417 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3418 "VLAN header in packets sent on a port",
3420 (void *)&cmd_tx_vlan_reset_tx_vlan,
3421 (void *)&cmd_tx_vlan_reset_reset,
3422 (void *)&cmd_tx_vlan_reset_portid,
3428 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3429 struct cmd_csum_result {
3430 cmdline_fixed_string_t csum;
3431 cmdline_fixed_string_t mode;
3432 cmdline_fixed_string_t proto;
3433 cmdline_fixed_string_t hwsw;
3438 csum_show(int port_id)
3440 struct rte_eth_dev_info dev_info;
3443 ol_flags = ports[port_id].tx_ol_flags;
3444 printf("Parse tunnel is %s\n",
3445 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3446 printf("IP checksum offload is %s\n",
3447 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3448 printf("UDP checksum offload is %s\n",
3449 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3450 printf("TCP checksum offload is %s\n",
3451 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3452 printf("SCTP checksum offload is %s\n",
3453 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3454 printf("Outer-Ip checksum offload is %s\n",
3455 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3457 /* display warnings if configuration is not supported by the NIC */
3458 rte_eth_dev_info_get(port_id, &dev_info);
3459 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3460 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3461 printf("Warning: hardware IP checksum enabled but not "
3462 "supported by port %d\n", port_id);
3464 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3465 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3466 printf("Warning: hardware UDP checksum enabled but not "
3467 "supported by port %d\n", port_id);
3469 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3470 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3471 printf("Warning: hardware TCP checksum enabled but not "
3472 "supported by port %d\n", port_id);
3474 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3475 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3476 printf("Warning: hardware SCTP checksum enabled but not "
3477 "supported by port %d\n", port_id);
3479 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3480 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3481 printf("Warning: hardware outer IP checksum enabled but not "
3482 "supported by port %d\n", port_id);
3487 cmd_csum_parsed(void *parsed_result,
3488 __attribute__((unused)) struct cmdline *cl,
3489 __attribute__((unused)) void *data)
3491 struct cmd_csum_result *res = parsed_result;
3495 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3496 printf("invalid port %d\n", res->port_id);
3500 if (!strcmp(res->mode, "set")) {
3502 if (!strcmp(res->hwsw, "hw"))
3505 if (!strcmp(res->proto, "ip")) {
3506 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3507 } else if (!strcmp(res->proto, "udp")) {
3508 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3509 } else if (!strcmp(res->proto, "tcp")) {
3510 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3511 } else if (!strcmp(res->proto, "sctp")) {
3512 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3513 } else if (!strcmp(res->proto, "outer-ip")) {
3514 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3518 ports[res->port_id].tx_ol_flags |= mask;
3520 ports[res->port_id].tx_ol_flags &= (~mask);
3522 csum_show(res->port_id);
3525 cmdline_parse_token_string_t cmd_csum_csum =
3526 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3528 cmdline_parse_token_string_t cmd_csum_mode =
3529 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3531 cmdline_parse_token_string_t cmd_csum_proto =
3532 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3533 proto, "ip#tcp#udp#sctp#outer-ip");
3534 cmdline_parse_token_string_t cmd_csum_hwsw =
3535 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3537 cmdline_parse_token_num_t cmd_csum_portid =
3538 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3541 cmdline_parse_inst_t cmd_csum_set = {
3542 .f = cmd_csum_parsed,
3544 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3545 "Enable/Disable hardware calculation of L3/L4 checksum when "
3546 "using csum forward engine",
3548 (void *)&cmd_csum_csum,
3549 (void *)&cmd_csum_mode,
3550 (void *)&cmd_csum_proto,
3551 (void *)&cmd_csum_hwsw,
3552 (void *)&cmd_csum_portid,
3557 cmdline_parse_token_string_t cmd_csum_mode_show =
3558 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3561 cmdline_parse_inst_t cmd_csum_show = {
3562 .f = cmd_csum_parsed,
3564 .help_str = "csum show <port_id>: Show checksum offload configuration",
3566 (void *)&cmd_csum_csum,
3567 (void *)&cmd_csum_mode_show,
3568 (void *)&cmd_csum_portid,
3573 /* Enable/disable tunnel parsing */
3574 struct cmd_csum_tunnel_result {
3575 cmdline_fixed_string_t csum;
3576 cmdline_fixed_string_t parse;
3577 cmdline_fixed_string_t onoff;
3582 cmd_csum_tunnel_parsed(void *parsed_result,
3583 __attribute__((unused)) struct cmdline *cl,
3584 __attribute__((unused)) void *data)
3586 struct cmd_csum_tunnel_result *res = parsed_result;
3588 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3591 if (!strcmp(res->onoff, "on"))
3592 ports[res->port_id].tx_ol_flags |=
3593 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3595 ports[res->port_id].tx_ol_flags &=
3596 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3598 csum_show(res->port_id);
3601 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3602 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3604 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3605 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3606 parse, "parse_tunnel");
3607 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3608 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3610 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3611 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3614 cmdline_parse_inst_t cmd_csum_tunnel = {
3615 .f = cmd_csum_tunnel_parsed,
3617 .help_str = "csum parse_tunnel on|off <port_id>: "
3618 "Enable/Disable parsing of tunnels for csum engine",
3620 (void *)&cmd_csum_tunnel_csum,
3621 (void *)&cmd_csum_tunnel_parse,
3622 (void *)&cmd_csum_tunnel_onoff,
3623 (void *)&cmd_csum_tunnel_portid,
3628 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3629 struct cmd_tso_set_result {
3630 cmdline_fixed_string_t tso;
3631 cmdline_fixed_string_t mode;
3637 cmd_tso_set_parsed(void *parsed_result,
3638 __attribute__((unused)) struct cmdline *cl,
3639 __attribute__((unused)) void *data)
3641 struct cmd_tso_set_result *res = parsed_result;
3642 struct rte_eth_dev_info dev_info;
3644 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3647 if (!strcmp(res->mode, "set"))
3648 ports[res->port_id].tso_segsz = res->tso_segsz;
3650 if (ports[res->port_id].tso_segsz == 0)
3651 printf("TSO for non-tunneled packets is disabled\n");
3653 printf("TSO segment size for non-tunneled packets is %d\n",
3654 ports[res->port_id].tso_segsz);
3656 /* display warnings if configuration is not supported by the NIC */
3657 rte_eth_dev_info_get(res->port_id, &dev_info);
3658 if ((ports[res->port_id].tso_segsz != 0) &&
3659 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3660 printf("Warning: TSO enabled but not "
3661 "supported by port %d\n", res->port_id);
3665 cmdline_parse_token_string_t cmd_tso_set_tso =
3666 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3668 cmdline_parse_token_string_t cmd_tso_set_mode =
3669 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3671 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3672 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3674 cmdline_parse_token_num_t cmd_tso_set_portid =
3675 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3678 cmdline_parse_inst_t cmd_tso_set = {
3679 .f = cmd_tso_set_parsed,
3681 .help_str = "tso set <tso_segsz> <port_id>: "
3682 "Set TSO segment size of non-tunneled packets for csum engine "
3685 (void *)&cmd_tso_set_tso,
3686 (void *)&cmd_tso_set_mode,
3687 (void *)&cmd_tso_set_tso_segsz,
3688 (void *)&cmd_tso_set_portid,
3693 cmdline_parse_token_string_t cmd_tso_show_mode =
3694 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3698 cmdline_parse_inst_t cmd_tso_show = {
3699 .f = cmd_tso_set_parsed,
3701 .help_str = "tso show <port_id>: "
3702 "Show TSO segment size of non-tunneled packets for csum engine",
3704 (void *)&cmd_tso_set_tso,
3705 (void *)&cmd_tso_show_mode,
3706 (void *)&cmd_tso_set_portid,
3711 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3712 struct cmd_tunnel_tso_set_result {
3713 cmdline_fixed_string_t tso;
3714 cmdline_fixed_string_t mode;
3720 check_tunnel_tso_nic_support(uint8_t port_id)
3722 struct rte_eth_dev_info dev_info;
3724 rte_eth_dev_info_get(port_id, &dev_info);
3725 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3726 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3727 "supported by port %d\n", port_id);
3728 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3729 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3730 "supported by port %d\n", port_id);
3731 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3732 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3733 "supported by port %d\n", port_id);
3734 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3735 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3736 "supported by port %d\n", port_id);
3740 cmd_tunnel_tso_set_parsed(void *parsed_result,
3741 __attribute__((unused)) struct cmdline *cl,
3742 __attribute__((unused)) void *data)
3744 struct cmd_tunnel_tso_set_result *res = parsed_result;
3746 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3749 if (!strcmp(res->mode, "set"))
3750 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3752 if (ports[res->port_id].tunnel_tso_segsz == 0)
3753 printf("TSO for tunneled packets is disabled\n");
3755 printf("TSO segment size for tunneled packets is %d\n",
3756 ports[res->port_id].tunnel_tso_segsz);
3758 /* Below conditions are needed to make it work:
3759 * (1) tunnel TSO is supported by the NIC;
3760 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3762 * (3) for tunneled pkts with outer L3 of IPv4,
3763 * "csum set outer-ip" must be set to hw, because after tso,
3764 * total_len of outer IP header is changed, and the checksum
3765 * of outer IP header calculated by sw should be wrong; that
3766 * is not necessary for IPv6 tunneled pkts because there's no
3767 * checksum in IP header anymore.
3769 check_tunnel_tso_nic_support(res->port_id);
3771 if (!(ports[res->port_id].tx_ol_flags &
3772 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3773 printf("Warning: csum parse_tunnel must be set "
3774 "so that tunneled packets are recognized\n");
3775 if (!(ports[res->port_id].tx_ol_flags &
3776 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3777 printf("Warning: csum set outer-ip must be set to hw "
3778 "if outer L3 is IPv4; not necessary for IPv6\n");
3782 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3783 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3785 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3786 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3788 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3789 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3791 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3792 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3795 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3796 .f = cmd_tunnel_tso_set_parsed,
3798 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3799 "Set TSO segment size of tunneled packets for csum engine "
3802 (void *)&cmd_tunnel_tso_set_tso,
3803 (void *)&cmd_tunnel_tso_set_mode,
3804 (void *)&cmd_tunnel_tso_set_tso_segsz,
3805 (void *)&cmd_tunnel_tso_set_portid,
3810 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3811 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3815 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3816 .f = cmd_tunnel_tso_set_parsed,
3818 .help_str = "tunnel_tso show <port_id> "
3819 "Show TSO segment size of tunneled packets for csum engine",
3821 (void *)&cmd_tunnel_tso_set_tso,
3822 (void *)&cmd_tunnel_tso_show_mode,
3823 (void *)&cmd_tunnel_tso_set_portid,
3828 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3829 struct cmd_set_flush_rx {
3830 cmdline_fixed_string_t set;
3831 cmdline_fixed_string_t flush_rx;
3832 cmdline_fixed_string_t mode;
3836 cmd_set_flush_rx_parsed(void *parsed_result,
3837 __attribute__((unused)) struct cmdline *cl,
3838 __attribute__((unused)) void *data)
3840 struct cmd_set_flush_rx *res = parsed_result;
3841 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3844 cmdline_parse_token_string_t cmd_setflushrx_set =
3845 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3847 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3848 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3849 flush_rx, "flush_rx");
3850 cmdline_parse_token_string_t cmd_setflushrx_mode =
3851 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3855 cmdline_parse_inst_t cmd_set_flush_rx = {
3856 .f = cmd_set_flush_rx_parsed,
3857 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3860 (void *)&cmd_setflushrx_set,
3861 (void *)&cmd_setflushrx_flush_rx,
3862 (void *)&cmd_setflushrx_mode,
3867 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3868 struct cmd_set_link_check {
3869 cmdline_fixed_string_t set;
3870 cmdline_fixed_string_t link_check;
3871 cmdline_fixed_string_t mode;
3875 cmd_set_link_check_parsed(void *parsed_result,
3876 __attribute__((unused)) struct cmdline *cl,
3877 __attribute__((unused)) void *data)
3879 struct cmd_set_link_check *res = parsed_result;
3880 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3883 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3884 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3886 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3887 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3888 link_check, "link_check");
3889 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3890 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3894 cmdline_parse_inst_t cmd_set_link_check = {
3895 .f = cmd_set_link_check_parsed,
3896 .help_str = "set link_check on|off: Enable/Disable link status check "
3897 "when starting/stopping a port",
3900 (void *)&cmd_setlinkcheck_set,
3901 (void *)&cmd_setlinkcheck_link_check,
3902 (void *)&cmd_setlinkcheck_mode,
3907 #ifdef RTE_NIC_BYPASS
3908 /* *** SET NIC BYPASS MODE *** */
3909 struct cmd_set_bypass_mode_result {
3910 cmdline_fixed_string_t set;
3911 cmdline_fixed_string_t bypass;
3912 cmdline_fixed_string_t mode;
3913 cmdline_fixed_string_t value;
3918 cmd_set_bypass_mode_parsed(void *parsed_result,
3919 __attribute__((unused)) struct cmdline *cl,
3920 __attribute__((unused)) void *data)
3922 struct cmd_set_bypass_mode_result *res = parsed_result;
3923 portid_t port_id = res->port_id;
3924 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3926 if (!strcmp(res->value, "bypass"))
3927 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3928 else if (!strcmp(res->value, "isolate"))
3929 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3931 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3933 /* Set the bypass mode for the relevant port. */
3934 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3935 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3939 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3940 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3942 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3943 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3945 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3946 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3948 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3949 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3950 value, "normal#bypass#isolate");
3951 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3952 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3955 cmdline_parse_inst_t cmd_set_bypass_mode = {
3956 .f = cmd_set_bypass_mode_parsed,
3957 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3958 "Set the NIC bypass mode for port_id",
3961 (void *)&cmd_setbypass_mode_set,
3962 (void *)&cmd_setbypass_mode_bypass,
3963 (void *)&cmd_setbypass_mode_mode,
3964 (void *)&cmd_setbypass_mode_value,
3965 (void *)&cmd_setbypass_mode_port,
3970 /* *** SET NIC BYPASS EVENT *** */
3971 struct cmd_set_bypass_event_result {
3972 cmdline_fixed_string_t set;
3973 cmdline_fixed_string_t bypass;
3974 cmdline_fixed_string_t event;
3975 cmdline_fixed_string_t event_value;
3976 cmdline_fixed_string_t mode;
3977 cmdline_fixed_string_t mode_value;
3982 cmd_set_bypass_event_parsed(void *parsed_result,
3983 __attribute__((unused)) struct cmdline *cl,
3984 __attribute__((unused)) void *data)
3987 struct cmd_set_bypass_event_result *res = parsed_result;
3988 portid_t port_id = res->port_id;
3989 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3990 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3992 if (!strcmp(res->event_value, "timeout"))
3993 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3994 else if (!strcmp(res->event_value, "os_on"))
3995 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3996 else if (!strcmp(res->event_value, "os_off"))
3997 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3998 else if (!strcmp(res->event_value, "power_on"))
3999 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
4000 else if (!strcmp(res->event_value, "power_off"))
4001 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
4003 bypass_event = RTE_BYPASS_EVENT_NONE;
4005 if (!strcmp(res->mode_value, "bypass"))
4006 bypass_mode = RTE_BYPASS_MODE_BYPASS;
4007 else if (!strcmp(res->mode_value, "isolate"))
4008 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
4010 bypass_mode = RTE_BYPASS_MODE_NORMAL;
4012 /* Set the watchdog timeout. */
4013 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
4016 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
4017 (rc = rte_eth_dev_wd_timeout_store(port_id,
4018 bypass_timeout)) != 0) {
4019 printf("Failed to set timeout value %u "
4020 "for port %d, errto code: %d.\n",
4021 bypass_timeout, port_id, rc);
4025 /* Set the bypass event to transition to bypass mode. */
4026 if (0 != rte_eth_dev_bypass_event_store(port_id,
4027 bypass_event, bypass_mode)) {
4028 printf("\t Failed to set bypass event for port = %d.\n", port_id);
4033 cmdline_parse_token_string_t cmd_setbypass_event_set =
4034 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4036 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4037 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4039 cmdline_parse_token_string_t cmd_setbypass_event_event =
4040 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4042 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4043 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4044 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4045 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4046 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4048 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4049 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4050 mode_value, "normal#bypass#isolate");
4051 cmdline_parse_token_num_t cmd_setbypass_event_port =
4052 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4055 cmdline_parse_inst_t cmd_set_bypass_event = {
4056 .f = cmd_set_bypass_event_parsed,
4057 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4058 "power_off mode normal|bypass|isolate <port_id>: "
4059 "Set the NIC bypass event mode for port_id",
4062 (void *)&cmd_setbypass_event_set,
4063 (void *)&cmd_setbypass_event_bypass,
4064 (void *)&cmd_setbypass_event_event,
4065 (void *)&cmd_setbypass_event_event_value,
4066 (void *)&cmd_setbypass_event_mode,
4067 (void *)&cmd_setbypass_event_mode_value,
4068 (void *)&cmd_setbypass_event_port,
4074 /* *** SET NIC BYPASS TIMEOUT *** */
4075 struct cmd_set_bypass_timeout_result {
4076 cmdline_fixed_string_t set;
4077 cmdline_fixed_string_t bypass;
4078 cmdline_fixed_string_t timeout;
4079 cmdline_fixed_string_t value;
4083 cmd_set_bypass_timeout_parsed(void *parsed_result,
4084 __attribute__((unused)) struct cmdline *cl,
4085 __attribute__((unused)) void *data)
4087 struct cmd_set_bypass_timeout_result *res = parsed_result;
4089 if (!strcmp(res->value, "1.5"))
4090 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4091 else if (!strcmp(res->value, "2"))
4092 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4093 else if (!strcmp(res->value, "3"))
4094 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4095 else if (!strcmp(res->value, "4"))
4096 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4097 else if (!strcmp(res->value, "8"))
4098 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4099 else if (!strcmp(res->value, "16"))
4100 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4101 else if (!strcmp(res->value, "32"))
4102 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4104 bypass_timeout = RTE_BYPASS_TMT_OFF;
4107 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4108 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4110 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4111 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4113 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4114 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4115 timeout, "timeout");
4116 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4117 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4118 value, "0#1.5#2#3#4#8#16#32");
4120 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4121 .f = cmd_set_bypass_timeout_parsed,
4122 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4123 "Set the NIC bypass watchdog timeout in seconds",
4126 (void *)&cmd_setbypass_timeout_set,
4127 (void *)&cmd_setbypass_timeout_bypass,
4128 (void *)&cmd_setbypass_timeout_timeout,
4129 (void *)&cmd_setbypass_timeout_value,
4134 /* *** SHOW NIC BYPASS MODE *** */
4135 struct cmd_show_bypass_config_result {
4136 cmdline_fixed_string_t show;
4137 cmdline_fixed_string_t bypass;
4138 cmdline_fixed_string_t config;
4143 cmd_show_bypass_config_parsed(void *parsed_result,
4144 __attribute__((unused)) struct cmdline *cl,
4145 __attribute__((unused)) void *data)
4147 struct cmd_show_bypass_config_result *res = parsed_result;
4148 uint32_t event_mode;
4149 uint32_t bypass_mode;
4150 portid_t port_id = res->port_id;
4151 uint32_t timeout = bypass_timeout;
4154 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4155 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4156 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4157 {"UNKNOWN", "normal", "bypass", "isolate"};
4158 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4165 int num_events = (sizeof events) / (sizeof events[0]);
4167 /* Display the bypass mode.*/
4168 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4169 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4173 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4174 bypass_mode = RTE_BYPASS_MODE_NONE;
4176 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4179 /* Display the bypass timeout.*/
4180 if (!RTE_BYPASS_TMT_VALID(timeout))
4181 timeout = RTE_BYPASS_TMT_OFF;
4183 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4185 /* Display the bypass events and associated modes. */
4186 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4188 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4189 printf("\tFailed to get bypass mode for event = %s\n",
4192 if (!RTE_BYPASS_MODE_VALID(event_mode))
4193 event_mode = RTE_BYPASS_MODE_NONE;
4195 printf("\tbypass event: %-16s = %s\n", events[i],
4201 cmdline_parse_token_string_t cmd_showbypass_config_show =
4202 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4204 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4205 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4207 cmdline_parse_token_string_t cmd_showbypass_config_config =
4208 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4210 cmdline_parse_token_num_t cmd_showbypass_config_port =
4211 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4214 cmdline_parse_inst_t cmd_show_bypass_config = {
4215 .f = cmd_show_bypass_config_parsed,
4216 .help_str = "show bypass config <port_id>: "
4217 "Show the NIC bypass config for port_id",
4220 (void *)&cmd_showbypass_config_show,
4221 (void *)&cmd_showbypass_config_bypass,
4222 (void *)&cmd_showbypass_config_config,
4223 (void *)&cmd_showbypass_config_port,
4229 #ifdef RTE_LIBRTE_PMD_BOND
4230 /* *** SET BONDING MODE *** */
4231 struct cmd_set_bonding_mode_result {
4232 cmdline_fixed_string_t set;
4233 cmdline_fixed_string_t bonding;
4234 cmdline_fixed_string_t mode;
4239 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4240 __attribute__((unused)) struct cmdline *cl,
4241 __attribute__((unused)) void *data)
4243 struct cmd_set_bonding_mode_result *res = parsed_result;
4244 portid_t port_id = res->port_id;
4246 /* Set the bonding mode for the relevant port. */
4247 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4248 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4251 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4252 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4254 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4255 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4256 bonding, "bonding");
4257 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4258 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4260 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4261 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4263 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4264 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4267 cmdline_parse_inst_t cmd_set_bonding_mode = {
4268 .f = cmd_set_bonding_mode_parsed,
4269 .help_str = "set bonding mode <mode_value> <port_id>: "
4270 "Set the bonding mode for port_id",
4273 (void *) &cmd_setbonding_mode_set,
4274 (void *) &cmd_setbonding_mode_bonding,
4275 (void *) &cmd_setbonding_mode_mode,
4276 (void *) &cmd_setbonding_mode_value,
4277 (void *) &cmd_setbonding_mode_port,
4282 /* *** SET BALANCE XMIT POLICY *** */
4283 struct cmd_set_bonding_balance_xmit_policy_result {
4284 cmdline_fixed_string_t set;
4285 cmdline_fixed_string_t bonding;
4286 cmdline_fixed_string_t balance_xmit_policy;
4288 cmdline_fixed_string_t policy;
4291 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4292 __attribute__((unused)) struct cmdline *cl,
4293 __attribute__((unused)) void *data)
4295 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4296 portid_t port_id = res->port_id;
4299 if (!strcmp(res->policy, "l2")) {
4300 policy = BALANCE_XMIT_POLICY_LAYER2;
4301 } else if (!strcmp(res->policy, "l23")) {
4302 policy = BALANCE_XMIT_POLICY_LAYER23;
4303 } else if (!strcmp(res->policy, "l34")) {
4304 policy = BALANCE_XMIT_POLICY_LAYER34;
4306 printf("\t Invalid xmit policy selection");
4310 /* Set the bonding mode for the relevant port. */
4311 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4312 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4317 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4318 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4320 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4321 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4322 bonding, "bonding");
4323 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4324 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4325 balance_xmit_policy, "balance_xmit_policy");
4326 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4327 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4329 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4330 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4331 policy, "l2#l23#l34");
4333 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4334 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4335 .help_str = "set bonding balance_xmit_policy <port_id> "
4337 "Set the bonding balance_xmit_policy for port_id",
4340 (void *)&cmd_setbonding_balance_xmit_policy_set,
4341 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4342 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4343 (void *)&cmd_setbonding_balance_xmit_policy_port,
4344 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4349 /* *** SHOW NIC BONDING CONFIGURATION *** */
4350 struct cmd_show_bonding_config_result {
4351 cmdline_fixed_string_t show;
4352 cmdline_fixed_string_t bonding;
4353 cmdline_fixed_string_t config;
4357 static void cmd_show_bonding_config_parsed(void *parsed_result,
4358 __attribute__((unused)) struct cmdline *cl,
4359 __attribute__((unused)) void *data)
4361 struct cmd_show_bonding_config_result *res = parsed_result;
4363 uint8_t slaves[RTE_MAX_ETHPORTS];
4364 int num_slaves, num_active_slaves;
4367 portid_t port_id = res->port_id;
4369 /* Display the bonding mode.*/
4370 bonding_mode = rte_eth_bond_mode_get(port_id);
4371 if (bonding_mode < 0) {
4372 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4375 printf("\tBonding mode: %d\n", bonding_mode);
4377 if (bonding_mode == BONDING_MODE_BALANCE) {
4378 int balance_xmit_policy;
4380 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4381 if (balance_xmit_policy < 0) {
4382 printf("\tFailed to get balance xmit policy for port = %d\n",
4386 printf("\tBalance Xmit Policy: ");
4388 switch (balance_xmit_policy) {
4389 case BALANCE_XMIT_POLICY_LAYER2:
4390 printf("BALANCE_XMIT_POLICY_LAYER2");
4392 case BALANCE_XMIT_POLICY_LAYER23:
4393 printf("BALANCE_XMIT_POLICY_LAYER23");
4395 case BALANCE_XMIT_POLICY_LAYER34:
4396 printf("BALANCE_XMIT_POLICY_LAYER34");
4403 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4405 if (num_slaves < 0) {
4406 printf("\tFailed to get slave list for port = %d\n", port_id);
4409 if (num_slaves > 0) {
4410 printf("\tSlaves (%d): [", num_slaves);
4411 for (i = 0; i < num_slaves - 1; i++)
4412 printf("%d ", slaves[i]);
4414 printf("%d]\n", slaves[num_slaves - 1]);
4416 printf("\tSlaves: []\n");
4420 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4423 if (num_active_slaves < 0) {
4424 printf("\tFailed to get active slave list for port = %d\n", port_id);
4427 if (num_active_slaves > 0) {
4428 printf("\tActive Slaves (%d): [", num_active_slaves);
4429 for (i = 0; i < num_active_slaves - 1; i++)
4430 printf("%d ", slaves[i]);
4432 printf("%d]\n", slaves[num_active_slaves - 1]);
4435 printf("\tActive Slaves: []\n");
4439 primary_id = rte_eth_bond_primary_get(port_id);
4440 if (primary_id < 0) {
4441 printf("\tFailed to get primary slave for port = %d\n", port_id);
4444 printf("\tPrimary: [%d]\n", primary_id);
4448 cmdline_parse_token_string_t cmd_showbonding_config_show =
4449 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4451 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4452 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4453 bonding, "bonding");
4454 cmdline_parse_token_string_t cmd_showbonding_config_config =
4455 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4457 cmdline_parse_token_num_t cmd_showbonding_config_port =
4458 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4461 cmdline_parse_inst_t cmd_show_bonding_config = {
4462 .f = cmd_show_bonding_config_parsed,
4463 .help_str = "show bonding config <port_id>: "
4464 "Show the bonding config for port_id",
4467 (void *)&cmd_showbonding_config_show,
4468 (void *)&cmd_showbonding_config_bonding,
4469 (void *)&cmd_showbonding_config_config,
4470 (void *)&cmd_showbonding_config_port,
4475 /* *** SET BONDING PRIMARY *** */
4476 struct cmd_set_bonding_primary_result {
4477 cmdline_fixed_string_t set;
4478 cmdline_fixed_string_t bonding;
4479 cmdline_fixed_string_t primary;
4484 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4485 __attribute__((unused)) struct cmdline *cl,
4486 __attribute__((unused)) void *data)
4488 struct cmd_set_bonding_primary_result *res = parsed_result;
4489 portid_t master_port_id = res->port_id;
4490 portid_t slave_port_id = res->slave_id;
4492 /* Set the primary slave for a bonded device. */
4493 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4494 printf("\t Failed to set primary slave for port = %d.\n",
4501 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4502 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4504 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4505 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4506 bonding, "bonding");
4507 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4508 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4509 primary, "primary");
4510 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4511 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4513 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4514 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4517 cmdline_parse_inst_t cmd_set_bonding_primary = {
4518 .f = cmd_set_bonding_primary_parsed,
4519 .help_str = "set bonding primary <slave_id> <port_id>: "
4520 "Set the primary slave for port_id",
4523 (void *)&cmd_setbonding_primary_set,
4524 (void *)&cmd_setbonding_primary_bonding,
4525 (void *)&cmd_setbonding_primary_primary,
4526 (void *)&cmd_setbonding_primary_slave,
4527 (void *)&cmd_setbonding_primary_port,
4532 /* *** ADD SLAVE *** */
4533 struct cmd_add_bonding_slave_result {
4534 cmdline_fixed_string_t add;
4535 cmdline_fixed_string_t bonding;
4536 cmdline_fixed_string_t slave;
4541 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4542 __attribute__((unused)) struct cmdline *cl,
4543 __attribute__((unused)) void *data)
4545 struct cmd_add_bonding_slave_result *res = parsed_result;
4546 portid_t master_port_id = res->port_id;
4547 portid_t slave_port_id = res->slave_id;
4549 /* Set the primary slave for a bonded device. */
4550 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4551 printf("\t Failed to add slave %d to master port = %d.\n",
4552 slave_port_id, master_port_id);
4556 set_port_slave_flag(slave_port_id);
4559 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4560 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4562 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4563 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4564 bonding, "bonding");
4565 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4566 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4568 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4569 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4571 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4572 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4575 cmdline_parse_inst_t cmd_add_bonding_slave = {
4576 .f = cmd_add_bonding_slave_parsed,
4577 .help_str = "add bonding slave <slave_id> <port_id>: "
4578 "Add a slave device to a bonded device",
4581 (void *)&cmd_addbonding_slave_add,
4582 (void *)&cmd_addbonding_slave_bonding,
4583 (void *)&cmd_addbonding_slave_slave,
4584 (void *)&cmd_addbonding_slave_slaveid,
4585 (void *)&cmd_addbonding_slave_port,
4590 /* *** REMOVE SLAVE *** */
4591 struct cmd_remove_bonding_slave_result {
4592 cmdline_fixed_string_t remove;
4593 cmdline_fixed_string_t bonding;
4594 cmdline_fixed_string_t slave;
4599 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4600 __attribute__((unused)) struct cmdline *cl,
4601 __attribute__((unused)) void *data)
4603 struct cmd_remove_bonding_slave_result *res = parsed_result;
4604 portid_t master_port_id = res->port_id;
4605 portid_t slave_port_id = res->slave_id;
4607 /* Set the primary slave for a bonded device. */
4608 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4609 printf("\t Failed to remove slave %d from master port = %d.\n",
4610 slave_port_id, master_port_id);
4614 clear_port_slave_flag(slave_port_id);
4617 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4618 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4620 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4621 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4622 bonding, "bonding");
4623 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4624 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4626 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4627 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4629 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4630 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4633 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4634 .f = cmd_remove_bonding_slave_parsed,
4635 .help_str = "remove bonding slave <slave_id> <port_id>: "
4636 "Remove a slave device from a bonded device",
4639 (void *)&cmd_removebonding_slave_remove,
4640 (void *)&cmd_removebonding_slave_bonding,
4641 (void *)&cmd_removebonding_slave_slave,
4642 (void *)&cmd_removebonding_slave_slaveid,
4643 (void *)&cmd_removebonding_slave_port,
4648 /* *** CREATE BONDED DEVICE *** */
4649 struct cmd_create_bonded_device_result {
4650 cmdline_fixed_string_t create;
4651 cmdline_fixed_string_t bonded;
4652 cmdline_fixed_string_t device;
4657 static int bond_dev_num = 0;
4659 static void cmd_create_bonded_device_parsed(void *parsed_result,
4660 __attribute__((unused)) struct cmdline *cl,
4661 __attribute__((unused)) void *data)
4663 struct cmd_create_bonded_device_result *res = parsed_result;
4664 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4667 if (test_done == 0) {
4668 printf("Please stop forwarding first\n");
4672 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4675 /* Create a new bonded device. */
4676 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4678 printf("\t Failed to create bonded device.\n");
4681 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4684 /* Update number of ports */
4685 nb_ports = rte_eth_dev_count();
4686 reconfig(port_id, res->socket);
4687 rte_eth_promiscuous_enable(port_id);
4692 cmdline_parse_token_string_t cmd_createbonded_device_create =
4693 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4695 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4696 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4698 cmdline_parse_token_string_t cmd_createbonded_device_device =
4699 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4701 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4702 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4704 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4705 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4708 cmdline_parse_inst_t cmd_create_bonded_device = {
4709 .f = cmd_create_bonded_device_parsed,
4710 .help_str = "create bonded device <mode> <socket>: "
4711 "Create a new bonded device with specific bonding mode and socket",
4714 (void *)&cmd_createbonded_device_create,
4715 (void *)&cmd_createbonded_device_bonded,
4716 (void *)&cmd_createbonded_device_device,
4717 (void *)&cmd_createbonded_device_mode,
4718 (void *)&cmd_createbonded_device_socket,
4723 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4724 struct cmd_set_bond_mac_addr_result {
4725 cmdline_fixed_string_t set;
4726 cmdline_fixed_string_t bonding;
4727 cmdline_fixed_string_t mac_addr;
4729 struct ether_addr address;
4732 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4733 __attribute__((unused)) struct cmdline *cl,
4734 __attribute__((unused)) void *data)
4736 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4739 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4742 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4744 /* check the return value and print it if is < 0 */
4746 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4749 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4750 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4751 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4752 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4754 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4755 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4757 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4758 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4759 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4760 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4762 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4763 .f = cmd_set_bond_mac_addr_parsed,
4765 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4767 (void *)&cmd_set_bond_mac_addr_set,
4768 (void *)&cmd_set_bond_mac_addr_bonding,
4769 (void *)&cmd_set_bond_mac_addr_mac,
4770 (void *)&cmd_set_bond_mac_addr_portnum,
4771 (void *)&cmd_set_bond_mac_addr_addr,
4777 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4778 struct cmd_set_bond_mon_period_result {
4779 cmdline_fixed_string_t set;
4780 cmdline_fixed_string_t bonding;
4781 cmdline_fixed_string_t mon_period;
4786 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4787 __attribute__((unused)) struct cmdline *cl,
4788 __attribute__((unused)) void *data)
4790 struct cmd_set_bond_mon_period_result *res = parsed_result;
4793 if (res->port_num >= nb_ports) {
4794 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4798 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4800 /* check the return value and print it if is < 0 */
4802 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4805 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4806 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4808 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4809 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4810 bonding, "bonding");
4811 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4812 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4813 mon_period, "mon_period");
4814 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4815 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4817 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4818 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4821 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4822 .f = cmd_set_bond_mon_period_parsed,
4824 .help_str = "set bonding mon_period <port_id> <period_ms>",
4826 (void *)&cmd_set_bond_mon_period_set,
4827 (void *)&cmd_set_bond_mon_period_bonding,
4828 (void *)&cmd_set_bond_mon_period_mon_period,
4829 (void *)&cmd_set_bond_mon_period_portnum,
4830 (void *)&cmd_set_bond_mon_period_period_ms,
4835 #endif /* RTE_LIBRTE_PMD_BOND */
4837 /* *** SET FORWARDING MODE *** */
4838 struct cmd_set_fwd_mode_result {
4839 cmdline_fixed_string_t set;
4840 cmdline_fixed_string_t fwd;
4841 cmdline_fixed_string_t mode;
4844 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4845 __attribute__((unused)) struct cmdline *cl,
4846 __attribute__((unused)) void *data)
4848 struct cmd_set_fwd_mode_result *res = parsed_result;
4851 set_pkt_forwarding_mode(res->mode);
4854 cmdline_parse_token_string_t cmd_setfwd_set =
4855 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4856 cmdline_parse_token_string_t cmd_setfwd_fwd =
4857 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4858 cmdline_parse_token_string_t cmd_setfwd_mode =
4859 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4860 "" /* defined at init */);
4862 cmdline_parse_inst_t cmd_set_fwd_mode = {
4863 .f = cmd_set_fwd_mode_parsed,
4865 .help_str = NULL, /* defined at init */
4867 (void *)&cmd_setfwd_set,
4868 (void *)&cmd_setfwd_fwd,
4869 (void *)&cmd_setfwd_mode,
4874 static void cmd_set_fwd_mode_init(void)
4877 static char token[128];
4878 static char help[256];
4879 cmdline_parse_token_string_t *token_struct;
4881 modes = list_pkt_forwarding_modes();
4882 snprintf(help, sizeof(help), "set fwd %s: "
4883 "Set packet forwarding mode", modes);
4884 cmd_set_fwd_mode.help_str = help;
4886 /* string token separator is # */
4887 for (c = token; *modes != '\0'; modes++)
4892 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4893 token_struct->string_data.str = token;
4896 /* *** SET RETRY FORWARDING MODE *** */
4897 struct cmd_set_fwd_retry_mode_result {
4898 cmdline_fixed_string_t set;
4899 cmdline_fixed_string_t fwd;
4900 cmdline_fixed_string_t mode;
4901 cmdline_fixed_string_t retry;
4904 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4905 __attribute__((unused)) struct cmdline *cl,
4906 __attribute__((unused)) void *data)
4908 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4911 set_pkt_forwarding_mode(res->mode);
4914 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4915 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4917 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4918 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4920 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4921 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4923 "" /* defined at init */);
4924 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4925 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4928 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4929 .f = cmd_set_fwd_retry_mode_parsed,
4931 .help_str = NULL, /* defined at init */
4933 (void *)&cmd_setfwd_retry_set,
4934 (void *)&cmd_setfwd_retry_fwd,
4935 (void *)&cmd_setfwd_retry_mode,
4936 (void *)&cmd_setfwd_retry_retry,
4941 static void cmd_set_fwd_retry_mode_init(void)
4944 static char token[128];
4945 static char help[256];
4946 cmdline_parse_token_string_t *token_struct;
4948 modes = list_pkt_forwarding_retry_modes();
4949 snprintf(help, sizeof(help), "set fwd %s retry: "
4950 "Set packet forwarding mode with retry", modes);
4951 cmd_set_fwd_retry_mode.help_str = help;
4953 /* string token separator is # */
4954 for (c = token; *modes != '\0'; modes++)
4959 token_struct = (cmdline_parse_token_string_t *)
4960 cmd_set_fwd_retry_mode.tokens[2];
4961 token_struct->string_data.str = token;
4964 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4965 struct cmd_set_burst_tx_retry_result {
4966 cmdline_fixed_string_t set;
4967 cmdline_fixed_string_t burst;
4968 cmdline_fixed_string_t tx;
4969 cmdline_fixed_string_t delay;
4971 cmdline_fixed_string_t retry;
4975 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4976 __attribute__((unused)) struct cmdline *cl,
4977 __attribute__((unused)) void *data)
4979 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4981 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4982 && !strcmp(res->tx, "tx")) {
4983 if (!strcmp(res->delay, "delay"))
4984 burst_tx_delay_time = res->time;
4985 if (!strcmp(res->retry, "retry"))
4986 burst_tx_retry_num = res->retry_num;
4991 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4992 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4993 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4994 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4996 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4997 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4998 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4999 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5000 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5001 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5002 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5003 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5004 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5005 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5007 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5008 .f = cmd_set_burst_tx_retry_parsed,
5009 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5011 (void *)&cmd_set_burst_tx_retry_set,
5012 (void *)&cmd_set_burst_tx_retry_burst,
5013 (void *)&cmd_set_burst_tx_retry_tx,
5014 (void *)&cmd_set_burst_tx_retry_delay,
5015 (void *)&cmd_set_burst_tx_retry_time,
5016 (void *)&cmd_set_burst_tx_retry_retry,
5017 (void *)&cmd_set_burst_tx_retry_retry_num,
5022 /* *** SET PROMISC MODE *** */
5023 struct cmd_set_promisc_mode_result {
5024 cmdline_fixed_string_t set;
5025 cmdline_fixed_string_t promisc;
5026 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5027 uint8_t port_num; /* valid if "allports" argument == 0 */
5028 cmdline_fixed_string_t mode;
5031 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5032 __attribute__((unused)) struct cmdline *cl,
5035 struct cmd_set_promisc_mode_result *res = parsed_result;
5039 if (!strcmp(res->mode, "on"))
5046 RTE_ETH_FOREACH_DEV(i) {
5048 rte_eth_promiscuous_enable(i);
5050 rte_eth_promiscuous_disable(i);
5055 rte_eth_promiscuous_enable(res->port_num);
5057 rte_eth_promiscuous_disable(res->port_num);
5061 cmdline_parse_token_string_t cmd_setpromisc_set =
5062 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5063 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5064 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5066 cmdline_parse_token_string_t cmd_setpromisc_portall =
5067 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5069 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5070 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5072 cmdline_parse_token_string_t cmd_setpromisc_mode =
5073 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5076 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5077 .f = cmd_set_promisc_mode_parsed,
5079 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5081 (void *)&cmd_setpromisc_set,
5082 (void *)&cmd_setpromisc_promisc,
5083 (void *)&cmd_setpromisc_portall,
5084 (void *)&cmd_setpromisc_mode,
5089 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5090 .f = cmd_set_promisc_mode_parsed,
5092 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5094 (void *)&cmd_setpromisc_set,
5095 (void *)&cmd_setpromisc_promisc,
5096 (void *)&cmd_setpromisc_portnum,
5097 (void *)&cmd_setpromisc_mode,
5102 /* *** SET ALLMULTI MODE *** */
5103 struct cmd_set_allmulti_mode_result {
5104 cmdline_fixed_string_t set;
5105 cmdline_fixed_string_t allmulti;
5106 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5107 uint8_t port_num; /* valid if "allports" argument == 0 */
5108 cmdline_fixed_string_t mode;
5111 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5112 __attribute__((unused)) struct cmdline *cl,
5115 struct cmd_set_allmulti_mode_result *res = parsed_result;
5119 if (!strcmp(res->mode, "on"))
5126 RTE_ETH_FOREACH_DEV(i) {
5128 rte_eth_allmulticast_enable(i);
5130 rte_eth_allmulticast_disable(i);
5135 rte_eth_allmulticast_enable(res->port_num);
5137 rte_eth_allmulticast_disable(res->port_num);
5141 cmdline_parse_token_string_t cmd_setallmulti_set =
5142 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5143 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5144 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5146 cmdline_parse_token_string_t cmd_setallmulti_portall =
5147 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5149 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5150 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5152 cmdline_parse_token_string_t cmd_setallmulti_mode =
5153 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5156 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5157 .f = cmd_set_allmulti_mode_parsed,
5159 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5161 (void *)&cmd_setallmulti_set,
5162 (void *)&cmd_setallmulti_allmulti,
5163 (void *)&cmd_setallmulti_portall,
5164 (void *)&cmd_setallmulti_mode,
5169 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5170 .f = cmd_set_allmulti_mode_parsed,
5172 .help_str = "set allmulti <port_id> on|off: "
5173 "Set allmulti mode on port_id",
5175 (void *)&cmd_setallmulti_set,
5176 (void *)&cmd_setallmulti_allmulti,
5177 (void *)&cmd_setallmulti_portnum,
5178 (void *)&cmd_setallmulti_mode,
5183 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5184 struct cmd_link_flow_ctrl_set_result {
5185 cmdline_fixed_string_t set;
5186 cmdline_fixed_string_t flow_ctrl;
5187 cmdline_fixed_string_t rx;
5188 cmdline_fixed_string_t rx_lfc_mode;
5189 cmdline_fixed_string_t tx;
5190 cmdline_fixed_string_t tx_lfc_mode;
5191 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5192 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5193 cmdline_fixed_string_t autoneg_str;
5194 cmdline_fixed_string_t autoneg;
5195 cmdline_fixed_string_t hw_str;
5196 uint32_t high_water;
5197 cmdline_fixed_string_t lw_str;
5199 cmdline_fixed_string_t pt_str;
5200 uint16_t pause_time;
5201 cmdline_fixed_string_t xon_str;
5206 cmdline_parse_token_string_t cmd_lfc_set_set =
5207 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5209 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5210 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5211 flow_ctrl, "flow_ctrl");
5212 cmdline_parse_token_string_t cmd_lfc_set_rx =
5213 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5215 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5216 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5217 rx_lfc_mode, "on#off");
5218 cmdline_parse_token_string_t cmd_lfc_set_tx =
5219 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5221 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5222 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5223 tx_lfc_mode, "on#off");
5224 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5225 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5226 hw_str, "high_water");
5227 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5228 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5229 high_water, UINT32);
5230 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5231 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5232 lw_str, "low_water");
5233 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5234 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5236 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5237 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5238 pt_str, "pause_time");
5239 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5240 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5241 pause_time, UINT16);
5242 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5243 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5244 xon_str, "send_xon");
5245 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5246 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5248 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5249 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5250 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5251 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5252 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5253 mac_ctrl_frame_fwd_mode, "on#off");
5254 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5255 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5256 autoneg_str, "autoneg");
5257 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5258 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5260 cmdline_parse_token_num_t cmd_lfc_set_portid =
5261 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5264 /* forward declaration */
5266 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5269 cmdline_parse_inst_t cmd_link_flow_control_set = {
5270 .f = cmd_link_flow_ctrl_set_parsed,
5272 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5273 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5274 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5276 (void *)&cmd_lfc_set_set,
5277 (void *)&cmd_lfc_set_flow_ctrl,
5278 (void *)&cmd_lfc_set_rx,
5279 (void *)&cmd_lfc_set_rx_mode,
5280 (void *)&cmd_lfc_set_tx,
5281 (void *)&cmd_lfc_set_tx_mode,
5282 (void *)&cmd_lfc_set_high_water,
5283 (void *)&cmd_lfc_set_low_water,
5284 (void *)&cmd_lfc_set_pause_time,
5285 (void *)&cmd_lfc_set_send_xon,
5286 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5287 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5288 (void *)&cmd_lfc_set_autoneg_str,
5289 (void *)&cmd_lfc_set_autoneg,
5290 (void *)&cmd_lfc_set_portid,
5295 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5296 .f = cmd_link_flow_ctrl_set_parsed,
5297 .data = (void *)&cmd_link_flow_control_set_rx,
5298 .help_str = "set flow_ctrl rx on|off <port_id>: "
5299 "Change rx flow control parameter",
5301 (void *)&cmd_lfc_set_set,
5302 (void *)&cmd_lfc_set_flow_ctrl,
5303 (void *)&cmd_lfc_set_rx,
5304 (void *)&cmd_lfc_set_rx_mode,
5305 (void *)&cmd_lfc_set_portid,
5310 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5311 .f = cmd_link_flow_ctrl_set_parsed,
5312 .data = (void *)&cmd_link_flow_control_set_tx,
5313 .help_str = "set flow_ctrl tx on|off <port_id>: "
5314 "Change tx flow control parameter",
5316 (void *)&cmd_lfc_set_set,
5317 (void *)&cmd_lfc_set_flow_ctrl,
5318 (void *)&cmd_lfc_set_tx,
5319 (void *)&cmd_lfc_set_tx_mode,
5320 (void *)&cmd_lfc_set_portid,
5325 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5326 .f = cmd_link_flow_ctrl_set_parsed,
5327 .data = (void *)&cmd_link_flow_control_set_hw,
5328 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5329 "Change high water flow control parameter",
5331 (void *)&cmd_lfc_set_set,
5332 (void *)&cmd_lfc_set_flow_ctrl,
5333 (void *)&cmd_lfc_set_high_water_str,
5334 (void *)&cmd_lfc_set_high_water,
5335 (void *)&cmd_lfc_set_portid,
5340 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5341 .f = cmd_link_flow_ctrl_set_parsed,
5342 .data = (void *)&cmd_link_flow_control_set_lw,
5343 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5344 "Change low water flow control parameter",
5346 (void *)&cmd_lfc_set_set,
5347 (void *)&cmd_lfc_set_flow_ctrl,
5348 (void *)&cmd_lfc_set_low_water_str,
5349 (void *)&cmd_lfc_set_low_water,
5350 (void *)&cmd_lfc_set_portid,
5355 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5356 .f = cmd_link_flow_ctrl_set_parsed,
5357 .data = (void *)&cmd_link_flow_control_set_pt,
5358 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5359 "Change pause time flow control parameter",
5361 (void *)&cmd_lfc_set_set,
5362 (void *)&cmd_lfc_set_flow_ctrl,
5363 (void *)&cmd_lfc_set_pause_time_str,
5364 (void *)&cmd_lfc_set_pause_time,
5365 (void *)&cmd_lfc_set_portid,
5370 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5371 .f = cmd_link_flow_ctrl_set_parsed,
5372 .data = (void *)&cmd_link_flow_control_set_xon,
5373 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5374 "Change send_xon flow control parameter",
5376 (void *)&cmd_lfc_set_set,
5377 (void *)&cmd_lfc_set_flow_ctrl,
5378 (void *)&cmd_lfc_set_send_xon_str,
5379 (void *)&cmd_lfc_set_send_xon,
5380 (void *)&cmd_lfc_set_portid,
5385 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5386 .f = cmd_link_flow_ctrl_set_parsed,
5387 .data = (void *)&cmd_link_flow_control_set_macfwd,
5388 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5389 "Change mac ctrl fwd flow control parameter",
5391 (void *)&cmd_lfc_set_set,
5392 (void *)&cmd_lfc_set_flow_ctrl,
5393 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5394 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5395 (void *)&cmd_lfc_set_portid,
5400 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5401 .f = cmd_link_flow_ctrl_set_parsed,
5402 .data = (void *)&cmd_link_flow_control_set_autoneg,
5403 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5404 "Change autoneg flow control parameter",
5406 (void *)&cmd_lfc_set_set,
5407 (void *)&cmd_lfc_set_flow_ctrl,
5408 (void *)&cmd_lfc_set_autoneg_str,
5409 (void *)&cmd_lfc_set_autoneg,
5410 (void *)&cmd_lfc_set_portid,
5416 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5417 __attribute__((unused)) struct cmdline *cl,
5420 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5421 cmdline_parse_inst_t *cmd = data;
5422 struct rte_eth_fc_conf fc_conf;
5428 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5429 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5430 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5431 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5433 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5434 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5437 /* Partial command line, retrieve current configuration */
5439 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5441 printf("cannot get current flow ctrl parameters, return"
5442 "code = %d\n", ret);
5446 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5447 (fc_conf.mode == RTE_FC_FULL))
5449 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5450 (fc_conf.mode == RTE_FC_FULL))
5454 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5455 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5457 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5458 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5460 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5462 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5463 fc_conf.high_water = res->high_water;
5465 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5466 fc_conf.low_water = res->low_water;
5468 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5469 fc_conf.pause_time = res->pause_time;
5471 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5472 fc_conf.send_xon = res->send_xon;
5474 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5475 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5476 fc_conf.mac_ctrl_frame_fwd = 1;
5478 fc_conf.mac_ctrl_frame_fwd = 0;
5481 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5482 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5484 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5486 printf("bad flow contrl parameter, return code = %d \n", ret);
5489 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5490 struct cmd_priority_flow_ctrl_set_result {
5491 cmdline_fixed_string_t set;
5492 cmdline_fixed_string_t pfc_ctrl;
5493 cmdline_fixed_string_t rx;
5494 cmdline_fixed_string_t rx_pfc_mode;
5495 cmdline_fixed_string_t tx;
5496 cmdline_fixed_string_t tx_pfc_mode;
5497 uint32_t high_water;
5499 uint16_t pause_time;
5505 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5506 __attribute__((unused)) struct cmdline *cl,
5507 __attribute__((unused)) void *data)
5509 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5510 struct rte_eth_pfc_conf pfc_conf;
5511 int rx_fc_enable, tx_fc_enable;
5515 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5516 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5517 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5518 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5520 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5521 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5524 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5525 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5526 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5527 pfc_conf.fc.high_water = res->high_water;
5528 pfc_conf.fc.low_water = res->low_water;
5529 pfc_conf.fc.pause_time = res->pause_time;
5530 pfc_conf.priority = res->priority;
5532 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5534 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5537 cmdline_parse_token_string_t cmd_pfc_set_set =
5538 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5540 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5541 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5542 pfc_ctrl, "pfc_ctrl");
5543 cmdline_parse_token_string_t cmd_pfc_set_rx =
5544 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5546 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5547 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5548 rx_pfc_mode, "on#off");
5549 cmdline_parse_token_string_t cmd_pfc_set_tx =
5550 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5552 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5553 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5554 tx_pfc_mode, "on#off");
5555 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5556 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5557 high_water, UINT32);
5558 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5559 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5561 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5562 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5563 pause_time, UINT16);
5564 cmdline_parse_token_num_t cmd_pfc_set_priority =
5565 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5567 cmdline_parse_token_num_t cmd_pfc_set_portid =
5568 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5571 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5572 .f = cmd_priority_flow_ctrl_set_parsed,
5574 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5575 "<pause_time> <priority> <port_id>: "
5576 "Configure the Ethernet priority flow control",
5578 (void *)&cmd_pfc_set_set,
5579 (void *)&cmd_pfc_set_flow_ctrl,
5580 (void *)&cmd_pfc_set_rx,
5581 (void *)&cmd_pfc_set_rx_mode,
5582 (void *)&cmd_pfc_set_tx,
5583 (void *)&cmd_pfc_set_tx_mode,
5584 (void *)&cmd_pfc_set_high_water,
5585 (void *)&cmd_pfc_set_low_water,
5586 (void *)&cmd_pfc_set_pause_time,
5587 (void *)&cmd_pfc_set_priority,
5588 (void *)&cmd_pfc_set_portid,
5593 /* *** RESET CONFIGURATION *** */
5594 struct cmd_reset_result {
5595 cmdline_fixed_string_t reset;
5596 cmdline_fixed_string_t def;
5599 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5601 __attribute__((unused)) void *data)
5603 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5604 set_def_fwd_config();
5607 cmdline_parse_token_string_t cmd_reset_set =
5608 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5609 cmdline_parse_token_string_t cmd_reset_def =
5610 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5613 cmdline_parse_inst_t cmd_reset = {
5614 .f = cmd_reset_parsed,
5616 .help_str = "set default: Reset default forwarding configuration",
5618 (void *)&cmd_reset_set,
5619 (void *)&cmd_reset_def,
5624 /* *** START FORWARDING *** */
5625 struct cmd_start_result {
5626 cmdline_fixed_string_t start;
5629 cmdline_parse_token_string_t cmd_start_start =
5630 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5632 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5633 __attribute__((unused)) struct cmdline *cl,
5634 __attribute__((unused)) void *data)
5636 start_packet_forwarding(0);
5639 cmdline_parse_inst_t cmd_start = {
5640 .f = cmd_start_parsed,
5642 .help_str = "start: Start packet forwarding",
5644 (void *)&cmd_start_start,
5649 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5650 struct cmd_start_tx_first_result {
5651 cmdline_fixed_string_t start;
5652 cmdline_fixed_string_t tx_first;
5656 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5657 __attribute__((unused)) struct cmdline *cl,
5658 __attribute__((unused)) void *data)
5660 start_packet_forwarding(1);
5663 cmdline_parse_token_string_t cmd_start_tx_first_start =
5664 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5666 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5667 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5668 tx_first, "tx_first");
5670 cmdline_parse_inst_t cmd_start_tx_first = {
5671 .f = cmd_start_tx_first_parsed,
5673 .help_str = "start tx_first: Start packet forwarding, "
5674 "after sending 1 burst of packets",
5676 (void *)&cmd_start_tx_first_start,
5677 (void *)&cmd_start_tx_first_tx_first,
5682 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5683 struct cmd_start_tx_first_n_result {
5684 cmdline_fixed_string_t start;
5685 cmdline_fixed_string_t tx_first;
5690 cmd_start_tx_first_n_parsed(void *parsed_result,
5691 __attribute__((unused)) struct cmdline *cl,
5692 __attribute__((unused)) void *data)
5694 struct cmd_start_tx_first_n_result *res = parsed_result;
5696 start_packet_forwarding(res->tx_num);
5699 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5700 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5702 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5703 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5704 tx_first, "tx_first");
5705 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5706 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5709 cmdline_parse_inst_t cmd_start_tx_first_n = {
5710 .f = cmd_start_tx_first_n_parsed,
5712 .help_str = "start tx_first <num>: "
5713 "packet forwarding, after sending <num> bursts of packets",
5715 (void *)&cmd_start_tx_first_n_start,
5716 (void *)&cmd_start_tx_first_n_tx_first,
5717 (void *)&cmd_start_tx_first_n_tx_num,
5722 /* *** SET LINK UP *** */
5723 struct cmd_set_link_up_result {
5724 cmdline_fixed_string_t set;
5725 cmdline_fixed_string_t link_up;
5726 cmdline_fixed_string_t port;
5730 cmdline_parse_token_string_t cmd_set_link_up_set =
5731 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5732 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5733 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5735 cmdline_parse_token_string_t cmd_set_link_up_port =
5736 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5737 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5738 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5740 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5741 __attribute__((unused)) struct cmdline *cl,
5742 __attribute__((unused)) void *data)
5744 struct cmd_set_link_up_result *res = parsed_result;
5745 dev_set_link_up(res->port_id);
5748 cmdline_parse_inst_t cmd_set_link_up = {
5749 .f = cmd_set_link_up_parsed,
5751 .help_str = "set link-up port <port id>",
5753 (void *)&cmd_set_link_up_set,
5754 (void *)&cmd_set_link_up_link_up,
5755 (void *)&cmd_set_link_up_port,
5756 (void *)&cmd_set_link_up_port_id,
5761 /* *** SET LINK DOWN *** */
5762 struct cmd_set_link_down_result {
5763 cmdline_fixed_string_t set;
5764 cmdline_fixed_string_t link_down;
5765 cmdline_fixed_string_t port;
5769 cmdline_parse_token_string_t cmd_set_link_down_set =
5770 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5771 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5772 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5774 cmdline_parse_token_string_t cmd_set_link_down_port =
5775 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5776 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5777 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5779 static void cmd_set_link_down_parsed(
5780 __attribute__((unused)) void *parsed_result,
5781 __attribute__((unused)) struct cmdline *cl,
5782 __attribute__((unused)) void *data)
5784 struct cmd_set_link_down_result *res = parsed_result;
5785 dev_set_link_down(res->port_id);
5788 cmdline_parse_inst_t cmd_set_link_down = {
5789 .f = cmd_set_link_down_parsed,
5791 .help_str = "set link-down port <port id>",
5793 (void *)&cmd_set_link_down_set,
5794 (void *)&cmd_set_link_down_link_down,
5795 (void *)&cmd_set_link_down_port,
5796 (void *)&cmd_set_link_down_port_id,
5801 /* *** SHOW CFG *** */
5802 struct cmd_showcfg_result {
5803 cmdline_fixed_string_t show;
5804 cmdline_fixed_string_t cfg;
5805 cmdline_fixed_string_t what;
5808 static void cmd_showcfg_parsed(void *parsed_result,
5809 __attribute__((unused)) struct cmdline *cl,
5810 __attribute__((unused)) void *data)
5812 struct cmd_showcfg_result *res = parsed_result;
5813 if (!strcmp(res->what, "rxtx"))
5814 rxtx_config_display();
5815 else if (!strcmp(res->what, "cores"))
5816 fwd_lcores_config_display();
5817 else if (!strcmp(res->what, "fwd"))
5818 pkt_fwd_config_display(&cur_fwd_config);
5819 else if (!strcmp(res->what, "txpkts"))
5820 show_tx_pkt_segments();
5823 cmdline_parse_token_string_t cmd_showcfg_show =
5824 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5825 cmdline_parse_token_string_t cmd_showcfg_port =
5826 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5827 cmdline_parse_token_string_t cmd_showcfg_what =
5828 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5829 "rxtx#cores#fwd#txpkts");
5831 cmdline_parse_inst_t cmd_showcfg = {
5832 .f = cmd_showcfg_parsed,
5834 .help_str = "show config rxtx|cores|fwd|txpkts",
5836 (void *)&cmd_showcfg_show,
5837 (void *)&cmd_showcfg_port,
5838 (void *)&cmd_showcfg_what,
5843 /* *** SHOW ALL PORT INFO *** */
5844 struct cmd_showportall_result {
5845 cmdline_fixed_string_t show;
5846 cmdline_fixed_string_t port;
5847 cmdline_fixed_string_t what;
5848 cmdline_fixed_string_t all;
5851 static void cmd_showportall_parsed(void *parsed_result,
5852 __attribute__((unused)) struct cmdline *cl,
5853 __attribute__((unused)) void *data)
5857 struct cmd_showportall_result *res = parsed_result;
5858 if (!strcmp(res->show, "clear")) {
5859 if (!strcmp(res->what, "stats"))
5860 RTE_ETH_FOREACH_DEV(i)
5862 else if (!strcmp(res->what, "xstats"))
5863 RTE_ETH_FOREACH_DEV(i)
5864 nic_xstats_clear(i);
5865 } else if (!strcmp(res->what, "info"))
5866 RTE_ETH_FOREACH_DEV(i)
5867 port_infos_display(i);
5868 else if (!strcmp(res->what, "stats"))
5869 RTE_ETH_FOREACH_DEV(i)
5870 nic_stats_display(i);
5871 else if (!strcmp(res->what, "xstats"))
5872 RTE_ETH_FOREACH_DEV(i)
5873 nic_xstats_display(i);
5874 else if (!strcmp(res->what, "fdir"))
5875 RTE_ETH_FOREACH_DEV(i)
5877 else if (!strcmp(res->what, "stat_qmap"))
5878 RTE_ETH_FOREACH_DEV(i)
5879 nic_stats_mapping_display(i);
5880 else if (!strcmp(res->what, "dcb_tc"))
5881 RTE_ETH_FOREACH_DEV(i)
5882 port_dcb_info_display(i);
5883 else if (!strcmp(res->what, "cap"))
5884 RTE_ETH_FOREACH_DEV(i)
5885 port_offload_cap_display(i);
5888 cmdline_parse_token_string_t cmd_showportall_show =
5889 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5891 cmdline_parse_token_string_t cmd_showportall_port =
5892 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5893 cmdline_parse_token_string_t cmd_showportall_what =
5894 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5895 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5896 cmdline_parse_token_string_t cmd_showportall_all =
5897 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5898 cmdline_parse_inst_t cmd_showportall = {
5899 .f = cmd_showportall_parsed,
5901 .help_str = "show|clear port "
5902 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5904 (void *)&cmd_showportall_show,
5905 (void *)&cmd_showportall_port,
5906 (void *)&cmd_showportall_what,
5907 (void *)&cmd_showportall_all,
5912 /* *** SHOW PORT INFO *** */
5913 struct cmd_showport_result {
5914 cmdline_fixed_string_t show;
5915 cmdline_fixed_string_t port;
5916 cmdline_fixed_string_t what;
5920 static void cmd_showport_parsed(void *parsed_result,
5921 __attribute__((unused)) struct cmdline *cl,
5922 __attribute__((unused)) void *data)
5924 struct cmd_showport_result *res = parsed_result;
5925 if (!strcmp(res->show, "clear")) {
5926 if (!strcmp(res->what, "stats"))
5927 nic_stats_clear(res->portnum);
5928 else if (!strcmp(res->what, "xstats"))
5929 nic_xstats_clear(res->portnum);
5930 } else if (!strcmp(res->what, "info"))
5931 port_infos_display(res->portnum);
5932 else if (!strcmp(res->what, "stats"))
5933 nic_stats_display(res->portnum);
5934 else if (!strcmp(res->what, "xstats"))
5935 nic_xstats_display(res->portnum);
5936 else if (!strcmp(res->what, "fdir"))
5937 fdir_get_infos(res->portnum);
5938 else if (!strcmp(res->what, "stat_qmap"))
5939 nic_stats_mapping_display(res->portnum);
5940 else if (!strcmp(res->what, "dcb_tc"))
5941 port_dcb_info_display(res->portnum);
5942 else if (!strcmp(res->what, "cap"))
5943 port_offload_cap_display(res->portnum);
5946 cmdline_parse_token_string_t cmd_showport_show =
5947 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5949 cmdline_parse_token_string_t cmd_showport_port =
5950 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5951 cmdline_parse_token_string_t cmd_showport_what =
5952 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5953 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5954 cmdline_parse_token_num_t cmd_showport_portnum =
5955 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5957 cmdline_parse_inst_t cmd_showport = {
5958 .f = cmd_showport_parsed,
5960 .help_str = "show|clear port "
5961 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5964 (void *)&cmd_showport_show,
5965 (void *)&cmd_showport_port,
5966 (void *)&cmd_showport_what,
5967 (void *)&cmd_showport_portnum,
5972 /* *** SHOW QUEUE INFO *** */
5973 struct cmd_showqueue_result {
5974 cmdline_fixed_string_t show;
5975 cmdline_fixed_string_t type;
5976 cmdline_fixed_string_t what;
5982 cmd_showqueue_parsed(void *parsed_result,
5983 __attribute__((unused)) struct cmdline *cl,
5984 __attribute__((unused)) void *data)
5986 struct cmd_showqueue_result *res = parsed_result;
5988 if (!strcmp(res->type, "rxq"))
5989 rx_queue_infos_display(res->portnum, res->queuenum);
5990 else if (!strcmp(res->type, "txq"))
5991 tx_queue_infos_display(res->portnum, res->queuenum);
5994 cmdline_parse_token_string_t cmd_showqueue_show =
5995 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5996 cmdline_parse_token_string_t cmd_showqueue_type =
5997 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5998 cmdline_parse_token_string_t cmd_showqueue_what =
5999 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6000 cmdline_parse_token_num_t cmd_showqueue_portnum =
6001 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6002 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6003 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6005 cmdline_parse_inst_t cmd_showqueue = {
6006 .f = cmd_showqueue_parsed,
6008 .help_str = "show rxq|txq info <port_id> <queue_id>",
6010 (void *)&cmd_showqueue_show,
6011 (void *)&cmd_showqueue_type,
6012 (void *)&cmd_showqueue_what,
6013 (void *)&cmd_showqueue_portnum,
6014 (void *)&cmd_showqueue_queuenum,
6019 /* *** READ PORT REGISTER *** */
6020 struct cmd_read_reg_result {
6021 cmdline_fixed_string_t read;
6022 cmdline_fixed_string_t reg;
6028 cmd_read_reg_parsed(void *parsed_result,
6029 __attribute__((unused)) struct cmdline *cl,
6030 __attribute__((unused)) void *data)
6032 struct cmd_read_reg_result *res = parsed_result;
6033 port_reg_display(res->port_id, res->reg_off);
6036 cmdline_parse_token_string_t cmd_read_reg_read =
6037 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6038 cmdline_parse_token_string_t cmd_read_reg_reg =
6039 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6040 cmdline_parse_token_num_t cmd_read_reg_port_id =
6041 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6042 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6043 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6045 cmdline_parse_inst_t cmd_read_reg = {
6046 .f = cmd_read_reg_parsed,
6048 .help_str = "read reg <port_id> <reg_off>",
6050 (void *)&cmd_read_reg_read,
6051 (void *)&cmd_read_reg_reg,
6052 (void *)&cmd_read_reg_port_id,
6053 (void *)&cmd_read_reg_reg_off,
6058 /* *** READ PORT REGISTER BIT FIELD *** */
6059 struct cmd_read_reg_bit_field_result {
6060 cmdline_fixed_string_t read;
6061 cmdline_fixed_string_t regfield;
6069 cmd_read_reg_bit_field_parsed(void *parsed_result,
6070 __attribute__((unused)) struct cmdline *cl,
6071 __attribute__((unused)) void *data)
6073 struct cmd_read_reg_bit_field_result *res = parsed_result;
6074 port_reg_bit_field_display(res->port_id, res->reg_off,
6075 res->bit1_pos, res->bit2_pos);
6078 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6079 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6081 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6082 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6083 regfield, "regfield");
6084 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6085 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6087 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6088 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6090 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6091 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6093 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6094 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6097 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6098 .f = cmd_read_reg_bit_field_parsed,
6100 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6101 "Read register bit field between bit_x and bit_y included",
6103 (void *)&cmd_read_reg_bit_field_read,
6104 (void *)&cmd_read_reg_bit_field_regfield,
6105 (void *)&cmd_read_reg_bit_field_port_id,
6106 (void *)&cmd_read_reg_bit_field_reg_off,
6107 (void *)&cmd_read_reg_bit_field_bit1_pos,
6108 (void *)&cmd_read_reg_bit_field_bit2_pos,
6113 /* *** READ PORT REGISTER BIT *** */
6114 struct cmd_read_reg_bit_result {
6115 cmdline_fixed_string_t read;
6116 cmdline_fixed_string_t regbit;
6123 cmd_read_reg_bit_parsed(void *parsed_result,
6124 __attribute__((unused)) struct cmdline *cl,
6125 __attribute__((unused)) void *data)
6127 struct cmd_read_reg_bit_result *res = parsed_result;
6128 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6131 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6132 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6133 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6134 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6136 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6137 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6138 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6139 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6140 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6141 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6143 cmdline_parse_inst_t cmd_read_reg_bit = {
6144 .f = cmd_read_reg_bit_parsed,
6146 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6148 (void *)&cmd_read_reg_bit_read,
6149 (void *)&cmd_read_reg_bit_regbit,
6150 (void *)&cmd_read_reg_bit_port_id,
6151 (void *)&cmd_read_reg_bit_reg_off,
6152 (void *)&cmd_read_reg_bit_bit_pos,
6157 /* *** WRITE PORT REGISTER *** */
6158 struct cmd_write_reg_result {
6159 cmdline_fixed_string_t write;
6160 cmdline_fixed_string_t reg;
6167 cmd_write_reg_parsed(void *parsed_result,
6168 __attribute__((unused)) struct cmdline *cl,
6169 __attribute__((unused)) void *data)
6171 struct cmd_write_reg_result *res = parsed_result;
6172 port_reg_set(res->port_id, res->reg_off, res->value);
6175 cmdline_parse_token_string_t cmd_write_reg_write =
6176 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6177 cmdline_parse_token_string_t cmd_write_reg_reg =
6178 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6179 cmdline_parse_token_num_t cmd_write_reg_port_id =
6180 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6181 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6182 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6183 cmdline_parse_token_num_t cmd_write_reg_value =
6184 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6186 cmdline_parse_inst_t cmd_write_reg = {
6187 .f = cmd_write_reg_parsed,
6189 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6191 (void *)&cmd_write_reg_write,
6192 (void *)&cmd_write_reg_reg,
6193 (void *)&cmd_write_reg_port_id,
6194 (void *)&cmd_write_reg_reg_off,
6195 (void *)&cmd_write_reg_value,
6200 /* *** WRITE PORT REGISTER BIT FIELD *** */
6201 struct cmd_write_reg_bit_field_result {
6202 cmdline_fixed_string_t write;
6203 cmdline_fixed_string_t regfield;
6212 cmd_write_reg_bit_field_parsed(void *parsed_result,
6213 __attribute__((unused)) struct cmdline *cl,
6214 __attribute__((unused)) void *data)
6216 struct cmd_write_reg_bit_field_result *res = parsed_result;
6217 port_reg_bit_field_set(res->port_id, res->reg_off,
6218 res->bit1_pos, res->bit2_pos, res->value);
6221 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6222 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6224 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6225 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6226 regfield, "regfield");
6227 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6228 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6230 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6231 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6233 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6234 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6236 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6237 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6239 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6240 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6243 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6244 .f = cmd_write_reg_bit_field_parsed,
6246 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6248 "Set register bit field between bit_x and bit_y included",
6250 (void *)&cmd_write_reg_bit_field_write,
6251 (void *)&cmd_write_reg_bit_field_regfield,
6252 (void *)&cmd_write_reg_bit_field_port_id,
6253 (void *)&cmd_write_reg_bit_field_reg_off,
6254 (void *)&cmd_write_reg_bit_field_bit1_pos,
6255 (void *)&cmd_write_reg_bit_field_bit2_pos,
6256 (void *)&cmd_write_reg_bit_field_value,
6261 /* *** WRITE PORT REGISTER BIT *** */
6262 struct cmd_write_reg_bit_result {
6263 cmdline_fixed_string_t write;
6264 cmdline_fixed_string_t regbit;
6272 cmd_write_reg_bit_parsed(void *parsed_result,
6273 __attribute__((unused)) struct cmdline *cl,
6274 __attribute__((unused)) void *data)
6276 struct cmd_write_reg_bit_result *res = parsed_result;
6277 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6280 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6281 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6283 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6284 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6286 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6287 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6288 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6289 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6290 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6291 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6292 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6293 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6295 cmdline_parse_inst_t cmd_write_reg_bit = {
6296 .f = cmd_write_reg_bit_parsed,
6298 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6301 (void *)&cmd_write_reg_bit_write,
6302 (void *)&cmd_write_reg_bit_regbit,
6303 (void *)&cmd_write_reg_bit_port_id,
6304 (void *)&cmd_write_reg_bit_reg_off,
6305 (void *)&cmd_write_reg_bit_bit_pos,
6306 (void *)&cmd_write_reg_bit_value,
6311 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6312 struct cmd_read_rxd_txd_result {
6313 cmdline_fixed_string_t read;
6314 cmdline_fixed_string_t rxd_txd;
6321 cmd_read_rxd_txd_parsed(void *parsed_result,
6322 __attribute__((unused)) struct cmdline *cl,
6323 __attribute__((unused)) void *data)
6325 struct cmd_read_rxd_txd_result *res = parsed_result;
6327 if (!strcmp(res->rxd_txd, "rxd"))
6328 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6329 else if (!strcmp(res->rxd_txd, "txd"))
6330 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6333 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6334 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6335 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6336 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6338 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6339 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6340 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6341 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6342 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6343 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6345 cmdline_parse_inst_t cmd_read_rxd_txd = {
6346 .f = cmd_read_rxd_txd_parsed,
6348 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6350 (void *)&cmd_read_rxd_txd_read,
6351 (void *)&cmd_read_rxd_txd_rxd_txd,
6352 (void *)&cmd_read_rxd_txd_port_id,
6353 (void *)&cmd_read_rxd_txd_queue_id,
6354 (void *)&cmd_read_rxd_txd_desc_id,
6360 struct cmd_quit_result {
6361 cmdline_fixed_string_t quit;
6364 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6366 __attribute__((unused)) void *data)
6372 cmdline_parse_token_string_t cmd_quit_quit =
6373 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6375 cmdline_parse_inst_t cmd_quit = {
6376 .f = cmd_quit_parsed,
6378 .help_str = "quit: Exit application",
6380 (void *)&cmd_quit_quit,
6385 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6386 struct cmd_mac_addr_result {
6387 cmdline_fixed_string_t mac_addr_cmd;
6388 cmdline_fixed_string_t what;
6390 struct ether_addr address;
6393 static void cmd_mac_addr_parsed(void *parsed_result,
6394 __attribute__((unused)) struct cmdline *cl,
6395 __attribute__((unused)) void *data)
6397 struct cmd_mac_addr_result *res = parsed_result;
6400 if (strcmp(res->what, "add") == 0)
6401 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6402 else if (strcmp(res->what, "set") == 0)
6403 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6406 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6408 /* check the return value and print it if is < 0 */
6410 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6414 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6415 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6417 cmdline_parse_token_string_t cmd_mac_addr_what =
6418 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6420 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6421 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6422 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6423 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6425 cmdline_parse_inst_t cmd_mac_addr = {
6426 .f = cmd_mac_addr_parsed,
6428 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6429 "Add/Remove/Set MAC address on port_id",
6431 (void *)&cmd_mac_addr_cmd,
6432 (void *)&cmd_mac_addr_what,
6433 (void *)&cmd_mac_addr_portnum,
6434 (void *)&cmd_mac_addr_addr,
6440 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6441 struct cmd_set_qmap_result {
6442 cmdline_fixed_string_t set;
6443 cmdline_fixed_string_t qmap;
6444 cmdline_fixed_string_t what;
6451 cmd_set_qmap_parsed(void *parsed_result,
6452 __attribute__((unused)) struct cmdline *cl,
6453 __attribute__((unused)) void *data)
6455 struct cmd_set_qmap_result *res = parsed_result;
6456 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6458 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6461 cmdline_parse_token_string_t cmd_setqmap_set =
6462 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6464 cmdline_parse_token_string_t cmd_setqmap_qmap =
6465 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6467 cmdline_parse_token_string_t cmd_setqmap_what =
6468 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6470 cmdline_parse_token_num_t cmd_setqmap_portid =
6471 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6473 cmdline_parse_token_num_t cmd_setqmap_queueid =
6474 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6476 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6477 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6480 cmdline_parse_inst_t cmd_set_qmap = {
6481 .f = cmd_set_qmap_parsed,
6483 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6484 "Set statistics mapping value on tx|rx queue_id of port_id",
6486 (void *)&cmd_setqmap_set,
6487 (void *)&cmd_setqmap_qmap,
6488 (void *)&cmd_setqmap_what,
6489 (void *)&cmd_setqmap_portid,
6490 (void *)&cmd_setqmap_queueid,
6491 (void *)&cmd_setqmap_mapvalue,
6496 /* *** CONFIGURE UNICAST HASH TABLE *** */
6497 struct cmd_set_uc_hash_table {
6498 cmdline_fixed_string_t set;
6499 cmdline_fixed_string_t port;
6501 cmdline_fixed_string_t what;
6502 struct ether_addr address;
6503 cmdline_fixed_string_t mode;
6507 cmd_set_uc_hash_parsed(void *parsed_result,
6508 __attribute__((unused)) struct cmdline *cl,
6509 __attribute__((unused)) void *data)
6512 struct cmd_set_uc_hash_table *res = parsed_result;
6514 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6516 if (strcmp(res->what, "uta") == 0)
6517 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6518 &res->address,(uint8_t)is_on);
6520 printf("bad unicast hash table parameter, return code = %d \n", ret);
6524 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6525 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6527 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6530 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6531 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6533 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6534 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6536 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6537 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6539 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6543 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6544 .f = cmd_set_uc_hash_parsed,
6546 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6548 (void *)&cmd_set_uc_hash_set,
6549 (void *)&cmd_set_uc_hash_port,
6550 (void *)&cmd_set_uc_hash_portid,
6551 (void *)&cmd_set_uc_hash_what,
6552 (void *)&cmd_set_uc_hash_mac,
6553 (void *)&cmd_set_uc_hash_mode,
6558 struct cmd_set_uc_all_hash_table {
6559 cmdline_fixed_string_t set;
6560 cmdline_fixed_string_t port;
6562 cmdline_fixed_string_t what;
6563 cmdline_fixed_string_t value;
6564 cmdline_fixed_string_t mode;
6568 cmd_set_uc_all_hash_parsed(void *parsed_result,
6569 __attribute__((unused)) struct cmdline *cl,
6570 __attribute__((unused)) void *data)
6573 struct cmd_set_uc_all_hash_table *res = parsed_result;
6575 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6577 if ((strcmp(res->what, "uta") == 0) &&
6578 (strcmp(res->value, "all") == 0))
6579 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6581 printf("bad unicast hash table parameter,"
6582 "return code = %d \n", ret);
6585 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6586 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6588 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6589 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6591 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6592 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6594 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6595 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6597 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6598 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6600 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6601 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6604 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6605 .f = cmd_set_uc_all_hash_parsed,
6607 .help_str = "set port <port_id> uta all on|off",
6609 (void *)&cmd_set_uc_all_hash_set,
6610 (void *)&cmd_set_uc_all_hash_port,
6611 (void *)&cmd_set_uc_all_hash_portid,
6612 (void *)&cmd_set_uc_all_hash_what,
6613 (void *)&cmd_set_uc_all_hash_value,
6614 (void *)&cmd_set_uc_all_hash_mode,
6619 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6620 struct cmd_set_vf_macvlan_filter {
6621 cmdline_fixed_string_t set;
6622 cmdline_fixed_string_t port;
6624 cmdline_fixed_string_t vf;
6626 struct ether_addr address;
6627 cmdline_fixed_string_t filter_type;
6628 cmdline_fixed_string_t mode;
6632 cmd_set_vf_macvlan_parsed(void *parsed_result,
6633 __attribute__((unused)) struct cmdline *cl,
6634 __attribute__((unused)) void *data)
6637 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6638 struct rte_eth_mac_filter filter;
6640 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6642 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6644 /* set VF MAC filter */
6648 filter.dst_id = res->vf_id;
6650 if (!strcmp(res->filter_type, "exact-mac"))
6651 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6652 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6653 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6654 else if (!strcmp(res->filter_type, "hashmac"))
6655 filter.filter_type = RTE_MAC_HASH_MATCH;
6656 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6657 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6659 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6662 ret = rte_eth_dev_filter_ctrl(res->port_id,
6663 RTE_ETH_FILTER_MACVLAN,
6667 ret = rte_eth_dev_filter_ctrl(res->port_id,
6668 RTE_ETH_FILTER_MACVLAN,
6669 RTE_ETH_FILTER_DELETE,
6673 printf("bad set MAC hash parameter, return code = %d\n", ret);
6677 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6678 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6680 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6681 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6683 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6684 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6686 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6687 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6689 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6690 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6692 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6693 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6695 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6696 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6697 filter_type, "exact-mac#exact-mac-vlan"
6698 "#hashmac#hashmac-vlan");
6699 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6700 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6703 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6704 .f = cmd_set_vf_macvlan_parsed,
6706 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6707 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6708 "Exact match rule: exact match of MAC or MAC and VLAN; "
6709 "hash match rule: hash match of MAC and exact match of VLAN",
6711 (void *)&cmd_set_vf_macvlan_set,
6712 (void *)&cmd_set_vf_macvlan_port,
6713 (void *)&cmd_set_vf_macvlan_portid,
6714 (void *)&cmd_set_vf_macvlan_vf,
6715 (void *)&cmd_set_vf_macvlan_vf_id,
6716 (void *)&cmd_set_vf_macvlan_mac,
6717 (void *)&cmd_set_vf_macvlan_filter_type,
6718 (void *)&cmd_set_vf_macvlan_mode,
6723 #ifdef RTE_LIBRTE_IXGBE_PMD
6724 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6725 struct cmd_set_vf_traffic {
6726 cmdline_fixed_string_t set;
6727 cmdline_fixed_string_t port;
6729 cmdline_fixed_string_t vf;
6731 cmdline_fixed_string_t what;
6732 cmdline_fixed_string_t mode;
6736 cmd_set_vf_traffic_parsed(void *parsed_result,
6737 __attribute__((unused)) struct cmdline *cl,
6738 __attribute__((unused)) void *data)
6740 struct cmd_set_vf_traffic *res = parsed_result;
6741 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6742 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6744 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6747 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6748 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6750 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6751 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6753 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6754 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6756 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6757 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6759 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6760 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6762 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6763 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6765 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6766 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6769 cmdline_parse_inst_t cmd_set_vf_traffic = {
6770 .f = cmd_set_vf_traffic_parsed,
6772 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6774 (void *)&cmd_setvf_traffic_set,
6775 (void *)&cmd_setvf_traffic_port,
6776 (void *)&cmd_setvf_traffic_portid,
6777 (void *)&cmd_setvf_traffic_vf,
6778 (void *)&cmd_setvf_traffic_vfid,
6779 (void *)&cmd_setvf_traffic_what,
6780 (void *)&cmd_setvf_traffic_mode,
6785 /* *** CONFIGURE VF RECEIVE MODE *** */
6786 struct cmd_set_vf_rxmode {
6787 cmdline_fixed_string_t set;
6788 cmdline_fixed_string_t port;
6790 cmdline_fixed_string_t vf;
6792 cmdline_fixed_string_t what;
6793 cmdline_fixed_string_t mode;
6794 cmdline_fixed_string_t on;
6798 cmd_set_vf_rxmode_parsed(void *parsed_result,
6799 __attribute__((unused)) struct cmdline *cl,
6800 __attribute__((unused)) void *data)
6803 uint16_t rx_mode = 0;
6804 struct cmd_set_vf_rxmode *res = parsed_result;
6806 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6807 if (!strcmp(res->what,"rxmode")) {
6808 if (!strcmp(res->mode, "AUPE"))
6809 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6810 else if (!strcmp(res->mode, "ROPE"))
6811 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6812 else if (!strcmp(res->mode, "BAM"))
6813 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6814 else if (!strncmp(res->mode, "MPE",3))
6815 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6818 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6820 printf("bad VF receive mode parameter, return code = %d \n",
6824 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6825 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6827 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6828 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6830 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6831 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6833 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6834 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6836 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6837 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6839 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6840 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6842 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6843 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6844 mode, "AUPE#ROPE#BAM#MPE");
6845 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6846 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6849 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6850 .f = cmd_set_vf_rxmode_parsed,
6852 .help_str = "set port <port_id> vf <vf_id> rxmode "
6853 "AUPE|ROPE|BAM|MPE on|off",
6855 (void *)&cmd_set_vf_rxmode_set,
6856 (void *)&cmd_set_vf_rxmode_port,
6857 (void *)&cmd_set_vf_rxmode_portid,
6858 (void *)&cmd_set_vf_rxmode_vf,
6859 (void *)&cmd_set_vf_rxmode_vfid,
6860 (void *)&cmd_set_vf_rxmode_what,
6861 (void *)&cmd_set_vf_rxmode_mode,
6862 (void *)&cmd_set_vf_rxmode_on,
6868 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6869 struct cmd_vf_mac_addr_result {
6870 cmdline_fixed_string_t mac_addr_cmd;
6871 cmdline_fixed_string_t what;
6872 cmdline_fixed_string_t port;
6874 cmdline_fixed_string_t vf;
6876 struct ether_addr address;
6879 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6880 __attribute__((unused)) struct cmdline *cl,
6881 __attribute__((unused)) void *data)
6883 struct cmd_vf_mac_addr_result *res = parsed_result;
6886 if (strcmp(res->what, "add") == 0)
6887 ret = rte_eth_dev_mac_addr_add(res->port_num,
6888 &res->address, res->vf_num);
6890 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6894 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6895 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6896 mac_addr_cmd,"mac_addr");
6897 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6898 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6900 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6901 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6903 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6904 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6906 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6907 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6909 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6910 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6912 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6913 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6916 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6917 .f = cmd_vf_mac_addr_parsed,
6919 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6920 "Add MAC address filtering for a VF on port_id",
6922 (void *)&cmd_vf_mac_addr_cmd,
6923 (void *)&cmd_vf_mac_addr_what,
6924 (void *)&cmd_vf_mac_addr_port,
6925 (void *)&cmd_vf_mac_addr_portnum,
6926 (void *)&cmd_vf_mac_addr_vf,
6927 (void *)&cmd_vf_mac_addr_vfnum,
6928 (void *)&cmd_vf_mac_addr_addr,
6933 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6934 struct cmd_vf_rx_vlan_filter {
6935 cmdline_fixed_string_t rx_vlan;
6936 cmdline_fixed_string_t what;
6938 cmdline_fixed_string_t port;
6940 cmdline_fixed_string_t vf;
6945 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6946 __attribute__((unused)) struct cmdline *cl,
6947 __attribute__((unused)) void *data)
6949 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6952 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6954 #ifdef RTE_LIBRTE_IXGBE_PMD
6955 if (ret == -ENOTSUP)
6956 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6957 res->vlan_id, res->vf_mask, is_add);
6959 #ifdef RTE_LIBRTE_I40E_PMD
6960 if (ret == -ENOTSUP)
6961 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6962 res->vlan_id, res->vf_mask, is_add);
6969 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6970 res->vlan_id, res->vf_mask);
6973 printf("invalid port_id %d\n", res->port_id);
6976 printf("function not implemented or supported\n");
6979 printf("programming error: (%s)\n", strerror(-ret));
6983 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6984 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6985 rx_vlan, "rx_vlan");
6986 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6987 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6989 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6990 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6992 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6993 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6995 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6996 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6998 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6999 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7001 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7002 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7005 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7006 .f = cmd_vf_rx_vlan_filter_parsed,
7008 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7009 "(vf_mask = hexadecimal VF mask)",
7011 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7012 (void *)&cmd_vf_rx_vlan_filter_what,
7013 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7014 (void *)&cmd_vf_rx_vlan_filter_port,
7015 (void *)&cmd_vf_rx_vlan_filter_portid,
7016 (void *)&cmd_vf_rx_vlan_filter_vf,
7017 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7022 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7023 struct cmd_queue_rate_limit_result {
7024 cmdline_fixed_string_t set;
7025 cmdline_fixed_string_t port;
7027 cmdline_fixed_string_t queue;
7029 cmdline_fixed_string_t rate;
7033 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7034 __attribute__((unused)) struct cmdline *cl,
7035 __attribute__((unused)) void *data)
7037 struct cmd_queue_rate_limit_result *res = parsed_result;
7040 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7041 && (strcmp(res->queue, "queue") == 0)
7042 && (strcmp(res->rate, "rate") == 0))
7043 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7046 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7050 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7051 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7053 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7054 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7056 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7057 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7059 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7060 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7062 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7063 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7065 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7066 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7068 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7069 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7072 cmdline_parse_inst_t cmd_queue_rate_limit = {
7073 .f = cmd_queue_rate_limit_parsed,
7075 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7076 "Set rate limit for a queue on port_id",
7078 (void *)&cmd_queue_rate_limit_set,
7079 (void *)&cmd_queue_rate_limit_port,
7080 (void *)&cmd_queue_rate_limit_portnum,
7081 (void *)&cmd_queue_rate_limit_queue,
7082 (void *)&cmd_queue_rate_limit_queuenum,
7083 (void *)&cmd_queue_rate_limit_rate,
7084 (void *)&cmd_queue_rate_limit_ratenum,
7089 #ifdef RTE_LIBRTE_IXGBE_PMD
7090 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7091 struct cmd_vf_rate_limit_result {
7092 cmdline_fixed_string_t set;
7093 cmdline_fixed_string_t port;
7095 cmdline_fixed_string_t vf;
7097 cmdline_fixed_string_t rate;
7099 cmdline_fixed_string_t q_msk;
7103 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7104 __attribute__((unused)) struct cmdline *cl,
7105 __attribute__((unused)) void *data)
7107 struct cmd_vf_rate_limit_result *res = parsed_result;
7110 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7111 && (strcmp(res->vf, "vf") == 0)
7112 && (strcmp(res->rate, "rate") == 0)
7113 && (strcmp(res->q_msk, "queue_mask") == 0))
7114 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7115 res->rate_num, res->q_msk_val);
7117 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7121 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7122 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7124 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7125 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7127 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7128 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7130 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7131 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7133 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7134 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7136 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7137 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7139 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7140 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7142 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7143 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7144 q_msk, "queue_mask");
7145 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7146 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7149 cmdline_parse_inst_t cmd_vf_rate_limit = {
7150 .f = cmd_vf_rate_limit_parsed,
7152 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7153 "queue_mask <queue_mask_value>: "
7154 "Set rate limit for queues of VF on port_id",
7156 (void *)&cmd_vf_rate_limit_set,
7157 (void *)&cmd_vf_rate_limit_port,
7158 (void *)&cmd_vf_rate_limit_portnum,
7159 (void *)&cmd_vf_rate_limit_vf,
7160 (void *)&cmd_vf_rate_limit_vfnum,
7161 (void *)&cmd_vf_rate_limit_rate,
7162 (void *)&cmd_vf_rate_limit_ratenum,
7163 (void *)&cmd_vf_rate_limit_q_msk,
7164 (void *)&cmd_vf_rate_limit_q_msk_val,
7170 /* *** ADD TUNNEL FILTER OF A PORT *** */
7171 struct cmd_tunnel_filter_result {
7172 cmdline_fixed_string_t cmd;
7173 cmdline_fixed_string_t what;
7175 struct ether_addr outer_mac;
7176 struct ether_addr inner_mac;
7177 cmdline_ipaddr_t ip_value;
7178 uint16_t inner_vlan;
7179 cmdline_fixed_string_t tunnel_type;
7180 cmdline_fixed_string_t filter_type;
7186 cmd_tunnel_filter_parsed(void *parsed_result,
7187 __attribute__((unused)) struct cmdline *cl,
7188 __attribute__((unused)) void *data)
7190 struct cmd_tunnel_filter_result *res = parsed_result;
7191 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7194 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7196 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7197 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7198 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7200 if (res->ip_value.family == AF_INET) {
7201 tunnel_filter_conf.ip_addr.ipv4_addr =
7202 res->ip_value.addr.ipv4.s_addr;
7203 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7205 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7206 &(res->ip_value.addr.ipv6),
7207 sizeof(struct in6_addr));
7208 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7211 if (!strcmp(res->filter_type, "imac-ivlan"))
7212 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7213 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7214 tunnel_filter_conf.filter_type =
7215 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7216 else if (!strcmp(res->filter_type, "imac-tenid"))
7217 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7218 else if (!strcmp(res->filter_type, "imac"))
7219 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7220 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7221 tunnel_filter_conf.filter_type =
7222 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7223 else if (!strcmp(res->filter_type, "oip"))
7224 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7225 else if (!strcmp(res->filter_type, "iip"))
7226 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7228 printf("The filter type is not supported");
7232 if (!strcmp(res->tunnel_type, "vxlan"))
7233 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7234 else if (!strcmp(res->tunnel_type, "nvgre"))
7235 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7236 else if (!strcmp(res->tunnel_type, "ipingre"))
7237 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7239 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7243 tunnel_filter_conf.tenant_id = res->tenant_id;
7244 tunnel_filter_conf.queue_id = res->queue_num;
7245 if (!strcmp(res->what, "add"))
7246 ret = rte_eth_dev_filter_ctrl(res->port_id,
7247 RTE_ETH_FILTER_TUNNEL,
7249 &tunnel_filter_conf);
7251 ret = rte_eth_dev_filter_ctrl(res->port_id,
7252 RTE_ETH_FILTER_TUNNEL,
7253 RTE_ETH_FILTER_DELETE,
7254 &tunnel_filter_conf);
7256 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7260 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7261 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7262 cmd, "tunnel_filter");
7263 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7264 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7266 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7267 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7269 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7270 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7272 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7273 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7275 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7276 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7277 inner_vlan, UINT16);
7278 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7279 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7281 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7282 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7283 tunnel_type, "vxlan#nvgre#ipingre");
7285 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7286 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7287 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7288 "imac#omac-imac-tenid");
7289 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7290 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7292 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7293 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7296 cmdline_parse_inst_t cmd_tunnel_filter = {
7297 .f = cmd_tunnel_filter_parsed,
7299 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7300 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7301 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7302 "<queue_id>: Add/Rm tunnel filter of a port",
7304 (void *)&cmd_tunnel_filter_cmd,
7305 (void *)&cmd_tunnel_filter_what,
7306 (void *)&cmd_tunnel_filter_port_id,
7307 (void *)&cmd_tunnel_filter_outer_mac,
7308 (void *)&cmd_tunnel_filter_inner_mac,
7309 (void *)&cmd_tunnel_filter_ip_value,
7310 (void *)&cmd_tunnel_filter_innner_vlan,
7311 (void *)&cmd_tunnel_filter_tunnel_type,
7312 (void *)&cmd_tunnel_filter_filter_type,
7313 (void *)&cmd_tunnel_filter_tenant_id,
7314 (void *)&cmd_tunnel_filter_queue_num,
7319 /* *** CONFIGURE TUNNEL UDP PORT *** */
7320 struct cmd_tunnel_udp_config {
7321 cmdline_fixed_string_t cmd;
7322 cmdline_fixed_string_t what;
7328 cmd_tunnel_udp_config_parsed(void *parsed_result,
7329 __attribute__((unused)) struct cmdline *cl,
7330 __attribute__((unused)) void *data)
7332 struct cmd_tunnel_udp_config *res = parsed_result;
7333 struct rte_eth_udp_tunnel tunnel_udp;
7336 tunnel_udp.udp_port = res->udp_port;
7338 if (!strcmp(res->cmd, "rx_vxlan_port"))
7339 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7341 if (!strcmp(res->what, "add"))
7342 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7345 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7349 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7352 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7353 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7354 cmd, "rx_vxlan_port");
7355 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7356 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7358 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7359 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7361 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7362 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7365 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7366 .f = cmd_tunnel_udp_config_parsed,
7368 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7369 "Add/Remove a tunneling UDP port filter",
7371 (void *)&cmd_tunnel_udp_config_cmd,
7372 (void *)&cmd_tunnel_udp_config_what,
7373 (void *)&cmd_tunnel_udp_config_udp_port,
7374 (void *)&cmd_tunnel_udp_config_port_id,
7379 /* *** GLOBAL CONFIG *** */
7380 struct cmd_global_config_result {
7381 cmdline_fixed_string_t cmd;
7383 cmdline_fixed_string_t cfg_type;
7388 cmd_global_config_parsed(void *parsed_result,
7389 __attribute__((unused)) struct cmdline *cl,
7390 __attribute__((unused)) void *data)
7392 struct cmd_global_config_result *res = parsed_result;
7393 struct rte_eth_global_cfg conf;
7396 memset(&conf, 0, sizeof(conf));
7397 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7398 conf.cfg.gre_key_len = res->len;
7399 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7400 RTE_ETH_FILTER_SET, &conf);
7402 printf("Global config error\n");
7405 cmdline_parse_token_string_t cmd_global_config_cmd =
7406 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7408 cmdline_parse_token_num_t cmd_global_config_port_id =
7409 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7410 cmdline_parse_token_string_t cmd_global_config_type =
7411 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7412 cfg_type, "gre-key-len");
7413 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7414 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7417 cmdline_parse_inst_t cmd_global_config = {
7418 .f = cmd_global_config_parsed,
7419 .data = (void *)NULL,
7420 .help_str = "global_config <port_id> gre-key-len <key_len>",
7422 (void *)&cmd_global_config_cmd,
7423 (void *)&cmd_global_config_port_id,
7424 (void *)&cmd_global_config_type,
7425 (void *)&cmd_global_config_gre_key_len,
7430 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7431 struct cmd_set_mirror_mask_result {
7432 cmdline_fixed_string_t set;
7433 cmdline_fixed_string_t port;
7435 cmdline_fixed_string_t mirror;
7437 cmdline_fixed_string_t what;
7438 cmdline_fixed_string_t value;
7439 cmdline_fixed_string_t dstpool;
7441 cmdline_fixed_string_t on;
7444 cmdline_parse_token_string_t cmd_mirror_mask_set =
7445 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7447 cmdline_parse_token_string_t cmd_mirror_mask_port =
7448 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7450 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7451 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7453 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7454 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7455 mirror, "mirror-rule");
7456 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7457 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7459 cmdline_parse_token_string_t cmd_mirror_mask_what =
7460 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7461 what, "pool-mirror-up#pool-mirror-down"
7463 cmdline_parse_token_string_t cmd_mirror_mask_value =
7464 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7466 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7467 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7468 dstpool, "dst-pool");
7469 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7470 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7472 cmdline_parse_token_string_t cmd_mirror_mask_on =
7473 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7477 cmd_set_mirror_mask_parsed(void *parsed_result,
7478 __attribute__((unused)) struct cmdline *cl,
7479 __attribute__((unused)) void *data)
7482 struct cmd_set_mirror_mask_result *res = parsed_result;
7483 struct rte_eth_mirror_conf mr_conf;
7485 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7487 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7489 mr_conf.dst_pool = res->dstpool_id;
7491 if (!strcmp(res->what, "pool-mirror-up")) {
7492 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7493 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7494 } else if (!strcmp(res->what, "pool-mirror-down")) {
7495 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7496 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7497 } else if (!strcmp(res->what, "vlan-mirror")) {
7498 mr_conf.rule_type = ETH_MIRROR_VLAN;
7499 nb_item = parse_item_list(res->value, "vlan",
7500 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7504 for (i = 0; i < nb_item; i++) {
7505 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7506 printf("Invalid vlan_id: must be < 4096\n");
7510 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7511 mr_conf.vlan.vlan_mask |= 1ULL << i;
7515 if (!strcmp(res->on, "on"))
7516 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7519 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7522 printf("mirror rule add error: (%s)\n", strerror(-ret));
7525 cmdline_parse_inst_t cmd_set_mirror_mask = {
7526 .f = cmd_set_mirror_mask_parsed,
7528 .help_str = "set port <port_id> mirror-rule <rule_id> "
7529 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7530 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7532 (void *)&cmd_mirror_mask_set,
7533 (void *)&cmd_mirror_mask_port,
7534 (void *)&cmd_mirror_mask_portid,
7535 (void *)&cmd_mirror_mask_mirror,
7536 (void *)&cmd_mirror_mask_ruleid,
7537 (void *)&cmd_mirror_mask_what,
7538 (void *)&cmd_mirror_mask_value,
7539 (void *)&cmd_mirror_mask_dstpool,
7540 (void *)&cmd_mirror_mask_poolid,
7541 (void *)&cmd_mirror_mask_on,
7546 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7547 struct cmd_set_mirror_link_result {
7548 cmdline_fixed_string_t set;
7549 cmdline_fixed_string_t port;
7551 cmdline_fixed_string_t mirror;
7553 cmdline_fixed_string_t what;
7554 cmdline_fixed_string_t dstpool;
7556 cmdline_fixed_string_t on;
7559 cmdline_parse_token_string_t cmd_mirror_link_set =
7560 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7562 cmdline_parse_token_string_t cmd_mirror_link_port =
7563 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7565 cmdline_parse_token_num_t cmd_mirror_link_portid =
7566 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7568 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7569 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7570 mirror, "mirror-rule");
7571 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7572 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7574 cmdline_parse_token_string_t cmd_mirror_link_what =
7575 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7576 what, "uplink-mirror#downlink-mirror");
7577 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7578 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7579 dstpool, "dst-pool");
7580 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7581 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7583 cmdline_parse_token_string_t cmd_mirror_link_on =
7584 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7588 cmd_set_mirror_link_parsed(void *parsed_result,
7589 __attribute__((unused)) struct cmdline *cl,
7590 __attribute__((unused)) void *data)
7593 struct cmd_set_mirror_link_result *res = parsed_result;
7594 struct rte_eth_mirror_conf mr_conf;
7596 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7597 if (!strcmp(res->what, "uplink-mirror"))
7598 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7600 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7602 mr_conf.dst_pool = res->dstpool_id;
7604 if (!strcmp(res->on, "on"))
7605 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7608 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7611 /* check the return value and print it if is < 0 */
7613 printf("mirror rule add error: (%s)\n", strerror(-ret));
7617 cmdline_parse_inst_t cmd_set_mirror_link = {
7618 .f = cmd_set_mirror_link_parsed,
7620 .help_str = "set port <port_id> mirror-rule <rule_id> "
7621 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7623 (void *)&cmd_mirror_link_set,
7624 (void *)&cmd_mirror_link_port,
7625 (void *)&cmd_mirror_link_portid,
7626 (void *)&cmd_mirror_link_mirror,
7627 (void *)&cmd_mirror_link_ruleid,
7628 (void *)&cmd_mirror_link_what,
7629 (void *)&cmd_mirror_link_dstpool,
7630 (void *)&cmd_mirror_link_poolid,
7631 (void *)&cmd_mirror_link_on,
7636 /* *** RESET VM MIRROR RULE *** */
7637 struct cmd_rm_mirror_rule_result {
7638 cmdline_fixed_string_t reset;
7639 cmdline_fixed_string_t port;
7641 cmdline_fixed_string_t mirror;
7645 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7646 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7648 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7649 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7651 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7652 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7654 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7655 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7656 mirror, "mirror-rule");
7657 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7658 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7662 cmd_reset_mirror_rule_parsed(void *parsed_result,
7663 __attribute__((unused)) struct cmdline *cl,
7664 __attribute__((unused)) void *data)
7667 struct cmd_set_mirror_link_result *res = parsed_result;
7669 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7671 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7674 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7675 .f = cmd_reset_mirror_rule_parsed,
7677 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7679 (void *)&cmd_rm_mirror_rule_reset,
7680 (void *)&cmd_rm_mirror_rule_port,
7681 (void *)&cmd_rm_mirror_rule_portid,
7682 (void *)&cmd_rm_mirror_rule_mirror,
7683 (void *)&cmd_rm_mirror_rule_ruleid,
7688 /* ******************************************************************************** */
7690 struct cmd_dump_result {
7691 cmdline_fixed_string_t dump;
7695 dump_struct_sizes(void)
7697 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7698 DUMP_SIZE(struct rte_mbuf);
7699 DUMP_SIZE(struct rte_mempool);
7700 DUMP_SIZE(struct rte_ring);
7704 static void cmd_dump_parsed(void *parsed_result,
7705 __attribute__((unused)) struct cmdline *cl,
7706 __attribute__((unused)) void *data)
7708 struct cmd_dump_result *res = parsed_result;
7710 if (!strcmp(res->dump, "dump_physmem"))
7711 rte_dump_physmem_layout(stdout);
7712 else if (!strcmp(res->dump, "dump_memzone"))
7713 rte_memzone_dump(stdout);
7714 else if (!strcmp(res->dump, "dump_struct_sizes"))
7715 dump_struct_sizes();
7716 else if (!strcmp(res->dump, "dump_ring"))
7717 rte_ring_list_dump(stdout);
7718 else if (!strcmp(res->dump, "dump_mempool"))
7719 rte_mempool_list_dump(stdout);
7720 else if (!strcmp(res->dump, "dump_devargs"))
7721 rte_eal_devargs_dump(stdout);
7722 else if (!strcmp(res->dump, "dump_log_types"))
7723 rte_log_dump(stdout);
7726 cmdline_parse_token_string_t cmd_dump_dump =
7727 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7730 "dump_struct_sizes#"
7736 cmdline_parse_inst_t cmd_dump = {
7737 .f = cmd_dump_parsed, /* function to call */
7738 .data = NULL, /* 2nd arg of func */
7739 .help_str = "Dump status",
7740 .tokens = { /* token list, NULL terminated */
7741 (void *)&cmd_dump_dump,
7746 /* ******************************************************************************** */
7748 struct cmd_dump_one_result {
7749 cmdline_fixed_string_t dump;
7750 cmdline_fixed_string_t name;
7753 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7754 __attribute__((unused)) void *data)
7756 struct cmd_dump_one_result *res = parsed_result;
7758 if (!strcmp(res->dump, "dump_ring")) {
7760 r = rte_ring_lookup(res->name);
7762 cmdline_printf(cl, "Cannot find ring\n");
7765 rte_ring_dump(stdout, r);
7766 } else if (!strcmp(res->dump, "dump_mempool")) {
7767 struct rte_mempool *mp;
7768 mp = rte_mempool_lookup(res->name);
7770 cmdline_printf(cl, "Cannot find mempool\n");
7773 rte_mempool_dump(stdout, mp);
7777 cmdline_parse_token_string_t cmd_dump_one_dump =
7778 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7779 "dump_ring#dump_mempool");
7781 cmdline_parse_token_string_t cmd_dump_one_name =
7782 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7784 cmdline_parse_inst_t cmd_dump_one = {
7785 .f = cmd_dump_one_parsed, /* function to call */
7786 .data = NULL, /* 2nd arg of func */
7787 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7788 .tokens = { /* token list, NULL terminated */
7789 (void *)&cmd_dump_one_dump,
7790 (void *)&cmd_dump_one_name,
7795 /* *** Add/Del syn filter *** */
7796 struct cmd_syn_filter_result {
7797 cmdline_fixed_string_t filter;
7799 cmdline_fixed_string_t ops;
7800 cmdline_fixed_string_t priority;
7801 cmdline_fixed_string_t high;
7802 cmdline_fixed_string_t queue;
7807 cmd_syn_filter_parsed(void *parsed_result,
7808 __attribute__((unused)) struct cmdline *cl,
7809 __attribute__((unused)) void *data)
7811 struct cmd_syn_filter_result *res = parsed_result;
7812 struct rte_eth_syn_filter syn_filter;
7815 ret = rte_eth_dev_filter_supported(res->port_id,
7816 RTE_ETH_FILTER_SYN);
7818 printf("syn filter is not supported on port %u.\n",
7823 memset(&syn_filter, 0, sizeof(syn_filter));
7825 if (!strcmp(res->ops, "add")) {
7826 if (!strcmp(res->high, "high"))
7827 syn_filter.hig_pri = 1;
7829 syn_filter.hig_pri = 0;
7831 syn_filter.queue = res->queue_id;
7832 ret = rte_eth_dev_filter_ctrl(res->port_id,
7837 ret = rte_eth_dev_filter_ctrl(res->port_id,
7839 RTE_ETH_FILTER_DELETE,
7843 printf("syn filter programming error: (%s)\n",
7847 cmdline_parse_token_string_t cmd_syn_filter_filter =
7848 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7849 filter, "syn_filter");
7850 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7851 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7853 cmdline_parse_token_string_t cmd_syn_filter_ops =
7854 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7856 cmdline_parse_token_string_t cmd_syn_filter_priority =
7857 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7858 priority, "priority");
7859 cmdline_parse_token_string_t cmd_syn_filter_high =
7860 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7862 cmdline_parse_token_string_t cmd_syn_filter_queue =
7863 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7865 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7866 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7869 cmdline_parse_inst_t cmd_syn_filter = {
7870 .f = cmd_syn_filter_parsed,
7872 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7873 "<queue_id>: Add/Delete syn filter",
7875 (void *)&cmd_syn_filter_filter,
7876 (void *)&cmd_syn_filter_port_id,
7877 (void *)&cmd_syn_filter_ops,
7878 (void *)&cmd_syn_filter_priority,
7879 (void *)&cmd_syn_filter_high,
7880 (void *)&cmd_syn_filter_queue,
7881 (void *)&cmd_syn_filter_queue_id,
7886 /* *** ADD/REMOVE A 2tuple FILTER *** */
7887 struct cmd_2tuple_filter_result {
7888 cmdline_fixed_string_t filter;
7890 cmdline_fixed_string_t ops;
7891 cmdline_fixed_string_t dst_port;
7892 uint16_t dst_port_value;
7893 cmdline_fixed_string_t protocol;
7894 uint8_t protocol_value;
7895 cmdline_fixed_string_t mask;
7897 cmdline_fixed_string_t tcp_flags;
7898 uint8_t tcp_flags_value;
7899 cmdline_fixed_string_t priority;
7900 uint8_t priority_value;
7901 cmdline_fixed_string_t queue;
7906 cmd_2tuple_filter_parsed(void *parsed_result,
7907 __attribute__((unused)) struct cmdline *cl,
7908 __attribute__((unused)) void *data)
7910 struct rte_eth_ntuple_filter filter;
7911 struct cmd_2tuple_filter_result *res = parsed_result;
7914 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7916 printf("ntuple filter is not supported on port %u.\n",
7921 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7923 filter.flags = RTE_2TUPLE_FLAGS;
7924 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7925 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7926 filter.proto = res->protocol_value;
7927 filter.priority = res->priority_value;
7928 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7929 printf("nonzero tcp_flags is only meaningful"
7930 " when protocol is TCP.\n");
7933 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7934 printf("invalid TCP flags.\n");
7938 if (res->tcp_flags_value != 0) {
7939 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7940 filter.tcp_flags = res->tcp_flags_value;
7943 /* need convert to big endian. */
7944 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7945 filter.queue = res->queue_id;
7947 if (!strcmp(res->ops, "add"))
7948 ret = rte_eth_dev_filter_ctrl(res->port_id,
7949 RTE_ETH_FILTER_NTUPLE,
7953 ret = rte_eth_dev_filter_ctrl(res->port_id,
7954 RTE_ETH_FILTER_NTUPLE,
7955 RTE_ETH_FILTER_DELETE,
7958 printf("2tuple filter programming error: (%s)\n",
7963 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7964 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7965 filter, "2tuple_filter");
7966 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7967 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7969 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7970 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7972 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7973 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7974 dst_port, "dst_port");
7975 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7976 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7977 dst_port_value, UINT16);
7978 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7979 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7980 protocol, "protocol");
7981 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7982 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7983 protocol_value, UINT8);
7984 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7985 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7987 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7988 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7990 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7991 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7992 tcp_flags, "tcp_flags");
7993 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7994 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7995 tcp_flags_value, UINT8);
7996 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7997 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7998 priority, "priority");
7999 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8000 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8001 priority_value, UINT8);
8002 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8003 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8005 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8006 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8009 cmdline_parse_inst_t cmd_2tuple_filter = {
8010 .f = cmd_2tuple_filter_parsed,
8012 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8013 "<value> mask <value> tcp_flags <value> priority <value> queue "
8014 "<queue_id>: Add a 2tuple filter",
8016 (void *)&cmd_2tuple_filter_filter,
8017 (void *)&cmd_2tuple_filter_port_id,
8018 (void *)&cmd_2tuple_filter_ops,
8019 (void *)&cmd_2tuple_filter_dst_port,
8020 (void *)&cmd_2tuple_filter_dst_port_value,
8021 (void *)&cmd_2tuple_filter_protocol,
8022 (void *)&cmd_2tuple_filter_protocol_value,
8023 (void *)&cmd_2tuple_filter_mask,
8024 (void *)&cmd_2tuple_filter_mask_value,
8025 (void *)&cmd_2tuple_filter_tcp_flags,
8026 (void *)&cmd_2tuple_filter_tcp_flags_value,
8027 (void *)&cmd_2tuple_filter_priority,
8028 (void *)&cmd_2tuple_filter_priority_value,
8029 (void *)&cmd_2tuple_filter_queue,
8030 (void *)&cmd_2tuple_filter_queue_id,
8035 /* *** ADD/REMOVE A 5tuple FILTER *** */
8036 struct cmd_5tuple_filter_result {
8037 cmdline_fixed_string_t filter;
8039 cmdline_fixed_string_t ops;
8040 cmdline_fixed_string_t dst_ip;
8041 cmdline_ipaddr_t dst_ip_value;
8042 cmdline_fixed_string_t src_ip;
8043 cmdline_ipaddr_t src_ip_value;
8044 cmdline_fixed_string_t dst_port;
8045 uint16_t dst_port_value;
8046 cmdline_fixed_string_t src_port;
8047 uint16_t src_port_value;
8048 cmdline_fixed_string_t protocol;
8049 uint8_t protocol_value;
8050 cmdline_fixed_string_t mask;
8052 cmdline_fixed_string_t tcp_flags;
8053 uint8_t tcp_flags_value;
8054 cmdline_fixed_string_t priority;
8055 uint8_t priority_value;
8056 cmdline_fixed_string_t queue;
8061 cmd_5tuple_filter_parsed(void *parsed_result,
8062 __attribute__((unused)) struct cmdline *cl,
8063 __attribute__((unused)) void *data)
8065 struct rte_eth_ntuple_filter filter;
8066 struct cmd_5tuple_filter_result *res = parsed_result;
8069 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8071 printf("ntuple filter is not supported on port %u.\n",
8076 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8078 filter.flags = RTE_5TUPLE_FLAGS;
8079 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8080 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8081 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8082 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8083 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8084 filter.proto = res->protocol_value;
8085 filter.priority = res->priority_value;
8086 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8087 printf("nonzero tcp_flags is only meaningful"
8088 " when protocol is TCP.\n");
8091 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8092 printf("invalid TCP flags.\n");
8096 if (res->tcp_flags_value != 0) {
8097 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8098 filter.tcp_flags = res->tcp_flags_value;
8101 if (res->dst_ip_value.family == AF_INET)
8102 /* no need to convert, already big endian. */
8103 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8105 if (filter.dst_ip_mask == 0) {
8106 printf("can not support ipv6 involved compare.\n");
8112 if (res->src_ip_value.family == AF_INET)
8113 /* no need to convert, already big endian. */
8114 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8116 if (filter.src_ip_mask == 0) {
8117 printf("can not support ipv6 involved compare.\n");
8122 /* need convert to big endian. */
8123 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8124 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8125 filter.queue = res->queue_id;
8127 if (!strcmp(res->ops, "add"))
8128 ret = rte_eth_dev_filter_ctrl(res->port_id,
8129 RTE_ETH_FILTER_NTUPLE,
8133 ret = rte_eth_dev_filter_ctrl(res->port_id,
8134 RTE_ETH_FILTER_NTUPLE,
8135 RTE_ETH_FILTER_DELETE,
8138 printf("5tuple filter programming error: (%s)\n",
8142 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8143 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8144 filter, "5tuple_filter");
8145 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8146 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8148 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8149 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8151 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8152 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8154 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8155 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8157 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8158 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8160 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8161 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8163 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8164 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8165 dst_port, "dst_port");
8166 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8167 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8168 dst_port_value, UINT16);
8169 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8170 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8171 src_port, "src_port");
8172 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8173 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8174 src_port_value, UINT16);
8175 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8176 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8177 protocol, "protocol");
8178 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8179 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8180 protocol_value, UINT8);
8181 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8182 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8184 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8185 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8187 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8188 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8189 tcp_flags, "tcp_flags");
8190 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8191 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8192 tcp_flags_value, UINT8);
8193 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8194 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8195 priority, "priority");
8196 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8197 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8198 priority_value, UINT8);
8199 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8200 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8202 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8203 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8206 cmdline_parse_inst_t cmd_5tuple_filter = {
8207 .f = cmd_5tuple_filter_parsed,
8209 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8210 "src_ip <value> dst_port <value> src_port <value> "
8211 "protocol <value> mask <value> tcp_flags <value> "
8212 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8214 (void *)&cmd_5tuple_filter_filter,
8215 (void *)&cmd_5tuple_filter_port_id,
8216 (void *)&cmd_5tuple_filter_ops,
8217 (void *)&cmd_5tuple_filter_dst_ip,
8218 (void *)&cmd_5tuple_filter_dst_ip_value,
8219 (void *)&cmd_5tuple_filter_src_ip,
8220 (void *)&cmd_5tuple_filter_src_ip_value,
8221 (void *)&cmd_5tuple_filter_dst_port,
8222 (void *)&cmd_5tuple_filter_dst_port_value,
8223 (void *)&cmd_5tuple_filter_src_port,
8224 (void *)&cmd_5tuple_filter_src_port_value,
8225 (void *)&cmd_5tuple_filter_protocol,
8226 (void *)&cmd_5tuple_filter_protocol_value,
8227 (void *)&cmd_5tuple_filter_mask,
8228 (void *)&cmd_5tuple_filter_mask_value,
8229 (void *)&cmd_5tuple_filter_tcp_flags,
8230 (void *)&cmd_5tuple_filter_tcp_flags_value,
8231 (void *)&cmd_5tuple_filter_priority,
8232 (void *)&cmd_5tuple_filter_priority_value,
8233 (void *)&cmd_5tuple_filter_queue,
8234 (void *)&cmd_5tuple_filter_queue_id,
8239 /* *** ADD/REMOVE A flex FILTER *** */
8240 struct cmd_flex_filter_result {
8241 cmdline_fixed_string_t filter;
8242 cmdline_fixed_string_t ops;
8244 cmdline_fixed_string_t len;
8246 cmdline_fixed_string_t bytes;
8247 cmdline_fixed_string_t bytes_value;
8248 cmdline_fixed_string_t mask;
8249 cmdline_fixed_string_t mask_value;
8250 cmdline_fixed_string_t priority;
8251 uint8_t priority_value;
8252 cmdline_fixed_string_t queue;
8256 static int xdigit2val(unsigned char c)
8261 else if (isupper(c))
8269 cmd_flex_filter_parsed(void *parsed_result,
8270 __attribute__((unused)) struct cmdline *cl,
8271 __attribute__((unused)) void *data)
8274 struct rte_eth_flex_filter filter;
8275 struct cmd_flex_filter_result *res = parsed_result;
8276 char *bytes_ptr, *mask_ptr;
8277 uint16_t len, i, j = 0;
8282 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8283 printf("the len exceed the max length 128\n");
8286 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8287 filter.len = res->len_value;
8288 filter.priority = res->priority_value;
8289 filter.queue = res->queue_id;
8290 bytes_ptr = res->bytes_value;
8291 mask_ptr = res->mask_value;
8293 /* translate bytes string to array. */
8294 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8295 (bytes_ptr[1] == 'X')))
8297 len = strnlen(bytes_ptr, res->len_value * 2);
8298 if (len == 0 || (len % 8 != 0)) {
8299 printf("please check len and bytes input\n");
8302 for (i = 0; i < len; i++) {
8304 if (isxdigit(c) == 0) {
8305 /* invalid characters. */
8306 printf("invalid input\n");
8309 val = xdigit2val(c);
8312 filter.bytes[j] = byte;
8313 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8320 /* translate mask string to uint8_t array. */
8321 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8322 (mask_ptr[1] == 'X')))
8324 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8326 printf("invalid input\n");
8331 for (i = 0; i < len; i++) {
8333 if (isxdigit(c) == 0) {
8334 /* invalid characters. */
8335 printf("invalid input\n");
8338 val = xdigit2val(c);
8341 filter.mask[j] = byte;
8342 printf("mask[%d]:%02x ", j, filter.mask[j]);
8350 if (!strcmp(res->ops, "add"))
8351 ret = rte_eth_dev_filter_ctrl(res->port_id,
8352 RTE_ETH_FILTER_FLEXIBLE,
8356 ret = rte_eth_dev_filter_ctrl(res->port_id,
8357 RTE_ETH_FILTER_FLEXIBLE,
8358 RTE_ETH_FILTER_DELETE,
8362 printf("flex filter setting error: (%s)\n", strerror(-ret));
8365 cmdline_parse_token_string_t cmd_flex_filter_filter =
8366 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8367 filter, "flex_filter");
8368 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8369 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8371 cmdline_parse_token_string_t cmd_flex_filter_ops =
8372 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8374 cmdline_parse_token_string_t cmd_flex_filter_len =
8375 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8377 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8378 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8380 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8381 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8383 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8384 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8386 cmdline_parse_token_string_t cmd_flex_filter_mask =
8387 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8389 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8390 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8392 cmdline_parse_token_string_t cmd_flex_filter_priority =
8393 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8394 priority, "priority");
8395 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8396 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8397 priority_value, UINT8);
8398 cmdline_parse_token_string_t cmd_flex_filter_queue =
8399 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8401 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8402 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8404 cmdline_parse_inst_t cmd_flex_filter = {
8405 .f = cmd_flex_filter_parsed,
8407 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8408 "<value> mask <value> priority <value> queue <queue_id>: "
8409 "Add/Del a flex filter",
8411 (void *)&cmd_flex_filter_filter,
8412 (void *)&cmd_flex_filter_port_id,
8413 (void *)&cmd_flex_filter_ops,
8414 (void *)&cmd_flex_filter_len,
8415 (void *)&cmd_flex_filter_len_value,
8416 (void *)&cmd_flex_filter_bytes,
8417 (void *)&cmd_flex_filter_bytes_value,
8418 (void *)&cmd_flex_filter_mask,
8419 (void *)&cmd_flex_filter_mask_value,
8420 (void *)&cmd_flex_filter_priority,
8421 (void *)&cmd_flex_filter_priority_value,
8422 (void *)&cmd_flex_filter_queue,
8423 (void *)&cmd_flex_filter_queue_id,
8428 /* *** Filters Control *** */
8430 /* *** deal with ethertype filter *** */
8431 struct cmd_ethertype_filter_result {
8432 cmdline_fixed_string_t filter;
8434 cmdline_fixed_string_t ops;
8435 cmdline_fixed_string_t mac;
8436 struct ether_addr mac_addr;
8437 cmdline_fixed_string_t ethertype;
8438 uint16_t ethertype_value;
8439 cmdline_fixed_string_t drop;
8440 cmdline_fixed_string_t queue;
8444 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8445 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8446 filter, "ethertype_filter");
8447 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8448 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8450 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8451 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8453 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8454 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8455 mac, "mac_addr#mac_ignr");
8456 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8457 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8459 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8460 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8461 ethertype, "ethertype");
8462 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8463 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8464 ethertype_value, UINT16);
8465 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8466 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8468 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8469 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8471 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8472 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8476 cmd_ethertype_filter_parsed(void *parsed_result,
8477 __attribute__((unused)) struct cmdline *cl,
8478 __attribute__((unused)) void *data)
8480 struct cmd_ethertype_filter_result *res = parsed_result;
8481 struct rte_eth_ethertype_filter filter;
8484 ret = rte_eth_dev_filter_supported(res->port_id,
8485 RTE_ETH_FILTER_ETHERTYPE);
8487 printf("ethertype filter is not supported on port %u.\n",
8492 memset(&filter, 0, sizeof(filter));
8493 if (!strcmp(res->mac, "mac_addr")) {
8494 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8495 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8496 sizeof(struct ether_addr));
8498 if (!strcmp(res->drop, "drop"))
8499 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8500 filter.ether_type = res->ethertype_value;
8501 filter.queue = res->queue_id;
8503 if (!strcmp(res->ops, "add"))
8504 ret = rte_eth_dev_filter_ctrl(res->port_id,
8505 RTE_ETH_FILTER_ETHERTYPE,
8509 ret = rte_eth_dev_filter_ctrl(res->port_id,
8510 RTE_ETH_FILTER_ETHERTYPE,
8511 RTE_ETH_FILTER_DELETE,
8514 printf("ethertype filter programming error: (%s)\n",
8518 cmdline_parse_inst_t cmd_ethertype_filter = {
8519 .f = cmd_ethertype_filter_parsed,
8521 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8522 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8523 "Add or delete an ethertype filter entry",
8525 (void *)&cmd_ethertype_filter_filter,
8526 (void *)&cmd_ethertype_filter_port_id,
8527 (void *)&cmd_ethertype_filter_ops,
8528 (void *)&cmd_ethertype_filter_mac,
8529 (void *)&cmd_ethertype_filter_mac_addr,
8530 (void *)&cmd_ethertype_filter_ethertype,
8531 (void *)&cmd_ethertype_filter_ethertype_value,
8532 (void *)&cmd_ethertype_filter_drop,
8533 (void *)&cmd_ethertype_filter_queue,
8534 (void *)&cmd_ethertype_filter_queue_id,
8539 /* *** deal with flow director filter *** */
8540 struct cmd_flow_director_result {
8541 cmdline_fixed_string_t flow_director_filter;
8543 cmdline_fixed_string_t mode;
8544 cmdline_fixed_string_t mode_value;
8545 cmdline_fixed_string_t ops;
8546 cmdline_fixed_string_t flow;
8547 cmdline_fixed_string_t flow_type;
8548 cmdline_fixed_string_t ether;
8549 uint16_t ether_type;
8550 cmdline_fixed_string_t src;
8551 cmdline_ipaddr_t ip_src;
8553 cmdline_fixed_string_t dst;
8554 cmdline_ipaddr_t ip_dst;
8556 cmdline_fixed_string_t verify_tag;
8557 uint32_t verify_tag_value;
8558 cmdline_ipaddr_t tos;
8560 cmdline_ipaddr_t proto;
8561 uint8_t proto_value;
8562 cmdline_ipaddr_t ttl;
8564 cmdline_fixed_string_t vlan;
8565 uint16_t vlan_value;
8566 cmdline_fixed_string_t flexbytes;
8567 cmdline_fixed_string_t flexbytes_value;
8568 cmdline_fixed_string_t pf_vf;
8569 cmdline_fixed_string_t drop;
8570 cmdline_fixed_string_t queue;
8572 cmdline_fixed_string_t fd_id;
8573 uint32_t fd_id_value;
8574 cmdline_fixed_string_t mac;
8575 struct ether_addr mac_addr;
8576 cmdline_fixed_string_t tunnel;
8577 cmdline_fixed_string_t tunnel_type;
8578 cmdline_fixed_string_t tunnel_id;
8579 uint32_t tunnel_id_value;
8583 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8586 const char *p, *p0 = q_arg;
8588 unsigned long int_fld;
8589 char *str_fld[max_num];
8594 p = strchr(p0, '(');
8598 p0 = strchr(p, ')');
8603 if (size >= sizeof(s))
8606 snprintf(s, sizeof(s), "%.*s", size, p);
8607 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8608 if (ret < 0 || ret > max_num)
8610 for (i = 0; i < ret; i++) {
8612 int_fld = strtoul(str_fld[i], &end, 0);
8613 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8615 flexbytes[i] = (uint8_t)int_fld;
8621 str2flowtype(char *string)
8624 static const struct {
8627 } flowtype_str[] = {
8628 {"raw", RTE_ETH_FLOW_RAW},
8629 {"ipv4", RTE_ETH_FLOW_IPV4},
8630 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8631 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8632 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8633 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8634 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8635 {"ipv6", RTE_ETH_FLOW_IPV6},
8636 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8637 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8638 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8639 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8640 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8641 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8644 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8645 if (!strcmp(flowtype_str[i].str, string))
8646 return flowtype_str[i].type;
8648 return RTE_ETH_FLOW_UNKNOWN;
8651 static enum rte_eth_fdir_tunnel_type
8652 str2fdir_tunneltype(char *string)
8656 static const struct {
8658 enum rte_eth_fdir_tunnel_type type;
8659 } tunneltype_str[] = {
8660 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8661 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8664 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8665 if (!strcmp(tunneltype_str[i].str, string))
8666 return tunneltype_str[i].type;
8668 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8671 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8673 if ((ip_addr).family == AF_INET) \
8674 (ip) = (ip_addr).addr.ipv4.s_addr; \
8676 printf("invalid parameter.\n"); \
8681 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8683 if ((ip_addr).family == AF_INET6) \
8684 (void)rte_memcpy(&(ip), \
8685 &((ip_addr).addr.ipv6), \
8686 sizeof(struct in6_addr)); \
8688 printf("invalid parameter.\n"); \
8694 cmd_flow_director_filter_parsed(void *parsed_result,
8695 __attribute__((unused)) struct cmdline *cl,
8696 __attribute__((unused)) void *data)
8698 struct cmd_flow_director_result *res = parsed_result;
8699 struct rte_eth_fdir_filter entry;
8700 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8702 unsigned long vf_id;
8705 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8707 printf("flow director is not supported on port %u.\n",
8711 memset(flexbytes, 0, sizeof(flexbytes));
8712 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8714 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8715 if (strcmp(res->mode_value, "MAC-VLAN")) {
8716 printf("Please set mode to MAC-VLAN.\n");
8719 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8720 if (strcmp(res->mode_value, "Tunnel")) {
8721 printf("Please set mode to Tunnel.\n");
8725 if (strcmp(res->mode_value, "IP")) {
8726 printf("Please set mode to IP.\n");
8729 entry.input.flow_type = str2flowtype(res->flow_type);
8732 ret = parse_flexbytes(res->flexbytes_value,
8734 RTE_ETH_FDIR_MAX_FLEXLEN);
8736 printf("error: Cannot parse flexbytes input.\n");
8740 switch (entry.input.flow_type) {
8741 case RTE_ETH_FLOW_FRAG_IPV4:
8742 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8743 entry.input.flow.ip4_flow.proto = res->proto_value;
8745 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8746 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8747 IPV4_ADDR_TO_UINT(res->ip_dst,
8748 entry.input.flow.ip4_flow.dst_ip);
8749 IPV4_ADDR_TO_UINT(res->ip_src,
8750 entry.input.flow.ip4_flow.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.udp4_flow.dst_port =
8755 rte_cpu_to_be_16(res->port_dst);
8756 entry.input.flow.udp4_flow.src_port =
8757 rte_cpu_to_be_16(res->port_src);
8759 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8760 IPV4_ADDR_TO_UINT(res->ip_dst,
8761 entry.input.flow.sctp4_flow.ip.dst_ip);
8762 IPV4_ADDR_TO_UINT(res->ip_src,
8763 entry.input.flow.sctp4_flow.ip.src_ip);
8764 entry.input.flow.ip4_flow.tos = res->tos_value;
8765 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8766 /* need convert to big endian. */
8767 entry.input.flow.sctp4_flow.dst_port =
8768 rte_cpu_to_be_16(res->port_dst);
8769 entry.input.flow.sctp4_flow.src_port =
8770 rte_cpu_to_be_16(res->port_src);
8771 entry.input.flow.sctp4_flow.verify_tag =
8772 rte_cpu_to_be_32(res->verify_tag_value);
8774 case RTE_ETH_FLOW_FRAG_IPV6:
8775 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8776 entry.input.flow.ipv6_flow.proto = res->proto_value;
8778 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8779 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8780 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8781 entry.input.flow.ipv6_flow.dst_ip);
8782 IPV6_ADDR_TO_ARRAY(res->ip_src,
8783 entry.input.flow.ipv6_flow.src_ip);
8784 entry.input.flow.ipv6_flow.tc = res->tos_value;
8785 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8786 /* need convert to big endian. */
8787 entry.input.flow.udp6_flow.dst_port =
8788 rte_cpu_to_be_16(res->port_dst);
8789 entry.input.flow.udp6_flow.src_port =
8790 rte_cpu_to_be_16(res->port_src);
8792 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8793 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8794 entry.input.flow.sctp6_flow.ip.dst_ip);
8795 IPV6_ADDR_TO_ARRAY(res->ip_src,
8796 entry.input.flow.sctp6_flow.ip.src_ip);
8797 entry.input.flow.ipv6_flow.tc = res->tos_value;
8798 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8799 /* need convert to big endian. */
8800 entry.input.flow.sctp6_flow.dst_port =
8801 rte_cpu_to_be_16(res->port_dst);
8802 entry.input.flow.sctp6_flow.src_port =
8803 rte_cpu_to_be_16(res->port_src);
8804 entry.input.flow.sctp6_flow.verify_tag =
8805 rte_cpu_to_be_32(res->verify_tag_value);
8807 case RTE_ETH_FLOW_L2_PAYLOAD:
8808 entry.input.flow.l2_flow.ether_type =
8809 rte_cpu_to_be_16(res->ether_type);
8815 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8816 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8818 sizeof(struct ether_addr));
8820 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8821 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8823 sizeof(struct ether_addr));
8824 entry.input.flow.tunnel_flow.tunnel_type =
8825 str2fdir_tunneltype(res->tunnel_type);
8826 entry.input.flow.tunnel_flow.tunnel_id =
8827 rte_cpu_to_be_32(res->tunnel_id_value);
8830 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8832 RTE_ETH_FDIR_MAX_FLEXLEN);
8834 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8836 entry.action.flex_off = 0; /*use 0 by default */
8837 if (!strcmp(res->drop, "drop"))
8838 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8840 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8842 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8843 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8844 if (!strcmp(res->pf_vf, "pf"))
8845 entry.input.flow_ext.is_vf = 0;
8846 else if (!strncmp(res->pf_vf, "vf", 2)) {
8847 struct rte_eth_dev_info dev_info;
8849 memset(&dev_info, 0, sizeof(dev_info));
8850 rte_eth_dev_info_get(res->port_id, &dev_info);
8852 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8853 if (errno != 0 || *end != '\0' ||
8854 vf_id >= dev_info.max_vfs) {
8855 printf("invalid parameter %s.\n", res->pf_vf);
8858 entry.input.flow_ext.is_vf = 1;
8859 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8861 printf("invalid parameter %s.\n", res->pf_vf);
8866 /* set to report FD ID by default */
8867 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8868 entry.action.rx_queue = res->queue_id;
8869 entry.soft_id = res->fd_id_value;
8870 if (!strcmp(res->ops, "add"))
8871 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8872 RTE_ETH_FILTER_ADD, &entry);
8873 else if (!strcmp(res->ops, "del"))
8874 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8875 RTE_ETH_FILTER_DELETE, &entry);
8877 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8878 RTE_ETH_FILTER_UPDATE, &entry);
8880 printf("flow director programming error: (%s)\n",
8884 cmdline_parse_token_string_t cmd_flow_director_filter =
8885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8886 flow_director_filter, "flow_director_filter");
8887 cmdline_parse_token_num_t cmd_flow_director_port_id =
8888 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8890 cmdline_parse_token_string_t cmd_flow_director_ops =
8891 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8892 ops, "add#del#update");
8893 cmdline_parse_token_string_t cmd_flow_director_flow =
8894 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8896 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8897 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8898 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8899 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8900 cmdline_parse_token_string_t cmd_flow_director_ether =
8901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8903 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8904 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8905 ether_type, UINT16);
8906 cmdline_parse_token_string_t cmd_flow_director_src =
8907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8909 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8910 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8912 cmdline_parse_token_num_t cmd_flow_director_port_src =
8913 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8915 cmdline_parse_token_string_t cmd_flow_director_dst =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8918 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8919 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8921 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8922 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8926 verify_tag, "verify_tag");
8927 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8928 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8929 verify_tag_value, UINT32);
8930 cmdline_parse_token_string_t cmd_flow_director_tos =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8933 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8934 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8936 cmdline_parse_token_string_t cmd_flow_director_proto =
8937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8939 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8940 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8941 proto_value, UINT8);
8942 cmdline_parse_token_string_t cmd_flow_director_ttl =
8943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8945 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8946 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8948 cmdline_parse_token_string_t cmd_flow_director_vlan =
8949 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8951 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8952 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8953 vlan_value, UINT16);
8954 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8956 flexbytes, "flexbytes");
8957 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8958 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8959 flexbytes_value, NULL);
8960 cmdline_parse_token_string_t cmd_flow_director_drop =
8961 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8963 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8964 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8966 cmdline_parse_token_string_t cmd_flow_director_queue =
8967 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8969 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8970 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8972 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8973 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8975 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8976 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8977 fd_id_value, UINT32);
8979 cmdline_parse_token_string_t cmd_flow_director_mode =
8980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8982 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8985 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8986 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8987 mode_value, "MAC-VLAN");
8988 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8990 mode_value, "Tunnel");
8991 cmdline_parse_token_string_t cmd_flow_director_mac =
8992 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8994 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8995 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8997 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9000 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9001 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9002 tunnel_type, "NVGRE#VxLAN");
9003 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9004 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9005 tunnel_id, "tunnel-id");
9006 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9007 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9008 tunnel_id_value, UINT32);
9010 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9011 .f = cmd_flow_director_filter_parsed,
9013 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9014 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9015 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9016 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9017 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9018 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9019 "fd_id <fd_id_value>: "
9020 "Add or delete an ip flow director entry on NIC",
9022 (void *)&cmd_flow_director_filter,
9023 (void *)&cmd_flow_director_port_id,
9024 (void *)&cmd_flow_director_mode,
9025 (void *)&cmd_flow_director_mode_ip,
9026 (void *)&cmd_flow_director_ops,
9027 (void *)&cmd_flow_director_flow,
9028 (void *)&cmd_flow_director_flow_type,
9029 (void *)&cmd_flow_director_src,
9030 (void *)&cmd_flow_director_ip_src,
9031 (void *)&cmd_flow_director_dst,
9032 (void *)&cmd_flow_director_ip_dst,
9033 (void *)&cmd_flow_director_tos,
9034 (void *)&cmd_flow_director_tos_value,
9035 (void *)&cmd_flow_director_proto,
9036 (void *)&cmd_flow_director_proto_value,
9037 (void *)&cmd_flow_director_ttl,
9038 (void *)&cmd_flow_director_ttl_value,
9039 (void *)&cmd_flow_director_vlan,
9040 (void *)&cmd_flow_director_vlan_value,
9041 (void *)&cmd_flow_director_flexbytes,
9042 (void *)&cmd_flow_director_flexbytes_value,
9043 (void *)&cmd_flow_director_drop,
9044 (void *)&cmd_flow_director_pf_vf,
9045 (void *)&cmd_flow_director_queue,
9046 (void *)&cmd_flow_director_queue_id,
9047 (void *)&cmd_flow_director_fd_id,
9048 (void *)&cmd_flow_director_fd_id_value,
9053 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9054 .f = cmd_flow_director_filter_parsed,
9056 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9057 "director entry on NIC",
9059 (void *)&cmd_flow_director_filter,
9060 (void *)&cmd_flow_director_port_id,
9061 (void *)&cmd_flow_director_mode,
9062 (void *)&cmd_flow_director_mode_ip,
9063 (void *)&cmd_flow_director_ops,
9064 (void *)&cmd_flow_director_flow,
9065 (void *)&cmd_flow_director_flow_type,
9066 (void *)&cmd_flow_director_src,
9067 (void *)&cmd_flow_director_ip_src,
9068 (void *)&cmd_flow_director_port_src,
9069 (void *)&cmd_flow_director_dst,
9070 (void *)&cmd_flow_director_ip_dst,
9071 (void *)&cmd_flow_director_port_dst,
9072 (void *)&cmd_flow_director_tos,
9073 (void *)&cmd_flow_director_tos_value,
9074 (void *)&cmd_flow_director_ttl,
9075 (void *)&cmd_flow_director_ttl_value,
9076 (void *)&cmd_flow_director_vlan,
9077 (void *)&cmd_flow_director_vlan_value,
9078 (void *)&cmd_flow_director_flexbytes,
9079 (void *)&cmd_flow_director_flexbytes_value,
9080 (void *)&cmd_flow_director_drop,
9081 (void *)&cmd_flow_director_pf_vf,
9082 (void *)&cmd_flow_director_queue,
9083 (void *)&cmd_flow_director_queue_id,
9084 (void *)&cmd_flow_director_fd_id,
9085 (void *)&cmd_flow_director_fd_id_value,
9090 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9091 .f = cmd_flow_director_filter_parsed,
9093 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9094 "director entry on NIC",
9096 (void *)&cmd_flow_director_filter,
9097 (void *)&cmd_flow_director_port_id,
9098 (void *)&cmd_flow_director_mode,
9099 (void *)&cmd_flow_director_mode_ip,
9100 (void *)&cmd_flow_director_ops,
9101 (void *)&cmd_flow_director_flow,
9102 (void *)&cmd_flow_director_flow_type,
9103 (void *)&cmd_flow_director_src,
9104 (void *)&cmd_flow_director_ip_src,
9105 (void *)&cmd_flow_director_port_dst,
9106 (void *)&cmd_flow_director_dst,
9107 (void *)&cmd_flow_director_ip_dst,
9108 (void *)&cmd_flow_director_port_dst,
9109 (void *)&cmd_flow_director_verify_tag,
9110 (void *)&cmd_flow_director_verify_tag_value,
9111 (void *)&cmd_flow_director_tos,
9112 (void *)&cmd_flow_director_tos_value,
9113 (void *)&cmd_flow_director_ttl,
9114 (void *)&cmd_flow_director_ttl_value,
9115 (void *)&cmd_flow_director_vlan,
9116 (void *)&cmd_flow_director_vlan_value,
9117 (void *)&cmd_flow_director_flexbytes,
9118 (void *)&cmd_flow_director_flexbytes_value,
9119 (void *)&cmd_flow_director_drop,
9120 (void *)&cmd_flow_director_pf_vf,
9121 (void *)&cmd_flow_director_queue,
9122 (void *)&cmd_flow_director_queue_id,
9123 (void *)&cmd_flow_director_fd_id,
9124 (void *)&cmd_flow_director_fd_id_value,
9129 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9130 .f = cmd_flow_director_filter_parsed,
9132 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9133 "director entry on NIC",
9135 (void *)&cmd_flow_director_filter,
9136 (void *)&cmd_flow_director_port_id,
9137 (void *)&cmd_flow_director_mode,
9138 (void *)&cmd_flow_director_mode_ip,
9139 (void *)&cmd_flow_director_ops,
9140 (void *)&cmd_flow_director_flow,
9141 (void *)&cmd_flow_director_flow_type,
9142 (void *)&cmd_flow_director_ether,
9143 (void *)&cmd_flow_director_ether_type,
9144 (void *)&cmd_flow_director_flexbytes,
9145 (void *)&cmd_flow_director_flexbytes_value,
9146 (void *)&cmd_flow_director_drop,
9147 (void *)&cmd_flow_director_pf_vf,
9148 (void *)&cmd_flow_director_queue,
9149 (void *)&cmd_flow_director_queue_id,
9150 (void *)&cmd_flow_director_fd_id,
9151 (void *)&cmd_flow_director_fd_id_value,
9156 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9157 .f = cmd_flow_director_filter_parsed,
9159 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9160 "director entry on NIC",
9162 (void *)&cmd_flow_director_filter,
9163 (void *)&cmd_flow_director_port_id,
9164 (void *)&cmd_flow_director_mode,
9165 (void *)&cmd_flow_director_mode_mac_vlan,
9166 (void *)&cmd_flow_director_ops,
9167 (void *)&cmd_flow_director_mac,
9168 (void *)&cmd_flow_director_mac_addr,
9169 (void *)&cmd_flow_director_vlan,
9170 (void *)&cmd_flow_director_vlan_value,
9171 (void *)&cmd_flow_director_flexbytes,
9172 (void *)&cmd_flow_director_flexbytes_value,
9173 (void *)&cmd_flow_director_drop,
9174 (void *)&cmd_flow_director_queue,
9175 (void *)&cmd_flow_director_queue_id,
9176 (void *)&cmd_flow_director_fd_id,
9177 (void *)&cmd_flow_director_fd_id_value,
9182 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9183 .f = cmd_flow_director_filter_parsed,
9185 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9186 "director entry on NIC",
9188 (void *)&cmd_flow_director_filter,
9189 (void *)&cmd_flow_director_port_id,
9190 (void *)&cmd_flow_director_mode,
9191 (void *)&cmd_flow_director_mode_tunnel,
9192 (void *)&cmd_flow_director_ops,
9193 (void *)&cmd_flow_director_mac,
9194 (void *)&cmd_flow_director_mac_addr,
9195 (void *)&cmd_flow_director_vlan,
9196 (void *)&cmd_flow_director_vlan_value,
9197 (void *)&cmd_flow_director_tunnel,
9198 (void *)&cmd_flow_director_tunnel_type,
9199 (void *)&cmd_flow_director_tunnel_id,
9200 (void *)&cmd_flow_director_tunnel_id_value,
9201 (void *)&cmd_flow_director_flexbytes,
9202 (void *)&cmd_flow_director_flexbytes_value,
9203 (void *)&cmd_flow_director_drop,
9204 (void *)&cmd_flow_director_queue,
9205 (void *)&cmd_flow_director_queue_id,
9206 (void *)&cmd_flow_director_fd_id,
9207 (void *)&cmd_flow_director_fd_id_value,
9212 struct cmd_flush_flow_director_result {
9213 cmdline_fixed_string_t flush_flow_director;
9217 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9218 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9219 flush_flow_director, "flush_flow_director");
9220 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9221 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9225 cmd_flush_flow_director_parsed(void *parsed_result,
9226 __attribute__((unused)) struct cmdline *cl,
9227 __attribute__((unused)) void *data)
9229 struct cmd_flow_director_result *res = parsed_result;
9232 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9234 printf("flow director is not supported on port %u.\n",
9239 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9240 RTE_ETH_FILTER_FLUSH, NULL);
9242 printf("flow director table flushing error: (%s)\n",
9246 cmdline_parse_inst_t cmd_flush_flow_director = {
9247 .f = cmd_flush_flow_director_parsed,
9249 .help_str = "flush_flow_director <port_id>: "
9250 "Flush all flow director entries of a device on NIC",
9252 (void *)&cmd_flush_flow_director_flush,
9253 (void *)&cmd_flush_flow_director_port_id,
9258 /* *** deal with flow director mask *** */
9259 struct cmd_flow_director_mask_result {
9260 cmdline_fixed_string_t flow_director_mask;
9262 cmdline_fixed_string_t mode;
9263 cmdline_fixed_string_t mode_value;
9264 cmdline_fixed_string_t vlan;
9266 cmdline_fixed_string_t src_mask;
9267 cmdline_ipaddr_t ipv4_src;
9268 cmdline_ipaddr_t ipv6_src;
9270 cmdline_fixed_string_t dst_mask;
9271 cmdline_ipaddr_t ipv4_dst;
9272 cmdline_ipaddr_t ipv6_dst;
9274 cmdline_fixed_string_t mac;
9275 uint8_t mac_addr_byte_mask;
9276 cmdline_fixed_string_t tunnel_id;
9277 uint32_t tunnel_id_mask;
9278 cmdline_fixed_string_t tunnel_type;
9279 uint8_t tunnel_type_mask;
9283 cmd_flow_director_mask_parsed(void *parsed_result,
9284 __attribute__((unused)) struct cmdline *cl,
9285 __attribute__((unused)) void *data)
9287 struct cmd_flow_director_mask_result *res = parsed_result;
9288 struct rte_eth_fdir_masks *mask;
9289 struct rte_port *port;
9291 if (res->port_id > nb_ports) {
9292 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9296 port = &ports[res->port_id];
9297 /** Check if the port is not started **/
9298 if (port->port_status != RTE_PORT_STOPPED) {
9299 printf("Please stop port %d first\n", res->port_id);
9303 mask = &port->dev_conf.fdir_conf.mask;
9305 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9306 if (strcmp(res->mode_value, "MAC-VLAN")) {
9307 printf("Please set mode to MAC-VLAN.\n");
9311 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9312 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9313 if (strcmp(res->mode_value, "Tunnel")) {
9314 printf("Please set mode to Tunnel.\n");
9318 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9319 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9320 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9321 mask->tunnel_type_mask = res->tunnel_type_mask;
9323 if (strcmp(res->mode_value, "IP")) {
9324 printf("Please set mode to IP.\n");
9328 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9329 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9330 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9331 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9332 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9333 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9334 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9337 cmd_reconfig_device_queue(res->port_id, 1, 1);
9340 cmdline_parse_token_string_t cmd_flow_director_mask =
9341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9342 flow_director_mask, "flow_director_mask");
9343 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9344 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9346 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9349 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9350 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9352 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9354 src_mask, "src_mask");
9355 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9356 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9358 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9359 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9361 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9362 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9364 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9366 dst_mask, "dst_mask");
9367 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9368 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9370 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9371 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9373 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9374 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9377 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9378 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9380 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9383 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9385 mode_value, "MAC-VLAN");
9386 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9388 mode_value, "Tunnel");
9389 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9390 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9392 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9393 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9394 mac_addr_byte_mask, UINT8);
9395 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9397 tunnel_type, "tunnel-type");
9398 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9399 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9400 tunnel_type_mask, UINT8);
9401 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9402 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9403 tunnel_id, "tunnel-id");
9404 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9405 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9406 tunnel_id_mask, UINT32);
9408 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9409 .f = cmd_flow_director_mask_parsed,
9411 .help_str = "flow_director_mask ... : "
9412 "Set IP mode flow director's mask on NIC",
9414 (void *)&cmd_flow_director_mask,
9415 (void *)&cmd_flow_director_mask_port_id,
9416 (void *)&cmd_flow_director_mask_mode,
9417 (void *)&cmd_flow_director_mask_mode_ip,
9418 (void *)&cmd_flow_director_mask_vlan,
9419 (void *)&cmd_flow_director_mask_vlan_value,
9420 (void *)&cmd_flow_director_mask_src,
9421 (void *)&cmd_flow_director_mask_ipv4_src,
9422 (void *)&cmd_flow_director_mask_ipv6_src,
9423 (void *)&cmd_flow_director_mask_port_src,
9424 (void *)&cmd_flow_director_mask_dst,
9425 (void *)&cmd_flow_director_mask_ipv4_dst,
9426 (void *)&cmd_flow_director_mask_ipv6_dst,
9427 (void *)&cmd_flow_director_mask_port_dst,
9432 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9433 .f = cmd_flow_director_mask_parsed,
9435 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9436 "flow director's mask on NIC",
9438 (void *)&cmd_flow_director_mask,
9439 (void *)&cmd_flow_director_mask_port_id,
9440 (void *)&cmd_flow_director_mask_mode,
9441 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9442 (void *)&cmd_flow_director_mask_vlan,
9443 (void *)&cmd_flow_director_mask_vlan_value,
9448 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9449 .f = cmd_flow_director_mask_parsed,
9451 .help_str = "flow_director_mask ... : Set tunnel mode "
9452 "flow director's mask on NIC",
9454 (void *)&cmd_flow_director_mask,
9455 (void *)&cmd_flow_director_mask_port_id,
9456 (void *)&cmd_flow_director_mask_mode,
9457 (void *)&cmd_flow_director_mask_mode_tunnel,
9458 (void *)&cmd_flow_director_mask_vlan,
9459 (void *)&cmd_flow_director_mask_vlan_value,
9460 (void *)&cmd_flow_director_mask_mac,
9461 (void *)&cmd_flow_director_mask_mac_value,
9462 (void *)&cmd_flow_director_mask_tunnel_type,
9463 (void *)&cmd_flow_director_mask_tunnel_type_value,
9464 (void *)&cmd_flow_director_mask_tunnel_id,
9465 (void *)&cmd_flow_director_mask_tunnel_id_value,
9470 /* *** deal with flow director mask on flexible payload *** */
9471 struct cmd_flow_director_flex_mask_result {
9472 cmdline_fixed_string_t flow_director_flexmask;
9474 cmdline_fixed_string_t flow;
9475 cmdline_fixed_string_t flow_type;
9476 cmdline_fixed_string_t mask;
9480 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9481 __attribute__((unused)) struct cmdline *cl,
9482 __attribute__((unused)) void *data)
9484 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9485 struct rte_eth_fdir_info fdir_info;
9486 struct rte_eth_fdir_flex_mask flex_mask;
9487 struct rte_port *port;
9488 uint32_t flow_type_mask;
9492 if (res->port_id > nb_ports) {
9493 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9497 port = &ports[res->port_id];
9498 /** Check if the port is not started **/
9499 if (port->port_status != RTE_PORT_STOPPED) {
9500 printf("Please stop port %d first\n", res->port_id);
9504 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9505 ret = parse_flexbytes(res->mask,
9507 RTE_ETH_FDIR_MAX_FLEXLEN);
9509 printf("error: Cannot parse mask input.\n");
9513 memset(&fdir_info, 0, sizeof(fdir_info));
9514 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9515 RTE_ETH_FILTER_INFO, &fdir_info);
9517 printf("Cannot get FDir filter info\n");
9521 if (!strcmp(res->flow_type, "none")) {
9522 /* means don't specify the flow type */
9523 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9524 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9525 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9526 0, sizeof(struct rte_eth_fdir_flex_mask));
9527 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9528 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9530 sizeof(struct rte_eth_fdir_flex_mask));
9531 cmd_reconfig_device_queue(res->port_id, 1, 1);
9534 flow_type_mask = fdir_info.flow_types_mask[0];
9535 if (!strcmp(res->flow_type, "all")) {
9536 if (!flow_type_mask) {
9537 printf("No flow type supported\n");
9540 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9541 if (flow_type_mask & (1 << i)) {
9542 flex_mask.flow_type = i;
9543 fdir_set_flex_mask(res->port_id, &flex_mask);
9546 cmd_reconfig_device_queue(res->port_id, 1, 1);
9549 flex_mask.flow_type = str2flowtype(res->flow_type);
9550 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9551 printf("Flow type %s not supported on port %d\n",
9552 res->flow_type, res->port_id);
9555 fdir_set_flex_mask(res->port_id, &flex_mask);
9556 cmd_reconfig_device_queue(res->port_id, 1, 1);
9559 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9561 flow_director_flexmask,
9562 "flow_director_flex_mask");
9563 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9564 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9566 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9567 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9569 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9571 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9572 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9573 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9577 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9578 .f = cmd_flow_director_flex_mask_parsed,
9580 .help_str = "flow_director_flex_mask ... : "
9581 "Set flow director's flex mask on NIC",
9583 (void *)&cmd_flow_director_flexmask,
9584 (void *)&cmd_flow_director_flexmask_port_id,
9585 (void *)&cmd_flow_director_flexmask_flow,
9586 (void *)&cmd_flow_director_flexmask_flow_type,
9587 (void *)&cmd_flow_director_flexmask_mask,
9592 /* *** deal with flow director flexible payload configuration *** */
9593 struct cmd_flow_director_flexpayload_result {
9594 cmdline_fixed_string_t flow_director_flexpayload;
9596 cmdline_fixed_string_t payload_layer;
9597 cmdline_fixed_string_t payload_cfg;
9601 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9604 const char *p, *p0 = q_arg;
9606 unsigned long int_fld;
9607 char *str_fld[max_num];
9612 p = strchr(p0, '(');
9616 p0 = strchr(p, ')');
9621 if (size >= sizeof(s))
9624 snprintf(s, sizeof(s), "%.*s", size, p);
9625 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9626 if (ret < 0 || ret > max_num)
9628 for (i = 0; i < ret; i++) {
9630 int_fld = strtoul(str_fld[i], &end, 0);
9631 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9633 offsets[i] = (uint16_t)int_fld;
9639 cmd_flow_director_flxpld_parsed(void *parsed_result,
9640 __attribute__((unused)) struct cmdline *cl,
9641 __attribute__((unused)) void *data)
9643 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9644 struct rte_eth_flex_payload_cfg flex_cfg;
9645 struct rte_port *port;
9648 if (res->port_id > nb_ports) {
9649 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9653 port = &ports[res->port_id];
9654 /** Check if the port is not started **/
9655 if (port->port_status != RTE_PORT_STOPPED) {
9656 printf("Please stop port %d first\n", res->port_id);
9660 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9662 if (!strcmp(res->payload_layer, "raw"))
9663 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9664 else if (!strcmp(res->payload_layer, "l2"))
9665 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9666 else if (!strcmp(res->payload_layer, "l3"))
9667 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9668 else if (!strcmp(res->payload_layer, "l4"))
9669 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9671 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9672 RTE_ETH_FDIR_MAX_FLEXLEN);
9674 printf("error: Cannot parse flex payload input.\n");
9678 fdir_set_flex_payload(res->port_id, &flex_cfg);
9679 cmd_reconfig_device_queue(res->port_id, 1, 1);
9682 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9683 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9684 flow_director_flexpayload,
9685 "flow_director_flex_payload");
9686 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9687 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9689 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9691 payload_layer, "raw#l2#l3#l4");
9692 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9693 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9696 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9697 .f = cmd_flow_director_flxpld_parsed,
9699 .help_str = "flow_director_flexpayload ... : "
9700 "Set flow director's flex payload on NIC",
9702 (void *)&cmd_flow_director_flexpayload,
9703 (void *)&cmd_flow_director_flexpayload_port_id,
9704 (void *)&cmd_flow_director_flexpayload_payload_layer,
9705 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9710 /* Generic flow interface command. */
9711 extern cmdline_parse_inst_t cmd_flow;
9713 /* *** Classification Filters Control *** */
9714 /* *** Get symmetric hash enable per port *** */
9715 struct cmd_get_sym_hash_ena_per_port_result {
9716 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9721 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9722 __rte_unused struct cmdline *cl,
9723 __rte_unused void *data)
9725 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9726 struct rte_eth_hash_filter_info info;
9729 if (rte_eth_dev_filter_supported(res->port_id,
9730 RTE_ETH_FILTER_HASH) < 0) {
9731 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9736 memset(&info, 0, sizeof(info));
9737 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9738 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9739 RTE_ETH_FILTER_GET, &info);
9742 printf("Cannot get symmetric hash enable per port "
9743 "on port %u\n", res->port_id);
9747 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9748 "enabled" : "disabled", res->port_id);
9751 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9752 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9753 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9754 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9755 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9758 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9759 .f = cmd_get_sym_hash_per_port_parsed,
9761 .help_str = "get_sym_hash_ena_per_port <port_id>",
9763 (void *)&cmd_get_sym_hash_ena_per_port_all,
9764 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9769 /* *** Set symmetric hash enable per port *** */
9770 struct cmd_set_sym_hash_ena_per_port_result {
9771 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9772 cmdline_fixed_string_t enable;
9777 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9778 __rte_unused struct cmdline *cl,
9779 __rte_unused void *data)
9781 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9782 struct rte_eth_hash_filter_info info;
9785 if (rte_eth_dev_filter_supported(res->port_id,
9786 RTE_ETH_FILTER_HASH) < 0) {
9787 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9792 memset(&info, 0, sizeof(info));
9793 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9794 if (!strcmp(res->enable, "enable"))
9795 info.info.enable = 1;
9796 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9797 RTE_ETH_FILTER_SET, &info);
9799 printf("Cannot set symmetric hash enable per port on "
9800 "port %u\n", res->port_id);
9803 printf("Symmetric hash has been set to %s on port %u\n",
9804 res->enable, res->port_id);
9807 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9808 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9809 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9810 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9811 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9813 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9814 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9815 enable, "enable#disable");
9817 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9818 .f = cmd_set_sym_hash_per_port_parsed,
9820 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9822 (void *)&cmd_set_sym_hash_ena_per_port_all,
9823 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9824 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9829 /* Get global config of hash function */
9830 struct cmd_get_hash_global_config_result {
9831 cmdline_fixed_string_t get_hash_global_config;
9836 flowtype_to_str(uint16_t ftype)
9843 {"ipv4", RTE_ETH_FLOW_IPV4},
9844 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9845 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9846 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9847 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9848 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9849 {"ipv6", RTE_ETH_FLOW_IPV6},
9850 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9851 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9852 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9853 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9854 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9855 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9856 {"port", RTE_ETH_FLOW_PORT},
9857 {"vxlan", RTE_ETH_FLOW_VXLAN},
9858 {"geneve", RTE_ETH_FLOW_GENEVE},
9859 {"nvgre", RTE_ETH_FLOW_NVGRE},
9862 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9863 if (ftype_table[i].ftype == ftype)
9864 return ftype_table[i].str;
9871 cmd_get_hash_global_config_parsed(void *parsed_result,
9872 __rte_unused struct cmdline *cl,
9873 __rte_unused void *data)
9875 struct cmd_get_hash_global_config_result *res = parsed_result;
9876 struct rte_eth_hash_filter_info info;
9877 uint32_t idx, offset;
9882 if (rte_eth_dev_filter_supported(res->port_id,
9883 RTE_ETH_FILTER_HASH) < 0) {
9884 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9889 memset(&info, 0, sizeof(info));
9890 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9891 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9892 RTE_ETH_FILTER_GET, &info);
9894 printf("Cannot get hash global configurations by port %d\n",
9899 switch (info.info.global_conf.hash_func) {
9900 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9901 printf("Hash function is Toeplitz\n");
9903 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9904 printf("Hash function is Simple XOR\n");
9907 printf("Unknown hash function\n");
9911 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9912 idx = i / UINT32_BIT;
9913 offset = i % UINT32_BIT;
9914 if (!(info.info.global_conf.valid_bit_mask[idx] &
9917 str = flowtype_to_str(i);
9920 printf("Symmetric hash is %s globally for flow type %s "
9922 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9923 (1UL << offset)) ? "enabled" : "disabled"), str,
9928 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9929 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9930 get_hash_global_config, "get_hash_global_config");
9931 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9932 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9935 cmdline_parse_inst_t cmd_get_hash_global_config = {
9936 .f = cmd_get_hash_global_config_parsed,
9938 .help_str = "get_hash_global_config <port_id>",
9940 (void *)&cmd_get_hash_global_config_all,
9941 (void *)&cmd_get_hash_global_config_port_id,
9946 /* Set global config of hash function */
9947 struct cmd_set_hash_global_config_result {
9948 cmdline_fixed_string_t set_hash_global_config;
9950 cmdline_fixed_string_t hash_func;
9951 cmdline_fixed_string_t flow_type;
9952 cmdline_fixed_string_t enable;
9956 cmd_set_hash_global_config_parsed(void *parsed_result,
9957 __rte_unused struct cmdline *cl,
9958 __rte_unused void *data)
9960 struct cmd_set_hash_global_config_result *res = parsed_result;
9961 struct rte_eth_hash_filter_info info;
9962 uint32_t ftype, idx, offset;
9965 if (rte_eth_dev_filter_supported(res->port_id,
9966 RTE_ETH_FILTER_HASH) < 0) {
9967 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9971 memset(&info, 0, sizeof(info));
9972 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9973 if (!strcmp(res->hash_func, "toeplitz"))
9974 info.info.global_conf.hash_func =
9975 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9976 else if (!strcmp(res->hash_func, "simple_xor"))
9977 info.info.global_conf.hash_func =
9978 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9979 else if (!strcmp(res->hash_func, "default"))
9980 info.info.global_conf.hash_func =
9981 RTE_ETH_HASH_FUNCTION_DEFAULT;
9983 ftype = str2flowtype(res->flow_type);
9984 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9985 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9986 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9987 if (!strcmp(res->enable, "enable"))
9988 info.info.global_conf.sym_hash_enable_mask[idx] |=
9990 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9991 RTE_ETH_FILTER_SET, &info);
9993 printf("Cannot set global hash configurations by port %d\n",
9996 printf("Global hash configurations have been set "
9997 "succcessfully by port %d\n", res->port_id);
10000 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10001 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10002 set_hash_global_config, "set_hash_global_config");
10003 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10004 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10006 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10007 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10008 hash_func, "toeplitz#simple_xor#default");
10009 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10010 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10012 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10013 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10014 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10015 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10016 enable, "enable#disable");
10018 cmdline_parse_inst_t cmd_set_hash_global_config = {
10019 .f = cmd_set_hash_global_config_parsed,
10021 .help_str = "set_hash_global_config <port_id> "
10022 "toeplitz|simple_xor|default "
10023 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10024 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10025 "l2_payload enable|disable",
10027 (void *)&cmd_set_hash_global_config_all,
10028 (void *)&cmd_set_hash_global_config_port_id,
10029 (void *)&cmd_set_hash_global_config_hash_func,
10030 (void *)&cmd_set_hash_global_config_flow_type,
10031 (void *)&cmd_set_hash_global_config_enable,
10036 /* Set hash input set */
10037 struct cmd_set_hash_input_set_result {
10038 cmdline_fixed_string_t set_hash_input_set;
10040 cmdline_fixed_string_t flow_type;
10041 cmdline_fixed_string_t inset_field;
10042 cmdline_fixed_string_t select;
10045 static enum rte_eth_input_set_field
10046 str2inset(char *string)
10050 static const struct {
10052 enum rte_eth_input_set_field inset;
10053 } inset_table[] = {
10054 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10055 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10056 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10057 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10058 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10059 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10060 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10061 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10062 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10063 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10064 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10065 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10066 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10067 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10068 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10069 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10070 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10071 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10072 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10073 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10074 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10075 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10076 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10077 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10078 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10079 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10080 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10081 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10082 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10083 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10084 {"none", RTE_ETH_INPUT_SET_NONE},
10087 for (i = 0; i < RTE_DIM(inset_table); i++) {
10088 if (!strcmp(string, inset_table[i].str))
10089 return inset_table[i].inset;
10092 return RTE_ETH_INPUT_SET_UNKNOWN;
10096 cmd_set_hash_input_set_parsed(void *parsed_result,
10097 __rte_unused struct cmdline *cl,
10098 __rte_unused void *data)
10100 struct cmd_set_hash_input_set_result *res = parsed_result;
10101 struct rte_eth_hash_filter_info info;
10103 memset(&info, 0, sizeof(info));
10104 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10105 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10106 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10107 info.info.input_set_conf.inset_size = 1;
10108 if (!strcmp(res->select, "select"))
10109 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10110 else if (!strcmp(res->select, "add"))
10111 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10112 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10113 RTE_ETH_FILTER_SET, &info);
10116 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10117 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10118 set_hash_input_set, "set_hash_input_set");
10119 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10120 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10122 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10123 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10125 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10126 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10127 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10128 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10130 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10131 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10132 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10133 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10134 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10136 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10137 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10138 select, "select#add");
10140 cmdline_parse_inst_t cmd_set_hash_input_set = {
10141 .f = cmd_set_hash_input_set_parsed,
10143 .help_str = "set_hash_input_set <port_id> "
10144 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10145 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10146 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10147 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10148 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10149 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10150 "fld-7th|fld-8th|none select|add",
10152 (void *)&cmd_set_hash_input_set_cmd,
10153 (void *)&cmd_set_hash_input_set_port_id,
10154 (void *)&cmd_set_hash_input_set_flow_type,
10155 (void *)&cmd_set_hash_input_set_field,
10156 (void *)&cmd_set_hash_input_set_select,
10161 /* Set flow director input set */
10162 struct cmd_set_fdir_input_set_result {
10163 cmdline_fixed_string_t set_fdir_input_set;
10165 cmdline_fixed_string_t flow_type;
10166 cmdline_fixed_string_t inset_field;
10167 cmdline_fixed_string_t select;
10171 cmd_set_fdir_input_set_parsed(void *parsed_result,
10172 __rte_unused struct cmdline *cl,
10173 __rte_unused void *data)
10175 struct cmd_set_fdir_input_set_result *res = parsed_result;
10176 struct rte_eth_fdir_filter_info info;
10178 memset(&info, 0, sizeof(info));
10179 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10180 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10181 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10182 info.info.input_set_conf.inset_size = 1;
10183 if (!strcmp(res->select, "select"))
10184 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10185 else if (!strcmp(res->select, "add"))
10186 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10187 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10188 RTE_ETH_FILTER_SET, &info);
10191 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10192 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10193 set_fdir_input_set, "set_fdir_input_set");
10194 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10195 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10197 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10198 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10200 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10201 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10202 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10203 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10205 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10206 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10207 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10208 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10209 "sctp-veri-tag#none");
10210 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10211 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10212 select, "select#add");
10214 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10215 .f = cmd_set_fdir_input_set_parsed,
10217 .help_str = "set_fdir_input_set <port_id> "
10218 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10219 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10220 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10221 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10222 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10223 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10224 "sctp-veri-tag|none select|add",
10226 (void *)&cmd_set_fdir_input_set_cmd,
10227 (void *)&cmd_set_fdir_input_set_port_id,
10228 (void *)&cmd_set_fdir_input_set_flow_type,
10229 (void *)&cmd_set_fdir_input_set_field,
10230 (void *)&cmd_set_fdir_input_set_select,
10235 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10236 struct cmd_mcast_addr_result {
10237 cmdline_fixed_string_t mcast_addr_cmd;
10238 cmdline_fixed_string_t what;
10240 struct ether_addr mc_addr;
10243 static void cmd_mcast_addr_parsed(void *parsed_result,
10244 __attribute__((unused)) struct cmdline *cl,
10245 __attribute__((unused)) void *data)
10247 struct cmd_mcast_addr_result *res = parsed_result;
10249 if (!is_multicast_ether_addr(&res->mc_addr)) {
10250 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10251 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10252 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10253 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10256 if (strcmp(res->what, "add") == 0)
10257 mcast_addr_add(res->port_num, &res->mc_addr);
10259 mcast_addr_remove(res->port_num, &res->mc_addr);
10262 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10263 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10264 mcast_addr_cmd, "mcast_addr");
10265 cmdline_parse_token_string_t cmd_mcast_addr_what =
10266 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10268 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10269 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10270 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10271 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10273 cmdline_parse_inst_t cmd_mcast_addr = {
10274 .f = cmd_mcast_addr_parsed,
10276 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10277 "Add/Remove multicast MAC address on port_id",
10279 (void *)&cmd_mcast_addr_cmd,
10280 (void *)&cmd_mcast_addr_what,
10281 (void *)&cmd_mcast_addr_portnum,
10282 (void *)&cmd_mcast_addr_addr,
10287 /* l2 tunnel config
10288 * only support E-tag now.
10291 /* Ether type config */
10292 struct cmd_config_l2_tunnel_eth_type_result {
10293 cmdline_fixed_string_t port;
10294 cmdline_fixed_string_t config;
10295 cmdline_fixed_string_t all;
10297 cmdline_fixed_string_t l2_tunnel;
10298 cmdline_fixed_string_t l2_tunnel_type;
10299 cmdline_fixed_string_t eth_type;
10300 uint16_t eth_type_val;
10303 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10304 TOKEN_STRING_INITIALIZER
10305 (struct cmd_config_l2_tunnel_eth_type_result,
10307 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10308 TOKEN_STRING_INITIALIZER
10309 (struct cmd_config_l2_tunnel_eth_type_result,
10311 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10312 TOKEN_STRING_INITIALIZER
10313 (struct cmd_config_l2_tunnel_eth_type_result,
10315 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10316 TOKEN_NUM_INITIALIZER
10317 (struct cmd_config_l2_tunnel_eth_type_result,
10319 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10320 TOKEN_STRING_INITIALIZER
10321 (struct cmd_config_l2_tunnel_eth_type_result,
10322 l2_tunnel, "l2-tunnel");
10323 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10324 TOKEN_STRING_INITIALIZER
10325 (struct cmd_config_l2_tunnel_eth_type_result,
10326 l2_tunnel_type, "E-tag");
10327 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10328 TOKEN_STRING_INITIALIZER
10329 (struct cmd_config_l2_tunnel_eth_type_result,
10330 eth_type, "ether-type");
10331 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10332 TOKEN_NUM_INITIALIZER
10333 (struct cmd_config_l2_tunnel_eth_type_result,
10334 eth_type_val, UINT16);
10336 static enum rte_eth_tunnel_type
10337 str2fdir_l2_tunnel_type(char *string)
10341 static const struct {
10343 enum rte_eth_tunnel_type type;
10344 } l2_tunnel_type_str[] = {
10345 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10348 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10349 if (!strcmp(l2_tunnel_type_str[i].str, string))
10350 return l2_tunnel_type_str[i].type;
10352 return RTE_TUNNEL_TYPE_NONE;
10355 /* ether type config for all ports */
10357 cmd_config_l2_tunnel_eth_type_all_parsed
10358 (void *parsed_result,
10359 __attribute__((unused)) struct cmdline *cl,
10360 __attribute__((unused)) void *data)
10362 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10363 struct rte_eth_l2_tunnel_conf entry;
10366 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10367 entry.ether_type = res->eth_type_val;
10369 RTE_ETH_FOREACH_DEV(pid) {
10370 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10374 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10375 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10377 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10379 (void *)&cmd_config_l2_tunnel_eth_type_port,
10380 (void *)&cmd_config_l2_tunnel_eth_type_config,
10381 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10382 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10383 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10384 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10385 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10390 /* ether type config for a specific port */
10392 cmd_config_l2_tunnel_eth_type_specific_parsed(
10393 void *parsed_result,
10394 __attribute__((unused)) struct cmdline *cl,
10395 __attribute__((unused)) void *data)
10397 struct cmd_config_l2_tunnel_eth_type_result *res =
10399 struct rte_eth_l2_tunnel_conf entry;
10401 if (port_id_is_invalid(res->id, ENABLED_WARN))
10404 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10405 entry.ether_type = res->eth_type_val;
10407 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10410 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10411 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10413 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10415 (void *)&cmd_config_l2_tunnel_eth_type_port,
10416 (void *)&cmd_config_l2_tunnel_eth_type_config,
10417 (void *)&cmd_config_l2_tunnel_eth_type_id,
10418 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10419 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10420 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10421 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10426 /* Enable/disable l2 tunnel */
10427 struct cmd_config_l2_tunnel_en_dis_result {
10428 cmdline_fixed_string_t port;
10429 cmdline_fixed_string_t config;
10430 cmdline_fixed_string_t all;
10432 cmdline_fixed_string_t l2_tunnel;
10433 cmdline_fixed_string_t l2_tunnel_type;
10434 cmdline_fixed_string_t en_dis;
10437 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10438 TOKEN_STRING_INITIALIZER
10439 (struct cmd_config_l2_tunnel_en_dis_result,
10441 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10442 TOKEN_STRING_INITIALIZER
10443 (struct cmd_config_l2_tunnel_en_dis_result,
10445 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10446 TOKEN_STRING_INITIALIZER
10447 (struct cmd_config_l2_tunnel_en_dis_result,
10449 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10450 TOKEN_NUM_INITIALIZER
10451 (struct cmd_config_l2_tunnel_en_dis_result,
10453 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10454 TOKEN_STRING_INITIALIZER
10455 (struct cmd_config_l2_tunnel_en_dis_result,
10456 l2_tunnel, "l2-tunnel");
10457 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10458 TOKEN_STRING_INITIALIZER
10459 (struct cmd_config_l2_tunnel_en_dis_result,
10460 l2_tunnel_type, "E-tag");
10461 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10462 TOKEN_STRING_INITIALIZER
10463 (struct cmd_config_l2_tunnel_en_dis_result,
10464 en_dis, "enable#disable");
10466 /* enable/disable l2 tunnel for all ports */
10468 cmd_config_l2_tunnel_en_dis_all_parsed(
10469 void *parsed_result,
10470 __attribute__((unused)) struct cmdline *cl,
10471 __attribute__((unused)) void *data)
10473 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10474 struct rte_eth_l2_tunnel_conf entry;
10478 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10480 if (!strcmp("enable", res->en_dis))
10485 RTE_ETH_FOREACH_DEV(pid) {
10486 rte_eth_dev_l2_tunnel_offload_set(pid,
10488 ETH_L2_TUNNEL_ENABLE_MASK,
10493 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10494 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10496 .help_str = "port config all l2-tunnel E-tag enable|disable",
10498 (void *)&cmd_config_l2_tunnel_en_dis_port,
10499 (void *)&cmd_config_l2_tunnel_en_dis_config,
10500 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10501 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10502 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10503 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10508 /* enable/disable l2 tunnel for a port */
10510 cmd_config_l2_tunnel_en_dis_specific_parsed(
10511 void *parsed_result,
10512 __attribute__((unused)) struct cmdline *cl,
10513 __attribute__((unused)) void *data)
10515 struct cmd_config_l2_tunnel_en_dis_result *res =
10517 struct rte_eth_l2_tunnel_conf entry;
10519 if (port_id_is_invalid(res->id, ENABLED_WARN))
10522 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10524 if (!strcmp("enable", res->en_dis))
10525 rte_eth_dev_l2_tunnel_offload_set(res->id,
10527 ETH_L2_TUNNEL_ENABLE_MASK,
10530 rte_eth_dev_l2_tunnel_offload_set(res->id,
10532 ETH_L2_TUNNEL_ENABLE_MASK,
10536 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10537 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10539 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10541 (void *)&cmd_config_l2_tunnel_en_dis_port,
10542 (void *)&cmd_config_l2_tunnel_en_dis_config,
10543 (void *)&cmd_config_l2_tunnel_en_dis_id,
10544 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10545 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10546 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10551 /* E-tag configuration */
10553 /* Common result structure for all E-tag configuration */
10554 struct cmd_config_e_tag_result {
10555 cmdline_fixed_string_t e_tag;
10556 cmdline_fixed_string_t set;
10557 cmdline_fixed_string_t insertion;
10558 cmdline_fixed_string_t stripping;
10559 cmdline_fixed_string_t forwarding;
10560 cmdline_fixed_string_t filter;
10561 cmdline_fixed_string_t add;
10562 cmdline_fixed_string_t del;
10563 cmdline_fixed_string_t on;
10564 cmdline_fixed_string_t off;
10565 cmdline_fixed_string_t on_off;
10566 cmdline_fixed_string_t port_tag_id;
10567 uint32_t port_tag_id_val;
10568 cmdline_fixed_string_t e_tag_id;
10569 uint16_t e_tag_id_val;
10570 cmdline_fixed_string_t dst_pool;
10571 uint8_t dst_pool_val;
10572 cmdline_fixed_string_t port;
10574 cmdline_fixed_string_t vf;
10578 /* Common CLI fields for all E-tag configuration */
10579 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10580 TOKEN_STRING_INITIALIZER
10581 (struct cmd_config_e_tag_result,
10583 cmdline_parse_token_string_t cmd_config_e_tag_set =
10584 TOKEN_STRING_INITIALIZER
10585 (struct cmd_config_e_tag_result,
10587 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10588 TOKEN_STRING_INITIALIZER
10589 (struct cmd_config_e_tag_result,
10590 insertion, "insertion");
10591 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10592 TOKEN_STRING_INITIALIZER
10593 (struct cmd_config_e_tag_result,
10594 stripping, "stripping");
10595 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10596 TOKEN_STRING_INITIALIZER
10597 (struct cmd_config_e_tag_result,
10598 forwarding, "forwarding");
10599 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10600 TOKEN_STRING_INITIALIZER
10601 (struct cmd_config_e_tag_result,
10603 cmdline_parse_token_string_t cmd_config_e_tag_add =
10604 TOKEN_STRING_INITIALIZER
10605 (struct cmd_config_e_tag_result,
10607 cmdline_parse_token_string_t cmd_config_e_tag_del =
10608 TOKEN_STRING_INITIALIZER
10609 (struct cmd_config_e_tag_result,
10611 cmdline_parse_token_string_t cmd_config_e_tag_on =
10612 TOKEN_STRING_INITIALIZER
10613 (struct cmd_config_e_tag_result,
10615 cmdline_parse_token_string_t cmd_config_e_tag_off =
10616 TOKEN_STRING_INITIALIZER
10617 (struct cmd_config_e_tag_result,
10619 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10620 TOKEN_STRING_INITIALIZER
10621 (struct cmd_config_e_tag_result,
10623 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10624 TOKEN_STRING_INITIALIZER
10625 (struct cmd_config_e_tag_result,
10626 port_tag_id, "port-tag-id");
10627 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10628 TOKEN_NUM_INITIALIZER
10629 (struct cmd_config_e_tag_result,
10630 port_tag_id_val, UINT32);
10631 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10632 TOKEN_STRING_INITIALIZER
10633 (struct cmd_config_e_tag_result,
10634 e_tag_id, "e-tag-id");
10635 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10636 TOKEN_NUM_INITIALIZER
10637 (struct cmd_config_e_tag_result,
10638 e_tag_id_val, UINT16);
10639 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10640 TOKEN_STRING_INITIALIZER
10641 (struct cmd_config_e_tag_result,
10642 dst_pool, "dst-pool");
10643 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10644 TOKEN_NUM_INITIALIZER
10645 (struct cmd_config_e_tag_result,
10646 dst_pool_val, UINT8);
10647 cmdline_parse_token_string_t cmd_config_e_tag_port =
10648 TOKEN_STRING_INITIALIZER
10649 (struct cmd_config_e_tag_result,
10651 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10652 TOKEN_NUM_INITIALIZER
10653 (struct cmd_config_e_tag_result,
10655 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10656 TOKEN_STRING_INITIALIZER
10657 (struct cmd_config_e_tag_result,
10659 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10660 TOKEN_NUM_INITIALIZER
10661 (struct cmd_config_e_tag_result,
10664 /* E-tag insertion configuration */
10666 cmd_config_e_tag_insertion_en_parsed(
10667 void *parsed_result,
10668 __attribute__((unused)) struct cmdline *cl,
10669 __attribute__((unused)) void *data)
10671 struct cmd_config_e_tag_result *res =
10673 struct rte_eth_l2_tunnel_conf entry;
10675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10678 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10679 entry.tunnel_id = res->port_tag_id_val;
10680 entry.vf_id = res->vf_id;
10681 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10683 ETH_L2_TUNNEL_INSERTION_MASK,
10688 cmd_config_e_tag_insertion_dis_parsed(
10689 void *parsed_result,
10690 __attribute__((unused)) struct cmdline *cl,
10691 __attribute__((unused)) void *data)
10693 struct cmd_config_e_tag_result *res =
10695 struct rte_eth_l2_tunnel_conf entry;
10697 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10700 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10701 entry.vf_id = res->vf_id;
10703 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10705 ETH_L2_TUNNEL_INSERTION_MASK,
10709 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10710 .f = cmd_config_e_tag_insertion_en_parsed,
10712 .help_str = "E-tag ... : E-tag insertion enable",
10714 (void *)&cmd_config_e_tag_e_tag,
10715 (void *)&cmd_config_e_tag_set,
10716 (void *)&cmd_config_e_tag_insertion,
10717 (void *)&cmd_config_e_tag_on,
10718 (void *)&cmd_config_e_tag_port_tag_id,
10719 (void *)&cmd_config_e_tag_port_tag_id_val,
10720 (void *)&cmd_config_e_tag_port,
10721 (void *)&cmd_config_e_tag_port_id,
10722 (void *)&cmd_config_e_tag_vf,
10723 (void *)&cmd_config_e_tag_vf_id,
10728 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10729 .f = cmd_config_e_tag_insertion_dis_parsed,
10731 .help_str = "E-tag ... : E-tag insertion disable",
10733 (void *)&cmd_config_e_tag_e_tag,
10734 (void *)&cmd_config_e_tag_set,
10735 (void *)&cmd_config_e_tag_insertion,
10736 (void *)&cmd_config_e_tag_off,
10737 (void *)&cmd_config_e_tag_port,
10738 (void *)&cmd_config_e_tag_port_id,
10739 (void *)&cmd_config_e_tag_vf,
10740 (void *)&cmd_config_e_tag_vf_id,
10745 /* E-tag stripping configuration */
10747 cmd_config_e_tag_stripping_parsed(
10748 void *parsed_result,
10749 __attribute__((unused)) struct cmdline *cl,
10750 __attribute__((unused)) void *data)
10752 struct cmd_config_e_tag_result *res =
10754 struct rte_eth_l2_tunnel_conf entry;
10756 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10759 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10761 if (!strcmp(res->on_off, "on"))
10762 rte_eth_dev_l2_tunnel_offload_set
10765 ETH_L2_TUNNEL_STRIPPING_MASK,
10768 rte_eth_dev_l2_tunnel_offload_set
10771 ETH_L2_TUNNEL_STRIPPING_MASK,
10775 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10776 .f = cmd_config_e_tag_stripping_parsed,
10778 .help_str = "E-tag ... : E-tag stripping enable/disable",
10780 (void *)&cmd_config_e_tag_e_tag,
10781 (void *)&cmd_config_e_tag_set,
10782 (void *)&cmd_config_e_tag_stripping,
10783 (void *)&cmd_config_e_tag_on_off,
10784 (void *)&cmd_config_e_tag_port,
10785 (void *)&cmd_config_e_tag_port_id,
10790 /* E-tag forwarding configuration */
10792 cmd_config_e_tag_forwarding_parsed(
10793 void *parsed_result,
10794 __attribute__((unused)) struct cmdline *cl,
10795 __attribute__((unused)) void *data)
10797 struct cmd_config_e_tag_result *res = parsed_result;
10798 struct rte_eth_l2_tunnel_conf entry;
10800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10803 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10805 if (!strcmp(res->on_off, "on"))
10806 rte_eth_dev_l2_tunnel_offload_set
10809 ETH_L2_TUNNEL_FORWARDING_MASK,
10812 rte_eth_dev_l2_tunnel_offload_set
10815 ETH_L2_TUNNEL_FORWARDING_MASK,
10819 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10820 .f = cmd_config_e_tag_forwarding_parsed,
10822 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10824 (void *)&cmd_config_e_tag_e_tag,
10825 (void *)&cmd_config_e_tag_set,
10826 (void *)&cmd_config_e_tag_forwarding,
10827 (void *)&cmd_config_e_tag_on_off,
10828 (void *)&cmd_config_e_tag_port,
10829 (void *)&cmd_config_e_tag_port_id,
10834 /* E-tag filter configuration */
10836 cmd_config_e_tag_filter_add_parsed(
10837 void *parsed_result,
10838 __attribute__((unused)) struct cmdline *cl,
10839 __attribute__((unused)) void *data)
10841 struct cmd_config_e_tag_result *res = parsed_result;
10842 struct rte_eth_l2_tunnel_conf entry;
10845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10848 if (res->e_tag_id_val > 0x3fff) {
10849 printf("e-tag-id must be equal or less than 0x3fff.\n");
10853 ret = rte_eth_dev_filter_supported(res->port_id,
10854 RTE_ETH_FILTER_L2_TUNNEL);
10856 printf("E-tag filter is not supported on port %u.\n",
10861 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10862 entry.tunnel_id = res->e_tag_id_val;
10863 entry.pool = res->dst_pool_val;
10865 ret = rte_eth_dev_filter_ctrl(res->port_id,
10866 RTE_ETH_FILTER_L2_TUNNEL,
10867 RTE_ETH_FILTER_ADD,
10870 printf("E-tag filter programming error: (%s)\n",
10874 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10875 .f = cmd_config_e_tag_filter_add_parsed,
10877 .help_str = "E-tag ... : E-tag filter add",
10879 (void *)&cmd_config_e_tag_e_tag,
10880 (void *)&cmd_config_e_tag_set,
10881 (void *)&cmd_config_e_tag_filter,
10882 (void *)&cmd_config_e_tag_add,
10883 (void *)&cmd_config_e_tag_e_tag_id,
10884 (void *)&cmd_config_e_tag_e_tag_id_val,
10885 (void *)&cmd_config_e_tag_dst_pool,
10886 (void *)&cmd_config_e_tag_dst_pool_val,
10887 (void *)&cmd_config_e_tag_port,
10888 (void *)&cmd_config_e_tag_port_id,
10894 cmd_config_e_tag_filter_del_parsed(
10895 void *parsed_result,
10896 __attribute__((unused)) struct cmdline *cl,
10897 __attribute__((unused)) void *data)
10899 struct cmd_config_e_tag_result *res = parsed_result;
10900 struct rte_eth_l2_tunnel_conf entry;
10903 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10906 if (res->e_tag_id_val > 0x3fff) {
10907 printf("e-tag-id must be less than 0x3fff.\n");
10911 ret = rte_eth_dev_filter_supported(res->port_id,
10912 RTE_ETH_FILTER_L2_TUNNEL);
10914 printf("E-tag filter is not supported on port %u.\n",
10919 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10920 entry.tunnel_id = res->e_tag_id_val;
10922 ret = rte_eth_dev_filter_ctrl(res->port_id,
10923 RTE_ETH_FILTER_L2_TUNNEL,
10924 RTE_ETH_FILTER_DELETE,
10927 printf("E-tag filter programming error: (%s)\n",
10931 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10932 .f = cmd_config_e_tag_filter_del_parsed,
10934 .help_str = "E-tag ... : E-tag filter delete",
10936 (void *)&cmd_config_e_tag_e_tag,
10937 (void *)&cmd_config_e_tag_set,
10938 (void *)&cmd_config_e_tag_filter,
10939 (void *)&cmd_config_e_tag_del,
10940 (void *)&cmd_config_e_tag_e_tag_id,
10941 (void *)&cmd_config_e_tag_e_tag_id_val,
10942 (void *)&cmd_config_e_tag_port,
10943 (void *)&cmd_config_e_tag_port_id,
10948 /* vf vlan anti spoof configuration */
10950 /* Common result structure for vf vlan anti spoof */
10951 struct cmd_vf_vlan_anti_spoof_result {
10952 cmdline_fixed_string_t set;
10953 cmdline_fixed_string_t vf;
10954 cmdline_fixed_string_t vlan;
10955 cmdline_fixed_string_t antispoof;
10958 cmdline_fixed_string_t on_off;
10961 /* Common CLI fields for vf vlan anti spoof enable disable */
10962 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10963 TOKEN_STRING_INITIALIZER
10964 (struct cmd_vf_vlan_anti_spoof_result,
10966 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10967 TOKEN_STRING_INITIALIZER
10968 (struct cmd_vf_vlan_anti_spoof_result,
10970 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10971 TOKEN_STRING_INITIALIZER
10972 (struct cmd_vf_vlan_anti_spoof_result,
10974 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10975 TOKEN_STRING_INITIALIZER
10976 (struct cmd_vf_vlan_anti_spoof_result,
10977 antispoof, "antispoof");
10978 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10979 TOKEN_NUM_INITIALIZER
10980 (struct cmd_vf_vlan_anti_spoof_result,
10982 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10983 TOKEN_NUM_INITIALIZER
10984 (struct cmd_vf_vlan_anti_spoof_result,
10986 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10987 TOKEN_STRING_INITIALIZER
10988 (struct cmd_vf_vlan_anti_spoof_result,
10992 cmd_set_vf_vlan_anti_spoof_parsed(
10993 void *parsed_result,
10994 __attribute__((unused)) struct cmdline *cl,
10995 __attribute__((unused)) void *data)
10997 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10998 int ret = -ENOTSUP;
11000 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11002 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11005 #ifdef RTE_LIBRTE_IXGBE_PMD
11006 if (ret == -ENOTSUP)
11007 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11008 res->vf_id, is_on);
11010 #ifdef RTE_LIBRTE_I40E_PMD
11011 if (ret == -ENOTSUP)
11012 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11013 res->vf_id, is_on);
11020 printf("invalid vf_id %d\n", res->vf_id);
11023 printf("invalid port_id %d\n", res->port_id);
11026 printf("function not implemented\n");
11029 printf("programming error: (%s)\n", strerror(-ret));
11033 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11034 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11036 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11038 (void *)&cmd_vf_vlan_anti_spoof_set,
11039 (void *)&cmd_vf_vlan_anti_spoof_vf,
11040 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11041 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11042 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11043 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11044 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11049 /* vf mac anti spoof configuration */
11051 /* Common result structure for vf mac anti spoof */
11052 struct cmd_vf_mac_anti_spoof_result {
11053 cmdline_fixed_string_t set;
11054 cmdline_fixed_string_t vf;
11055 cmdline_fixed_string_t mac;
11056 cmdline_fixed_string_t antispoof;
11059 cmdline_fixed_string_t on_off;
11062 /* Common CLI fields for vf mac anti spoof enable disable */
11063 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11064 TOKEN_STRING_INITIALIZER
11065 (struct cmd_vf_mac_anti_spoof_result,
11067 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11068 TOKEN_STRING_INITIALIZER
11069 (struct cmd_vf_mac_anti_spoof_result,
11071 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11072 TOKEN_STRING_INITIALIZER
11073 (struct cmd_vf_mac_anti_spoof_result,
11075 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11076 TOKEN_STRING_INITIALIZER
11077 (struct cmd_vf_mac_anti_spoof_result,
11078 antispoof, "antispoof");
11079 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11080 TOKEN_NUM_INITIALIZER
11081 (struct cmd_vf_mac_anti_spoof_result,
11083 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11084 TOKEN_NUM_INITIALIZER
11085 (struct cmd_vf_mac_anti_spoof_result,
11087 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11088 TOKEN_STRING_INITIALIZER
11089 (struct cmd_vf_mac_anti_spoof_result,
11093 cmd_set_vf_mac_anti_spoof_parsed(
11094 void *parsed_result,
11095 __attribute__((unused)) struct cmdline *cl,
11096 __attribute__((unused)) void *data)
11098 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11099 int ret = -ENOTSUP;
11101 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11103 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11106 #ifdef RTE_LIBRTE_IXGBE_PMD
11107 if (ret == -ENOTSUP)
11108 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11109 res->vf_id, is_on);
11111 #ifdef RTE_LIBRTE_I40E_PMD
11112 if (ret == -ENOTSUP)
11113 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11114 res->vf_id, is_on);
11121 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11124 printf("invalid port_id %d\n", res->port_id);
11127 printf("function not implemented\n");
11130 printf("programming error: (%s)\n", strerror(-ret));
11134 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11135 .f = cmd_set_vf_mac_anti_spoof_parsed,
11137 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11139 (void *)&cmd_vf_mac_anti_spoof_set,
11140 (void *)&cmd_vf_mac_anti_spoof_vf,
11141 (void *)&cmd_vf_mac_anti_spoof_mac,
11142 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11143 (void *)&cmd_vf_mac_anti_spoof_port_id,
11144 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11145 (void *)&cmd_vf_mac_anti_spoof_on_off,
11150 /* vf vlan strip queue configuration */
11152 /* Common result structure for vf mac anti spoof */
11153 struct cmd_vf_vlan_stripq_result {
11154 cmdline_fixed_string_t set;
11155 cmdline_fixed_string_t vf;
11156 cmdline_fixed_string_t vlan;
11157 cmdline_fixed_string_t stripq;
11160 cmdline_fixed_string_t on_off;
11163 /* Common CLI fields for vf vlan strip enable disable */
11164 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11165 TOKEN_STRING_INITIALIZER
11166 (struct cmd_vf_vlan_stripq_result,
11168 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11169 TOKEN_STRING_INITIALIZER
11170 (struct cmd_vf_vlan_stripq_result,
11172 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11173 TOKEN_STRING_INITIALIZER
11174 (struct cmd_vf_vlan_stripq_result,
11176 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11177 TOKEN_STRING_INITIALIZER
11178 (struct cmd_vf_vlan_stripq_result,
11180 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11181 TOKEN_NUM_INITIALIZER
11182 (struct cmd_vf_vlan_stripq_result,
11184 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11185 TOKEN_NUM_INITIALIZER
11186 (struct cmd_vf_vlan_stripq_result,
11188 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11189 TOKEN_STRING_INITIALIZER
11190 (struct cmd_vf_vlan_stripq_result,
11194 cmd_set_vf_vlan_stripq_parsed(
11195 void *parsed_result,
11196 __attribute__((unused)) struct cmdline *cl,
11197 __attribute__((unused)) void *data)
11199 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11200 int ret = -ENOTSUP;
11202 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11207 #ifdef RTE_LIBRTE_IXGBE_PMD
11208 if (ret == -ENOTSUP)
11209 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11210 res->vf_id, is_on);
11212 #ifdef RTE_LIBRTE_I40E_PMD
11213 if (ret == -ENOTSUP)
11214 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11215 res->vf_id, is_on);
11222 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11225 printf("invalid port_id %d\n", res->port_id);
11228 printf("function not implemented\n");
11231 printf("programming error: (%s)\n", strerror(-ret));
11235 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11236 .f = cmd_set_vf_vlan_stripq_parsed,
11238 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11240 (void *)&cmd_vf_vlan_stripq_set,
11241 (void *)&cmd_vf_vlan_stripq_vf,
11242 (void *)&cmd_vf_vlan_stripq_vlan,
11243 (void *)&cmd_vf_vlan_stripq_stripq,
11244 (void *)&cmd_vf_vlan_stripq_port_id,
11245 (void *)&cmd_vf_vlan_stripq_vf_id,
11246 (void *)&cmd_vf_vlan_stripq_on_off,
11251 /* vf vlan insert configuration */
11253 /* Common result structure for vf vlan insert */
11254 struct cmd_vf_vlan_insert_result {
11255 cmdline_fixed_string_t set;
11256 cmdline_fixed_string_t vf;
11257 cmdline_fixed_string_t vlan;
11258 cmdline_fixed_string_t insert;
11264 /* Common CLI fields for vf vlan insert enable disable */
11265 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11266 TOKEN_STRING_INITIALIZER
11267 (struct cmd_vf_vlan_insert_result,
11269 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11270 TOKEN_STRING_INITIALIZER
11271 (struct cmd_vf_vlan_insert_result,
11273 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11274 TOKEN_STRING_INITIALIZER
11275 (struct cmd_vf_vlan_insert_result,
11277 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11278 TOKEN_STRING_INITIALIZER
11279 (struct cmd_vf_vlan_insert_result,
11281 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11282 TOKEN_NUM_INITIALIZER
11283 (struct cmd_vf_vlan_insert_result,
11285 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11286 TOKEN_NUM_INITIALIZER
11287 (struct cmd_vf_vlan_insert_result,
11289 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11290 TOKEN_NUM_INITIALIZER
11291 (struct cmd_vf_vlan_insert_result,
11295 cmd_set_vf_vlan_insert_parsed(
11296 void *parsed_result,
11297 __attribute__((unused)) struct cmdline *cl,
11298 __attribute__((unused)) void *data)
11300 struct cmd_vf_vlan_insert_result *res = parsed_result;
11301 int ret = -ENOTSUP;
11303 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11306 #ifdef RTE_LIBRTE_IXGBE_PMD
11307 if (ret == -ENOTSUP)
11308 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11311 #ifdef RTE_LIBRTE_I40E_PMD
11312 if (ret == -ENOTSUP)
11313 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11321 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11324 printf("invalid port_id %d\n", res->port_id);
11327 printf("function not implemented\n");
11330 printf("programming error: (%s)\n", strerror(-ret));
11334 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11335 .f = cmd_set_vf_vlan_insert_parsed,
11337 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11339 (void *)&cmd_vf_vlan_insert_set,
11340 (void *)&cmd_vf_vlan_insert_vf,
11341 (void *)&cmd_vf_vlan_insert_vlan,
11342 (void *)&cmd_vf_vlan_insert_insert,
11343 (void *)&cmd_vf_vlan_insert_port_id,
11344 (void *)&cmd_vf_vlan_insert_vf_id,
11345 (void *)&cmd_vf_vlan_insert_vlan_id,
11350 /* tx loopback configuration */
11352 /* Common result structure for tx loopback */
11353 struct cmd_tx_loopback_result {
11354 cmdline_fixed_string_t set;
11355 cmdline_fixed_string_t tx;
11356 cmdline_fixed_string_t loopback;
11358 cmdline_fixed_string_t on_off;
11361 /* Common CLI fields for tx loopback enable disable */
11362 cmdline_parse_token_string_t cmd_tx_loopback_set =
11363 TOKEN_STRING_INITIALIZER
11364 (struct cmd_tx_loopback_result,
11366 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11367 TOKEN_STRING_INITIALIZER
11368 (struct cmd_tx_loopback_result,
11370 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11371 TOKEN_STRING_INITIALIZER
11372 (struct cmd_tx_loopback_result,
11373 loopback, "loopback");
11374 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11375 TOKEN_NUM_INITIALIZER
11376 (struct cmd_tx_loopback_result,
11378 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11379 TOKEN_STRING_INITIALIZER
11380 (struct cmd_tx_loopback_result,
11384 cmd_set_tx_loopback_parsed(
11385 void *parsed_result,
11386 __attribute__((unused)) struct cmdline *cl,
11387 __attribute__((unused)) void *data)
11389 struct cmd_tx_loopback_result *res = parsed_result;
11390 int ret = -ENOTSUP;
11392 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11397 #ifdef RTE_LIBRTE_IXGBE_PMD
11398 if (ret == -ENOTSUP)
11399 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11401 #ifdef RTE_LIBRTE_I40E_PMD
11402 if (ret == -ENOTSUP)
11403 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11410 printf("invalid is_on %d\n", is_on);
11413 printf("invalid port_id %d\n", res->port_id);
11416 printf("function not implemented\n");
11419 printf("programming error: (%s)\n", strerror(-ret));
11423 cmdline_parse_inst_t cmd_set_tx_loopback = {
11424 .f = cmd_set_tx_loopback_parsed,
11426 .help_str = "set tx loopback <port_id> on|off",
11428 (void *)&cmd_tx_loopback_set,
11429 (void *)&cmd_tx_loopback_tx,
11430 (void *)&cmd_tx_loopback_loopback,
11431 (void *)&cmd_tx_loopback_port_id,
11432 (void *)&cmd_tx_loopback_on_off,
11437 #ifdef RTE_LIBRTE_IXGBE_PMD
11438 /* all queues drop enable configuration */
11440 /* Common result structure for all queues drop enable */
11441 struct cmd_all_queues_drop_en_result {
11442 cmdline_fixed_string_t set;
11443 cmdline_fixed_string_t all;
11444 cmdline_fixed_string_t queues;
11445 cmdline_fixed_string_t drop;
11447 cmdline_fixed_string_t on_off;
11450 /* Common CLI fields for tx loopback enable disable */
11451 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11452 TOKEN_STRING_INITIALIZER
11453 (struct cmd_all_queues_drop_en_result,
11455 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11456 TOKEN_STRING_INITIALIZER
11457 (struct cmd_all_queues_drop_en_result,
11459 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11460 TOKEN_STRING_INITIALIZER
11461 (struct cmd_all_queues_drop_en_result,
11463 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11464 TOKEN_STRING_INITIALIZER
11465 (struct cmd_all_queues_drop_en_result,
11467 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11468 TOKEN_NUM_INITIALIZER
11469 (struct cmd_all_queues_drop_en_result,
11471 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11472 TOKEN_STRING_INITIALIZER
11473 (struct cmd_all_queues_drop_en_result,
11477 cmd_set_all_queues_drop_en_parsed(
11478 void *parsed_result,
11479 __attribute__((unused)) struct cmdline *cl,
11480 __attribute__((unused)) void *data)
11482 struct cmd_all_queues_drop_en_result *res = parsed_result;
11484 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11486 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11489 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11494 printf("invalid is_on %d\n", is_on);
11497 printf("invalid port_id %d\n", res->port_id);
11500 printf("function not implemented\n");
11503 printf("programming error: (%s)\n", strerror(-ret));
11507 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11508 .f = cmd_set_all_queues_drop_en_parsed,
11510 .help_str = "set all queues drop <port_id> on|off",
11512 (void *)&cmd_all_queues_drop_en_set,
11513 (void *)&cmd_all_queues_drop_en_all,
11514 (void *)&cmd_all_queues_drop_en_queues,
11515 (void *)&cmd_all_queues_drop_en_drop,
11516 (void *)&cmd_all_queues_drop_en_port_id,
11517 (void *)&cmd_all_queues_drop_en_on_off,
11522 /* vf split drop enable configuration */
11524 /* Common result structure for vf split drop enable */
11525 struct cmd_vf_split_drop_en_result {
11526 cmdline_fixed_string_t set;
11527 cmdline_fixed_string_t vf;
11528 cmdline_fixed_string_t split;
11529 cmdline_fixed_string_t drop;
11532 cmdline_fixed_string_t on_off;
11535 /* Common CLI fields for vf split drop enable disable */
11536 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11537 TOKEN_STRING_INITIALIZER
11538 (struct cmd_vf_split_drop_en_result,
11540 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11541 TOKEN_STRING_INITIALIZER
11542 (struct cmd_vf_split_drop_en_result,
11544 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11545 TOKEN_STRING_INITIALIZER
11546 (struct cmd_vf_split_drop_en_result,
11548 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11549 TOKEN_STRING_INITIALIZER
11550 (struct cmd_vf_split_drop_en_result,
11552 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11553 TOKEN_NUM_INITIALIZER
11554 (struct cmd_vf_split_drop_en_result,
11556 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11557 TOKEN_NUM_INITIALIZER
11558 (struct cmd_vf_split_drop_en_result,
11560 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11561 TOKEN_STRING_INITIALIZER
11562 (struct cmd_vf_split_drop_en_result,
11566 cmd_set_vf_split_drop_en_parsed(
11567 void *parsed_result,
11568 __attribute__((unused)) struct cmdline *cl,
11569 __attribute__((unused)) void *data)
11571 struct cmd_vf_split_drop_en_result *res = parsed_result;
11573 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11575 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11578 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11584 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11587 printf("invalid port_id %d\n", res->port_id);
11590 printf("programming error: (%s)\n", strerror(-ret));
11594 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11595 .f = cmd_set_vf_split_drop_en_parsed,
11597 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11599 (void *)&cmd_vf_split_drop_en_set,
11600 (void *)&cmd_vf_split_drop_en_vf,
11601 (void *)&cmd_vf_split_drop_en_split,
11602 (void *)&cmd_vf_split_drop_en_drop,
11603 (void *)&cmd_vf_split_drop_en_port_id,
11604 (void *)&cmd_vf_split_drop_en_vf_id,
11605 (void *)&cmd_vf_split_drop_en_on_off,
11611 /* vf mac address configuration */
11613 /* Common result structure for vf mac address */
11614 struct cmd_set_vf_mac_addr_result {
11615 cmdline_fixed_string_t set;
11616 cmdline_fixed_string_t vf;
11617 cmdline_fixed_string_t mac;
11618 cmdline_fixed_string_t addr;
11621 struct ether_addr mac_addr;
11625 /* Common CLI fields for vf split drop enable disable */
11626 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11627 TOKEN_STRING_INITIALIZER
11628 (struct cmd_set_vf_mac_addr_result,
11630 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11631 TOKEN_STRING_INITIALIZER
11632 (struct cmd_set_vf_mac_addr_result,
11634 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11635 TOKEN_STRING_INITIALIZER
11636 (struct cmd_set_vf_mac_addr_result,
11638 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11639 TOKEN_STRING_INITIALIZER
11640 (struct cmd_set_vf_mac_addr_result,
11642 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11643 TOKEN_NUM_INITIALIZER
11644 (struct cmd_set_vf_mac_addr_result,
11646 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11647 TOKEN_NUM_INITIALIZER
11648 (struct cmd_set_vf_mac_addr_result,
11650 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11651 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11655 cmd_set_vf_mac_addr_parsed(
11656 void *parsed_result,
11657 __attribute__((unused)) struct cmdline *cl,
11658 __attribute__((unused)) void *data)
11660 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11661 int ret = -ENOTSUP;
11663 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11666 #ifdef RTE_LIBRTE_IXGBE_PMD
11667 if (ret == -ENOTSUP)
11668 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11671 #ifdef RTE_LIBRTE_I40E_PMD
11672 if (ret == -ENOTSUP)
11673 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11681 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11684 printf("invalid port_id %d\n", res->port_id);
11687 printf("function not implemented\n");
11690 printf("programming error: (%s)\n", strerror(-ret));
11694 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11695 .f = cmd_set_vf_mac_addr_parsed,
11697 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11699 (void *)&cmd_set_vf_mac_addr_set,
11700 (void *)&cmd_set_vf_mac_addr_vf,
11701 (void *)&cmd_set_vf_mac_addr_mac,
11702 (void *)&cmd_set_vf_mac_addr_addr,
11703 (void *)&cmd_set_vf_mac_addr_port_id,
11704 (void *)&cmd_set_vf_mac_addr_vf_id,
11705 (void *)&cmd_set_vf_mac_addr_mac_addr,
11710 #ifdef RTE_LIBRTE_IXGBE_PMD
11711 /* MACsec configuration */
11713 /* Common result structure for MACsec offload enable */
11714 struct cmd_macsec_offload_on_result {
11715 cmdline_fixed_string_t set;
11716 cmdline_fixed_string_t macsec;
11717 cmdline_fixed_string_t offload;
11719 cmdline_fixed_string_t on;
11720 cmdline_fixed_string_t encrypt;
11721 cmdline_fixed_string_t en_on_off;
11722 cmdline_fixed_string_t replay_protect;
11723 cmdline_fixed_string_t rp_on_off;
11726 /* Common CLI fields for MACsec offload disable */
11727 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11728 TOKEN_STRING_INITIALIZER
11729 (struct cmd_macsec_offload_on_result,
11731 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11732 TOKEN_STRING_INITIALIZER
11733 (struct cmd_macsec_offload_on_result,
11735 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11736 TOKEN_STRING_INITIALIZER
11737 (struct cmd_macsec_offload_on_result,
11738 offload, "offload");
11739 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11740 TOKEN_NUM_INITIALIZER
11741 (struct cmd_macsec_offload_on_result,
11743 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11744 TOKEN_STRING_INITIALIZER
11745 (struct cmd_macsec_offload_on_result,
11747 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11748 TOKEN_STRING_INITIALIZER
11749 (struct cmd_macsec_offload_on_result,
11750 encrypt, "encrypt");
11751 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11752 TOKEN_STRING_INITIALIZER
11753 (struct cmd_macsec_offload_on_result,
11754 en_on_off, "on#off");
11755 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11756 TOKEN_STRING_INITIALIZER
11757 (struct cmd_macsec_offload_on_result,
11758 replay_protect, "replay-protect");
11759 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11760 TOKEN_STRING_INITIALIZER
11761 (struct cmd_macsec_offload_on_result,
11762 rp_on_off, "on#off");
11765 cmd_set_macsec_offload_on_parsed(
11766 void *parsed_result,
11767 __attribute__((unused)) struct cmdline *cl,
11768 __attribute__((unused)) void *data)
11770 struct cmd_macsec_offload_on_result *res = parsed_result;
11772 portid_t port_id = res->port_id;
11773 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11774 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11776 if (port_id_is_invalid(port_id, ENABLED_WARN))
11779 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11780 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11786 printf("invalid port_id %d\n", port_id);
11789 printf("programming error: (%s)\n", strerror(-ret));
11793 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11794 .f = cmd_set_macsec_offload_on_parsed,
11796 .help_str = "set macsec offload <port_id> on "
11797 "encrypt on|off replay-protect on|off",
11799 (void *)&cmd_macsec_offload_on_set,
11800 (void *)&cmd_macsec_offload_on_macsec,
11801 (void *)&cmd_macsec_offload_on_offload,
11802 (void *)&cmd_macsec_offload_on_port_id,
11803 (void *)&cmd_macsec_offload_on_on,
11804 (void *)&cmd_macsec_offload_on_encrypt,
11805 (void *)&cmd_macsec_offload_on_en_on_off,
11806 (void *)&cmd_macsec_offload_on_replay_protect,
11807 (void *)&cmd_macsec_offload_on_rp_on_off,
11812 /* Common result structure for MACsec offload disable */
11813 struct cmd_macsec_offload_off_result {
11814 cmdline_fixed_string_t set;
11815 cmdline_fixed_string_t macsec;
11816 cmdline_fixed_string_t offload;
11818 cmdline_fixed_string_t off;
11821 /* Common CLI fields for MACsec offload disable */
11822 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11823 TOKEN_STRING_INITIALIZER
11824 (struct cmd_macsec_offload_off_result,
11826 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11827 TOKEN_STRING_INITIALIZER
11828 (struct cmd_macsec_offload_off_result,
11830 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11831 TOKEN_STRING_INITIALIZER
11832 (struct cmd_macsec_offload_off_result,
11833 offload, "offload");
11834 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11835 TOKEN_NUM_INITIALIZER
11836 (struct cmd_macsec_offload_off_result,
11838 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11839 TOKEN_STRING_INITIALIZER
11840 (struct cmd_macsec_offload_off_result,
11844 cmd_set_macsec_offload_off_parsed(
11845 void *parsed_result,
11846 __attribute__((unused)) struct cmdline *cl,
11847 __attribute__((unused)) void *data)
11849 struct cmd_macsec_offload_off_result *res = parsed_result;
11851 portid_t port_id = res->port_id;
11853 if (port_id_is_invalid(port_id, ENABLED_WARN))
11856 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11857 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11863 printf("invalid port_id %d\n", port_id);
11866 printf("programming error: (%s)\n", strerror(-ret));
11870 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11871 .f = cmd_set_macsec_offload_off_parsed,
11873 .help_str = "set macsec offload <port_id> off",
11875 (void *)&cmd_macsec_offload_off_set,
11876 (void *)&cmd_macsec_offload_off_macsec,
11877 (void *)&cmd_macsec_offload_off_offload,
11878 (void *)&cmd_macsec_offload_off_port_id,
11879 (void *)&cmd_macsec_offload_off_off,
11884 /* Common result structure for MACsec secure connection configure */
11885 struct cmd_macsec_sc_result {
11886 cmdline_fixed_string_t set;
11887 cmdline_fixed_string_t macsec;
11888 cmdline_fixed_string_t sc;
11889 cmdline_fixed_string_t tx_rx;
11891 struct ether_addr mac;
11895 /* Common CLI fields for MACsec secure connection configure */
11896 cmdline_parse_token_string_t cmd_macsec_sc_set =
11897 TOKEN_STRING_INITIALIZER
11898 (struct cmd_macsec_sc_result,
11900 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11901 TOKEN_STRING_INITIALIZER
11902 (struct cmd_macsec_sc_result,
11904 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11905 TOKEN_STRING_INITIALIZER
11906 (struct cmd_macsec_sc_result,
11908 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11909 TOKEN_STRING_INITIALIZER
11910 (struct cmd_macsec_sc_result,
11912 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11913 TOKEN_NUM_INITIALIZER
11914 (struct cmd_macsec_sc_result,
11916 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11917 TOKEN_ETHERADDR_INITIALIZER
11918 (struct cmd_macsec_sc_result,
11920 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11921 TOKEN_NUM_INITIALIZER
11922 (struct cmd_macsec_sc_result,
11926 cmd_set_macsec_sc_parsed(
11927 void *parsed_result,
11928 __attribute__((unused)) struct cmdline *cl,
11929 __attribute__((unused)) void *data)
11931 struct cmd_macsec_sc_result *res = parsed_result;
11933 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11936 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11937 res->mac.addr_bytes) :
11938 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11939 res->mac.addr_bytes, res->pi);
11944 printf("invalid port_id %d\n", res->port_id);
11947 printf("programming error: (%s)\n", strerror(-ret));
11951 cmdline_parse_inst_t cmd_set_macsec_sc = {
11952 .f = cmd_set_macsec_sc_parsed,
11954 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11956 (void *)&cmd_macsec_sc_set,
11957 (void *)&cmd_macsec_sc_macsec,
11958 (void *)&cmd_macsec_sc_sc,
11959 (void *)&cmd_macsec_sc_tx_rx,
11960 (void *)&cmd_macsec_sc_port_id,
11961 (void *)&cmd_macsec_sc_mac,
11962 (void *)&cmd_macsec_sc_pi,
11967 /* Common result structure for MACsec secure connection configure */
11968 struct cmd_macsec_sa_result {
11969 cmdline_fixed_string_t set;
11970 cmdline_fixed_string_t macsec;
11971 cmdline_fixed_string_t sa;
11972 cmdline_fixed_string_t tx_rx;
11977 cmdline_fixed_string_t key;
11980 /* Common CLI fields for MACsec secure connection configure */
11981 cmdline_parse_token_string_t cmd_macsec_sa_set =
11982 TOKEN_STRING_INITIALIZER
11983 (struct cmd_macsec_sa_result,
11985 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11986 TOKEN_STRING_INITIALIZER
11987 (struct cmd_macsec_sa_result,
11989 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11990 TOKEN_STRING_INITIALIZER
11991 (struct cmd_macsec_sa_result,
11993 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11994 TOKEN_STRING_INITIALIZER
11995 (struct cmd_macsec_sa_result,
11997 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11998 TOKEN_NUM_INITIALIZER
11999 (struct cmd_macsec_sa_result,
12001 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12002 TOKEN_NUM_INITIALIZER
12003 (struct cmd_macsec_sa_result,
12005 cmdline_parse_token_num_t cmd_macsec_sa_an =
12006 TOKEN_NUM_INITIALIZER
12007 (struct cmd_macsec_sa_result,
12009 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12010 TOKEN_NUM_INITIALIZER
12011 (struct cmd_macsec_sa_result,
12013 cmdline_parse_token_string_t cmd_macsec_sa_key =
12014 TOKEN_STRING_INITIALIZER
12015 (struct cmd_macsec_sa_result,
12019 cmd_set_macsec_sa_parsed(
12020 void *parsed_result,
12021 __attribute__((unused)) struct cmdline *cl,
12022 __attribute__((unused)) void *data)
12024 struct cmd_macsec_sa_result *res = parsed_result;
12026 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12027 uint8_t key[16] = { 0 };
12033 key_len = strlen(res->key) / 2;
12037 for (i = 0; i < key_len; i++) {
12038 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12041 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12044 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12048 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12049 res->idx, res->an, res->pn, key) :
12050 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12051 res->idx, res->an, res->pn, key);
12056 printf("invalid idx %d or an %d\n", res->idx, res->an);
12059 printf("invalid port_id %d\n", res->port_id);
12062 printf("programming error: (%s)\n", strerror(-ret));
12066 cmdline_parse_inst_t cmd_set_macsec_sa = {
12067 .f = cmd_set_macsec_sa_parsed,
12069 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12071 (void *)&cmd_macsec_sa_set,
12072 (void *)&cmd_macsec_sa_macsec,
12073 (void *)&cmd_macsec_sa_sa,
12074 (void *)&cmd_macsec_sa_tx_rx,
12075 (void *)&cmd_macsec_sa_port_id,
12076 (void *)&cmd_macsec_sa_idx,
12077 (void *)&cmd_macsec_sa_an,
12078 (void *)&cmd_macsec_sa_pn,
12079 (void *)&cmd_macsec_sa_key,
12085 /* VF unicast promiscuous mode configuration */
12087 /* Common result structure for VF unicast promiscuous mode */
12088 struct cmd_vf_promisc_result {
12089 cmdline_fixed_string_t set;
12090 cmdline_fixed_string_t vf;
12091 cmdline_fixed_string_t promisc;
12094 cmdline_fixed_string_t on_off;
12097 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12098 cmdline_parse_token_string_t cmd_vf_promisc_set =
12099 TOKEN_STRING_INITIALIZER
12100 (struct cmd_vf_promisc_result,
12102 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12103 TOKEN_STRING_INITIALIZER
12104 (struct cmd_vf_promisc_result,
12106 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12107 TOKEN_STRING_INITIALIZER
12108 (struct cmd_vf_promisc_result,
12109 promisc, "promisc");
12110 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12111 TOKEN_NUM_INITIALIZER
12112 (struct cmd_vf_promisc_result,
12114 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12115 TOKEN_NUM_INITIALIZER
12116 (struct cmd_vf_promisc_result,
12118 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12119 TOKEN_STRING_INITIALIZER
12120 (struct cmd_vf_promisc_result,
12124 cmd_set_vf_promisc_parsed(
12125 void *parsed_result,
12126 __attribute__((unused)) struct cmdline *cl,
12127 __attribute__((unused)) void *data)
12129 struct cmd_vf_promisc_result *res = parsed_result;
12130 int ret = -ENOTSUP;
12132 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12134 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12137 #ifdef RTE_LIBRTE_I40E_PMD
12138 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12139 res->vf_id, is_on);
12146 printf("invalid vf_id %d\n", res->vf_id);
12149 printf("invalid port_id %d\n", res->port_id);
12152 printf("function not implemented\n");
12155 printf("programming error: (%s)\n", strerror(-ret));
12159 cmdline_parse_inst_t cmd_set_vf_promisc = {
12160 .f = cmd_set_vf_promisc_parsed,
12162 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12163 "Set unicast promiscuous mode for a VF from the PF",
12165 (void *)&cmd_vf_promisc_set,
12166 (void *)&cmd_vf_promisc_vf,
12167 (void *)&cmd_vf_promisc_promisc,
12168 (void *)&cmd_vf_promisc_port_id,
12169 (void *)&cmd_vf_promisc_vf_id,
12170 (void *)&cmd_vf_promisc_on_off,
12175 /* VF multicast promiscuous mode configuration */
12177 /* Common result structure for VF multicast promiscuous mode */
12178 struct cmd_vf_allmulti_result {
12179 cmdline_fixed_string_t set;
12180 cmdline_fixed_string_t vf;
12181 cmdline_fixed_string_t allmulti;
12184 cmdline_fixed_string_t on_off;
12187 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12188 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12189 TOKEN_STRING_INITIALIZER
12190 (struct cmd_vf_allmulti_result,
12192 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12193 TOKEN_STRING_INITIALIZER
12194 (struct cmd_vf_allmulti_result,
12196 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12197 TOKEN_STRING_INITIALIZER
12198 (struct cmd_vf_allmulti_result,
12199 allmulti, "allmulti");
12200 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12201 TOKEN_NUM_INITIALIZER
12202 (struct cmd_vf_allmulti_result,
12204 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12205 TOKEN_NUM_INITIALIZER
12206 (struct cmd_vf_allmulti_result,
12208 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12209 TOKEN_STRING_INITIALIZER
12210 (struct cmd_vf_allmulti_result,
12214 cmd_set_vf_allmulti_parsed(
12215 void *parsed_result,
12216 __attribute__((unused)) struct cmdline *cl,
12217 __attribute__((unused)) void *data)
12219 struct cmd_vf_allmulti_result *res = parsed_result;
12220 int ret = -ENOTSUP;
12222 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12227 #ifdef RTE_LIBRTE_I40E_PMD
12228 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12229 res->vf_id, is_on);
12236 printf("invalid vf_id %d\n", res->vf_id);
12239 printf("invalid port_id %d\n", res->port_id);
12242 printf("function not implemented\n");
12245 printf("programming error: (%s)\n", strerror(-ret));
12249 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12250 .f = cmd_set_vf_allmulti_parsed,
12252 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12253 "Set multicast promiscuous mode for a VF from the PF",
12255 (void *)&cmd_vf_allmulti_set,
12256 (void *)&cmd_vf_allmulti_vf,
12257 (void *)&cmd_vf_allmulti_allmulti,
12258 (void *)&cmd_vf_allmulti_port_id,
12259 (void *)&cmd_vf_allmulti_vf_id,
12260 (void *)&cmd_vf_allmulti_on_off,
12265 /* vf broadcast mode configuration */
12267 /* Common result structure for vf broadcast */
12268 struct cmd_set_vf_broadcast_result {
12269 cmdline_fixed_string_t set;
12270 cmdline_fixed_string_t vf;
12271 cmdline_fixed_string_t broadcast;
12274 cmdline_fixed_string_t on_off;
12277 /* Common CLI fields for vf broadcast enable disable */
12278 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12279 TOKEN_STRING_INITIALIZER
12280 (struct cmd_set_vf_broadcast_result,
12282 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12283 TOKEN_STRING_INITIALIZER
12284 (struct cmd_set_vf_broadcast_result,
12286 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12287 TOKEN_STRING_INITIALIZER
12288 (struct cmd_set_vf_broadcast_result,
12289 broadcast, "broadcast");
12290 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12291 TOKEN_NUM_INITIALIZER
12292 (struct cmd_set_vf_broadcast_result,
12294 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12295 TOKEN_NUM_INITIALIZER
12296 (struct cmd_set_vf_broadcast_result,
12298 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12299 TOKEN_STRING_INITIALIZER
12300 (struct cmd_set_vf_broadcast_result,
12304 cmd_set_vf_broadcast_parsed(
12305 void *parsed_result,
12306 __attribute__((unused)) struct cmdline *cl,
12307 __attribute__((unused)) void *data)
12309 struct cmd_set_vf_broadcast_result *res = parsed_result;
12310 int ret = -ENOTSUP;
12312 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12314 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12317 #ifdef RTE_LIBRTE_I40E_PMD
12318 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12319 res->vf_id, is_on);
12326 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12329 printf("invalid port_id %d\n", res->port_id);
12332 printf("function not implemented\n");
12335 printf("programming error: (%s)\n", strerror(-ret));
12339 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12340 .f = cmd_set_vf_broadcast_parsed,
12342 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12344 (void *)&cmd_set_vf_broadcast_set,
12345 (void *)&cmd_set_vf_broadcast_vf,
12346 (void *)&cmd_set_vf_broadcast_broadcast,
12347 (void *)&cmd_set_vf_broadcast_port_id,
12348 (void *)&cmd_set_vf_broadcast_vf_id,
12349 (void *)&cmd_set_vf_broadcast_on_off,
12354 /* vf vlan tag configuration */
12356 /* Common result structure for vf vlan tag */
12357 struct cmd_set_vf_vlan_tag_result {
12358 cmdline_fixed_string_t set;
12359 cmdline_fixed_string_t vf;
12360 cmdline_fixed_string_t vlan;
12361 cmdline_fixed_string_t tag;
12364 cmdline_fixed_string_t on_off;
12367 /* Common CLI fields for vf vlan tag enable disable */
12368 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12369 TOKEN_STRING_INITIALIZER
12370 (struct cmd_set_vf_vlan_tag_result,
12372 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12373 TOKEN_STRING_INITIALIZER
12374 (struct cmd_set_vf_vlan_tag_result,
12376 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_set_vf_vlan_tag_result,
12380 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12381 TOKEN_STRING_INITIALIZER
12382 (struct cmd_set_vf_vlan_tag_result,
12384 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12385 TOKEN_NUM_INITIALIZER
12386 (struct cmd_set_vf_vlan_tag_result,
12388 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12389 TOKEN_NUM_INITIALIZER
12390 (struct cmd_set_vf_vlan_tag_result,
12392 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12393 TOKEN_STRING_INITIALIZER
12394 (struct cmd_set_vf_vlan_tag_result,
12398 cmd_set_vf_vlan_tag_parsed(
12399 void *parsed_result,
12400 __attribute__((unused)) struct cmdline *cl,
12401 __attribute__((unused)) void *data)
12403 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12404 int ret = -ENOTSUP;
12406 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12408 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12411 #ifdef RTE_LIBRTE_I40E_PMD
12412 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12413 res->vf_id, is_on);
12420 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12423 printf("invalid port_id %d\n", res->port_id);
12426 printf("function not implemented\n");
12429 printf("programming error: (%s)\n", strerror(-ret));
12433 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12434 .f = cmd_set_vf_vlan_tag_parsed,
12436 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12438 (void *)&cmd_set_vf_vlan_tag_set,
12439 (void *)&cmd_set_vf_vlan_tag_vf,
12440 (void *)&cmd_set_vf_vlan_tag_vlan,
12441 (void *)&cmd_set_vf_vlan_tag_tag,
12442 (void *)&cmd_set_vf_vlan_tag_port_id,
12443 (void *)&cmd_set_vf_vlan_tag_vf_id,
12444 (void *)&cmd_set_vf_vlan_tag_on_off,
12449 /* Common definition of VF and TC TX bandwidth configuration */
12450 struct cmd_vf_tc_bw_result {
12451 cmdline_fixed_string_t set;
12452 cmdline_fixed_string_t vf;
12453 cmdline_fixed_string_t tc;
12454 cmdline_fixed_string_t tx;
12455 cmdline_fixed_string_t min_bw;
12456 cmdline_fixed_string_t max_bw;
12457 cmdline_fixed_string_t strict_link_prio;
12462 cmdline_fixed_string_t bw_list;
12466 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12467 TOKEN_STRING_INITIALIZER
12468 (struct cmd_vf_tc_bw_result,
12470 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12471 TOKEN_STRING_INITIALIZER
12472 (struct cmd_vf_tc_bw_result,
12474 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12475 TOKEN_STRING_INITIALIZER
12476 (struct cmd_vf_tc_bw_result,
12478 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12479 TOKEN_STRING_INITIALIZER
12480 (struct cmd_vf_tc_bw_result,
12482 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12483 TOKEN_STRING_INITIALIZER
12484 (struct cmd_vf_tc_bw_result,
12485 strict_link_prio, "strict-link-priority");
12486 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12487 TOKEN_STRING_INITIALIZER
12488 (struct cmd_vf_tc_bw_result,
12489 min_bw, "min-bandwidth");
12490 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12491 TOKEN_STRING_INITIALIZER
12492 (struct cmd_vf_tc_bw_result,
12493 max_bw, "max-bandwidth");
12494 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12495 TOKEN_NUM_INITIALIZER
12496 (struct cmd_vf_tc_bw_result,
12498 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12499 TOKEN_NUM_INITIALIZER
12500 (struct cmd_vf_tc_bw_result,
12502 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12503 TOKEN_NUM_INITIALIZER
12504 (struct cmd_vf_tc_bw_result,
12506 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12507 TOKEN_NUM_INITIALIZER
12508 (struct cmd_vf_tc_bw_result,
12510 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12511 TOKEN_STRING_INITIALIZER
12512 (struct cmd_vf_tc_bw_result,
12514 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12515 TOKEN_NUM_INITIALIZER
12516 (struct cmd_vf_tc_bw_result,
12519 /* VF max bandwidth setting */
12521 cmd_vf_max_bw_parsed(
12522 void *parsed_result,
12523 __attribute__((unused)) struct cmdline *cl,
12524 __attribute__((unused)) void *data)
12526 struct cmd_vf_tc_bw_result *res = parsed_result;
12527 int ret = -ENOTSUP;
12529 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12532 #ifdef RTE_LIBRTE_I40E_PMD
12533 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12534 res->vf_id, res->bw);
12541 printf("invalid vf_id %d or bandwidth %d\n",
12542 res->vf_id, res->bw);
12545 printf("invalid port_id %d\n", res->port_id);
12548 printf("function not implemented\n");
12551 printf("programming error: (%s)\n", strerror(-ret));
12555 cmdline_parse_inst_t cmd_vf_max_bw = {
12556 .f = cmd_vf_max_bw_parsed,
12558 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12560 (void *)&cmd_vf_tc_bw_set,
12561 (void *)&cmd_vf_tc_bw_vf,
12562 (void *)&cmd_vf_tc_bw_tx,
12563 (void *)&cmd_vf_tc_bw_max_bw,
12564 (void *)&cmd_vf_tc_bw_port_id,
12565 (void *)&cmd_vf_tc_bw_vf_id,
12566 (void *)&cmd_vf_tc_bw_bw,
12572 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12577 const char *p, *p0 = str;
12584 p = strchr(p0, '(');
12586 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12590 p0 = strchr(p, ')');
12592 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12596 if (size >= sizeof(s)) {
12597 printf("The string size exceeds the internal buffer size\n");
12600 snprintf(s, sizeof(s), "%.*s", size, p);
12601 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12603 printf("Failed to get the bandwidth list. ");
12607 for (i = 0; i < ret; i++)
12608 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12613 /* TC min bandwidth setting */
12615 cmd_vf_tc_min_bw_parsed(
12616 void *parsed_result,
12617 __attribute__((unused)) struct cmdline *cl,
12618 __attribute__((unused)) void *data)
12620 struct cmd_vf_tc_bw_result *res = parsed_result;
12623 int ret = -ENOTSUP;
12625 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12628 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12632 #ifdef RTE_LIBRTE_I40E_PMD
12633 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12641 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12644 printf("invalid port_id %d\n", res->port_id);
12647 printf("function not implemented\n");
12650 printf("programming error: (%s)\n", strerror(-ret));
12654 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12655 .f = cmd_vf_tc_min_bw_parsed,
12657 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12658 " <bw1, bw2, ...>",
12660 (void *)&cmd_vf_tc_bw_set,
12661 (void *)&cmd_vf_tc_bw_vf,
12662 (void *)&cmd_vf_tc_bw_tc,
12663 (void *)&cmd_vf_tc_bw_tx,
12664 (void *)&cmd_vf_tc_bw_min_bw,
12665 (void *)&cmd_vf_tc_bw_port_id,
12666 (void *)&cmd_vf_tc_bw_vf_id,
12667 (void *)&cmd_vf_tc_bw_bw_list,
12673 cmd_tc_min_bw_parsed(
12674 void *parsed_result,
12675 __attribute__((unused)) struct cmdline *cl,
12676 __attribute__((unused)) void *data)
12678 struct cmd_vf_tc_bw_result *res = parsed_result;
12679 struct rte_port *port;
12682 int ret = -ENOTSUP;
12684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12687 port = &ports[res->port_id];
12688 /** Check if the port is not started **/
12689 if (port->port_status != RTE_PORT_STOPPED) {
12690 printf("Please stop port %d first\n", res->port_id);
12694 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12698 #ifdef RTE_LIBRTE_IXGBE_PMD
12699 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12706 printf("invalid bandwidth\n");
12709 printf("invalid port_id %d\n", res->port_id);
12712 printf("function not implemented\n");
12715 printf("programming error: (%s)\n", strerror(-ret));
12719 cmdline_parse_inst_t cmd_tc_min_bw = {
12720 .f = cmd_tc_min_bw_parsed,
12722 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12724 (void *)&cmd_vf_tc_bw_set,
12725 (void *)&cmd_vf_tc_bw_tc,
12726 (void *)&cmd_vf_tc_bw_tx,
12727 (void *)&cmd_vf_tc_bw_min_bw,
12728 (void *)&cmd_vf_tc_bw_port_id,
12729 (void *)&cmd_vf_tc_bw_bw_list,
12734 /* TC max bandwidth setting */
12736 cmd_vf_tc_max_bw_parsed(
12737 void *parsed_result,
12738 __attribute__((unused)) struct cmdline *cl,
12739 __attribute__((unused)) void *data)
12741 struct cmd_vf_tc_bw_result *res = parsed_result;
12742 int ret = -ENOTSUP;
12744 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12747 #ifdef RTE_LIBRTE_I40E_PMD
12748 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12749 res->tc_no, res->bw);
12756 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12757 res->vf_id, res->tc_no, res->bw);
12760 printf("invalid port_id %d\n", res->port_id);
12763 printf("function not implemented\n");
12766 printf("programming error: (%s)\n", strerror(-ret));
12770 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12771 .f = cmd_vf_tc_max_bw_parsed,
12773 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12776 (void *)&cmd_vf_tc_bw_set,
12777 (void *)&cmd_vf_tc_bw_vf,
12778 (void *)&cmd_vf_tc_bw_tc,
12779 (void *)&cmd_vf_tc_bw_tx,
12780 (void *)&cmd_vf_tc_bw_max_bw,
12781 (void *)&cmd_vf_tc_bw_port_id,
12782 (void *)&cmd_vf_tc_bw_vf_id,
12783 (void *)&cmd_vf_tc_bw_tc_no,
12784 (void *)&cmd_vf_tc_bw_bw,
12789 /* Strict link priority scheduling mode setting */
12791 cmd_strict_link_prio_parsed(
12792 void *parsed_result,
12793 __attribute__((unused)) struct cmdline *cl,
12794 __attribute__((unused)) void *data)
12796 struct cmd_vf_tc_bw_result *res = parsed_result;
12797 int ret = -ENOTSUP;
12799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12802 #ifdef RTE_LIBRTE_I40E_PMD
12803 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12810 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12813 printf("invalid port_id %d\n", res->port_id);
12816 printf("function not implemented\n");
12819 printf("programming error: (%s)\n", strerror(-ret));
12823 cmdline_parse_inst_t cmd_strict_link_prio = {
12824 .f = cmd_strict_link_prio_parsed,
12826 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12828 (void *)&cmd_vf_tc_bw_set,
12829 (void *)&cmd_vf_tc_bw_tx,
12830 (void *)&cmd_vf_tc_bw_strict_link_prio,
12831 (void *)&cmd_vf_tc_bw_port_id,
12832 (void *)&cmd_vf_tc_bw_tc_map,
12837 /* Load dynamic device personalization*/
12838 struct cmd_ddp_add_result {
12839 cmdline_fixed_string_t ddp;
12840 cmdline_fixed_string_t add;
12845 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12846 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12847 cmdline_parse_token_string_t cmd_ddp_add_add =
12848 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12849 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12850 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12851 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12852 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12855 cmd_ddp_add_parsed(
12856 void *parsed_result,
12857 __attribute__((unused)) struct cmdline *cl,
12858 __attribute__((unused)) void *data)
12860 struct cmd_ddp_add_result *res = parsed_result;
12863 int ret = -ENOTSUP;
12865 if (res->port_id > nb_ports) {
12866 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12870 if (!all_ports_stopped()) {
12871 printf("Please stop all ports first\n");
12875 buff = open_ddp_package_file(res->filepath, &size);
12879 #ifdef RTE_LIBRTE_I40E_PMD
12880 if (ret == -ENOTSUP)
12881 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12883 RTE_PMD_I40E_PKG_OP_WR_ADD);
12887 printf("Failed to load profile.\n");
12889 printf("Profile has already existed.\n");
12891 close_ddp_package_file(buff);
12894 cmdline_parse_inst_t cmd_ddp_add = {
12895 .f = cmd_ddp_add_parsed,
12897 .help_str = "ddp add <port_id> <profile_path>",
12899 (void *)&cmd_ddp_add_ddp,
12900 (void *)&cmd_ddp_add_add,
12901 (void *)&cmd_ddp_add_port_id,
12902 (void *)&cmd_ddp_add_filepath,
12907 /* Get dynamic device personalization profile info list*/
12908 #define PROFILE_INFO_SIZE 48
12909 #define MAX_PROFILE_NUM 16
12911 struct cmd_ddp_get_list_result {
12912 cmdline_fixed_string_t ddp;
12913 cmdline_fixed_string_t get;
12914 cmdline_fixed_string_t list;
12918 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
12919 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
12920 cmdline_parse_token_string_t cmd_ddp_get_list_get =
12921 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
12922 cmdline_parse_token_string_t cmd_ddp_get_list_list =
12923 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
12924 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
12925 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
12928 cmd_ddp_get_list_parsed(
12929 void *parsed_result,
12930 __attribute__((unused)) struct cmdline *cl,
12931 __attribute__((unused)) void *data)
12933 struct cmd_ddp_get_list_result *res = parsed_result;
12934 #ifdef RTE_LIBRTE_I40E_PMD
12935 struct rte_pmd_i40e_profile_list *p_list;
12936 struct rte_pmd_i40e_profile_info *p_info;
12941 int ret = -ENOTSUP;
12943 if (res->port_id > nb_ports) {
12944 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12948 #ifdef RTE_LIBRTE_I40E_PMD
12949 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
12950 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
12952 printf("%s: Failed to malloc buffer\n", __func__);
12954 if (ret == -ENOTSUP)
12955 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
12956 (uint8_t *)p_list, size);
12959 p_num = p_list->p_count;
12960 printf("Profile number is: %d\n\n", p_num);
12962 for (i = 0; i < p_num; i++) {
12963 p_info = &p_list->p_info[i];
12964 printf("Profile %d:\n", i);
12965 printf("Track id: 0x%x\n", p_info->track_id);
12966 printf("Version: %d.%d.%d.%d\n",
12967 p_info->version.major,
12968 p_info->version.minor,
12969 p_info->version.update,
12970 p_info->version.draft);
12971 printf("Profile name: %s\n\n", p_info->name);
12979 printf("Failed to get ddp list\n");
12982 cmdline_parse_inst_t cmd_ddp_get_list = {
12983 .f = cmd_ddp_get_list_parsed,
12985 .help_str = "ddp get list <port_id>",
12987 (void *)&cmd_ddp_get_list_ddp,
12988 (void *)&cmd_ddp_get_list_get,
12989 (void *)&cmd_ddp_get_list_list,
12990 (void *)&cmd_ddp_get_list_port_id,
12995 /* show vf stats */
12997 /* Common result structure for show vf stats */
12998 struct cmd_show_vf_stats_result {
12999 cmdline_fixed_string_t show;
13000 cmdline_fixed_string_t vf;
13001 cmdline_fixed_string_t stats;
13006 /* Common CLI fields show vf stats*/
13007 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13008 TOKEN_STRING_INITIALIZER
13009 (struct cmd_show_vf_stats_result,
13011 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13012 TOKEN_STRING_INITIALIZER
13013 (struct cmd_show_vf_stats_result,
13015 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13016 TOKEN_STRING_INITIALIZER
13017 (struct cmd_show_vf_stats_result,
13019 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13020 TOKEN_NUM_INITIALIZER
13021 (struct cmd_show_vf_stats_result,
13023 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13024 TOKEN_NUM_INITIALIZER
13025 (struct cmd_show_vf_stats_result,
13029 cmd_show_vf_stats_parsed(
13030 void *parsed_result,
13031 __attribute__((unused)) struct cmdline *cl,
13032 __attribute__((unused)) void *data)
13034 struct cmd_show_vf_stats_result *res = parsed_result;
13035 struct rte_eth_stats stats;
13036 int ret = -ENOTSUP;
13037 static const char *nic_stats_border = "########################";
13039 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13042 memset(&stats, 0, sizeof(stats));
13044 #ifdef RTE_LIBRTE_I40E_PMD
13045 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13054 printf("invalid vf_id %d\n", res->vf_id);
13057 printf("invalid port_id %d\n", res->port_id);
13060 printf("function not implemented\n");
13063 printf("programming error: (%s)\n", strerror(-ret));
13066 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13067 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13069 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13071 stats.ipackets, stats.imissed, stats.ibytes);
13072 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13073 printf(" RX-nombuf: %-10"PRIu64"\n",
13075 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13077 stats.opackets, stats.oerrors, stats.obytes);
13079 printf(" %s############################%s\n",
13080 nic_stats_border, nic_stats_border);
13083 cmdline_parse_inst_t cmd_show_vf_stats = {
13084 .f = cmd_show_vf_stats_parsed,
13086 .help_str = "show vf stats <port_id> <vf_id>",
13088 (void *)&cmd_show_vf_stats_show,
13089 (void *)&cmd_show_vf_stats_vf,
13090 (void *)&cmd_show_vf_stats_stats,
13091 (void *)&cmd_show_vf_stats_port_id,
13092 (void *)&cmd_show_vf_stats_vf_id,
13097 /* clear vf stats */
13099 /* Common result structure for clear vf stats */
13100 struct cmd_clear_vf_stats_result {
13101 cmdline_fixed_string_t clear;
13102 cmdline_fixed_string_t vf;
13103 cmdline_fixed_string_t stats;
13108 /* Common CLI fields clear vf stats*/
13109 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13110 TOKEN_STRING_INITIALIZER
13111 (struct cmd_clear_vf_stats_result,
13113 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13114 TOKEN_STRING_INITIALIZER
13115 (struct cmd_clear_vf_stats_result,
13117 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13118 TOKEN_STRING_INITIALIZER
13119 (struct cmd_clear_vf_stats_result,
13121 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13122 TOKEN_NUM_INITIALIZER
13123 (struct cmd_clear_vf_stats_result,
13125 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13126 TOKEN_NUM_INITIALIZER
13127 (struct cmd_clear_vf_stats_result,
13131 cmd_clear_vf_stats_parsed(
13132 void *parsed_result,
13133 __attribute__((unused)) struct cmdline *cl,
13134 __attribute__((unused)) void *data)
13136 struct cmd_clear_vf_stats_result *res = parsed_result;
13137 int ret = -ENOTSUP;
13139 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13142 #ifdef RTE_LIBRTE_I40E_PMD
13143 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13151 printf("invalid vf_id %d\n", res->vf_id);
13154 printf("invalid port_id %d\n", res->port_id);
13157 printf("function not implemented\n");
13160 printf("programming error: (%s)\n", strerror(-ret));
13164 cmdline_parse_inst_t cmd_clear_vf_stats = {
13165 .f = cmd_clear_vf_stats_parsed,
13167 .help_str = "clear vf stats <port_id> <vf_id>",
13169 (void *)&cmd_clear_vf_stats_clear,
13170 (void *)&cmd_clear_vf_stats_vf,
13171 (void *)&cmd_clear_vf_stats_stats,
13172 (void *)&cmd_clear_vf_stats_port_id,
13173 (void *)&cmd_clear_vf_stats_vf_id,
13178 /* ptype mapping get */
13180 /* Common result structure for ptype mapping get */
13181 struct cmd_ptype_mapping_get_result {
13182 cmdline_fixed_string_t ptype;
13183 cmdline_fixed_string_t mapping;
13184 cmdline_fixed_string_t get;
13186 uint8_t valid_only;
13189 /* Common CLI fields for ptype mapping get */
13190 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13191 TOKEN_STRING_INITIALIZER
13192 (struct cmd_ptype_mapping_get_result,
13194 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13195 TOKEN_STRING_INITIALIZER
13196 (struct cmd_ptype_mapping_get_result,
13197 mapping, "mapping");
13198 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13199 TOKEN_STRING_INITIALIZER
13200 (struct cmd_ptype_mapping_get_result,
13202 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13203 TOKEN_NUM_INITIALIZER
13204 (struct cmd_ptype_mapping_get_result,
13206 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13207 TOKEN_NUM_INITIALIZER
13208 (struct cmd_ptype_mapping_get_result,
13209 valid_only, UINT8);
13212 cmd_ptype_mapping_get_parsed(
13213 void *parsed_result,
13214 __attribute__((unused)) struct cmdline *cl,
13215 __attribute__((unused)) void *data)
13217 struct cmd_ptype_mapping_get_result *res = parsed_result;
13218 int ret = -ENOTSUP;
13219 #ifdef RTE_LIBRTE_I40E_PMD
13220 int max_ptype_num = 256;
13221 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13229 #ifdef RTE_LIBRTE_I40E_PMD
13230 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13241 printf("invalid port_id %d\n", res->port_id);
13244 printf("function not implemented\n");
13247 printf("programming error: (%s)\n", strerror(-ret));
13250 #ifdef RTE_LIBRTE_I40E_PMD
13252 for (i = 0; i < count; i++)
13253 printf("%3d\t0x%08x\n",
13254 mapping[i].hw_ptype, mapping[i].sw_ptype);
13259 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13260 .f = cmd_ptype_mapping_get_parsed,
13262 .help_str = "ptype mapping get <port_id> <valid_only>",
13264 (void *)&cmd_ptype_mapping_get_ptype,
13265 (void *)&cmd_ptype_mapping_get_mapping,
13266 (void *)&cmd_ptype_mapping_get_get,
13267 (void *)&cmd_ptype_mapping_get_port_id,
13268 (void *)&cmd_ptype_mapping_get_valid_only,
13273 /* ptype mapping replace */
13275 /* Common result structure for ptype mapping replace */
13276 struct cmd_ptype_mapping_replace_result {
13277 cmdline_fixed_string_t ptype;
13278 cmdline_fixed_string_t mapping;
13279 cmdline_fixed_string_t replace;
13286 /* Common CLI fields for ptype mapping replace */
13287 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13288 TOKEN_STRING_INITIALIZER
13289 (struct cmd_ptype_mapping_replace_result,
13291 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13292 TOKEN_STRING_INITIALIZER
13293 (struct cmd_ptype_mapping_replace_result,
13294 mapping, "mapping");
13295 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13296 TOKEN_STRING_INITIALIZER
13297 (struct cmd_ptype_mapping_replace_result,
13298 replace, "replace");
13299 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13300 TOKEN_NUM_INITIALIZER
13301 (struct cmd_ptype_mapping_replace_result,
13303 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13304 TOKEN_NUM_INITIALIZER
13305 (struct cmd_ptype_mapping_replace_result,
13307 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13308 TOKEN_NUM_INITIALIZER
13309 (struct cmd_ptype_mapping_replace_result,
13311 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13312 TOKEN_NUM_INITIALIZER
13313 (struct cmd_ptype_mapping_replace_result,
13317 cmd_ptype_mapping_replace_parsed(
13318 void *parsed_result,
13319 __attribute__((unused)) struct cmdline *cl,
13320 __attribute__((unused)) void *data)
13322 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13323 int ret = -ENOTSUP;
13325 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13328 #ifdef RTE_LIBRTE_I40E_PMD
13329 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13339 printf("invalid ptype 0x%8x or 0x%8x\n",
13340 res->target, res->pkt_type);
13343 printf("invalid port_id %d\n", res->port_id);
13346 printf("function not implemented\n");
13349 printf("programming error: (%s)\n", strerror(-ret));
13353 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13354 .f = cmd_ptype_mapping_replace_parsed,
13357 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13359 (void *)&cmd_ptype_mapping_replace_ptype,
13360 (void *)&cmd_ptype_mapping_replace_mapping,
13361 (void *)&cmd_ptype_mapping_replace_replace,
13362 (void *)&cmd_ptype_mapping_replace_port_id,
13363 (void *)&cmd_ptype_mapping_replace_target,
13364 (void *)&cmd_ptype_mapping_replace_mask,
13365 (void *)&cmd_ptype_mapping_replace_pkt_type,
13370 /* ptype mapping reset */
13372 /* Common result structure for ptype mapping reset */
13373 struct cmd_ptype_mapping_reset_result {
13374 cmdline_fixed_string_t ptype;
13375 cmdline_fixed_string_t mapping;
13376 cmdline_fixed_string_t reset;
13380 /* Common CLI fields for ptype mapping reset*/
13381 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
13382 TOKEN_STRING_INITIALIZER
13383 (struct cmd_ptype_mapping_reset_result,
13385 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
13386 TOKEN_STRING_INITIALIZER
13387 (struct cmd_ptype_mapping_reset_result,
13388 mapping, "mapping");
13389 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
13390 TOKEN_STRING_INITIALIZER
13391 (struct cmd_ptype_mapping_reset_result,
13393 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
13394 TOKEN_NUM_INITIALIZER
13395 (struct cmd_ptype_mapping_reset_result,
13399 cmd_ptype_mapping_reset_parsed(
13400 void *parsed_result,
13401 __attribute__((unused)) struct cmdline *cl,
13402 __attribute__((unused)) void *data)
13404 struct cmd_ptype_mapping_reset_result *res = parsed_result;
13405 int ret = -ENOTSUP;
13407 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13410 #ifdef RTE_LIBRTE_I40E_PMD
13411 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
13418 printf("invalid port_id %d\n", res->port_id);
13421 printf("function not implemented\n");
13424 printf("programming error: (%s)\n", strerror(-ret));
13428 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
13429 .f = cmd_ptype_mapping_reset_parsed,
13431 .help_str = "ptype mapping reset <port_id>",
13433 (void *)&cmd_ptype_mapping_reset_ptype,
13434 (void *)&cmd_ptype_mapping_reset_mapping,
13435 (void *)&cmd_ptype_mapping_reset_reset,
13436 (void *)&cmd_ptype_mapping_reset_port_id,
13441 /* ptype mapping update */
13443 /* Common result structure for ptype mapping update */
13444 struct cmd_ptype_mapping_update_result {
13445 cmdline_fixed_string_t ptype;
13446 cmdline_fixed_string_t mapping;
13447 cmdline_fixed_string_t reset;
13453 /* Common CLI fields for ptype mapping update*/
13454 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
13455 TOKEN_STRING_INITIALIZER
13456 (struct cmd_ptype_mapping_update_result,
13458 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
13459 TOKEN_STRING_INITIALIZER
13460 (struct cmd_ptype_mapping_update_result,
13461 mapping, "mapping");
13462 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
13463 TOKEN_STRING_INITIALIZER
13464 (struct cmd_ptype_mapping_update_result,
13466 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
13467 TOKEN_NUM_INITIALIZER
13468 (struct cmd_ptype_mapping_update_result,
13470 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
13471 TOKEN_NUM_INITIALIZER
13472 (struct cmd_ptype_mapping_update_result,
13474 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
13475 TOKEN_NUM_INITIALIZER
13476 (struct cmd_ptype_mapping_update_result,
13480 cmd_ptype_mapping_update_parsed(
13481 void *parsed_result,
13482 __attribute__((unused)) struct cmdline *cl,
13483 __attribute__((unused)) void *data)
13485 struct cmd_ptype_mapping_update_result *res = parsed_result;
13486 int ret = -ENOTSUP;
13487 #ifdef RTE_LIBRTE_I40E_PMD
13488 struct rte_pmd_i40e_ptype_mapping mapping;
13490 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13493 #ifdef RTE_LIBRTE_I40E_PMD
13494 mapping.hw_ptype = res->hw_ptype;
13495 mapping.sw_ptype = res->sw_ptype;
13496 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
13506 printf("invalid ptype 0x%8x\n", res->sw_ptype);
13509 printf("invalid port_id %d\n", res->port_id);
13512 printf("function not implemented\n");
13515 printf("programming error: (%s)\n", strerror(-ret));
13519 cmdline_parse_inst_t cmd_ptype_mapping_update = {
13520 .f = cmd_ptype_mapping_update_parsed,
13522 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
13524 (void *)&cmd_ptype_mapping_update_ptype,
13525 (void *)&cmd_ptype_mapping_update_mapping,
13526 (void *)&cmd_ptype_mapping_update_update,
13527 (void *)&cmd_ptype_mapping_update_port_id,
13528 (void *)&cmd_ptype_mapping_update_hw_ptype,
13529 (void *)&cmd_ptype_mapping_update_sw_ptype,
13534 /* Common result structure for file commands */
13535 struct cmd_cmdfile_result {
13536 cmdline_fixed_string_t load;
13537 cmdline_fixed_string_t filename;
13540 /* Common CLI fields for file commands */
13541 cmdline_parse_token_string_t cmd_load_cmdfile =
13542 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
13543 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
13544 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
13547 cmd_load_from_file_parsed(
13548 void *parsed_result,
13549 __attribute__((unused)) struct cmdline *cl,
13550 __attribute__((unused)) void *data)
13552 struct cmd_cmdfile_result *res = parsed_result;
13554 cmdline_read_from_file(res->filename);
13557 cmdline_parse_inst_t cmd_load_from_file = {
13558 .f = cmd_load_from_file_parsed,
13560 .help_str = "load <filename>",
13562 (void *)&cmd_load_cmdfile,
13563 (void *)&cmd_load_cmdfile_filename,
13568 /* ******************************************************************************** */
13570 /* list of instructions */
13571 cmdline_parse_ctx_t main_ctx[] = {
13572 (cmdline_parse_inst_t *)&cmd_help_brief,
13573 (cmdline_parse_inst_t *)&cmd_help_long,
13574 (cmdline_parse_inst_t *)&cmd_quit,
13575 (cmdline_parse_inst_t *)&cmd_load_from_file,
13576 (cmdline_parse_inst_t *)&cmd_showport,
13577 (cmdline_parse_inst_t *)&cmd_showqueue,
13578 (cmdline_parse_inst_t *)&cmd_showportall,
13579 (cmdline_parse_inst_t *)&cmd_showcfg,
13580 (cmdline_parse_inst_t *)&cmd_start,
13581 (cmdline_parse_inst_t *)&cmd_start_tx_first,
13582 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13583 (cmdline_parse_inst_t *)&cmd_set_link_up,
13584 (cmdline_parse_inst_t *)&cmd_set_link_down,
13585 (cmdline_parse_inst_t *)&cmd_reset,
13586 (cmdline_parse_inst_t *)&cmd_set_numbers,
13587 (cmdline_parse_inst_t *)&cmd_set_txpkts,
13588 (cmdline_parse_inst_t *)&cmd_set_txsplit,
13589 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13590 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13591 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13592 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13593 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13594 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13595 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13596 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13597 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13598 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13599 (cmdline_parse_inst_t *)&cmd_set_link_check,
13600 #ifdef RTE_NIC_BYPASS
13601 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13602 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13603 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13604 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13606 #ifdef RTE_LIBRTE_PMD_BOND
13607 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13608 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13609 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13610 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13611 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13612 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13613 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13614 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13615 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13617 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13618 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13619 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13620 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13621 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13622 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13623 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13624 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13625 (cmdline_parse_inst_t *)&cmd_csum_set,
13626 (cmdline_parse_inst_t *)&cmd_csum_show,
13627 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13628 (cmdline_parse_inst_t *)&cmd_tso_set,
13629 (cmdline_parse_inst_t *)&cmd_tso_show,
13630 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13631 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13632 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13633 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13634 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13635 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13636 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13637 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13638 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13639 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13640 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13641 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13642 (cmdline_parse_inst_t *)&cmd_config_dcb,
13643 (cmdline_parse_inst_t *)&cmd_read_reg,
13644 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13645 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13646 (cmdline_parse_inst_t *)&cmd_write_reg,
13647 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13648 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13649 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13650 (cmdline_parse_inst_t *)&cmd_stop,
13651 (cmdline_parse_inst_t *)&cmd_mac_addr,
13652 (cmdline_parse_inst_t *)&cmd_set_qmap,
13653 (cmdline_parse_inst_t *)&cmd_operate_port,
13654 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13655 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13656 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13657 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13658 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13659 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13660 (cmdline_parse_inst_t *)&cmd_config_mtu,
13661 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13662 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13663 (cmdline_parse_inst_t *)&cmd_config_rss,
13664 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13665 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13666 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13667 (cmdline_parse_inst_t *)&cmd_showport_reta,
13668 (cmdline_parse_inst_t *)&cmd_config_burst,
13669 (cmdline_parse_inst_t *)&cmd_config_thresh,
13670 (cmdline_parse_inst_t *)&cmd_config_threshold,
13671 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13672 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13673 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13674 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13675 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13676 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13677 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13678 (cmdline_parse_inst_t *)&cmd_global_config,
13679 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13680 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13681 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13682 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13683 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13684 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13685 (cmdline_parse_inst_t *)&cmd_dump,
13686 (cmdline_parse_inst_t *)&cmd_dump_one,
13687 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13688 (cmdline_parse_inst_t *)&cmd_syn_filter,
13689 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13690 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13691 (cmdline_parse_inst_t *)&cmd_flex_filter,
13692 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13693 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13694 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13695 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13696 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13697 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13698 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13699 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13700 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13701 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13702 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13703 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13704 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13705 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13706 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13707 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13708 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13709 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13710 (cmdline_parse_inst_t *)&cmd_flow,
13711 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13712 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13713 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13714 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13715 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13716 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13717 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13718 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13719 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13720 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13721 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13722 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13723 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13724 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13725 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13726 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13727 #ifdef RTE_LIBRTE_IXGBE_PMD
13728 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13729 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13730 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13731 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13732 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13733 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13734 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13735 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13736 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13738 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13739 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13740 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13741 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13742 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13743 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13744 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13745 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13746 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13747 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13748 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
13749 (cmdline_parse_inst_t *)&cmd_ddp_add,
13750 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13751 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13752 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13753 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
13754 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
13755 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
13756 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
13760 /* read cmdline commands from file */
13762 cmdline_read_from_file(const char *filename)
13764 struct cmdline *cl;
13766 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
13768 printf("Failed to create file based cmdline context: %s\n",
13773 cmdline_interact(cl);
13778 printf("Read CLI commands from %s\n", filename);
13781 /* prompt function, called from main on MASTER lcore */
13785 /* initialize non-constant commands */
13786 cmd_set_fwd_mode_init();
13787 cmd_set_fwd_retry_mode_init();
13789 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13790 if (testpmd_cl == NULL)
13792 cmdline_interact(testpmd_cl);
13793 cmdline_stdin_exit(testpmd_cl);
13799 if (testpmd_cl != NULL)
13800 cmdline_quit(testpmd_cl);
13804 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13806 if (id == (portid_t)RTE_PORT_ALL) {
13809 RTE_ETH_FOREACH_DEV(pid) {
13810 /* check if need_reconfig has been set to 1 */
13811 if (ports[pid].need_reconfig == 0)
13812 ports[pid].need_reconfig = dev;
13813 /* check if need_reconfig_queues has been set to 1 */
13814 if (ports[pid].need_reconfig_queues == 0)
13815 ports[pid].need_reconfig_queues = queue;
13817 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13818 /* check if need_reconfig has been set to 1 */
13819 if (ports[id].need_reconfig == 0)
13820 ports[id].need_reconfig = dev;
13821 /* check if need_reconfig_queues has been set to 1 */
13822 if (ports[id].need_reconfig_queues == 0)
13823 ports[id].need_reconfig_queues = queue;