4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_malloc.h>
63 #include <rte_launch.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
77 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
91 #ifdef RTE_LIBRTE_IXGBE_PMD
92 #include <rte_pmd_ixgbe.h>
94 #ifdef RTE_LIBRTE_I40E_PMD
95 #include <rte_pmd_i40e.h>
99 static struct cmdline *testpmd_cl;
101 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
103 /* *** Help command with introduction. *** */
104 struct cmd_help_brief_result {
105 cmdline_fixed_string_t help;
108 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
110 __attribute__((unused)) void *data)
115 "Help is available for the following sections:\n\n"
116 " help control : Start and stop forwarding.\n"
117 " help display : Displaying port, stats and config "
119 " help config : Configuration information.\n"
120 " help ports : Configuring ports.\n"
121 " help registers : Reading and setting port registers.\n"
122 " help filters : Filters configuration help.\n"
123 " help all : All of the above sections.\n\n"
128 cmdline_parse_token_string_t cmd_help_brief_help =
129 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
131 cmdline_parse_inst_t cmd_help_brief = {
132 .f = cmd_help_brief_parsed,
134 .help_str = "help: Show help",
136 (void *)&cmd_help_brief_help,
141 /* *** Help command with help sections. *** */
142 struct cmd_help_long_result {
143 cmdline_fixed_string_t help;
144 cmdline_fixed_string_t section;
147 static void cmd_help_long_parsed(void *parsed_result,
149 __attribute__((unused)) void *data)
152 struct cmd_help_long_result *res = parsed_result;
154 if (!strcmp(res->section, "all"))
157 if (show_all || !strcmp(res->section, "control")) {
162 "Control forwarding:\n"
163 "-------------------\n\n"
166 " Start packet forwarding with current configuration.\n\n"
169 " Start packet forwarding with current config"
170 " after sending one burst of packets.\n\n"
173 " Stop packet forwarding, and display accumulated"
177 " Quit to prompt.\n\n"
181 if (show_all || !strcmp(res->section, "display")) {
189 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
190 " Display information for port_id, or all.\n\n"
192 "show port X rss reta (size) (mask0,mask1,...)\n"
193 " Display the rss redirection table entry indicated"
194 " by masks on port X. size is used to indicate the"
195 " hardware supported reta size\n\n"
197 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
198 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
199 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
200 " Display the RSS hash functions and RSS hash key"
203 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
204 " Clear information for port_id, or all.\n\n"
206 "show (rxq|txq) info (port_id) (queue_id)\n"
207 " Display information for configured RX/TX queue.\n\n"
209 "show config (rxtx|cores|fwd|txpkts)\n"
210 " Display the given configuration.\n\n"
212 "read rxd (port_id) (queue_id) (rxd_id)\n"
213 " Display an RX descriptor of a port RX queue.\n\n"
215 "read txd (port_id) (queue_id) (txd_id)\n"
216 " Display a TX descriptor of a port TX queue.\n\n"
218 "ddp get list (port_id)\n"
219 " Get ddp profile info list\n\n"
221 "show vf stats (port_id) (vf_id)\n"
222 " Display a VF's statistics.\n\n"
224 "clear vf stats (port_id) (vf_id)\n"
225 " Reset a VF's statistics.\n\n"
229 if (show_all || !strcmp(res->section, "config")) {
235 "Configuration changes only become active when"
236 " forwarding is started/restarted.\n\n"
239 " Reset forwarding to the default configuration.\n\n"
241 "set verbose (level)\n"
242 " Set the debug verbosity level X.\n\n"
245 " Set number of ports.\n\n"
248 " Set number of cores.\n\n"
250 "set coremask (mask)\n"
251 " Set the forwarding cores hexadecimal mask.\n\n"
253 "set portmask (mask)\n"
254 " Set the forwarding ports hexadecimal mask.\n\n"
257 " Set number of packets per burst.\n\n"
259 "set burst tx delay (microseconds) retry (num)\n"
260 " Set the transmit delay time and number of retries,"
261 " effective when retry is enabled.\n\n"
263 "set txpkts (x[,y]*)\n"
264 " Set the length of each segment of TXONLY"
265 " and optionally CSUM packets.\n\n"
267 "set txsplit (off|on|rand)\n"
268 " Set the split policy for the TX packets."
269 " Right now only applicable for CSUM and TXONLY"
272 "set corelist (x[,y]*)\n"
273 " Set the list of forwarding cores.\n\n"
275 "set portlist (x[,y]*)\n"
276 " Set the list of forwarding ports.\n\n"
278 "set tx loopback (port_id) (on|off)\n"
279 " Enable or disable tx loopback.\n\n"
281 #ifdef RTE_LIBRTE_IXGBE_PMD
282 "set all queues drop (port_id) (on|off)\n"
283 " Set drop enable bit for all queues.\n\n"
285 "set vf split drop (port_id) (vf_id) (on|off)\n"
286 " Set split drop enable bit for a VF from the PF.\n\n"
289 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
290 " Set MAC antispoof for a VF from the PF.\n\n"
292 #ifdef RTE_LIBRTE_IXGBE_PMD
293 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
294 " Enable MACsec offload.\n\n"
296 "set macsec offload (port_id) off\n"
297 " Disable MACsec offload.\n\n"
299 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
300 " Configure MACsec secure connection (SC).\n\n"
302 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
303 " Configure MACsec secure association (SA).\n\n"
306 "set vf broadcast (port_id) (vf_id) (on|off)\n"
307 " Set VF broadcast for a VF from the PF.\n\n"
309 "vlan set strip (on|off) (port_id)\n"
310 " Set the VLAN strip on a port.\n\n"
312 "vlan set stripq (on|off) (port_id,queue_id)\n"
313 " Set the VLAN strip for a queue on a port.\n\n"
315 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
316 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
318 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
319 " Set VLAN insert for a VF from the PF.\n\n"
321 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
322 " Set VLAN antispoof for a VF from the PF.\n\n"
324 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
325 " Set VLAN tag for a VF from the PF.\n\n"
327 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
328 " Set a VF's max bandwidth(Mbps).\n\n"
330 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
331 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
333 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
334 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
336 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
337 " Set some TCs' strict link priority mode on a physical port.\n\n"
339 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
340 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
342 "vlan set filter (on|off) (port_id)\n"
343 " Set the VLAN filter on a port.\n\n"
345 "vlan set qinq (on|off) (port_id)\n"
346 " Set the VLAN QinQ (extended queue in queue)"
349 "vlan set (inner|outer) tpid (value) (port_id)\n"
350 " Set the VLAN TPID for Packet Filtering on"
353 "rx_vlan add (vlan_id|all) (port_id)\n"
354 " Add a vlan_id, or all identifiers, to the set"
355 " of VLAN identifiers filtered by port_id.\n\n"
357 "rx_vlan rm (vlan_id|all) (port_id)\n"
358 " Remove a vlan_id, or all identifiers, from the set"
359 " of VLAN identifiers filtered by port_id.\n\n"
361 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
362 " Add a vlan_id, to the set of VLAN identifiers"
363 "filtered for VF(s) from port_id.\n\n"
365 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
366 " Remove a vlan_id, to the set of VLAN identifiers"
367 "filtered for VF(s) from port_id.\n\n"
369 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
370 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
371 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
372 " add a tunnel filter of a port.\n\n"
374 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
375 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
376 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
377 " remove a tunnel filter of a port.\n\n"
379 "rx_vxlan_port add (udp_port) (port_id)\n"
380 " Add an UDP port for VXLAN packet filter on a port\n\n"
382 "rx_vxlan_port rm (udp_port) (port_id)\n"
383 " Remove an UDP port for VXLAN packet filter on a port\n\n"
385 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
386 " Set hardware insertion of VLAN IDs (single or double VLAN "
387 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
389 "tx_vlan set pvid port_id vlan_id (on|off)\n"
390 " Set port based TX VLAN insertion.\n\n"
392 "tx_vlan reset (port_id)\n"
393 " Disable hardware insertion of a VLAN header in"
394 " packets sent on a port.\n\n"
396 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
397 " Select hardware or software calculation of the"
398 " checksum when transmitting a packet using the"
399 " csum forward engine.\n"
400 " ip|udp|tcp|sctp always concern the inner layer.\n"
401 " outer-ip concerns the outer IP layer in"
402 " case the packet is recognized as a tunnel packet by"
403 " the forward engine (vxlan, gre and ipip are supported)\n"
404 " Please check the NIC datasheet for HW limits.\n\n"
406 "csum parse-tunnel (on|off) (tx_port_id)\n"
407 " If disabled, treat tunnel packets as non-tunneled"
408 " packets (treat inner headers as payload). The port\n"
409 " argument is the port used for TX in csum forward"
412 "csum show (port_id)\n"
413 " Display tx checksum offload configuration\n\n"
415 "tso set (segsize) (portid)\n"
416 " Enable TCP Segmentation Offload in csum forward"
418 " Please check the NIC datasheet for HW limits.\n\n"
421 " Display the status of TCP Segmentation Offload.\n\n"
424 " Set packet forwarding mode.\n\n"
426 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
427 " Add a MAC address on port_id.\n\n"
429 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
430 " Remove a MAC address from port_id.\n\n"
432 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
433 " Set the default MAC address for port_id.\n\n"
435 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
436 " Add a MAC address for a VF on the port.\n\n"
438 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
439 " Set the MAC address for a VF from the PF.\n\n"
441 "set port (port_id) uta (mac_address|all) (on|off)\n"
442 " Add/Remove a or all unicast hash filter(s)"
445 "set promisc (port_id|all) (on|off)\n"
446 " Set the promiscuous mode on port_id, or all.\n\n"
448 "set allmulti (port_id|all) (on|off)\n"
449 " Set the allmulti mode on port_id, or all.\n\n"
451 "set vf promisc (port_id) (vf_id) (on|off)\n"
452 " Set unicast promiscuous mode for a VF from the PF.\n\n"
454 "set vf allmulti (port_id) (vf_id) (on|off)\n"
455 " Set multicast promiscuous mode for a VF from the PF.\n\n"
457 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
458 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
459 " (on|off) autoneg (on|off) (port_id)\n"
460 "set flow_ctrl rx (on|off) (portid)\n"
461 "set flow_ctrl tx (on|off) (portid)\n"
462 "set flow_ctrl high_water (high_water) (portid)\n"
463 "set flow_ctrl low_water (low_water) (portid)\n"
464 "set flow_ctrl pause_time (pause_time) (portid)\n"
465 "set flow_ctrl send_xon (send_xon) (portid)\n"
466 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
467 "set flow_ctrl autoneg (on|off) (port_id)\n"
468 " Set the link flow control parameter on a port.\n\n"
470 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
471 " (low_water) (pause_time) (priority) (port_id)\n"
472 " Set the priority flow control parameter on a"
475 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
476 " Set statistics mapping (qmapping 0..15) for RX/TX"
478 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
479 " on port 0 to mapping 5.\n\n"
481 "set port (port_id) vf (vf_id) rx|tx on|off\n"
482 " Enable/Disable a VF receive/tranmit from a port\n\n"
484 "set port (port_id) vf (vf_id) (mac_addr)"
485 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
486 " Add/Remove unicast or multicast MAC addr filter"
489 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
491 " AUPE:accepts untagged VLAN;"
492 "ROPE:accept unicast hash\n\n"
493 " BAM:accepts broadcast packets;"
494 "MPE:accepts all multicast packets\n\n"
495 " Enable/Disable a VF receive mode of a port\n\n"
497 "set port (port_id) queue (queue_id) rate (rate_num)\n"
498 " Set rate limit for a queue of a port\n\n"
500 "set port (port_id) vf (vf_id) rate (rate_num) "
501 "queue_mask (queue_mask_value)\n"
502 " Set rate limit for queues in VF of a port\n\n"
504 "set port (port_id) mirror-rule (rule_id)"
505 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
506 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
507 " Set pool or vlan type mirror rule on a port.\n"
508 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
509 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
512 "set port (port_id) mirror-rule (rule_id)"
513 " (uplink-mirror|downlink-mirror) dst-pool"
514 " (pool_id) (on|off)\n"
515 " Set uplink or downlink type mirror rule on a port.\n"
516 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
517 " 0 on' enable mirror income traffic to pool 0.\n\n"
519 "reset port (port_id) mirror-rule (rule_id)\n"
520 " Reset a mirror rule.\n\n"
522 "set flush_rx (on|off)\n"
523 " Flush (default) or don't flush RX streams before"
524 " forwarding. Mainly used with PCAP drivers.\n\n"
526 #ifdef RTE_NIC_BYPASS
527 "set bypass mode (normal|bypass|isolate) (port_id)\n"
528 " Set the bypass mode for the lowest port on bypass enabled"
531 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
532 "mode (normal|bypass|isolate) (port_id)\n"
533 " Set the event required to initiate specified bypass mode for"
534 " the lowest port on a bypass enabled NIC where:\n"
535 " timeout = enable bypass after watchdog timeout.\n"
536 " os_on = enable bypass when OS/board is powered on.\n"
537 " os_off = enable bypass when OS/board is powered off.\n"
538 " power_on = enable bypass when power supply is turned on.\n"
539 " power_off = enable bypass when power supply is turned off."
542 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
543 " Set the bypass watchdog timeout to 'n' seconds"
544 " where 0 = instant.\n\n"
546 "show bypass config (port_id)\n"
547 " Show the bypass configuration for a bypass enabled NIC"
548 " using the lowest port on the NIC.\n\n"
550 #ifdef RTE_LIBRTE_PMD_BOND
551 "create bonded device (mode) (socket)\n"
552 " Create a new bonded device with specific bonding mode and socket.\n\n"
554 "add bonding slave (slave_id) (port_id)\n"
555 " Add a slave device to a bonded device.\n\n"
557 "remove bonding slave (slave_id) (port_id)\n"
558 " Remove a slave device from a bonded device.\n\n"
560 "set bonding mode (value) (port_id)\n"
561 " Set the bonding mode on a bonded device.\n\n"
563 "set bonding primary (slave_id) (port_id)\n"
564 " Set the primary slave for a bonded device.\n\n"
566 "show bonding config (port_id)\n"
567 " Show the bonding config for port_id.\n\n"
569 "set bonding mac_addr (port_id) (address)\n"
570 " Set the MAC address of a bonded device.\n\n"
572 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
573 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
575 "set bonding mon_period (port_id) (value)\n"
576 " Set the bonding link status monitoring polling period in ms.\n\n"
578 "set link-up port (port_id)\n"
579 " Set link up for a port.\n\n"
581 "set link-down port (port_id)\n"
582 " Set link down for a port.\n\n"
584 "E-tag set insertion on port-tag-id (value)"
585 " port (port_id) vf (vf_id)\n"
586 " Enable E-tag insertion for a VF on a port\n\n"
588 "E-tag set insertion off port (port_id) vf (vf_id)\n"
589 " Disable E-tag insertion for a VF on a port\n\n"
591 "E-tag set stripping (on|off) port (port_id)\n"
592 " Enable/disable E-tag stripping on a port\n\n"
594 "E-tag set forwarding (on|off) port (port_id)\n"
595 " Enable/disable E-tag based forwarding"
598 "E-tag set filter add e-tag-id (value) dst-pool"
599 " (pool_id) port (port_id)\n"
600 " Add an E-tag forwarding filter on a port\n\n"
602 "E-tag set filter del e-tag-id (value) port (port_id)\n"
603 " Delete an E-tag forwarding filter on a port\n\n"
605 "ddp add (port_id) (profile_path)\n"
606 " Load a profile package on a port\n\n"
608 , list_pkt_forwarding_modes()
612 if (show_all || !strcmp(res->section, "ports")) {
618 "----------------\n\n"
620 "port start (port_id|all)\n"
621 " Start all ports or port_id.\n\n"
623 "port stop (port_id|all)\n"
624 " Stop all ports or port_id.\n\n"
626 "port close (port_id|all)\n"
627 " Close all ports or port_id.\n\n"
629 "port attach (ident)\n"
630 " Attach physical or virtual dev by pci address or virtual device name\n\n"
632 "port detach (port_id)\n"
633 " Detach physical or virtual dev by port_id\n\n"
635 "port config (port_id|all)"
636 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
637 " duplex (half|full|auto)\n"
638 " Set speed and duplex for all ports or port_id\n\n"
640 "port config all (rxq|txq|rxd|txd) (value)\n"
641 " Set number for rxq/txq/rxd/txd.\n\n"
643 "port config all max-pkt-len (value)\n"
644 " Set the max packet length.\n\n"
646 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
647 "hw-vlan-strip|hw-vlan-extend|drop-en)"
649 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
652 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
653 " Set the RSS mode.\n\n"
655 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
656 " Set the RSS redirection table.\n\n"
658 "port config (port_id) dcb vt (on|off) (traffic_class)"
660 " Set the DCB mode.\n\n"
662 "port config all burst (value)\n"
663 " Set the number of packets per burst.\n\n"
665 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
667 " Set the ring prefetch/host/writeback threshold"
668 " for tx/rx queue.\n\n"
670 "port config all (txfreet|txrst|rxfreet) (value)\n"
671 " Set free threshold for rx/tx, or set"
672 " tx rs bit threshold.\n\n"
673 "port config mtu X value\n"
674 " Set the MTU of port X to a given value\n\n"
676 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
677 " Start/stop a rx/tx queue of port X. Only take effect"
678 " when port X is started\n\n"
680 "port config (port_id|all) l2-tunnel E-tag ether-type"
682 " Set the value of E-tag ether-type.\n\n"
684 "port config (port_id|all) l2-tunnel E-tag"
685 " (enable|disable)\n"
686 " Enable/disable the E-tag support.\n\n"
690 if (show_all || !strcmp(res->section, "registers")) {
698 "read reg (port_id) (address)\n"
699 " Display value of a port register.\n\n"
701 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
702 " Display a port register bit field.\n\n"
704 "read regbit (port_id) (address) (bit_x)\n"
705 " Display a single port register bit.\n\n"
707 "write reg (port_id) (address) (value)\n"
708 " Set value of a port register.\n\n"
710 "write regfield (port_id) (address) (bit_x) (bit_y)"
712 " Set bit field of a port register.\n\n"
714 "write regbit (port_id) (address) (bit_x) (value)\n"
715 " Set single bit value of a port register.\n\n"
718 if (show_all || !strcmp(res->section, "filters")) {
726 "ethertype_filter (port_id) (add|del)"
727 " (mac_addr|mac_ignr) (mac_address) ethertype"
728 " (ether_type) (drop|fwd) queue (queue_id)\n"
729 " Add/Del an ethertype filter.\n\n"
731 "2tuple_filter (port_id) (add|del)"
732 " dst_port (dst_port_value) protocol (protocol_value)"
733 " mask (mask_value) tcp_flags (tcp_flags_value)"
734 " priority (prio_value) queue (queue_id)\n"
735 " Add/Del a 2tuple filter.\n\n"
737 "5tuple_filter (port_id) (add|del)"
738 " dst_ip (dst_address) src_ip (src_address)"
739 " dst_port (dst_port_value) src_port (src_port_value)"
740 " protocol (protocol_value)"
741 " mask (mask_value) tcp_flags (tcp_flags_value)"
742 " priority (prio_value) queue (queue_id)\n"
743 " Add/Del a 5tuple filter.\n\n"
745 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
746 " Add/Del syn filter.\n\n"
748 "flex_filter (port_id) (add|del) len (len_value)"
749 " bytes (bytes_value) mask (mask_value)"
750 " priority (prio_value) queue (queue_id)\n"
751 " Add/Del a flex filter.\n\n"
753 "flow_director_filter (port_id) mode IP (add|del|update)"
754 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
755 " src (src_ip_address) dst (dst_ip_address)"
756 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
757 " vlan (vlan_value) flexbytes (flexbytes_value)"
758 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
759 " fd_id (fd_id_value)\n"
760 " Add/Del an IP type flow director filter.\n\n"
762 "flow_director_filter (port_id) mode IP (add|del|update)"
763 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
764 " src (src_ip_address) (src_port)"
765 " dst (dst_ip_address) (dst_port)"
766 " tos (tos_value) ttl (ttl_value)"
767 " vlan (vlan_value) flexbytes (flexbytes_value)"
768 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
769 " fd_id (fd_id_value)\n"
770 " Add/Del an UDP/TCP type flow director filter.\n\n"
772 "flow_director_filter (port_id) mode IP (add|del|update)"
773 " flow (ipv4-sctp|ipv6-sctp)"
774 " src (src_ip_address) (src_port)"
775 " dst (dst_ip_address) (dst_port)"
776 " tag (verification_tag) "
777 " tos (tos_value) ttl (ttl_value)"
779 " flexbytes (flexbytes_value) (drop|fwd)"
780 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
781 " Add/Del a SCTP type flow director filter.\n\n"
783 "flow_director_filter (port_id) mode IP (add|del|update)"
784 " flow l2_payload ether (ethertype)"
785 " flexbytes (flexbytes_value) (drop|fwd)"
786 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
787 " Add/Del a l2 payload type flow director filter.\n\n"
789 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
790 " mac (mac_address) vlan (vlan_value)"
791 " flexbytes (flexbytes_value) (drop|fwd)"
792 " queue (queue_id) fd_id (fd_id_value)\n"
793 " Add/Del a MAC-VLAN flow director filter.\n\n"
795 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
796 " mac (mac_address) vlan (vlan_value)"
797 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
798 " flexbytes (flexbytes_value) (drop|fwd)"
799 " queue (queue_id) fd_id (fd_id_value)\n"
800 " Add/Del a Tunnel flow director filter.\n\n"
802 "flush_flow_director (port_id)\n"
803 " Flush all flow director entries of a device.\n\n"
805 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
806 " src_mask (ipv4_src) (ipv6_src) (src_port)"
807 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
808 " Set flow director IP mask.\n\n"
810 "flow_director_mask (port_id) mode MAC-VLAN"
811 " vlan (vlan_value)\n"
812 " Set flow director MAC-VLAN mask.\n\n"
814 "flow_director_mask (port_id) mode Tunnel"
815 " vlan (vlan_value) mac (mac_value)"
816 " tunnel-type (tunnel_type_value)"
817 " tunnel-id (tunnel_id_value)\n"
818 " Set flow director Tunnel mask.\n\n"
820 "flow_director_flex_mask (port_id)"
821 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
822 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
824 " Configure mask of flex payload.\n\n"
826 "flow_director_flex_payload (port_id)"
827 " (raw|l2|l3|l4) (config)\n"
828 " Configure flex payload selection.\n\n"
830 "get_sym_hash_ena_per_port (port_id)\n"
831 " get symmetric hash enable configuration per port.\n\n"
833 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
834 " set symmetric hash enable configuration per port"
835 " to enable or disable.\n\n"
837 "get_hash_global_config (port_id)\n"
838 " Get the global configurations of hash filters.\n\n"
840 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
841 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
842 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
843 " (enable|disable)\n"
844 " Set the global configurations of hash filters.\n\n"
846 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
847 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
848 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
849 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
850 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
851 "ipv6-next-header|udp-src-port|udp-dst-port|"
852 "tcp-src-port|tcp-dst-port|sctp-src-port|"
853 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
854 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
855 "fld-8th|none) (select|add)\n"
856 " Set the input set for hash.\n\n"
858 "set_fdir_input_set (port_id) "
859 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
860 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
861 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
862 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
863 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
864 "udp-dst-port|tcp-src-port|tcp-dst-port|"
865 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
867 " Set the input set for FDir.\n\n"
869 "flow validate {port_id}"
870 " [group {group_id}] [priority {level}]"
871 " [ingress] [egress]"
872 " pattern {item} [/ {item} [...]] / end"
873 " actions {action} [/ {action} [...]] / end\n"
874 " Check whether a flow rule can be created.\n\n"
876 "flow create {port_id}"
877 " [group {group_id}] [priority {level}]"
878 " [ingress] [egress]"
879 " pattern {item} [/ {item} [...]] / end"
880 " actions {action} [/ {action} [...]] / end\n"
881 " Create a flow rule.\n\n"
883 "flow destroy {port_id} rule {rule_id} [...]\n"
884 " Destroy specific flow rules.\n\n"
886 "flow flush {port_id}\n"
887 " Destroy all flow rules.\n\n"
889 "flow query {port_id} {rule_id} {action}\n"
890 " Query an existing flow rule.\n\n"
892 "flow list {port_id} [group {group_id}] [...]\n"
893 " List existing flow rules sorted by priority,"
894 " filtered by group identifiers.\n\n"
899 cmdline_parse_token_string_t cmd_help_long_help =
900 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
902 cmdline_parse_token_string_t cmd_help_long_section =
903 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
904 "all#control#display#config#"
905 "ports#registers#filters");
907 cmdline_parse_inst_t cmd_help_long = {
908 .f = cmd_help_long_parsed,
910 .help_str = "help all|control|display|config|ports|register|filters: "
913 (void *)&cmd_help_long_help,
914 (void *)&cmd_help_long_section,
920 /* *** start/stop/close all ports *** */
921 struct cmd_operate_port_result {
922 cmdline_fixed_string_t keyword;
923 cmdline_fixed_string_t name;
924 cmdline_fixed_string_t value;
927 static void cmd_operate_port_parsed(void *parsed_result,
928 __attribute__((unused)) struct cmdline *cl,
929 __attribute__((unused)) void *data)
931 struct cmd_operate_port_result *res = parsed_result;
933 if (!strcmp(res->name, "start"))
934 start_port(RTE_PORT_ALL);
935 else if (!strcmp(res->name, "stop"))
936 stop_port(RTE_PORT_ALL);
937 else if (!strcmp(res->name, "close"))
938 close_port(RTE_PORT_ALL);
940 printf("Unknown parameter\n");
943 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
944 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
946 cmdline_parse_token_string_t cmd_operate_port_all_port =
947 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
949 cmdline_parse_token_string_t cmd_operate_port_all_all =
950 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
952 cmdline_parse_inst_t cmd_operate_port = {
953 .f = cmd_operate_port_parsed,
955 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
957 (void *)&cmd_operate_port_all_cmd,
958 (void *)&cmd_operate_port_all_port,
959 (void *)&cmd_operate_port_all_all,
964 /* *** start/stop/close specific port *** */
965 struct cmd_operate_specific_port_result {
966 cmdline_fixed_string_t keyword;
967 cmdline_fixed_string_t name;
971 static void cmd_operate_specific_port_parsed(void *parsed_result,
972 __attribute__((unused)) struct cmdline *cl,
973 __attribute__((unused)) void *data)
975 struct cmd_operate_specific_port_result *res = parsed_result;
977 if (!strcmp(res->name, "start"))
978 start_port(res->value);
979 else if (!strcmp(res->name, "stop"))
980 stop_port(res->value);
981 else if (!strcmp(res->name, "close"))
982 close_port(res->value);
984 printf("Unknown parameter\n");
987 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
988 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
990 cmdline_parse_token_string_t cmd_operate_specific_port_port =
991 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
992 name, "start#stop#close");
993 cmdline_parse_token_num_t cmd_operate_specific_port_id =
994 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
997 cmdline_parse_inst_t cmd_operate_specific_port = {
998 .f = cmd_operate_specific_port_parsed,
1000 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1002 (void *)&cmd_operate_specific_port_cmd,
1003 (void *)&cmd_operate_specific_port_port,
1004 (void *)&cmd_operate_specific_port_id,
1009 /* *** attach a specified port *** */
1010 struct cmd_operate_attach_port_result {
1011 cmdline_fixed_string_t port;
1012 cmdline_fixed_string_t keyword;
1013 cmdline_fixed_string_t identifier;
1016 static void cmd_operate_attach_port_parsed(void *parsed_result,
1017 __attribute__((unused)) struct cmdline *cl,
1018 __attribute__((unused)) void *data)
1020 struct cmd_operate_attach_port_result *res = parsed_result;
1022 if (!strcmp(res->keyword, "attach"))
1023 attach_port(res->identifier);
1025 printf("Unknown parameter\n");
1028 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1029 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1031 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1032 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1034 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1035 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1038 cmdline_parse_inst_t cmd_operate_attach_port = {
1039 .f = cmd_operate_attach_port_parsed,
1041 .help_str = "port attach <identifier>: "
1042 "(identifier: pci address or virtual dev name)",
1044 (void *)&cmd_operate_attach_port_port,
1045 (void *)&cmd_operate_attach_port_keyword,
1046 (void *)&cmd_operate_attach_port_identifier,
1051 /* *** detach a specified port *** */
1052 struct cmd_operate_detach_port_result {
1053 cmdline_fixed_string_t port;
1054 cmdline_fixed_string_t keyword;
1058 static void cmd_operate_detach_port_parsed(void *parsed_result,
1059 __attribute__((unused)) struct cmdline *cl,
1060 __attribute__((unused)) void *data)
1062 struct cmd_operate_detach_port_result *res = parsed_result;
1064 if (!strcmp(res->keyword, "detach"))
1065 detach_port(res->port_id);
1067 printf("Unknown parameter\n");
1070 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1071 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1073 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1074 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1076 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1077 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1080 cmdline_parse_inst_t cmd_operate_detach_port = {
1081 .f = cmd_operate_detach_port_parsed,
1083 .help_str = "port detach <port_id>",
1085 (void *)&cmd_operate_detach_port_port,
1086 (void *)&cmd_operate_detach_port_keyword,
1087 (void *)&cmd_operate_detach_port_port_id,
1092 /* *** configure speed for all ports *** */
1093 struct cmd_config_speed_all {
1094 cmdline_fixed_string_t port;
1095 cmdline_fixed_string_t keyword;
1096 cmdline_fixed_string_t all;
1097 cmdline_fixed_string_t item1;
1098 cmdline_fixed_string_t item2;
1099 cmdline_fixed_string_t value1;
1100 cmdline_fixed_string_t value2;
1104 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1109 if (!strcmp(duplexstr, "half")) {
1110 duplex = ETH_LINK_HALF_DUPLEX;
1111 } else if (!strcmp(duplexstr, "full")) {
1112 duplex = ETH_LINK_FULL_DUPLEX;
1113 } else if (!strcmp(duplexstr, "auto")) {
1114 duplex = ETH_LINK_FULL_DUPLEX;
1116 printf("Unknown duplex parameter\n");
1120 if (!strcmp(speedstr, "10")) {
1121 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1122 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1123 } else if (!strcmp(speedstr, "100")) {
1124 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1125 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1127 if (duplex != ETH_LINK_FULL_DUPLEX) {
1128 printf("Invalid speed/duplex parameters\n");
1131 if (!strcmp(speedstr, "1000")) {
1132 *speed = ETH_LINK_SPEED_1G;
1133 } else if (!strcmp(speedstr, "10000")) {
1134 *speed = ETH_LINK_SPEED_10G;
1135 } else if (!strcmp(speedstr, "25000")) {
1136 *speed = ETH_LINK_SPEED_25G;
1137 } else if (!strcmp(speedstr, "40000")) {
1138 *speed = ETH_LINK_SPEED_40G;
1139 } else if (!strcmp(speedstr, "50000")) {
1140 *speed = ETH_LINK_SPEED_50G;
1141 } else if (!strcmp(speedstr, "100000")) {
1142 *speed = ETH_LINK_SPEED_100G;
1143 } else if (!strcmp(speedstr, "auto")) {
1144 *speed = ETH_LINK_SPEED_AUTONEG;
1146 printf("Unknown speed parameter\n");
1155 cmd_config_speed_all_parsed(void *parsed_result,
1156 __attribute__((unused)) struct cmdline *cl,
1157 __attribute__((unused)) void *data)
1159 struct cmd_config_speed_all *res = parsed_result;
1160 uint32_t link_speed;
1163 if (!all_ports_stopped()) {
1164 printf("Please stop all ports first\n");
1168 if (parse_and_check_speed_duplex(res->value1, res->value2,
1172 FOREACH_PORT(pid, ports) {
1173 ports[pid].dev_conf.link_speeds = link_speed;
1176 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1179 cmdline_parse_token_string_t cmd_config_speed_all_port =
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1181 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1182 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1184 cmdline_parse_token_string_t cmd_config_speed_all_all =
1185 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1186 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1187 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1188 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1189 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1190 "10#100#1000#10000#25000#40000#50000#100000#auto");
1191 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1192 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1193 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1194 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1197 cmdline_parse_inst_t cmd_config_speed_all = {
1198 .f = cmd_config_speed_all_parsed,
1200 .help_str = "port config all speed "
1201 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1204 (void *)&cmd_config_speed_all_port,
1205 (void *)&cmd_config_speed_all_keyword,
1206 (void *)&cmd_config_speed_all_all,
1207 (void *)&cmd_config_speed_all_item1,
1208 (void *)&cmd_config_speed_all_value1,
1209 (void *)&cmd_config_speed_all_item2,
1210 (void *)&cmd_config_speed_all_value2,
1215 /* *** configure speed for specific port *** */
1216 struct cmd_config_speed_specific {
1217 cmdline_fixed_string_t port;
1218 cmdline_fixed_string_t keyword;
1220 cmdline_fixed_string_t item1;
1221 cmdline_fixed_string_t item2;
1222 cmdline_fixed_string_t value1;
1223 cmdline_fixed_string_t value2;
1227 cmd_config_speed_specific_parsed(void *parsed_result,
1228 __attribute__((unused)) struct cmdline *cl,
1229 __attribute__((unused)) void *data)
1231 struct cmd_config_speed_specific *res = parsed_result;
1232 uint32_t link_speed;
1234 if (!all_ports_stopped()) {
1235 printf("Please stop all ports first\n");
1239 if (port_id_is_invalid(res->id, ENABLED_WARN))
1242 if (parse_and_check_speed_duplex(res->value1, res->value2,
1246 ports[res->id].dev_conf.link_speeds = link_speed;
1248 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1252 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1253 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1255 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1256 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1258 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1259 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1260 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1261 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1263 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1264 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1265 "10#100#1000#10000#25000#40000#50000#100000#auto");
1266 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1267 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1269 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1270 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1273 cmdline_parse_inst_t cmd_config_speed_specific = {
1274 .f = cmd_config_speed_specific_parsed,
1276 .help_str = "port config <port_id> speed "
1277 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1280 (void *)&cmd_config_speed_specific_port,
1281 (void *)&cmd_config_speed_specific_keyword,
1282 (void *)&cmd_config_speed_specific_id,
1283 (void *)&cmd_config_speed_specific_item1,
1284 (void *)&cmd_config_speed_specific_value1,
1285 (void *)&cmd_config_speed_specific_item2,
1286 (void *)&cmd_config_speed_specific_value2,
1291 /* *** configure txq/rxq, txd/rxd *** */
1292 struct cmd_config_rx_tx {
1293 cmdline_fixed_string_t port;
1294 cmdline_fixed_string_t keyword;
1295 cmdline_fixed_string_t all;
1296 cmdline_fixed_string_t name;
1301 cmd_config_rx_tx_parsed(void *parsed_result,
1302 __attribute__((unused)) struct cmdline *cl,
1303 __attribute__((unused)) void *data)
1305 struct cmd_config_rx_tx *res = parsed_result;
1307 if (!all_ports_stopped()) {
1308 printf("Please stop all ports first\n");
1311 if (!strcmp(res->name, "rxq")) {
1312 if (!res->value && !nb_txq) {
1313 printf("Warning: Either rx or tx queues should be non zero\n");
1316 nb_rxq = res->value;
1318 else if (!strcmp(res->name, "txq")) {
1319 if (!res->value && !nb_rxq) {
1320 printf("Warning: Either rx or tx queues should be non zero\n");
1323 nb_txq = res->value;
1325 else if (!strcmp(res->name, "rxd")) {
1326 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1327 printf("rxd %d invalid - must be > 0 && <= %d\n",
1328 res->value, RTE_TEST_RX_DESC_MAX);
1331 nb_rxd = res->value;
1332 } else if (!strcmp(res->name, "txd")) {
1333 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1334 printf("txd %d invalid - must be > 0 && <= %d\n",
1335 res->value, RTE_TEST_TX_DESC_MAX);
1338 nb_txd = res->value;
1340 printf("Unknown parameter\n");
1348 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1351 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1352 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1353 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1355 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1356 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1357 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1358 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1360 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1361 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1363 cmdline_parse_inst_t cmd_config_rx_tx = {
1364 .f = cmd_config_rx_tx_parsed,
1366 .help_str = "port config all rxq|txq|rxd|txd <value>",
1368 (void *)&cmd_config_rx_tx_port,
1369 (void *)&cmd_config_rx_tx_keyword,
1370 (void *)&cmd_config_rx_tx_all,
1371 (void *)&cmd_config_rx_tx_name,
1372 (void *)&cmd_config_rx_tx_value,
1377 /* *** config max packet length *** */
1378 struct cmd_config_max_pkt_len_result {
1379 cmdline_fixed_string_t port;
1380 cmdline_fixed_string_t keyword;
1381 cmdline_fixed_string_t all;
1382 cmdline_fixed_string_t name;
1387 cmd_config_max_pkt_len_parsed(void *parsed_result,
1388 __attribute__((unused)) struct cmdline *cl,
1389 __attribute__((unused)) void *data)
1391 struct cmd_config_max_pkt_len_result *res = parsed_result;
1393 if (!all_ports_stopped()) {
1394 printf("Please stop all ports first\n");
1398 if (!strcmp(res->name, "max-pkt-len")) {
1399 if (res->value < ETHER_MIN_LEN) {
1400 printf("max-pkt-len can not be less than %d\n",
1404 if (res->value == rx_mode.max_rx_pkt_len)
1407 rx_mode.max_rx_pkt_len = res->value;
1408 if (res->value > ETHER_MAX_LEN)
1409 rx_mode.jumbo_frame = 1;
1411 rx_mode.jumbo_frame = 0;
1413 printf("Unknown parameter\n");
1419 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1422 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1425 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1428 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1429 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1431 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1432 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1434 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1435 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1438 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1439 .f = cmd_config_max_pkt_len_parsed,
1441 .help_str = "port config all max-pkt-len <value>",
1443 (void *)&cmd_config_max_pkt_len_port,
1444 (void *)&cmd_config_max_pkt_len_keyword,
1445 (void *)&cmd_config_max_pkt_len_all,
1446 (void *)&cmd_config_max_pkt_len_name,
1447 (void *)&cmd_config_max_pkt_len_value,
1452 /* *** configure port MTU *** */
1453 struct cmd_config_mtu_result {
1454 cmdline_fixed_string_t port;
1455 cmdline_fixed_string_t keyword;
1456 cmdline_fixed_string_t mtu;
1462 cmd_config_mtu_parsed(void *parsed_result,
1463 __attribute__((unused)) struct cmdline *cl,
1464 __attribute__((unused)) void *data)
1466 struct cmd_config_mtu_result *res = parsed_result;
1468 if (res->value < ETHER_MIN_LEN) {
1469 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1472 port_mtu_set(res->port_id, res->value);
1475 cmdline_parse_token_string_t cmd_config_mtu_port =
1476 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1478 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1479 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1481 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1482 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1484 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1485 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1486 cmdline_parse_token_num_t cmd_config_mtu_value =
1487 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1489 cmdline_parse_inst_t cmd_config_mtu = {
1490 .f = cmd_config_mtu_parsed,
1492 .help_str = "port config mtu <port_id> <value>",
1494 (void *)&cmd_config_mtu_port,
1495 (void *)&cmd_config_mtu_keyword,
1496 (void *)&cmd_config_mtu_mtu,
1497 (void *)&cmd_config_mtu_port_id,
1498 (void *)&cmd_config_mtu_value,
1503 /* *** configure rx mode *** */
1504 struct cmd_config_rx_mode_flag {
1505 cmdline_fixed_string_t port;
1506 cmdline_fixed_string_t keyword;
1507 cmdline_fixed_string_t all;
1508 cmdline_fixed_string_t name;
1509 cmdline_fixed_string_t value;
1513 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1514 __attribute__((unused)) struct cmdline *cl,
1515 __attribute__((unused)) void *data)
1517 struct cmd_config_rx_mode_flag *res = parsed_result;
1519 if (!all_ports_stopped()) {
1520 printf("Please stop all ports first\n");
1524 if (!strcmp(res->name, "crc-strip")) {
1525 if (!strcmp(res->value, "on"))
1526 rx_mode.hw_strip_crc = 1;
1527 else if (!strcmp(res->value, "off"))
1528 rx_mode.hw_strip_crc = 0;
1530 printf("Unknown parameter\n");
1533 } else if (!strcmp(res->name, "scatter")) {
1534 if (!strcmp(res->value, "on"))
1535 rx_mode.enable_scatter = 1;
1536 else if (!strcmp(res->value, "off"))
1537 rx_mode.enable_scatter = 0;
1539 printf("Unknown parameter\n");
1542 } else if (!strcmp(res->name, "rx-cksum")) {
1543 if (!strcmp(res->value, "on"))
1544 rx_mode.hw_ip_checksum = 1;
1545 else if (!strcmp(res->value, "off"))
1546 rx_mode.hw_ip_checksum = 0;
1548 printf("Unknown parameter\n");
1551 } else if (!strcmp(res->name, "hw-vlan")) {
1552 if (!strcmp(res->value, "on")) {
1553 rx_mode.hw_vlan_filter = 1;
1554 rx_mode.hw_vlan_strip = 1;
1556 else if (!strcmp(res->value, "off")) {
1557 rx_mode.hw_vlan_filter = 0;
1558 rx_mode.hw_vlan_strip = 0;
1561 printf("Unknown parameter\n");
1564 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1565 if (!strcmp(res->value, "on"))
1566 rx_mode.hw_vlan_filter = 1;
1567 else if (!strcmp(res->value, "off"))
1568 rx_mode.hw_vlan_filter = 0;
1570 printf("Unknown parameter\n");
1573 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1574 if (!strcmp(res->value, "on"))
1575 rx_mode.hw_vlan_strip = 1;
1576 else if (!strcmp(res->value, "off"))
1577 rx_mode.hw_vlan_strip = 0;
1579 printf("Unknown parameter\n");
1582 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1583 if (!strcmp(res->value, "on"))
1584 rx_mode.hw_vlan_extend = 1;
1585 else if (!strcmp(res->value, "off"))
1586 rx_mode.hw_vlan_extend = 0;
1588 printf("Unknown parameter\n");
1591 } else if (!strcmp(res->name, "drop-en")) {
1592 if (!strcmp(res->value, "on"))
1594 else if (!strcmp(res->value, "off"))
1597 printf("Unknown parameter\n");
1601 printf("Unknown parameter\n");
1607 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1610 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1611 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1612 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1613 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1615 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1616 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1617 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1618 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1619 "crc-strip#scatter#rx-cksum#hw-vlan#"
1620 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1621 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1625 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1626 .f = cmd_config_rx_mode_flag_parsed,
1628 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1629 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1631 (void *)&cmd_config_rx_mode_flag_port,
1632 (void *)&cmd_config_rx_mode_flag_keyword,
1633 (void *)&cmd_config_rx_mode_flag_all,
1634 (void *)&cmd_config_rx_mode_flag_name,
1635 (void *)&cmd_config_rx_mode_flag_value,
1640 /* *** configure rss *** */
1641 struct cmd_config_rss {
1642 cmdline_fixed_string_t port;
1643 cmdline_fixed_string_t keyword;
1644 cmdline_fixed_string_t all;
1645 cmdline_fixed_string_t name;
1646 cmdline_fixed_string_t value;
1650 cmd_config_rss_parsed(void *parsed_result,
1651 __attribute__((unused)) struct cmdline *cl,
1652 __attribute__((unused)) void *data)
1654 struct cmd_config_rss *res = parsed_result;
1655 struct rte_eth_rss_conf rss_conf;
1659 if (!strcmp(res->value, "all"))
1660 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1661 ETH_RSS_UDP | ETH_RSS_SCTP |
1663 else if (!strcmp(res->value, "ip"))
1664 rss_conf.rss_hf = ETH_RSS_IP;
1665 else if (!strcmp(res->value, "udp"))
1666 rss_conf.rss_hf = ETH_RSS_UDP;
1667 else if (!strcmp(res->value, "tcp"))
1668 rss_conf.rss_hf = ETH_RSS_TCP;
1669 else if (!strcmp(res->value, "sctp"))
1670 rss_conf.rss_hf = ETH_RSS_SCTP;
1671 else if (!strcmp(res->value, "ether"))
1672 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1673 else if (!strcmp(res->value, "port"))
1674 rss_conf.rss_hf = ETH_RSS_PORT;
1675 else if (!strcmp(res->value, "vxlan"))
1676 rss_conf.rss_hf = ETH_RSS_VXLAN;
1677 else if (!strcmp(res->value, "geneve"))
1678 rss_conf.rss_hf = ETH_RSS_GENEVE;
1679 else if (!strcmp(res->value, "nvgre"))
1680 rss_conf.rss_hf = ETH_RSS_NVGRE;
1681 else if (!strcmp(res->value, "none"))
1682 rss_conf.rss_hf = 0;
1684 printf("Unknown parameter\n");
1687 rss_conf.rss_key = NULL;
1688 for (i = 0; i < rte_eth_dev_count(); i++) {
1689 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1691 printf("Configuration of RSS hash at ethernet port %d "
1692 "failed with error (%d): %s.\n",
1693 i, -diag, strerror(-diag));
1697 cmdline_parse_token_string_t cmd_config_rss_port =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1699 cmdline_parse_token_string_t cmd_config_rss_keyword =
1700 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1701 cmdline_parse_token_string_t cmd_config_rss_all =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1703 cmdline_parse_token_string_t cmd_config_rss_name =
1704 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1705 cmdline_parse_token_string_t cmd_config_rss_value =
1706 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1707 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1709 cmdline_parse_inst_t cmd_config_rss = {
1710 .f = cmd_config_rss_parsed,
1712 .help_str = "port config all rss "
1713 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1715 (void *)&cmd_config_rss_port,
1716 (void *)&cmd_config_rss_keyword,
1717 (void *)&cmd_config_rss_all,
1718 (void *)&cmd_config_rss_name,
1719 (void *)&cmd_config_rss_value,
1724 /* *** configure rss hash key *** */
1725 struct cmd_config_rss_hash_key {
1726 cmdline_fixed_string_t port;
1727 cmdline_fixed_string_t config;
1729 cmdline_fixed_string_t rss_hash_key;
1730 cmdline_fixed_string_t rss_type;
1731 cmdline_fixed_string_t key;
1735 hexa_digit_to_value(char hexa_digit)
1737 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1738 return (uint8_t) (hexa_digit - '0');
1739 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1740 return (uint8_t) ((hexa_digit - 'a') + 10);
1741 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1742 return (uint8_t) ((hexa_digit - 'A') + 10);
1743 /* Invalid hexa digit */
1748 parse_and_check_key_hexa_digit(char *key, int idx)
1752 hexa_v = hexa_digit_to_value(key[idx]);
1754 printf("invalid key: character %c at position %d is not a "
1755 "valid hexa digit\n", key[idx], idx);
1760 cmd_config_rss_hash_key_parsed(void *parsed_result,
1761 __attribute__((unused)) struct cmdline *cl,
1762 __attribute__((unused)) void *data)
1764 struct cmd_config_rss_hash_key *res = parsed_result;
1765 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1769 struct rte_eth_dev_info dev_info;
1770 uint8_t hash_key_size;
1773 memset(&dev_info, 0, sizeof(dev_info));
1774 rte_eth_dev_info_get(res->port_id, &dev_info);
1775 if (dev_info.hash_key_size > 0 &&
1776 dev_info.hash_key_size <= sizeof(hash_key))
1777 hash_key_size = dev_info.hash_key_size;
1779 printf("dev_info did not provide a valid hash key size\n");
1782 /* Check the length of the RSS hash key */
1783 key_len = strlen(res->key);
1784 if (key_len != (hash_key_size * 2)) {
1785 printf("key length: %d invalid - key must be a string of %d"
1786 " hexa-decimal numbers\n",
1787 (int) key_len, hash_key_size * 2);
1790 /* Translate RSS hash key into binary representation */
1791 for (i = 0; i < hash_key_size; i++) {
1792 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1795 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1798 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1800 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1804 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1806 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1807 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1809 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1810 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1811 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1812 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1813 rss_hash_key, "rss-hash-key");
1814 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1815 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1816 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1817 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1818 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1819 "ipv6-tcp-ex#ipv6-udp-ex");
1820 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1821 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1823 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1824 .f = cmd_config_rss_hash_key_parsed,
1826 .help_str = "port config <port_id> rss-hash-key "
1827 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1828 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1829 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1830 "<string of hex digits (variable length, NIC dependent)>",
1832 (void *)&cmd_config_rss_hash_key_port,
1833 (void *)&cmd_config_rss_hash_key_config,
1834 (void *)&cmd_config_rss_hash_key_port_id,
1835 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1836 (void *)&cmd_config_rss_hash_key_rss_type,
1837 (void *)&cmd_config_rss_hash_key_value,
1842 /* *** configure port rxq/txq start/stop *** */
1843 struct cmd_config_rxtx_queue {
1844 cmdline_fixed_string_t port;
1846 cmdline_fixed_string_t rxtxq;
1848 cmdline_fixed_string_t opname;
1852 cmd_config_rxtx_queue_parsed(void *parsed_result,
1853 __attribute__((unused)) struct cmdline *cl,
1854 __attribute__((unused)) void *data)
1856 struct cmd_config_rxtx_queue *res = parsed_result;
1861 if (test_done == 0) {
1862 printf("Please stop forwarding first\n");
1866 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1869 if (port_is_started(res->portid) != 1) {
1870 printf("Please start port %u first\n", res->portid);
1874 if (!strcmp(res->rxtxq, "rxq"))
1876 else if (!strcmp(res->rxtxq, "txq"))
1879 printf("Unknown parameter\n");
1883 if (isrx && rx_queue_id_is_invalid(res->qid))
1885 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1888 if (!strcmp(res->opname, "start"))
1890 else if (!strcmp(res->opname, "stop"))
1893 printf("Unknown parameter\n");
1897 if (isstart && isrx)
1898 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1899 else if (!isstart && isrx)
1900 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1901 else if (isstart && !isrx)
1902 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1904 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1906 if (ret == -ENOTSUP)
1907 printf("Function not supported in PMD driver\n");
1910 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1911 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1912 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1913 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1914 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1915 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1916 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1917 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1918 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1919 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1922 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1923 .f = cmd_config_rxtx_queue_parsed,
1925 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1927 (void *)&cmd_config_speed_all_port,
1928 (void *)&cmd_config_rxtx_queue_portid,
1929 (void *)&cmd_config_rxtx_queue_rxtxq,
1930 (void *)&cmd_config_rxtx_queue_qid,
1931 (void *)&cmd_config_rxtx_queue_opname,
1936 /* *** Configure RSS RETA *** */
1937 struct cmd_config_rss_reta {
1938 cmdline_fixed_string_t port;
1939 cmdline_fixed_string_t keyword;
1941 cmdline_fixed_string_t name;
1942 cmdline_fixed_string_t list_name;
1943 cmdline_fixed_string_t list_of_items;
1947 parse_reta_config(const char *str,
1948 struct rte_eth_rss_reta_entry64 *reta_conf,
1949 uint16_t nb_entries)
1953 uint16_t hash_index, idx, shift;
1956 const char *p, *p0 = str;
1963 unsigned long int_fld[_NUM_FLD];
1964 char *str_fld[_NUM_FLD];
1966 while ((p = strchr(p0,'(')) != NULL) {
1968 if((p0 = strchr(p,')')) == NULL)
1972 if(size >= sizeof(s))
1975 snprintf(s, sizeof(s), "%.*s", size, p);
1976 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1978 for (i = 0; i < _NUM_FLD; i++) {
1980 int_fld[i] = strtoul(str_fld[i], &end, 0);
1981 if (errno != 0 || end == str_fld[i] ||
1986 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1987 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1989 if (hash_index >= nb_entries) {
1990 printf("Invalid RETA hash index=%d\n", hash_index);
1994 idx = hash_index / RTE_RETA_GROUP_SIZE;
1995 shift = hash_index % RTE_RETA_GROUP_SIZE;
1996 reta_conf[idx].mask |= (1ULL << shift);
1997 reta_conf[idx].reta[shift] = nb_queue;
2004 cmd_set_rss_reta_parsed(void *parsed_result,
2005 __attribute__((unused)) struct cmdline *cl,
2006 __attribute__((unused)) void *data)
2009 struct rte_eth_dev_info dev_info;
2010 struct rte_eth_rss_reta_entry64 reta_conf[8];
2011 struct cmd_config_rss_reta *res = parsed_result;
2013 memset(&dev_info, 0, sizeof(dev_info));
2014 rte_eth_dev_info_get(res->port_id, &dev_info);
2015 if (dev_info.reta_size == 0) {
2016 printf("Redirection table size is 0 which is "
2017 "invalid for RSS\n");
2020 printf("The reta size of port %d is %u\n",
2021 res->port_id, dev_info.reta_size);
2022 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2023 printf("Currently do not support more than %u entries of "
2024 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2028 memset(reta_conf, 0, sizeof(reta_conf));
2029 if (!strcmp(res->list_name, "reta")) {
2030 if (parse_reta_config(res->list_of_items, reta_conf,
2031 dev_info.reta_size)) {
2032 printf("Invalid RSS Redirection Table "
2033 "config entered\n");
2036 ret = rte_eth_dev_rss_reta_update(res->port_id,
2037 reta_conf, dev_info.reta_size);
2039 printf("Bad redirection table parameter, "
2040 "return code = %d \n", ret);
2044 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2046 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2047 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2048 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2049 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2050 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2052 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2054 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2057 cmdline_parse_inst_t cmd_config_rss_reta = {
2058 .f = cmd_set_rss_reta_parsed,
2060 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2062 (void *)&cmd_config_rss_reta_port,
2063 (void *)&cmd_config_rss_reta_keyword,
2064 (void *)&cmd_config_rss_reta_port_id,
2065 (void *)&cmd_config_rss_reta_name,
2066 (void *)&cmd_config_rss_reta_list_name,
2067 (void *)&cmd_config_rss_reta_list_of_items,
2072 /* *** SHOW PORT RETA INFO *** */
2073 struct cmd_showport_reta {
2074 cmdline_fixed_string_t show;
2075 cmdline_fixed_string_t port;
2077 cmdline_fixed_string_t rss;
2078 cmdline_fixed_string_t reta;
2080 cmdline_fixed_string_t list_of_items;
2084 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2085 uint16_t nb_entries,
2089 const char *p, *p0 = str;
2094 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2095 RTE_RETA_GROUP_SIZE;
2098 p = strchr(p0, '(');
2102 p0 = strchr(p, ')');
2106 if (size >= sizeof(s)) {
2107 printf("The string size exceeds the internal buffer size\n");
2110 snprintf(s, sizeof(s), "%.*s", size, p);
2111 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2112 if (ret <= 0 || ret != num) {
2113 printf("The bits of masks do not match the number of "
2114 "reta entries: %u\n", num);
2117 for (i = 0; i < ret; i++)
2118 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2124 cmd_showport_reta_parsed(void *parsed_result,
2125 __attribute__((unused)) struct cmdline *cl,
2126 __attribute__((unused)) void *data)
2128 struct cmd_showport_reta *res = parsed_result;
2129 struct rte_eth_rss_reta_entry64 reta_conf[8];
2130 struct rte_eth_dev_info dev_info;
2132 memset(&dev_info, 0, sizeof(dev_info));
2133 rte_eth_dev_info_get(res->port_id, &dev_info);
2134 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2135 res->size > ETH_RSS_RETA_SIZE_512) {
2136 printf("Invalid redirection table size: %u\n", res->size);
2140 memset(reta_conf, 0, sizeof(reta_conf));
2141 if (showport_parse_reta_config(reta_conf, res->size,
2142 res->list_of_items) < 0) {
2143 printf("Invalid string: %s for reta masks\n",
2144 res->list_of_items);
2147 port_rss_reta_info(res->port_id, reta_conf, res->size);
2150 cmdline_parse_token_string_t cmd_showport_reta_show =
2151 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2152 cmdline_parse_token_string_t cmd_showport_reta_port =
2153 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2154 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2155 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2156 cmdline_parse_token_string_t cmd_showport_reta_rss =
2157 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2158 cmdline_parse_token_string_t cmd_showport_reta_reta =
2159 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2160 cmdline_parse_token_num_t cmd_showport_reta_size =
2161 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2162 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2163 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2164 list_of_items, NULL);
2166 cmdline_parse_inst_t cmd_showport_reta = {
2167 .f = cmd_showport_reta_parsed,
2169 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2171 (void *)&cmd_showport_reta_show,
2172 (void *)&cmd_showport_reta_port,
2173 (void *)&cmd_showport_reta_port_id,
2174 (void *)&cmd_showport_reta_rss,
2175 (void *)&cmd_showport_reta_reta,
2176 (void *)&cmd_showport_reta_size,
2177 (void *)&cmd_showport_reta_list_of_items,
2182 /* *** Show RSS hash configuration *** */
2183 struct cmd_showport_rss_hash {
2184 cmdline_fixed_string_t show;
2185 cmdline_fixed_string_t port;
2187 cmdline_fixed_string_t rss_hash;
2188 cmdline_fixed_string_t rss_type;
2189 cmdline_fixed_string_t key; /* optional argument */
2192 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2193 __attribute__((unused)) struct cmdline *cl,
2196 struct cmd_showport_rss_hash *res = parsed_result;
2198 port_rss_hash_conf_show(res->port_id, res->rss_type,
2199 show_rss_key != NULL);
2202 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2203 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2204 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2205 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2206 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2207 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2208 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2209 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2211 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2212 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2213 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2214 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2215 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2216 "ipv6-tcp-ex#ipv6-udp-ex");
2217 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2218 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2220 cmdline_parse_inst_t cmd_showport_rss_hash = {
2221 .f = cmd_showport_rss_hash_parsed,
2223 .help_str = "show port <port_id> rss-hash "
2224 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2225 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2226 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2228 (void *)&cmd_showport_rss_hash_show,
2229 (void *)&cmd_showport_rss_hash_port,
2230 (void *)&cmd_showport_rss_hash_port_id,
2231 (void *)&cmd_showport_rss_hash_rss_hash,
2232 (void *)&cmd_showport_rss_hash_rss_hash_info,
2237 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2238 .f = cmd_showport_rss_hash_parsed,
2240 .help_str = "show port <port_id> rss-hash "
2241 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2242 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2243 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2245 (void *)&cmd_showport_rss_hash_show,
2246 (void *)&cmd_showport_rss_hash_port,
2247 (void *)&cmd_showport_rss_hash_port_id,
2248 (void *)&cmd_showport_rss_hash_rss_hash,
2249 (void *)&cmd_showport_rss_hash_rss_hash_info,
2250 (void *)&cmd_showport_rss_hash_rss_key,
2255 /* *** Configure DCB *** */
2256 struct cmd_config_dcb {
2257 cmdline_fixed_string_t port;
2258 cmdline_fixed_string_t config;
2260 cmdline_fixed_string_t dcb;
2261 cmdline_fixed_string_t vt;
2262 cmdline_fixed_string_t vt_en;
2264 cmdline_fixed_string_t pfc;
2265 cmdline_fixed_string_t pfc_en;
2269 cmd_config_dcb_parsed(void *parsed_result,
2270 __attribute__((unused)) struct cmdline *cl,
2271 __attribute__((unused)) void *data)
2273 struct cmd_config_dcb *res = parsed_result;
2274 portid_t port_id = res->port_id;
2275 struct rte_port *port;
2279 port = &ports[port_id];
2280 /** Check if the port is not started **/
2281 if (port->port_status != RTE_PORT_STOPPED) {
2282 printf("Please stop port %d first\n", port_id);
2286 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2287 printf("The invalid number of traffic class,"
2288 " only 4 or 8 allowed.\n");
2292 if (nb_fwd_lcores < res->num_tcs) {
2293 printf("nb_cores shouldn't be less than number of TCs.\n");
2296 if (!strncmp(res->pfc_en, "on", 2))
2301 /* DCB in VT mode */
2302 if (!strncmp(res->vt_en, "on", 2))
2303 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2304 (enum rte_eth_nb_tcs)res->num_tcs,
2307 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2308 (enum rte_eth_nb_tcs)res->num_tcs,
2313 printf("Cannot initialize network ports.\n");
2317 cmd_reconfig_device_queue(port_id, 1, 1);
2320 cmdline_parse_token_string_t cmd_config_dcb_port =
2321 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2322 cmdline_parse_token_string_t cmd_config_dcb_config =
2323 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2324 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2325 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2326 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2327 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2328 cmdline_parse_token_string_t cmd_config_dcb_vt =
2329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2330 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2331 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2332 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2333 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2334 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2336 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2337 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2339 cmdline_parse_inst_t cmd_config_dcb = {
2340 .f = cmd_config_dcb_parsed,
2342 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2344 (void *)&cmd_config_dcb_port,
2345 (void *)&cmd_config_dcb_config,
2346 (void *)&cmd_config_dcb_port_id,
2347 (void *)&cmd_config_dcb_dcb,
2348 (void *)&cmd_config_dcb_vt,
2349 (void *)&cmd_config_dcb_vt_en,
2350 (void *)&cmd_config_dcb_num_tcs,
2351 (void *)&cmd_config_dcb_pfc,
2352 (void *)&cmd_config_dcb_pfc_en,
2357 /* *** configure number of packets per burst *** */
2358 struct cmd_config_burst {
2359 cmdline_fixed_string_t port;
2360 cmdline_fixed_string_t keyword;
2361 cmdline_fixed_string_t all;
2362 cmdline_fixed_string_t name;
2367 cmd_config_burst_parsed(void *parsed_result,
2368 __attribute__((unused)) struct cmdline *cl,
2369 __attribute__((unused)) void *data)
2371 struct cmd_config_burst *res = parsed_result;
2373 if (!all_ports_stopped()) {
2374 printf("Please stop all ports first\n");
2378 if (!strcmp(res->name, "burst")) {
2379 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2380 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2383 nb_pkt_per_burst = res->value;
2385 printf("Unknown parameter\n");
2391 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2394 cmdline_parse_token_string_t cmd_config_burst_port =
2395 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2396 cmdline_parse_token_string_t cmd_config_burst_keyword =
2397 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2398 cmdline_parse_token_string_t cmd_config_burst_all =
2399 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2400 cmdline_parse_token_string_t cmd_config_burst_name =
2401 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2402 cmdline_parse_token_num_t cmd_config_burst_value =
2403 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2405 cmdline_parse_inst_t cmd_config_burst = {
2406 .f = cmd_config_burst_parsed,
2408 .help_str = "port config all burst <value>",
2410 (void *)&cmd_config_burst_port,
2411 (void *)&cmd_config_burst_keyword,
2412 (void *)&cmd_config_burst_all,
2413 (void *)&cmd_config_burst_name,
2414 (void *)&cmd_config_burst_value,
2419 /* *** configure rx/tx queues *** */
2420 struct cmd_config_thresh {
2421 cmdline_fixed_string_t port;
2422 cmdline_fixed_string_t keyword;
2423 cmdline_fixed_string_t all;
2424 cmdline_fixed_string_t name;
2429 cmd_config_thresh_parsed(void *parsed_result,
2430 __attribute__((unused)) struct cmdline *cl,
2431 __attribute__((unused)) void *data)
2433 struct cmd_config_thresh *res = parsed_result;
2435 if (!all_ports_stopped()) {
2436 printf("Please stop all ports first\n");
2440 if (!strcmp(res->name, "txpt"))
2441 tx_pthresh = res->value;
2442 else if(!strcmp(res->name, "txht"))
2443 tx_hthresh = res->value;
2444 else if(!strcmp(res->name, "txwt"))
2445 tx_wthresh = res->value;
2446 else if(!strcmp(res->name, "rxpt"))
2447 rx_pthresh = res->value;
2448 else if(!strcmp(res->name, "rxht"))
2449 rx_hthresh = res->value;
2450 else if(!strcmp(res->name, "rxwt"))
2451 rx_wthresh = res->value;
2453 printf("Unknown parameter\n");
2459 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2462 cmdline_parse_token_string_t cmd_config_thresh_port =
2463 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2464 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2465 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2466 cmdline_parse_token_string_t cmd_config_thresh_all =
2467 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2468 cmdline_parse_token_string_t cmd_config_thresh_name =
2469 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2470 "txpt#txht#txwt#rxpt#rxht#rxwt");
2471 cmdline_parse_token_num_t cmd_config_thresh_value =
2472 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2474 cmdline_parse_inst_t cmd_config_thresh = {
2475 .f = cmd_config_thresh_parsed,
2477 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2479 (void *)&cmd_config_thresh_port,
2480 (void *)&cmd_config_thresh_keyword,
2481 (void *)&cmd_config_thresh_all,
2482 (void *)&cmd_config_thresh_name,
2483 (void *)&cmd_config_thresh_value,
2488 /* *** configure free/rs threshold *** */
2489 struct cmd_config_threshold {
2490 cmdline_fixed_string_t port;
2491 cmdline_fixed_string_t keyword;
2492 cmdline_fixed_string_t all;
2493 cmdline_fixed_string_t name;
2498 cmd_config_threshold_parsed(void *parsed_result,
2499 __attribute__((unused)) struct cmdline *cl,
2500 __attribute__((unused)) void *data)
2502 struct cmd_config_threshold *res = parsed_result;
2504 if (!all_ports_stopped()) {
2505 printf("Please stop all ports first\n");
2509 if (!strcmp(res->name, "txfreet"))
2510 tx_free_thresh = res->value;
2511 else if (!strcmp(res->name, "txrst"))
2512 tx_rs_thresh = res->value;
2513 else if (!strcmp(res->name, "rxfreet"))
2514 rx_free_thresh = res->value;
2516 printf("Unknown parameter\n");
2522 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2525 cmdline_parse_token_string_t cmd_config_threshold_port =
2526 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2527 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2528 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2530 cmdline_parse_token_string_t cmd_config_threshold_all =
2531 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2532 cmdline_parse_token_string_t cmd_config_threshold_name =
2533 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2534 "txfreet#txrst#rxfreet");
2535 cmdline_parse_token_num_t cmd_config_threshold_value =
2536 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2538 cmdline_parse_inst_t cmd_config_threshold = {
2539 .f = cmd_config_threshold_parsed,
2541 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2543 (void *)&cmd_config_threshold_port,
2544 (void *)&cmd_config_threshold_keyword,
2545 (void *)&cmd_config_threshold_all,
2546 (void *)&cmd_config_threshold_name,
2547 (void *)&cmd_config_threshold_value,
2553 struct cmd_stop_result {
2554 cmdline_fixed_string_t stop;
2557 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2558 __attribute__((unused)) struct cmdline *cl,
2559 __attribute__((unused)) void *data)
2561 stop_packet_forwarding();
2564 cmdline_parse_token_string_t cmd_stop_stop =
2565 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2567 cmdline_parse_inst_t cmd_stop = {
2568 .f = cmd_stop_parsed,
2570 .help_str = "stop: Stop packet forwarding",
2572 (void *)&cmd_stop_stop,
2577 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2580 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2581 unsigned int *parsed_items, int check_unique_values)
2583 unsigned int nb_item;
2591 * First parse all items in the list and store their value.
2596 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2598 if ((c >= '0') && (c <= '9')) {
2599 value = (unsigned int) (value * 10 + (c - '0'));
2604 printf("character %c is not a decimal digit\n", c);
2608 printf("No valid value before comma\n");
2611 if (nb_item < max_items) {
2612 parsed_items[nb_item] = value;
2618 if (nb_item >= max_items) {
2619 printf("Number of %s = %u > %u (maximum items)\n",
2620 item_name, nb_item + 1, max_items);
2623 parsed_items[nb_item++] = value;
2624 if (! check_unique_values)
2628 * Then, check that all values in the list are differents.
2629 * No optimization here...
2631 for (i = 0; i < nb_item; i++) {
2632 for (j = i + 1; j < nb_item; j++) {
2633 if (parsed_items[j] == parsed_items[i]) {
2634 printf("duplicated %s %u at index %u and %u\n",
2635 item_name, parsed_items[i], i, j);
2643 struct cmd_set_list_result {
2644 cmdline_fixed_string_t cmd_keyword;
2645 cmdline_fixed_string_t list_name;
2646 cmdline_fixed_string_t list_of_items;
2649 static void cmd_set_list_parsed(void *parsed_result,
2650 __attribute__((unused)) struct cmdline *cl,
2651 __attribute__((unused)) void *data)
2653 struct cmd_set_list_result *res;
2655 unsigned int lcorelist[RTE_MAX_LCORE];
2656 unsigned int portlist[RTE_MAX_ETHPORTS];
2658 unsigned int nb_item;
2660 if (test_done == 0) {
2661 printf("Please stop forwarding first\n");
2665 res = parsed_result;
2666 if (!strcmp(res->list_name, "corelist")) {
2667 nb_item = parse_item_list(res->list_of_items, "core",
2669 parsed_items.lcorelist, 1);
2671 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2676 if (!strcmp(res->list_name, "portlist")) {
2677 nb_item = parse_item_list(res->list_of_items, "port",
2679 parsed_items.portlist, 1);
2681 set_fwd_ports_list(parsed_items.portlist, nb_item);
2687 cmdline_parse_token_string_t cmd_set_list_keyword =
2688 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2690 cmdline_parse_token_string_t cmd_set_list_name =
2691 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2692 "corelist#portlist");
2693 cmdline_parse_token_string_t cmd_set_list_of_items =
2694 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2697 cmdline_parse_inst_t cmd_set_fwd_list = {
2698 .f = cmd_set_list_parsed,
2700 .help_str = "set corelist|portlist <list0[,list1]*>",
2702 (void *)&cmd_set_list_keyword,
2703 (void *)&cmd_set_list_name,
2704 (void *)&cmd_set_list_of_items,
2709 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2711 struct cmd_setmask_result {
2712 cmdline_fixed_string_t set;
2713 cmdline_fixed_string_t mask;
2717 static void cmd_set_mask_parsed(void *parsed_result,
2718 __attribute__((unused)) struct cmdline *cl,
2719 __attribute__((unused)) void *data)
2721 struct cmd_setmask_result *res = parsed_result;
2723 if (test_done == 0) {
2724 printf("Please stop forwarding first\n");
2727 if (!strcmp(res->mask, "coremask")) {
2728 set_fwd_lcores_mask(res->hexavalue);
2730 } else if (!strcmp(res->mask, "portmask")) {
2731 set_fwd_ports_mask(res->hexavalue);
2736 cmdline_parse_token_string_t cmd_setmask_set =
2737 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2738 cmdline_parse_token_string_t cmd_setmask_mask =
2739 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2740 "coremask#portmask");
2741 cmdline_parse_token_num_t cmd_setmask_value =
2742 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2744 cmdline_parse_inst_t cmd_set_fwd_mask = {
2745 .f = cmd_set_mask_parsed,
2747 .help_str = "set coremask|portmask <hexadecimal value>",
2749 (void *)&cmd_setmask_set,
2750 (void *)&cmd_setmask_mask,
2751 (void *)&cmd_setmask_value,
2757 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2759 struct cmd_set_result {
2760 cmdline_fixed_string_t set;
2761 cmdline_fixed_string_t what;
2765 static void cmd_set_parsed(void *parsed_result,
2766 __attribute__((unused)) struct cmdline *cl,
2767 __attribute__((unused)) void *data)
2769 struct cmd_set_result *res = parsed_result;
2770 if (!strcmp(res->what, "nbport")) {
2771 set_fwd_ports_number(res->value);
2773 } else if (!strcmp(res->what, "nbcore")) {
2774 set_fwd_lcores_number(res->value);
2776 } else if (!strcmp(res->what, "burst"))
2777 set_nb_pkt_per_burst(res->value);
2778 else if (!strcmp(res->what, "verbose"))
2779 set_verbose_level(res->value);
2782 cmdline_parse_token_string_t cmd_set_set =
2783 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2784 cmdline_parse_token_string_t cmd_set_what =
2785 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2786 "nbport#nbcore#burst#verbose");
2787 cmdline_parse_token_num_t cmd_set_value =
2788 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2790 cmdline_parse_inst_t cmd_set_numbers = {
2791 .f = cmd_set_parsed,
2793 .help_str = "set nbport|nbcore|burst|verbose <value>",
2795 (void *)&cmd_set_set,
2796 (void *)&cmd_set_what,
2797 (void *)&cmd_set_value,
2802 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2804 struct cmd_set_txpkts_result {
2805 cmdline_fixed_string_t cmd_keyword;
2806 cmdline_fixed_string_t txpkts;
2807 cmdline_fixed_string_t seg_lengths;
2811 cmd_set_txpkts_parsed(void *parsed_result,
2812 __attribute__((unused)) struct cmdline *cl,
2813 __attribute__((unused)) void *data)
2815 struct cmd_set_txpkts_result *res;
2816 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2817 unsigned int nb_segs;
2819 res = parsed_result;
2820 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2821 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2823 set_tx_pkt_segments(seg_lengths, nb_segs);
2826 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2827 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2828 cmd_keyword, "set");
2829 cmdline_parse_token_string_t cmd_set_txpkts_name =
2830 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2832 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2833 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2836 cmdline_parse_inst_t cmd_set_txpkts = {
2837 .f = cmd_set_txpkts_parsed,
2839 .help_str = "set txpkts <len0[,len1]*>",
2841 (void *)&cmd_set_txpkts_keyword,
2842 (void *)&cmd_set_txpkts_name,
2843 (void *)&cmd_set_txpkts_lengths,
2848 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2850 struct cmd_set_txsplit_result {
2851 cmdline_fixed_string_t cmd_keyword;
2852 cmdline_fixed_string_t txsplit;
2853 cmdline_fixed_string_t mode;
2857 cmd_set_txsplit_parsed(void *parsed_result,
2858 __attribute__((unused)) struct cmdline *cl,
2859 __attribute__((unused)) void *data)
2861 struct cmd_set_txsplit_result *res;
2863 res = parsed_result;
2864 set_tx_pkt_split(res->mode);
2867 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2868 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2869 cmd_keyword, "set");
2870 cmdline_parse_token_string_t cmd_set_txsplit_name =
2871 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2872 txsplit, "txsplit");
2873 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2874 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2877 cmdline_parse_inst_t cmd_set_txsplit = {
2878 .f = cmd_set_txsplit_parsed,
2880 .help_str = "set txsplit on|off|rand",
2882 (void *)&cmd_set_txsplit_keyword,
2883 (void *)&cmd_set_txsplit_name,
2884 (void *)&cmd_set_txsplit_mode,
2889 /* *** CONFIG TX QUEUE FLAGS *** */
2891 struct cmd_config_txqflags_result {
2892 cmdline_fixed_string_t port;
2893 cmdline_fixed_string_t config;
2894 cmdline_fixed_string_t all;
2895 cmdline_fixed_string_t what;
2899 static void cmd_config_txqflags_parsed(void *parsed_result,
2900 __attribute__((unused)) struct cmdline *cl,
2901 __attribute__((unused)) void *data)
2903 struct cmd_config_txqflags_result *res = parsed_result;
2905 if (!all_ports_stopped()) {
2906 printf("Please stop all ports first\n");
2910 if (strcmp(res->what, "txqflags")) {
2911 printf("Unknown parameter\n");
2915 if (res->hexvalue >= 0) {
2916 txq_flags = res->hexvalue;
2918 printf("txqflags must be >= 0\n");
2924 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2927 cmdline_parse_token_string_t cmd_config_txqflags_port =
2928 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2930 cmdline_parse_token_string_t cmd_config_txqflags_config =
2931 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2933 cmdline_parse_token_string_t cmd_config_txqflags_all =
2934 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2936 cmdline_parse_token_string_t cmd_config_txqflags_what =
2937 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2939 cmdline_parse_token_num_t cmd_config_txqflags_value =
2940 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2943 cmdline_parse_inst_t cmd_config_txqflags = {
2944 .f = cmd_config_txqflags_parsed,
2946 .help_str = "port config all txqflags <value>",
2948 (void *)&cmd_config_txqflags_port,
2949 (void *)&cmd_config_txqflags_config,
2950 (void *)&cmd_config_txqflags_all,
2951 (void *)&cmd_config_txqflags_what,
2952 (void *)&cmd_config_txqflags_value,
2957 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2958 struct cmd_rx_vlan_filter_all_result {
2959 cmdline_fixed_string_t rx_vlan;
2960 cmdline_fixed_string_t what;
2961 cmdline_fixed_string_t all;
2966 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2967 __attribute__((unused)) struct cmdline *cl,
2968 __attribute__((unused)) void *data)
2970 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2972 if (!strcmp(res->what, "add"))
2973 rx_vlan_all_filter_set(res->port_id, 1);
2975 rx_vlan_all_filter_set(res->port_id, 0);
2978 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2979 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2980 rx_vlan, "rx_vlan");
2981 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2982 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2984 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2985 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2987 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2988 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2991 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2992 .f = cmd_rx_vlan_filter_all_parsed,
2994 .help_str = "rx_vlan add|rm all <port_id>: "
2995 "Add/Remove all identifiers to/from the set of VLAN "
2996 "identifiers filtered by a port",
2998 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2999 (void *)&cmd_rx_vlan_filter_all_what,
3000 (void *)&cmd_rx_vlan_filter_all_all,
3001 (void *)&cmd_rx_vlan_filter_all_portid,
3006 /* *** VLAN OFFLOAD SET ON A PORT *** */
3007 struct cmd_vlan_offload_result {
3008 cmdline_fixed_string_t vlan;
3009 cmdline_fixed_string_t set;
3010 cmdline_fixed_string_t vlan_type;
3011 cmdline_fixed_string_t what;
3012 cmdline_fixed_string_t on;
3013 cmdline_fixed_string_t port_id;
3017 cmd_vlan_offload_parsed(void *parsed_result,
3018 __attribute__((unused)) struct cmdline *cl,
3019 __attribute__((unused)) void *data)
3022 struct cmd_vlan_offload_result *res = parsed_result;
3025 portid_t port_id = 0;
3029 len = strnlen(str, STR_TOKEN_SIZE);
3031 /* Get port_id first */
3039 tmp = strtoul(str, NULL, 0);
3040 /* If port_id greater that what portid_t can represent, return */
3041 if(tmp >= RTE_MAX_ETHPORTS)
3043 port_id = (portid_t)tmp;
3045 if (!strcmp(res->on, "on"))
3050 if (!strcmp(res->what, "strip"))
3051 rx_vlan_strip_set(port_id, on);
3052 else if(!strcmp(res->what, "stripq")){
3053 uint16_t queue_id = 0;
3055 /* No queue_id, return */
3057 printf("must specify (port,queue_id)\n");
3060 tmp = strtoul(str + i + 1, NULL, 0);
3061 /* If queue_id greater that what 16-bits can represent, return */
3065 queue_id = (uint16_t)tmp;
3066 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3068 else if (!strcmp(res->what, "filter"))
3069 rx_vlan_filter_set(port_id, on);
3071 vlan_extend_set(port_id, on);
3076 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3077 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3079 cmdline_parse_token_string_t cmd_vlan_offload_set =
3080 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3082 cmdline_parse_token_string_t cmd_vlan_offload_what =
3083 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3084 what, "strip#filter#qinq#stripq");
3085 cmdline_parse_token_string_t cmd_vlan_offload_on =
3086 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3088 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3089 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3092 cmdline_parse_inst_t cmd_vlan_offload = {
3093 .f = cmd_vlan_offload_parsed,
3095 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3096 "<port_id[,queue_id]>: "
3097 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3099 (void *)&cmd_vlan_offload_vlan,
3100 (void *)&cmd_vlan_offload_set,
3101 (void *)&cmd_vlan_offload_what,
3102 (void *)&cmd_vlan_offload_on,
3103 (void *)&cmd_vlan_offload_portid,
3108 /* *** VLAN TPID SET ON A PORT *** */
3109 struct cmd_vlan_tpid_result {
3110 cmdline_fixed_string_t vlan;
3111 cmdline_fixed_string_t set;
3112 cmdline_fixed_string_t vlan_type;
3113 cmdline_fixed_string_t what;
3119 cmd_vlan_tpid_parsed(void *parsed_result,
3120 __attribute__((unused)) struct cmdline *cl,
3121 __attribute__((unused)) void *data)
3123 struct cmd_vlan_tpid_result *res = parsed_result;
3124 enum rte_vlan_type vlan_type;
3126 if (!strcmp(res->vlan_type, "inner"))
3127 vlan_type = ETH_VLAN_TYPE_INNER;
3128 else if (!strcmp(res->vlan_type, "outer"))
3129 vlan_type = ETH_VLAN_TYPE_OUTER;
3131 printf("Unknown vlan type\n");
3134 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3137 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3138 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3140 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3141 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3143 cmdline_parse_token_string_t cmd_vlan_type =
3144 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3145 vlan_type, "inner#outer");
3146 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3147 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3149 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3150 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3152 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3153 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3156 cmdline_parse_inst_t cmd_vlan_tpid = {
3157 .f = cmd_vlan_tpid_parsed,
3159 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3160 "Set the VLAN Ether type",
3162 (void *)&cmd_vlan_tpid_vlan,
3163 (void *)&cmd_vlan_tpid_set,
3164 (void *)&cmd_vlan_type,
3165 (void *)&cmd_vlan_tpid_what,
3166 (void *)&cmd_vlan_tpid_tpid,
3167 (void *)&cmd_vlan_tpid_portid,
3172 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3173 struct cmd_rx_vlan_filter_result {
3174 cmdline_fixed_string_t rx_vlan;
3175 cmdline_fixed_string_t what;
3181 cmd_rx_vlan_filter_parsed(void *parsed_result,
3182 __attribute__((unused)) struct cmdline *cl,
3183 __attribute__((unused)) void *data)
3185 struct cmd_rx_vlan_filter_result *res = parsed_result;
3187 if (!strcmp(res->what, "add"))
3188 rx_vft_set(res->port_id, res->vlan_id, 1);
3190 rx_vft_set(res->port_id, res->vlan_id, 0);
3193 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3194 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3195 rx_vlan, "rx_vlan");
3196 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3197 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3199 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3200 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3202 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3203 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3206 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3207 .f = cmd_rx_vlan_filter_parsed,
3209 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3210 "Add/Remove a VLAN identifier to/from the set of VLAN "
3211 "identifiers filtered by a port",
3213 (void *)&cmd_rx_vlan_filter_rx_vlan,
3214 (void *)&cmd_rx_vlan_filter_what,
3215 (void *)&cmd_rx_vlan_filter_vlanid,
3216 (void *)&cmd_rx_vlan_filter_portid,
3221 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3222 struct cmd_tx_vlan_set_result {
3223 cmdline_fixed_string_t tx_vlan;
3224 cmdline_fixed_string_t set;
3230 cmd_tx_vlan_set_parsed(void *parsed_result,
3231 __attribute__((unused)) struct cmdline *cl,
3232 __attribute__((unused)) void *data)
3234 struct cmd_tx_vlan_set_result *res = parsed_result;
3236 tx_vlan_set(res->port_id, res->vlan_id);
3239 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3240 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3241 tx_vlan, "tx_vlan");
3242 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3243 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3245 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3246 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3248 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3249 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3252 cmdline_parse_inst_t cmd_tx_vlan_set = {
3253 .f = cmd_tx_vlan_set_parsed,
3255 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3256 "Enable hardware insertion of a single VLAN header "
3257 "with a given TAG Identifier in packets sent on a port",
3259 (void *)&cmd_tx_vlan_set_tx_vlan,
3260 (void *)&cmd_tx_vlan_set_set,
3261 (void *)&cmd_tx_vlan_set_portid,
3262 (void *)&cmd_tx_vlan_set_vlanid,
3267 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3268 struct cmd_tx_vlan_set_qinq_result {
3269 cmdline_fixed_string_t tx_vlan;
3270 cmdline_fixed_string_t set;
3273 uint16_t vlan_id_outer;
3277 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3278 __attribute__((unused)) struct cmdline *cl,
3279 __attribute__((unused)) void *data)
3281 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3283 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3286 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3287 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3288 tx_vlan, "tx_vlan");
3289 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3290 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3292 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3293 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3295 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3296 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3298 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3299 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3300 vlan_id_outer, UINT16);
3302 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3303 .f = cmd_tx_vlan_set_qinq_parsed,
3305 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3306 "Enable hardware insertion of double VLAN header "
3307 "with given TAG Identifiers in packets sent on a port",
3309 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3310 (void *)&cmd_tx_vlan_set_qinq_set,
3311 (void *)&cmd_tx_vlan_set_qinq_portid,
3312 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3313 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3318 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3319 struct cmd_tx_vlan_set_pvid_result {
3320 cmdline_fixed_string_t tx_vlan;
3321 cmdline_fixed_string_t set;
3322 cmdline_fixed_string_t pvid;
3325 cmdline_fixed_string_t mode;
3329 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3330 __attribute__((unused)) struct cmdline *cl,
3331 __attribute__((unused)) void *data)
3333 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3335 if (strcmp(res->mode, "on") == 0)
3336 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3338 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3341 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3342 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3343 tx_vlan, "tx_vlan");
3344 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3345 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3347 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3348 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3350 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3351 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3353 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3354 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3356 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3357 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3360 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3361 .f = cmd_tx_vlan_set_pvid_parsed,
3363 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3365 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3366 (void *)&cmd_tx_vlan_set_pvid_set,
3367 (void *)&cmd_tx_vlan_set_pvid_pvid,
3368 (void *)&cmd_tx_vlan_set_pvid_port_id,
3369 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3370 (void *)&cmd_tx_vlan_set_pvid_mode,
3375 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3376 struct cmd_tx_vlan_reset_result {
3377 cmdline_fixed_string_t tx_vlan;
3378 cmdline_fixed_string_t reset;
3383 cmd_tx_vlan_reset_parsed(void *parsed_result,
3384 __attribute__((unused)) struct cmdline *cl,
3385 __attribute__((unused)) void *data)
3387 struct cmd_tx_vlan_reset_result *res = parsed_result;
3389 tx_vlan_reset(res->port_id);
3392 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3393 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3394 tx_vlan, "tx_vlan");
3395 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3396 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3398 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3399 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3402 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3403 .f = cmd_tx_vlan_reset_parsed,
3405 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3406 "VLAN header in packets sent on a port",
3408 (void *)&cmd_tx_vlan_reset_tx_vlan,
3409 (void *)&cmd_tx_vlan_reset_reset,
3410 (void *)&cmd_tx_vlan_reset_portid,
3416 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3417 struct cmd_csum_result {
3418 cmdline_fixed_string_t csum;
3419 cmdline_fixed_string_t mode;
3420 cmdline_fixed_string_t proto;
3421 cmdline_fixed_string_t hwsw;
3426 csum_show(int port_id)
3428 struct rte_eth_dev_info dev_info;
3431 ol_flags = ports[port_id].tx_ol_flags;
3432 printf("Parse tunnel is %s\n",
3433 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3434 printf("IP checksum offload is %s\n",
3435 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3436 printf("UDP checksum offload is %s\n",
3437 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3438 printf("TCP checksum offload is %s\n",
3439 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3440 printf("SCTP checksum offload is %s\n",
3441 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3442 printf("Outer-Ip checksum offload is %s\n",
3443 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3445 /* display warnings if configuration is not supported by the NIC */
3446 rte_eth_dev_info_get(port_id, &dev_info);
3447 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3448 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3449 printf("Warning: hardware IP checksum enabled but not "
3450 "supported by port %d\n", port_id);
3452 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3453 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3454 printf("Warning: hardware UDP checksum enabled but not "
3455 "supported by port %d\n", port_id);
3457 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3458 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3459 printf("Warning: hardware TCP checksum enabled but not "
3460 "supported by port %d\n", port_id);
3462 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3463 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3464 printf("Warning: hardware SCTP checksum enabled but not "
3465 "supported by port %d\n", port_id);
3467 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3468 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3469 printf("Warning: hardware outer IP checksum enabled but not "
3470 "supported by port %d\n", port_id);
3475 cmd_csum_parsed(void *parsed_result,
3476 __attribute__((unused)) struct cmdline *cl,
3477 __attribute__((unused)) void *data)
3479 struct cmd_csum_result *res = parsed_result;
3483 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3484 printf("invalid port %d\n", res->port_id);
3488 if (!strcmp(res->mode, "set")) {
3490 if (!strcmp(res->hwsw, "hw"))
3493 if (!strcmp(res->proto, "ip")) {
3494 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3495 } else if (!strcmp(res->proto, "udp")) {
3496 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3497 } else if (!strcmp(res->proto, "tcp")) {
3498 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3499 } else if (!strcmp(res->proto, "sctp")) {
3500 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3501 } else if (!strcmp(res->proto, "outer-ip")) {
3502 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3506 ports[res->port_id].tx_ol_flags |= mask;
3508 ports[res->port_id].tx_ol_flags &= (~mask);
3510 csum_show(res->port_id);
3513 cmdline_parse_token_string_t cmd_csum_csum =
3514 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3516 cmdline_parse_token_string_t cmd_csum_mode =
3517 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3519 cmdline_parse_token_string_t cmd_csum_proto =
3520 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3521 proto, "ip#tcp#udp#sctp#outer-ip");
3522 cmdline_parse_token_string_t cmd_csum_hwsw =
3523 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3525 cmdline_parse_token_num_t cmd_csum_portid =
3526 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3529 cmdline_parse_inst_t cmd_csum_set = {
3530 .f = cmd_csum_parsed,
3532 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3533 "Enable/Disable hardware calculation of L3/L4 checksum when "
3534 "using csum forward engine",
3536 (void *)&cmd_csum_csum,
3537 (void *)&cmd_csum_mode,
3538 (void *)&cmd_csum_proto,
3539 (void *)&cmd_csum_hwsw,
3540 (void *)&cmd_csum_portid,
3545 cmdline_parse_token_string_t cmd_csum_mode_show =
3546 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3549 cmdline_parse_inst_t cmd_csum_show = {
3550 .f = cmd_csum_parsed,
3552 .help_str = "csum show <port_id>: Show checksum offload configuration",
3554 (void *)&cmd_csum_csum,
3555 (void *)&cmd_csum_mode_show,
3556 (void *)&cmd_csum_portid,
3561 /* Enable/disable tunnel parsing */
3562 struct cmd_csum_tunnel_result {
3563 cmdline_fixed_string_t csum;
3564 cmdline_fixed_string_t parse;
3565 cmdline_fixed_string_t onoff;
3570 cmd_csum_tunnel_parsed(void *parsed_result,
3571 __attribute__((unused)) struct cmdline *cl,
3572 __attribute__((unused)) void *data)
3574 struct cmd_csum_tunnel_result *res = parsed_result;
3576 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3579 if (!strcmp(res->onoff, "on"))
3580 ports[res->port_id].tx_ol_flags |=
3581 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3583 ports[res->port_id].tx_ol_flags &=
3584 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3586 csum_show(res->port_id);
3589 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3590 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3592 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3593 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3594 parse, "parse_tunnel");
3595 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3596 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3598 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3599 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3602 cmdline_parse_inst_t cmd_csum_tunnel = {
3603 .f = cmd_csum_tunnel_parsed,
3605 .help_str = "csum parse_tunnel on|off <port_id>: "
3606 "Enable/Disable parsing of tunnels for csum engine",
3608 (void *)&cmd_csum_tunnel_csum,
3609 (void *)&cmd_csum_tunnel_parse,
3610 (void *)&cmd_csum_tunnel_onoff,
3611 (void *)&cmd_csum_tunnel_portid,
3616 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3617 struct cmd_tso_set_result {
3618 cmdline_fixed_string_t tso;
3619 cmdline_fixed_string_t mode;
3625 cmd_tso_set_parsed(void *parsed_result,
3626 __attribute__((unused)) struct cmdline *cl,
3627 __attribute__((unused)) void *data)
3629 struct cmd_tso_set_result *res = parsed_result;
3630 struct rte_eth_dev_info dev_info;
3632 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3635 if (!strcmp(res->mode, "set"))
3636 ports[res->port_id].tso_segsz = res->tso_segsz;
3638 if (ports[res->port_id].tso_segsz == 0)
3639 printf("TSO for non-tunneled packets is disabled\n");
3641 printf("TSO segment size for non-tunneled packets is %d\n",
3642 ports[res->port_id].tso_segsz);
3644 /* display warnings if configuration is not supported by the NIC */
3645 rte_eth_dev_info_get(res->port_id, &dev_info);
3646 if ((ports[res->port_id].tso_segsz != 0) &&
3647 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3648 printf("Warning: TSO enabled but not "
3649 "supported by port %d\n", res->port_id);
3653 cmdline_parse_token_string_t cmd_tso_set_tso =
3654 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3656 cmdline_parse_token_string_t cmd_tso_set_mode =
3657 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3659 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3660 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3662 cmdline_parse_token_num_t cmd_tso_set_portid =
3663 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3666 cmdline_parse_inst_t cmd_tso_set = {
3667 .f = cmd_tso_set_parsed,
3669 .help_str = "tso set <tso_segsz> <port_id>: "
3670 "Set TSO segment size of non-tunneled packets for csum engine "
3673 (void *)&cmd_tso_set_tso,
3674 (void *)&cmd_tso_set_mode,
3675 (void *)&cmd_tso_set_tso_segsz,
3676 (void *)&cmd_tso_set_portid,
3681 cmdline_parse_token_string_t cmd_tso_show_mode =
3682 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3686 cmdline_parse_inst_t cmd_tso_show = {
3687 .f = cmd_tso_set_parsed,
3689 .help_str = "tso show <port_id>: "
3690 "Show TSO segment size of non-tunneled packets for csum engine",
3692 (void *)&cmd_tso_set_tso,
3693 (void *)&cmd_tso_show_mode,
3694 (void *)&cmd_tso_set_portid,
3699 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3700 struct cmd_tunnel_tso_set_result {
3701 cmdline_fixed_string_t tso;
3702 cmdline_fixed_string_t mode;
3708 check_tunnel_tso_nic_support(uint8_t port_id)
3710 struct rte_eth_dev_info dev_info;
3712 rte_eth_dev_info_get(port_id, &dev_info);
3713 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3714 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3715 "supported by port %d\n", port_id);
3716 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3717 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3718 "supported by port %d\n", port_id);
3719 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3720 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3721 "supported by port %d\n", port_id);
3722 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3723 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3724 "supported by port %d\n", port_id);
3728 cmd_tunnel_tso_set_parsed(void *parsed_result,
3729 __attribute__((unused)) struct cmdline *cl,
3730 __attribute__((unused)) void *data)
3732 struct cmd_tunnel_tso_set_result *res = parsed_result;
3734 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3737 if (!strcmp(res->mode, "set"))
3738 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3740 if (ports[res->port_id].tunnel_tso_segsz == 0)
3741 printf("TSO for tunneled packets is disabled\n");
3743 printf("TSO segment size for tunneled packets is %d\n",
3744 ports[res->port_id].tunnel_tso_segsz);
3746 /* Below conditions are needed to make it work:
3747 * (1) tunnel TSO is supported by the NIC;
3748 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3750 * (3) for tunneled pkts with outer L3 of IPv4,
3751 * "csum set outer-ip" must be set to hw, because after tso,
3752 * total_len of outer IP header is changed, and the checksum
3753 * of outer IP header calculated by sw should be wrong; that
3754 * is not necessary for IPv6 tunneled pkts because there's no
3755 * checksum in IP header anymore.
3757 check_tunnel_tso_nic_support(res->port_id);
3759 if (!(ports[res->port_id].tx_ol_flags &
3760 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3761 printf("Warning: csum parse_tunnel must be set "
3762 "so that tunneled packets are recognized\n");
3763 if (!(ports[res->port_id].tx_ol_flags &
3764 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3765 printf("Warning: csum set outer-ip must be set to hw "
3766 "if outer L3 is IPv4; not necessary for IPv6\n");
3770 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3771 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3773 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3774 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3776 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3777 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3779 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3780 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3783 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3784 .f = cmd_tunnel_tso_set_parsed,
3786 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3787 "Set TSO segment size of tunneled packets for csum engine "
3790 (void *)&cmd_tunnel_tso_set_tso,
3791 (void *)&cmd_tunnel_tso_set_mode,
3792 (void *)&cmd_tunnel_tso_set_tso_segsz,
3793 (void *)&cmd_tunnel_tso_set_portid,
3798 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3799 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3803 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3804 .f = cmd_tunnel_tso_set_parsed,
3806 .help_str = "tunnel_tso show <port_id> "
3807 "Show TSO segment size of tunneled packets for csum engine",
3809 (void *)&cmd_tunnel_tso_set_tso,
3810 (void *)&cmd_tunnel_tso_show_mode,
3811 (void *)&cmd_tunnel_tso_set_portid,
3816 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3817 struct cmd_set_flush_rx {
3818 cmdline_fixed_string_t set;
3819 cmdline_fixed_string_t flush_rx;
3820 cmdline_fixed_string_t mode;
3824 cmd_set_flush_rx_parsed(void *parsed_result,
3825 __attribute__((unused)) struct cmdline *cl,
3826 __attribute__((unused)) void *data)
3828 struct cmd_set_flush_rx *res = parsed_result;
3829 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3832 cmdline_parse_token_string_t cmd_setflushrx_set =
3833 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3835 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3836 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3837 flush_rx, "flush_rx");
3838 cmdline_parse_token_string_t cmd_setflushrx_mode =
3839 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3843 cmdline_parse_inst_t cmd_set_flush_rx = {
3844 .f = cmd_set_flush_rx_parsed,
3845 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3848 (void *)&cmd_setflushrx_set,
3849 (void *)&cmd_setflushrx_flush_rx,
3850 (void *)&cmd_setflushrx_mode,
3855 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3856 struct cmd_set_link_check {
3857 cmdline_fixed_string_t set;
3858 cmdline_fixed_string_t link_check;
3859 cmdline_fixed_string_t mode;
3863 cmd_set_link_check_parsed(void *parsed_result,
3864 __attribute__((unused)) struct cmdline *cl,
3865 __attribute__((unused)) void *data)
3867 struct cmd_set_link_check *res = parsed_result;
3868 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3871 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3874 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3875 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3876 link_check, "link_check");
3877 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3878 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3882 cmdline_parse_inst_t cmd_set_link_check = {
3883 .f = cmd_set_link_check_parsed,
3884 .help_str = "set link_check on|off: Enable/Disable link status check "
3885 "when starting/stopping a port",
3888 (void *)&cmd_setlinkcheck_set,
3889 (void *)&cmd_setlinkcheck_link_check,
3890 (void *)&cmd_setlinkcheck_mode,
3895 #ifdef RTE_NIC_BYPASS
3896 /* *** SET NIC BYPASS MODE *** */
3897 struct cmd_set_bypass_mode_result {
3898 cmdline_fixed_string_t set;
3899 cmdline_fixed_string_t bypass;
3900 cmdline_fixed_string_t mode;
3901 cmdline_fixed_string_t value;
3906 cmd_set_bypass_mode_parsed(void *parsed_result,
3907 __attribute__((unused)) struct cmdline *cl,
3908 __attribute__((unused)) void *data)
3910 struct cmd_set_bypass_mode_result *res = parsed_result;
3911 portid_t port_id = res->port_id;
3912 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3914 if (!strcmp(res->value, "bypass"))
3915 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3916 else if (!strcmp(res->value, "isolate"))
3917 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3919 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3921 /* Set the bypass mode for the relevant port. */
3922 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3923 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3927 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3928 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3930 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3931 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3933 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3934 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3936 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3937 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3938 value, "normal#bypass#isolate");
3939 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3940 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3943 cmdline_parse_inst_t cmd_set_bypass_mode = {
3944 .f = cmd_set_bypass_mode_parsed,
3945 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3946 "Set the NIC bypass mode for port_id",
3949 (void *)&cmd_setbypass_mode_set,
3950 (void *)&cmd_setbypass_mode_bypass,
3951 (void *)&cmd_setbypass_mode_mode,
3952 (void *)&cmd_setbypass_mode_value,
3953 (void *)&cmd_setbypass_mode_port,
3958 /* *** SET NIC BYPASS EVENT *** */
3959 struct cmd_set_bypass_event_result {
3960 cmdline_fixed_string_t set;
3961 cmdline_fixed_string_t bypass;
3962 cmdline_fixed_string_t event;
3963 cmdline_fixed_string_t event_value;
3964 cmdline_fixed_string_t mode;
3965 cmdline_fixed_string_t mode_value;
3970 cmd_set_bypass_event_parsed(void *parsed_result,
3971 __attribute__((unused)) struct cmdline *cl,
3972 __attribute__((unused)) void *data)
3975 struct cmd_set_bypass_event_result *res = parsed_result;
3976 portid_t port_id = res->port_id;
3977 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3978 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3980 if (!strcmp(res->event_value, "timeout"))
3981 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3982 else if (!strcmp(res->event_value, "os_on"))
3983 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3984 else if (!strcmp(res->event_value, "os_off"))
3985 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3986 else if (!strcmp(res->event_value, "power_on"))
3987 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3988 else if (!strcmp(res->event_value, "power_off"))
3989 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3991 bypass_event = RTE_BYPASS_EVENT_NONE;
3993 if (!strcmp(res->mode_value, "bypass"))
3994 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3995 else if (!strcmp(res->mode_value, "isolate"))
3996 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3998 bypass_mode = RTE_BYPASS_MODE_NORMAL;
4000 /* Set the watchdog timeout. */
4001 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
4004 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
4005 (rc = rte_eth_dev_wd_timeout_store(port_id,
4006 bypass_timeout)) != 0) {
4007 printf("Failed to set timeout value %u "
4008 "for port %d, errto code: %d.\n",
4009 bypass_timeout, port_id, rc);
4013 /* Set the bypass event to transition to bypass mode. */
4014 if (0 != rte_eth_dev_bypass_event_store(port_id,
4015 bypass_event, bypass_mode)) {
4016 printf("\t Failed to set bypass event for port = %d.\n", port_id);
4021 cmdline_parse_token_string_t cmd_setbypass_event_set =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4024 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4027 cmdline_parse_token_string_t cmd_setbypass_event_event =
4028 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4030 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4031 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4032 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4033 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4034 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4036 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4037 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4038 mode_value, "normal#bypass#isolate");
4039 cmdline_parse_token_num_t cmd_setbypass_event_port =
4040 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4043 cmdline_parse_inst_t cmd_set_bypass_event = {
4044 .f = cmd_set_bypass_event_parsed,
4045 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4046 "power_off mode normal|bypass|isolate <port_id>: "
4047 "Set the NIC bypass event mode for port_id",
4050 (void *)&cmd_setbypass_event_set,
4051 (void *)&cmd_setbypass_event_bypass,
4052 (void *)&cmd_setbypass_event_event,
4053 (void *)&cmd_setbypass_event_event_value,
4054 (void *)&cmd_setbypass_event_mode,
4055 (void *)&cmd_setbypass_event_mode_value,
4056 (void *)&cmd_setbypass_event_port,
4062 /* *** SET NIC BYPASS TIMEOUT *** */
4063 struct cmd_set_bypass_timeout_result {
4064 cmdline_fixed_string_t set;
4065 cmdline_fixed_string_t bypass;
4066 cmdline_fixed_string_t timeout;
4067 cmdline_fixed_string_t value;
4071 cmd_set_bypass_timeout_parsed(void *parsed_result,
4072 __attribute__((unused)) struct cmdline *cl,
4073 __attribute__((unused)) void *data)
4075 struct cmd_set_bypass_timeout_result *res = parsed_result;
4077 if (!strcmp(res->value, "1.5"))
4078 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4079 else if (!strcmp(res->value, "2"))
4080 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4081 else if (!strcmp(res->value, "3"))
4082 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4083 else if (!strcmp(res->value, "4"))
4084 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4085 else if (!strcmp(res->value, "8"))
4086 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4087 else if (!strcmp(res->value, "16"))
4088 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4089 else if (!strcmp(res->value, "32"))
4090 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4092 bypass_timeout = RTE_BYPASS_TMT_OFF;
4095 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4096 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4098 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4099 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4101 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4102 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4103 timeout, "timeout");
4104 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4105 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4106 value, "0#1.5#2#3#4#8#16#32");
4108 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4109 .f = cmd_set_bypass_timeout_parsed,
4110 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4111 "Set the NIC bypass watchdog timeout in seconds",
4114 (void *)&cmd_setbypass_timeout_set,
4115 (void *)&cmd_setbypass_timeout_bypass,
4116 (void *)&cmd_setbypass_timeout_timeout,
4117 (void *)&cmd_setbypass_timeout_value,
4122 /* *** SHOW NIC BYPASS MODE *** */
4123 struct cmd_show_bypass_config_result {
4124 cmdline_fixed_string_t show;
4125 cmdline_fixed_string_t bypass;
4126 cmdline_fixed_string_t config;
4131 cmd_show_bypass_config_parsed(void *parsed_result,
4132 __attribute__((unused)) struct cmdline *cl,
4133 __attribute__((unused)) void *data)
4135 struct cmd_show_bypass_config_result *res = parsed_result;
4136 uint32_t event_mode;
4137 uint32_t bypass_mode;
4138 portid_t port_id = res->port_id;
4139 uint32_t timeout = bypass_timeout;
4142 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4143 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4144 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4145 {"UNKNOWN", "normal", "bypass", "isolate"};
4146 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4153 int num_events = (sizeof events) / (sizeof events[0]);
4155 /* Display the bypass mode.*/
4156 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4157 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4161 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4162 bypass_mode = RTE_BYPASS_MODE_NONE;
4164 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4167 /* Display the bypass timeout.*/
4168 if (!RTE_BYPASS_TMT_VALID(timeout))
4169 timeout = RTE_BYPASS_TMT_OFF;
4171 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4173 /* Display the bypass events and associated modes. */
4174 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4176 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4177 printf("\tFailed to get bypass mode for event = %s\n",
4180 if (!RTE_BYPASS_MODE_VALID(event_mode))
4181 event_mode = RTE_BYPASS_MODE_NONE;
4183 printf("\tbypass event: %-16s = %s\n", events[i],
4189 cmdline_parse_token_string_t cmd_showbypass_config_show =
4190 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4192 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4193 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4195 cmdline_parse_token_string_t cmd_showbypass_config_config =
4196 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4198 cmdline_parse_token_num_t cmd_showbypass_config_port =
4199 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4202 cmdline_parse_inst_t cmd_show_bypass_config = {
4203 .f = cmd_show_bypass_config_parsed,
4204 .help_str = "show bypass config <port_id>: "
4205 "Show the NIC bypass config for port_id",
4208 (void *)&cmd_showbypass_config_show,
4209 (void *)&cmd_showbypass_config_bypass,
4210 (void *)&cmd_showbypass_config_config,
4211 (void *)&cmd_showbypass_config_port,
4217 #ifdef RTE_LIBRTE_PMD_BOND
4218 /* *** SET BONDING MODE *** */
4219 struct cmd_set_bonding_mode_result {
4220 cmdline_fixed_string_t set;
4221 cmdline_fixed_string_t bonding;
4222 cmdline_fixed_string_t mode;
4227 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4228 __attribute__((unused)) struct cmdline *cl,
4229 __attribute__((unused)) void *data)
4231 struct cmd_set_bonding_mode_result *res = parsed_result;
4232 portid_t port_id = res->port_id;
4234 /* Set the bonding mode for the relevant port. */
4235 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4236 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4239 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4240 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4242 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4243 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4244 bonding, "bonding");
4245 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4246 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4248 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4249 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4251 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4252 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4255 cmdline_parse_inst_t cmd_set_bonding_mode = {
4256 .f = cmd_set_bonding_mode_parsed,
4257 .help_str = "set bonding mode <mode_value> <port_id>: "
4258 "Set the bonding mode for port_id",
4261 (void *) &cmd_setbonding_mode_set,
4262 (void *) &cmd_setbonding_mode_bonding,
4263 (void *) &cmd_setbonding_mode_mode,
4264 (void *) &cmd_setbonding_mode_value,
4265 (void *) &cmd_setbonding_mode_port,
4270 /* *** SET BALANCE XMIT POLICY *** */
4271 struct cmd_set_bonding_balance_xmit_policy_result {
4272 cmdline_fixed_string_t set;
4273 cmdline_fixed_string_t bonding;
4274 cmdline_fixed_string_t balance_xmit_policy;
4276 cmdline_fixed_string_t policy;
4279 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4280 __attribute__((unused)) struct cmdline *cl,
4281 __attribute__((unused)) void *data)
4283 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4284 portid_t port_id = res->port_id;
4287 if (!strcmp(res->policy, "l2")) {
4288 policy = BALANCE_XMIT_POLICY_LAYER2;
4289 } else if (!strcmp(res->policy, "l23")) {
4290 policy = BALANCE_XMIT_POLICY_LAYER23;
4291 } else if (!strcmp(res->policy, "l34")) {
4292 policy = BALANCE_XMIT_POLICY_LAYER34;
4294 printf("\t Invalid xmit policy selection");
4298 /* Set the bonding mode for the relevant port. */
4299 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4300 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4305 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4306 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4308 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4309 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4310 bonding, "bonding");
4311 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4312 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4313 balance_xmit_policy, "balance_xmit_policy");
4314 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4315 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4317 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4318 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4319 policy, "l2#l23#l34");
4321 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4322 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4323 .help_str = "set bonding balance_xmit_policy <port_id> "
4325 "Set the bonding balance_xmit_policy for port_id",
4328 (void *)&cmd_setbonding_balance_xmit_policy_set,
4329 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4330 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4331 (void *)&cmd_setbonding_balance_xmit_policy_port,
4332 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4337 /* *** SHOW NIC BONDING CONFIGURATION *** */
4338 struct cmd_show_bonding_config_result {
4339 cmdline_fixed_string_t show;
4340 cmdline_fixed_string_t bonding;
4341 cmdline_fixed_string_t config;
4345 static void cmd_show_bonding_config_parsed(void *parsed_result,
4346 __attribute__((unused)) struct cmdline *cl,
4347 __attribute__((unused)) void *data)
4349 struct cmd_show_bonding_config_result *res = parsed_result;
4351 uint8_t slaves[RTE_MAX_ETHPORTS];
4352 int num_slaves, num_active_slaves;
4355 portid_t port_id = res->port_id;
4357 /* Display the bonding mode.*/
4358 bonding_mode = rte_eth_bond_mode_get(port_id);
4359 if (bonding_mode < 0) {
4360 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4363 printf("\tBonding mode: %d\n", bonding_mode);
4365 if (bonding_mode == BONDING_MODE_BALANCE) {
4366 int balance_xmit_policy;
4368 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4369 if (balance_xmit_policy < 0) {
4370 printf("\tFailed to get balance xmit policy for port = %d\n",
4374 printf("\tBalance Xmit Policy: ");
4376 switch (balance_xmit_policy) {
4377 case BALANCE_XMIT_POLICY_LAYER2:
4378 printf("BALANCE_XMIT_POLICY_LAYER2");
4380 case BALANCE_XMIT_POLICY_LAYER23:
4381 printf("BALANCE_XMIT_POLICY_LAYER23");
4383 case BALANCE_XMIT_POLICY_LAYER34:
4384 printf("BALANCE_XMIT_POLICY_LAYER34");
4391 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4393 if (num_slaves < 0) {
4394 printf("\tFailed to get slave list for port = %d\n", port_id);
4397 if (num_slaves > 0) {
4398 printf("\tSlaves (%d): [", num_slaves);
4399 for (i = 0; i < num_slaves - 1; i++)
4400 printf("%d ", slaves[i]);
4402 printf("%d]\n", slaves[num_slaves - 1]);
4404 printf("\tSlaves: []\n");
4408 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4411 if (num_active_slaves < 0) {
4412 printf("\tFailed to get active slave list for port = %d\n", port_id);
4415 if (num_active_slaves > 0) {
4416 printf("\tActive Slaves (%d): [", num_active_slaves);
4417 for (i = 0; i < num_active_slaves - 1; i++)
4418 printf("%d ", slaves[i]);
4420 printf("%d]\n", slaves[num_active_slaves - 1]);
4423 printf("\tActive Slaves: []\n");
4427 primary_id = rte_eth_bond_primary_get(port_id);
4428 if (primary_id < 0) {
4429 printf("\tFailed to get primary slave for port = %d\n", port_id);
4432 printf("\tPrimary: [%d]\n", primary_id);
4436 cmdline_parse_token_string_t cmd_showbonding_config_show =
4437 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4439 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4440 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4441 bonding, "bonding");
4442 cmdline_parse_token_string_t cmd_showbonding_config_config =
4443 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4445 cmdline_parse_token_num_t cmd_showbonding_config_port =
4446 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4449 cmdline_parse_inst_t cmd_show_bonding_config = {
4450 .f = cmd_show_bonding_config_parsed,
4451 .help_str = "show bonding config <port_id>: "
4452 "Show the bonding config for port_id",
4455 (void *)&cmd_showbonding_config_show,
4456 (void *)&cmd_showbonding_config_bonding,
4457 (void *)&cmd_showbonding_config_config,
4458 (void *)&cmd_showbonding_config_port,
4463 /* *** SET BONDING PRIMARY *** */
4464 struct cmd_set_bonding_primary_result {
4465 cmdline_fixed_string_t set;
4466 cmdline_fixed_string_t bonding;
4467 cmdline_fixed_string_t primary;
4472 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4473 __attribute__((unused)) struct cmdline *cl,
4474 __attribute__((unused)) void *data)
4476 struct cmd_set_bonding_primary_result *res = parsed_result;
4477 portid_t master_port_id = res->port_id;
4478 portid_t slave_port_id = res->slave_id;
4480 /* Set the primary slave for a bonded device. */
4481 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4482 printf("\t Failed to set primary slave for port = %d.\n",
4489 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4490 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4492 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4493 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4494 bonding, "bonding");
4495 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4496 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4497 primary, "primary");
4498 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4499 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4501 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4502 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4505 cmdline_parse_inst_t cmd_set_bonding_primary = {
4506 .f = cmd_set_bonding_primary_parsed,
4507 .help_str = "set bonding primary <slave_id> <port_id>: "
4508 "Set the primary slave for port_id",
4511 (void *)&cmd_setbonding_primary_set,
4512 (void *)&cmd_setbonding_primary_bonding,
4513 (void *)&cmd_setbonding_primary_primary,
4514 (void *)&cmd_setbonding_primary_slave,
4515 (void *)&cmd_setbonding_primary_port,
4520 /* *** ADD SLAVE *** */
4521 struct cmd_add_bonding_slave_result {
4522 cmdline_fixed_string_t add;
4523 cmdline_fixed_string_t bonding;
4524 cmdline_fixed_string_t slave;
4529 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4530 __attribute__((unused)) struct cmdline *cl,
4531 __attribute__((unused)) void *data)
4533 struct cmd_add_bonding_slave_result *res = parsed_result;
4534 portid_t master_port_id = res->port_id;
4535 portid_t slave_port_id = res->slave_id;
4537 /* Set the primary slave for a bonded device. */
4538 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4539 printf("\t Failed to add slave %d to master port = %d.\n",
4540 slave_port_id, master_port_id);
4544 set_port_slave_flag(slave_port_id);
4547 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4548 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4550 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4551 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4552 bonding, "bonding");
4553 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4554 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4556 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4557 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4559 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4560 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4563 cmdline_parse_inst_t cmd_add_bonding_slave = {
4564 .f = cmd_add_bonding_slave_parsed,
4565 .help_str = "add bonding slave <slave_id> <port_id>: "
4566 "Add a slave device to a bonded device",
4569 (void *)&cmd_addbonding_slave_add,
4570 (void *)&cmd_addbonding_slave_bonding,
4571 (void *)&cmd_addbonding_slave_slave,
4572 (void *)&cmd_addbonding_slave_slaveid,
4573 (void *)&cmd_addbonding_slave_port,
4578 /* *** REMOVE SLAVE *** */
4579 struct cmd_remove_bonding_slave_result {
4580 cmdline_fixed_string_t remove;
4581 cmdline_fixed_string_t bonding;
4582 cmdline_fixed_string_t slave;
4587 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4588 __attribute__((unused)) struct cmdline *cl,
4589 __attribute__((unused)) void *data)
4591 struct cmd_remove_bonding_slave_result *res = parsed_result;
4592 portid_t master_port_id = res->port_id;
4593 portid_t slave_port_id = res->slave_id;
4595 /* Set the primary slave for a bonded device. */
4596 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4597 printf("\t Failed to remove slave %d from master port = %d.\n",
4598 slave_port_id, master_port_id);
4602 clear_port_slave_flag(slave_port_id);
4605 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4606 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4608 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4609 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4610 bonding, "bonding");
4611 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4612 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4614 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4615 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4617 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4618 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4621 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4622 .f = cmd_remove_bonding_slave_parsed,
4623 .help_str = "remove bonding slave <slave_id> <port_id>: "
4624 "Remove a slave device from a bonded device",
4627 (void *)&cmd_removebonding_slave_remove,
4628 (void *)&cmd_removebonding_slave_bonding,
4629 (void *)&cmd_removebonding_slave_slave,
4630 (void *)&cmd_removebonding_slave_slaveid,
4631 (void *)&cmd_removebonding_slave_port,
4636 /* *** CREATE BONDED DEVICE *** */
4637 struct cmd_create_bonded_device_result {
4638 cmdline_fixed_string_t create;
4639 cmdline_fixed_string_t bonded;
4640 cmdline_fixed_string_t device;
4645 static int bond_dev_num = 0;
4647 static void cmd_create_bonded_device_parsed(void *parsed_result,
4648 __attribute__((unused)) struct cmdline *cl,
4649 __attribute__((unused)) void *data)
4651 struct cmd_create_bonded_device_result *res = parsed_result;
4652 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4655 if (test_done == 0) {
4656 printf("Please stop forwarding first\n");
4660 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4663 /* Create a new bonded device. */
4664 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4666 printf("\t Failed to create bonded device.\n");
4669 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4672 /* Update number of ports */
4673 nb_ports = rte_eth_dev_count();
4674 reconfig(port_id, res->socket);
4675 rte_eth_promiscuous_enable(port_id);
4676 ports[port_id].enabled = 1;
4681 cmdline_parse_token_string_t cmd_createbonded_device_create =
4682 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4684 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4685 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4687 cmdline_parse_token_string_t cmd_createbonded_device_device =
4688 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4690 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4691 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4693 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4694 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4697 cmdline_parse_inst_t cmd_create_bonded_device = {
4698 .f = cmd_create_bonded_device_parsed,
4699 .help_str = "create bonded device <mode> <socket>: "
4700 "Create a new bonded device with specific bonding mode and socket",
4703 (void *)&cmd_createbonded_device_create,
4704 (void *)&cmd_createbonded_device_bonded,
4705 (void *)&cmd_createbonded_device_device,
4706 (void *)&cmd_createbonded_device_mode,
4707 (void *)&cmd_createbonded_device_socket,
4712 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4713 struct cmd_set_bond_mac_addr_result {
4714 cmdline_fixed_string_t set;
4715 cmdline_fixed_string_t bonding;
4716 cmdline_fixed_string_t mac_addr;
4718 struct ether_addr address;
4721 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4722 __attribute__((unused)) struct cmdline *cl,
4723 __attribute__((unused)) void *data)
4725 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4728 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4731 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4733 /* check the return value and print it if is < 0 */
4735 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4738 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4739 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4740 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4741 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4743 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4744 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4746 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4747 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4748 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4749 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4751 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4752 .f = cmd_set_bond_mac_addr_parsed,
4754 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4756 (void *)&cmd_set_bond_mac_addr_set,
4757 (void *)&cmd_set_bond_mac_addr_bonding,
4758 (void *)&cmd_set_bond_mac_addr_mac,
4759 (void *)&cmd_set_bond_mac_addr_portnum,
4760 (void *)&cmd_set_bond_mac_addr_addr,
4766 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4767 struct cmd_set_bond_mon_period_result {
4768 cmdline_fixed_string_t set;
4769 cmdline_fixed_string_t bonding;
4770 cmdline_fixed_string_t mon_period;
4775 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4776 __attribute__((unused)) struct cmdline *cl,
4777 __attribute__((unused)) void *data)
4779 struct cmd_set_bond_mon_period_result *res = parsed_result;
4782 if (res->port_num >= nb_ports) {
4783 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4787 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4789 /* check the return value and print it if is < 0 */
4791 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4794 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4795 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4797 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4798 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4799 bonding, "bonding");
4800 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4801 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4802 mon_period, "mon_period");
4803 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4804 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4806 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4807 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4810 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4811 .f = cmd_set_bond_mon_period_parsed,
4813 .help_str = "set bonding mon_period <port_id> <period_ms>",
4815 (void *)&cmd_set_bond_mon_period_set,
4816 (void *)&cmd_set_bond_mon_period_bonding,
4817 (void *)&cmd_set_bond_mon_period_mon_period,
4818 (void *)&cmd_set_bond_mon_period_portnum,
4819 (void *)&cmd_set_bond_mon_period_period_ms,
4824 #endif /* RTE_LIBRTE_PMD_BOND */
4826 /* *** SET FORWARDING MODE *** */
4827 struct cmd_set_fwd_mode_result {
4828 cmdline_fixed_string_t set;
4829 cmdline_fixed_string_t fwd;
4830 cmdline_fixed_string_t mode;
4833 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4834 __attribute__((unused)) struct cmdline *cl,
4835 __attribute__((unused)) void *data)
4837 struct cmd_set_fwd_mode_result *res = parsed_result;
4840 set_pkt_forwarding_mode(res->mode);
4843 cmdline_parse_token_string_t cmd_setfwd_set =
4844 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4845 cmdline_parse_token_string_t cmd_setfwd_fwd =
4846 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4847 cmdline_parse_token_string_t cmd_setfwd_mode =
4848 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4849 "" /* defined at init */);
4851 cmdline_parse_inst_t cmd_set_fwd_mode = {
4852 .f = cmd_set_fwd_mode_parsed,
4854 .help_str = NULL, /* defined at init */
4856 (void *)&cmd_setfwd_set,
4857 (void *)&cmd_setfwd_fwd,
4858 (void *)&cmd_setfwd_mode,
4863 static void cmd_set_fwd_mode_init(void)
4866 static char token[128];
4867 static char help[256];
4868 cmdline_parse_token_string_t *token_struct;
4870 modes = list_pkt_forwarding_modes();
4871 snprintf(help, sizeof(help), "set fwd %s: "
4872 "Set packet forwarding mode", modes);
4873 cmd_set_fwd_mode.help_str = help;
4875 /* string token separator is # */
4876 for (c = token; *modes != '\0'; modes++)
4881 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4882 token_struct->string_data.str = token;
4885 /* *** SET RETRY FORWARDING MODE *** */
4886 struct cmd_set_fwd_retry_mode_result {
4887 cmdline_fixed_string_t set;
4888 cmdline_fixed_string_t fwd;
4889 cmdline_fixed_string_t mode;
4890 cmdline_fixed_string_t retry;
4893 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4894 __attribute__((unused)) struct cmdline *cl,
4895 __attribute__((unused)) void *data)
4897 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4900 set_pkt_forwarding_mode(res->mode);
4903 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4904 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4906 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4907 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4909 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4910 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4912 "" /* defined at init */);
4913 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4914 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4917 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4918 .f = cmd_set_fwd_retry_mode_parsed,
4920 .help_str = NULL, /* defined at init */
4922 (void *)&cmd_setfwd_retry_set,
4923 (void *)&cmd_setfwd_retry_fwd,
4924 (void *)&cmd_setfwd_retry_mode,
4925 (void *)&cmd_setfwd_retry_retry,
4930 static void cmd_set_fwd_retry_mode_init(void)
4933 static char token[128];
4934 static char help[256];
4935 cmdline_parse_token_string_t *token_struct;
4937 modes = list_pkt_forwarding_retry_modes();
4938 snprintf(help, sizeof(help), "set fwd %s retry: "
4939 "Set packet forwarding mode with retry", modes);
4940 cmd_set_fwd_retry_mode.help_str = help;
4942 /* string token separator is # */
4943 for (c = token; *modes != '\0'; modes++)
4948 token_struct = (cmdline_parse_token_string_t *)
4949 cmd_set_fwd_retry_mode.tokens[2];
4950 token_struct->string_data.str = token;
4953 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4954 struct cmd_set_burst_tx_retry_result {
4955 cmdline_fixed_string_t set;
4956 cmdline_fixed_string_t burst;
4957 cmdline_fixed_string_t tx;
4958 cmdline_fixed_string_t delay;
4960 cmdline_fixed_string_t retry;
4964 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4965 __attribute__((unused)) struct cmdline *cl,
4966 __attribute__((unused)) void *data)
4968 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4970 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4971 && !strcmp(res->tx, "tx")) {
4972 if (!strcmp(res->delay, "delay"))
4973 burst_tx_delay_time = res->time;
4974 if (!strcmp(res->retry, "retry"))
4975 burst_tx_retry_num = res->retry_num;
4980 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4981 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4982 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4983 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4985 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4986 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4987 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4988 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4989 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4990 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4991 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4992 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4993 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4994 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4996 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4997 .f = cmd_set_burst_tx_retry_parsed,
4998 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5000 (void *)&cmd_set_burst_tx_retry_set,
5001 (void *)&cmd_set_burst_tx_retry_burst,
5002 (void *)&cmd_set_burst_tx_retry_tx,
5003 (void *)&cmd_set_burst_tx_retry_delay,
5004 (void *)&cmd_set_burst_tx_retry_time,
5005 (void *)&cmd_set_burst_tx_retry_retry,
5006 (void *)&cmd_set_burst_tx_retry_retry_num,
5011 /* *** SET PROMISC MODE *** */
5012 struct cmd_set_promisc_mode_result {
5013 cmdline_fixed_string_t set;
5014 cmdline_fixed_string_t promisc;
5015 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5016 uint8_t port_num; /* valid if "allports" argument == 0 */
5017 cmdline_fixed_string_t mode;
5020 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5021 __attribute__((unused)) struct cmdline *cl,
5024 struct cmd_set_promisc_mode_result *res = parsed_result;
5028 if (!strcmp(res->mode, "on"))
5035 FOREACH_PORT(i, ports) {
5037 rte_eth_promiscuous_enable(i);
5039 rte_eth_promiscuous_disable(i);
5044 rte_eth_promiscuous_enable(res->port_num);
5046 rte_eth_promiscuous_disable(res->port_num);
5050 cmdline_parse_token_string_t cmd_setpromisc_set =
5051 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5052 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5053 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5055 cmdline_parse_token_string_t cmd_setpromisc_portall =
5056 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5058 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5059 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5061 cmdline_parse_token_string_t cmd_setpromisc_mode =
5062 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5065 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5066 .f = cmd_set_promisc_mode_parsed,
5068 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5070 (void *)&cmd_setpromisc_set,
5071 (void *)&cmd_setpromisc_promisc,
5072 (void *)&cmd_setpromisc_portall,
5073 (void *)&cmd_setpromisc_mode,
5078 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5079 .f = cmd_set_promisc_mode_parsed,
5081 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5083 (void *)&cmd_setpromisc_set,
5084 (void *)&cmd_setpromisc_promisc,
5085 (void *)&cmd_setpromisc_portnum,
5086 (void *)&cmd_setpromisc_mode,
5091 /* *** SET ALLMULTI MODE *** */
5092 struct cmd_set_allmulti_mode_result {
5093 cmdline_fixed_string_t set;
5094 cmdline_fixed_string_t allmulti;
5095 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5096 uint8_t port_num; /* valid if "allports" argument == 0 */
5097 cmdline_fixed_string_t mode;
5100 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5101 __attribute__((unused)) struct cmdline *cl,
5104 struct cmd_set_allmulti_mode_result *res = parsed_result;
5108 if (!strcmp(res->mode, "on"))
5115 FOREACH_PORT(i, ports) {
5117 rte_eth_allmulticast_enable(i);
5119 rte_eth_allmulticast_disable(i);
5124 rte_eth_allmulticast_enable(res->port_num);
5126 rte_eth_allmulticast_disable(res->port_num);
5130 cmdline_parse_token_string_t cmd_setallmulti_set =
5131 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5132 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5133 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5135 cmdline_parse_token_string_t cmd_setallmulti_portall =
5136 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5138 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5139 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5141 cmdline_parse_token_string_t cmd_setallmulti_mode =
5142 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5145 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5146 .f = cmd_set_allmulti_mode_parsed,
5148 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5150 (void *)&cmd_setallmulti_set,
5151 (void *)&cmd_setallmulti_allmulti,
5152 (void *)&cmd_setallmulti_portall,
5153 (void *)&cmd_setallmulti_mode,
5158 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5159 .f = cmd_set_allmulti_mode_parsed,
5161 .help_str = "set allmulti <port_id> on|off: "
5162 "Set allmulti mode on port_id",
5164 (void *)&cmd_setallmulti_set,
5165 (void *)&cmd_setallmulti_allmulti,
5166 (void *)&cmd_setallmulti_portnum,
5167 (void *)&cmd_setallmulti_mode,
5172 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5173 struct cmd_link_flow_ctrl_set_result {
5174 cmdline_fixed_string_t set;
5175 cmdline_fixed_string_t flow_ctrl;
5176 cmdline_fixed_string_t rx;
5177 cmdline_fixed_string_t rx_lfc_mode;
5178 cmdline_fixed_string_t tx;
5179 cmdline_fixed_string_t tx_lfc_mode;
5180 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5181 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5182 cmdline_fixed_string_t autoneg_str;
5183 cmdline_fixed_string_t autoneg;
5184 cmdline_fixed_string_t hw_str;
5185 uint32_t high_water;
5186 cmdline_fixed_string_t lw_str;
5188 cmdline_fixed_string_t pt_str;
5189 uint16_t pause_time;
5190 cmdline_fixed_string_t xon_str;
5195 cmdline_parse_token_string_t cmd_lfc_set_set =
5196 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5198 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5199 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5200 flow_ctrl, "flow_ctrl");
5201 cmdline_parse_token_string_t cmd_lfc_set_rx =
5202 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5205 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5206 rx_lfc_mode, "on#off");
5207 cmdline_parse_token_string_t cmd_lfc_set_tx =
5208 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5210 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5211 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5212 tx_lfc_mode, "on#off");
5213 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5214 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5215 hw_str, "high_water");
5216 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5217 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5218 high_water, UINT32);
5219 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5220 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5221 lw_str, "low_water");
5222 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5223 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5225 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5226 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5227 pt_str, "pause_time");
5228 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5229 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5230 pause_time, UINT16);
5231 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5232 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5233 xon_str, "send_xon");
5234 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5235 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5237 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5238 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5239 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5240 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5241 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5242 mac_ctrl_frame_fwd_mode, "on#off");
5243 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5244 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5245 autoneg_str, "autoneg");
5246 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5247 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5249 cmdline_parse_token_num_t cmd_lfc_set_portid =
5250 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5253 /* forward declaration */
5255 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5258 cmdline_parse_inst_t cmd_link_flow_control_set = {
5259 .f = cmd_link_flow_ctrl_set_parsed,
5261 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5262 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5263 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5265 (void *)&cmd_lfc_set_set,
5266 (void *)&cmd_lfc_set_flow_ctrl,
5267 (void *)&cmd_lfc_set_rx,
5268 (void *)&cmd_lfc_set_rx_mode,
5269 (void *)&cmd_lfc_set_tx,
5270 (void *)&cmd_lfc_set_tx_mode,
5271 (void *)&cmd_lfc_set_high_water,
5272 (void *)&cmd_lfc_set_low_water,
5273 (void *)&cmd_lfc_set_pause_time,
5274 (void *)&cmd_lfc_set_send_xon,
5275 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5276 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5277 (void *)&cmd_lfc_set_autoneg_str,
5278 (void *)&cmd_lfc_set_autoneg,
5279 (void *)&cmd_lfc_set_portid,
5284 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5285 .f = cmd_link_flow_ctrl_set_parsed,
5286 .data = (void *)&cmd_link_flow_control_set_rx,
5287 .help_str = "set flow_ctrl rx on|off <port_id>: "
5288 "Change rx flow control parameter",
5290 (void *)&cmd_lfc_set_set,
5291 (void *)&cmd_lfc_set_flow_ctrl,
5292 (void *)&cmd_lfc_set_rx,
5293 (void *)&cmd_lfc_set_rx_mode,
5294 (void *)&cmd_lfc_set_portid,
5299 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5300 .f = cmd_link_flow_ctrl_set_parsed,
5301 .data = (void *)&cmd_link_flow_control_set_tx,
5302 .help_str = "set flow_ctrl tx on|off <port_id>: "
5303 "Change tx flow control parameter",
5305 (void *)&cmd_lfc_set_set,
5306 (void *)&cmd_lfc_set_flow_ctrl,
5307 (void *)&cmd_lfc_set_tx,
5308 (void *)&cmd_lfc_set_tx_mode,
5309 (void *)&cmd_lfc_set_portid,
5314 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5315 .f = cmd_link_flow_ctrl_set_parsed,
5316 .data = (void *)&cmd_link_flow_control_set_hw,
5317 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5318 "Change high water flow control parameter",
5320 (void *)&cmd_lfc_set_set,
5321 (void *)&cmd_lfc_set_flow_ctrl,
5322 (void *)&cmd_lfc_set_high_water_str,
5323 (void *)&cmd_lfc_set_high_water,
5324 (void *)&cmd_lfc_set_portid,
5329 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5330 .f = cmd_link_flow_ctrl_set_parsed,
5331 .data = (void *)&cmd_link_flow_control_set_lw,
5332 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5333 "Change low water flow control parameter",
5335 (void *)&cmd_lfc_set_set,
5336 (void *)&cmd_lfc_set_flow_ctrl,
5337 (void *)&cmd_lfc_set_low_water_str,
5338 (void *)&cmd_lfc_set_low_water,
5339 (void *)&cmd_lfc_set_portid,
5344 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5345 .f = cmd_link_flow_ctrl_set_parsed,
5346 .data = (void *)&cmd_link_flow_control_set_pt,
5347 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5348 "Change pause time flow control parameter",
5350 (void *)&cmd_lfc_set_set,
5351 (void *)&cmd_lfc_set_flow_ctrl,
5352 (void *)&cmd_lfc_set_pause_time_str,
5353 (void *)&cmd_lfc_set_pause_time,
5354 (void *)&cmd_lfc_set_portid,
5359 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5360 .f = cmd_link_flow_ctrl_set_parsed,
5361 .data = (void *)&cmd_link_flow_control_set_xon,
5362 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5363 "Change send_xon flow control parameter",
5365 (void *)&cmd_lfc_set_set,
5366 (void *)&cmd_lfc_set_flow_ctrl,
5367 (void *)&cmd_lfc_set_send_xon_str,
5368 (void *)&cmd_lfc_set_send_xon,
5369 (void *)&cmd_lfc_set_portid,
5374 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5375 .f = cmd_link_flow_ctrl_set_parsed,
5376 .data = (void *)&cmd_link_flow_control_set_macfwd,
5377 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5378 "Change mac ctrl fwd flow control parameter",
5380 (void *)&cmd_lfc_set_set,
5381 (void *)&cmd_lfc_set_flow_ctrl,
5382 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5383 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5384 (void *)&cmd_lfc_set_portid,
5389 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5390 .f = cmd_link_flow_ctrl_set_parsed,
5391 .data = (void *)&cmd_link_flow_control_set_autoneg,
5392 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5393 "Change autoneg flow control parameter",
5395 (void *)&cmd_lfc_set_set,
5396 (void *)&cmd_lfc_set_flow_ctrl,
5397 (void *)&cmd_lfc_set_autoneg_str,
5398 (void *)&cmd_lfc_set_autoneg,
5399 (void *)&cmd_lfc_set_portid,
5405 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5406 __attribute__((unused)) struct cmdline *cl,
5409 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5410 cmdline_parse_inst_t *cmd = data;
5411 struct rte_eth_fc_conf fc_conf;
5417 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5418 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5419 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5420 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5422 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5423 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5426 /* Partial command line, retrieve current configuration */
5428 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5430 printf("cannot get current flow ctrl parameters, return"
5431 "code = %d\n", ret);
5435 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5436 (fc_conf.mode == RTE_FC_FULL))
5438 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5439 (fc_conf.mode == RTE_FC_FULL))
5443 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5444 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5446 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5447 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5449 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5451 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5452 fc_conf.high_water = res->high_water;
5454 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5455 fc_conf.low_water = res->low_water;
5457 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5458 fc_conf.pause_time = res->pause_time;
5460 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5461 fc_conf.send_xon = res->send_xon;
5463 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5464 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5465 fc_conf.mac_ctrl_frame_fwd = 1;
5467 fc_conf.mac_ctrl_frame_fwd = 0;
5470 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5471 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5473 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5475 printf("bad flow contrl parameter, return code = %d \n", ret);
5478 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5479 struct cmd_priority_flow_ctrl_set_result {
5480 cmdline_fixed_string_t set;
5481 cmdline_fixed_string_t pfc_ctrl;
5482 cmdline_fixed_string_t rx;
5483 cmdline_fixed_string_t rx_pfc_mode;
5484 cmdline_fixed_string_t tx;
5485 cmdline_fixed_string_t tx_pfc_mode;
5486 uint32_t high_water;
5488 uint16_t pause_time;
5494 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5495 __attribute__((unused)) struct cmdline *cl,
5496 __attribute__((unused)) void *data)
5498 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5499 struct rte_eth_pfc_conf pfc_conf;
5500 int rx_fc_enable, tx_fc_enable;
5504 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5505 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5506 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5507 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5509 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5510 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5513 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5514 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5515 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5516 pfc_conf.fc.high_water = res->high_water;
5517 pfc_conf.fc.low_water = res->low_water;
5518 pfc_conf.fc.pause_time = res->pause_time;
5519 pfc_conf.priority = res->priority;
5521 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5523 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5526 cmdline_parse_token_string_t cmd_pfc_set_set =
5527 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5529 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5530 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5531 pfc_ctrl, "pfc_ctrl");
5532 cmdline_parse_token_string_t cmd_pfc_set_rx =
5533 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5535 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5536 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5537 rx_pfc_mode, "on#off");
5538 cmdline_parse_token_string_t cmd_pfc_set_tx =
5539 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5541 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5542 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5543 tx_pfc_mode, "on#off");
5544 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5545 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5546 high_water, UINT32);
5547 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5548 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5550 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5551 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5552 pause_time, UINT16);
5553 cmdline_parse_token_num_t cmd_pfc_set_priority =
5554 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5556 cmdline_parse_token_num_t cmd_pfc_set_portid =
5557 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5560 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5561 .f = cmd_priority_flow_ctrl_set_parsed,
5563 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5564 "<pause_time> <priority> <port_id>: "
5565 "Configure the Ethernet priority flow control",
5567 (void *)&cmd_pfc_set_set,
5568 (void *)&cmd_pfc_set_flow_ctrl,
5569 (void *)&cmd_pfc_set_rx,
5570 (void *)&cmd_pfc_set_rx_mode,
5571 (void *)&cmd_pfc_set_tx,
5572 (void *)&cmd_pfc_set_tx_mode,
5573 (void *)&cmd_pfc_set_high_water,
5574 (void *)&cmd_pfc_set_low_water,
5575 (void *)&cmd_pfc_set_pause_time,
5576 (void *)&cmd_pfc_set_priority,
5577 (void *)&cmd_pfc_set_portid,
5582 /* *** RESET CONFIGURATION *** */
5583 struct cmd_reset_result {
5584 cmdline_fixed_string_t reset;
5585 cmdline_fixed_string_t def;
5588 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5590 __attribute__((unused)) void *data)
5592 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5593 set_def_fwd_config();
5596 cmdline_parse_token_string_t cmd_reset_set =
5597 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5598 cmdline_parse_token_string_t cmd_reset_def =
5599 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5602 cmdline_parse_inst_t cmd_reset = {
5603 .f = cmd_reset_parsed,
5605 .help_str = "set default: Reset default forwarding configuration",
5607 (void *)&cmd_reset_set,
5608 (void *)&cmd_reset_def,
5613 /* *** START FORWARDING *** */
5614 struct cmd_start_result {
5615 cmdline_fixed_string_t start;
5618 cmdline_parse_token_string_t cmd_start_start =
5619 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5621 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5622 __attribute__((unused)) struct cmdline *cl,
5623 __attribute__((unused)) void *data)
5625 start_packet_forwarding(0);
5628 cmdline_parse_inst_t cmd_start = {
5629 .f = cmd_start_parsed,
5631 .help_str = "start: Start packet forwarding",
5633 (void *)&cmd_start_start,
5638 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5639 struct cmd_start_tx_first_result {
5640 cmdline_fixed_string_t start;
5641 cmdline_fixed_string_t tx_first;
5645 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5646 __attribute__((unused)) struct cmdline *cl,
5647 __attribute__((unused)) void *data)
5649 start_packet_forwarding(1);
5652 cmdline_parse_token_string_t cmd_start_tx_first_start =
5653 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5655 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5656 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5657 tx_first, "tx_first");
5659 cmdline_parse_inst_t cmd_start_tx_first = {
5660 .f = cmd_start_tx_first_parsed,
5662 .help_str = "start tx_first: Start packet forwarding, "
5663 "after sending 1 burst of packets",
5665 (void *)&cmd_start_tx_first_start,
5666 (void *)&cmd_start_tx_first_tx_first,
5671 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5672 struct cmd_start_tx_first_n_result {
5673 cmdline_fixed_string_t start;
5674 cmdline_fixed_string_t tx_first;
5679 cmd_start_tx_first_n_parsed(void *parsed_result,
5680 __attribute__((unused)) struct cmdline *cl,
5681 __attribute__((unused)) void *data)
5683 struct cmd_start_tx_first_n_result *res = parsed_result;
5685 start_packet_forwarding(res->tx_num);
5688 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5689 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5691 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5692 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5693 tx_first, "tx_first");
5694 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5695 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5698 cmdline_parse_inst_t cmd_start_tx_first_n = {
5699 .f = cmd_start_tx_first_n_parsed,
5701 .help_str = "start tx_first <num>: "
5702 "packet forwarding, after sending <num> bursts of packets",
5704 (void *)&cmd_start_tx_first_n_start,
5705 (void *)&cmd_start_tx_first_n_tx_first,
5706 (void *)&cmd_start_tx_first_n_tx_num,
5711 /* *** SET LINK UP *** */
5712 struct cmd_set_link_up_result {
5713 cmdline_fixed_string_t set;
5714 cmdline_fixed_string_t link_up;
5715 cmdline_fixed_string_t port;
5719 cmdline_parse_token_string_t cmd_set_link_up_set =
5720 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5721 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5722 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5724 cmdline_parse_token_string_t cmd_set_link_up_port =
5725 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5726 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5727 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5729 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5730 __attribute__((unused)) struct cmdline *cl,
5731 __attribute__((unused)) void *data)
5733 struct cmd_set_link_up_result *res = parsed_result;
5734 dev_set_link_up(res->port_id);
5737 cmdline_parse_inst_t cmd_set_link_up = {
5738 .f = cmd_set_link_up_parsed,
5740 .help_str = "set link-up port <port id>",
5742 (void *)&cmd_set_link_up_set,
5743 (void *)&cmd_set_link_up_link_up,
5744 (void *)&cmd_set_link_up_port,
5745 (void *)&cmd_set_link_up_port_id,
5750 /* *** SET LINK DOWN *** */
5751 struct cmd_set_link_down_result {
5752 cmdline_fixed_string_t set;
5753 cmdline_fixed_string_t link_down;
5754 cmdline_fixed_string_t port;
5758 cmdline_parse_token_string_t cmd_set_link_down_set =
5759 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5760 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5763 cmdline_parse_token_string_t cmd_set_link_down_port =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5765 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5766 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5768 static void cmd_set_link_down_parsed(
5769 __attribute__((unused)) void *parsed_result,
5770 __attribute__((unused)) struct cmdline *cl,
5771 __attribute__((unused)) void *data)
5773 struct cmd_set_link_down_result *res = parsed_result;
5774 dev_set_link_down(res->port_id);
5777 cmdline_parse_inst_t cmd_set_link_down = {
5778 .f = cmd_set_link_down_parsed,
5780 .help_str = "set link-down port <port id>",
5782 (void *)&cmd_set_link_down_set,
5783 (void *)&cmd_set_link_down_link_down,
5784 (void *)&cmd_set_link_down_port,
5785 (void *)&cmd_set_link_down_port_id,
5790 /* *** SHOW CFG *** */
5791 struct cmd_showcfg_result {
5792 cmdline_fixed_string_t show;
5793 cmdline_fixed_string_t cfg;
5794 cmdline_fixed_string_t what;
5797 static void cmd_showcfg_parsed(void *parsed_result,
5798 __attribute__((unused)) struct cmdline *cl,
5799 __attribute__((unused)) void *data)
5801 struct cmd_showcfg_result *res = parsed_result;
5802 if (!strcmp(res->what, "rxtx"))
5803 rxtx_config_display();
5804 else if (!strcmp(res->what, "cores"))
5805 fwd_lcores_config_display();
5806 else if (!strcmp(res->what, "fwd"))
5807 pkt_fwd_config_display(&cur_fwd_config);
5808 else if (!strcmp(res->what, "txpkts"))
5809 show_tx_pkt_segments();
5812 cmdline_parse_token_string_t cmd_showcfg_show =
5813 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5814 cmdline_parse_token_string_t cmd_showcfg_port =
5815 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5816 cmdline_parse_token_string_t cmd_showcfg_what =
5817 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5818 "rxtx#cores#fwd#txpkts");
5820 cmdline_parse_inst_t cmd_showcfg = {
5821 .f = cmd_showcfg_parsed,
5823 .help_str = "show config rxtx|cores|fwd|txpkts",
5825 (void *)&cmd_showcfg_show,
5826 (void *)&cmd_showcfg_port,
5827 (void *)&cmd_showcfg_what,
5832 /* *** SHOW ALL PORT INFO *** */
5833 struct cmd_showportall_result {
5834 cmdline_fixed_string_t show;
5835 cmdline_fixed_string_t port;
5836 cmdline_fixed_string_t what;
5837 cmdline_fixed_string_t all;
5840 static void cmd_showportall_parsed(void *parsed_result,
5841 __attribute__((unused)) struct cmdline *cl,
5842 __attribute__((unused)) void *data)
5846 struct cmd_showportall_result *res = parsed_result;
5847 if (!strcmp(res->show, "clear")) {
5848 if (!strcmp(res->what, "stats"))
5849 FOREACH_PORT(i, ports)
5851 else if (!strcmp(res->what, "xstats"))
5852 FOREACH_PORT(i, ports)
5853 nic_xstats_clear(i);
5854 } else if (!strcmp(res->what, "info"))
5855 FOREACH_PORT(i, ports)
5856 port_infos_display(i);
5857 else if (!strcmp(res->what, "stats"))
5858 FOREACH_PORT(i, ports)
5859 nic_stats_display(i);
5860 else if (!strcmp(res->what, "xstats"))
5861 FOREACH_PORT(i, ports)
5862 nic_xstats_display(i);
5863 else if (!strcmp(res->what, "fdir"))
5864 FOREACH_PORT(i, ports)
5866 else if (!strcmp(res->what, "stat_qmap"))
5867 FOREACH_PORT(i, ports)
5868 nic_stats_mapping_display(i);
5869 else if (!strcmp(res->what, "dcb_tc"))
5870 FOREACH_PORT(i, ports)
5871 port_dcb_info_display(i);
5872 else if (!strcmp(res->what, "cap"))
5873 FOREACH_PORT(i, ports)
5874 port_offload_cap_display(i);
5877 cmdline_parse_token_string_t cmd_showportall_show =
5878 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5880 cmdline_parse_token_string_t cmd_showportall_port =
5881 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5882 cmdline_parse_token_string_t cmd_showportall_what =
5883 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5884 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5885 cmdline_parse_token_string_t cmd_showportall_all =
5886 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5887 cmdline_parse_inst_t cmd_showportall = {
5888 .f = cmd_showportall_parsed,
5890 .help_str = "show|clear port "
5891 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5893 (void *)&cmd_showportall_show,
5894 (void *)&cmd_showportall_port,
5895 (void *)&cmd_showportall_what,
5896 (void *)&cmd_showportall_all,
5901 /* *** SHOW PORT INFO *** */
5902 struct cmd_showport_result {
5903 cmdline_fixed_string_t show;
5904 cmdline_fixed_string_t port;
5905 cmdline_fixed_string_t what;
5909 static void cmd_showport_parsed(void *parsed_result,
5910 __attribute__((unused)) struct cmdline *cl,
5911 __attribute__((unused)) void *data)
5913 struct cmd_showport_result *res = parsed_result;
5914 if (!strcmp(res->show, "clear")) {
5915 if (!strcmp(res->what, "stats"))
5916 nic_stats_clear(res->portnum);
5917 else if (!strcmp(res->what, "xstats"))
5918 nic_xstats_clear(res->portnum);
5919 } else if (!strcmp(res->what, "info"))
5920 port_infos_display(res->portnum);
5921 else if (!strcmp(res->what, "stats"))
5922 nic_stats_display(res->portnum);
5923 else if (!strcmp(res->what, "xstats"))
5924 nic_xstats_display(res->portnum);
5925 else if (!strcmp(res->what, "fdir"))
5926 fdir_get_infos(res->portnum);
5927 else if (!strcmp(res->what, "stat_qmap"))
5928 nic_stats_mapping_display(res->portnum);
5929 else if (!strcmp(res->what, "dcb_tc"))
5930 port_dcb_info_display(res->portnum);
5931 else if (!strcmp(res->what, "cap"))
5932 port_offload_cap_display(res->portnum);
5935 cmdline_parse_token_string_t cmd_showport_show =
5936 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5938 cmdline_parse_token_string_t cmd_showport_port =
5939 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5940 cmdline_parse_token_string_t cmd_showport_what =
5941 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5942 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5943 cmdline_parse_token_num_t cmd_showport_portnum =
5944 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5946 cmdline_parse_inst_t cmd_showport = {
5947 .f = cmd_showport_parsed,
5949 .help_str = "show|clear port "
5950 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5953 (void *)&cmd_showport_show,
5954 (void *)&cmd_showport_port,
5955 (void *)&cmd_showport_what,
5956 (void *)&cmd_showport_portnum,
5961 /* *** SHOW QUEUE INFO *** */
5962 struct cmd_showqueue_result {
5963 cmdline_fixed_string_t show;
5964 cmdline_fixed_string_t type;
5965 cmdline_fixed_string_t what;
5971 cmd_showqueue_parsed(void *parsed_result,
5972 __attribute__((unused)) struct cmdline *cl,
5973 __attribute__((unused)) void *data)
5975 struct cmd_showqueue_result *res = parsed_result;
5977 if (!strcmp(res->type, "rxq"))
5978 rx_queue_infos_display(res->portnum, res->queuenum);
5979 else if (!strcmp(res->type, "txq"))
5980 tx_queue_infos_display(res->portnum, res->queuenum);
5983 cmdline_parse_token_string_t cmd_showqueue_show =
5984 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5985 cmdline_parse_token_string_t cmd_showqueue_type =
5986 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5987 cmdline_parse_token_string_t cmd_showqueue_what =
5988 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5989 cmdline_parse_token_num_t cmd_showqueue_portnum =
5990 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5991 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5992 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5994 cmdline_parse_inst_t cmd_showqueue = {
5995 .f = cmd_showqueue_parsed,
5997 .help_str = "show rxq|txq info <port_id> <queue_id>",
5999 (void *)&cmd_showqueue_show,
6000 (void *)&cmd_showqueue_type,
6001 (void *)&cmd_showqueue_what,
6002 (void *)&cmd_showqueue_portnum,
6003 (void *)&cmd_showqueue_queuenum,
6008 /* *** READ PORT REGISTER *** */
6009 struct cmd_read_reg_result {
6010 cmdline_fixed_string_t read;
6011 cmdline_fixed_string_t reg;
6017 cmd_read_reg_parsed(void *parsed_result,
6018 __attribute__((unused)) struct cmdline *cl,
6019 __attribute__((unused)) void *data)
6021 struct cmd_read_reg_result *res = parsed_result;
6022 port_reg_display(res->port_id, res->reg_off);
6025 cmdline_parse_token_string_t cmd_read_reg_read =
6026 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6027 cmdline_parse_token_string_t cmd_read_reg_reg =
6028 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6029 cmdline_parse_token_num_t cmd_read_reg_port_id =
6030 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6031 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6032 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6034 cmdline_parse_inst_t cmd_read_reg = {
6035 .f = cmd_read_reg_parsed,
6037 .help_str = "read reg <port_id> <reg_off>",
6039 (void *)&cmd_read_reg_read,
6040 (void *)&cmd_read_reg_reg,
6041 (void *)&cmd_read_reg_port_id,
6042 (void *)&cmd_read_reg_reg_off,
6047 /* *** READ PORT REGISTER BIT FIELD *** */
6048 struct cmd_read_reg_bit_field_result {
6049 cmdline_fixed_string_t read;
6050 cmdline_fixed_string_t regfield;
6058 cmd_read_reg_bit_field_parsed(void *parsed_result,
6059 __attribute__((unused)) struct cmdline *cl,
6060 __attribute__((unused)) void *data)
6062 struct cmd_read_reg_bit_field_result *res = parsed_result;
6063 port_reg_bit_field_display(res->port_id, res->reg_off,
6064 res->bit1_pos, res->bit2_pos);
6067 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6068 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6070 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6071 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6072 regfield, "regfield");
6073 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6074 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6076 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6077 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6079 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6080 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6082 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6083 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6086 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6087 .f = cmd_read_reg_bit_field_parsed,
6089 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6090 "Read register bit field between bit_x and bit_y included",
6092 (void *)&cmd_read_reg_bit_field_read,
6093 (void *)&cmd_read_reg_bit_field_regfield,
6094 (void *)&cmd_read_reg_bit_field_port_id,
6095 (void *)&cmd_read_reg_bit_field_reg_off,
6096 (void *)&cmd_read_reg_bit_field_bit1_pos,
6097 (void *)&cmd_read_reg_bit_field_bit2_pos,
6102 /* *** READ PORT REGISTER BIT *** */
6103 struct cmd_read_reg_bit_result {
6104 cmdline_fixed_string_t read;
6105 cmdline_fixed_string_t regbit;
6112 cmd_read_reg_bit_parsed(void *parsed_result,
6113 __attribute__((unused)) struct cmdline *cl,
6114 __attribute__((unused)) void *data)
6116 struct cmd_read_reg_bit_result *res = parsed_result;
6117 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6120 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6121 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6122 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6123 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6125 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6126 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6127 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6128 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6129 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6130 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6132 cmdline_parse_inst_t cmd_read_reg_bit = {
6133 .f = cmd_read_reg_bit_parsed,
6135 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6137 (void *)&cmd_read_reg_bit_read,
6138 (void *)&cmd_read_reg_bit_regbit,
6139 (void *)&cmd_read_reg_bit_port_id,
6140 (void *)&cmd_read_reg_bit_reg_off,
6141 (void *)&cmd_read_reg_bit_bit_pos,
6146 /* *** WRITE PORT REGISTER *** */
6147 struct cmd_write_reg_result {
6148 cmdline_fixed_string_t write;
6149 cmdline_fixed_string_t reg;
6156 cmd_write_reg_parsed(void *parsed_result,
6157 __attribute__((unused)) struct cmdline *cl,
6158 __attribute__((unused)) void *data)
6160 struct cmd_write_reg_result *res = parsed_result;
6161 port_reg_set(res->port_id, res->reg_off, res->value);
6164 cmdline_parse_token_string_t cmd_write_reg_write =
6165 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6166 cmdline_parse_token_string_t cmd_write_reg_reg =
6167 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6168 cmdline_parse_token_num_t cmd_write_reg_port_id =
6169 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6170 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6171 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6172 cmdline_parse_token_num_t cmd_write_reg_value =
6173 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6175 cmdline_parse_inst_t cmd_write_reg = {
6176 .f = cmd_write_reg_parsed,
6178 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6180 (void *)&cmd_write_reg_write,
6181 (void *)&cmd_write_reg_reg,
6182 (void *)&cmd_write_reg_port_id,
6183 (void *)&cmd_write_reg_reg_off,
6184 (void *)&cmd_write_reg_value,
6189 /* *** WRITE PORT REGISTER BIT FIELD *** */
6190 struct cmd_write_reg_bit_field_result {
6191 cmdline_fixed_string_t write;
6192 cmdline_fixed_string_t regfield;
6201 cmd_write_reg_bit_field_parsed(void *parsed_result,
6202 __attribute__((unused)) struct cmdline *cl,
6203 __attribute__((unused)) void *data)
6205 struct cmd_write_reg_bit_field_result *res = parsed_result;
6206 port_reg_bit_field_set(res->port_id, res->reg_off,
6207 res->bit1_pos, res->bit2_pos, res->value);
6210 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6211 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6213 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6214 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6215 regfield, "regfield");
6216 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6217 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6219 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6220 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6222 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6223 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6225 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6226 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6228 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6229 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6232 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6233 .f = cmd_write_reg_bit_field_parsed,
6235 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6237 "Set register bit field between bit_x and bit_y included",
6239 (void *)&cmd_write_reg_bit_field_write,
6240 (void *)&cmd_write_reg_bit_field_regfield,
6241 (void *)&cmd_write_reg_bit_field_port_id,
6242 (void *)&cmd_write_reg_bit_field_reg_off,
6243 (void *)&cmd_write_reg_bit_field_bit1_pos,
6244 (void *)&cmd_write_reg_bit_field_bit2_pos,
6245 (void *)&cmd_write_reg_bit_field_value,
6250 /* *** WRITE PORT REGISTER BIT *** */
6251 struct cmd_write_reg_bit_result {
6252 cmdline_fixed_string_t write;
6253 cmdline_fixed_string_t regbit;
6261 cmd_write_reg_bit_parsed(void *parsed_result,
6262 __attribute__((unused)) struct cmdline *cl,
6263 __attribute__((unused)) void *data)
6265 struct cmd_write_reg_bit_result *res = parsed_result;
6266 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6269 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6270 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6272 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6273 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6275 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6276 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6277 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6278 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6279 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6280 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6281 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6282 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6284 cmdline_parse_inst_t cmd_write_reg_bit = {
6285 .f = cmd_write_reg_bit_parsed,
6287 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6290 (void *)&cmd_write_reg_bit_write,
6291 (void *)&cmd_write_reg_bit_regbit,
6292 (void *)&cmd_write_reg_bit_port_id,
6293 (void *)&cmd_write_reg_bit_reg_off,
6294 (void *)&cmd_write_reg_bit_bit_pos,
6295 (void *)&cmd_write_reg_bit_value,
6300 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6301 struct cmd_read_rxd_txd_result {
6302 cmdline_fixed_string_t read;
6303 cmdline_fixed_string_t rxd_txd;
6310 cmd_read_rxd_txd_parsed(void *parsed_result,
6311 __attribute__((unused)) struct cmdline *cl,
6312 __attribute__((unused)) void *data)
6314 struct cmd_read_rxd_txd_result *res = parsed_result;
6316 if (!strcmp(res->rxd_txd, "rxd"))
6317 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6318 else if (!strcmp(res->rxd_txd, "txd"))
6319 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6322 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6323 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6324 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6325 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6327 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6328 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6329 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6330 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6331 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6332 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6334 cmdline_parse_inst_t cmd_read_rxd_txd = {
6335 .f = cmd_read_rxd_txd_parsed,
6337 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6339 (void *)&cmd_read_rxd_txd_read,
6340 (void *)&cmd_read_rxd_txd_rxd_txd,
6341 (void *)&cmd_read_rxd_txd_port_id,
6342 (void *)&cmd_read_rxd_txd_queue_id,
6343 (void *)&cmd_read_rxd_txd_desc_id,
6349 struct cmd_quit_result {
6350 cmdline_fixed_string_t quit;
6353 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6355 __attribute__((unused)) void *data)
6361 cmdline_parse_token_string_t cmd_quit_quit =
6362 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6364 cmdline_parse_inst_t cmd_quit = {
6365 .f = cmd_quit_parsed,
6367 .help_str = "quit: Exit application",
6369 (void *)&cmd_quit_quit,
6374 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6375 struct cmd_mac_addr_result {
6376 cmdline_fixed_string_t mac_addr_cmd;
6377 cmdline_fixed_string_t what;
6379 struct ether_addr address;
6382 static void cmd_mac_addr_parsed(void *parsed_result,
6383 __attribute__((unused)) struct cmdline *cl,
6384 __attribute__((unused)) void *data)
6386 struct cmd_mac_addr_result *res = parsed_result;
6389 if (strcmp(res->what, "add") == 0)
6390 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6391 else if (strcmp(res->what, "set") == 0)
6392 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6395 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6397 /* check the return value and print it if is < 0 */
6399 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6403 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6404 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6406 cmdline_parse_token_string_t cmd_mac_addr_what =
6407 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6409 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6410 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6411 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6412 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6414 cmdline_parse_inst_t cmd_mac_addr = {
6415 .f = cmd_mac_addr_parsed,
6417 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6418 "Add/Remove/Set MAC address on port_id",
6420 (void *)&cmd_mac_addr_cmd,
6421 (void *)&cmd_mac_addr_what,
6422 (void *)&cmd_mac_addr_portnum,
6423 (void *)&cmd_mac_addr_addr,
6429 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6430 struct cmd_set_qmap_result {
6431 cmdline_fixed_string_t set;
6432 cmdline_fixed_string_t qmap;
6433 cmdline_fixed_string_t what;
6440 cmd_set_qmap_parsed(void *parsed_result,
6441 __attribute__((unused)) struct cmdline *cl,
6442 __attribute__((unused)) void *data)
6444 struct cmd_set_qmap_result *res = parsed_result;
6445 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6447 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6450 cmdline_parse_token_string_t cmd_setqmap_set =
6451 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6453 cmdline_parse_token_string_t cmd_setqmap_qmap =
6454 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6456 cmdline_parse_token_string_t cmd_setqmap_what =
6457 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6459 cmdline_parse_token_num_t cmd_setqmap_portid =
6460 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6462 cmdline_parse_token_num_t cmd_setqmap_queueid =
6463 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6465 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6466 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6469 cmdline_parse_inst_t cmd_set_qmap = {
6470 .f = cmd_set_qmap_parsed,
6472 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6473 "Set statistics mapping value on tx|rx queue_id of port_id",
6475 (void *)&cmd_setqmap_set,
6476 (void *)&cmd_setqmap_qmap,
6477 (void *)&cmd_setqmap_what,
6478 (void *)&cmd_setqmap_portid,
6479 (void *)&cmd_setqmap_queueid,
6480 (void *)&cmd_setqmap_mapvalue,
6485 /* *** CONFIGURE UNICAST HASH TABLE *** */
6486 struct cmd_set_uc_hash_table {
6487 cmdline_fixed_string_t set;
6488 cmdline_fixed_string_t port;
6490 cmdline_fixed_string_t what;
6491 struct ether_addr address;
6492 cmdline_fixed_string_t mode;
6496 cmd_set_uc_hash_parsed(void *parsed_result,
6497 __attribute__((unused)) struct cmdline *cl,
6498 __attribute__((unused)) void *data)
6501 struct cmd_set_uc_hash_table *res = parsed_result;
6503 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6505 if (strcmp(res->what, "uta") == 0)
6506 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6507 &res->address,(uint8_t)is_on);
6509 printf("bad unicast hash table parameter, return code = %d \n", ret);
6513 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6514 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6516 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6517 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6519 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6520 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6522 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6523 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6525 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6526 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6528 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6532 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6533 .f = cmd_set_uc_hash_parsed,
6535 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6537 (void *)&cmd_set_uc_hash_set,
6538 (void *)&cmd_set_uc_hash_port,
6539 (void *)&cmd_set_uc_hash_portid,
6540 (void *)&cmd_set_uc_hash_what,
6541 (void *)&cmd_set_uc_hash_mac,
6542 (void *)&cmd_set_uc_hash_mode,
6547 struct cmd_set_uc_all_hash_table {
6548 cmdline_fixed_string_t set;
6549 cmdline_fixed_string_t port;
6551 cmdline_fixed_string_t what;
6552 cmdline_fixed_string_t value;
6553 cmdline_fixed_string_t mode;
6557 cmd_set_uc_all_hash_parsed(void *parsed_result,
6558 __attribute__((unused)) struct cmdline *cl,
6559 __attribute__((unused)) void *data)
6562 struct cmd_set_uc_all_hash_table *res = parsed_result;
6564 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6566 if ((strcmp(res->what, "uta") == 0) &&
6567 (strcmp(res->value, "all") == 0))
6568 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6570 printf("bad unicast hash table parameter,"
6571 "return code = %d \n", ret);
6574 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6575 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6577 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6578 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6580 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6581 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6583 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6584 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6586 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6587 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6589 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6590 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6593 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6594 .f = cmd_set_uc_all_hash_parsed,
6596 .help_str = "set port <port_id> uta all on|off",
6598 (void *)&cmd_set_uc_all_hash_set,
6599 (void *)&cmd_set_uc_all_hash_port,
6600 (void *)&cmd_set_uc_all_hash_portid,
6601 (void *)&cmd_set_uc_all_hash_what,
6602 (void *)&cmd_set_uc_all_hash_value,
6603 (void *)&cmd_set_uc_all_hash_mode,
6608 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6609 struct cmd_set_vf_macvlan_filter {
6610 cmdline_fixed_string_t set;
6611 cmdline_fixed_string_t port;
6613 cmdline_fixed_string_t vf;
6615 struct ether_addr address;
6616 cmdline_fixed_string_t filter_type;
6617 cmdline_fixed_string_t mode;
6621 cmd_set_vf_macvlan_parsed(void *parsed_result,
6622 __attribute__((unused)) struct cmdline *cl,
6623 __attribute__((unused)) void *data)
6626 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6627 struct rte_eth_mac_filter filter;
6629 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6631 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6633 /* set VF MAC filter */
6637 filter.dst_id = res->vf_id;
6639 if (!strcmp(res->filter_type, "exact-mac"))
6640 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6641 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6642 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6643 else if (!strcmp(res->filter_type, "hashmac"))
6644 filter.filter_type = RTE_MAC_HASH_MATCH;
6645 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6646 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6648 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6651 ret = rte_eth_dev_filter_ctrl(res->port_id,
6652 RTE_ETH_FILTER_MACVLAN,
6656 ret = rte_eth_dev_filter_ctrl(res->port_id,
6657 RTE_ETH_FILTER_MACVLAN,
6658 RTE_ETH_FILTER_DELETE,
6662 printf("bad set MAC hash parameter, return code = %d\n", ret);
6666 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6669 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6670 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6672 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6673 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6675 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6676 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6678 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6679 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6681 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6682 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6684 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6685 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6686 filter_type, "exact-mac#exact-mac-vlan"
6687 "#hashmac#hashmac-vlan");
6688 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6689 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6692 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6693 .f = cmd_set_vf_macvlan_parsed,
6695 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6696 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6697 "Exact match rule: exact match of MAC or MAC and VLAN; "
6698 "hash match rule: hash match of MAC and exact match of VLAN",
6700 (void *)&cmd_set_vf_macvlan_set,
6701 (void *)&cmd_set_vf_macvlan_port,
6702 (void *)&cmd_set_vf_macvlan_portid,
6703 (void *)&cmd_set_vf_macvlan_vf,
6704 (void *)&cmd_set_vf_macvlan_vf_id,
6705 (void *)&cmd_set_vf_macvlan_mac,
6706 (void *)&cmd_set_vf_macvlan_filter_type,
6707 (void *)&cmd_set_vf_macvlan_mode,
6712 #ifdef RTE_LIBRTE_IXGBE_PMD
6713 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6714 struct cmd_set_vf_traffic {
6715 cmdline_fixed_string_t set;
6716 cmdline_fixed_string_t port;
6718 cmdline_fixed_string_t vf;
6720 cmdline_fixed_string_t what;
6721 cmdline_fixed_string_t mode;
6725 cmd_set_vf_traffic_parsed(void *parsed_result,
6726 __attribute__((unused)) struct cmdline *cl,
6727 __attribute__((unused)) void *data)
6729 struct cmd_set_vf_traffic *res = parsed_result;
6730 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6731 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6733 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6736 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6737 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6739 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6740 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6742 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6743 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6745 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6746 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6748 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6749 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6751 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6752 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6754 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6755 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6758 cmdline_parse_inst_t cmd_set_vf_traffic = {
6759 .f = cmd_set_vf_traffic_parsed,
6761 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6763 (void *)&cmd_setvf_traffic_set,
6764 (void *)&cmd_setvf_traffic_port,
6765 (void *)&cmd_setvf_traffic_portid,
6766 (void *)&cmd_setvf_traffic_vf,
6767 (void *)&cmd_setvf_traffic_vfid,
6768 (void *)&cmd_setvf_traffic_what,
6769 (void *)&cmd_setvf_traffic_mode,
6774 /* *** CONFIGURE VF RECEIVE MODE *** */
6775 struct cmd_set_vf_rxmode {
6776 cmdline_fixed_string_t set;
6777 cmdline_fixed_string_t port;
6779 cmdline_fixed_string_t vf;
6781 cmdline_fixed_string_t what;
6782 cmdline_fixed_string_t mode;
6783 cmdline_fixed_string_t on;
6787 cmd_set_vf_rxmode_parsed(void *parsed_result,
6788 __attribute__((unused)) struct cmdline *cl,
6789 __attribute__((unused)) void *data)
6792 uint16_t rx_mode = 0;
6793 struct cmd_set_vf_rxmode *res = parsed_result;
6795 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6796 if (!strcmp(res->what,"rxmode")) {
6797 if (!strcmp(res->mode, "AUPE"))
6798 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6799 else if (!strcmp(res->mode, "ROPE"))
6800 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6801 else if (!strcmp(res->mode, "BAM"))
6802 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6803 else if (!strncmp(res->mode, "MPE",3))
6804 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6807 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6809 printf("bad VF receive mode parameter, return code = %d \n",
6813 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6814 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6816 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6817 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6819 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6820 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6822 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6823 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6825 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6826 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6828 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6829 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6831 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6832 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6833 mode, "AUPE#ROPE#BAM#MPE");
6834 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6835 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6838 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6839 .f = cmd_set_vf_rxmode_parsed,
6841 .help_str = "set port <port_id> vf <vf_id> rxmode "
6842 "AUPE|ROPE|BAM|MPE on|off",
6844 (void *)&cmd_set_vf_rxmode_set,
6845 (void *)&cmd_set_vf_rxmode_port,
6846 (void *)&cmd_set_vf_rxmode_portid,
6847 (void *)&cmd_set_vf_rxmode_vf,
6848 (void *)&cmd_set_vf_rxmode_vfid,
6849 (void *)&cmd_set_vf_rxmode_what,
6850 (void *)&cmd_set_vf_rxmode_mode,
6851 (void *)&cmd_set_vf_rxmode_on,
6857 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6858 struct cmd_vf_mac_addr_result {
6859 cmdline_fixed_string_t mac_addr_cmd;
6860 cmdline_fixed_string_t what;
6861 cmdline_fixed_string_t port;
6863 cmdline_fixed_string_t vf;
6865 struct ether_addr address;
6868 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6869 __attribute__((unused)) struct cmdline *cl,
6870 __attribute__((unused)) void *data)
6872 struct cmd_vf_mac_addr_result *res = parsed_result;
6875 if (strcmp(res->what, "add") == 0)
6876 ret = rte_eth_dev_mac_addr_add(res->port_num,
6877 &res->address, res->vf_num);
6879 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6883 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6884 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6885 mac_addr_cmd,"mac_addr");
6886 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6887 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6889 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6890 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6892 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6893 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6895 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6896 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6898 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6899 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6901 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6902 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6905 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6906 .f = cmd_vf_mac_addr_parsed,
6908 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6909 "Add MAC address filtering for a VF on port_id",
6911 (void *)&cmd_vf_mac_addr_cmd,
6912 (void *)&cmd_vf_mac_addr_what,
6913 (void *)&cmd_vf_mac_addr_port,
6914 (void *)&cmd_vf_mac_addr_portnum,
6915 (void *)&cmd_vf_mac_addr_vf,
6916 (void *)&cmd_vf_mac_addr_vfnum,
6917 (void *)&cmd_vf_mac_addr_addr,
6922 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6923 struct cmd_vf_rx_vlan_filter {
6924 cmdline_fixed_string_t rx_vlan;
6925 cmdline_fixed_string_t what;
6927 cmdline_fixed_string_t port;
6929 cmdline_fixed_string_t vf;
6934 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6935 __attribute__((unused)) struct cmdline *cl,
6936 __attribute__((unused)) void *data)
6938 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6941 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6943 #ifdef RTE_LIBRTE_IXGBE_PMD
6944 if (ret == -ENOTSUP)
6945 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6946 res->vlan_id, res->vf_mask, is_add);
6948 #ifdef RTE_LIBRTE_I40E_PMD
6949 if (ret == -ENOTSUP)
6950 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6951 res->vlan_id, res->vf_mask, is_add);
6958 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6959 res->vlan_id, res->vf_mask);
6962 printf("invalid port_id %d\n", res->port_id);
6965 printf("function not implemented or supported\n");
6968 printf("programming error: (%s)\n", strerror(-ret));
6972 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6973 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6974 rx_vlan, "rx_vlan");
6975 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6976 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6978 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6979 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6981 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6982 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6984 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6985 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6987 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6988 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6990 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6991 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6994 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6995 .f = cmd_vf_rx_vlan_filter_parsed,
6997 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6998 "(vf_mask = hexadecimal VF mask)",
7000 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7001 (void *)&cmd_vf_rx_vlan_filter_what,
7002 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7003 (void *)&cmd_vf_rx_vlan_filter_port,
7004 (void *)&cmd_vf_rx_vlan_filter_portid,
7005 (void *)&cmd_vf_rx_vlan_filter_vf,
7006 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7011 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7012 struct cmd_queue_rate_limit_result {
7013 cmdline_fixed_string_t set;
7014 cmdline_fixed_string_t port;
7016 cmdline_fixed_string_t queue;
7018 cmdline_fixed_string_t rate;
7022 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7023 __attribute__((unused)) struct cmdline *cl,
7024 __attribute__((unused)) void *data)
7026 struct cmd_queue_rate_limit_result *res = parsed_result;
7029 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7030 && (strcmp(res->queue, "queue") == 0)
7031 && (strcmp(res->rate, "rate") == 0))
7032 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7035 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7039 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7040 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7042 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7043 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7045 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7046 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7048 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7049 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7051 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7052 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7054 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7055 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7057 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7058 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7061 cmdline_parse_inst_t cmd_queue_rate_limit = {
7062 .f = cmd_queue_rate_limit_parsed,
7064 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7065 "Set rate limit for a queue on port_id",
7067 (void *)&cmd_queue_rate_limit_set,
7068 (void *)&cmd_queue_rate_limit_port,
7069 (void *)&cmd_queue_rate_limit_portnum,
7070 (void *)&cmd_queue_rate_limit_queue,
7071 (void *)&cmd_queue_rate_limit_queuenum,
7072 (void *)&cmd_queue_rate_limit_rate,
7073 (void *)&cmd_queue_rate_limit_ratenum,
7078 #ifdef RTE_LIBRTE_IXGBE_PMD
7079 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7080 struct cmd_vf_rate_limit_result {
7081 cmdline_fixed_string_t set;
7082 cmdline_fixed_string_t port;
7084 cmdline_fixed_string_t vf;
7086 cmdline_fixed_string_t rate;
7088 cmdline_fixed_string_t q_msk;
7092 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7093 __attribute__((unused)) struct cmdline *cl,
7094 __attribute__((unused)) void *data)
7096 struct cmd_vf_rate_limit_result *res = parsed_result;
7099 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7100 && (strcmp(res->vf, "vf") == 0)
7101 && (strcmp(res->rate, "rate") == 0)
7102 && (strcmp(res->q_msk, "queue_mask") == 0))
7103 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7104 res->rate_num, res->q_msk_val);
7106 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7110 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7111 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7113 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7114 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7116 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7117 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7119 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7120 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7122 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7123 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7125 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7126 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7128 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7129 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7131 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7132 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7133 q_msk, "queue_mask");
7134 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7135 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7138 cmdline_parse_inst_t cmd_vf_rate_limit = {
7139 .f = cmd_vf_rate_limit_parsed,
7141 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7142 "queue_mask <queue_mask_value>: "
7143 "Set rate limit for queues of VF on port_id",
7145 (void *)&cmd_vf_rate_limit_set,
7146 (void *)&cmd_vf_rate_limit_port,
7147 (void *)&cmd_vf_rate_limit_portnum,
7148 (void *)&cmd_vf_rate_limit_vf,
7149 (void *)&cmd_vf_rate_limit_vfnum,
7150 (void *)&cmd_vf_rate_limit_rate,
7151 (void *)&cmd_vf_rate_limit_ratenum,
7152 (void *)&cmd_vf_rate_limit_q_msk,
7153 (void *)&cmd_vf_rate_limit_q_msk_val,
7159 /* *** ADD TUNNEL FILTER OF A PORT *** */
7160 struct cmd_tunnel_filter_result {
7161 cmdline_fixed_string_t cmd;
7162 cmdline_fixed_string_t what;
7164 struct ether_addr outer_mac;
7165 struct ether_addr inner_mac;
7166 cmdline_ipaddr_t ip_value;
7167 uint16_t inner_vlan;
7168 cmdline_fixed_string_t tunnel_type;
7169 cmdline_fixed_string_t filter_type;
7175 cmd_tunnel_filter_parsed(void *parsed_result,
7176 __attribute__((unused)) struct cmdline *cl,
7177 __attribute__((unused)) void *data)
7179 struct cmd_tunnel_filter_result *res = parsed_result;
7180 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7183 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7185 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7186 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7187 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7189 if (res->ip_value.family == AF_INET) {
7190 tunnel_filter_conf.ip_addr.ipv4_addr =
7191 res->ip_value.addr.ipv4.s_addr;
7192 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7194 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7195 &(res->ip_value.addr.ipv6),
7196 sizeof(struct in6_addr));
7197 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7200 if (!strcmp(res->filter_type, "imac-ivlan"))
7201 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7202 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7203 tunnel_filter_conf.filter_type =
7204 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7205 else if (!strcmp(res->filter_type, "imac-tenid"))
7206 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7207 else if (!strcmp(res->filter_type, "imac"))
7208 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7209 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7210 tunnel_filter_conf.filter_type =
7211 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7212 else if (!strcmp(res->filter_type, "oip"))
7213 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7214 else if (!strcmp(res->filter_type, "iip"))
7215 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7217 printf("The filter type is not supported");
7221 if (!strcmp(res->tunnel_type, "vxlan"))
7222 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7223 else if (!strcmp(res->tunnel_type, "nvgre"))
7224 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7225 else if (!strcmp(res->tunnel_type, "ipingre"))
7226 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7228 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7232 tunnel_filter_conf.tenant_id = res->tenant_id;
7233 tunnel_filter_conf.queue_id = res->queue_num;
7234 if (!strcmp(res->what, "add"))
7235 ret = rte_eth_dev_filter_ctrl(res->port_id,
7236 RTE_ETH_FILTER_TUNNEL,
7238 &tunnel_filter_conf);
7240 ret = rte_eth_dev_filter_ctrl(res->port_id,
7241 RTE_ETH_FILTER_TUNNEL,
7242 RTE_ETH_FILTER_DELETE,
7243 &tunnel_filter_conf);
7245 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7249 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7250 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7251 cmd, "tunnel_filter");
7252 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7253 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7255 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7256 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7258 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7259 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7261 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7262 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7264 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7265 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7266 inner_vlan, UINT16);
7267 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7268 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7270 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7271 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7272 tunnel_type, "vxlan#nvgre#ipingre");
7274 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7275 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7276 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7277 "imac#omac-imac-tenid");
7278 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7279 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7281 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7282 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7285 cmdline_parse_inst_t cmd_tunnel_filter = {
7286 .f = cmd_tunnel_filter_parsed,
7288 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7289 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7290 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7291 "<queue_id>: Add/Rm tunnel filter of a port",
7293 (void *)&cmd_tunnel_filter_cmd,
7294 (void *)&cmd_tunnel_filter_what,
7295 (void *)&cmd_tunnel_filter_port_id,
7296 (void *)&cmd_tunnel_filter_outer_mac,
7297 (void *)&cmd_tunnel_filter_inner_mac,
7298 (void *)&cmd_tunnel_filter_ip_value,
7299 (void *)&cmd_tunnel_filter_innner_vlan,
7300 (void *)&cmd_tunnel_filter_tunnel_type,
7301 (void *)&cmd_tunnel_filter_filter_type,
7302 (void *)&cmd_tunnel_filter_tenant_id,
7303 (void *)&cmd_tunnel_filter_queue_num,
7308 /* *** CONFIGURE TUNNEL UDP PORT *** */
7309 struct cmd_tunnel_udp_config {
7310 cmdline_fixed_string_t cmd;
7311 cmdline_fixed_string_t what;
7317 cmd_tunnel_udp_config_parsed(void *parsed_result,
7318 __attribute__((unused)) struct cmdline *cl,
7319 __attribute__((unused)) void *data)
7321 struct cmd_tunnel_udp_config *res = parsed_result;
7322 struct rte_eth_udp_tunnel tunnel_udp;
7325 tunnel_udp.udp_port = res->udp_port;
7327 if (!strcmp(res->cmd, "rx_vxlan_port"))
7328 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7330 if (!strcmp(res->what, "add"))
7331 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7334 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7338 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7341 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7342 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7343 cmd, "rx_vxlan_port");
7344 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7345 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7347 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7348 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7350 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7351 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7354 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7355 .f = cmd_tunnel_udp_config_parsed,
7357 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7358 "Add/Remove a tunneling UDP port filter",
7360 (void *)&cmd_tunnel_udp_config_cmd,
7361 (void *)&cmd_tunnel_udp_config_what,
7362 (void *)&cmd_tunnel_udp_config_udp_port,
7363 (void *)&cmd_tunnel_udp_config_port_id,
7368 /* *** GLOBAL CONFIG *** */
7369 struct cmd_global_config_result {
7370 cmdline_fixed_string_t cmd;
7372 cmdline_fixed_string_t cfg_type;
7377 cmd_global_config_parsed(void *parsed_result,
7378 __attribute__((unused)) struct cmdline *cl,
7379 __attribute__((unused)) void *data)
7381 struct cmd_global_config_result *res = parsed_result;
7382 struct rte_eth_global_cfg conf;
7385 memset(&conf, 0, sizeof(conf));
7386 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7387 conf.cfg.gre_key_len = res->len;
7388 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7389 RTE_ETH_FILTER_SET, &conf);
7391 printf("Global config error\n");
7394 cmdline_parse_token_string_t cmd_global_config_cmd =
7395 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7397 cmdline_parse_token_num_t cmd_global_config_port_id =
7398 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7399 cmdline_parse_token_string_t cmd_global_config_type =
7400 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7401 cfg_type, "gre-key-len");
7402 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7403 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7406 cmdline_parse_inst_t cmd_global_config = {
7407 .f = cmd_global_config_parsed,
7408 .data = (void *)NULL,
7409 .help_str = "global_config <port_id> gre-key-len <key_len>",
7411 (void *)&cmd_global_config_cmd,
7412 (void *)&cmd_global_config_port_id,
7413 (void *)&cmd_global_config_type,
7414 (void *)&cmd_global_config_gre_key_len,
7419 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7420 struct cmd_set_mirror_mask_result {
7421 cmdline_fixed_string_t set;
7422 cmdline_fixed_string_t port;
7424 cmdline_fixed_string_t mirror;
7426 cmdline_fixed_string_t what;
7427 cmdline_fixed_string_t value;
7428 cmdline_fixed_string_t dstpool;
7430 cmdline_fixed_string_t on;
7433 cmdline_parse_token_string_t cmd_mirror_mask_set =
7434 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7436 cmdline_parse_token_string_t cmd_mirror_mask_port =
7437 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7439 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7440 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7442 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7443 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7444 mirror, "mirror-rule");
7445 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7446 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7448 cmdline_parse_token_string_t cmd_mirror_mask_what =
7449 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7450 what, "pool-mirror-up#pool-mirror-down"
7452 cmdline_parse_token_string_t cmd_mirror_mask_value =
7453 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7455 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7456 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7457 dstpool, "dst-pool");
7458 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7459 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7461 cmdline_parse_token_string_t cmd_mirror_mask_on =
7462 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7466 cmd_set_mirror_mask_parsed(void *parsed_result,
7467 __attribute__((unused)) struct cmdline *cl,
7468 __attribute__((unused)) void *data)
7471 struct cmd_set_mirror_mask_result *res = parsed_result;
7472 struct rte_eth_mirror_conf mr_conf;
7474 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7476 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7478 mr_conf.dst_pool = res->dstpool_id;
7480 if (!strcmp(res->what, "pool-mirror-up")) {
7481 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7482 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7483 } else if (!strcmp(res->what, "pool-mirror-down")) {
7484 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7485 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7486 } else if (!strcmp(res->what, "vlan-mirror")) {
7487 mr_conf.rule_type = ETH_MIRROR_VLAN;
7488 nb_item = parse_item_list(res->value, "vlan",
7489 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7493 for (i = 0; i < nb_item; i++) {
7494 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7495 printf("Invalid vlan_id: must be < 4096\n");
7499 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7500 mr_conf.vlan.vlan_mask |= 1ULL << i;
7504 if (!strcmp(res->on, "on"))
7505 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7508 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7511 printf("mirror rule add error: (%s)\n", strerror(-ret));
7514 cmdline_parse_inst_t cmd_set_mirror_mask = {
7515 .f = cmd_set_mirror_mask_parsed,
7517 .help_str = "set port <port_id> mirror-rule <rule_id> "
7518 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7519 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7521 (void *)&cmd_mirror_mask_set,
7522 (void *)&cmd_mirror_mask_port,
7523 (void *)&cmd_mirror_mask_portid,
7524 (void *)&cmd_mirror_mask_mirror,
7525 (void *)&cmd_mirror_mask_ruleid,
7526 (void *)&cmd_mirror_mask_what,
7527 (void *)&cmd_mirror_mask_value,
7528 (void *)&cmd_mirror_mask_dstpool,
7529 (void *)&cmd_mirror_mask_poolid,
7530 (void *)&cmd_mirror_mask_on,
7535 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7536 struct cmd_set_mirror_link_result {
7537 cmdline_fixed_string_t set;
7538 cmdline_fixed_string_t port;
7540 cmdline_fixed_string_t mirror;
7542 cmdline_fixed_string_t what;
7543 cmdline_fixed_string_t dstpool;
7545 cmdline_fixed_string_t on;
7548 cmdline_parse_token_string_t cmd_mirror_link_set =
7549 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7551 cmdline_parse_token_string_t cmd_mirror_link_port =
7552 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7554 cmdline_parse_token_num_t cmd_mirror_link_portid =
7555 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7557 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7558 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7559 mirror, "mirror-rule");
7560 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7561 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7563 cmdline_parse_token_string_t cmd_mirror_link_what =
7564 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7565 what, "uplink-mirror#downlink-mirror");
7566 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7567 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7568 dstpool, "dst-pool");
7569 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7570 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7572 cmdline_parse_token_string_t cmd_mirror_link_on =
7573 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7577 cmd_set_mirror_link_parsed(void *parsed_result,
7578 __attribute__((unused)) struct cmdline *cl,
7579 __attribute__((unused)) void *data)
7582 struct cmd_set_mirror_link_result *res = parsed_result;
7583 struct rte_eth_mirror_conf mr_conf;
7585 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7586 if (!strcmp(res->what, "uplink-mirror"))
7587 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7589 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7591 mr_conf.dst_pool = res->dstpool_id;
7593 if (!strcmp(res->on, "on"))
7594 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7597 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7600 /* check the return value and print it if is < 0 */
7602 printf("mirror rule add error: (%s)\n", strerror(-ret));
7606 cmdline_parse_inst_t cmd_set_mirror_link = {
7607 .f = cmd_set_mirror_link_parsed,
7609 .help_str = "set port <port_id> mirror-rule <rule_id> "
7610 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7612 (void *)&cmd_mirror_link_set,
7613 (void *)&cmd_mirror_link_port,
7614 (void *)&cmd_mirror_link_portid,
7615 (void *)&cmd_mirror_link_mirror,
7616 (void *)&cmd_mirror_link_ruleid,
7617 (void *)&cmd_mirror_link_what,
7618 (void *)&cmd_mirror_link_dstpool,
7619 (void *)&cmd_mirror_link_poolid,
7620 (void *)&cmd_mirror_link_on,
7625 /* *** RESET VM MIRROR RULE *** */
7626 struct cmd_rm_mirror_rule_result {
7627 cmdline_fixed_string_t reset;
7628 cmdline_fixed_string_t port;
7630 cmdline_fixed_string_t mirror;
7634 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7635 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7637 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7638 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7640 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7641 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7643 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7644 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7645 mirror, "mirror-rule");
7646 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7647 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7651 cmd_reset_mirror_rule_parsed(void *parsed_result,
7652 __attribute__((unused)) struct cmdline *cl,
7653 __attribute__((unused)) void *data)
7656 struct cmd_set_mirror_link_result *res = parsed_result;
7658 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7660 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7663 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7664 .f = cmd_reset_mirror_rule_parsed,
7666 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7668 (void *)&cmd_rm_mirror_rule_reset,
7669 (void *)&cmd_rm_mirror_rule_port,
7670 (void *)&cmd_rm_mirror_rule_portid,
7671 (void *)&cmd_rm_mirror_rule_mirror,
7672 (void *)&cmd_rm_mirror_rule_ruleid,
7677 /* ******************************************************************************** */
7679 struct cmd_dump_result {
7680 cmdline_fixed_string_t dump;
7684 dump_struct_sizes(void)
7686 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7687 DUMP_SIZE(struct rte_mbuf);
7688 DUMP_SIZE(struct rte_mempool);
7689 DUMP_SIZE(struct rte_ring);
7693 static void cmd_dump_parsed(void *parsed_result,
7694 __attribute__((unused)) struct cmdline *cl,
7695 __attribute__((unused)) void *data)
7697 struct cmd_dump_result *res = parsed_result;
7699 if (!strcmp(res->dump, "dump_physmem"))
7700 rte_dump_physmem_layout(stdout);
7701 else if (!strcmp(res->dump, "dump_memzone"))
7702 rte_memzone_dump(stdout);
7703 else if (!strcmp(res->dump, "dump_struct_sizes"))
7704 dump_struct_sizes();
7705 else if (!strcmp(res->dump, "dump_ring"))
7706 rte_ring_list_dump(stdout);
7707 else if (!strcmp(res->dump, "dump_mempool"))
7708 rte_mempool_list_dump(stdout);
7709 else if (!strcmp(res->dump, "dump_devargs"))
7710 rte_eal_devargs_dump(stdout);
7711 else if (!strcmp(res->dump, "dump_log_types"))
7712 rte_log_dump(stdout);
7715 cmdline_parse_token_string_t cmd_dump_dump =
7716 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7719 "dump_struct_sizes#"
7725 cmdline_parse_inst_t cmd_dump = {
7726 .f = cmd_dump_parsed, /* function to call */
7727 .data = NULL, /* 2nd arg of func */
7728 .help_str = "Dump status",
7729 .tokens = { /* token list, NULL terminated */
7730 (void *)&cmd_dump_dump,
7735 /* ******************************************************************************** */
7737 struct cmd_dump_one_result {
7738 cmdline_fixed_string_t dump;
7739 cmdline_fixed_string_t name;
7742 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7743 __attribute__((unused)) void *data)
7745 struct cmd_dump_one_result *res = parsed_result;
7747 if (!strcmp(res->dump, "dump_ring")) {
7749 r = rte_ring_lookup(res->name);
7751 cmdline_printf(cl, "Cannot find ring\n");
7754 rte_ring_dump(stdout, r);
7755 } else if (!strcmp(res->dump, "dump_mempool")) {
7756 struct rte_mempool *mp;
7757 mp = rte_mempool_lookup(res->name);
7759 cmdline_printf(cl, "Cannot find mempool\n");
7762 rte_mempool_dump(stdout, mp);
7766 cmdline_parse_token_string_t cmd_dump_one_dump =
7767 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7768 "dump_ring#dump_mempool");
7770 cmdline_parse_token_string_t cmd_dump_one_name =
7771 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7773 cmdline_parse_inst_t cmd_dump_one = {
7774 .f = cmd_dump_one_parsed, /* function to call */
7775 .data = NULL, /* 2nd arg of func */
7776 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7777 .tokens = { /* token list, NULL terminated */
7778 (void *)&cmd_dump_one_dump,
7779 (void *)&cmd_dump_one_name,
7784 /* *** Add/Del syn filter *** */
7785 struct cmd_syn_filter_result {
7786 cmdline_fixed_string_t filter;
7788 cmdline_fixed_string_t ops;
7789 cmdline_fixed_string_t priority;
7790 cmdline_fixed_string_t high;
7791 cmdline_fixed_string_t queue;
7796 cmd_syn_filter_parsed(void *parsed_result,
7797 __attribute__((unused)) struct cmdline *cl,
7798 __attribute__((unused)) void *data)
7800 struct cmd_syn_filter_result *res = parsed_result;
7801 struct rte_eth_syn_filter syn_filter;
7804 ret = rte_eth_dev_filter_supported(res->port_id,
7805 RTE_ETH_FILTER_SYN);
7807 printf("syn filter is not supported on port %u.\n",
7812 memset(&syn_filter, 0, sizeof(syn_filter));
7814 if (!strcmp(res->ops, "add")) {
7815 if (!strcmp(res->high, "high"))
7816 syn_filter.hig_pri = 1;
7818 syn_filter.hig_pri = 0;
7820 syn_filter.queue = res->queue_id;
7821 ret = rte_eth_dev_filter_ctrl(res->port_id,
7826 ret = rte_eth_dev_filter_ctrl(res->port_id,
7828 RTE_ETH_FILTER_DELETE,
7832 printf("syn filter programming error: (%s)\n",
7836 cmdline_parse_token_string_t cmd_syn_filter_filter =
7837 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7838 filter, "syn_filter");
7839 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7840 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7842 cmdline_parse_token_string_t cmd_syn_filter_ops =
7843 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7845 cmdline_parse_token_string_t cmd_syn_filter_priority =
7846 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7847 priority, "priority");
7848 cmdline_parse_token_string_t cmd_syn_filter_high =
7849 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7851 cmdline_parse_token_string_t cmd_syn_filter_queue =
7852 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7854 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7855 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7858 cmdline_parse_inst_t cmd_syn_filter = {
7859 .f = cmd_syn_filter_parsed,
7861 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7862 "<queue_id>: Add/Delete syn filter",
7864 (void *)&cmd_syn_filter_filter,
7865 (void *)&cmd_syn_filter_port_id,
7866 (void *)&cmd_syn_filter_ops,
7867 (void *)&cmd_syn_filter_priority,
7868 (void *)&cmd_syn_filter_high,
7869 (void *)&cmd_syn_filter_queue,
7870 (void *)&cmd_syn_filter_queue_id,
7875 /* *** ADD/REMOVE A 2tuple FILTER *** */
7876 struct cmd_2tuple_filter_result {
7877 cmdline_fixed_string_t filter;
7879 cmdline_fixed_string_t ops;
7880 cmdline_fixed_string_t dst_port;
7881 uint16_t dst_port_value;
7882 cmdline_fixed_string_t protocol;
7883 uint8_t protocol_value;
7884 cmdline_fixed_string_t mask;
7886 cmdline_fixed_string_t tcp_flags;
7887 uint8_t tcp_flags_value;
7888 cmdline_fixed_string_t priority;
7889 uint8_t priority_value;
7890 cmdline_fixed_string_t queue;
7895 cmd_2tuple_filter_parsed(void *parsed_result,
7896 __attribute__((unused)) struct cmdline *cl,
7897 __attribute__((unused)) void *data)
7899 struct rte_eth_ntuple_filter filter;
7900 struct cmd_2tuple_filter_result *res = parsed_result;
7903 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7905 printf("ntuple filter is not supported on port %u.\n",
7910 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7912 filter.flags = RTE_2TUPLE_FLAGS;
7913 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7914 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7915 filter.proto = res->protocol_value;
7916 filter.priority = res->priority_value;
7917 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7918 printf("nonzero tcp_flags is only meaningful"
7919 " when protocol is TCP.\n");
7922 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7923 printf("invalid TCP flags.\n");
7927 if (res->tcp_flags_value != 0) {
7928 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7929 filter.tcp_flags = res->tcp_flags_value;
7932 /* need convert to big endian. */
7933 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7934 filter.queue = res->queue_id;
7936 if (!strcmp(res->ops, "add"))
7937 ret = rte_eth_dev_filter_ctrl(res->port_id,
7938 RTE_ETH_FILTER_NTUPLE,
7942 ret = rte_eth_dev_filter_ctrl(res->port_id,
7943 RTE_ETH_FILTER_NTUPLE,
7944 RTE_ETH_FILTER_DELETE,
7947 printf("2tuple filter programming error: (%s)\n",
7952 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7953 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7954 filter, "2tuple_filter");
7955 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7956 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7958 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7959 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7961 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7962 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7963 dst_port, "dst_port");
7964 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7965 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7966 dst_port_value, UINT16);
7967 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7968 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7969 protocol, "protocol");
7970 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7971 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7972 protocol_value, UINT8);
7973 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7974 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7976 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7977 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7979 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7980 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7981 tcp_flags, "tcp_flags");
7982 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7983 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7984 tcp_flags_value, UINT8);
7985 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7986 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7987 priority, "priority");
7988 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7989 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7990 priority_value, UINT8);
7991 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7992 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7994 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7995 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7998 cmdline_parse_inst_t cmd_2tuple_filter = {
7999 .f = cmd_2tuple_filter_parsed,
8001 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8002 "<value> mask <value> tcp_flags <value> priority <value> queue "
8003 "<queue_id>: Add a 2tuple filter",
8005 (void *)&cmd_2tuple_filter_filter,
8006 (void *)&cmd_2tuple_filter_port_id,
8007 (void *)&cmd_2tuple_filter_ops,
8008 (void *)&cmd_2tuple_filter_dst_port,
8009 (void *)&cmd_2tuple_filter_dst_port_value,
8010 (void *)&cmd_2tuple_filter_protocol,
8011 (void *)&cmd_2tuple_filter_protocol_value,
8012 (void *)&cmd_2tuple_filter_mask,
8013 (void *)&cmd_2tuple_filter_mask_value,
8014 (void *)&cmd_2tuple_filter_tcp_flags,
8015 (void *)&cmd_2tuple_filter_tcp_flags_value,
8016 (void *)&cmd_2tuple_filter_priority,
8017 (void *)&cmd_2tuple_filter_priority_value,
8018 (void *)&cmd_2tuple_filter_queue,
8019 (void *)&cmd_2tuple_filter_queue_id,
8024 /* *** ADD/REMOVE A 5tuple FILTER *** */
8025 struct cmd_5tuple_filter_result {
8026 cmdline_fixed_string_t filter;
8028 cmdline_fixed_string_t ops;
8029 cmdline_fixed_string_t dst_ip;
8030 cmdline_ipaddr_t dst_ip_value;
8031 cmdline_fixed_string_t src_ip;
8032 cmdline_ipaddr_t src_ip_value;
8033 cmdline_fixed_string_t dst_port;
8034 uint16_t dst_port_value;
8035 cmdline_fixed_string_t src_port;
8036 uint16_t src_port_value;
8037 cmdline_fixed_string_t protocol;
8038 uint8_t protocol_value;
8039 cmdline_fixed_string_t mask;
8041 cmdline_fixed_string_t tcp_flags;
8042 uint8_t tcp_flags_value;
8043 cmdline_fixed_string_t priority;
8044 uint8_t priority_value;
8045 cmdline_fixed_string_t queue;
8050 cmd_5tuple_filter_parsed(void *parsed_result,
8051 __attribute__((unused)) struct cmdline *cl,
8052 __attribute__((unused)) void *data)
8054 struct rte_eth_ntuple_filter filter;
8055 struct cmd_5tuple_filter_result *res = parsed_result;
8058 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8060 printf("ntuple filter is not supported on port %u.\n",
8065 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8067 filter.flags = RTE_5TUPLE_FLAGS;
8068 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8069 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8070 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8071 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8072 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8073 filter.proto = res->protocol_value;
8074 filter.priority = res->priority_value;
8075 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8076 printf("nonzero tcp_flags is only meaningful"
8077 " when protocol is TCP.\n");
8080 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8081 printf("invalid TCP flags.\n");
8085 if (res->tcp_flags_value != 0) {
8086 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8087 filter.tcp_flags = res->tcp_flags_value;
8090 if (res->dst_ip_value.family == AF_INET)
8091 /* no need to convert, already big endian. */
8092 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8094 if (filter.dst_ip_mask == 0) {
8095 printf("can not support ipv6 involved compare.\n");
8101 if (res->src_ip_value.family == AF_INET)
8102 /* no need to convert, already big endian. */
8103 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8105 if (filter.src_ip_mask == 0) {
8106 printf("can not support ipv6 involved compare.\n");
8111 /* need convert to big endian. */
8112 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8113 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8114 filter.queue = res->queue_id;
8116 if (!strcmp(res->ops, "add"))
8117 ret = rte_eth_dev_filter_ctrl(res->port_id,
8118 RTE_ETH_FILTER_NTUPLE,
8122 ret = rte_eth_dev_filter_ctrl(res->port_id,
8123 RTE_ETH_FILTER_NTUPLE,
8124 RTE_ETH_FILTER_DELETE,
8127 printf("5tuple filter programming error: (%s)\n",
8131 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8132 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8133 filter, "5tuple_filter");
8134 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8135 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8137 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8138 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8140 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8141 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8143 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8144 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8146 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8147 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8149 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8150 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8152 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8153 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8154 dst_port, "dst_port");
8155 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8156 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8157 dst_port_value, UINT16);
8158 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8159 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8160 src_port, "src_port");
8161 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8162 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8163 src_port_value, UINT16);
8164 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8165 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8166 protocol, "protocol");
8167 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8168 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8169 protocol_value, UINT8);
8170 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8171 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8173 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8174 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8176 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8177 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8178 tcp_flags, "tcp_flags");
8179 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8180 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8181 tcp_flags_value, UINT8);
8182 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8183 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8184 priority, "priority");
8185 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8186 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8187 priority_value, UINT8);
8188 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8189 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8191 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8192 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8195 cmdline_parse_inst_t cmd_5tuple_filter = {
8196 .f = cmd_5tuple_filter_parsed,
8198 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8199 "src_ip <value> dst_port <value> src_port <value> "
8200 "protocol <value> mask <value> tcp_flags <value> "
8201 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8203 (void *)&cmd_5tuple_filter_filter,
8204 (void *)&cmd_5tuple_filter_port_id,
8205 (void *)&cmd_5tuple_filter_ops,
8206 (void *)&cmd_5tuple_filter_dst_ip,
8207 (void *)&cmd_5tuple_filter_dst_ip_value,
8208 (void *)&cmd_5tuple_filter_src_ip,
8209 (void *)&cmd_5tuple_filter_src_ip_value,
8210 (void *)&cmd_5tuple_filter_dst_port,
8211 (void *)&cmd_5tuple_filter_dst_port_value,
8212 (void *)&cmd_5tuple_filter_src_port,
8213 (void *)&cmd_5tuple_filter_src_port_value,
8214 (void *)&cmd_5tuple_filter_protocol,
8215 (void *)&cmd_5tuple_filter_protocol_value,
8216 (void *)&cmd_5tuple_filter_mask,
8217 (void *)&cmd_5tuple_filter_mask_value,
8218 (void *)&cmd_5tuple_filter_tcp_flags,
8219 (void *)&cmd_5tuple_filter_tcp_flags_value,
8220 (void *)&cmd_5tuple_filter_priority,
8221 (void *)&cmd_5tuple_filter_priority_value,
8222 (void *)&cmd_5tuple_filter_queue,
8223 (void *)&cmd_5tuple_filter_queue_id,
8228 /* *** ADD/REMOVE A flex FILTER *** */
8229 struct cmd_flex_filter_result {
8230 cmdline_fixed_string_t filter;
8231 cmdline_fixed_string_t ops;
8233 cmdline_fixed_string_t len;
8235 cmdline_fixed_string_t bytes;
8236 cmdline_fixed_string_t bytes_value;
8237 cmdline_fixed_string_t mask;
8238 cmdline_fixed_string_t mask_value;
8239 cmdline_fixed_string_t priority;
8240 uint8_t priority_value;
8241 cmdline_fixed_string_t queue;
8245 static int xdigit2val(unsigned char c)
8250 else if (isupper(c))
8258 cmd_flex_filter_parsed(void *parsed_result,
8259 __attribute__((unused)) struct cmdline *cl,
8260 __attribute__((unused)) void *data)
8263 struct rte_eth_flex_filter filter;
8264 struct cmd_flex_filter_result *res = parsed_result;
8265 char *bytes_ptr, *mask_ptr;
8266 uint16_t len, i, j = 0;
8271 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8272 printf("the len exceed the max length 128\n");
8275 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8276 filter.len = res->len_value;
8277 filter.priority = res->priority_value;
8278 filter.queue = res->queue_id;
8279 bytes_ptr = res->bytes_value;
8280 mask_ptr = res->mask_value;
8282 /* translate bytes string to array. */
8283 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8284 (bytes_ptr[1] == 'X')))
8286 len = strnlen(bytes_ptr, res->len_value * 2);
8287 if (len == 0 || (len % 8 != 0)) {
8288 printf("please check len and bytes input\n");
8291 for (i = 0; i < len; i++) {
8293 if (isxdigit(c) == 0) {
8294 /* invalid characters. */
8295 printf("invalid input\n");
8298 val = xdigit2val(c);
8301 filter.bytes[j] = byte;
8302 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8309 /* translate mask string to uint8_t array. */
8310 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8311 (mask_ptr[1] == 'X')))
8313 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8315 printf("invalid input\n");
8320 for (i = 0; i < len; i++) {
8322 if (isxdigit(c) == 0) {
8323 /* invalid characters. */
8324 printf("invalid input\n");
8327 val = xdigit2val(c);
8330 filter.mask[j] = byte;
8331 printf("mask[%d]:%02x ", j, filter.mask[j]);
8339 if (!strcmp(res->ops, "add"))
8340 ret = rte_eth_dev_filter_ctrl(res->port_id,
8341 RTE_ETH_FILTER_FLEXIBLE,
8345 ret = rte_eth_dev_filter_ctrl(res->port_id,
8346 RTE_ETH_FILTER_FLEXIBLE,
8347 RTE_ETH_FILTER_DELETE,
8351 printf("flex filter setting error: (%s)\n", strerror(-ret));
8354 cmdline_parse_token_string_t cmd_flex_filter_filter =
8355 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8356 filter, "flex_filter");
8357 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8358 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8360 cmdline_parse_token_string_t cmd_flex_filter_ops =
8361 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8363 cmdline_parse_token_string_t cmd_flex_filter_len =
8364 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8366 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8367 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8369 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8370 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8372 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8373 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8375 cmdline_parse_token_string_t cmd_flex_filter_mask =
8376 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8378 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8379 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8381 cmdline_parse_token_string_t cmd_flex_filter_priority =
8382 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8383 priority, "priority");
8384 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8385 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8386 priority_value, UINT8);
8387 cmdline_parse_token_string_t cmd_flex_filter_queue =
8388 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8390 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8391 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8393 cmdline_parse_inst_t cmd_flex_filter = {
8394 .f = cmd_flex_filter_parsed,
8396 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8397 "<value> mask <value> priority <value> queue <queue_id>: "
8398 "Add/Del a flex filter",
8400 (void *)&cmd_flex_filter_filter,
8401 (void *)&cmd_flex_filter_port_id,
8402 (void *)&cmd_flex_filter_ops,
8403 (void *)&cmd_flex_filter_len,
8404 (void *)&cmd_flex_filter_len_value,
8405 (void *)&cmd_flex_filter_bytes,
8406 (void *)&cmd_flex_filter_bytes_value,
8407 (void *)&cmd_flex_filter_mask,
8408 (void *)&cmd_flex_filter_mask_value,
8409 (void *)&cmd_flex_filter_priority,
8410 (void *)&cmd_flex_filter_priority_value,
8411 (void *)&cmd_flex_filter_queue,
8412 (void *)&cmd_flex_filter_queue_id,
8417 /* *** Filters Control *** */
8419 /* *** deal with ethertype filter *** */
8420 struct cmd_ethertype_filter_result {
8421 cmdline_fixed_string_t filter;
8423 cmdline_fixed_string_t ops;
8424 cmdline_fixed_string_t mac;
8425 struct ether_addr mac_addr;
8426 cmdline_fixed_string_t ethertype;
8427 uint16_t ethertype_value;
8428 cmdline_fixed_string_t drop;
8429 cmdline_fixed_string_t queue;
8433 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8434 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8435 filter, "ethertype_filter");
8436 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8437 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8439 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8440 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8442 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8443 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8444 mac, "mac_addr#mac_ignr");
8445 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8446 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8448 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8449 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8450 ethertype, "ethertype");
8451 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8452 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8453 ethertype_value, UINT16);
8454 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8455 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8457 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8458 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8460 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8461 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8465 cmd_ethertype_filter_parsed(void *parsed_result,
8466 __attribute__((unused)) struct cmdline *cl,
8467 __attribute__((unused)) void *data)
8469 struct cmd_ethertype_filter_result *res = parsed_result;
8470 struct rte_eth_ethertype_filter filter;
8473 ret = rte_eth_dev_filter_supported(res->port_id,
8474 RTE_ETH_FILTER_ETHERTYPE);
8476 printf("ethertype filter is not supported on port %u.\n",
8481 memset(&filter, 0, sizeof(filter));
8482 if (!strcmp(res->mac, "mac_addr")) {
8483 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8484 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8485 sizeof(struct ether_addr));
8487 if (!strcmp(res->drop, "drop"))
8488 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8489 filter.ether_type = res->ethertype_value;
8490 filter.queue = res->queue_id;
8492 if (!strcmp(res->ops, "add"))
8493 ret = rte_eth_dev_filter_ctrl(res->port_id,
8494 RTE_ETH_FILTER_ETHERTYPE,
8498 ret = rte_eth_dev_filter_ctrl(res->port_id,
8499 RTE_ETH_FILTER_ETHERTYPE,
8500 RTE_ETH_FILTER_DELETE,
8503 printf("ethertype filter programming error: (%s)\n",
8507 cmdline_parse_inst_t cmd_ethertype_filter = {
8508 .f = cmd_ethertype_filter_parsed,
8510 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8511 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8512 "Add or delete an ethertype filter entry",
8514 (void *)&cmd_ethertype_filter_filter,
8515 (void *)&cmd_ethertype_filter_port_id,
8516 (void *)&cmd_ethertype_filter_ops,
8517 (void *)&cmd_ethertype_filter_mac,
8518 (void *)&cmd_ethertype_filter_mac_addr,
8519 (void *)&cmd_ethertype_filter_ethertype,
8520 (void *)&cmd_ethertype_filter_ethertype_value,
8521 (void *)&cmd_ethertype_filter_drop,
8522 (void *)&cmd_ethertype_filter_queue,
8523 (void *)&cmd_ethertype_filter_queue_id,
8528 /* *** deal with flow director filter *** */
8529 struct cmd_flow_director_result {
8530 cmdline_fixed_string_t flow_director_filter;
8532 cmdline_fixed_string_t mode;
8533 cmdline_fixed_string_t mode_value;
8534 cmdline_fixed_string_t ops;
8535 cmdline_fixed_string_t flow;
8536 cmdline_fixed_string_t flow_type;
8537 cmdline_fixed_string_t ether;
8538 uint16_t ether_type;
8539 cmdline_fixed_string_t src;
8540 cmdline_ipaddr_t ip_src;
8542 cmdline_fixed_string_t dst;
8543 cmdline_ipaddr_t ip_dst;
8545 cmdline_fixed_string_t verify_tag;
8546 uint32_t verify_tag_value;
8547 cmdline_ipaddr_t tos;
8549 cmdline_ipaddr_t proto;
8550 uint8_t proto_value;
8551 cmdline_ipaddr_t ttl;
8553 cmdline_fixed_string_t vlan;
8554 uint16_t vlan_value;
8555 cmdline_fixed_string_t flexbytes;
8556 cmdline_fixed_string_t flexbytes_value;
8557 cmdline_fixed_string_t pf_vf;
8558 cmdline_fixed_string_t drop;
8559 cmdline_fixed_string_t queue;
8561 cmdline_fixed_string_t fd_id;
8562 uint32_t fd_id_value;
8563 cmdline_fixed_string_t mac;
8564 struct ether_addr mac_addr;
8565 cmdline_fixed_string_t tunnel;
8566 cmdline_fixed_string_t tunnel_type;
8567 cmdline_fixed_string_t tunnel_id;
8568 uint32_t tunnel_id_value;
8572 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8575 const char *p, *p0 = q_arg;
8577 unsigned long int_fld;
8578 char *str_fld[max_num];
8583 p = strchr(p0, '(');
8587 p0 = strchr(p, ')');
8592 if (size >= sizeof(s))
8595 snprintf(s, sizeof(s), "%.*s", size, p);
8596 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8597 if (ret < 0 || ret > max_num)
8599 for (i = 0; i < ret; i++) {
8601 int_fld = strtoul(str_fld[i], &end, 0);
8602 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8604 flexbytes[i] = (uint8_t)int_fld;
8610 str2flowtype(char *string)
8613 static const struct {
8616 } flowtype_str[] = {
8617 {"raw", RTE_ETH_FLOW_RAW},
8618 {"ipv4", RTE_ETH_FLOW_IPV4},
8619 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8620 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8621 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8622 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8623 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8624 {"ipv6", RTE_ETH_FLOW_IPV6},
8625 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8626 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8627 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8628 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8629 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8630 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8633 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8634 if (!strcmp(flowtype_str[i].str, string))
8635 return flowtype_str[i].type;
8637 return RTE_ETH_FLOW_UNKNOWN;
8640 static enum rte_eth_fdir_tunnel_type
8641 str2fdir_tunneltype(char *string)
8645 static const struct {
8647 enum rte_eth_fdir_tunnel_type type;
8648 } tunneltype_str[] = {
8649 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8650 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8653 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8654 if (!strcmp(tunneltype_str[i].str, string))
8655 return tunneltype_str[i].type;
8657 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8660 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8662 if ((ip_addr).family == AF_INET) \
8663 (ip) = (ip_addr).addr.ipv4.s_addr; \
8665 printf("invalid parameter.\n"); \
8670 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8672 if ((ip_addr).family == AF_INET6) \
8673 (void)rte_memcpy(&(ip), \
8674 &((ip_addr).addr.ipv6), \
8675 sizeof(struct in6_addr)); \
8677 printf("invalid parameter.\n"); \
8683 cmd_flow_director_filter_parsed(void *parsed_result,
8684 __attribute__((unused)) struct cmdline *cl,
8685 __attribute__((unused)) void *data)
8687 struct cmd_flow_director_result *res = parsed_result;
8688 struct rte_eth_fdir_filter entry;
8689 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8691 unsigned long vf_id;
8694 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8696 printf("flow director is not supported on port %u.\n",
8700 memset(flexbytes, 0, sizeof(flexbytes));
8701 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8703 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8704 if (strcmp(res->mode_value, "MAC-VLAN")) {
8705 printf("Please set mode to MAC-VLAN.\n");
8708 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8709 if (strcmp(res->mode_value, "Tunnel")) {
8710 printf("Please set mode to Tunnel.\n");
8714 if (strcmp(res->mode_value, "IP")) {
8715 printf("Please set mode to IP.\n");
8718 entry.input.flow_type = str2flowtype(res->flow_type);
8721 ret = parse_flexbytes(res->flexbytes_value,
8723 RTE_ETH_FDIR_MAX_FLEXLEN);
8725 printf("error: Cannot parse flexbytes input.\n");
8729 switch (entry.input.flow_type) {
8730 case RTE_ETH_FLOW_FRAG_IPV4:
8731 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8732 entry.input.flow.ip4_flow.proto = res->proto_value;
8733 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8734 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8735 IPV4_ADDR_TO_UINT(res->ip_dst,
8736 entry.input.flow.ip4_flow.dst_ip);
8737 IPV4_ADDR_TO_UINT(res->ip_src,
8738 entry.input.flow.ip4_flow.src_ip);
8739 entry.input.flow.ip4_flow.tos = res->tos_value;
8740 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8741 /* need convert to big endian. */
8742 entry.input.flow.udp4_flow.dst_port =
8743 rte_cpu_to_be_16(res->port_dst);
8744 entry.input.flow.udp4_flow.src_port =
8745 rte_cpu_to_be_16(res->port_src);
8747 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8748 IPV4_ADDR_TO_UINT(res->ip_dst,
8749 entry.input.flow.sctp4_flow.ip.dst_ip);
8750 IPV4_ADDR_TO_UINT(res->ip_src,
8751 entry.input.flow.sctp4_flow.ip.src_ip);
8752 entry.input.flow.ip4_flow.tos = res->tos_value;
8753 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8754 /* need convert to big endian. */
8755 entry.input.flow.sctp4_flow.dst_port =
8756 rte_cpu_to_be_16(res->port_dst);
8757 entry.input.flow.sctp4_flow.src_port =
8758 rte_cpu_to_be_16(res->port_src);
8759 entry.input.flow.sctp4_flow.verify_tag =
8760 rte_cpu_to_be_32(res->verify_tag_value);
8762 case RTE_ETH_FLOW_FRAG_IPV6:
8763 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8764 entry.input.flow.ipv6_flow.proto = res->proto_value;
8765 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8766 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8767 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8768 entry.input.flow.ipv6_flow.dst_ip);
8769 IPV6_ADDR_TO_ARRAY(res->ip_src,
8770 entry.input.flow.ipv6_flow.src_ip);
8771 entry.input.flow.ipv6_flow.tc = res->tos_value;
8772 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8773 /* need convert to big endian. */
8774 entry.input.flow.udp6_flow.dst_port =
8775 rte_cpu_to_be_16(res->port_dst);
8776 entry.input.flow.udp6_flow.src_port =
8777 rte_cpu_to_be_16(res->port_src);
8779 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8780 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8781 entry.input.flow.sctp6_flow.ip.dst_ip);
8782 IPV6_ADDR_TO_ARRAY(res->ip_src,
8783 entry.input.flow.sctp6_flow.ip.src_ip);
8784 entry.input.flow.ipv6_flow.tc = res->tos_value;
8785 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8786 /* need convert to big endian. */
8787 entry.input.flow.sctp6_flow.dst_port =
8788 rte_cpu_to_be_16(res->port_dst);
8789 entry.input.flow.sctp6_flow.src_port =
8790 rte_cpu_to_be_16(res->port_src);
8791 entry.input.flow.sctp6_flow.verify_tag =
8792 rte_cpu_to_be_32(res->verify_tag_value);
8794 case RTE_ETH_FLOW_L2_PAYLOAD:
8795 entry.input.flow.l2_flow.ether_type =
8796 rte_cpu_to_be_16(res->ether_type);
8802 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8803 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8805 sizeof(struct ether_addr));
8807 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8808 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8810 sizeof(struct ether_addr));
8811 entry.input.flow.tunnel_flow.tunnel_type =
8812 str2fdir_tunneltype(res->tunnel_type);
8813 entry.input.flow.tunnel_flow.tunnel_id =
8814 rte_cpu_to_be_32(res->tunnel_id_value);
8817 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8819 RTE_ETH_FDIR_MAX_FLEXLEN);
8821 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8823 entry.action.flex_off = 0; /*use 0 by default */
8824 if (!strcmp(res->drop, "drop"))
8825 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8827 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8829 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8830 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8831 if (!strcmp(res->pf_vf, "pf"))
8832 entry.input.flow_ext.is_vf = 0;
8833 else if (!strncmp(res->pf_vf, "vf", 2)) {
8834 struct rte_eth_dev_info dev_info;
8836 memset(&dev_info, 0, sizeof(dev_info));
8837 rte_eth_dev_info_get(res->port_id, &dev_info);
8839 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8840 if (errno != 0 || *end != '\0' ||
8841 vf_id >= dev_info.max_vfs) {
8842 printf("invalid parameter %s.\n", res->pf_vf);
8845 entry.input.flow_ext.is_vf = 1;
8846 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8848 printf("invalid parameter %s.\n", res->pf_vf);
8853 /* set to report FD ID by default */
8854 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8855 entry.action.rx_queue = res->queue_id;
8856 entry.soft_id = res->fd_id_value;
8857 if (!strcmp(res->ops, "add"))
8858 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8859 RTE_ETH_FILTER_ADD, &entry);
8860 else if (!strcmp(res->ops, "del"))
8861 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8862 RTE_ETH_FILTER_DELETE, &entry);
8864 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8865 RTE_ETH_FILTER_UPDATE, &entry);
8867 printf("flow director programming error: (%s)\n",
8871 cmdline_parse_token_string_t cmd_flow_director_filter =
8872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8873 flow_director_filter, "flow_director_filter");
8874 cmdline_parse_token_num_t cmd_flow_director_port_id =
8875 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8877 cmdline_parse_token_string_t cmd_flow_director_ops =
8878 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8879 ops, "add#del#update");
8880 cmdline_parse_token_string_t cmd_flow_director_flow =
8881 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8883 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8884 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8885 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8886 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8887 cmdline_parse_token_string_t cmd_flow_director_ether =
8888 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8890 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8891 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8892 ether_type, UINT16);
8893 cmdline_parse_token_string_t cmd_flow_director_src =
8894 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8896 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8897 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8899 cmdline_parse_token_num_t cmd_flow_director_port_src =
8900 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8902 cmdline_parse_token_string_t cmd_flow_director_dst =
8903 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8905 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8906 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8908 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8909 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8911 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8912 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8913 verify_tag, "verify_tag");
8914 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8915 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8916 verify_tag_value, UINT32);
8917 cmdline_parse_token_string_t cmd_flow_director_tos =
8918 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8920 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8921 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8923 cmdline_parse_token_string_t cmd_flow_director_proto =
8924 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8926 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8927 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8928 proto_value, UINT8);
8929 cmdline_parse_token_string_t cmd_flow_director_ttl =
8930 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8932 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8933 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8935 cmdline_parse_token_string_t cmd_flow_director_vlan =
8936 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8938 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8939 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8940 vlan_value, UINT16);
8941 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8942 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8943 flexbytes, "flexbytes");
8944 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8945 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8946 flexbytes_value, NULL);
8947 cmdline_parse_token_string_t cmd_flow_director_drop =
8948 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8950 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8951 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8953 cmdline_parse_token_string_t cmd_flow_director_queue =
8954 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8956 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8957 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8959 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8960 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8962 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8963 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8964 fd_id_value, UINT32);
8966 cmdline_parse_token_string_t cmd_flow_director_mode =
8967 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8969 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8970 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8972 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8973 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8974 mode_value, "MAC-VLAN");
8975 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8976 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8977 mode_value, "Tunnel");
8978 cmdline_parse_token_string_t cmd_flow_director_mac =
8979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8981 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8982 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8984 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8985 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8987 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8988 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8989 tunnel_type, "NVGRE#VxLAN");
8990 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8991 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8992 tunnel_id, "tunnel-id");
8993 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8994 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8995 tunnel_id_value, UINT32);
8997 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8998 .f = cmd_flow_director_filter_parsed,
9000 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9001 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9002 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9003 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9004 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9005 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9006 "fd_id <fd_id_value>: "
9007 "Add or delete an ip flow director entry on NIC",
9009 (void *)&cmd_flow_director_filter,
9010 (void *)&cmd_flow_director_port_id,
9011 (void *)&cmd_flow_director_mode,
9012 (void *)&cmd_flow_director_mode_ip,
9013 (void *)&cmd_flow_director_ops,
9014 (void *)&cmd_flow_director_flow,
9015 (void *)&cmd_flow_director_flow_type,
9016 (void *)&cmd_flow_director_src,
9017 (void *)&cmd_flow_director_ip_src,
9018 (void *)&cmd_flow_director_dst,
9019 (void *)&cmd_flow_director_ip_dst,
9020 (void *)&cmd_flow_director_tos,
9021 (void *)&cmd_flow_director_tos_value,
9022 (void *)&cmd_flow_director_proto,
9023 (void *)&cmd_flow_director_proto_value,
9024 (void *)&cmd_flow_director_ttl,
9025 (void *)&cmd_flow_director_ttl_value,
9026 (void *)&cmd_flow_director_vlan,
9027 (void *)&cmd_flow_director_vlan_value,
9028 (void *)&cmd_flow_director_flexbytes,
9029 (void *)&cmd_flow_director_flexbytes_value,
9030 (void *)&cmd_flow_director_drop,
9031 (void *)&cmd_flow_director_pf_vf,
9032 (void *)&cmd_flow_director_queue,
9033 (void *)&cmd_flow_director_queue_id,
9034 (void *)&cmd_flow_director_fd_id,
9035 (void *)&cmd_flow_director_fd_id_value,
9040 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9041 .f = cmd_flow_director_filter_parsed,
9043 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9044 "director entry on NIC",
9046 (void *)&cmd_flow_director_filter,
9047 (void *)&cmd_flow_director_port_id,
9048 (void *)&cmd_flow_director_mode,
9049 (void *)&cmd_flow_director_mode_ip,
9050 (void *)&cmd_flow_director_ops,
9051 (void *)&cmd_flow_director_flow,
9052 (void *)&cmd_flow_director_flow_type,
9053 (void *)&cmd_flow_director_src,
9054 (void *)&cmd_flow_director_ip_src,
9055 (void *)&cmd_flow_director_port_src,
9056 (void *)&cmd_flow_director_dst,
9057 (void *)&cmd_flow_director_ip_dst,
9058 (void *)&cmd_flow_director_port_dst,
9059 (void *)&cmd_flow_director_tos,
9060 (void *)&cmd_flow_director_tos_value,
9061 (void *)&cmd_flow_director_ttl,
9062 (void *)&cmd_flow_director_ttl_value,
9063 (void *)&cmd_flow_director_vlan,
9064 (void *)&cmd_flow_director_vlan_value,
9065 (void *)&cmd_flow_director_flexbytes,
9066 (void *)&cmd_flow_director_flexbytes_value,
9067 (void *)&cmd_flow_director_drop,
9068 (void *)&cmd_flow_director_pf_vf,
9069 (void *)&cmd_flow_director_queue,
9070 (void *)&cmd_flow_director_queue_id,
9071 (void *)&cmd_flow_director_fd_id,
9072 (void *)&cmd_flow_director_fd_id_value,
9077 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9078 .f = cmd_flow_director_filter_parsed,
9080 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9081 "director entry on NIC",
9083 (void *)&cmd_flow_director_filter,
9084 (void *)&cmd_flow_director_port_id,
9085 (void *)&cmd_flow_director_mode,
9086 (void *)&cmd_flow_director_mode_ip,
9087 (void *)&cmd_flow_director_ops,
9088 (void *)&cmd_flow_director_flow,
9089 (void *)&cmd_flow_director_flow_type,
9090 (void *)&cmd_flow_director_src,
9091 (void *)&cmd_flow_director_ip_src,
9092 (void *)&cmd_flow_director_port_dst,
9093 (void *)&cmd_flow_director_dst,
9094 (void *)&cmd_flow_director_ip_dst,
9095 (void *)&cmd_flow_director_port_dst,
9096 (void *)&cmd_flow_director_verify_tag,
9097 (void *)&cmd_flow_director_verify_tag_value,
9098 (void *)&cmd_flow_director_tos,
9099 (void *)&cmd_flow_director_tos_value,
9100 (void *)&cmd_flow_director_ttl,
9101 (void *)&cmd_flow_director_ttl_value,
9102 (void *)&cmd_flow_director_vlan,
9103 (void *)&cmd_flow_director_vlan_value,
9104 (void *)&cmd_flow_director_flexbytes,
9105 (void *)&cmd_flow_director_flexbytes_value,
9106 (void *)&cmd_flow_director_drop,
9107 (void *)&cmd_flow_director_pf_vf,
9108 (void *)&cmd_flow_director_queue,
9109 (void *)&cmd_flow_director_queue_id,
9110 (void *)&cmd_flow_director_fd_id,
9111 (void *)&cmd_flow_director_fd_id_value,
9116 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9117 .f = cmd_flow_director_filter_parsed,
9119 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9120 "director entry on NIC",
9122 (void *)&cmd_flow_director_filter,
9123 (void *)&cmd_flow_director_port_id,
9124 (void *)&cmd_flow_director_mode,
9125 (void *)&cmd_flow_director_mode_ip,
9126 (void *)&cmd_flow_director_ops,
9127 (void *)&cmd_flow_director_flow,
9128 (void *)&cmd_flow_director_flow_type,
9129 (void *)&cmd_flow_director_ether,
9130 (void *)&cmd_flow_director_ether_type,
9131 (void *)&cmd_flow_director_flexbytes,
9132 (void *)&cmd_flow_director_flexbytes_value,
9133 (void *)&cmd_flow_director_drop,
9134 (void *)&cmd_flow_director_pf_vf,
9135 (void *)&cmd_flow_director_queue,
9136 (void *)&cmd_flow_director_queue_id,
9137 (void *)&cmd_flow_director_fd_id,
9138 (void *)&cmd_flow_director_fd_id_value,
9143 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9144 .f = cmd_flow_director_filter_parsed,
9146 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9147 "director entry on NIC",
9149 (void *)&cmd_flow_director_filter,
9150 (void *)&cmd_flow_director_port_id,
9151 (void *)&cmd_flow_director_mode,
9152 (void *)&cmd_flow_director_mode_mac_vlan,
9153 (void *)&cmd_flow_director_ops,
9154 (void *)&cmd_flow_director_mac,
9155 (void *)&cmd_flow_director_mac_addr,
9156 (void *)&cmd_flow_director_vlan,
9157 (void *)&cmd_flow_director_vlan_value,
9158 (void *)&cmd_flow_director_flexbytes,
9159 (void *)&cmd_flow_director_flexbytes_value,
9160 (void *)&cmd_flow_director_drop,
9161 (void *)&cmd_flow_director_queue,
9162 (void *)&cmd_flow_director_queue_id,
9163 (void *)&cmd_flow_director_fd_id,
9164 (void *)&cmd_flow_director_fd_id_value,
9169 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9170 .f = cmd_flow_director_filter_parsed,
9172 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9173 "director entry on NIC",
9175 (void *)&cmd_flow_director_filter,
9176 (void *)&cmd_flow_director_port_id,
9177 (void *)&cmd_flow_director_mode,
9178 (void *)&cmd_flow_director_mode_tunnel,
9179 (void *)&cmd_flow_director_ops,
9180 (void *)&cmd_flow_director_mac,
9181 (void *)&cmd_flow_director_mac_addr,
9182 (void *)&cmd_flow_director_vlan,
9183 (void *)&cmd_flow_director_vlan_value,
9184 (void *)&cmd_flow_director_tunnel,
9185 (void *)&cmd_flow_director_tunnel_type,
9186 (void *)&cmd_flow_director_tunnel_id,
9187 (void *)&cmd_flow_director_tunnel_id_value,
9188 (void *)&cmd_flow_director_flexbytes,
9189 (void *)&cmd_flow_director_flexbytes_value,
9190 (void *)&cmd_flow_director_drop,
9191 (void *)&cmd_flow_director_queue,
9192 (void *)&cmd_flow_director_queue_id,
9193 (void *)&cmd_flow_director_fd_id,
9194 (void *)&cmd_flow_director_fd_id_value,
9199 struct cmd_flush_flow_director_result {
9200 cmdline_fixed_string_t flush_flow_director;
9204 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9205 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9206 flush_flow_director, "flush_flow_director");
9207 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9208 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9212 cmd_flush_flow_director_parsed(void *parsed_result,
9213 __attribute__((unused)) struct cmdline *cl,
9214 __attribute__((unused)) void *data)
9216 struct cmd_flow_director_result *res = parsed_result;
9219 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9221 printf("flow director is not supported on port %u.\n",
9226 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9227 RTE_ETH_FILTER_FLUSH, NULL);
9229 printf("flow director table flushing error: (%s)\n",
9233 cmdline_parse_inst_t cmd_flush_flow_director = {
9234 .f = cmd_flush_flow_director_parsed,
9236 .help_str = "flush_flow_director <port_id>: "
9237 "Flush all flow director entries of a device on NIC",
9239 (void *)&cmd_flush_flow_director_flush,
9240 (void *)&cmd_flush_flow_director_port_id,
9245 /* *** deal with flow director mask *** */
9246 struct cmd_flow_director_mask_result {
9247 cmdline_fixed_string_t flow_director_mask;
9249 cmdline_fixed_string_t mode;
9250 cmdline_fixed_string_t mode_value;
9251 cmdline_fixed_string_t vlan;
9253 cmdline_fixed_string_t src_mask;
9254 cmdline_ipaddr_t ipv4_src;
9255 cmdline_ipaddr_t ipv6_src;
9257 cmdline_fixed_string_t dst_mask;
9258 cmdline_ipaddr_t ipv4_dst;
9259 cmdline_ipaddr_t ipv6_dst;
9261 cmdline_fixed_string_t mac;
9262 uint8_t mac_addr_byte_mask;
9263 cmdline_fixed_string_t tunnel_id;
9264 uint32_t tunnel_id_mask;
9265 cmdline_fixed_string_t tunnel_type;
9266 uint8_t tunnel_type_mask;
9270 cmd_flow_director_mask_parsed(void *parsed_result,
9271 __attribute__((unused)) struct cmdline *cl,
9272 __attribute__((unused)) void *data)
9274 struct cmd_flow_director_mask_result *res = parsed_result;
9275 struct rte_eth_fdir_masks *mask;
9276 struct rte_port *port;
9278 if (res->port_id > nb_ports) {
9279 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9283 port = &ports[res->port_id];
9284 /** Check if the port is not started **/
9285 if (port->port_status != RTE_PORT_STOPPED) {
9286 printf("Please stop port %d first\n", res->port_id);
9290 mask = &port->dev_conf.fdir_conf.mask;
9292 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9293 if (strcmp(res->mode_value, "MAC-VLAN")) {
9294 printf("Please set mode to MAC-VLAN.\n");
9298 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9299 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9300 if (strcmp(res->mode_value, "Tunnel")) {
9301 printf("Please set mode to Tunnel.\n");
9305 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9306 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9307 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9308 mask->tunnel_type_mask = res->tunnel_type_mask;
9310 if (strcmp(res->mode_value, "IP")) {
9311 printf("Please set mode to IP.\n");
9315 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9316 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9317 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9318 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9319 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9320 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9321 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9324 cmd_reconfig_device_queue(res->port_id, 1, 1);
9327 cmdline_parse_token_string_t cmd_flow_director_mask =
9328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9329 flow_director_mask, "flow_director_mask");
9330 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9331 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9333 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9336 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9337 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9339 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9341 src_mask, "src_mask");
9342 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9343 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9345 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9346 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9348 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9349 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9351 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9353 dst_mask, "dst_mask");
9354 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9355 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9357 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9358 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9360 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9361 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9364 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9367 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9370 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9372 mode_value, "MAC-VLAN");
9373 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9375 mode_value, "Tunnel");
9376 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9379 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9380 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9381 mac_addr_byte_mask, UINT8);
9382 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9384 tunnel_type, "tunnel-type");
9385 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9386 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9387 tunnel_type_mask, UINT8);
9388 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9389 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9390 tunnel_id, "tunnel-id");
9391 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9392 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9393 tunnel_id_mask, UINT32);
9395 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9396 .f = cmd_flow_director_mask_parsed,
9398 .help_str = "flow_director_mask ... : "
9399 "Set IP mode flow director's mask on NIC",
9401 (void *)&cmd_flow_director_mask,
9402 (void *)&cmd_flow_director_mask_port_id,
9403 (void *)&cmd_flow_director_mask_mode,
9404 (void *)&cmd_flow_director_mask_mode_ip,
9405 (void *)&cmd_flow_director_mask_vlan,
9406 (void *)&cmd_flow_director_mask_vlan_value,
9407 (void *)&cmd_flow_director_mask_src,
9408 (void *)&cmd_flow_director_mask_ipv4_src,
9409 (void *)&cmd_flow_director_mask_ipv6_src,
9410 (void *)&cmd_flow_director_mask_port_src,
9411 (void *)&cmd_flow_director_mask_dst,
9412 (void *)&cmd_flow_director_mask_ipv4_dst,
9413 (void *)&cmd_flow_director_mask_ipv6_dst,
9414 (void *)&cmd_flow_director_mask_port_dst,
9419 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9420 .f = cmd_flow_director_mask_parsed,
9422 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9423 "flow director's mask on NIC",
9425 (void *)&cmd_flow_director_mask,
9426 (void *)&cmd_flow_director_mask_port_id,
9427 (void *)&cmd_flow_director_mask_mode,
9428 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9429 (void *)&cmd_flow_director_mask_vlan,
9430 (void *)&cmd_flow_director_mask_vlan_value,
9435 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9436 .f = cmd_flow_director_mask_parsed,
9438 .help_str = "flow_director_mask ... : Set tunnel mode "
9439 "flow director's mask on NIC",
9441 (void *)&cmd_flow_director_mask,
9442 (void *)&cmd_flow_director_mask_port_id,
9443 (void *)&cmd_flow_director_mask_mode,
9444 (void *)&cmd_flow_director_mask_mode_tunnel,
9445 (void *)&cmd_flow_director_mask_vlan,
9446 (void *)&cmd_flow_director_mask_vlan_value,
9447 (void *)&cmd_flow_director_mask_mac,
9448 (void *)&cmd_flow_director_mask_mac_value,
9449 (void *)&cmd_flow_director_mask_tunnel_type,
9450 (void *)&cmd_flow_director_mask_tunnel_type_value,
9451 (void *)&cmd_flow_director_mask_tunnel_id,
9452 (void *)&cmd_flow_director_mask_tunnel_id_value,
9457 /* *** deal with flow director mask on flexible payload *** */
9458 struct cmd_flow_director_flex_mask_result {
9459 cmdline_fixed_string_t flow_director_flexmask;
9461 cmdline_fixed_string_t flow;
9462 cmdline_fixed_string_t flow_type;
9463 cmdline_fixed_string_t mask;
9467 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9468 __attribute__((unused)) struct cmdline *cl,
9469 __attribute__((unused)) void *data)
9471 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9472 struct rte_eth_fdir_info fdir_info;
9473 struct rte_eth_fdir_flex_mask flex_mask;
9474 struct rte_port *port;
9475 uint32_t flow_type_mask;
9479 if (res->port_id > nb_ports) {
9480 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9484 port = &ports[res->port_id];
9485 /** Check if the port is not started **/
9486 if (port->port_status != RTE_PORT_STOPPED) {
9487 printf("Please stop port %d first\n", res->port_id);
9491 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9492 ret = parse_flexbytes(res->mask,
9494 RTE_ETH_FDIR_MAX_FLEXLEN);
9496 printf("error: Cannot parse mask input.\n");
9500 memset(&fdir_info, 0, sizeof(fdir_info));
9501 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9502 RTE_ETH_FILTER_INFO, &fdir_info);
9504 printf("Cannot get FDir filter info\n");
9508 if (!strcmp(res->flow_type, "none")) {
9509 /* means don't specify the flow type */
9510 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9511 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9512 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9513 0, sizeof(struct rte_eth_fdir_flex_mask));
9514 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9515 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9517 sizeof(struct rte_eth_fdir_flex_mask));
9518 cmd_reconfig_device_queue(res->port_id, 1, 1);
9521 flow_type_mask = fdir_info.flow_types_mask[0];
9522 if (!strcmp(res->flow_type, "all")) {
9523 if (!flow_type_mask) {
9524 printf("No flow type supported\n");
9527 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9528 if (flow_type_mask & (1 << i)) {
9529 flex_mask.flow_type = i;
9530 fdir_set_flex_mask(res->port_id, &flex_mask);
9533 cmd_reconfig_device_queue(res->port_id, 1, 1);
9536 flex_mask.flow_type = str2flowtype(res->flow_type);
9537 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9538 printf("Flow type %s not supported on port %d\n",
9539 res->flow_type, res->port_id);
9542 fdir_set_flex_mask(res->port_id, &flex_mask);
9543 cmd_reconfig_device_queue(res->port_id, 1, 1);
9546 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9547 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9548 flow_director_flexmask,
9549 "flow_director_flex_mask");
9550 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9551 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9553 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9556 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9558 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9559 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9560 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9561 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9564 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9565 .f = cmd_flow_director_flex_mask_parsed,
9567 .help_str = "flow_director_flex_mask ... : "
9568 "Set flow director's flex mask on NIC",
9570 (void *)&cmd_flow_director_flexmask,
9571 (void *)&cmd_flow_director_flexmask_port_id,
9572 (void *)&cmd_flow_director_flexmask_flow,
9573 (void *)&cmd_flow_director_flexmask_flow_type,
9574 (void *)&cmd_flow_director_flexmask_mask,
9579 /* *** deal with flow director flexible payload configuration *** */
9580 struct cmd_flow_director_flexpayload_result {
9581 cmdline_fixed_string_t flow_director_flexpayload;
9583 cmdline_fixed_string_t payload_layer;
9584 cmdline_fixed_string_t payload_cfg;
9588 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9591 const char *p, *p0 = q_arg;
9593 unsigned long int_fld;
9594 char *str_fld[max_num];
9599 p = strchr(p0, '(');
9603 p0 = strchr(p, ')');
9608 if (size >= sizeof(s))
9611 snprintf(s, sizeof(s), "%.*s", size, p);
9612 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9613 if (ret < 0 || ret > max_num)
9615 for (i = 0; i < ret; i++) {
9617 int_fld = strtoul(str_fld[i], &end, 0);
9618 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9620 offsets[i] = (uint16_t)int_fld;
9626 cmd_flow_director_flxpld_parsed(void *parsed_result,
9627 __attribute__((unused)) struct cmdline *cl,
9628 __attribute__((unused)) void *data)
9630 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9631 struct rte_eth_flex_payload_cfg flex_cfg;
9632 struct rte_port *port;
9635 if (res->port_id > nb_ports) {
9636 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9640 port = &ports[res->port_id];
9641 /** Check if the port is not started **/
9642 if (port->port_status != RTE_PORT_STOPPED) {
9643 printf("Please stop port %d first\n", res->port_id);
9647 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9649 if (!strcmp(res->payload_layer, "raw"))
9650 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9651 else if (!strcmp(res->payload_layer, "l2"))
9652 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9653 else if (!strcmp(res->payload_layer, "l3"))
9654 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9655 else if (!strcmp(res->payload_layer, "l4"))
9656 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9658 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9659 RTE_ETH_FDIR_MAX_FLEXLEN);
9661 printf("error: Cannot parse flex payload input.\n");
9665 fdir_set_flex_payload(res->port_id, &flex_cfg);
9666 cmd_reconfig_device_queue(res->port_id, 1, 1);
9669 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9670 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9671 flow_director_flexpayload,
9672 "flow_director_flex_payload");
9673 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9674 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9676 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9677 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9678 payload_layer, "raw#l2#l3#l4");
9679 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9680 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9683 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9684 .f = cmd_flow_director_flxpld_parsed,
9686 .help_str = "flow_director_flexpayload ... : "
9687 "Set flow director's flex payload on NIC",
9689 (void *)&cmd_flow_director_flexpayload,
9690 (void *)&cmd_flow_director_flexpayload_port_id,
9691 (void *)&cmd_flow_director_flexpayload_payload_layer,
9692 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9697 /* Generic flow interface command. */
9698 extern cmdline_parse_inst_t cmd_flow;
9700 /* *** Classification Filters Control *** */
9701 /* *** Get symmetric hash enable per port *** */
9702 struct cmd_get_sym_hash_ena_per_port_result {
9703 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9708 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9709 __rte_unused struct cmdline *cl,
9710 __rte_unused void *data)
9712 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9713 struct rte_eth_hash_filter_info info;
9716 if (rte_eth_dev_filter_supported(res->port_id,
9717 RTE_ETH_FILTER_HASH) < 0) {
9718 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9723 memset(&info, 0, sizeof(info));
9724 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9725 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9726 RTE_ETH_FILTER_GET, &info);
9729 printf("Cannot get symmetric hash enable per port "
9730 "on port %u\n", res->port_id);
9734 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9735 "enabled" : "disabled", res->port_id);
9738 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9739 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9740 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9741 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9742 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9745 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9746 .f = cmd_get_sym_hash_per_port_parsed,
9748 .help_str = "get_sym_hash_ena_per_port <port_id>",
9750 (void *)&cmd_get_sym_hash_ena_per_port_all,
9751 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9756 /* *** Set symmetric hash enable per port *** */
9757 struct cmd_set_sym_hash_ena_per_port_result {
9758 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9759 cmdline_fixed_string_t enable;
9764 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9765 __rte_unused struct cmdline *cl,
9766 __rte_unused void *data)
9768 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9769 struct rte_eth_hash_filter_info info;
9772 if (rte_eth_dev_filter_supported(res->port_id,
9773 RTE_ETH_FILTER_HASH) < 0) {
9774 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9779 memset(&info, 0, sizeof(info));
9780 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9781 if (!strcmp(res->enable, "enable"))
9782 info.info.enable = 1;
9783 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9784 RTE_ETH_FILTER_SET, &info);
9786 printf("Cannot set symmetric hash enable per port on "
9787 "port %u\n", res->port_id);
9790 printf("Symmetric hash has been set to %s on port %u\n",
9791 res->enable, res->port_id);
9794 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9795 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9796 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9797 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9798 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9800 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9801 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9802 enable, "enable#disable");
9804 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9805 .f = cmd_set_sym_hash_per_port_parsed,
9807 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9809 (void *)&cmd_set_sym_hash_ena_per_port_all,
9810 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9811 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9816 /* Get global config of hash function */
9817 struct cmd_get_hash_global_config_result {
9818 cmdline_fixed_string_t get_hash_global_config;
9823 flowtype_to_str(uint16_t ftype)
9830 {"ipv4", RTE_ETH_FLOW_IPV4},
9831 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9832 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9833 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9834 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9835 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9836 {"ipv6", RTE_ETH_FLOW_IPV6},
9837 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9838 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9839 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9840 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9841 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9842 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9843 {"port", RTE_ETH_FLOW_PORT},
9844 {"vxlan", RTE_ETH_FLOW_VXLAN},
9845 {"geneve", RTE_ETH_FLOW_GENEVE},
9846 {"nvgre", RTE_ETH_FLOW_NVGRE},
9849 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9850 if (ftype_table[i].ftype == ftype)
9851 return ftype_table[i].str;
9858 cmd_get_hash_global_config_parsed(void *parsed_result,
9859 __rte_unused struct cmdline *cl,
9860 __rte_unused void *data)
9862 struct cmd_get_hash_global_config_result *res = parsed_result;
9863 struct rte_eth_hash_filter_info info;
9864 uint32_t idx, offset;
9869 if (rte_eth_dev_filter_supported(res->port_id,
9870 RTE_ETH_FILTER_HASH) < 0) {
9871 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9876 memset(&info, 0, sizeof(info));
9877 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9878 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9879 RTE_ETH_FILTER_GET, &info);
9881 printf("Cannot get hash global configurations by port %d\n",
9886 switch (info.info.global_conf.hash_func) {
9887 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9888 printf("Hash function is Toeplitz\n");
9890 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9891 printf("Hash function is Simple XOR\n");
9894 printf("Unknown hash function\n");
9898 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9899 idx = i / UINT32_BIT;
9900 offset = i % UINT32_BIT;
9901 if (!(info.info.global_conf.valid_bit_mask[idx] &
9904 str = flowtype_to_str(i);
9907 printf("Symmetric hash is %s globally for flow type %s "
9909 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9910 (1UL << offset)) ? "enabled" : "disabled"), str,
9915 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9916 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9917 get_hash_global_config, "get_hash_global_config");
9918 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9919 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9922 cmdline_parse_inst_t cmd_get_hash_global_config = {
9923 .f = cmd_get_hash_global_config_parsed,
9925 .help_str = "get_hash_global_config <port_id>",
9927 (void *)&cmd_get_hash_global_config_all,
9928 (void *)&cmd_get_hash_global_config_port_id,
9933 /* Set global config of hash function */
9934 struct cmd_set_hash_global_config_result {
9935 cmdline_fixed_string_t set_hash_global_config;
9937 cmdline_fixed_string_t hash_func;
9938 cmdline_fixed_string_t flow_type;
9939 cmdline_fixed_string_t enable;
9943 cmd_set_hash_global_config_parsed(void *parsed_result,
9944 __rte_unused struct cmdline *cl,
9945 __rte_unused void *data)
9947 struct cmd_set_hash_global_config_result *res = parsed_result;
9948 struct rte_eth_hash_filter_info info;
9949 uint32_t ftype, idx, offset;
9952 if (rte_eth_dev_filter_supported(res->port_id,
9953 RTE_ETH_FILTER_HASH) < 0) {
9954 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9958 memset(&info, 0, sizeof(info));
9959 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9960 if (!strcmp(res->hash_func, "toeplitz"))
9961 info.info.global_conf.hash_func =
9962 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9963 else if (!strcmp(res->hash_func, "simple_xor"))
9964 info.info.global_conf.hash_func =
9965 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9966 else if (!strcmp(res->hash_func, "default"))
9967 info.info.global_conf.hash_func =
9968 RTE_ETH_HASH_FUNCTION_DEFAULT;
9970 ftype = str2flowtype(res->flow_type);
9971 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9972 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9973 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9974 if (!strcmp(res->enable, "enable"))
9975 info.info.global_conf.sym_hash_enable_mask[idx] |=
9977 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9978 RTE_ETH_FILTER_SET, &info);
9980 printf("Cannot set global hash configurations by port %d\n",
9983 printf("Global hash configurations have been set "
9984 "succcessfully by port %d\n", res->port_id);
9987 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9988 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9989 set_hash_global_config, "set_hash_global_config");
9990 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9991 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9993 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9994 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9995 hash_func, "toeplitz#simple_xor#default");
9996 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9997 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9999 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10000 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10001 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10002 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10003 enable, "enable#disable");
10005 cmdline_parse_inst_t cmd_set_hash_global_config = {
10006 .f = cmd_set_hash_global_config_parsed,
10008 .help_str = "set_hash_global_config <port_id> "
10009 "toeplitz|simple_xor|default "
10010 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10011 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10012 "l2_payload enable|disable",
10014 (void *)&cmd_set_hash_global_config_all,
10015 (void *)&cmd_set_hash_global_config_port_id,
10016 (void *)&cmd_set_hash_global_config_hash_func,
10017 (void *)&cmd_set_hash_global_config_flow_type,
10018 (void *)&cmd_set_hash_global_config_enable,
10023 /* Set hash input set */
10024 struct cmd_set_hash_input_set_result {
10025 cmdline_fixed_string_t set_hash_input_set;
10027 cmdline_fixed_string_t flow_type;
10028 cmdline_fixed_string_t inset_field;
10029 cmdline_fixed_string_t select;
10032 static enum rte_eth_input_set_field
10033 str2inset(char *string)
10037 static const struct {
10039 enum rte_eth_input_set_field inset;
10040 } inset_table[] = {
10041 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10042 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10043 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10044 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10045 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10046 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10047 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10048 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10049 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10050 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10051 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10052 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10053 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10054 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10055 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10056 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10057 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10058 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10059 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10060 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10061 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10062 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10063 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10064 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10065 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10066 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10067 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10068 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10069 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10070 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10071 {"none", RTE_ETH_INPUT_SET_NONE},
10074 for (i = 0; i < RTE_DIM(inset_table); i++) {
10075 if (!strcmp(string, inset_table[i].str))
10076 return inset_table[i].inset;
10079 return RTE_ETH_INPUT_SET_UNKNOWN;
10083 cmd_set_hash_input_set_parsed(void *parsed_result,
10084 __rte_unused struct cmdline *cl,
10085 __rte_unused void *data)
10087 struct cmd_set_hash_input_set_result *res = parsed_result;
10088 struct rte_eth_hash_filter_info info;
10090 memset(&info, 0, sizeof(info));
10091 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10092 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10093 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10094 info.info.input_set_conf.inset_size = 1;
10095 if (!strcmp(res->select, "select"))
10096 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10097 else if (!strcmp(res->select, "add"))
10098 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10099 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10100 RTE_ETH_FILTER_SET, &info);
10103 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10104 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10105 set_hash_input_set, "set_hash_input_set");
10106 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10107 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10109 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10110 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10112 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10113 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10114 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10115 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10117 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10118 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10119 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10120 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10121 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10123 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10124 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10125 select, "select#add");
10127 cmdline_parse_inst_t cmd_set_hash_input_set = {
10128 .f = cmd_set_hash_input_set_parsed,
10130 .help_str = "set_hash_input_set <port_id> "
10131 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10132 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10133 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10134 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10135 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10136 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10137 "fld-7th|fld-8th|none select|add",
10139 (void *)&cmd_set_hash_input_set_cmd,
10140 (void *)&cmd_set_hash_input_set_port_id,
10141 (void *)&cmd_set_hash_input_set_flow_type,
10142 (void *)&cmd_set_hash_input_set_field,
10143 (void *)&cmd_set_hash_input_set_select,
10148 /* Set flow director input set */
10149 struct cmd_set_fdir_input_set_result {
10150 cmdline_fixed_string_t set_fdir_input_set;
10152 cmdline_fixed_string_t flow_type;
10153 cmdline_fixed_string_t inset_field;
10154 cmdline_fixed_string_t select;
10158 cmd_set_fdir_input_set_parsed(void *parsed_result,
10159 __rte_unused struct cmdline *cl,
10160 __rte_unused void *data)
10162 struct cmd_set_fdir_input_set_result *res = parsed_result;
10163 struct rte_eth_fdir_filter_info info;
10165 memset(&info, 0, sizeof(info));
10166 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10167 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10168 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10169 info.info.input_set_conf.inset_size = 1;
10170 if (!strcmp(res->select, "select"))
10171 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10172 else if (!strcmp(res->select, "add"))
10173 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10174 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10175 RTE_ETH_FILTER_SET, &info);
10178 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10179 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10180 set_fdir_input_set, "set_fdir_input_set");
10181 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10182 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10184 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10185 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10187 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10188 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10189 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10190 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10192 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10193 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10194 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10195 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10196 "sctp-veri-tag#none");
10197 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10198 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10199 select, "select#add");
10201 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10202 .f = cmd_set_fdir_input_set_parsed,
10204 .help_str = "set_fdir_input_set <port_id> "
10205 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10206 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10207 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10208 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10209 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10210 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10211 "sctp-veri-tag|none select|add",
10213 (void *)&cmd_set_fdir_input_set_cmd,
10214 (void *)&cmd_set_fdir_input_set_port_id,
10215 (void *)&cmd_set_fdir_input_set_flow_type,
10216 (void *)&cmd_set_fdir_input_set_field,
10217 (void *)&cmd_set_fdir_input_set_select,
10222 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10223 struct cmd_mcast_addr_result {
10224 cmdline_fixed_string_t mcast_addr_cmd;
10225 cmdline_fixed_string_t what;
10227 struct ether_addr mc_addr;
10230 static void cmd_mcast_addr_parsed(void *parsed_result,
10231 __attribute__((unused)) struct cmdline *cl,
10232 __attribute__((unused)) void *data)
10234 struct cmd_mcast_addr_result *res = parsed_result;
10236 if (!is_multicast_ether_addr(&res->mc_addr)) {
10237 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10238 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10239 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10240 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10243 if (strcmp(res->what, "add") == 0)
10244 mcast_addr_add(res->port_num, &res->mc_addr);
10246 mcast_addr_remove(res->port_num, &res->mc_addr);
10249 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10250 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10251 mcast_addr_cmd, "mcast_addr");
10252 cmdline_parse_token_string_t cmd_mcast_addr_what =
10253 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10255 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10256 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10257 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10258 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10260 cmdline_parse_inst_t cmd_mcast_addr = {
10261 .f = cmd_mcast_addr_parsed,
10263 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10264 "Add/Remove multicast MAC address on port_id",
10266 (void *)&cmd_mcast_addr_cmd,
10267 (void *)&cmd_mcast_addr_what,
10268 (void *)&cmd_mcast_addr_portnum,
10269 (void *)&cmd_mcast_addr_addr,
10274 /* l2 tunnel config
10275 * only support E-tag now.
10278 /* Ether type config */
10279 struct cmd_config_l2_tunnel_eth_type_result {
10280 cmdline_fixed_string_t port;
10281 cmdline_fixed_string_t config;
10282 cmdline_fixed_string_t all;
10284 cmdline_fixed_string_t l2_tunnel;
10285 cmdline_fixed_string_t l2_tunnel_type;
10286 cmdline_fixed_string_t eth_type;
10287 uint16_t eth_type_val;
10290 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10291 TOKEN_STRING_INITIALIZER
10292 (struct cmd_config_l2_tunnel_eth_type_result,
10294 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10295 TOKEN_STRING_INITIALIZER
10296 (struct cmd_config_l2_tunnel_eth_type_result,
10298 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10299 TOKEN_STRING_INITIALIZER
10300 (struct cmd_config_l2_tunnel_eth_type_result,
10302 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10303 TOKEN_NUM_INITIALIZER
10304 (struct cmd_config_l2_tunnel_eth_type_result,
10306 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10307 TOKEN_STRING_INITIALIZER
10308 (struct cmd_config_l2_tunnel_eth_type_result,
10309 l2_tunnel, "l2-tunnel");
10310 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10311 TOKEN_STRING_INITIALIZER
10312 (struct cmd_config_l2_tunnel_eth_type_result,
10313 l2_tunnel_type, "E-tag");
10314 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10315 TOKEN_STRING_INITIALIZER
10316 (struct cmd_config_l2_tunnel_eth_type_result,
10317 eth_type, "ether-type");
10318 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10319 TOKEN_NUM_INITIALIZER
10320 (struct cmd_config_l2_tunnel_eth_type_result,
10321 eth_type_val, UINT16);
10323 static enum rte_eth_tunnel_type
10324 str2fdir_l2_tunnel_type(char *string)
10328 static const struct {
10330 enum rte_eth_tunnel_type type;
10331 } l2_tunnel_type_str[] = {
10332 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10335 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10336 if (!strcmp(l2_tunnel_type_str[i].str, string))
10337 return l2_tunnel_type_str[i].type;
10339 return RTE_TUNNEL_TYPE_NONE;
10342 /* ether type config for all ports */
10344 cmd_config_l2_tunnel_eth_type_all_parsed
10345 (void *parsed_result,
10346 __attribute__((unused)) struct cmdline *cl,
10347 __attribute__((unused)) void *data)
10349 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10350 struct rte_eth_l2_tunnel_conf entry;
10353 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10354 entry.ether_type = res->eth_type_val;
10356 FOREACH_PORT(pid, ports) {
10357 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10361 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10362 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10364 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10366 (void *)&cmd_config_l2_tunnel_eth_type_port,
10367 (void *)&cmd_config_l2_tunnel_eth_type_config,
10368 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10369 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10370 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10371 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10372 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10377 /* ether type config for a specific port */
10379 cmd_config_l2_tunnel_eth_type_specific_parsed(
10380 void *parsed_result,
10381 __attribute__((unused)) struct cmdline *cl,
10382 __attribute__((unused)) void *data)
10384 struct cmd_config_l2_tunnel_eth_type_result *res =
10386 struct rte_eth_l2_tunnel_conf entry;
10388 if (port_id_is_invalid(res->id, ENABLED_WARN))
10391 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10392 entry.ether_type = res->eth_type_val;
10394 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10397 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10398 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10400 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10402 (void *)&cmd_config_l2_tunnel_eth_type_port,
10403 (void *)&cmd_config_l2_tunnel_eth_type_config,
10404 (void *)&cmd_config_l2_tunnel_eth_type_id,
10405 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10406 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10407 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10408 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10413 /* Enable/disable l2 tunnel */
10414 struct cmd_config_l2_tunnel_en_dis_result {
10415 cmdline_fixed_string_t port;
10416 cmdline_fixed_string_t config;
10417 cmdline_fixed_string_t all;
10419 cmdline_fixed_string_t l2_tunnel;
10420 cmdline_fixed_string_t l2_tunnel_type;
10421 cmdline_fixed_string_t en_dis;
10424 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10425 TOKEN_STRING_INITIALIZER
10426 (struct cmd_config_l2_tunnel_en_dis_result,
10428 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10429 TOKEN_STRING_INITIALIZER
10430 (struct cmd_config_l2_tunnel_en_dis_result,
10432 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10433 TOKEN_STRING_INITIALIZER
10434 (struct cmd_config_l2_tunnel_en_dis_result,
10436 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10437 TOKEN_NUM_INITIALIZER
10438 (struct cmd_config_l2_tunnel_en_dis_result,
10440 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10441 TOKEN_STRING_INITIALIZER
10442 (struct cmd_config_l2_tunnel_en_dis_result,
10443 l2_tunnel, "l2-tunnel");
10444 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10445 TOKEN_STRING_INITIALIZER
10446 (struct cmd_config_l2_tunnel_en_dis_result,
10447 l2_tunnel_type, "E-tag");
10448 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10449 TOKEN_STRING_INITIALIZER
10450 (struct cmd_config_l2_tunnel_en_dis_result,
10451 en_dis, "enable#disable");
10453 /* enable/disable l2 tunnel for all ports */
10455 cmd_config_l2_tunnel_en_dis_all_parsed(
10456 void *parsed_result,
10457 __attribute__((unused)) struct cmdline *cl,
10458 __attribute__((unused)) void *data)
10460 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10461 struct rte_eth_l2_tunnel_conf entry;
10465 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10467 if (!strcmp("enable", res->en_dis))
10472 FOREACH_PORT(pid, ports) {
10473 rte_eth_dev_l2_tunnel_offload_set(pid,
10475 ETH_L2_TUNNEL_ENABLE_MASK,
10480 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10481 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10483 .help_str = "port config all l2-tunnel E-tag enable|disable",
10485 (void *)&cmd_config_l2_tunnel_en_dis_port,
10486 (void *)&cmd_config_l2_tunnel_en_dis_config,
10487 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10488 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10489 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10490 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10495 /* enable/disable l2 tunnel for a port */
10497 cmd_config_l2_tunnel_en_dis_specific_parsed(
10498 void *parsed_result,
10499 __attribute__((unused)) struct cmdline *cl,
10500 __attribute__((unused)) void *data)
10502 struct cmd_config_l2_tunnel_en_dis_result *res =
10504 struct rte_eth_l2_tunnel_conf entry;
10506 if (port_id_is_invalid(res->id, ENABLED_WARN))
10509 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10511 if (!strcmp("enable", res->en_dis))
10512 rte_eth_dev_l2_tunnel_offload_set(res->id,
10514 ETH_L2_TUNNEL_ENABLE_MASK,
10517 rte_eth_dev_l2_tunnel_offload_set(res->id,
10519 ETH_L2_TUNNEL_ENABLE_MASK,
10523 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10524 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10526 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10528 (void *)&cmd_config_l2_tunnel_en_dis_port,
10529 (void *)&cmd_config_l2_tunnel_en_dis_config,
10530 (void *)&cmd_config_l2_tunnel_en_dis_id,
10531 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10532 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10533 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10538 /* E-tag configuration */
10540 /* Common result structure for all E-tag configuration */
10541 struct cmd_config_e_tag_result {
10542 cmdline_fixed_string_t e_tag;
10543 cmdline_fixed_string_t set;
10544 cmdline_fixed_string_t insertion;
10545 cmdline_fixed_string_t stripping;
10546 cmdline_fixed_string_t forwarding;
10547 cmdline_fixed_string_t filter;
10548 cmdline_fixed_string_t add;
10549 cmdline_fixed_string_t del;
10550 cmdline_fixed_string_t on;
10551 cmdline_fixed_string_t off;
10552 cmdline_fixed_string_t on_off;
10553 cmdline_fixed_string_t port_tag_id;
10554 uint32_t port_tag_id_val;
10555 cmdline_fixed_string_t e_tag_id;
10556 uint16_t e_tag_id_val;
10557 cmdline_fixed_string_t dst_pool;
10558 uint8_t dst_pool_val;
10559 cmdline_fixed_string_t port;
10561 cmdline_fixed_string_t vf;
10565 /* Common CLI fields for all E-tag configuration */
10566 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10567 TOKEN_STRING_INITIALIZER
10568 (struct cmd_config_e_tag_result,
10570 cmdline_parse_token_string_t cmd_config_e_tag_set =
10571 TOKEN_STRING_INITIALIZER
10572 (struct cmd_config_e_tag_result,
10574 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10575 TOKEN_STRING_INITIALIZER
10576 (struct cmd_config_e_tag_result,
10577 insertion, "insertion");
10578 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10579 TOKEN_STRING_INITIALIZER
10580 (struct cmd_config_e_tag_result,
10581 stripping, "stripping");
10582 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10583 TOKEN_STRING_INITIALIZER
10584 (struct cmd_config_e_tag_result,
10585 forwarding, "forwarding");
10586 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10587 TOKEN_STRING_INITIALIZER
10588 (struct cmd_config_e_tag_result,
10590 cmdline_parse_token_string_t cmd_config_e_tag_add =
10591 TOKEN_STRING_INITIALIZER
10592 (struct cmd_config_e_tag_result,
10594 cmdline_parse_token_string_t cmd_config_e_tag_del =
10595 TOKEN_STRING_INITIALIZER
10596 (struct cmd_config_e_tag_result,
10598 cmdline_parse_token_string_t cmd_config_e_tag_on =
10599 TOKEN_STRING_INITIALIZER
10600 (struct cmd_config_e_tag_result,
10602 cmdline_parse_token_string_t cmd_config_e_tag_off =
10603 TOKEN_STRING_INITIALIZER
10604 (struct cmd_config_e_tag_result,
10606 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10607 TOKEN_STRING_INITIALIZER
10608 (struct cmd_config_e_tag_result,
10610 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10611 TOKEN_STRING_INITIALIZER
10612 (struct cmd_config_e_tag_result,
10613 port_tag_id, "port-tag-id");
10614 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10615 TOKEN_NUM_INITIALIZER
10616 (struct cmd_config_e_tag_result,
10617 port_tag_id_val, UINT32);
10618 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10619 TOKEN_STRING_INITIALIZER
10620 (struct cmd_config_e_tag_result,
10621 e_tag_id, "e-tag-id");
10622 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10623 TOKEN_NUM_INITIALIZER
10624 (struct cmd_config_e_tag_result,
10625 e_tag_id_val, UINT16);
10626 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10627 TOKEN_STRING_INITIALIZER
10628 (struct cmd_config_e_tag_result,
10629 dst_pool, "dst-pool");
10630 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10631 TOKEN_NUM_INITIALIZER
10632 (struct cmd_config_e_tag_result,
10633 dst_pool_val, UINT8);
10634 cmdline_parse_token_string_t cmd_config_e_tag_port =
10635 TOKEN_STRING_INITIALIZER
10636 (struct cmd_config_e_tag_result,
10638 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10639 TOKEN_NUM_INITIALIZER
10640 (struct cmd_config_e_tag_result,
10642 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10643 TOKEN_STRING_INITIALIZER
10644 (struct cmd_config_e_tag_result,
10646 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10647 TOKEN_NUM_INITIALIZER
10648 (struct cmd_config_e_tag_result,
10651 /* E-tag insertion configuration */
10653 cmd_config_e_tag_insertion_en_parsed(
10654 void *parsed_result,
10655 __attribute__((unused)) struct cmdline *cl,
10656 __attribute__((unused)) void *data)
10658 struct cmd_config_e_tag_result *res =
10660 struct rte_eth_l2_tunnel_conf entry;
10662 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10665 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10666 entry.tunnel_id = res->port_tag_id_val;
10667 entry.vf_id = res->vf_id;
10668 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10670 ETH_L2_TUNNEL_INSERTION_MASK,
10675 cmd_config_e_tag_insertion_dis_parsed(
10676 void *parsed_result,
10677 __attribute__((unused)) struct cmdline *cl,
10678 __attribute__((unused)) void *data)
10680 struct cmd_config_e_tag_result *res =
10682 struct rte_eth_l2_tunnel_conf entry;
10684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10687 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10688 entry.vf_id = res->vf_id;
10690 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10692 ETH_L2_TUNNEL_INSERTION_MASK,
10696 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10697 .f = cmd_config_e_tag_insertion_en_parsed,
10699 .help_str = "E-tag ... : E-tag insertion enable",
10701 (void *)&cmd_config_e_tag_e_tag,
10702 (void *)&cmd_config_e_tag_set,
10703 (void *)&cmd_config_e_tag_insertion,
10704 (void *)&cmd_config_e_tag_on,
10705 (void *)&cmd_config_e_tag_port_tag_id,
10706 (void *)&cmd_config_e_tag_port_tag_id_val,
10707 (void *)&cmd_config_e_tag_port,
10708 (void *)&cmd_config_e_tag_port_id,
10709 (void *)&cmd_config_e_tag_vf,
10710 (void *)&cmd_config_e_tag_vf_id,
10715 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10716 .f = cmd_config_e_tag_insertion_dis_parsed,
10718 .help_str = "E-tag ... : E-tag insertion disable",
10720 (void *)&cmd_config_e_tag_e_tag,
10721 (void *)&cmd_config_e_tag_set,
10722 (void *)&cmd_config_e_tag_insertion,
10723 (void *)&cmd_config_e_tag_off,
10724 (void *)&cmd_config_e_tag_port,
10725 (void *)&cmd_config_e_tag_port_id,
10726 (void *)&cmd_config_e_tag_vf,
10727 (void *)&cmd_config_e_tag_vf_id,
10732 /* E-tag stripping configuration */
10734 cmd_config_e_tag_stripping_parsed(
10735 void *parsed_result,
10736 __attribute__((unused)) struct cmdline *cl,
10737 __attribute__((unused)) void *data)
10739 struct cmd_config_e_tag_result *res =
10741 struct rte_eth_l2_tunnel_conf entry;
10743 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10746 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10748 if (!strcmp(res->on_off, "on"))
10749 rte_eth_dev_l2_tunnel_offload_set
10752 ETH_L2_TUNNEL_STRIPPING_MASK,
10755 rte_eth_dev_l2_tunnel_offload_set
10758 ETH_L2_TUNNEL_STRIPPING_MASK,
10762 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10763 .f = cmd_config_e_tag_stripping_parsed,
10765 .help_str = "E-tag ... : E-tag stripping enable/disable",
10767 (void *)&cmd_config_e_tag_e_tag,
10768 (void *)&cmd_config_e_tag_set,
10769 (void *)&cmd_config_e_tag_stripping,
10770 (void *)&cmd_config_e_tag_on_off,
10771 (void *)&cmd_config_e_tag_port,
10772 (void *)&cmd_config_e_tag_port_id,
10777 /* E-tag forwarding configuration */
10779 cmd_config_e_tag_forwarding_parsed(
10780 void *parsed_result,
10781 __attribute__((unused)) struct cmdline *cl,
10782 __attribute__((unused)) void *data)
10784 struct cmd_config_e_tag_result *res = parsed_result;
10785 struct rte_eth_l2_tunnel_conf entry;
10787 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10790 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10792 if (!strcmp(res->on_off, "on"))
10793 rte_eth_dev_l2_tunnel_offload_set
10796 ETH_L2_TUNNEL_FORWARDING_MASK,
10799 rte_eth_dev_l2_tunnel_offload_set
10802 ETH_L2_TUNNEL_FORWARDING_MASK,
10806 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10807 .f = cmd_config_e_tag_forwarding_parsed,
10809 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10811 (void *)&cmd_config_e_tag_e_tag,
10812 (void *)&cmd_config_e_tag_set,
10813 (void *)&cmd_config_e_tag_forwarding,
10814 (void *)&cmd_config_e_tag_on_off,
10815 (void *)&cmd_config_e_tag_port,
10816 (void *)&cmd_config_e_tag_port_id,
10821 /* E-tag filter configuration */
10823 cmd_config_e_tag_filter_add_parsed(
10824 void *parsed_result,
10825 __attribute__((unused)) struct cmdline *cl,
10826 __attribute__((unused)) void *data)
10828 struct cmd_config_e_tag_result *res = parsed_result;
10829 struct rte_eth_l2_tunnel_conf entry;
10832 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10835 if (res->e_tag_id_val > 0x3fff) {
10836 printf("e-tag-id must be equal or less than 0x3fff.\n");
10840 ret = rte_eth_dev_filter_supported(res->port_id,
10841 RTE_ETH_FILTER_L2_TUNNEL);
10843 printf("E-tag filter is not supported on port %u.\n",
10848 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10849 entry.tunnel_id = res->e_tag_id_val;
10850 entry.pool = res->dst_pool_val;
10852 ret = rte_eth_dev_filter_ctrl(res->port_id,
10853 RTE_ETH_FILTER_L2_TUNNEL,
10854 RTE_ETH_FILTER_ADD,
10857 printf("E-tag filter programming error: (%s)\n",
10861 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10862 .f = cmd_config_e_tag_filter_add_parsed,
10864 .help_str = "E-tag ... : E-tag filter add",
10866 (void *)&cmd_config_e_tag_e_tag,
10867 (void *)&cmd_config_e_tag_set,
10868 (void *)&cmd_config_e_tag_filter,
10869 (void *)&cmd_config_e_tag_add,
10870 (void *)&cmd_config_e_tag_e_tag_id,
10871 (void *)&cmd_config_e_tag_e_tag_id_val,
10872 (void *)&cmd_config_e_tag_dst_pool,
10873 (void *)&cmd_config_e_tag_dst_pool_val,
10874 (void *)&cmd_config_e_tag_port,
10875 (void *)&cmd_config_e_tag_port_id,
10881 cmd_config_e_tag_filter_del_parsed(
10882 void *parsed_result,
10883 __attribute__((unused)) struct cmdline *cl,
10884 __attribute__((unused)) void *data)
10886 struct cmd_config_e_tag_result *res = parsed_result;
10887 struct rte_eth_l2_tunnel_conf entry;
10890 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10893 if (res->e_tag_id_val > 0x3fff) {
10894 printf("e-tag-id must be less than 0x3fff.\n");
10898 ret = rte_eth_dev_filter_supported(res->port_id,
10899 RTE_ETH_FILTER_L2_TUNNEL);
10901 printf("E-tag filter is not supported on port %u.\n",
10906 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10907 entry.tunnel_id = res->e_tag_id_val;
10909 ret = rte_eth_dev_filter_ctrl(res->port_id,
10910 RTE_ETH_FILTER_L2_TUNNEL,
10911 RTE_ETH_FILTER_DELETE,
10914 printf("E-tag filter programming error: (%s)\n",
10918 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10919 .f = cmd_config_e_tag_filter_del_parsed,
10921 .help_str = "E-tag ... : E-tag filter delete",
10923 (void *)&cmd_config_e_tag_e_tag,
10924 (void *)&cmd_config_e_tag_set,
10925 (void *)&cmd_config_e_tag_filter,
10926 (void *)&cmd_config_e_tag_del,
10927 (void *)&cmd_config_e_tag_e_tag_id,
10928 (void *)&cmd_config_e_tag_e_tag_id_val,
10929 (void *)&cmd_config_e_tag_port,
10930 (void *)&cmd_config_e_tag_port_id,
10935 /* vf vlan anti spoof configuration */
10937 /* Common result structure for vf vlan anti spoof */
10938 struct cmd_vf_vlan_anti_spoof_result {
10939 cmdline_fixed_string_t set;
10940 cmdline_fixed_string_t vf;
10941 cmdline_fixed_string_t vlan;
10942 cmdline_fixed_string_t antispoof;
10945 cmdline_fixed_string_t on_off;
10948 /* Common CLI fields for vf vlan anti spoof enable disable */
10949 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10950 TOKEN_STRING_INITIALIZER
10951 (struct cmd_vf_vlan_anti_spoof_result,
10953 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10954 TOKEN_STRING_INITIALIZER
10955 (struct cmd_vf_vlan_anti_spoof_result,
10957 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10958 TOKEN_STRING_INITIALIZER
10959 (struct cmd_vf_vlan_anti_spoof_result,
10961 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10962 TOKEN_STRING_INITIALIZER
10963 (struct cmd_vf_vlan_anti_spoof_result,
10964 antispoof, "antispoof");
10965 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10966 TOKEN_NUM_INITIALIZER
10967 (struct cmd_vf_vlan_anti_spoof_result,
10969 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10970 TOKEN_NUM_INITIALIZER
10971 (struct cmd_vf_vlan_anti_spoof_result,
10973 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10974 TOKEN_STRING_INITIALIZER
10975 (struct cmd_vf_vlan_anti_spoof_result,
10979 cmd_set_vf_vlan_anti_spoof_parsed(
10980 void *parsed_result,
10981 __attribute__((unused)) struct cmdline *cl,
10982 __attribute__((unused)) void *data)
10984 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10985 int ret = -ENOTSUP;
10987 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10989 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10992 #ifdef RTE_LIBRTE_IXGBE_PMD
10993 if (ret == -ENOTSUP)
10994 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10995 res->vf_id, is_on);
10997 #ifdef RTE_LIBRTE_I40E_PMD
10998 if (ret == -ENOTSUP)
10999 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11000 res->vf_id, is_on);
11007 printf("invalid vf_id %d\n", res->vf_id);
11010 printf("invalid port_id %d\n", res->port_id);
11013 printf("function not implemented\n");
11016 printf("programming error: (%s)\n", strerror(-ret));
11020 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11021 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11023 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11025 (void *)&cmd_vf_vlan_anti_spoof_set,
11026 (void *)&cmd_vf_vlan_anti_spoof_vf,
11027 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11028 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11029 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11030 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11031 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11036 /* vf mac anti spoof configuration */
11038 /* Common result structure for vf mac anti spoof */
11039 struct cmd_vf_mac_anti_spoof_result {
11040 cmdline_fixed_string_t set;
11041 cmdline_fixed_string_t vf;
11042 cmdline_fixed_string_t mac;
11043 cmdline_fixed_string_t antispoof;
11046 cmdline_fixed_string_t on_off;
11049 /* Common CLI fields for vf mac anti spoof enable disable */
11050 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11051 TOKEN_STRING_INITIALIZER
11052 (struct cmd_vf_mac_anti_spoof_result,
11054 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11055 TOKEN_STRING_INITIALIZER
11056 (struct cmd_vf_mac_anti_spoof_result,
11058 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11059 TOKEN_STRING_INITIALIZER
11060 (struct cmd_vf_mac_anti_spoof_result,
11062 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11063 TOKEN_STRING_INITIALIZER
11064 (struct cmd_vf_mac_anti_spoof_result,
11065 antispoof, "antispoof");
11066 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11067 TOKEN_NUM_INITIALIZER
11068 (struct cmd_vf_mac_anti_spoof_result,
11070 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11071 TOKEN_NUM_INITIALIZER
11072 (struct cmd_vf_mac_anti_spoof_result,
11074 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11075 TOKEN_STRING_INITIALIZER
11076 (struct cmd_vf_mac_anti_spoof_result,
11080 cmd_set_vf_mac_anti_spoof_parsed(
11081 void *parsed_result,
11082 __attribute__((unused)) struct cmdline *cl,
11083 __attribute__((unused)) void *data)
11085 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11086 int ret = -ENOTSUP;
11088 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11090 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11093 #ifdef RTE_LIBRTE_IXGBE_PMD
11094 if (ret == -ENOTSUP)
11095 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11096 res->vf_id, is_on);
11098 #ifdef RTE_LIBRTE_I40E_PMD
11099 if (ret == -ENOTSUP)
11100 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11101 res->vf_id, is_on);
11108 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11111 printf("invalid port_id %d\n", res->port_id);
11114 printf("function not implemented\n");
11117 printf("programming error: (%s)\n", strerror(-ret));
11121 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11122 .f = cmd_set_vf_mac_anti_spoof_parsed,
11124 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11126 (void *)&cmd_vf_mac_anti_spoof_set,
11127 (void *)&cmd_vf_mac_anti_spoof_vf,
11128 (void *)&cmd_vf_mac_anti_spoof_mac,
11129 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11130 (void *)&cmd_vf_mac_anti_spoof_port_id,
11131 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11132 (void *)&cmd_vf_mac_anti_spoof_on_off,
11137 /* vf vlan strip queue configuration */
11139 /* Common result structure for vf mac anti spoof */
11140 struct cmd_vf_vlan_stripq_result {
11141 cmdline_fixed_string_t set;
11142 cmdline_fixed_string_t vf;
11143 cmdline_fixed_string_t vlan;
11144 cmdline_fixed_string_t stripq;
11147 cmdline_fixed_string_t on_off;
11150 /* Common CLI fields for vf vlan strip enable disable */
11151 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11152 TOKEN_STRING_INITIALIZER
11153 (struct cmd_vf_vlan_stripq_result,
11155 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11156 TOKEN_STRING_INITIALIZER
11157 (struct cmd_vf_vlan_stripq_result,
11159 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11160 TOKEN_STRING_INITIALIZER
11161 (struct cmd_vf_vlan_stripq_result,
11163 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11164 TOKEN_STRING_INITIALIZER
11165 (struct cmd_vf_vlan_stripq_result,
11167 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11168 TOKEN_NUM_INITIALIZER
11169 (struct cmd_vf_vlan_stripq_result,
11171 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11172 TOKEN_NUM_INITIALIZER
11173 (struct cmd_vf_vlan_stripq_result,
11175 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11176 TOKEN_STRING_INITIALIZER
11177 (struct cmd_vf_vlan_stripq_result,
11181 cmd_set_vf_vlan_stripq_parsed(
11182 void *parsed_result,
11183 __attribute__((unused)) struct cmdline *cl,
11184 __attribute__((unused)) void *data)
11186 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11187 int ret = -ENOTSUP;
11189 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11191 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11194 #ifdef RTE_LIBRTE_IXGBE_PMD
11195 if (ret == -ENOTSUP)
11196 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11197 res->vf_id, is_on);
11199 #ifdef RTE_LIBRTE_I40E_PMD
11200 if (ret == -ENOTSUP)
11201 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11202 res->vf_id, is_on);
11209 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11212 printf("invalid port_id %d\n", res->port_id);
11215 printf("function not implemented\n");
11218 printf("programming error: (%s)\n", strerror(-ret));
11222 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11223 .f = cmd_set_vf_vlan_stripq_parsed,
11225 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11227 (void *)&cmd_vf_vlan_stripq_set,
11228 (void *)&cmd_vf_vlan_stripq_vf,
11229 (void *)&cmd_vf_vlan_stripq_vlan,
11230 (void *)&cmd_vf_vlan_stripq_stripq,
11231 (void *)&cmd_vf_vlan_stripq_port_id,
11232 (void *)&cmd_vf_vlan_stripq_vf_id,
11233 (void *)&cmd_vf_vlan_stripq_on_off,
11238 /* vf vlan insert configuration */
11240 /* Common result structure for vf vlan insert */
11241 struct cmd_vf_vlan_insert_result {
11242 cmdline_fixed_string_t set;
11243 cmdline_fixed_string_t vf;
11244 cmdline_fixed_string_t vlan;
11245 cmdline_fixed_string_t insert;
11251 /* Common CLI fields for vf vlan insert enable disable */
11252 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11253 TOKEN_STRING_INITIALIZER
11254 (struct cmd_vf_vlan_insert_result,
11256 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11257 TOKEN_STRING_INITIALIZER
11258 (struct cmd_vf_vlan_insert_result,
11260 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11261 TOKEN_STRING_INITIALIZER
11262 (struct cmd_vf_vlan_insert_result,
11264 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11265 TOKEN_STRING_INITIALIZER
11266 (struct cmd_vf_vlan_insert_result,
11268 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11269 TOKEN_NUM_INITIALIZER
11270 (struct cmd_vf_vlan_insert_result,
11272 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11273 TOKEN_NUM_INITIALIZER
11274 (struct cmd_vf_vlan_insert_result,
11276 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11277 TOKEN_NUM_INITIALIZER
11278 (struct cmd_vf_vlan_insert_result,
11282 cmd_set_vf_vlan_insert_parsed(
11283 void *parsed_result,
11284 __attribute__((unused)) struct cmdline *cl,
11285 __attribute__((unused)) void *data)
11287 struct cmd_vf_vlan_insert_result *res = parsed_result;
11288 int ret = -ENOTSUP;
11290 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11293 #ifdef RTE_LIBRTE_IXGBE_PMD
11294 if (ret == -ENOTSUP)
11295 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11298 #ifdef RTE_LIBRTE_I40E_PMD
11299 if (ret == -ENOTSUP)
11300 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11308 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11311 printf("invalid port_id %d\n", res->port_id);
11314 printf("function not implemented\n");
11317 printf("programming error: (%s)\n", strerror(-ret));
11321 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11322 .f = cmd_set_vf_vlan_insert_parsed,
11324 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11326 (void *)&cmd_vf_vlan_insert_set,
11327 (void *)&cmd_vf_vlan_insert_vf,
11328 (void *)&cmd_vf_vlan_insert_vlan,
11329 (void *)&cmd_vf_vlan_insert_insert,
11330 (void *)&cmd_vf_vlan_insert_port_id,
11331 (void *)&cmd_vf_vlan_insert_vf_id,
11332 (void *)&cmd_vf_vlan_insert_vlan_id,
11337 /* tx loopback configuration */
11339 /* Common result structure for tx loopback */
11340 struct cmd_tx_loopback_result {
11341 cmdline_fixed_string_t set;
11342 cmdline_fixed_string_t tx;
11343 cmdline_fixed_string_t loopback;
11345 cmdline_fixed_string_t on_off;
11348 /* Common CLI fields for tx loopback enable disable */
11349 cmdline_parse_token_string_t cmd_tx_loopback_set =
11350 TOKEN_STRING_INITIALIZER
11351 (struct cmd_tx_loopback_result,
11353 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11354 TOKEN_STRING_INITIALIZER
11355 (struct cmd_tx_loopback_result,
11357 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11358 TOKEN_STRING_INITIALIZER
11359 (struct cmd_tx_loopback_result,
11360 loopback, "loopback");
11361 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11362 TOKEN_NUM_INITIALIZER
11363 (struct cmd_tx_loopback_result,
11365 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11366 TOKEN_STRING_INITIALIZER
11367 (struct cmd_tx_loopback_result,
11371 cmd_set_tx_loopback_parsed(
11372 void *parsed_result,
11373 __attribute__((unused)) struct cmdline *cl,
11374 __attribute__((unused)) void *data)
11376 struct cmd_tx_loopback_result *res = parsed_result;
11377 int ret = -ENOTSUP;
11379 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11381 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11384 #ifdef RTE_LIBRTE_IXGBE_PMD
11385 if (ret == -ENOTSUP)
11386 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11388 #ifdef RTE_LIBRTE_I40E_PMD
11389 if (ret == -ENOTSUP)
11390 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11397 printf("invalid is_on %d\n", is_on);
11400 printf("invalid port_id %d\n", res->port_id);
11403 printf("function not implemented\n");
11406 printf("programming error: (%s)\n", strerror(-ret));
11410 cmdline_parse_inst_t cmd_set_tx_loopback = {
11411 .f = cmd_set_tx_loopback_parsed,
11413 .help_str = "set tx loopback <port_id> on|off",
11415 (void *)&cmd_tx_loopback_set,
11416 (void *)&cmd_tx_loopback_tx,
11417 (void *)&cmd_tx_loopback_loopback,
11418 (void *)&cmd_tx_loopback_port_id,
11419 (void *)&cmd_tx_loopback_on_off,
11424 #ifdef RTE_LIBRTE_IXGBE_PMD
11425 /* all queues drop enable configuration */
11427 /* Common result structure for all queues drop enable */
11428 struct cmd_all_queues_drop_en_result {
11429 cmdline_fixed_string_t set;
11430 cmdline_fixed_string_t all;
11431 cmdline_fixed_string_t queues;
11432 cmdline_fixed_string_t drop;
11434 cmdline_fixed_string_t on_off;
11437 /* Common CLI fields for tx loopback enable disable */
11438 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11439 TOKEN_STRING_INITIALIZER
11440 (struct cmd_all_queues_drop_en_result,
11442 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11443 TOKEN_STRING_INITIALIZER
11444 (struct cmd_all_queues_drop_en_result,
11446 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11447 TOKEN_STRING_INITIALIZER
11448 (struct cmd_all_queues_drop_en_result,
11450 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11451 TOKEN_STRING_INITIALIZER
11452 (struct cmd_all_queues_drop_en_result,
11454 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11455 TOKEN_NUM_INITIALIZER
11456 (struct cmd_all_queues_drop_en_result,
11458 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11459 TOKEN_STRING_INITIALIZER
11460 (struct cmd_all_queues_drop_en_result,
11464 cmd_set_all_queues_drop_en_parsed(
11465 void *parsed_result,
11466 __attribute__((unused)) struct cmdline *cl,
11467 __attribute__((unused)) void *data)
11469 struct cmd_all_queues_drop_en_result *res = parsed_result;
11471 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11473 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11476 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11481 printf("invalid is_on %d\n", is_on);
11484 printf("invalid port_id %d\n", res->port_id);
11487 printf("function not implemented\n");
11490 printf("programming error: (%s)\n", strerror(-ret));
11494 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11495 .f = cmd_set_all_queues_drop_en_parsed,
11497 .help_str = "set all queues drop <port_id> on|off",
11499 (void *)&cmd_all_queues_drop_en_set,
11500 (void *)&cmd_all_queues_drop_en_all,
11501 (void *)&cmd_all_queues_drop_en_queues,
11502 (void *)&cmd_all_queues_drop_en_drop,
11503 (void *)&cmd_all_queues_drop_en_port_id,
11504 (void *)&cmd_all_queues_drop_en_on_off,
11509 /* vf split drop enable configuration */
11511 /* Common result structure for vf split drop enable */
11512 struct cmd_vf_split_drop_en_result {
11513 cmdline_fixed_string_t set;
11514 cmdline_fixed_string_t vf;
11515 cmdline_fixed_string_t split;
11516 cmdline_fixed_string_t drop;
11519 cmdline_fixed_string_t on_off;
11522 /* Common CLI fields for vf split drop enable disable */
11523 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11524 TOKEN_STRING_INITIALIZER
11525 (struct cmd_vf_split_drop_en_result,
11527 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11528 TOKEN_STRING_INITIALIZER
11529 (struct cmd_vf_split_drop_en_result,
11531 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11532 TOKEN_STRING_INITIALIZER
11533 (struct cmd_vf_split_drop_en_result,
11535 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11536 TOKEN_STRING_INITIALIZER
11537 (struct cmd_vf_split_drop_en_result,
11539 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11540 TOKEN_NUM_INITIALIZER
11541 (struct cmd_vf_split_drop_en_result,
11543 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11544 TOKEN_NUM_INITIALIZER
11545 (struct cmd_vf_split_drop_en_result,
11547 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11548 TOKEN_STRING_INITIALIZER
11549 (struct cmd_vf_split_drop_en_result,
11553 cmd_set_vf_split_drop_en_parsed(
11554 void *parsed_result,
11555 __attribute__((unused)) struct cmdline *cl,
11556 __attribute__((unused)) void *data)
11558 struct cmd_vf_split_drop_en_result *res = parsed_result;
11560 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11562 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11565 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11571 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11574 printf("invalid port_id %d\n", res->port_id);
11577 printf("programming error: (%s)\n", strerror(-ret));
11581 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11582 .f = cmd_set_vf_split_drop_en_parsed,
11584 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11586 (void *)&cmd_vf_split_drop_en_set,
11587 (void *)&cmd_vf_split_drop_en_vf,
11588 (void *)&cmd_vf_split_drop_en_split,
11589 (void *)&cmd_vf_split_drop_en_drop,
11590 (void *)&cmd_vf_split_drop_en_port_id,
11591 (void *)&cmd_vf_split_drop_en_vf_id,
11592 (void *)&cmd_vf_split_drop_en_on_off,
11598 /* vf mac address configuration */
11600 /* Common result structure for vf mac address */
11601 struct cmd_set_vf_mac_addr_result {
11602 cmdline_fixed_string_t set;
11603 cmdline_fixed_string_t vf;
11604 cmdline_fixed_string_t mac;
11605 cmdline_fixed_string_t addr;
11608 struct ether_addr mac_addr;
11612 /* Common CLI fields for vf split drop enable disable */
11613 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11614 TOKEN_STRING_INITIALIZER
11615 (struct cmd_set_vf_mac_addr_result,
11617 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11618 TOKEN_STRING_INITIALIZER
11619 (struct cmd_set_vf_mac_addr_result,
11621 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11622 TOKEN_STRING_INITIALIZER
11623 (struct cmd_set_vf_mac_addr_result,
11625 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11626 TOKEN_STRING_INITIALIZER
11627 (struct cmd_set_vf_mac_addr_result,
11629 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11630 TOKEN_NUM_INITIALIZER
11631 (struct cmd_set_vf_mac_addr_result,
11633 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11634 TOKEN_NUM_INITIALIZER
11635 (struct cmd_set_vf_mac_addr_result,
11637 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11638 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11642 cmd_set_vf_mac_addr_parsed(
11643 void *parsed_result,
11644 __attribute__((unused)) struct cmdline *cl,
11645 __attribute__((unused)) void *data)
11647 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11648 int ret = -ENOTSUP;
11650 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11653 #ifdef RTE_LIBRTE_IXGBE_PMD
11654 if (ret == -ENOTSUP)
11655 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11658 #ifdef RTE_LIBRTE_I40E_PMD
11659 if (ret == -ENOTSUP)
11660 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11668 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11671 printf("invalid port_id %d\n", res->port_id);
11674 printf("function not implemented\n");
11677 printf("programming error: (%s)\n", strerror(-ret));
11681 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11682 .f = cmd_set_vf_mac_addr_parsed,
11684 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11686 (void *)&cmd_set_vf_mac_addr_set,
11687 (void *)&cmd_set_vf_mac_addr_vf,
11688 (void *)&cmd_set_vf_mac_addr_mac,
11689 (void *)&cmd_set_vf_mac_addr_addr,
11690 (void *)&cmd_set_vf_mac_addr_port_id,
11691 (void *)&cmd_set_vf_mac_addr_vf_id,
11692 (void *)&cmd_set_vf_mac_addr_mac_addr,
11697 #ifdef RTE_LIBRTE_IXGBE_PMD
11698 /* MACsec configuration */
11700 /* Common result structure for MACsec offload enable */
11701 struct cmd_macsec_offload_on_result {
11702 cmdline_fixed_string_t set;
11703 cmdline_fixed_string_t macsec;
11704 cmdline_fixed_string_t offload;
11706 cmdline_fixed_string_t on;
11707 cmdline_fixed_string_t encrypt;
11708 cmdline_fixed_string_t en_on_off;
11709 cmdline_fixed_string_t replay_protect;
11710 cmdline_fixed_string_t rp_on_off;
11713 /* Common CLI fields for MACsec offload disable */
11714 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11715 TOKEN_STRING_INITIALIZER
11716 (struct cmd_macsec_offload_on_result,
11718 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11719 TOKEN_STRING_INITIALIZER
11720 (struct cmd_macsec_offload_on_result,
11722 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11723 TOKEN_STRING_INITIALIZER
11724 (struct cmd_macsec_offload_on_result,
11725 offload, "offload");
11726 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11727 TOKEN_NUM_INITIALIZER
11728 (struct cmd_macsec_offload_on_result,
11730 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11731 TOKEN_STRING_INITIALIZER
11732 (struct cmd_macsec_offload_on_result,
11734 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11735 TOKEN_STRING_INITIALIZER
11736 (struct cmd_macsec_offload_on_result,
11737 encrypt, "encrypt");
11738 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11739 TOKEN_STRING_INITIALIZER
11740 (struct cmd_macsec_offload_on_result,
11741 en_on_off, "on#off");
11742 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11743 TOKEN_STRING_INITIALIZER
11744 (struct cmd_macsec_offload_on_result,
11745 replay_protect, "replay-protect");
11746 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11747 TOKEN_STRING_INITIALIZER
11748 (struct cmd_macsec_offload_on_result,
11749 rp_on_off, "on#off");
11752 cmd_set_macsec_offload_on_parsed(
11753 void *parsed_result,
11754 __attribute__((unused)) struct cmdline *cl,
11755 __attribute__((unused)) void *data)
11757 struct cmd_macsec_offload_on_result *res = parsed_result;
11759 portid_t port_id = res->port_id;
11760 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11761 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11763 if (port_id_is_invalid(port_id, ENABLED_WARN))
11766 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11767 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11773 printf("invalid port_id %d\n", port_id);
11776 printf("programming error: (%s)\n", strerror(-ret));
11780 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11781 .f = cmd_set_macsec_offload_on_parsed,
11783 .help_str = "set macsec offload <port_id> on "
11784 "encrypt on|off replay-protect on|off",
11786 (void *)&cmd_macsec_offload_on_set,
11787 (void *)&cmd_macsec_offload_on_macsec,
11788 (void *)&cmd_macsec_offload_on_offload,
11789 (void *)&cmd_macsec_offload_on_port_id,
11790 (void *)&cmd_macsec_offload_on_on,
11791 (void *)&cmd_macsec_offload_on_encrypt,
11792 (void *)&cmd_macsec_offload_on_en_on_off,
11793 (void *)&cmd_macsec_offload_on_replay_protect,
11794 (void *)&cmd_macsec_offload_on_rp_on_off,
11799 /* Common result structure for MACsec offload disable */
11800 struct cmd_macsec_offload_off_result {
11801 cmdline_fixed_string_t set;
11802 cmdline_fixed_string_t macsec;
11803 cmdline_fixed_string_t offload;
11805 cmdline_fixed_string_t off;
11808 /* Common CLI fields for MACsec offload disable */
11809 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_macsec_offload_off_result,
11813 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_macsec_offload_off_result,
11817 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_macsec_offload_off_result,
11820 offload, "offload");
11821 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11822 TOKEN_NUM_INITIALIZER
11823 (struct cmd_macsec_offload_off_result,
11825 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11826 TOKEN_STRING_INITIALIZER
11827 (struct cmd_macsec_offload_off_result,
11831 cmd_set_macsec_offload_off_parsed(
11832 void *parsed_result,
11833 __attribute__((unused)) struct cmdline *cl,
11834 __attribute__((unused)) void *data)
11836 struct cmd_macsec_offload_off_result *res = parsed_result;
11838 portid_t port_id = res->port_id;
11840 if (port_id_is_invalid(port_id, ENABLED_WARN))
11843 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11844 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11850 printf("invalid port_id %d\n", port_id);
11853 printf("programming error: (%s)\n", strerror(-ret));
11857 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11858 .f = cmd_set_macsec_offload_off_parsed,
11860 .help_str = "set macsec offload <port_id> off",
11862 (void *)&cmd_macsec_offload_off_set,
11863 (void *)&cmd_macsec_offload_off_macsec,
11864 (void *)&cmd_macsec_offload_off_offload,
11865 (void *)&cmd_macsec_offload_off_port_id,
11866 (void *)&cmd_macsec_offload_off_off,
11871 /* Common result structure for MACsec secure connection configure */
11872 struct cmd_macsec_sc_result {
11873 cmdline_fixed_string_t set;
11874 cmdline_fixed_string_t macsec;
11875 cmdline_fixed_string_t sc;
11876 cmdline_fixed_string_t tx_rx;
11878 struct ether_addr mac;
11882 /* Common CLI fields for MACsec secure connection configure */
11883 cmdline_parse_token_string_t cmd_macsec_sc_set =
11884 TOKEN_STRING_INITIALIZER
11885 (struct cmd_macsec_sc_result,
11887 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11888 TOKEN_STRING_INITIALIZER
11889 (struct cmd_macsec_sc_result,
11891 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11892 TOKEN_STRING_INITIALIZER
11893 (struct cmd_macsec_sc_result,
11895 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11896 TOKEN_STRING_INITIALIZER
11897 (struct cmd_macsec_sc_result,
11899 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11900 TOKEN_NUM_INITIALIZER
11901 (struct cmd_macsec_sc_result,
11903 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11904 TOKEN_ETHERADDR_INITIALIZER
11905 (struct cmd_macsec_sc_result,
11907 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11908 TOKEN_NUM_INITIALIZER
11909 (struct cmd_macsec_sc_result,
11913 cmd_set_macsec_sc_parsed(
11914 void *parsed_result,
11915 __attribute__((unused)) struct cmdline *cl,
11916 __attribute__((unused)) void *data)
11918 struct cmd_macsec_sc_result *res = parsed_result;
11920 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11923 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11924 res->mac.addr_bytes) :
11925 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11926 res->mac.addr_bytes, res->pi);
11931 printf("invalid port_id %d\n", res->port_id);
11934 printf("programming error: (%s)\n", strerror(-ret));
11938 cmdline_parse_inst_t cmd_set_macsec_sc = {
11939 .f = cmd_set_macsec_sc_parsed,
11941 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11943 (void *)&cmd_macsec_sc_set,
11944 (void *)&cmd_macsec_sc_macsec,
11945 (void *)&cmd_macsec_sc_sc,
11946 (void *)&cmd_macsec_sc_tx_rx,
11947 (void *)&cmd_macsec_sc_port_id,
11948 (void *)&cmd_macsec_sc_mac,
11949 (void *)&cmd_macsec_sc_pi,
11954 /* Common result structure for MACsec secure connection configure */
11955 struct cmd_macsec_sa_result {
11956 cmdline_fixed_string_t set;
11957 cmdline_fixed_string_t macsec;
11958 cmdline_fixed_string_t sa;
11959 cmdline_fixed_string_t tx_rx;
11964 cmdline_fixed_string_t key;
11967 /* Common CLI fields for MACsec secure connection configure */
11968 cmdline_parse_token_string_t cmd_macsec_sa_set =
11969 TOKEN_STRING_INITIALIZER
11970 (struct cmd_macsec_sa_result,
11972 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11973 TOKEN_STRING_INITIALIZER
11974 (struct cmd_macsec_sa_result,
11976 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11977 TOKEN_STRING_INITIALIZER
11978 (struct cmd_macsec_sa_result,
11980 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11981 TOKEN_STRING_INITIALIZER
11982 (struct cmd_macsec_sa_result,
11984 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11985 TOKEN_NUM_INITIALIZER
11986 (struct cmd_macsec_sa_result,
11988 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11989 TOKEN_NUM_INITIALIZER
11990 (struct cmd_macsec_sa_result,
11992 cmdline_parse_token_num_t cmd_macsec_sa_an =
11993 TOKEN_NUM_INITIALIZER
11994 (struct cmd_macsec_sa_result,
11996 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11997 TOKEN_NUM_INITIALIZER
11998 (struct cmd_macsec_sa_result,
12000 cmdline_parse_token_string_t cmd_macsec_sa_key =
12001 TOKEN_STRING_INITIALIZER
12002 (struct cmd_macsec_sa_result,
12006 cmd_set_macsec_sa_parsed(
12007 void *parsed_result,
12008 __attribute__((unused)) struct cmdline *cl,
12009 __attribute__((unused)) void *data)
12011 struct cmd_macsec_sa_result *res = parsed_result;
12013 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12014 uint8_t key[16] = { 0 };
12020 key_len = strlen(res->key) / 2;
12024 for (i = 0; i < key_len; i++) {
12025 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12028 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12031 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12035 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12036 res->idx, res->an, res->pn, key) :
12037 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12038 res->idx, res->an, res->pn, key);
12043 printf("invalid idx %d or an %d\n", res->idx, res->an);
12046 printf("invalid port_id %d\n", res->port_id);
12049 printf("programming error: (%s)\n", strerror(-ret));
12053 cmdline_parse_inst_t cmd_set_macsec_sa = {
12054 .f = cmd_set_macsec_sa_parsed,
12056 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12058 (void *)&cmd_macsec_sa_set,
12059 (void *)&cmd_macsec_sa_macsec,
12060 (void *)&cmd_macsec_sa_sa,
12061 (void *)&cmd_macsec_sa_tx_rx,
12062 (void *)&cmd_macsec_sa_port_id,
12063 (void *)&cmd_macsec_sa_idx,
12064 (void *)&cmd_macsec_sa_an,
12065 (void *)&cmd_macsec_sa_pn,
12066 (void *)&cmd_macsec_sa_key,
12072 /* VF unicast promiscuous mode configuration */
12074 /* Common result structure for VF unicast promiscuous mode */
12075 struct cmd_vf_promisc_result {
12076 cmdline_fixed_string_t set;
12077 cmdline_fixed_string_t vf;
12078 cmdline_fixed_string_t promisc;
12081 cmdline_fixed_string_t on_off;
12084 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12085 cmdline_parse_token_string_t cmd_vf_promisc_set =
12086 TOKEN_STRING_INITIALIZER
12087 (struct cmd_vf_promisc_result,
12089 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12090 TOKEN_STRING_INITIALIZER
12091 (struct cmd_vf_promisc_result,
12093 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12094 TOKEN_STRING_INITIALIZER
12095 (struct cmd_vf_promisc_result,
12096 promisc, "promisc");
12097 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12098 TOKEN_NUM_INITIALIZER
12099 (struct cmd_vf_promisc_result,
12101 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12102 TOKEN_NUM_INITIALIZER
12103 (struct cmd_vf_promisc_result,
12105 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12106 TOKEN_STRING_INITIALIZER
12107 (struct cmd_vf_promisc_result,
12111 cmd_set_vf_promisc_parsed(
12112 void *parsed_result,
12113 __attribute__((unused)) struct cmdline *cl,
12114 __attribute__((unused)) void *data)
12116 struct cmd_vf_promisc_result *res = parsed_result;
12117 int ret = -ENOTSUP;
12119 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12121 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12124 #ifdef RTE_LIBRTE_I40E_PMD
12125 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12126 res->vf_id, is_on);
12133 printf("invalid vf_id %d\n", res->vf_id);
12136 printf("invalid port_id %d\n", res->port_id);
12139 printf("function not implemented\n");
12142 printf("programming error: (%s)\n", strerror(-ret));
12146 cmdline_parse_inst_t cmd_set_vf_promisc = {
12147 .f = cmd_set_vf_promisc_parsed,
12149 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12150 "Set unicast promiscuous mode for a VF from the PF",
12152 (void *)&cmd_vf_promisc_set,
12153 (void *)&cmd_vf_promisc_vf,
12154 (void *)&cmd_vf_promisc_promisc,
12155 (void *)&cmd_vf_promisc_port_id,
12156 (void *)&cmd_vf_promisc_vf_id,
12157 (void *)&cmd_vf_promisc_on_off,
12162 /* VF multicast promiscuous mode configuration */
12164 /* Common result structure for VF multicast promiscuous mode */
12165 struct cmd_vf_allmulti_result {
12166 cmdline_fixed_string_t set;
12167 cmdline_fixed_string_t vf;
12168 cmdline_fixed_string_t allmulti;
12171 cmdline_fixed_string_t on_off;
12174 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12175 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12176 TOKEN_STRING_INITIALIZER
12177 (struct cmd_vf_allmulti_result,
12179 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12180 TOKEN_STRING_INITIALIZER
12181 (struct cmd_vf_allmulti_result,
12183 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12184 TOKEN_STRING_INITIALIZER
12185 (struct cmd_vf_allmulti_result,
12186 allmulti, "allmulti");
12187 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12188 TOKEN_NUM_INITIALIZER
12189 (struct cmd_vf_allmulti_result,
12191 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12192 TOKEN_NUM_INITIALIZER
12193 (struct cmd_vf_allmulti_result,
12195 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12196 TOKEN_STRING_INITIALIZER
12197 (struct cmd_vf_allmulti_result,
12201 cmd_set_vf_allmulti_parsed(
12202 void *parsed_result,
12203 __attribute__((unused)) struct cmdline *cl,
12204 __attribute__((unused)) void *data)
12206 struct cmd_vf_allmulti_result *res = parsed_result;
12207 int ret = -ENOTSUP;
12209 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12211 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12214 #ifdef RTE_LIBRTE_I40E_PMD
12215 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12216 res->vf_id, is_on);
12223 printf("invalid vf_id %d\n", res->vf_id);
12226 printf("invalid port_id %d\n", res->port_id);
12229 printf("function not implemented\n");
12232 printf("programming error: (%s)\n", strerror(-ret));
12236 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12237 .f = cmd_set_vf_allmulti_parsed,
12239 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12240 "Set multicast promiscuous mode for a VF from the PF",
12242 (void *)&cmd_vf_allmulti_set,
12243 (void *)&cmd_vf_allmulti_vf,
12244 (void *)&cmd_vf_allmulti_allmulti,
12245 (void *)&cmd_vf_allmulti_port_id,
12246 (void *)&cmd_vf_allmulti_vf_id,
12247 (void *)&cmd_vf_allmulti_on_off,
12252 /* vf broadcast mode configuration */
12254 /* Common result structure for vf broadcast */
12255 struct cmd_set_vf_broadcast_result {
12256 cmdline_fixed_string_t set;
12257 cmdline_fixed_string_t vf;
12258 cmdline_fixed_string_t broadcast;
12261 cmdline_fixed_string_t on_off;
12264 /* Common CLI fields for vf broadcast enable disable */
12265 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12266 TOKEN_STRING_INITIALIZER
12267 (struct cmd_set_vf_broadcast_result,
12269 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12270 TOKEN_STRING_INITIALIZER
12271 (struct cmd_set_vf_broadcast_result,
12273 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12274 TOKEN_STRING_INITIALIZER
12275 (struct cmd_set_vf_broadcast_result,
12276 broadcast, "broadcast");
12277 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12278 TOKEN_NUM_INITIALIZER
12279 (struct cmd_set_vf_broadcast_result,
12281 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12282 TOKEN_NUM_INITIALIZER
12283 (struct cmd_set_vf_broadcast_result,
12285 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12286 TOKEN_STRING_INITIALIZER
12287 (struct cmd_set_vf_broadcast_result,
12291 cmd_set_vf_broadcast_parsed(
12292 void *parsed_result,
12293 __attribute__((unused)) struct cmdline *cl,
12294 __attribute__((unused)) void *data)
12296 struct cmd_set_vf_broadcast_result *res = parsed_result;
12297 int ret = -ENOTSUP;
12299 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12301 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12304 #ifdef RTE_LIBRTE_I40E_PMD
12305 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12306 res->vf_id, is_on);
12313 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12316 printf("invalid port_id %d\n", res->port_id);
12319 printf("function not implemented\n");
12322 printf("programming error: (%s)\n", strerror(-ret));
12326 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12327 .f = cmd_set_vf_broadcast_parsed,
12329 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12331 (void *)&cmd_set_vf_broadcast_set,
12332 (void *)&cmd_set_vf_broadcast_vf,
12333 (void *)&cmd_set_vf_broadcast_broadcast,
12334 (void *)&cmd_set_vf_broadcast_port_id,
12335 (void *)&cmd_set_vf_broadcast_vf_id,
12336 (void *)&cmd_set_vf_broadcast_on_off,
12341 /* vf vlan tag configuration */
12343 /* Common result structure for vf vlan tag */
12344 struct cmd_set_vf_vlan_tag_result {
12345 cmdline_fixed_string_t set;
12346 cmdline_fixed_string_t vf;
12347 cmdline_fixed_string_t vlan;
12348 cmdline_fixed_string_t tag;
12351 cmdline_fixed_string_t on_off;
12354 /* Common CLI fields for vf vlan tag enable disable */
12355 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12356 TOKEN_STRING_INITIALIZER
12357 (struct cmd_set_vf_vlan_tag_result,
12359 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12360 TOKEN_STRING_INITIALIZER
12361 (struct cmd_set_vf_vlan_tag_result,
12363 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12364 TOKEN_STRING_INITIALIZER
12365 (struct cmd_set_vf_vlan_tag_result,
12367 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12368 TOKEN_STRING_INITIALIZER
12369 (struct cmd_set_vf_vlan_tag_result,
12371 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12372 TOKEN_NUM_INITIALIZER
12373 (struct cmd_set_vf_vlan_tag_result,
12375 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12376 TOKEN_NUM_INITIALIZER
12377 (struct cmd_set_vf_vlan_tag_result,
12379 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12380 TOKEN_STRING_INITIALIZER
12381 (struct cmd_set_vf_vlan_tag_result,
12385 cmd_set_vf_vlan_tag_parsed(
12386 void *parsed_result,
12387 __attribute__((unused)) struct cmdline *cl,
12388 __attribute__((unused)) void *data)
12390 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12391 int ret = -ENOTSUP;
12393 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12395 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12398 #ifdef RTE_LIBRTE_I40E_PMD
12399 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12400 res->vf_id, is_on);
12407 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12410 printf("invalid port_id %d\n", res->port_id);
12413 printf("function not implemented\n");
12416 printf("programming error: (%s)\n", strerror(-ret));
12420 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12421 .f = cmd_set_vf_vlan_tag_parsed,
12423 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12425 (void *)&cmd_set_vf_vlan_tag_set,
12426 (void *)&cmd_set_vf_vlan_tag_vf,
12427 (void *)&cmd_set_vf_vlan_tag_vlan,
12428 (void *)&cmd_set_vf_vlan_tag_tag,
12429 (void *)&cmd_set_vf_vlan_tag_port_id,
12430 (void *)&cmd_set_vf_vlan_tag_vf_id,
12431 (void *)&cmd_set_vf_vlan_tag_on_off,
12436 /* Common definition of VF and TC TX bandwidth configuration */
12437 struct cmd_vf_tc_bw_result {
12438 cmdline_fixed_string_t set;
12439 cmdline_fixed_string_t vf;
12440 cmdline_fixed_string_t tc;
12441 cmdline_fixed_string_t tx;
12442 cmdline_fixed_string_t min_bw;
12443 cmdline_fixed_string_t max_bw;
12444 cmdline_fixed_string_t strict_link_prio;
12449 cmdline_fixed_string_t bw_list;
12453 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12454 TOKEN_STRING_INITIALIZER
12455 (struct cmd_vf_tc_bw_result,
12457 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12458 TOKEN_STRING_INITIALIZER
12459 (struct cmd_vf_tc_bw_result,
12461 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12462 TOKEN_STRING_INITIALIZER
12463 (struct cmd_vf_tc_bw_result,
12465 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12466 TOKEN_STRING_INITIALIZER
12467 (struct cmd_vf_tc_bw_result,
12469 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12470 TOKEN_STRING_INITIALIZER
12471 (struct cmd_vf_tc_bw_result,
12472 strict_link_prio, "strict-link-priority");
12473 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12474 TOKEN_STRING_INITIALIZER
12475 (struct cmd_vf_tc_bw_result,
12476 min_bw, "min-bandwidth");
12477 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12478 TOKEN_STRING_INITIALIZER
12479 (struct cmd_vf_tc_bw_result,
12480 max_bw, "max-bandwidth");
12481 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12482 TOKEN_NUM_INITIALIZER
12483 (struct cmd_vf_tc_bw_result,
12485 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12486 TOKEN_NUM_INITIALIZER
12487 (struct cmd_vf_tc_bw_result,
12489 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12490 TOKEN_NUM_INITIALIZER
12491 (struct cmd_vf_tc_bw_result,
12493 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12494 TOKEN_NUM_INITIALIZER
12495 (struct cmd_vf_tc_bw_result,
12497 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12498 TOKEN_STRING_INITIALIZER
12499 (struct cmd_vf_tc_bw_result,
12501 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12502 TOKEN_NUM_INITIALIZER
12503 (struct cmd_vf_tc_bw_result,
12506 /* VF max bandwidth setting */
12508 cmd_vf_max_bw_parsed(
12509 void *parsed_result,
12510 __attribute__((unused)) struct cmdline *cl,
12511 __attribute__((unused)) void *data)
12513 struct cmd_vf_tc_bw_result *res = parsed_result;
12514 int ret = -ENOTSUP;
12516 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12519 #ifdef RTE_LIBRTE_I40E_PMD
12520 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12521 res->vf_id, res->bw);
12528 printf("invalid vf_id %d or bandwidth %d\n",
12529 res->vf_id, res->bw);
12532 printf("invalid port_id %d\n", res->port_id);
12535 printf("function not implemented\n");
12538 printf("programming error: (%s)\n", strerror(-ret));
12542 cmdline_parse_inst_t cmd_vf_max_bw = {
12543 .f = cmd_vf_max_bw_parsed,
12545 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12547 (void *)&cmd_vf_tc_bw_set,
12548 (void *)&cmd_vf_tc_bw_vf,
12549 (void *)&cmd_vf_tc_bw_tx,
12550 (void *)&cmd_vf_tc_bw_max_bw,
12551 (void *)&cmd_vf_tc_bw_port_id,
12552 (void *)&cmd_vf_tc_bw_vf_id,
12553 (void *)&cmd_vf_tc_bw_bw,
12559 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12564 const char *p, *p0 = str;
12571 p = strchr(p0, '(');
12573 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12577 p0 = strchr(p, ')');
12579 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12583 if (size >= sizeof(s)) {
12584 printf("The string size exceeds the internal buffer size\n");
12587 snprintf(s, sizeof(s), "%.*s", size, p);
12588 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12590 printf("Failed to get the bandwidth list. ");
12594 for (i = 0; i < ret; i++)
12595 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12600 /* TC min bandwidth setting */
12602 cmd_vf_tc_min_bw_parsed(
12603 void *parsed_result,
12604 __attribute__((unused)) struct cmdline *cl,
12605 __attribute__((unused)) void *data)
12607 struct cmd_vf_tc_bw_result *res = parsed_result;
12610 int ret = -ENOTSUP;
12612 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12615 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12619 #ifdef RTE_LIBRTE_I40E_PMD
12620 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12628 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12631 printf("invalid port_id %d\n", res->port_id);
12634 printf("function not implemented\n");
12637 printf("programming error: (%s)\n", strerror(-ret));
12641 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12642 .f = cmd_vf_tc_min_bw_parsed,
12644 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12645 " <bw1, bw2, ...>",
12647 (void *)&cmd_vf_tc_bw_set,
12648 (void *)&cmd_vf_tc_bw_vf,
12649 (void *)&cmd_vf_tc_bw_tc,
12650 (void *)&cmd_vf_tc_bw_tx,
12651 (void *)&cmd_vf_tc_bw_min_bw,
12652 (void *)&cmd_vf_tc_bw_port_id,
12653 (void *)&cmd_vf_tc_bw_vf_id,
12654 (void *)&cmd_vf_tc_bw_bw_list,
12660 cmd_tc_min_bw_parsed(
12661 void *parsed_result,
12662 __attribute__((unused)) struct cmdline *cl,
12663 __attribute__((unused)) void *data)
12665 struct cmd_vf_tc_bw_result *res = parsed_result;
12666 struct rte_port *port;
12669 int ret = -ENOTSUP;
12671 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12674 port = &ports[res->port_id];
12675 /** Check if the port is not started **/
12676 if (port->port_status != RTE_PORT_STOPPED) {
12677 printf("Please stop port %d first\n", res->port_id);
12681 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12685 #ifdef RTE_LIBRTE_IXGBE_PMD
12686 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12693 printf("invalid bandwidth\n");
12696 printf("invalid port_id %d\n", res->port_id);
12699 printf("function not implemented\n");
12702 printf("programming error: (%s)\n", strerror(-ret));
12706 cmdline_parse_inst_t cmd_tc_min_bw = {
12707 .f = cmd_tc_min_bw_parsed,
12709 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12711 (void *)&cmd_vf_tc_bw_set,
12712 (void *)&cmd_vf_tc_bw_tc,
12713 (void *)&cmd_vf_tc_bw_tx,
12714 (void *)&cmd_vf_tc_bw_min_bw,
12715 (void *)&cmd_vf_tc_bw_port_id,
12716 (void *)&cmd_vf_tc_bw_bw_list,
12721 /* TC max bandwidth setting */
12723 cmd_vf_tc_max_bw_parsed(
12724 void *parsed_result,
12725 __attribute__((unused)) struct cmdline *cl,
12726 __attribute__((unused)) void *data)
12728 struct cmd_vf_tc_bw_result *res = parsed_result;
12729 int ret = -ENOTSUP;
12731 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12734 #ifdef RTE_LIBRTE_I40E_PMD
12735 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12736 res->tc_no, res->bw);
12743 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12744 res->vf_id, res->tc_no, res->bw);
12747 printf("invalid port_id %d\n", res->port_id);
12750 printf("function not implemented\n");
12753 printf("programming error: (%s)\n", strerror(-ret));
12757 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12758 .f = cmd_vf_tc_max_bw_parsed,
12760 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12763 (void *)&cmd_vf_tc_bw_set,
12764 (void *)&cmd_vf_tc_bw_vf,
12765 (void *)&cmd_vf_tc_bw_tc,
12766 (void *)&cmd_vf_tc_bw_tx,
12767 (void *)&cmd_vf_tc_bw_max_bw,
12768 (void *)&cmd_vf_tc_bw_port_id,
12769 (void *)&cmd_vf_tc_bw_vf_id,
12770 (void *)&cmd_vf_tc_bw_tc_no,
12771 (void *)&cmd_vf_tc_bw_bw,
12776 /* Strict link priority scheduling mode setting */
12778 cmd_strict_link_prio_parsed(
12779 void *parsed_result,
12780 __attribute__((unused)) struct cmdline *cl,
12781 __attribute__((unused)) void *data)
12783 struct cmd_vf_tc_bw_result *res = parsed_result;
12784 int ret = -ENOTSUP;
12786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12789 #ifdef RTE_LIBRTE_I40E_PMD
12790 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12797 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12800 printf("invalid port_id %d\n", res->port_id);
12803 printf("function not implemented\n");
12806 printf("programming error: (%s)\n", strerror(-ret));
12810 cmdline_parse_inst_t cmd_strict_link_prio = {
12811 .f = cmd_strict_link_prio_parsed,
12813 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12815 (void *)&cmd_vf_tc_bw_set,
12816 (void *)&cmd_vf_tc_bw_tx,
12817 (void *)&cmd_vf_tc_bw_strict_link_prio,
12818 (void *)&cmd_vf_tc_bw_port_id,
12819 (void *)&cmd_vf_tc_bw_tc_map,
12824 /* Load dynamic device personalization*/
12825 struct cmd_ddp_add_result {
12826 cmdline_fixed_string_t ddp;
12827 cmdline_fixed_string_t add;
12832 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12833 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12834 cmdline_parse_token_string_t cmd_ddp_add_add =
12835 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12836 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12837 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12838 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12839 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12842 cmd_ddp_add_parsed(
12843 void *parsed_result,
12844 __attribute__((unused)) struct cmdline *cl,
12845 __attribute__((unused)) void *data)
12847 struct cmd_ddp_add_result *res = parsed_result;
12850 int ret = -ENOTSUP;
12852 if (res->port_id > nb_ports) {
12853 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12857 if (!all_ports_stopped()) {
12858 printf("Please stop all ports first\n");
12862 buff = open_ddp_package_file(res->filepath, &size);
12866 #ifdef RTE_LIBRTE_I40E_PMD
12867 if (ret == -ENOTSUP)
12868 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12870 RTE_PMD_I40E_PKG_OP_WR_ADD);
12874 printf("Failed to load profile.\n");
12876 printf("Profile has already existed.\n");
12878 close_ddp_package_file(buff);
12881 cmdline_parse_inst_t cmd_ddp_add = {
12882 .f = cmd_ddp_add_parsed,
12884 .help_str = "ddp add <port_id> <profile_path>",
12886 (void *)&cmd_ddp_add_ddp,
12887 (void *)&cmd_ddp_add_add,
12888 (void *)&cmd_ddp_add_port_id,
12889 (void *)&cmd_ddp_add_filepath,
12894 /* Get dynamic device personalization profile info list*/
12895 #define PROFILE_INFO_SIZE 48
12896 #define MAX_PROFILE_NUM 16
12898 struct cmd_ddp_get_list_result {
12899 cmdline_fixed_string_t ddp;
12900 cmdline_fixed_string_t get;
12901 cmdline_fixed_string_t list;
12905 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
12906 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
12907 cmdline_parse_token_string_t cmd_ddp_get_list_get =
12908 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
12909 cmdline_parse_token_string_t cmd_ddp_get_list_list =
12910 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
12911 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
12912 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
12915 cmd_ddp_get_list_parsed(
12916 void *parsed_result,
12917 __attribute__((unused)) struct cmdline *cl,
12918 __attribute__((unused)) void *data)
12920 struct cmd_ddp_get_list_result *res = parsed_result;
12921 #ifdef RTE_LIBRTE_I40E_PMD
12922 struct rte_pmd_i40e_profile_list *p_list;
12923 struct rte_pmd_i40e_profile_info *p_info;
12928 int ret = -ENOTSUP;
12930 if (res->port_id > nb_ports) {
12931 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12935 #ifdef RTE_LIBRTE_I40E_PMD
12936 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
12937 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
12939 printf("%s: Failed to malloc buffer\n", __func__);
12941 if (ret == -ENOTSUP)
12942 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
12943 (uint8_t *)p_list, size);
12946 p_num = p_list->p_count;
12947 printf("Profile number is: %d\n\n", p_num);
12949 for (i = 0; i < p_num; i++) {
12950 p_info = &p_list->p_info[i];
12951 printf("Profile %d:\n", i);
12952 printf("Track id: 0x%x\n", p_info->track_id);
12953 printf("Version: %d.%d.%d.%d\n",
12954 p_info->version.major,
12955 p_info->version.minor,
12956 p_info->version.update,
12957 p_info->version.draft);
12958 printf("Profile name: %s\n\n", p_info->name);
12966 printf("Failed to get ddp list\n");
12969 cmdline_parse_inst_t cmd_ddp_get_list = {
12970 .f = cmd_ddp_get_list_parsed,
12972 .help_str = "ddp get list <port_id>",
12974 (void *)&cmd_ddp_get_list_ddp,
12975 (void *)&cmd_ddp_get_list_get,
12976 (void *)&cmd_ddp_get_list_list,
12977 (void *)&cmd_ddp_get_list_port_id,
12982 /* show vf stats */
12984 /* Common result structure for show vf stats */
12985 struct cmd_show_vf_stats_result {
12986 cmdline_fixed_string_t show;
12987 cmdline_fixed_string_t vf;
12988 cmdline_fixed_string_t stats;
12993 /* Common CLI fields show vf stats*/
12994 cmdline_parse_token_string_t cmd_show_vf_stats_show =
12995 TOKEN_STRING_INITIALIZER
12996 (struct cmd_show_vf_stats_result,
12998 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
12999 TOKEN_STRING_INITIALIZER
13000 (struct cmd_show_vf_stats_result,
13002 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13003 TOKEN_STRING_INITIALIZER
13004 (struct cmd_show_vf_stats_result,
13006 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13007 TOKEN_NUM_INITIALIZER
13008 (struct cmd_show_vf_stats_result,
13010 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13011 TOKEN_NUM_INITIALIZER
13012 (struct cmd_show_vf_stats_result,
13016 cmd_show_vf_stats_parsed(
13017 void *parsed_result,
13018 __attribute__((unused)) struct cmdline *cl,
13019 __attribute__((unused)) void *data)
13021 struct cmd_show_vf_stats_result *res = parsed_result;
13022 struct rte_eth_stats stats;
13023 int ret = -ENOTSUP;
13024 static const char *nic_stats_border = "########################";
13026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13029 memset(&stats, 0, sizeof(stats));
13031 #ifdef RTE_LIBRTE_I40E_PMD
13032 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13041 printf("invalid vf_id %d\n", res->vf_id);
13044 printf("invalid port_id %d\n", res->port_id);
13047 printf("function not implemented\n");
13050 printf("programming error: (%s)\n", strerror(-ret));
13053 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13054 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13056 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13058 stats.ipackets, stats.imissed, stats.ibytes);
13059 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13060 printf(" RX-nombuf: %-10"PRIu64"\n",
13062 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13064 stats.opackets, stats.oerrors, stats.obytes);
13066 printf(" %s############################%s\n",
13067 nic_stats_border, nic_stats_border);
13070 cmdline_parse_inst_t cmd_show_vf_stats = {
13071 .f = cmd_show_vf_stats_parsed,
13073 .help_str = "show vf stats <port_id> <vf_id>",
13075 (void *)&cmd_show_vf_stats_show,
13076 (void *)&cmd_show_vf_stats_vf,
13077 (void *)&cmd_show_vf_stats_stats,
13078 (void *)&cmd_show_vf_stats_port_id,
13079 (void *)&cmd_show_vf_stats_vf_id,
13084 /* clear vf stats */
13086 /* Common result structure for clear vf stats */
13087 struct cmd_clear_vf_stats_result {
13088 cmdline_fixed_string_t clear;
13089 cmdline_fixed_string_t vf;
13090 cmdline_fixed_string_t stats;
13095 /* Common CLI fields clear vf stats*/
13096 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13097 TOKEN_STRING_INITIALIZER
13098 (struct cmd_clear_vf_stats_result,
13100 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13101 TOKEN_STRING_INITIALIZER
13102 (struct cmd_clear_vf_stats_result,
13104 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13105 TOKEN_STRING_INITIALIZER
13106 (struct cmd_clear_vf_stats_result,
13108 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13109 TOKEN_NUM_INITIALIZER
13110 (struct cmd_clear_vf_stats_result,
13112 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13113 TOKEN_NUM_INITIALIZER
13114 (struct cmd_clear_vf_stats_result,
13118 cmd_clear_vf_stats_parsed(
13119 void *parsed_result,
13120 __attribute__((unused)) struct cmdline *cl,
13121 __attribute__((unused)) void *data)
13123 struct cmd_clear_vf_stats_result *res = parsed_result;
13124 int ret = -ENOTSUP;
13126 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13129 #ifdef RTE_LIBRTE_I40E_PMD
13130 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13138 printf("invalid vf_id %d\n", res->vf_id);
13141 printf("invalid port_id %d\n", res->port_id);
13144 printf("function not implemented\n");
13147 printf("programming error: (%s)\n", strerror(-ret));
13151 cmdline_parse_inst_t cmd_clear_vf_stats = {
13152 .f = cmd_clear_vf_stats_parsed,
13154 .help_str = "clear vf stats <port_id> <vf_id>",
13156 (void *)&cmd_clear_vf_stats_clear,
13157 (void *)&cmd_clear_vf_stats_vf,
13158 (void *)&cmd_clear_vf_stats_stats,
13159 (void *)&cmd_clear_vf_stats_port_id,
13160 (void *)&cmd_clear_vf_stats_vf_id,
13165 /* ******************************************************************************** */
13167 /* list of instructions */
13168 cmdline_parse_ctx_t main_ctx[] = {
13169 (cmdline_parse_inst_t *)&cmd_help_brief,
13170 (cmdline_parse_inst_t *)&cmd_help_long,
13171 (cmdline_parse_inst_t *)&cmd_quit,
13172 (cmdline_parse_inst_t *)&cmd_showport,
13173 (cmdline_parse_inst_t *)&cmd_showqueue,
13174 (cmdline_parse_inst_t *)&cmd_showportall,
13175 (cmdline_parse_inst_t *)&cmd_showcfg,
13176 (cmdline_parse_inst_t *)&cmd_start,
13177 (cmdline_parse_inst_t *)&cmd_start_tx_first,
13178 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13179 (cmdline_parse_inst_t *)&cmd_set_link_up,
13180 (cmdline_parse_inst_t *)&cmd_set_link_down,
13181 (cmdline_parse_inst_t *)&cmd_reset,
13182 (cmdline_parse_inst_t *)&cmd_set_numbers,
13183 (cmdline_parse_inst_t *)&cmd_set_txpkts,
13184 (cmdline_parse_inst_t *)&cmd_set_txsplit,
13185 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13186 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13187 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13188 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13189 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13190 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13191 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13192 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13193 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13194 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13195 (cmdline_parse_inst_t *)&cmd_set_link_check,
13196 #ifdef RTE_NIC_BYPASS
13197 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13198 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13199 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13200 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13202 #ifdef RTE_LIBRTE_PMD_BOND
13203 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13204 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13205 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13206 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13207 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13208 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13209 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13210 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13211 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13213 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13214 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13215 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13216 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13217 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13218 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13219 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13220 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13221 (cmdline_parse_inst_t *)&cmd_csum_set,
13222 (cmdline_parse_inst_t *)&cmd_csum_show,
13223 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13224 (cmdline_parse_inst_t *)&cmd_tso_set,
13225 (cmdline_parse_inst_t *)&cmd_tso_show,
13226 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13227 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13228 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13229 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13230 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13231 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13232 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13233 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13234 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13235 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13236 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13237 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13238 (cmdline_parse_inst_t *)&cmd_config_dcb,
13239 (cmdline_parse_inst_t *)&cmd_read_reg,
13240 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13241 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13242 (cmdline_parse_inst_t *)&cmd_write_reg,
13243 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13244 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13245 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13246 (cmdline_parse_inst_t *)&cmd_stop,
13247 (cmdline_parse_inst_t *)&cmd_mac_addr,
13248 (cmdline_parse_inst_t *)&cmd_set_qmap,
13249 (cmdline_parse_inst_t *)&cmd_operate_port,
13250 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13251 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13252 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13253 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13254 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13255 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13256 (cmdline_parse_inst_t *)&cmd_config_mtu,
13257 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13258 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13259 (cmdline_parse_inst_t *)&cmd_config_rss,
13260 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13261 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13262 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13263 (cmdline_parse_inst_t *)&cmd_showport_reta,
13264 (cmdline_parse_inst_t *)&cmd_config_burst,
13265 (cmdline_parse_inst_t *)&cmd_config_thresh,
13266 (cmdline_parse_inst_t *)&cmd_config_threshold,
13267 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13268 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13269 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13270 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13271 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13272 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13273 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13274 (cmdline_parse_inst_t *)&cmd_global_config,
13275 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13276 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13277 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13278 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13279 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13280 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13281 (cmdline_parse_inst_t *)&cmd_dump,
13282 (cmdline_parse_inst_t *)&cmd_dump_one,
13283 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13284 (cmdline_parse_inst_t *)&cmd_syn_filter,
13285 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13286 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13287 (cmdline_parse_inst_t *)&cmd_flex_filter,
13288 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13289 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13290 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13291 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13292 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13293 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13294 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13295 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13296 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13297 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13298 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13299 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13300 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13301 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13302 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13303 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13304 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13305 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13306 (cmdline_parse_inst_t *)&cmd_flow,
13307 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13308 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13309 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13310 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13311 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13312 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13313 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13314 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13315 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13316 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13317 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13318 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13319 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13320 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13321 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13322 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13323 #ifdef RTE_LIBRTE_IXGBE_PMD
13324 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13325 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13326 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13327 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13328 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13329 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13330 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13331 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13332 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13334 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13335 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13336 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13337 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13338 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13339 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13340 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13341 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13342 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13343 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13344 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
13345 (cmdline_parse_inst_t *)&cmd_ddp_add,
13346 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13347 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13348 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13352 /* prompt function, called from main on MASTER lcore */
13356 /* initialize non-constant commands */
13357 cmd_set_fwd_mode_init();
13358 cmd_set_fwd_retry_mode_init();
13360 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13361 if (testpmd_cl == NULL)
13363 cmdline_interact(testpmd_cl);
13364 cmdline_stdin_exit(testpmd_cl);
13370 if (testpmd_cl != NULL)
13371 cmdline_quit(testpmd_cl);
13375 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13377 if (id == (portid_t)RTE_PORT_ALL) {
13380 FOREACH_PORT(pid, ports) {
13381 /* check if need_reconfig has been set to 1 */
13382 if (ports[pid].need_reconfig == 0)
13383 ports[pid].need_reconfig = dev;
13384 /* check if need_reconfig_queues has been set to 1 */
13385 if (ports[pid].need_reconfig_queues == 0)
13386 ports[pid].need_reconfig_queues = queue;
13388 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13389 /* check if need_reconfig has been set to 1 */
13390 if (ports[id].need_reconfig == 0)
13391 ports[id].need_reconfig = dev;
13392 /* check if need_reconfig_queues has been set to 1 */
13393 if (ports[id].need_reconfig_queues == 0)
13394 ports[id].need_reconfig_queues = queue;