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;
8744 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8745 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8746 IPV4_ADDR_TO_UINT(res->ip_dst,
8747 entry.input.flow.ip4_flow.dst_ip);
8748 IPV4_ADDR_TO_UINT(res->ip_src,
8749 entry.input.flow.ip4_flow.src_ip);
8750 entry.input.flow.ip4_flow.tos = res->tos_value;
8751 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8752 /* need convert to big endian. */
8753 entry.input.flow.udp4_flow.dst_port =
8754 rte_cpu_to_be_16(res->port_dst);
8755 entry.input.flow.udp4_flow.src_port =
8756 rte_cpu_to_be_16(res->port_src);
8758 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8759 IPV4_ADDR_TO_UINT(res->ip_dst,
8760 entry.input.flow.sctp4_flow.ip.dst_ip);
8761 IPV4_ADDR_TO_UINT(res->ip_src,
8762 entry.input.flow.sctp4_flow.ip.src_ip);
8763 entry.input.flow.ip4_flow.tos = res->tos_value;
8764 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8765 /* need convert to big endian. */
8766 entry.input.flow.sctp4_flow.dst_port =
8767 rte_cpu_to_be_16(res->port_dst);
8768 entry.input.flow.sctp4_flow.src_port =
8769 rte_cpu_to_be_16(res->port_src);
8770 entry.input.flow.sctp4_flow.verify_tag =
8771 rte_cpu_to_be_32(res->verify_tag_value);
8773 case RTE_ETH_FLOW_FRAG_IPV6:
8774 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8775 entry.input.flow.ipv6_flow.proto = res->proto_value;
8776 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8777 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8778 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8779 entry.input.flow.ipv6_flow.dst_ip);
8780 IPV6_ADDR_TO_ARRAY(res->ip_src,
8781 entry.input.flow.ipv6_flow.src_ip);
8782 entry.input.flow.ipv6_flow.tc = res->tos_value;
8783 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8784 /* need convert to big endian. */
8785 entry.input.flow.udp6_flow.dst_port =
8786 rte_cpu_to_be_16(res->port_dst);
8787 entry.input.flow.udp6_flow.src_port =
8788 rte_cpu_to_be_16(res->port_src);
8790 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8791 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8792 entry.input.flow.sctp6_flow.ip.dst_ip);
8793 IPV6_ADDR_TO_ARRAY(res->ip_src,
8794 entry.input.flow.sctp6_flow.ip.src_ip);
8795 entry.input.flow.ipv6_flow.tc = res->tos_value;
8796 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8797 /* need convert to big endian. */
8798 entry.input.flow.sctp6_flow.dst_port =
8799 rte_cpu_to_be_16(res->port_dst);
8800 entry.input.flow.sctp6_flow.src_port =
8801 rte_cpu_to_be_16(res->port_src);
8802 entry.input.flow.sctp6_flow.verify_tag =
8803 rte_cpu_to_be_32(res->verify_tag_value);
8805 case RTE_ETH_FLOW_L2_PAYLOAD:
8806 entry.input.flow.l2_flow.ether_type =
8807 rte_cpu_to_be_16(res->ether_type);
8813 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8814 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8816 sizeof(struct ether_addr));
8818 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8819 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8821 sizeof(struct ether_addr));
8822 entry.input.flow.tunnel_flow.tunnel_type =
8823 str2fdir_tunneltype(res->tunnel_type);
8824 entry.input.flow.tunnel_flow.tunnel_id =
8825 rte_cpu_to_be_32(res->tunnel_id_value);
8828 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8830 RTE_ETH_FDIR_MAX_FLEXLEN);
8832 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8834 entry.action.flex_off = 0; /*use 0 by default */
8835 if (!strcmp(res->drop, "drop"))
8836 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8838 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8840 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8841 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8842 if (!strcmp(res->pf_vf, "pf"))
8843 entry.input.flow_ext.is_vf = 0;
8844 else if (!strncmp(res->pf_vf, "vf", 2)) {
8845 struct rte_eth_dev_info dev_info;
8847 memset(&dev_info, 0, sizeof(dev_info));
8848 rte_eth_dev_info_get(res->port_id, &dev_info);
8850 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8851 if (errno != 0 || *end != '\0' ||
8852 vf_id >= dev_info.max_vfs) {
8853 printf("invalid parameter %s.\n", res->pf_vf);
8856 entry.input.flow_ext.is_vf = 1;
8857 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8859 printf("invalid parameter %s.\n", res->pf_vf);
8864 /* set to report FD ID by default */
8865 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8866 entry.action.rx_queue = res->queue_id;
8867 entry.soft_id = res->fd_id_value;
8868 if (!strcmp(res->ops, "add"))
8869 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8870 RTE_ETH_FILTER_ADD, &entry);
8871 else if (!strcmp(res->ops, "del"))
8872 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8873 RTE_ETH_FILTER_DELETE, &entry);
8875 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8876 RTE_ETH_FILTER_UPDATE, &entry);
8878 printf("flow director programming error: (%s)\n",
8882 cmdline_parse_token_string_t cmd_flow_director_filter =
8883 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8884 flow_director_filter, "flow_director_filter");
8885 cmdline_parse_token_num_t cmd_flow_director_port_id =
8886 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8888 cmdline_parse_token_string_t cmd_flow_director_ops =
8889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8890 ops, "add#del#update");
8891 cmdline_parse_token_string_t cmd_flow_director_flow =
8892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8894 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8896 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8897 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8898 cmdline_parse_token_string_t cmd_flow_director_ether =
8899 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8901 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8902 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8903 ether_type, UINT16);
8904 cmdline_parse_token_string_t cmd_flow_director_src =
8905 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8907 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8908 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8910 cmdline_parse_token_num_t cmd_flow_director_port_src =
8911 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8913 cmdline_parse_token_string_t cmd_flow_director_dst =
8914 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8916 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8917 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8919 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8920 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8922 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8923 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8924 verify_tag, "verify_tag");
8925 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8926 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8927 verify_tag_value, UINT32);
8928 cmdline_parse_token_string_t cmd_flow_director_tos =
8929 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8931 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8932 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8934 cmdline_parse_token_string_t cmd_flow_director_proto =
8935 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8937 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8938 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8939 proto_value, UINT8);
8940 cmdline_parse_token_string_t cmd_flow_director_ttl =
8941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8943 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8944 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8946 cmdline_parse_token_string_t cmd_flow_director_vlan =
8947 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8949 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8950 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8951 vlan_value, UINT16);
8952 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8954 flexbytes, "flexbytes");
8955 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8957 flexbytes_value, NULL);
8958 cmdline_parse_token_string_t cmd_flow_director_drop =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8961 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8964 cmdline_parse_token_string_t cmd_flow_director_queue =
8965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8967 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8968 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8970 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8973 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8974 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8975 fd_id_value, UINT32);
8977 cmdline_parse_token_string_t cmd_flow_director_mode =
8978 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8980 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8981 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8983 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8984 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8985 mode_value, "MAC-VLAN");
8986 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8987 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8988 mode_value, "Tunnel");
8989 cmdline_parse_token_string_t cmd_flow_director_mac =
8990 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8992 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8993 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8995 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8996 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8998 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8999 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9000 tunnel_type, "NVGRE#VxLAN");
9001 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9002 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9003 tunnel_id, "tunnel-id");
9004 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9005 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9006 tunnel_id_value, UINT32);
9008 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9009 .f = cmd_flow_director_filter_parsed,
9011 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9012 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9013 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9014 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9015 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9016 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9017 "fd_id <fd_id_value>: "
9018 "Add or delete an ip flow director entry on NIC",
9020 (void *)&cmd_flow_director_filter,
9021 (void *)&cmd_flow_director_port_id,
9022 (void *)&cmd_flow_director_mode,
9023 (void *)&cmd_flow_director_mode_ip,
9024 (void *)&cmd_flow_director_ops,
9025 (void *)&cmd_flow_director_flow,
9026 (void *)&cmd_flow_director_flow_type,
9027 (void *)&cmd_flow_director_src,
9028 (void *)&cmd_flow_director_ip_src,
9029 (void *)&cmd_flow_director_dst,
9030 (void *)&cmd_flow_director_ip_dst,
9031 (void *)&cmd_flow_director_tos,
9032 (void *)&cmd_flow_director_tos_value,
9033 (void *)&cmd_flow_director_proto,
9034 (void *)&cmd_flow_director_proto_value,
9035 (void *)&cmd_flow_director_ttl,
9036 (void *)&cmd_flow_director_ttl_value,
9037 (void *)&cmd_flow_director_vlan,
9038 (void *)&cmd_flow_director_vlan_value,
9039 (void *)&cmd_flow_director_flexbytes,
9040 (void *)&cmd_flow_director_flexbytes_value,
9041 (void *)&cmd_flow_director_drop,
9042 (void *)&cmd_flow_director_pf_vf,
9043 (void *)&cmd_flow_director_queue,
9044 (void *)&cmd_flow_director_queue_id,
9045 (void *)&cmd_flow_director_fd_id,
9046 (void *)&cmd_flow_director_fd_id_value,
9051 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9052 .f = cmd_flow_director_filter_parsed,
9054 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9055 "director entry on NIC",
9057 (void *)&cmd_flow_director_filter,
9058 (void *)&cmd_flow_director_port_id,
9059 (void *)&cmd_flow_director_mode,
9060 (void *)&cmd_flow_director_mode_ip,
9061 (void *)&cmd_flow_director_ops,
9062 (void *)&cmd_flow_director_flow,
9063 (void *)&cmd_flow_director_flow_type,
9064 (void *)&cmd_flow_director_src,
9065 (void *)&cmd_flow_director_ip_src,
9066 (void *)&cmd_flow_director_port_src,
9067 (void *)&cmd_flow_director_dst,
9068 (void *)&cmd_flow_director_ip_dst,
9069 (void *)&cmd_flow_director_port_dst,
9070 (void *)&cmd_flow_director_tos,
9071 (void *)&cmd_flow_director_tos_value,
9072 (void *)&cmd_flow_director_ttl,
9073 (void *)&cmd_flow_director_ttl_value,
9074 (void *)&cmd_flow_director_vlan,
9075 (void *)&cmd_flow_director_vlan_value,
9076 (void *)&cmd_flow_director_flexbytes,
9077 (void *)&cmd_flow_director_flexbytes_value,
9078 (void *)&cmd_flow_director_drop,
9079 (void *)&cmd_flow_director_pf_vf,
9080 (void *)&cmd_flow_director_queue,
9081 (void *)&cmd_flow_director_queue_id,
9082 (void *)&cmd_flow_director_fd_id,
9083 (void *)&cmd_flow_director_fd_id_value,
9088 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9089 .f = cmd_flow_director_filter_parsed,
9091 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9092 "director entry on NIC",
9094 (void *)&cmd_flow_director_filter,
9095 (void *)&cmd_flow_director_port_id,
9096 (void *)&cmd_flow_director_mode,
9097 (void *)&cmd_flow_director_mode_ip,
9098 (void *)&cmd_flow_director_ops,
9099 (void *)&cmd_flow_director_flow,
9100 (void *)&cmd_flow_director_flow_type,
9101 (void *)&cmd_flow_director_src,
9102 (void *)&cmd_flow_director_ip_src,
9103 (void *)&cmd_flow_director_port_dst,
9104 (void *)&cmd_flow_director_dst,
9105 (void *)&cmd_flow_director_ip_dst,
9106 (void *)&cmd_flow_director_port_dst,
9107 (void *)&cmd_flow_director_verify_tag,
9108 (void *)&cmd_flow_director_verify_tag_value,
9109 (void *)&cmd_flow_director_tos,
9110 (void *)&cmd_flow_director_tos_value,
9111 (void *)&cmd_flow_director_ttl,
9112 (void *)&cmd_flow_director_ttl_value,
9113 (void *)&cmd_flow_director_vlan,
9114 (void *)&cmd_flow_director_vlan_value,
9115 (void *)&cmd_flow_director_flexbytes,
9116 (void *)&cmd_flow_director_flexbytes_value,
9117 (void *)&cmd_flow_director_drop,
9118 (void *)&cmd_flow_director_pf_vf,
9119 (void *)&cmd_flow_director_queue,
9120 (void *)&cmd_flow_director_queue_id,
9121 (void *)&cmd_flow_director_fd_id,
9122 (void *)&cmd_flow_director_fd_id_value,
9127 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9128 .f = cmd_flow_director_filter_parsed,
9130 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9131 "director entry on NIC",
9133 (void *)&cmd_flow_director_filter,
9134 (void *)&cmd_flow_director_port_id,
9135 (void *)&cmd_flow_director_mode,
9136 (void *)&cmd_flow_director_mode_ip,
9137 (void *)&cmd_flow_director_ops,
9138 (void *)&cmd_flow_director_flow,
9139 (void *)&cmd_flow_director_flow_type,
9140 (void *)&cmd_flow_director_ether,
9141 (void *)&cmd_flow_director_ether_type,
9142 (void *)&cmd_flow_director_flexbytes,
9143 (void *)&cmd_flow_director_flexbytes_value,
9144 (void *)&cmd_flow_director_drop,
9145 (void *)&cmd_flow_director_pf_vf,
9146 (void *)&cmd_flow_director_queue,
9147 (void *)&cmd_flow_director_queue_id,
9148 (void *)&cmd_flow_director_fd_id,
9149 (void *)&cmd_flow_director_fd_id_value,
9154 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9155 .f = cmd_flow_director_filter_parsed,
9157 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9158 "director entry on NIC",
9160 (void *)&cmd_flow_director_filter,
9161 (void *)&cmd_flow_director_port_id,
9162 (void *)&cmd_flow_director_mode,
9163 (void *)&cmd_flow_director_mode_mac_vlan,
9164 (void *)&cmd_flow_director_ops,
9165 (void *)&cmd_flow_director_mac,
9166 (void *)&cmd_flow_director_mac_addr,
9167 (void *)&cmd_flow_director_vlan,
9168 (void *)&cmd_flow_director_vlan_value,
9169 (void *)&cmd_flow_director_flexbytes,
9170 (void *)&cmd_flow_director_flexbytes_value,
9171 (void *)&cmd_flow_director_drop,
9172 (void *)&cmd_flow_director_queue,
9173 (void *)&cmd_flow_director_queue_id,
9174 (void *)&cmd_flow_director_fd_id,
9175 (void *)&cmd_flow_director_fd_id_value,
9180 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9181 .f = cmd_flow_director_filter_parsed,
9183 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9184 "director entry on NIC",
9186 (void *)&cmd_flow_director_filter,
9187 (void *)&cmd_flow_director_port_id,
9188 (void *)&cmd_flow_director_mode,
9189 (void *)&cmd_flow_director_mode_tunnel,
9190 (void *)&cmd_flow_director_ops,
9191 (void *)&cmd_flow_director_mac,
9192 (void *)&cmd_flow_director_mac_addr,
9193 (void *)&cmd_flow_director_vlan,
9194 (void *)&cmd_flow_director_vlan_value,
9195 (void *)&cmd_flow_director_tunnel,
9196 (void *)&cmd_flow_director_tunnel_type,
9197 (void *)&cmd_flow_director_tunnel_id,
9198 (void *)&cmd_flow_director_tunnel_id_value,
9199 (void *)&cmd_flow_director_flexbytes,
9200 (void *)&cmd_flow_director_flexbytes_value,
9201 (void *)&cmd_flow_director_drop,
9202 (void *)&cmd_flow_director_queue,
9203 (void *)&cmd_flow_director_queue_id,
9204 (void *)&cmd_flow_director_fd_id,
9205 (void *)&cmd_flow_director_fd_id_value,
9210 struct cmd_flush_flow_director_result {
9211 cmdline_fixed_string_t flush_flow_director;
9215 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9216 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9217 flush_flow_director, "flush_flow_director");
9218 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9219 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9223 cmd_flush_flow_director_parsed(void *parsed_result,
9224 __attribute__((unused)) struct cmdline *cl,
9225 __attribute__((unused)) void *data)
9227 struct cmd_flow_director_result *res = parsed_result;
9230 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9232 printf("flow director is not supported on port %u.\n",
9237 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9238 RTE_ETH_FILTER_FLUSH, NULL);
9240 printf("flow director table flushing error: (%s)\n",
9244 cmdline_parse_inst_t cmd_flush_flow_director = {
9245 .f = cmd_flush_flow_director_parsed,
9247 .help_str = "flush_flow_director <port_id>: "
9248 "Flush all flow director entries of a device on NIC",
9250 (void *)&cmd_flush_flow_director_flush,
9251 (void *)&cmd_flush_flow_director_port_id,
9256 /* *** deal with flow director mask *** */
9257 struct cmd_flow_director_mask_result {
9258 cmdline_fixed_string_t flow_director_mask;
9260 cmdline_fixed_string_t mode;
9261 cmdline_fixed_string_t mode_value;
9262 cmdline_fixed_string_t vlan;
9264 cmdline_fixed_string_t src_mask;
9265 cmdline_ipaddr_t ipv4_src;
9266 cmdline_ipaddr_t ipv6_src;
9268 cmdline_fixed_string_t dst_mask;
9269 cmdline_ipaddr_t ipv4_dst;
9270 cmdline_ipaddr_t ipv6_dst;
9272 cmdline_fixed_string_t mac;
9273 uint8_t mac_addr_byte_mask;
9274 cmdline_fixed_string_t tunnel_id;
9275 uint32_t tunnel_id_mask;
9276 cmdline_fixed_string_t tunnel_type;
9277 uint8_t tunnel_type_mask;
9281 cmd_flow_director_mask_parsed(void *parsed_result,
9282 __attribute__((unused)) struct cmdline *cl,
9283 __attribute__((unused)) void *data)
9285 struct cmd_flow_director_mask_result *res = parsed_result;
9286 struct rte_eth_fdir_masks *mask;
9287 struct rte_port *port;
9289 if (res->port_id > nb_ports) {
9290 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9294 port = &ports[res->port_id];
9295 /** Check if the port is not started **/
9296 if (port->port_status != RTE_PORT_STOPPED) {
9297 printf("Please stop port %d first\n", res->port_id);
9301 mask = &port->dev_conf.fdir_conf.mask;
9303 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9304 if (strcmp(res->mode_value, "MAC-VLAN")) {
9305 printf("Please set mode to MAC-VLAN.\n");
9309 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9310 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9311 if (strcmp(res->mode_value, "Tunnel")) {
9312 printf("Please set mode to Tunnel.\n");
9316 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9317 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9318 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9319 mask->tunnel_type_mask = res->tunnel_type_mask;
9321 if (strcmp(res->mode_value, "IP")) {
9322 printf("Please set mode to IP.\n");
9326 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9327 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9328 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9329 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9330 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9331 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9332 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9335 cmd_reconfig_device_queue(res->port_id, 1, 1);
9338 cmdline_parse_token_string_t cmd_flow_director_mask =
9339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9340 flow_director_mask, "flow_director_mask");
9341 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9342 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9344 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9347 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9348 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9350 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9352 src_mask, "src_mask");
9353 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9354 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9356 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9357 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9359 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9360 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9362 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9364 dst_mask, "dst_mask");
9365 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9366 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9368 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9369 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9371 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9372 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9375 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9378 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9381 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9383 mode_value, "MAC-VLAN");
9384 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9385 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9386 mode_value, "Tunnel");
9387 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9390 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9391 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9392 mac_addr_byte_mask, UINT8);
9393 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9394 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9395 tunnel_type, "tunnel-type");
9396 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9397 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9398 tunnel_type_mask, UINT8);
9399 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9401 tunnel_id, "tunnel-id");
9402 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9403 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9404 tunnel_id_mask, UINT32);
9406 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9407 .f = cmd_flow_director_mask_parsed,
9409 .help_str = "flow_director_mask ... : "
9410 "Set IP mode flow director's mask on NIC",
9412 (void *)&cmd_flow_director_mask,
9413 (void *)&cmd_flow_director_mask_port_id,
9414 (void *)&cmd_flow_director_mask_mode,
9415 (void *)&cmd_flow_director_mask_mode_ip,
9416 (void *)&cmd_flow_director_mask_vlan,
9417 (void *)&cmd_flow_director_mask_vlan_value,
9418 (void *)&cmd_flow_director_mask_src,
9419 (void *)&cmd_flow_director_mask_ipv4_src,
9420 (void *)&cmd_flow_director_mask_ipv6_src,
9421 (void *)&cmd_flow_director_mask_port_src,
9422 (void *)&cmd_flow_director_mask_dst,
9423 (void *)&cmd_flow_director_mask_ipv4_dst,
9424 (void *)&cmd_flow_director_mask_ipv6_dst,
9425 (void *)&cmd_flow_director_mask_port_dst,
9430 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9431 .f = cmd_flow_director_mask_parsed,
9433 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9434 "flow director's mask on NIC",
9436 (void *)&cmd_flow_director_mask,
9437 (void *)&cmd_flow_director_mask_port_id,
9438 (void *)&cmd_flow_director_mask_mode,
9439 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9440 (void *)&cmd_flow_director_mask_vlan,
9441 (void *)&cmd_flow_director_mask_vlan_value,
9446 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9447 .f = cmd_flow_director_mask_parsed,
9449 .help_str = "flow_director_mask ... : Set tunnel mode "
9450 "flow director's mask on NIC",
9452 (void *)&cmd_flow_director_mask,
9453 (void *)&cmd_flow_director_mask_port_id,
9454 (void *)&cmd_flow_director_mask_mode,
9455 (void *)&cmd_flow_director_mask_mode_tunnel,
9456 (void *)&cmd_flow_director_mask_vlan,
9457 (void *)&cmd_flow_director_mask_vlan_value,
9458 (void *)&cmd_flow_director_mask_mac,
9459 (void *)&cmd_flow_director_mask_mac_value,
9460 (void *)&cmd_flow_director_mask_tunnel_type,
9461 (void *)&cmd_flow_director_mask_tunnel_type_value,
9462 (void *)&cmd_flow_director_mask_tunnel_id,
9463 (void *)&cmd_flow_director_mask_tunnel_id_value,
9468 /* *** deal with flow director mask on flexible payload *** */
9469 struct cmd_flow_director_flex_mask_result {
9470 cmdline_fixed_string_t flow_director_flexmask;
9472 cmdline_fixed_string_t flow;
9473 cmdline_fixed_string_t flow_type;
9474 cmdline_fixed_string_t mask;
9478 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9479 __attribute__((unused)) struct cmdline *cl,
9480 __attribute__((unused)) void *data)
9482 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9483 struct rte_eth_fdir_info fdir_info;
9484 struct rte_eth_fdir_flex_mask flex_mask;
9485 struct rte_port *port;
9486 uint32_t flow_type_mask;
9490 if (res->port_id > nb_ports) {
9491 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9495 port = &ports[res->port_id];
9496 /** Check if the port is not started **/
9497 if (port->port_status != RTE_PORT_STOPPED) {
9498 printf("Please stop port %d first\n", res->port_id);
9502 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9503 ret = parse_flexbytes(res->mask,
9505 RTE_ETH_FDIR_MAX_FLEXLEN);
9507 printf("error: Cannot parse mask input.\n");
9511 memset(&fdir_info, 0, sizeof(fdir_info));
9512 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9513 RTE_ETH_FILTER_INFO, &fdir_info);
9515 printf("Cannot get FDir filter info\n");
9519 if (!strcmp(res->flow_type, "none")) {
9520 /* means don't specify the flow type */
9521 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9522 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9523 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9524 0, sizeof(struct rte_eth_fdir_flex_mask));
9525 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9526 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9528 sizeof(struct rte_eth_fdir_flex_mask));
9529 cmd_reconfig_device_queue(res->port_id, 1, 1);
9532 flow_type_mask = fdir_info.flow_types_mask[0];
9533 if (!strcmp(res->flow_type, "all")) {
9534 if (!flow_type_mask) {
9535 printf("No flow type supported\n");
9538 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9539 if (flow_type_mask & (1 << i)) {
9540 flex_mask.flow_type = i;
9541 fdir_set_flex_mask(res->port_id, &flex_mask);
9544 cmd_reconfig_device_queue(res->port_id, 1, 1);
9547 flex_mask.flow_type = str2flowtype(res->flow_type);
9548 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9549 printf("Flow type %s not supported on port %d\n",
9550 res->flow_type, res->port_id);
9553 fdir_set_flex_mask(res->port_id, &flex_mask);
9554 cmd_reconfig_device_queue(res->port_id, 1, 1);
9557 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9558 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9559 flow_director_flexmask,
9560 "flow_director_flex_mask");
9561 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9562 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9564 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9565 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9567 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9568 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9569 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9570 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9571 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9572 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9575 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9576 .f = cmd_flow_director_flex_mask_parsed,
9578 .help_str = "flow_director_flex_mask ... : "
9579 "Set flow director's flex mask on NIC",
9581 (void *)&cmd_flow_director_flexmask,
9582 (void *)&cmd_flow_director_flexmask_port_id,
9583 (void *)&cmd_flow_director_flexmask_flow,
9584 (void *)&cmd_flow_director_flexmask_flow_type,
9585 (void *)&cmd_flow_director_flexmask_mask,
9590 /* *** deal with flow director flexible payload configuration *** */
9591 struct cmd_flow_director_flexpayload_result {
9592 cmdline_fixed_string_t flow_director_flexpayload;
9594 cmdline_fixed_string_t payload_layer;
9595 cmdline_fixed_string_t payload_cfg;
9599 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9602 const char *p, *p0 = q_arg;
9604 unsigned long int_fld;
9605 char *str_fld[max_num];
9610 p = strchr(p0, '(');
9614 p0 = strchr(p, ')');
9619 if (size >= sizeof(s))
9622 snprintf(s, sizeof(s), "%.*s", size, p);
9623 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9624 if (ret < 0 || ret > max_num)
9626 for (i = 0; i < ret; i++) {
9628 int_fld = strtoul(str_fld[i], &end, 0);
9629 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9631 offsets[i] = (uint16_t)int_fld;
9637 cmd_flow_director_flxpld_parsed(void *parsed_result,
9638 __attribute__((unused)) struct cmdline *cl,
9639 __attribute__((unused)) void *data)
9641 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9642 struct rte_eth_flex_payload_cfg flex_cfg;
9643 struct rte_port *port;
9646 if (res->port_id > nb_ports) {
9647 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9651 port = &ports[res->port_id];
9652 /** Check if the port is not started **/
9653 if (port->port_status != RTE_PORT_STOPPED) {
9654 printf("Please stop port %d first\n", res->port_id);
9658 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9660 if (!strcmp(res->payload_layer, "raw"))
9661 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9662 else if (!strcmp(res->payload_layer, "l2"))
9663 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9664 else if (!strcmp(res->payload_layer, "l3"))
9665 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9666 else if (!strcmp(res->payload_layer, "l4"))
9667 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9669 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9670 RTE_ETH_FDIR_MAX_FLEXLEN);
9672 printf("error: Cannot parse flex payload input.\n");
9676 fdir_set_flex_payload(res->port_id, &flex_cfg);
9677 cmd_reconfig_device_queue(res->port_id, 1, 1);
9680 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9681 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9682 flow_director_flexpayload,
9683 "flow_director_flex_payload");
9684 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9685 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9687 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9689 payload_layer, "raw#l2#l3#l4");
9690 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9694 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9695 .f = cmd_flow_director_flxpld_parsed,
9697 .help_str = "flow_director_flexpayload ... : "
9698 "Set flow director's flex payload on NIC",
9700 (void *)&cmd_flow_director_flexpayload,
9701 (void *)&cmd_flow_director_flexpayload_port_id,
9702 (void *)&cmd_flow_director_flexpayload_payload_layer,
9703 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9708 /* Generic flow interface command. */
9709 extern cmdline_parse_inst_t cmd_flow;
9711 /* *** Classification Filters Control *** */
9712 /* *** Get symmetric hash enable per port *** */
9713 struct cmd_get_sym_hash_ena_per_port_result {
9714 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9719 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9720 __rte_unused struct cmdline *cl,
9721 __rte_unused void *data)
9723 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9724 struct rte_eth_hash_filter_info info;
9727 if (rte_eth_dev_filter_supported(res->port_id,
9728 RTE_ETH_FILTER_HASH) < 0) {
9729 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9734 memset(&info, 0, sizeof(info));
9735 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9736 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9737 RTE_ETH_FILTER_GET, &info);
9740 printf("Cannot get symmetric hash enable per port "
9741 "on port %u\n", res->port_id);
9745 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9746 "enabled" : "disabled", res->port_id);
9749 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9750 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9751 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9752 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9753 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9756 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9757 .f = cmd_get_sym_hash_per_port_parsed,
9759 .help_str = "get_sym_hash_ena_per_port <port_id>",
9761 (void *)&cmd_get_sym_hash_ena_per_port_all,
9762 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9767 /* *** Set symmetric hash enable per port *** */
9768 struct cmd_set_sym_hash_ena_per_port_result {
9769 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9770 cmdline_fixed_string_t enable;
9775 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9776 __rte_unused struct cmdline *cl,
9777 __rte_unused void *data)
9779 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9780 struct rte_eth_hash_filter_info info;
9783 if (rte_eth_dev_filter_supported(res->port_id,
9784 RTE_ETH_FILTER_HASH) < 0) {
9785 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9790 memset(&info, 0, sizeof(info));
9791 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9792 if (!strcmp(res->enable, "enable"))
9793 info.info.enable = 1;
9794 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9795 RTE_ETH_FILTER_SET, &info);
9797 printf("Cannot set symmetric hash enable per port on "
9798 "port %u\n", res->port_id);
9801 printf("Symmetric hash has been set to %s on port %u\n",
9802 res->enable, res->port_id);
9805 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9806 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9807 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9808 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9809 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9811 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9812 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9813 enable, "enable#disable");
9815 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9816 .f = cmd_set_sym_hash_per_port_parsed,
9818 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9820 (void *)&cmd_set_sym_hash_ena_per_port_all,
9821 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9822 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9827 /* Get global config of hash function */
9828 struct cmd_get_hash_global_config_result {
9829 cmdline_fixed_string_t get_hash_global_config;
9834 flowtype_to_str(uint16_t ftype)
9841 {"ipv4", RTE_ETH_FLOW_IPV4},
9842 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9843 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9844 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9845 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9846 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9847 {"ipv6", RTE_ETH_FLOW_IPV6},
9848 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9849 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9850 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9851 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9852 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9853 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9854 {"port", RTE_ETH_FLOW_PORT},
9855 {"vxlan", RTE_ETH_FLOW_VXLAN},
9856 {"geneve", RTE_ETH_FLOW_GENEVE},
9857 {"nvgre", RTE_ETH_FLOW_NVGRE},
9860 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9861 if (ftype_table[i].ftype == ftype)
9862 return ftype_table[i].str;
9869 cmd_get_hash_global_config_parsed(void *parsed_result,
9870 __rte_unused struct cmdline *cl,
9871 __rte_unused void *data)
9873 struct cmd_get_hash_global_config_result *res = parsed_result;
9874 struct rte_eth_hash_filter_info info;
9875 uint32_t idx, offset;
9880 if (rte_eth_dev_filter_supported(res->port_id,
9881 RTE_ETH_FILTER_HASH) < 0) {
9882 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9887 memset(&info, 0, sizeof(info));
9888 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9889 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9890 RTE_ETH_FILTER_GET, &info);
9892 printf("Cannot get hash global configurations by port %d\n",
9897 switch (info.info.global_conf.hash_func) {
9898 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9899 printf("Hash function is Toeplitz\n");
9901 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9902 printf("Hash function is Simple XOR\n");
9905 printf("Unknown hash function\n");
9909 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9910 idx = i / UINT32_BIT;
9911 offset = i % UINT32_BIT;
9912 if (!(info.info.global_conf.valid_bit_mask[idx] &
9915 str = flowtype_to_str(i);
9918 printf("Symmetric hash is %s globally for flow type %s "
9920 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9921 (1UL << offset)) ? "enabled" : "disabled"), str,
9926 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9927 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9928 get_hash_global_config, "get_hash_global_config");
9929 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9930 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9933 cmdline_parse_inst_t cmd_get_hash_global_config = {
9934 .f = cmd_get_hash_global_config_parsed,
9936 .help_str = "get_hash_global_config <port_id>",
9938 (void *)&cmd_get_hash_global_config_all,
9939 (void *)&cmd_get_hash_global_config_port_id,
9944 /* Set global config of hash function */
9945 struct cmd_set_hash_global_config_result {
9946 cmdline_fixed_string_t set_hash_global_config;
9948 cmdline_fixed_string_t hash_func;
9949 cmdline_fixed_string_t flow_type;
9950 cmdline_fixed_string_t enable;
9954 cmd_set_hash_global_config_parsed(void *parsed_result,
9955 __rte_unused struct cmdline *cl,
9956 __rte_unused void *data)
9958 struct cmd_set_hash_global_config_result *res = parsed_result;
9959 struct rte_eth_hash_filter_info info;
9960 uint32_t ftype, idx, offset;
9963 if (rte_eth_dev_filter_supported(res->port_id,
9964 RTE_ETH_FILTER_HASH) < 0) {
9965 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9969 memset(&info, 0, sizeof(info));
9970 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9971 if (!strcmp(res->hash_func, "toeplitz"))
9972 info.info.global_conf.hash_func =
9973 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9974 else if (!strcmp(res->hash_func, "simple_xor"))
9975 info.info.global_conf.hash_func =
9976 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9977 else if (!strcmp(res->hash_func, "default"))
9978 info.info.global_conf.hash_func =
9979 RTE_ETH_HASH_FUNCTION_DEFAULT;
9981 ftype = str2flowtype(res->flow_type);
9982 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9983 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9984 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9985 if (!strcmp(res->enable, "enable"))
9986 info.info.global_conf.sym_hash_enable_mask[idx] |=
9988 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9989 RTE_ETH_FILTER_SET, &info);
9991 printf("Cannot set global hash configurations by port %d\n",
9994 printf("Global hash configurations have been set "
9995 "succcessfully by port %d\n", res->port_id);
9998 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9999 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10000 set_hash_global_config, "set_hash_global_config");
10001 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10002 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10004 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10005 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10006 hash_func, "toeplitz#simple_xor#default");
10007 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10008 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10010 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10011 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10012 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10013 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10014 enable, "enable#disable");
10016 cmdline_parse_inst_t cmd_set_hash_global_config = {
10017 .f = cmd_set_hash_global_config_parsed,
10019 .help_str = "set_hash_global_config <port_id> "
10020 "toeplitz|simple_xor|default "
10021 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10022 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10023 "l2_payload enable|disable",
10025 (void *)&cmd_set_hash_global_config_all,
10026 (void *)&cmd_set_hash_global_config_port_id,
10027 (void *)&cmd_set_hash_global_config_hash_func,
10028 (void *)&cmd_set_hash_global_config_flow_type,
10029 (void *)&cmd_set_hash_global_config_enable,
10034 /* Set hash input set */
10035 struct cmd_set_hash_input_set_result {
10036 cmdline_fixed_string_t set_hash_input_set;
10038 cmdline_fixed_string_t flow_type;
10039 cmdline_fixed_string_t inset_field;
10040 cmdline_fixed_string_t select;
10043 static enum rte_eth_input_set_field
10044 str2inset(char *string)
10048 static const struct {
10050 enum rte_eth_input_set_field inset;
10051 } inset_table[] = {
10052 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10053 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10054 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10055 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10056 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10057 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10058 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10059 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10060 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10061 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10062 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10063 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10064 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10065 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10066 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10067 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10068 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10069 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10070 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10071 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10072 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10073 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10074 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10075 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10076 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10077 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10078 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10079 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10080 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10081 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10082 {"none", RTE_ETH_INPUT_SET_NONE},
10085 for (i = 0; i < RTE_DIM(inset_table); i++) {
10086 if (!strcmp(string, inset_table[i].str))
10087 return inset_table[i].inset;
10090 return RTE_ETH_INPUT_SET_UNKNOWN;
10094 cmd_set_hash_input_set_parsed(void *parsed_result,
10095 __rte_unused struct cmdline *cl,
10096 __rte_unused void *data)
10098 struct cmd_set_hash_input_set_result *res = parsed_result;
10099 struct rte_eth_hash_filter_info info;
10101 memset(&info, 0, sizeof(info));
10102 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10103 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10104 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10105 info.info.input_set_conf.inset_size = 1;
10106 if (!strcmp(res->select, "select"))
10107 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10108 else if (!strcmp(res->select, "add"))
10109 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10110 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10111 RTE_ETH_FILTER_SET, &info);
10114 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10115 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10116 set_hash_input_set, "set_hash_input_set");
10117 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10118 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10120 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10121 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10123 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10124 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10125 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10126 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10128 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10129 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10130 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10131 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10132 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10134 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10135 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10136 select, "select#add");
10138 cmdline_parse_inst_t cmd_set_hash_input_set = {
10139 .f = cmd_set_hash_input_set_parsed,
10141 .help_str = "set_hash_input_set <port_id> "
10142 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10143 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10144 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10145 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10146 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10147 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10148 "fld-7th|fld-8th|none select|add",
10150 (void *)&cmd_set_hash_input_set_cmd,
10151 (void *)&cmd_set_hash_input_set_port_id,
10152 (void *)&cmd_set_hash_input_set_flow_type,
10153 (void *)&cmd_set_hash_input_set_field,
10154 (void *)&cmd_set_hash_input_set_select,
10159 /* Set flow director input set */
10160 struct cmd_set_fdir_input_set_result {
10161 cmdline_fixed_string_t set_fdir_input_set;
10163 cmdline_fixed_string_t flow_type;
10164 cmdline_fixed_string_t inset_field;
10165 cmdline_fixed_string_t select;
10169 cmd_set_fdir_input_set_parsed(void *parsed_result,
10170 __rte_unused struct cmdline *cl,
10171 __rte_unused void *data)
10173 struct cmd_set_fdir_input_set_result *res = parsed_result;
10174 struct rte_eth_fdir_filter_info info;
10176 memset(&info, 0, sizeof(info));
10177 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10178 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10179 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10180 info.info.input_set_conf.inset_size = 1;
10181 if (!strcmp(res->select, "select"))
10182 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10183 else if (!strcmp(res->select, "add"))
10184 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10185 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10186 RTE_ETH_FILTER_SET, &info);
10189 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10190 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10191 set_fdir_input_set, "set_fdir_input_set");
10192 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10193 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10195 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10196 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10198 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10199 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10200 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10201 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10203 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10204 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10205 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10206 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10207 "sctp-veri-tag#none");
10208 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10209 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10210 select, "select#add");
10212 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10213 .f = cmd_set_fdir_input_set_parsed,
10215 .help_str = "set_fdir_input_set <port_id> "
10216 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10217 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10218 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10219 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10220 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10221 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10222 "sctp-veri-tag|none select|add",
10224 (void *)&cmd_set_fdir_input_set_cmd,
10225 (void *)&cmd_set_fdir_input_set_port_id,
10226 (void *)&cmd_set_fdir_input_set_flow_type,
10227 (void *)&cmd_set_fdir_input_set_field,
10228 (void *)&cmd_set_fdir_input_set_select,
10233 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10234 struct cmd_mcast_addr_result {
10235 cmdline_fixed_string_t mcast_addr_cmd;
10236 cmdline_fixed_string_t what;
10238 struct ether_addr mc_addr;
10241 static void cmd_mcast_addr_parsed(void *parsed_result,
10242 __attribute__((unused)) struct cmdline *cl,
10243 __attribute__((unused)) void *data)
10245 struct cmd_mcast_addr_result *res = parsed_result;
10247 if (!is_multicast_ether_addr(&res->mc_addr)) {
10248 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10249 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10250 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10251 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10254 if (strcmp(res->what, "add") == 0)
10255 mcast_addr_add(res->port_num, &res->mc_addr);
10257 mcast_addr_remove(res->port_num, &res->mc_addr);
10260 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10261 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10262 mcast_addr_cmd, "mcast_addr");
10263 cmdline_parse_token_string_t cmd_mcast_addr_what =
10264 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10266 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10267 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10268 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10269 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10271 cmdline_parse_inst_t cmd_mcast_addr = {
10272 .f = cmd_mcast_addr_parsed,
10274 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10275 "Add/Remove multicast MAC address on port_id",
10277 (void *)&cmd_mcast_addr_cmd,
10278 (void *)&cmd_mcast_addr_what,
10279 (void *)&cmd_mcast_addr_portnum,
10280 (void *)&cmd_mcast_addr_addr,
10285 /* l2 tunnel config
10286 * only support E-tag now.
10289 /* Ether type config */
10290 struct cmd_config_l2_tunnel_eth_type_result {
10291 cmdline_fixed_string_t port;
10292 cmdline_fixed_string_t config;
10293 cmdline_fixed_string_t all;
10295 cmdline_fixed_string_t l2_tunnel;
10296 cmdline_fixed_string_t l2_tunnel_type;
10297 cmdline_fixed_string_t eth_type;
10298 uint16_t eth_type_val;
10301 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10302 TOKEN_STRING_INITIALIZER
10303 (struct cmd_config_l2_tunnel_eth_type_result,
10305 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10306 TOKEN_STRING_INITIALIZER
10307 (struct cmd_config_l2_tunnel_eth_type_result,
10309 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10310 TOKEN_STRING_INITIALIZER
10311 (struct cmd_config_l2_tunnel_eth_type_result,
10313 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10314 TOKEN_NUM_INITIALIZER
10315 (struct cmd_config_l2_tunnel_eth_type_result,
10317 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10318 TOKEN_STRING_INITIALIZER
10319 (struct cmd_config_l2_tunnel_eth_type_result,
10320 l2_tunnel, "l2-tunnel");
10321 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10322 TOKEN_STRING_INITIALIZER
10323 (struct cmd_config_l2_tunnel_eth_type_result,
10324 l2_tunnel_type, "E-tag");
10325 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10326 TOKEN_STRING_INITIALIZER
10327 (struct cmd_config_l2_tunnel_eth_type_result,
10328 eth_type, "ether-type");
10329 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10330 TOKEN_NUM_INITIALIZER
10331 (struct cmd_config_l2_tunnel_eth_type_result,
10332 eth_type_val, UINT16);
10334 static enum rte_eth_tunnel_type
10335 str2fdir_l2_tunnel_type(char *string)
10339 static const struct {
10341 enum rte_eth_tunnel_type type;
10342 } l2_tunnel_type_str[] = {
10343 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10346 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10347 if (!strcmp(l2_tunnel_type_str[i].str, string))
10348 return l2_tunnel_type_str[i].type;
10350 return RTE_TUNNEL_TYPE_NONE;
10353 /* ether type config for all ports */
10355 cmd_config_l2_tunnel_eth_type_all_parsed
10356 (void *parsed_result,
10357 __attribute__((unused)) struct cmdline *cl,
10358 __attribute__((unused)) void *data)
10360 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10361 struct rte_eth_l2_tunnel_conf entry;
10364 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10365 entry.ether_type = res->eth_type_val;
10367 RTE_ETH_FOREACH_DEV(pid) {
10368 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10372 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10373 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10375 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10377 (void *)&cmd_config_l2_tunnel_eth_type_port,
10378 (void *)&cmd_config_l2_tunnel_eth_type_config,
10379 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10380 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10381 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10382 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10383 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10388 /* ether type config for a specific port */
10390 cmd_config_l2_tunnel_eth_type_specific_parsed(
10391 void *parsed_result,
10392 __attribute__((unused)) struct cmdline *cl,
10393 __attribute__((unused)) void *data)
10395 struct cmd_config_l2_tunnel_eth_type_result *res =
10397 struct rte_eth_l2_tunnel_conf entry;
10399 if (port_id_is_invalid(res->id, ENABLED_WARN))
10402 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10403 entry.ether_type = res->eth_type_val;
10405 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10408 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10409 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10411 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10413 (void *)&cmd_config_l2_tunnel_eth_type_port,
10414 (void *)&cmd_config_l2_tunnel_eth_type_config,
10415 (void *)&cmd_config_l2_tunnel_eth_type_id,
10416 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10417 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10418 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10419 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10424 /* Enable/disable l2 tunnel */
10425 struct cmd_config_l2_tunnel_en_dis_result {
10426 cmdline_fixed_string_t port;
10427 cmdline_fixed_string_t config;
10428 cmdline_fixed_string_t all;
10430 cmdline_fixed_string_t l2_tunnel;
10431 cmdline_fixed_string_t l2_tunnel_type;
10432 cmdline_fixed_string_t en_dis;
10435 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10436 TOKEN_STRING_INITIALIZER
10437 (struct cmd_config_l2_tunnel_en_dis_result,
10439 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10440 TOKEN_STRING_INITIALIZER
10441 (struct cmd_config_l2_tunnel_en_dis_result,
10443 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10444 TOKEN_STRING_INITIALIZER
10445 (struct cmd_config_l2_tunnel_en_dis_result,
10447 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10448 TOKEN_NUM_INITIALIZER
10449 (struct cmd_config_l2_tunnel_en_dis_result,
10451 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10452 TOKEN_STRING_INITIALIZER
10453 (struct cmd_config_l2_tunnel_en_dis_result,
10454 l2_tunnel, "l2-tunnel");
10455 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10456 TOKEN_STRING_INITIALIZER
10457 (struct cmd_config_l2_tunnel_en_dis_result,
10458 l2_tunnel_type, "E-tag");
10459 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10460 TOKEN_STRING_INITIALIZER
10461 (struct cmd_config_l2_tunnel_en_dis_result,
10462 en_dis, "enable#disable");
10464 /* enable/disable l2 tunnel for all ports */
10466 cmd_config_l2_tunnel_en_dis_all_parsed(
10467 void *parsed_result,
10468 __attribute__((unused)) struct cmdline *cl,
10469 __attribute__((unused)) void *data)
10471 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10472 struct rte_eth_l2_tunnel_conf entry;
10476 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10478 if (!strcmp("enable", res->en_dis))
10483 RTE_ETH_FOREACH_DEV(pid) {
10484 rte_eth_dev_l2_tunnel_offload_set(pid,
10486 ETH_L2_TUNNEL_ENABLE_MASK,
10491 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10492 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10494 .help_str = "port config all l2-tunnel E-tag enable|disable",
10496 (void *)&cmd_config_l2_tunnel_en_dis_port,
10497 (void *)&cmd_config_l2_tunnel_en_dis_config,
10498 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10499 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10500 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10501 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10506 /* enable/disable l2 tunnel for a port */
10508 cmd_config_l2_tunnel_en_dis_specific_parsed(
10509 void *parsed_result,
10510 __attribute__((unused)) struct cmdline *cl,
10511 __attribute__((unused)) void *data)
10513 struct cmd_config_l2_tunnel_en_dis_result *res =
10515 struct rte_eth_l2_tunnel_conf entry;
10517 if (port_id_is_invalid(res->id, ENABLED_WARN))
10520 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10522 if (!strcmp("enable", res->en_dis))
10523 rte_eth_dev_l2_tunnel_offload_set(res->id,
10525 ETH_L2_TUNNEL_ENABLE_MASK,
10528 rte_eth_dev_l2_tunnel_offload_set(res->id,
10530 ETH_L2_TUNNEL_ENABLE_MASK,
10534 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10535 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10537 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10539 (void *)&cmd_config_l2_tunnel_en_dis_port,
10540 (void *)&cmd_config_l2_tunnel_en_dis_config,
10541 (void *)&cmd_config_l2_tunnel_en_dis_id,
10542 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10543 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10544 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10549 /* E-tag configuration */
10551 /* Common result structure for all E-tag configuration */
10552 struct cmd_config_e_tag_result {
10553 cmdline_fixed_string_t e_tag;
10554 cmdline_fixed_string_t set;
10555 cmdline_fixed_string_t insertion;
10556 cmdline_fixed_string_t stripping;
10557 cmdline_fixed_string_t forwarding;
10558 cmdline_fixed_string_t filter;
10559 cmdline_fixed_string_t add;
10560 cmdline_fixed_string_t del;
10561 cmdline_fixed_string_t on;
10562 cmdline_fixed_string_t off;
10563 cmdline_fixed_string_t on_off;
10564 cmdline_fixed_string_t port_tag_id;
10565 uint32_t port_tag_id_val;
10566 cmdline_fixed_string_t e_tag_id;
10567 uint16_t e_tag_id_val;
10568 cmdline_fixed_string_t dst_pool;
10569 uint8_t dst_pool_val;
10570 cmdline_fixed_string_t port;
10572 cmdline_fixed_string_t vf;
10576 /* Common CLI fields for all E-tag configuration */
10577 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10578 TOKEN_STRING_INITIALIZER
10579 (struct cmd_config_e_tag_result,
10581 cmdline_parse_token_string_t cmd_config_e_tag_set =
10582 TOKEN_STRING_INITIALIZER
10583 (struct cmd_config_e_tag_result,
10585 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10586 TOKEN_STRING_INITIALIZER
10587 (struct cmd_config_e_tag_result,
10588 insertion, "insertion");
10589 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10590 TOKEN_STRING_INITIALIZER
10591 (struct cmd_config_e_tag_result,
10592 stripping, "stripping");
10593 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10594 TOKEN_STRING_INITIALIZER
10595 (struct cmd_config_e_tag_result,
10596 forwarding, "forwarding");
10597 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10598 TOKEN_STRING_INITIALIZER
10599 (struct cmd_config_e_tag_result,
10601 cmdline_parse_token_string_t cmd_config_e_tag_add =
10602 TOKEN_STRING_INITIALIZER
10603 (struct cmd_config_e_tag_result,
10605 cmdline_parse_token_string_t cmd_config_e_tag_del =
10606 TOKEN_STRING_INITIALIZER
10607 (struct cmd_config_e_tag_result,
10609 cmdline_parse_token_string_t cmd_config_e_tag_on =
10610 TOKEN_STRING_INITIALIZER
10611 (struct cmd_config_e_tag_result,
10613 cmdline_parse_token_string_t cmd_config_e_tag_off =
10614 TOKEN_STRING_INITIALIZER
10615 (struct cmd_config_e_tag_result,
10617 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10618 TOKEN_STRING_INITIALIZER
10619 (struct cmd_config_e_tag_result,
10621 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10622 TOKEN_STRING_INITIALIZER
10623 (struct cmd_config_e_tag_result,
10624 port_tag_id, "port-tag-id");
10625 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10626 TOKEN_NUM_INITIALIZER
10627 (struct cmd_config_e_tag_result,
10628 port_tag_id_val, UINT32);
10629 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10630 TOKEN_STRING_INITIALIZER
10631 (struct cmd_config_e_tag_result,
10632 e_tag_id, "e-tag-id");
10633 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10634 TOKEN_NUM_INITIALIZER
10635 (struct cmd_config_e_tag_result,
10636 e_tag_id_val, UINT16);
10637 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10638 TOKEN_STRING_INITIALIZER
10639 (struct cmd_config_e_tag_result,
10640 dst_pool, "dst-pool");
10641 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10642 TOKEN_NUM_INITIALIZER
10643 (struct cmd_config_e_tag_result,
10644 dst_pool_val, UINT8);
10645 cmdline_parse_token_string_t cmd_config_e_tag_port =
10646 TOKEN_STRING_INITIALIZER
10647 (struct cmd_config_e_tag_result,
10649 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10650 TOKEN_NUM_INITIALIZER
10651 (struct cmd_config_e_tag_result,
10653 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10654 TOKEN_STRING_INITIALIZER
10655 (struct cmd_config_e_tag_result,
10657 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10658 TOKEN_NUM_INITIALIZER
10659 (struct cmd_config_e_tag_result,
10662 /* E-tag insertion configuration */
10664 cmd_config_e_tag_insertion_en_parsed(
10665 void *parsed_result,
10666 __attribute__((unused)) struct cmdline *cl,
10667 __attribute__((unused)) void *data)
10669 struct cmd_config_e_tag_result *res =
10671 struct rte_eth_l2_tunnel_conf entry;
10673 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10676 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10677 entry.tunnel_id = res->port_tag_id_val;
10678 entry.vf_id = res->vf_id;
10679 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10681 ETH_L2_TUNNEL_INSERTION_MASK,
10686 cmd_config_e_tag_insertion_dis_parsed(
10687 void *parsed_result,
10688 __attribute__((unused)) struct cmdline *cl,
10689 __attribute__((unused)) void *data)
10691 struct cmd_config_e_tag_result *res =
10693 struct rte_eth_l2_tunnel_conf entry;
10695 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10698 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10699 entry.vf_id = res->vf_id;
10701 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10703 ETH_L2_TUNNEL_INSERTION_MASK,
10707 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10708 .f = cmd_config_e_tag_insertion_en_parsed,
10710 .help_str = "E-tag ... : E-tag insertion enable",
10712 (void *)&cmd_config_e_tag_e_tag,
10713 (void *)&cmd_config_e_tag_set,
10714 (void *)&cmd_config_e_tag_insertion,
10715 (void *)&cmd_config_e_tag_on,
10716 (void *)&cmd_config_e_tag_port_tag_id,
10717 (void *)&cmd_config_e_tag_port_tag_id_val,
10718 (void *)&cmd_config_e_tag_port,
10719 (void *)&cmd_config_e_tag_port_id,
10720 (void *)&cmd_config_e_tag_vf,
10721 (void *)&cmd_config_e_tag_vf_id,
10726 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10727 .f = cmd_config_e_tag_insertion_dis_parsed,
10729 .help_str = "E-tag ... : E-tag insertion disable",
10731 (void *)&cmd_config_e_tag_e_tag,
10732 (void *)&cmd_config_e_tag_set,
10733 (void *)&cmd_config_e_tag_insertion,
10734 (void *)&cmd_config_e_tag_off,
10735 (void *)&cmd_config_e_tag_port,
10736 (void *)&cmd_config_e_tag_port_id,
10737 (void *)&cmd_config_e_tag_vf,
10738 (void *)&cmd_config_e_tag_vf_id,
10743 /* E-tag stripping configuration */
10745 cmd_config_e_tag_stripping_parsed(
10746 void *parsed_result,
10747 __attribute__((unused)) struct cmdline *cl,
10748 __attribute__((unused)) void *data)
10750 struct cmd_config_e_tag_result *res =
10752 struct rte_eth_l2_tunnel_conf entry;
10754 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10757 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10759 if (!strcmp(res->on_off, "on"))
10760 rte_eth_dev_l2_tunnel_offload_set
10763 ETH_L2_TUNNEL_STRIPPING_MASK,
10766 rte_eth_dev_l2_tunnel_offload_set
10769 ETH_L2_TUNNEL_STRIPPING_MASK,
10773 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10774 .f = cmd_config_e_tag_stripping_parsed,
10776 .help_str = "E-tag ... : E-tag stripping enable/disable",
10778 (void *)&cmd_config_e_tag_e_tag,
10779 (void *)&cmd_config_e_tag_set,
10780 (void *)&cmd_config_e_tag_stripping,
10781 (void *)&cmd_config_e_tag_on_off,
10782 (void *)&cmd_config_e_tag_port,
10783 (void *)&cmd_config_e_tag_port_id,
10788 /* E-tag forwarding configuration */
10790 cmd_config_e_tag_forwarding_parsed(
10791 void *parsed_result,
10792 __attribute__((unused)) struct cmdline *cl,
10793 __attribute__((unused)) void *data)
10795 struct cmd_config_e_tag_result *res = parsed_result;
10796 struct rte_eth_l2_tunnel_conf entry;
10798 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10801 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10803 if (!strcmp(res->on_off, "on"))
10804 rte_eth_dev_l2_tunnel_offload_set
10807 ETH_L2_TUNNEL_FORWARDING_MASK,
10810 rte_eth_dev_l2_tunnel_offload_set
10813 ETH_L2_TUNNEL_FORWARDING_MASK,
10817 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10818 .f = cmd_config_e_tag_forwarding_parsed,
10820 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10822 (void *)&cmd_config_e_tag_e_tag,
10823 (void *)&cmd_config_e_tag_set,
10824 (void *)&cmd_config_e_tag_forwarding,
10825 (void *)&cmd_config_e_tag_on_off,
10826 (void *)&cmd_config_e_tag_port,
10827 (void *)&cmd_config_e_tag_port_id,
10832 /* E-tag filter configuration */
10834 cmd_config_e_tag_filter_add_parsed(
10835 void *parsed_result,
10836 __attribute__((unused)) struct cmdline *cl,
10837 __attribute__((unused)) void *data)
10839 struct cmd_config_e_tag_result *res = parsed_result;
10840 struct rte_eth_l2_tunnel_conf entry;
10843 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10846 if (res->e_tag_id_val > 0x3fff) {
10847 printf("e-tag-id must be equal or less than 0x3fff.\n");
10851 ret = rte_eth_dev_filter_supported(res->port_id,
10852 RTE_ETH_FILTER_L2_TUNNEL);
10854 printf("E-tag filter is not supported on port %u.\n",
10859 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10860 entry.tunnel_id = res->e_tag_id_val;
10861 entry.pool = res->dst_pool_val;
10863 ret = rte_eth_dev_filter_ctrl(res->port_id,
10864 RTE_ETH_FILTER_L2_TUNNEL,
10865 RTE_ETH_FILTER_ADD,
10868 printf("E-tag filter programming error: (%s)\n",
10872 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10873 .f = cmd_config_e_tag_filter_add_parsed,
10875 .help_str = "E-tag ... : E-tag filter add",
10877 (void *)&cmd_config_e_tag_e_tag,
10878 (void *)&cmd_config_e_tag_set,
10879 (void *)&cmd_config_e_tag_filter,
10880 (void *)&cmd_config_e_tag_add,
10881 (void *)&cmd_config_e_tag_e_tag_id,
10882 (void *)&cmd_config_e_tag_e_tag_id_val,
10883 (void *)&cmd_config_e_tag_dst_pool,
10884 (void *)&cmd_config_e_tag_dst_pool_val,
10885 (void *)&cmd_config_e_tag_port,
10886 (void *)&cmd_config_e_tag_port_id,
10892 cmd_config_e_tag_filter_del_parsed(
10893 void *parsed_result,
10894 __attribute__((unused)) struct cmdline *cl,
10895 __attribute__((unused)) void *data)
10897 struct cmd_config_e_tag_result *res = parsed_result;
10898 struct rte_eth_l2_tunnel_conf entry;
10901 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10904 if (res->e_tag_id_val > 0x3fff) {
10905 printf("e-tag-id must be less than 0x3fff.\n");
10909 ret = rte_eth_dev_filter_supported(res->port_id,
10910 RTE_ETH_FILTER_L2_TUNNEL);
10912 printf("E-tag filter is not supported on port %u.\n",
10917 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10918 entry.tunnel_id = res->e_tag_id_val;
10920 ret = rte_eth_dev_filter_ctrl(res->port_id,
10921 RTE_ETH_FILTER_L2_TUNNEL,
10922 RTE_ETH_FILTER_DELETE,
10925 printf("E-tag filter programming error: (%s)\n",
10929 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10930 .f = cmd_config_e_tag_filter_del_parsed,
10932 .help_str = "E-tag ... : E-tag filter delete",
10934 (void *)&cmd_config_e_tag_e_tag,
10935 (void *)&cmd_config_e_tag_set,
10936 (void *)&cmd_config_e_tag_filter,
10937 (void *)&cmd_config_e_tag_del,
10938 (void *)&cmd_config_e_tag_e_tag_id,
10939 (void *)&cmd_config_e_tag_e_tag_id_val,
10940 (void *)&cmd_config_e_tag_port,
10941 (void *)&cmd_config_e_tag_port_id,
10946 /* vf vlan anti spoof configuration */
10948 /* Common result structure for vf vlan anti spoof */
10949 struct cmd_vf_vlan_anti_spoof_result {
10950 cmdline_fixed_string_t set;
10951 cmdline_fixed_string_t vf;
10952 cmdline_fixed_string_t vlan;
10953 cmdline_fixed_string_t antispoof;
10956 cmdline_fixed_string_t on_off;
10959 /* Common CLI fields for vf vlan anti spoof enable disable */
10960 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10961 TOKEN_STRING_INITIALIZER
10962 (struct cmd_vf_vlan_anti_spoof_result,
10964 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10965 TOKEN_STRING_INITIALIZER
10966 (struct cmd_vf_vlan_anti_spoof_result,
10968 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10969 TOKEN_STRING_INITIALIZER
10970 (struct cmd_vf_vlan_anti_spoof_result,
10972 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10973 TOKEN_STRING_INITIALIZER
10974 (struct cmd_vf_vlan_anti_spoof_result,
10975 antispoof, "antispoof");
10976 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10977 TOKEN_NUM_INITIALIZER
10978 (struct cmd_vf_vlan_anti_spoof_result,
10980 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10981 TOKEN_NUM_INITIALIZER
10982 (struct cmd_vf_vlan_anti_spoof_result,
10984 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10985 TOKEN_STRING_INITIALIZER
10986 (struct cmd_vf_vlan_anti_spoof_result,
10990 cmd_set_vf_vlan_anti_spoof_parsed(
10991 void *parsed_result,
10992 __attribute__((unused)) struct cmdline *cl,
10993 __attribute__((unused)) void *data)
10995 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10996 int ret = -ENOTSUP;
10998 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11003 #ifdef RTE_LIBRTE_IXGBE_PMD
11004 if (ret == -ENOTSUP)
11005 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11006 res->vf_id, is_on);
11008 #ifdef RTE_LIBRTE_I40E_PMD
11009 if (ret == -ENOTSUP)
11010 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11011 res->vf_id, is_on);
11018 printf("invalid vf_id %d\n", res->vf_id);
11021 printf("invalid port_id %d\n", res->port_id);
11024 printf("function not implemented\n");
11027 printf("programming error: (%s)\n", strerror(-ret));
11031 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11032 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11034 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11036 (void *)&cmd_vf_vlan_anti_spoof_set,
11037 (void *)&cmd_vf_vlan_anti_spoof_vf,
11038 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11039 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11040 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11041 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11042 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11047 /* vf mac anti spoof configuration */
11049 /* Common result structure for vf mac anti spoof */
11050 struct cmd_vf_mac_anti_spoof_result {
11051 cmdline_fixed_string_t set;
11052 cmdline_fixed_string_t vf;
11053 cmdline_fixed_string_t mac;
11054 cmdline_fixed_string_t antispoof;
11057 cmdline_fixed_string_t on_off;
11060 /* Common CLI fields for vf mac anti spoof enable disable */
11061 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11062 TOKEN_STRING_INITIALIZER
11063 (struct cmd_vf_mac_anti_spoof_result,
11065 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11066 TOKEN_STRING_INITIALIZER
11067 (struct cmd_vf_mac_anti_spoof_result,
11069 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11070 TOKEN_STRING_INITIALIZER
11071 (struct cmd_vf_mac_anti_spoof_result,
11073 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11074 TOKEN_STRING_INITIALIZER
11075 (struct cmd_vf_mac_anti_spoof_result,
11076 antispoof, "antispoof");
11077 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11078 TOKEN_NUM_INITIALIZER
11079 (struct cmd_vf_mac_anti_spoof_result,
11081 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11082 TOKEN_NUM_INITIALIZER
11083 (struct cmd_vf_mac_anti_spoof_result,
11085 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11086 TOKEN_STRING_INITIALIZER
11087 (struct cmd_vf_mac_anti_spoof_result,
11091 cmd_set_vf_mac_anti_spoof_parsed(
11092 void *parsed_result,
11093 __attribute__((unused)) struct cmdline *cl,
11094 __attribute__((unused)) void *data)
11096 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11097 int ret = -ENOTSUP;
11099 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11101 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11104 #ifdef RTE_LIBRTE_IXGBE_PMD
11105 if (ret == -ENOTSUP)
11106 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11107 res->vf_id, is_on);
11109 #ifdef RTE_LIBRTE_I40E_PMD
11110 if (ret == -ENOTSUP)
11111 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11112 res->vf_id, is_on);
11119 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11122 printf("invalid port_id %d\n", res->port_id);
11125 printf("function not implemented\n");
11128 printf("programming error: (%s)\n", strerror(-ret));
11132 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11133 .f = cmd_set_vf_mac_anti_spoof_parsed,
11135 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11137 (void *)&cmd_vf_mac_anti_spoof_set,
11138 (void *)&cmd_vf_mac_anti_spoof_vf,
11139 (void *)&cmd_vf_mac_anti_spoof_mac,
11140 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11141 (void *)&cmd_vf_mac_anti_spoof_port_id,
11142 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11143 (void *)&cmd_vf_mac_anti_spoof_on_off,
11148 /* vf vlan strip queue configuration */
11150 /* Common result structure for vf mac anti spoof */
11151 struct cmd_vf_vlan_stripq_result {
11152 cmdline_fixed_string_t set;
11153 cmdline_fixed_string_t vf;
11154 cmdline_fixed_string_t vlan;
11155 cmdline_fixed_string_t stripq;
11158 cmdline_fixed_string_t on_off;
11161 /* Common CLI fields for vf vlan strip enable disable */
11162 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11163 TOKEN_STRING_INITIALIZER
11164 (struct cmd_vf_vlan_stripq_result,
11166 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11167 TOKEN_STRING_INITIALIZER
11168 (struct cmd_vf_vlan_stripq_result,
11170 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11171 TOKEN_STRING_INITIALIZER
11172 (struct cmd_vf_vlan_stripq_result,
11174 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11175 TOKEN_STRING_INITIALIZER
11176 (struct cmd_vf_vlan_stripq_result,
11178 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11179 TOKEN_NUM_INITIALIZER
11180 (struct cmd_vf_vlan_stripq_result,
11182 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11183 TOKEN_NUM_INITIALIZER
11184 (struct cmd_vf_vlan_stripq_result,
11186 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11187 TOKEN_STRING_INITIALIZER
11188 (struct cmd_vf_vlan_stripq_result,
11192 cmd_set_vf_vlan_stripq_parsed(
11193 void *parsed_result,
11194 __attribute__((unused)) struct cmdline *cl,
11195 __attribute__((unused)) void *data)
11197 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11198 int ret = -ENOTSUP;
11200 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11202 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11205 #ifdef RTE_LIBRTE_IXGBE_PMD
11206 if (ret == -ENOTSUP)
11207 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11208 res->vf_id, is_on);
11210 #ifdef RTE_LIBRTE_I40E_PMD
11211 if (ret == -ENOTSUP)
11212 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11213 res->vf_id, is_on);
11220 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11223 printf("invalid port_id %d\n", res->port_id);
11226 printf("function not implemented\n");
11229 printf("programming error: (%s)\n", strerror(-ret));
11233 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11234 .f = cmd_set_vf_vlan_stripq_parsed,
11236 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11238 (void *)&cmd_vf_vlan_stripq_set,
11239 (void *)&cmd_vf_vlan_stripq_vf,
11240 (void *)&cmd_vf_vlan_stripq_vlan,
11241 (void *)&cmd_vf_vlan_stripq_stripq,
11242 (void *)&cmd_vf_vlan_stripq_port_id,
11243 (void *)&cmd_vf_vlan_stripq_vf_id,
11244 (void *)&cmd_vf_vlan_stripq_on_off,
11249 /* vf vlan insert configuration */
11251 /* Common result structure for vf vlan insert */
11252 struct cmd_vf_vlan_insert_result {
11253 cmdline_fixed_string_t set;
11254 cmdline_fixed_string_t vf;
11255 cmdline_fixed_string_t vlan;
11256 cmdline_fixed_string_t insert;
11262 /* Common CLI fields for vf vlan insert enable disable */
11263 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11264 TOKEN_STRING_INITIALIZER
11265 (struct cmd_vf_vlan_insert_result,
11267 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11268 TOKEN_STRING_INITIALIZER
11269 (struct cmd_vf_vlan_insert_result,
11271 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11272 TOKEN_STRING_INITIALIZER
11273 (struct cmd_vf_vlan_insert_result,
11275 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11276 TOKEN_STRING_INITIALIZER
11277 (struct cmd_vf_vlan_insert_result,
11279 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11280 TOKEN_NUM_INITIALIZER
11281 (struct cmd_vf_vlan_insert_result,
11283 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11284 TOKEN_NUM_INITIALIZER
11285 (struct cmd_vf_vlan_insert_result,
11287 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11288 TOKEN_NUM_INITIALIZER
11289 (struct cmd_vf_vlan_insert_result,
11293 cmd_set_vf_vlan_insert_parsed(
11294 void *parsed_result,
11295 __attribute__((unused)) struct cmdline *cl,
11296 __attribute__((unused)) void *data)
11298 struct cmd_vf_vlan_insert_result *res = parsed_result;
11299 int ret = -ENOTSUP;
11301 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11304 #ifdef RTE_LIBRTE_IXGBE_PMD
11305 if (ret == -ENOTSUP)
11306 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11309 #ifdef RTE_LIBRTE_I40E_PMD
11310 if (ret == -ENOTSUP)
11311 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11319 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11322 printf("invalid port_id %d\n", res->port_id);
11325 printf("function not implemented\n");
11328 printf("programming error: (%s)\n", strerror(-ret));
11332 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11333 .f = cmd_set_vf_vlan_insert_parsed,
11335 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11337 (void *)&cmd_vf_vlan_insert_set,
11338 (void *)&cmd_vf_vlan_insert_vf,
11339 (void *)&cmd_vf_vlan_insert_vlan,
11340 (void *)&cmd_vf_vlan_insert_insert,
11341 (void *)&cmd_vf_vlan_insert_port_id,
11342 (void *)&cmd_vf_vlan_insert_vf_id,
11343 (void *)&cmd_vf_vlan_insert_vlan_id,
11348 /* tx loopback configuration */
11350 /* Common result structure for tx loopback */
11351 struct cmd_tx_loopback_result {
11352 cmdline_fixed_string_t set;
11353 cmdline_fixed_string_t tx;
11354 cmdline_fixed_string_t loopback;
11356 cmdline_fixed_string_t on_off;
11359 /* Common CLI fields for tx loopback enable disable */
11360 cmdline_parse_token_string_t cmd_tx_loopback_set =
11361 TOKEN_STRING_INITIALIZER
11362 (struct cmd_tx_loopback_result,
11364 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11365 TOKEN_STRING_INITIALIZER
11366 (struct cmd_tx_loopback_result,
11368 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11369 TOKEN_STRING_INITIALIZER
11370 (struct cmd_tx_loopback_result,
11371 loopback, "loopback");
11372 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11373 TOKEN_NUM_INITIALIZER
11374 (struct cmd_tx_loopback_result,
11376 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11377 TOKEN_STRING_INITIALIZER
11378 (struct cmd_tx_loopback_result,
11382 cmd_set_tx_loopback_parsed(
11383 void *parsed_result,
11384 __attribute__((unused)) struct cmdline *cl,
11385 __attribute__((unused)) void *data)
11387 struct cmd_tx_loopback_result *res = parsed_result;
11388 int ret = -ENOTSUP;
11390 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11392 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11395 #ifdef RTE_LIBRTE_IXGBE_PMD
11396 if (ret == -ENOTSUP)
11397 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11399 #ifdef RTE_LIBRTE_I40E_PMD
11400 if (ret == -ENOTSUP)
11401 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11408 printf("invalid is_on %d\n", is_on);
11411 printf("invalid port_id %d\n", res->port_id);
11414 printf("function not implemented\n");
11417 printf("programming error: (%s)\n", strerror(-ret));
11421 cmdline_parse_inst_t cmd_set_tx_loopback = {
11422 .f = cmd_set_tx_loopback_parsed,
11424 .help_str = "set tx loopback <port_id> on|off",
11426 (void *)&cmd_tx_loopback_set,
11427 (void *)&cmd_tx_loopback_tx,
11428 (void *)&cmd_tx_loopback_loopback,
11429 (void *)&cmd_tx_loopback_port_id,
11430 (void *)&cmd_tx_loopback_on_off,
11435 #ifdef RTE_LIBRTE_IXGBE_PMD
11436 /* all queues drop enable configuration */
11438 /* Common result structure for all queues drop enable */
11439 struct cmd_all_queues_drop_en_result {
11440 cmdline_fixed_string_t set;
11441 cmdline_fixed_string_t all;
11442 cmdline_fixed_string_t queues;
11443 cmdline_fixed_string_t drop;
11445 cmdline_fixed_string_t on_off;
11448 /* Common CLI fields for tx loopback enable disable */
11449 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11450 TOKEN_STRING_INITIALIZER
11451 (struct cmd_all_queues_drop_en_result,
11453 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11454 TOKEN_STRING_INITIALIZER
11455 (struct cmd_all_queues_drop_en_result,
11457 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11458 TOKEN_STRING_INITIALIZER
11459 (struct cmd_all_queues_drop_en_result,
11461 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11462 TOKEN_STRING_INITIALIZER
11463 (struct cmd_all_queues_drop_en_result,
11465 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11466 TOKEN_NUM_INITIALIZER
11467 (struct cmd_all_queues_drop_en_result,
11469 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11470 TOKEN_STRING_INITIALIZER
11471 (struct cmd_all_queues_drop_en_result,
11475 cmd_set_all_queues_drop_en_parsed(
11476 void *parsed_result,
11477 __attribute__((unused)) struct cmdline *cl,
11478 __attribute__((unused)) void *data)
11480 struct cmd_all_queues_drop_en_result *res = parsed_result;
11482 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11484 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11487 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11492 printf("invalid is_on %d\n", is_on);
11495 printf("invalid port_id %d\n", res->port_id);
11498 printf("function not implemented\n");
11501 printf("programming error: (%s)\n", strerror(-ret));
11505 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11506 .f = cmd_set_all_queues_drop_en_parsed,
11508 .help_str = "set all queues drop <port_id> on|off",
11510 (void *)&cmd_all_queues_drop_en_set,
11511 (void *)&cmd_all_queues_drop_en_all,
11512 (void *)&cmd_all_queues_drop_en_queues,
11513 (void *)&cmd_all_queues_drop_en_drop,
11514 (void *)&cmd_all_queues_drop_en_port_id,
11515 (void *)&cmd_all_queues_drop_en_on_off,
11520 /* vf split drop enable configuration */
11522 /* Common result structure for vf split drop enable */
11523 struct cmd_vf_split_drop_en_result {
11524 cmdline_fixed_string_t set;
11525 cmdline_fixed_string_t vf;
11526 cmdline_fixed_string_t split;
11527 cmdline_fixed_string_t drop;
11530 cmdline_fixed_string_t on_off;
11533 /* Common CLI fields for vf split drop enable disable */
11534 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11535 TOKEN_STRING_INITIALIZER
11536 (struct cmd_vf_split_drop_en_result,
11538 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11539 TOKEN_STRING_INITIALIZER
11540 (struct cmd_vf_split_drop_en_result,
11542 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11543 TOKEN_STRING_INITIALIZER
11544 (struct cmd_vf_split_drop_en_result,
11546 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11547 TOKEN_STRING_INITIALIZER
11548 (struct cmd_vf_split_drop_en_result,
11550 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11551 TOKEN_NUM_INITIALIZER
11552 (struct cmd_vf_split_drop_en_result,
11554 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11555 TOKEN_NUM_INITIALIZER
11556 (struct cmd_vf_split_drop_en_result,
11558 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11559 TOKEN_STRING_INITIALIZER
11560 (struct cmd_vf_split_drop_en_result,
11564 cmd_set_vf_split_drop_en_parsed(
11565 void *parsed_result,
11566 __attribute__((unused)) struct cmdline *cl,
11567 __attribute__((unused)) void *data)
11569 struct cmd_vf_split_drop_en_result *res = parsed_result;
11571 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11573 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11576 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11582 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11585 printf("invalid port_id %d\n", res->port_id);
11588 printf("programming error: (%s)\n", strerror(-ret));
11592 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11593 .f = cmd_set_vf_split_drop_en_parsed,
11595 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11597 (void *)&cmd_vf_split_drop_en_set,
11598 (void *)&cmd_vf_split_drop_en_vf,
11599 (void *)&cmd_vf_split_drop_en_split,
11600 (void *)&cmd_vf_split_drop_en_drop,
11601 (void *)&cmd_vf_split_drop_en_port_id,
11602 (void *)&cmd_vf_split_drop_en_vf_id,
11603 (void *)&cmd_vf_split_drop_en_on_off,
11609 /* vf mac address configuration */
11611 /* Common result structure for vf mac address */
11612 struct cmd_set_vf_mac_addr_result {
11613 cmdline_fixed_string_t set;
11614 cmdline_fixed_string_t vf;
11615 cmdline_fixed_string_t mac;
11616 cmdline_fixed_string_t addr;
11619 struct ether_addr mac_addr;
11623 /* Common CLI fields for vf split drop enable disable */
11624 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11625 TOKEN_STRING_INITIALIZER
11626 (struct cmd_set_vf_mac_addr_result,
11628 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11629 TOKEN_STRING_INITIALIZER
11630 (struct cmd_set_vf_mac_addr_result,
11632 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11633 TOKEN_STRING_INITIALIZER
11634 (struct cmd_set_vf_mac_addr_result,
11636 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11637 TOKEN_STRING_INITIALIZER
11638 (struct cmd_set_vf_mac_addr_result,
11640 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11641 TOKEN_NUM_INITIALIZER
11642 (struct cmd_set_vf_mac_addr_result,
11644 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11645 TOKEN_NUM_INITIALIZER
11646 (struct cmd_set_vf_mac_addr_result,
11648 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11649 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11653 cmd_set_vf_mac_addr_parsed(
11654 void *parsed_result,
11655 __attribute__((unused)) struct cmdline *cl,
11656 __attribute__((unused)) void *data)
11658 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11659 int ret = -ENOTSUP;
11661 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11664 #ifdef RTE_LIBRTE_IXGBE_PMD
11665 if (ret == -ENOTSUP)
11666 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11669 #ifdef RTE_LIBRTE_I40E_PMD
11670 if (ret == -ENOTSUP)
11671 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11679 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11682 printf("invalid port_id %d\n", res->port_id);
11685 printf("function not implemented\n");
11688 printf("programming error: (%s)\n", strerror(-ret));
11692 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11693 .f = cmd_set_vf_mac_addr_parsed,
11695 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11697 (void *)&cmd_set_vf_mac_addr_set,
11698 (void *)&cmd_set_vf_mac_addr_vf,
11699 (void *)&cmd_set_vf_mac_addr_mac,
11700 (void *)&cmd_set_vf_mac_addr_addr,
11701 (void *)&cmd_set_vf_mac_addr_port_id,
11702 (void *)&cmd_set_vf_mac_addr_vf_id,
11703 (void *)&cmd_set_vf_mac_addr_mac_addr,
11708 #ifdef RTE_LIBRTE_IXGBE_PMD
11709 /* MACsec configuration */
11711 /* Common result structure for MACsec offload enable */
11712 struct cmd_macsec_offload_on_result {
11713 cmdline_fixed_string_t set;
11714 cmdline_fixed_string_t macsec;
11715 cmdline_fixed_string_t offload;
11717 cmdline_fixed_string_t on;
11718 cmdline_fixed_string_t encrypt;
11719 cmdline_fixed_string_t en_on_off;
11720 cmdline_fixed_string_t replay_protect;
11721 cmdline_fixed_string_t rp_on_off;
11724 /* Common CLI fields for MACsec offload disable */
11725 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11726 TOKEN_STRING_INITIALIZER
11727 (struct cmd_macsec_offload_on_result,
11729 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11730 TOKEN_STRING_INITIALIZER
11731 (struct cmd_macsec_offload_on_result,
11733 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11734 TOKEN_STRING_INITIALIZER
11735 (struct cmd_macsec_offload_on_result,
11736 offload, "offload");
11737 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11738 TOKEN_NUM_INITIALIZER
11739 (struct cmd_macsec_offload_on_result,
11741 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11742 TOKEN_STRING_INITIALIZER
11743 (struct cmd_macsec_offload_on_result,
11745 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11746 TOKEN_STRING_INITIALIZER
11747 (struct cmd_macsec_offload_on_result,
11748 encrypt, "encrypt");
11749 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11750 TOKEN_STRING_INITIALIZER
11751 (struct cmd_macsec_offload_on_result,
11752 en_on_off, "on#off");
11753 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11754 TOKEN_STRING_INITIALIZER
11755 (struct cmd_macsec_offload_on_result,
11756 replay_protect, "replay-protect");
11757 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11758 TOKEN_STRING_INITIALIZER
11759 (struct cmd_macsec_offload_on_result,
11760 rp_on_off, "on#off");
11763 cmd_set_macsec_offload_on_parsed(
11764 void *parsed_result,
11765 __attribute__((unused)) struct cmdline *cl,
11766 __attribute__((unused)) void *data)
11768 struct cmd_macsec_offload_on_result *res = parsed_result;
11770 portid_t port_id = res->port_id;
11771 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11772 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11774 if (port_id_is_invalid(port_id, ENABLED_WARN))
11777 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11778 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11784 printf("invalid port_id %d\n", port_id);
11787 printf("programming error: (%s)\n", strerror(-ret));
11791 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11792 .f = cmd_set_macsec_offload_on_parsed,
11794 .help_str = "set macsec offload <port_id> on "
11795 "encrypt on|off replay-protect on|off",
11797 (void *)&cmd_macsec_offload_on_set,
11798 (void *)&cmd_macsec_offload_on_macsec,
11799 (void *)&cmd_macsec_offload_on_offload,
11800 (void *)&cmd_macsec_offload_on_port_id,
11801 (void *)&cmd_macsec_offload_on_on,
11802 (void *)&cmd_macsec_offload_on_encrypt,
11803 (void *)&cmd_macsec_offload_on_en_on_off,
11804 (void *)&cmd_macsec_offload_on_replay_protect,
11805 (void *)&cmd_macsec_offload_on_rp_on_off,
11810 /* Common result structure for MACsec offload disable */
11811 struct cmd_macsec_offload_off_result {
11812 cmdline_fixed_string_t set;
11813 cmdline_fixed_string_t macsec;
11814 cmdline_fixed_string_t offload;
11816 cmdline_fixed_string_t off;
11819 /* Common CLI fields for MACsec offload disable */
11820 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11821 TOKEN_STRING_INITIALIZER
11822 (struct cmd_macsec_offload_off_result,
11824 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11825 TOKEN_STRING_INITIALIZER
11826 (struct cmd_macsec_offload_off_result,
11828 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11829 TOKEN_STRING_INITIALIZER
11830 (struct cmd_macsec_offload_off_result,
11831 offload, "offload");
11832 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11833 TOKEN_NUM_INITIALIZER
11834 (struct cmd_macsec_offload_off_result,
11836 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11837 TOKEN_STRING_INITIALIZER
11838 (struct cmd_macsec_offload_off_result,
11842 cmd_set_macsec_offload_off_parsed(
11843 void *parsed_result,
11844 __attribute__((unused)) struct cmdline *cl,
11845 __attribute__((unused)) void *data)
11847 struct cmd_macsec_offload_off_result *res = parsed_result;
11849 portid_t port_id = res->port_id;
11851 if (port_id_is_invalid(port_id, ENABLED_WARN))
11854 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11855 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11861 printf("invalid port_id %d\n", port_id);
11864 printf("programming error: (%s)\n", strerror(-ret));
11868 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11869 .f = cmd_set_macsec_offload_off_parsed,
11871 .help_str = "set macsec offload <port_id> off",
11873 (void *)&cmd_macsec_offload_off_set,
11874 (void *)&cmd_macsec_offload_off_macsec,
11875 (void *)&cmd_macsec_offload_off_offload,
11876 (void *)&cmd_macsec_offload_off_port_id,
11877 (void *)&cmd_macsec_offload_off_off,
11882 /* Common result structure for MACsec secure connection configure */
11883 struct cmd_macsec_sc_result {
11884 cmdline_fixed_string_t set;
11885 cmdline_fixed_string_t macsec;
11886 cmdline_fixed_string_t sc;
11887 cmdline_fixed_string_t tx_rx;
11889 struct ether_addr mac;
11893 /* Common CLI fields for MACsec secure connection configure */
11894 cmdline_parse_token_string_t cmd_macsec_sc_set =
11895 TOKEN_STRING_INITIALIZER
11896 (struct cmd_macsec_sc_result,
11898 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11899 TOKEN_STRING_INITIALIZER
11900 (struct cmd_macsec_sc_result,
11902 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11903 TOKEN_STRING_INITIALIZER
11904 (struct cmd_macsec_sc_result,
11906 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11907 TOKEN_STRING_INITIALIZER
11908 (struct cmd_macsec_sc_result,
11910 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11911 TOKEN_NUM_INITIALIZER
11912 (struct cmd_macsec_sc_result,
11914 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11915 TOKEN_ETHERADDR_INITIALIZER
11916 (struct cmd_macsec_sc_result,
11918 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11919 TOKEN_NUM_INITIALIZER
11920 (struct cmd_macsec_sc_result,
11924 cmd_set_macsec_sc_parsed(
11925 void *parsed_result,
11926 __attribute__((unused)) struct cmdline *cl,
11927 __attribute__((unused)) void *data)
11929 struct cmd_macsec_sc_result *res = parsed_result;
11931 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11934 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11935 res->mac.addr_bytes) :
11936 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11937 res->mac.addr_bytes, res->pi);
11942 printf("invalid port_id %d\n", res->port_id);
11945 printf("programming error: (%s)\n", strerror(-ret));
11949 cmdline_parse_inst_t cmd_set_macsec_sc = {
11950 .f = cmd_set_macsec_sc_parsed,
11952 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11954 (void *)&cmd_macsec_sc_set,
11955 (void *)&cmd_macsec_sc_macsec,
11956 (void *)&cmd_macsec_sc_sc,
11957 (void *)&cmd_macsec_sc_tx_rx,
11958 (void *)&cmd_macsec_sc_port_id,
11959 (void *)&cmd_macsec_sc_mac,
11960 (void *)&cmd_macsec_sc_pi,
11965 /* Common result structure for MACsec secure connection configure */
11966 struct cmd_macsec_sa_result {
11967 cmdline_fixed_string_t set;
11968 cmdline_fixed_string_t macsec;
11969 cmdline_fixed_string_t sa;
11970 cmdline_fixed_string_t tx_rx;
11975 cmdline_fixed_string_t key;
11978 /* Common CLI fields for MACsec secure connection configure */
11979 cmdline_parse_token_string_t cmd_macsec_sa_set =
11980 TOKEN_STRING_INITIALIZER
11981 (struct cmd_macsec_sa_result,
11983 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11984 TOKEN_STRING_INITIALIZER
11985 (struct cmd_macsec_sa_result,
11987 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11988 TOKEN_STRING_INITIALIZER
11989 (struct cmd_macsec_sa_result,
11991 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11992 TOKEN_STRING_INITIALIZER
11993 (struct cmd_macsec_sa_result,
11995 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11996 TOKEN_NUM_INITIALIZER
11997 (struct cmd_macsec_sa_result,
11999 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12000 TOKEN_NUM_INITIALIZER
12001 (struct cmd_macsec_sa_result,
12003 cmdline_parse_token_num_t cmd_macsec_sa_an =
12004 TOKEN_NUM_INITIALIZER
12005 (struct cmd_macsec_sa_result,
12007 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12008 TOKEN_NUM_INITIALIZER
12009 (struct cmd_macsec_sa_result,
12011 cmdline_parse_token_string_t cmd_macsec_sa_key =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_macsec_sa_result,
12017 cmd_set_macsec_sa_parsed(
12018 void *parsed_result,
12019 __attribute__((unused)) struct cmdline *cl,
12020 __attribute__((unused)) void *data)
12022 struct cmd_macsec_sa_result *res = parsed_result;
12024 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12025 uint8_t key[16] = { 0 };
12031 key_len = strlen(res->key) / 2;
12035 for (i = 0; i < key_len; i++) {
12036 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12039 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12042 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12046 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12047 res->idx, res->an, res->pn, key) :
12048 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12049 res->idx, res->an, res->pn, key);
12054 printf("invalid idx %d or an %d\n", res->idx, res->an);
12057 printf("invalid port_id %d\n", res->port_id);
12060 printf("programming error: (%s)\n", strerror(-ret));
12064 cmdline_parse_inst_t cmd_set_macsec_sa = {
12065 .f = cmd_set_macsec_sa_parsed,
12067 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12069 (void *)&cmd_macsec_sa_set,
12070 (void *)&cmd_macsec_sa_macsec,
12071 (void *)&cmd_macsec_sa_sa,
12072 (void *)&cmd_macsec_sa_tx_rx,
12073 (void *)&cmd_macsec_sa_port_id,
12074 (void *)&cmd_macsec_sa_idx,
12075 (void *)&cmd_macsec_sa_an,
12076 (void *)&cmd_macsec_sa_pn,
12077 (void *)&cmd_macsec_sa_key,
12083 /* VF unicast promiscuous mode configuration */
12085 /* Common result structure for VF unicast promiscuous mode */
12086 struct cmd_vf_promisc_result {
12087 cmdline_fixed_string_t set;
12088 cmdline_fixed_string_t vf;
12089 cmdline_fixed_string_t promisc;
12092 cmdline_fixed_string_t on_off;
12095 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12096 cmdline_parse_token_string_t cmd_vf_promisc_set =
12097 TOKEN_STRING_INITIALIZER
12098 (struct cmd_vf_promisc_result,
12100 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12101 TOKEN_STRING_INITIALIZER
12102 (struct cmd_vf_promisc_result,
12104 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_vf_promisc_result,
12107 promisc, "promisc");
12108 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12109 TOKEN_NUM_INITIALIZER
12110 (struct cmd_vf_promisc_result,
12112 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12113 TOKEN_NUM_INITIALIZER
12114 (struct cmd_vf_promisc_result,
12116 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_vf_promisc_result,
12122 cmd_set_vf_promisc_parsed(
12123 void *parsed_result,
12124 __attribute__((unused)) struct cmdline *cl,
12125 __attribute__((unused)) void *data)
12127 struct cmd_vf_promisc_result *res = parsed_result;
12128 int ret = -ENOTSUP;
12130 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12132 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12135 #ifdef RTE_LIBRTE_I40E_PMD
12136 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12137 res->vf_id, is_on);
12144 printf("invalid vf_id %d\n", res->vf_id);
12147 printf("invalid port_id %d\n", res->port_id);
12150 printf("function not implemented\n");
12153 printf("programming error: (%s)\n", strerror(-ret));
12157 cmdline_parse_inst_t cmd_set_vf_promisc = {
12158 .f = cmd_set_vf_promisc_parsed,
12160 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12161 "Set unicast promiscuous mode for a VF from the PF",
12163 (void *)&cmd_vf_promisc_set,
12164 (void *)&cmd_vf_promisc_vf,
12165 (void *)&cmd_vf_promisc_promisc,
12166 (void *)&cmd_vf_promisc_port_id,
12167 (void *)&cmd_vf_promisc_vf_id,
12168 (void *)&cmd_vf_promisc_on_off,
12173 /* VF multicast promiscuous mode configuration */
12175 /* Common result structure for VF multicast promiscuous mode */
12176 struct cmd_vf_allmulti_result {
12177 cmdline_fixed_string_t set;
12178 cmdline_fixed_string_t vf;
12179 cmdline_fixed_string_t allmulti;
12182 cmdline_fixed_string_t on_off;
12185 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12186 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12187 TOKEN_STRING_INITIALIZER
12188 (struct cmd_vf_allmulti_result,
12190 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12191 TOKEN_STRING_INITIALIZER
12192 (struct cmd_vf_allmulti_result,
12194 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12195 TOKEN_STRING_INITIALIZER
12196 (struct cmd_vf_allmulti_result,
12197 allmulti, "allmulti");
12198 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12199 TOKEN_NUM_INITIALIZER
12200 (struct cmd_vf_allmulti_result,
12202 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12203 TOKEN_NUM_INITIALIZER
12204 (struct cmd_vf_allmulti_result,
12206 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12207 TOKEN_STRING_INITIALIZER
12208 (struct cmd_vf_allmulti_result,
12212 cmd_set_vf_allmulti_parsed(
12213 void *parsed_result,
12214 __attribute__((unused)) struct cmdline *cl,
12215 __attribute__((unused)) void *data)
12217 struct cmd_vf_allmulti_result *res = parsed_result;
12218 int ret = -ENOTSUP;
12220 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12222 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12225 #ifdef RTE_LIBRTE_I40E_PMD
12226 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12227 res->vf_id, is_on);
12234 printf("invalid vf_id %d\n", res->vf_id);
12237 printf("invalid port_id %d\n", res->port_id);
12240 printf("function not implemented\n");
12243 printf("programming error: (%s)\n", strerror(-ret));
12247 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12248 .f = cmd_set_vf_allmulti_parsed,
12250 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12251 "Set multicast promiscuous mode for a VF from the PF",
12253 (void *)&cmd_vf_allmulti_set,
12254 (void *)&cmd_vf_allmulti_vf,
12255 (void *)&cmd_vf_allmulti_allmulti,
12256 (void *)&cmd_vf_allmulti_port_id,
12257 (void *)&cmd_vf_allmulti_vf_id,
12258 (void *)&cmd_vf_allmulti_on_off,
12263 /* vf broadcast mode configuration */
12265 /* Common result structure for vf broadcast */
12266 struct cmd_set_vf_broadcast_result {
12267 cmdline_fixed_string_t set;
12268 cmdline_fixed_string_t vf;
12269 cmdline_fixed_string_t broadcast;
12272 cmdline_fixed_string_t on_off;
12275 /* Common CLI fields for vf broadcast enable disable */
12276 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12277 TOKEN_STRING_INITIALIZER
12278 (struct cmd_set_vf_broadcast_result,
12280 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12281 TOKEN_STRING_INITIALIZER
12282 (struct cmd_set_vf_broadcast_result,
12284 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12285 TOKEN_STRING_INITIALIZER
12286 (struct cmd_set_vf_broadcast_result,
12287 broadcast, "broadcast");
12288 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12289 TOKEN_NUM_INITIALIZER
12290 (struct cmd_set_vf_broadcast_result,
12292 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12293 TOKEN_NUM_INITIALIZER
12294 (struct cmd_set_vf_broadcast_result,
12296 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12297 TOKEN_STRING_INITIALIZER
12298 (struct cmd_set_vf_broadcast_result,
12302 cmd_set_vf_broadcast_parsed(
12303 void *parsed_result,
12304 __attribute__((unused)) struct cmdline *cl,
12305 __attribute__((unused)) void *data)
12307 struct cmd_set_vf_broadcast_result *res = parsed_result;
12308 int ret = -ENOTSUP;
12310 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12315 #ifdef RTE_LIBRTE_I40E_PMD
12316 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12317 res->vf_id, is_on);
12324 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12327 printf("invalid port_id %d\n", res->port_id);
12330 printf("function not implemented\n");
12333 printf("programming error: (%s)\n", strerror(-ret));
12337 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12338 .f = cmd_set_vf_broadcast_parsed,
12340 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12342 (void *)&cmd_set_vf_broadcast_set,
12343 (void *)&cmd_set_vf_broadcast_vf,
12344 (void *)&cmd_set_vf_broadcast_broadcast,
12345 (void *)&cmd_set_vf_broadcast_port_id,
12346 (void *)&cmd_set_vf_broadcast_vf_id,
12347 (void *)&cmd_set_vf_broadcast_on_off,
12352 /* vf vlan tag configuration */
12354 /* Common result structure for vf vlan tag */
12355 struct cmd_set_vf_vlan_tag_result {
12356 cmdline_fixed_string_t set;
12357 cmdline_fixed_string_t vf;
12358 cmdline_fixed_string_t vlan;
12359 cmdline_fixed_string_t tag;
12362 cmdline_fixed_string_t on_off;
12365 /* Common CLI fields for vf vlan tag enable disable */
12366 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12367 TOKEN_STRING_INITIALIZER
12368 (struct cmd_set_vf_vlan_tag_result,
12370 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12371 TOKEN_STRING_INITIALIZER
12372 (struct cmd_set_vf_vlan_tag_result,
12374 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12375 TOKEN_STRING_INITIALIZER
12376 (struct cmd_set_vf_vlan_tag_result,
12378 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_set_vf_vlan_tag_result,
12382 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12383 TOKEN_NUM_INITIALIZER
12384 (struct cmd_set_vf_vlan_tag_result,
12386 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12387 TOKEN_NUM_INITIALIZER
12388 (struct cmd_set_vf_vlan_tag_result,
12390 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12391 TOKEN_STRING_INITIALIZER
12392 (struct cmd_set_vf_vlan_tag_result,
12396 cmd_set_vf_vlan_tag_parsed(
12397 void *parsed_result,
12398 __attribute__((unused)) struct cmdline *cl,
12399 __attribute__((unused)) void *data)
12401 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12402 int ret = -ENOTSUP;
12404 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12406 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12409 #ifdef RTE_LIBRTE_I40E_PMD
12410 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12411 res->vf_id, is_on);
12418 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12421 printf("invalid port_id %d\n", res->port_id);
12424 printf("function not implemented\n");
12427 printf("programming error: (%s)\n", strerror(-ret));
12431 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12432 .f = cmd_set_vf_vlan_tag_parsed,
12434 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12436 (void *)&cmd_set_vf_vlan_tag_set,
12437 (void *)&cmd_set_vf_vlan_tag_vf,
12438 (void *)&cmd_set_vf_vlan_tag_vlan,
12439 (void *)&cmd_set_vf_vlan_tag_tag,
12440 (void *)&cmd_set_vf_vlan_tag_port_id,
12441 (void *)&cmd_set_vf_vlan_tag_vf_id,
12442 (void *)&cmd_set_vf_vlan_tag_on_off,
12447 /* Common definition of VF and TC TX bandwidth configuration */
12448 struct cmd_vf_tc_bw_result {
12449 cmdline_fixed_string_t set;
12450 cmdline_fixed_string_t vf;
12451 cmdline_fixed_string_t tc;
12452 cmdline_fixed_string_t tx;
12453 cmdline_fixed_string_t min_bw;
12454 cmdline_fixed_string_t max_bw;
12455 cmdline_fixed_string_t strict_link_prio;
12460 cmdline_fixed_string_t bw_list;
12464 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_vf_tc_bw_result,
12468 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_vf_tc_bw_result,
12472 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_vf_tc_bw_result,
12476 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_vf_tc_bw_result,
12480 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12481 TOKEN_STRING_INITIALIZER
12482 (struct cmd_vf_tc_bw_result,
12483 strict_link_prio, "strict-link-priority");
12484 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12485 TOKEN_STRING_INITIALIZER
12486 (struct cmd_vf_tc_bw_result,
12487 min_bw, "min-bandwidth");
12488 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_vf_tc_bw_result,
12491 max_bw, "max-bandwidth");
12492 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12493 TOKEN_NUM_INITIALIZER
12494 (struct cmd_vf_tc_bw_result,
12496 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12497 TOKEN_NUM_INITIALIZER
12498 (struct cmd_vf_tc_bw_result,
12500 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12501 TOKEN_NUM_INITIALIZER
12502 (struct cmd_vf_tc_bw_result,
12504 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12505 TOKEN_NUM_INITIALIZER
12506 (struct cmd_vf_tc_bw_result,
12508 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12509 TOKEN_STRING_INITIALIZER
12510 (struct cmd_vf_tc_bw_result,
12512 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12513 TOKEN_NUM_INITIALIZER
12514 (struct cmd_vf_tc_bw_result,
12517 /* VF max bandwidth setting */
12519 cmd_vf_max_bw_parsed(
12520 void *parsed_result,
12521 __attribute__((unused)) struct cmdline *cl,
12522 __attribute__((unused)) void *data)
12524 struct cmd_vf_tc_bw_result *res = parsed_result;
12525 int ret = -ENOTSUP;
12527 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12530 #ifdef RTE_LIBRTE_I40E_PMD
12531 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12532 res->vf_id, res->bw);
12539 printf("invalid vf_id %d or bandwidth %d\n",
12540 res->vf_id, res->bw);
12543 printf("invalid port_id %d\n", res->port_id);
12546 printf("function not implemented\n");
12549 printf("programming error: (%s)\n", strerror(-ret));
12553 cmdline_parse_inst_t cmd_vf_max_bw = {
12554 .f = cmd_vf_max_bw_parsed,
12556 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12558 (void *)&cmd_vf_tc_bw_set,
12559 (void *)&cmd_vf_tc_bw_vf,
12560 (void *)&cmd_vf_tc_bw_tx,
12561 (void *)&cmd_vf_tc_bw_max_bw,
12562 (void *)&cmd_vf_tc_bw_port_id,
12563 (void *)&cmd_vf_tc_bw_vf_id,
12564 (void *)&cmd_vf_tc_bw_bw,
12570 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12575 const char *p, *p0 = str;
12582 p = strchr(p0, '(');
12584 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12588 p0 = strchr(p, ')');
12590 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12594 if (size >= sizeof(s)) {
12595 printf("The string size exceeds the internal buffer size\n");
12598 snprintf(s, sizeof(s), "%.*s", size, p);
12599 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12601 printf("Failed to get the bandwidth list. ");
12605 for (i = 0; i < ret; i++)
12606 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12611 /* TC min bandwidth setting */
12613 cmd_vf_tc_min_bw_parsed(
12614 void *parsed_result,
12615 __attribute__((unused)) struct cmdline *cl,
12616 __attribute__((unused)) void *data)
12618 struct cmd_vf_tc_bw_result *res = parsed_result;
12621 int ret = -ENOTSUP;
12623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12626 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12630 #ifdef RTE_LIBRTE_I40E_PMD
12631 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12639 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12642 printf("invalid port_id %d\n", res->port_id);
12645 printf("function not implemented\n");
12648 printf("programming error: (%s)\n", strerror(-ret));
12652 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12653 .f = cmd_vf_tc_min_bw_parsed,
12655 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12656 " <bw1, bw2, ...>",
12658 (void *)&cmd_vf_tc_bw_set,
12659 (void *)&cmd_vf_tc_bw_vf,
12660 (void *)&cmd_vf_tc_bw_tc,
12661 (void *)&cmd_vf_tc_bw_tx,
12662 (void *)&cmd_vf_tc_bw_min_bw,
12663 (void *)&cmd_vf_tc_bw_port_id,
12664 (void *)&cmd_vf_tc_bw_vf_id,
12665 (void *)&cmd_vf_tc_bw_bw_list,
12671 cmd_tc_min_bw_parsed(
12672 void *parsed_result,
12673 __attribute__((unused)) struct cmdline *cl,
12674 __attribute__((unused)) void *data)
12676 struct cmd_vf_tc_bw_result *res = parsed_result;
12677 struct rte_port *port;
12680 int ret = -ENOTSUP;
12682 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12685 port = &ports[res->port_id];
12686 /** Check if the port is not started **/
12687 if (port->port_status != RTE_PORT_STOPPED) {
12688 printf("Please stop port %d first\n", res->port_id);
12692 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12696 #ifdef RTE_LIBRTE_IXGBE_PMD
12697 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12704 printf("invalid bandwidth\n");
12707 printf("invalid port_id %d\n", res->port_id);
12710 printf("function not implemented\n");
12713 printf("programming error: (%s)\n", strerror(-ret));
12717 cmdline_parse_inst_t cmd_tc_min_bw = {
12718 .f = cmd_tc_min_bw_parsed,
12720 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12722 (void *)&cmd_vf_tc_bw_set,
12723 (void *)&cmd_vf_tc_bw_tc,
12724 (void *)&cmd_vf_tc_bw_tx,
12725 (void *)&cmd_vf_tc_bw_min_bw,
12726 (void *)&cmd_vf_tc_bw_port_id,
12727 (void *)&cmd_vf_tc_bw_bw_list,
12732 /* TC max bandwidth setting */
12734 cmd_vf_tc_max_bw_parsed(
12735 void *parsed_result,
12736 __attribute__((unused)) struct cmdline *cl,
12737 __attribute__((unused)) void *data)
12739 struct cmd_vf_tc_bw_result *res = parsed_result;
12740 int ret = -ENOTSUP;
12742 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12745 #ifdef RTE_LIBRTE_I40E_PMD
12746 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12747 res->tc_no, res->bw);
12754 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12755 res->vf_id, res->tc_no, res->bw);
12758 printf("invalid port_id %d\n", res->port_id);
12761 printf("function not implemented\n");
12764 printf("programming error: (%s)\n", strerror(-ret));
12768 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12769 .f = cmd_vf_tc_max_bw_parsed,
12771 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12774 (void *)&cmd_vf_tc_bw_set,
12775 (void *)&cmd_vf_tc_bw_vf,
12776 (void *)&cmd_vf_tc_bw_tc,
12777 (void *)&cmd_vf_tc_bw_tx,
12778 (void *)&cmd_vf_tc_bw_max_bw,
12779 (void *)&cmd_vf_tc_bw_port_id,
12780 (void *)&cmd_vf_tc_bw_vf_id,
12781 (void *)&cmd_vf_tc_bw_tc_no,
12782 (void *)&cmd_vf_tc_bw_bw,
12787 /* Strict link priority scheduling mode setting */
12789 cmd_strict_link_prio_parsed(
12790 void *parsed_result,
12791 __attribute__((unused)) struct cmdline *cl,
12792 __attribute__((unused)) void *data)
12794 struct cmd_vf_tc_bw_result *res = parsed_result;
12795 int ret = -ENOTSUP;
12797 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12800 #ifdef RTE_LIBRTE_I40E_PMD
12801 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12808 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12811 printf("invalid port_id %d\n", res->port_id);
12814 printf("function not implemented\n");
12817 printf("programming error: (%s)\n", strerror(-ret));
12821 cmdline_parse_inst_t cmd_strict_link_prio = {
12822 .f = cmd_strict_link_prio_parsed,
12824 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12826 (void *)&cmd_vf_tc_bw_set,
12827 (void *)&cmd_vf_tc_bw_tx,
12828 (void *)&cmd_vf_tc_bw_strict_link_prio,
12829 (void *)&cmd_vf_tc_bw_port_id,
12830 (void *)&cmd_vf_tc_bw_tc_map,
12835 /* Load dynamic device personalization*/
12836 struct cmd_ddp_add_result {
12837 cmdline_fixed_string_t ddp;
12838 cmdline_fixed_string_t add;
12843 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12844 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12845 cmdline_parse_token_string_t cmd_ddp_add_add =
12846 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12847 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12848 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12849 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12850 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12853 cmd_ddp_add_parsed(
12854 void *parsed_result,
12855 __attribute__((unused)) struct cmdline *cl,
12856 __attribute__((unused)) void *data)
12858 struct cmd_ddp_add_result *res = parsed_result;
12861 int ret = -ENOTSUP;
12863 if (res->port_id > nb_ports) {
12864 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12868 if (!all_ports_stopped()) {
12869 printf("Please stop all ports first\n");
12873 buff = open_ddp_package_file(res->filepath, &size);
12877 #ifdef RTE_LIBRTE_I40E_PMD
12878 if (ret == -ENOTSUP)
12879 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12881 RTE_PMD_I40E_PKG_OP_WR_ADD);
12885 printf("Failed to load profile.\n");
12887 printf("Profile has already existed.\n");
12889 close_ddp_package_file(buff);
12892 cmdline_parse_inst_t cmd_ddp_add = {
12893 .f = cmd_ddp_add_parsed,
12895 .help_str = "ddp add <port_id> <profile_path>",
12897 (void *)&cmd_ddp_add_ddp,
12898 (void *)&cmd_ddp_add_add,
12899 (void *)&cmd_ddp_add_port_id,
12900 (void *)&cmd_ddp_add_filepath,
12905 /* Get dynamic device personalization profile info list*/
12906 #define PROFILE_INFO_SIZE 48
12907 #define MAX_PROFILE_NUM 16
12909 struct cmd_ddp_get_list_result {
12910 cmdline_fixed_string_t ddp;
12911 cmdline_fixed_string_t get;
12912 cmdline_fixed_string_t list;
12916 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
12917 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
12918 cmdline_parse_token_string_t cmd_ddp_get_list_get =
12919 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
12920 cmdline_parse_token_string_t cmd_ddp_get_list_list =
12921 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
12922 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
12923 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
12926 cmd_ddp_get_list_parsed(
12927 void *parsed_result,
12928 __attribute__((unused)) struct cmdline *cl,
12929 __attribute__((unused)) void *data)
12931 struct cmd_ddp_get_list_result *res = parsed_result;
12932 #ifdef RTE_LIBRTE_I40E_PMD
12933 struct rte_pmd_i40e_profile_list *p_list;
12934 struct rte_pmd_i40e_profile_info *p_info;
12939 int ret = -ENOTSUP;
12941 if (res->port_id > nb_ports) {
12942 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12946 #ifdef RTE_LIBRTE_I40E_PMD
12947 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
12948 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
12950 printf("%s: Failed to malloc buffer\n", __func__);
12952 if (ret == -ENOTSUP)
12953 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
12954 (uint8_t *)p_list, size);
12957 p_num = p_list->p_count;
12958 printf("Profile number is: %d\n\n", p_num);
12960 for (i = 0; i < p_num; i++) {
12961 p_info = &p_list->p_info[i];
12962 printf("Profile %d:\n", i);
12963 printf("Track id: 0x%x\n", p_info->track_id);
12964 printf("Version: %d.%d.%d.%d\n",
12965 p_info->version.major,
12966 p_info->version.minor,
12967 p_info->version.update,
12968 p_info->version.draft);
12969 printf("Profile name: %s\n\n", p_info->name);
12977 printf("Failed to get ddp list\n");
12980 cmdline_parse_inst_t cmd_ddp_get_list = {
12981 .f = cmd_ddp_get_list_parsed,
12983 .help_str = "ddp get list <port_id>",
12985 (void *)&cmd_ddp_get_list_ddp,
12986 (void *)&cmd_ddp_get_list_get,
12987 (void *)&cmd_ddp_get_list_list,
12988 (void *)&cmd_ddp_get_list_port_id,
12993 /* show vf stats */
12995 /* Common result structure for show vf stats */
12996 struct cmd_show_vf_stats_result {
12997 cmdline_fixed_string_t show;
12998 cmdline_fixed_string_t vf;
12999 cmdline_fixed_string_t stats;
13004 /* Common CLI fields show vf stats*/
13005 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13006 TOKEN_STRING_INITIALIZER
13007 (struct cmd_show_vf_stats_result,
13009 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13010 TOKEN_STRING_INITIALIZER
13011 (struct cmd_show_vf_stats_result,
13013 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13014 TOKEN_STRING_INITIALIZER
13015 (struct cmd_show_vf_stats_result,
13017 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13018 TOKEN_NUM_INITIALIZER
13019 (struct cmd_show_vf_stats_result,
13021 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13022 TOKEN_NUM_INITIALIZER
13023 (struct cmd_show_vf_stats_result,
13027 cmd_show_vf_stats_parsed(
13028 void *parsed_result,
13029 __attribute__((unused)) struct cmdline *cl,
13030 __attribute__((unused)) void *data)
13032 struct cmd_show_vf_stats_result *res = parsed_result;
13033 struct rte_eth_stats stats;
13034 int ret = -ENOTSUP;
13035 static const char *nic_stats_border = "########################";
13037 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13040 memset(&stats, 0, sizeof(stats));
13042 #ifdef RTE_LIBRTE_I40E_PMD
13043 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13052 printf("invalid vf_id %d\n", res->vf_id);
13055 printf("invalid port_id %d\n", res->port_id);
13058 printf("function not implemented\n");
13061 printf("programming error: (%s)\n", strerror(-ret));
13064 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13065 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13067 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13069 stats.ipackets, stats.imissed, stats.ibytes);
13070 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13071 printf(" RX-nombuf: %-10"PRIu64"\n",
13073 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13075 stats.opackets, stats.oerrors, stats.obytes);
13077 printf(" %s############################%s\n",
13078 nic_stats_border, nic_stats_border);
13081 cmdline_parse_inst_t cmd_show_vf_stats = {
13082 .f = cmd_show_vf_stats_parsed,
13084 .help_str = "show vf stats <port_id> <vf_id>",
13086 (void *)&cmd_show_vf_stats_show,
13087 (void *)&cmd_show_vf_stats_vf,
13088 (void *)&cmd_show_vf_stats_stats,
13089 (void *)&cmd_show_vf_stats_port_id,
13090 (void *)&cmd_show_vf_stats_vf_id,
13095 /* clear vf stats */
13097 /* Common result structure for clear vf stats */
13098 struct cmd_clear_vf_stats_result {
13099 cmdline_fixed_string_t clear;
13100 cmdline_fixed_string_t vf;
13101 cmdline_fixed_string_t stats;
13106 /* Common CLI fields clear vf stats*/
13107 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13108 TOKEN_STRING_INITIALIZER
13109 (struct cmd_clear_vf_stats_result,
13111 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13112 TOKEN_STRING_INITIALIZER
13113 (struct cmd_clear_vf_stats_result,
13115 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13116 TOKEN_STRING_INITIALIZER
13117 (struct cmd_clear_vf_stats_result,
13119 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13120 TOKEN_NUM_INITIALIZER
13121 (struct cmd_clear_vf_stats_result,
13123 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13124 TOKEN_NUM_INITIALIZER
13125 (struct cmd_clear_vf_stats_result,
13129 cmd_clear_vf_stats_parsed(
13130 void *parsed_result,
13131 __attribute__((unused)) struct cmdline *cl,
13132 __attribute__((unused)) void *data)
13134 struct cmd_clear_vf_stats_result *res = parsed_result;
13135 int ret = -ENOTSUP;
13137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13140 #ifdef RTE_LIBRTE_I40E_PMD
13141 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13149 printf("invalid vf_id %d\n", res->vf_id);
13152 printf("invalid port_id %d\n", res->port_id);
13155 printf("function not implemented\n");
13158 printf("programming error: (%s)\n", strerror(-ret));
13162 cmdline_parse_inst_t cmd_clear_vf_stats = {
13163 .f = cmd_clear_vf_stats_parsed,
13165 .help_str = "clear vf stats <port_id> <vf_id>",
13167 (void *)&cmd_clear_vf_stats_clear,
13168 (void *)&cmd_clear_vf_stats_vf,
13169 (void *)&cmd_clear_vf_stats_stats,
13170 (void *)&cmd_clear_vf_stats_port_id,
13171 (void *)&cmd_clear_vf_stats_vf_id,
13176 /* ptype mapping get */
13178 /* Common result structure for ptype mapping get */
13179 struct cmd_ptype_mapping_get_result {
13180 cmdline_fixed_string_t ptype;
13181 cmdline_fixed_string_t mapping;
13182 cmdline_fixed_string_t get;
13184 uint8_t valid_only;
13187 /* Common CLI fields for ptype mapping get */
13188 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13189 TOKEN_STRING_INITIALIZER
13190 (struct cmd_ptype_mapping_get_result,
13192 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13193 TOKEN_STRING_INITIALIZER
13194 (struct cmd_ptype_mapping_get_result,
13195 mapping, "mapping");
13196 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13197 TOKEN_STRING_INITIALIZER
13198 (struct cmd_ptype_mapping_get_result,
13200 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13201 TOKEN_NUM_INITIALIZER
13202 (struct cmd_ptype_mapping_get_result,
13204 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13205 TOKEN_NUM_INITIALIZER
13206 (struct cmd_ptype_mapping_get_result,
13207 valid_only, UINT8);
13210 cmd_ptype_mapping_get_parsed(
13211 void *parsed_result,
13212 __attribute__((unused)) struct cmdline *cl,
13213 __attribute__((unused)) void *data)
13215 struct cmd_ptype_mapping_get_result *res = parsed_result;
13216 int ret = -ENOTSUP;
13217 #ifdef RTE_LIBRTE_I40E_PMD
13218 int max_ptype_num = 256;
13219 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13227 #ifdef RTE_LIBRTE_I40E_PMD
13228 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13239 printf("invalid port_id %d\n", res->port_id);
13242 printf("function not implemented\n");
13245 printf("programming error: (%s)\n", strerror(-ret));
13248 #ifdef RTE_LIBRTE_I40E_PMD
13250 for (i = 0; i < count; i++)
13251 printf("%3d\t0x%08x\n",
13252 mapping[i].hw_ptype, mapping[i].sw_ptype);
13257 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13258 .f = cmd_ptype_mapping_get_parsed,
13260 .help_str = "ptype mapping get <port_id> <valid_only>",
13262 (void *)&cmd_ptype_mapping_get_ptype,
13263 (void *)&cmd_ptype_mapping_get_mapping,
13264 (void *)&cmd_ptype_mapping_get_get,
13265 (void *)&cmd_ptype_mapping_get_port_id,
13266 (void *)&cmd_ptype_mapping_get_valid_only,
13271 /* ptype mapping replace */
13273 /* Common result structure for ptype mapping replace */
13274 struct cmd_ptype_mapping_replace_result {
13275 cmdline_fixed_string_t ptype;
13276 cmdline_fixed_string_t mapping;
13277 cmdline_fixed_string_t replace;
13284 /* Common CLI fields for ptype mapping replace */
13285 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13286 TOKEN_STRING_INITIALIZER
13287 (struct cmd_ptype_mapping_replace_result,
13289 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13290 TOKEN_STRING_INITIALIZER
13291 (struct cmd_ptype_mapping_replace_result,
13292 mapping, "mapping");
13293 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13294 TOKEN_STRING_INITIALIZER
13295 (struct cmd_ptype_mapping_replace_result,
13296 replace, "replace");
13297 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13298 TOKEN_NUM_INITIALIZER
13299 (struct cmd_ptype_mapping_replace_result,
13301 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13302 TOKEN_NUM_INITIALIZER
13303 (struct cmd_ptype_mapping_replace_result,
13305 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13306 TOKEN_NUM_INITIALIZER
13307 (struct cmd_ptype_mapping_replace_result,
13309 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13310 TOKEN_NUM_INITIALIZER
13311 (struct cmd_ptype_mapping_replace_result,
13315 cmd_ptype_mapping_replace_parsed(
13316 void *parsed_result,
13317 __attribute__((unused)) struct cmdline *cl,
13318 __attribute__((unused)) void *data)
13320 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13321 int ret = -ENOTSUP;
13323 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13326 #ifdef RTE_LIBRTE_I40E_PMD
13327 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13337 printf("invalid ptype 0x%8x or 0x%8x\n",
13338 res->target, res->pkt_type);
13341 printf("invalid port_id %d\n", res->port_id);
13344 printf("function not implemented\n");
13347 printf("programming error: (%s)\n", strerror(-ret));
13351 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13352 .f = cmd_ptype_mapping_replace_parsed,
13355 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13357 (void *)&cmd_ptype_mapping_replace_ptype,
13358 (void *)&cmd_ptype_mapping_replace_mapping,
13359 (void *)&cmd_ptype_mapping_replace_replace,
13360 (void *)&cmd_ptype_mapping_replace_port_id,
13361 (void *)&cmd_ptype_mapping_replace_target,
13362 (void *)&cmd_ptype_mapping_replace_mask,
13363 (void *)&cmd_ptype_mapping_replace_pkt_type,
13368 /* ptype mapping reset */
13370 /* Common result structure for ptype mapping reset */
13371 struct cmd_ptype_mapping_reset_result {
13372 cmdline_fixed_string_t ptype;
13373 cmdline_fixed_string_t mapping;
13374 cmdline_fixed_string_t reset;
13378 /* Common CLI fields for ptype mapping reset*/
13379 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
13380 TOKEN_STRING_INITIALIZER
13381 (struct cmd_ptype_mapping_reset_result,
13383 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
13384 TOKEN_STRING_INITIALIZER
13385 (struct cmd_ptype_mapping_reset_result,
13386 mapping, "mapping");
13387 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
13388 TOKEN_STRING_INITIALIZER
13389 (struct cmd_ptype_mapping_reset_result,
13391 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
13392 TOKEN_NUM_INITIALIZER
13393 (struct cmd_ptype_mapping_reset_result,
13397 cmd_ptype_mapping_reset_parsed(
13398 void *parsed_result,
13399 __attribute__((unused)) struct cmdline *cl,
13400 __attribute__((unused)) void *data)
13402 struct cmd_ptype_mapping_reset_result *res = parsed_result;
13403 int ret = -ENOTSUP;
13405 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13408 #ifdef RTE_LIBRTE_I40E_PMD
13409 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
13416 printf("invalid port_id %d\n", res->port_id);
13419 printf("function not implemented\n");
13422 printf("programming error: (%s)\n", strerror(-ret));
13426 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
13427 .f = cmd_ptype_mapping_reset_parsed,
13429 .help_str = "ptype mapping reset <port_id>",
13431 (void *)&cmd_ptype_mapping_reset_ptype,
13432 (void *)&cmd_ptype_mapping_reset_mapping,
13433 (void *)&cmd_ptype_mapping_reset_reset,
13434 (void *)&cmd_ptype_mapping_reset_port_id,
13439 /* ptype mapping update */
13441 /* Common result structure for ptype mapping update */
13442 struct cmd_ptype_mapping_update_result {
13443 cmdline_fixed_string_t ptype;
13444 cmdline_fixed_string_t mapping;
13445 cmdline_fixed_string_t reset;
13451 /* Common CLI fields for ptype mapping update*/
13452 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
13453 TOKEN_STRING_INITIALIZER
13454 (struct cmd_ptype_mapping_update_result,
13456 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
13457 TOKEN_STRING_INITIALIZER
13458 (struct cmd_ptype_mapping_update_result,
13459 mapping, "mapping");
13460 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
13461 TOKEN_STRING_INITIALIZER
13462 (struct cmd_ptype_mapping_update_result,
13464 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
13465 TOKEN_NUM_INITIALIZER
13466 (struct cmd_ptype_mapping_update_result,
13468 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
13469 TOKEN_NUM_INITIALIZER
13470 (struct cmd_ptype_mapping_update_result,
13472 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
13473 TOKEN_NUM_INITIALIZER
13474 (struct cmd_ptype_mapping_update_result,
13478 cmd_ptype_mapping_update_parsed(
13479 void *parsed_result,
13480 __attribute__((unused)) struct cmdline *cl,
13481 __attribute__((unused)) void *data)
13483 struct cmd_ptype_mapping_update_result *res = parsed_result;
13484 int ret = -ENOTSUP;
13485 #ifdef RTE_LIBRTE_I40E_PMD
13486 struct rte_pmd_i40e_ptype_mapping mapping;
13488 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13491 #ifdef RTE_LIBRTE_I40E_PMD
13492 mapping.hw_ptype = res->hw_ptype;
13493 mapping.sw_ptype = res->sw_ptype;
13494 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
13504 printf("invalid ptype 0x%8x\n", res->sw_ptype);
13507 printf("invalid port_id %d\n", res->port_id);
13510 printf("function not implemented\n");
13513 printf("programming error: (%s)\n", strerror(-ret));
13517 cmdline_parse_inst_t cmd_ptype_mapping_update = {
13518 .f = cmd_ptype_mapping_update_parsed,
13520 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
13522 (void *)&cmd_ptype_mapping_update_ptype,
13523 (void *)&cmd_ptype_mapping_update_mapping,
13524 (void *)&cmd_ptype_mapping_update_update,
13525 (void *)&cmd_ptype_mapping_update_port_id,
13526 (void *)&cmd_ptype_mapping_update_hw_ptype,
13527 (void *)&cmd_ptype_mapping_update_sw_ptype,
13532 /* ******************************************************************************** */
13534 /* list of instructions */
13535 cmdline_parse_ctx_t main_ctx[] = {
13536 (cmdline_parse_inst_t *)&cmd_help_brief,
13537 (cmdline_parse_inst_t *)&cmd_help_long,
13538 (cmdline_parse_inst_t *)&cmd_quit,
13539 (cmdline_parse_inst_t *)&cmd_showport,
13540 (cmdline_parse_inst_t *)&cmd_showqueue,
13541 (cmdline_parse_inst_t *)&cmd_showportall,
13542 (cmdline_parse_inst_t *)&cmd_showcfg,
13543 (cmdline_parse_inst_t *)&cmd_start,
13544 (cmdline_parse_inst_t *)&cmd_start_tx_first,
13545 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13546 (cmdline_parse_inst_t *)&cmd_set_link_up,
13547 (cmdline_parse_inst_t *)&cmd_set_link_down,
13548 (cmdline_parse_inst_t *)&cmd_reset,
13549 (cmdline_parse_inst_t *)&cmd_set_numbers,
13550 (cmdline_parse_inst_t *)&cmd_set_txpkts,
13551 (cmdline_parse_inst_t *)&cmd_set_txsplit,
13552 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13553 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13554 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13555 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13556 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13557 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13558 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13559 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13560 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13561 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13562 (cmdline_parse_inst_t *)&cmd_set_link_check,
13563 #ifdef RTE_NIC_BYPASS
13564 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13565 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13566 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13567 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13569 #ifdef RTE_LIBRTE_PMD_BOND
13570 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13571 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13572 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13573 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13574 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13575 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13576 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13577 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13578 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13580 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13581 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13582 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13583 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13584 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13585 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13586 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13587 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13588 (cmdline_parse_inst_t *)&cmd_csum_set,
13589 (cmdline_parse_inst_t *)&cmd_csum_show,
13590 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13591 (cmdline_parse_inst_t *)&cmd_tso_set,
13592 (cmdline_parse_inst_t *)&cmd_tso_show,
13593 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13594 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13595 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13596 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13597 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13598 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13599 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13600 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13601 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13602 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13603 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13604 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13605 (cmdline_parse_inst_t *)&cmd_config_dcb,
13606 (cmdline_parse_inst_t *)&cmd_read_reg,
13607 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13608 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13609 (cmdline_parse_inst_t *)&cmd_write_reg,
13610 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13611 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13612 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13613 (cmdline_parse_inst_t *)&cmd_stop,
13614 (cmdline_parse_inst_t *)&cmd_mac_addr,
13615 (cmdline_parse_inst_t *)&cmd_set_qmap,
13616 (cmdline_parse_inst_t *)&cmd_operate_port,
13617 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13618 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13619 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13620 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13621 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13622 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13623 (cmdline_parse_inst_t *)&cmd_config_mtu,
13624 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13625 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13626 (cmdline_parse_inst_t *)&cmd_config_rss,
13627 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13628 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13629 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13630 (cmdline_parse_inst_t *)&cmd_showport_reta,
13631 (cmdline_parse_inst_t *)&cmd_config_burst,
13632 (cmdline_parse_inst_t *)&cmd_config_thresh,
13633 (cmdline_parse_inst_t *)&cmd_config_threshold,
13634 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13635 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13636 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13637 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13638 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13639 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13640 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13641 (cmdline_parse_inst_t *)&cmd_global_config,
13642 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13643 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13644 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13645 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13646 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13647 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13648 (cmdline_parse_inst_t *)&cmd_dump,
13649 (cmdline_parse_inst_t *)&cmd_dump_one,
13650 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13651 (cmdline_parse_inst_t *)&cmd_syn_filter,
13652 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13653 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13654 (cmdline_parse_inst_t *)&cmd_flex_filter,
13655 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13656 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13657 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13658 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13659 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13660 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13661 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13662 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13663 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13664 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13665 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13666 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13667 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13668 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13669 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13670 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13671 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13672 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13673 (cmdline_parse_inst_t *)&cmd_flow,
13674 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13675 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13676 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13677 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13678 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13679 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13680 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13681 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13682 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13683 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13684 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13685 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13686 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13687 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13688 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13689 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13690 #ifdef RTE_LIBRTE_IXGBE_PMD
13691 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13692 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13693 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13694 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13695 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13696 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13697 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13698 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13699 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13701 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13702 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13703 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13704 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13705 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13706 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13707 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13708 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13709 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13710 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13711 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
13712 (cmdline_parse_inst_t *)&cmd_ddp_add,
13713 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13714 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13715 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13716 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
13717 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
13718 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
13719 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
13723 /* prompt function, called from main on MASTER lcore */
13727 /* initialize non-constant commands */
13728 cmd_set_fwd_mode_init();
13729 cmd_set_fwd_retry_mode_init();
13731 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13732 if (testpmd_cl == NULL)
13734 cmdline_interact(testpmd_cl);
13735 cmdline_stdin_exit(testpmd_cl);
13741 if (testpmd_cl != NULL)
13742 cmdline_quit(testpmd_cl);
13746 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13748 if (id == (portid_t)RTE_PORT_ALL) {
13751 RTE_ETH_FOREACH_DEV(pid) {
13752 /* check if need_reconfig has been set to 1 */
13753 if (ports[pid].need_reconfig == 0)
13754 ports[pid].need_reconfig = dev;
13755 /* check if need_reconfig_queues has been set to 1 */
13756 if (ports[pid].need_reconfig_queues == 0)
13757 ports[pid].need_reconfig_queues = queue;
13759 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13760 /* check if need_reconfig has been set to 1 */
13761 if (ports[id].need_reconfig == 0)
13762 ports[id].need_reconfig = dev;
13763 /* check if need_reconfig_queues has been set to 1 */
13764 if (ports[id].need_reconfig_queues == 0)
13765 ports[id].need_reconfig_queues = queue;