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>
97 #ifdef RTE_LIBRTE_BNXT_PMD
98 #include <rte_pmd_bnxt.h>
102 static struct cmdline *testpmd_cl;
104 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
106 /* *** Help command with introduction. *** */
107 struct cmd_help_brief_result {
108 cmdline_fixed_string_t help;
111 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
113 __attribute__((unused)) void *data)
118 "Help is available for the following sections:\n\n"
119 " help control : Start and stop forwarding.\n"
120 " help display : Displaying port, stats and config "
122 " help config : Configuration information.\n"
123 " help ports : Configuring ports.\n"
124 " help registers : Reading and setting port registers.\n"
125 " help filters : Filters configuration help.\n"
126 " help all : All of the above sections.\n\n"
131 cmdline_parse_token_string_t cmd_help_brief_help =
132 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
134 cmdline_parse_inst_t cmd_help_brief = {
135 .f = cmd_help_brief_parsed,
137 .help_str = "help: Show help",
139 (void *)&cmd_help_brief_help,
144 /* *** Help command with help sections. *** */
145 struct cmd_help_long_result {
146 cmdline_fixed_string_t help;
147 cmdline_fixed_string_t section;
150 static void cmd_help_long_parsed(void *parsed_result,
152 __attribute__((unused)) void *data)
155 struct cmd_help_long_result *res = parsed_result;
157 if (!strcmp(res->section, "all"))
160 if (show_all || !strcmp(res->section, "control")) {
165 "Control forwarding:\n"
166 "-------------------\n\n"
169 " Start packet forwarding with current configuration.\n\n"
172 " Start packet forwarding with current config"
173 " after sending one burst of packets.\n\n"
176 " Stop packet forwarding, and display accumulated"
180 " Quit to prompt.\n\n"
184 if (show_all || !strcmp(res->section, "display")) {
192 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
193 " Display information for port_id, or all.\n\n"
195 "show port X rss reta (size) (mask0,mask1,...)\n"
196 " Display the rss redirection table entry indicated"
197 " by masks on port X. size is used to indicate the"
198 " hardware supported reta size\n\n"
200 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
201 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
202 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
203 " Display the RSS hash functions and RSS hash key"
206 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
207 " Clear information for port_id, or all.\n\n"
209 "show (rxq|txq) info (port_id) (queue_id)\n"
210 " Display information for configured RX/TX queue.\n\n"
212 "show config (rxtx|cores|fwd|txpkts)\n"
213 " Display the given configuration.\n\n"
215 "read rxd (port_id) (queue_id) (rxd_id)\n"
216 " Display an RX descriptor of a port RX queue.\n\n"
218 "read txd (port_id) (queue_id) (txd_id)\n"
219 " Display a TX descriptor of a port TX queue.\n\n"
221 "ddp get list (port_id)\n"
222 " Get ddp profile info list\n\n"
224 "ddp get info (profile_path)\n"
225 " Get ddp profile information.\n\n"
227 "show vf stats (port_id) (vf_id)\n"
228 " Display a VF's statistics.\n\n"
230 "clear vf stats (port_id) (vf_id)\n"
231 " Reset a VF's statistics.\n\n"
235 if (show_all || !strcmp(res->section, "config")) {
241 "Configuration changes only become active when"
242 " forwarding is started/restarted.\n\n"
245 " Reset forwarding to the default configuration.\n\n"
247 "set verbose (level)\n"
248 " Set the debug verbosity level X.\n\n"
251 " Set number of ports.\n\n"
254 " Set number of cores.\n\n"
256 "set coremask (mask)\n"
257 " Set the forwarding cores hexadecimal mask.\n\n"
259 "set portmask (mask)\n"
260 " Set the forwarding ports hexadecimal mask.\n\n"
263 " Set number of packets per burst.\n\n"
265 "set burst tx delay (microseconds) retry (num)\n"
266 " Set the transmit delay time and number of retries,"
267 " effective when retry is enabled.\n\n"
269 "set txpkts (x[,y]*)\n"
270 " Set the length of each segment of TXONLY"
271 " and optionally CSUM packets.\n\n"
273 "set txsplit (off|on|rand)\n"
274 " Set the split policy for the TX packets."
275 " Right now only applicable for CSUM and TXONLY"
278 "set corelist (x[,y]*)\n"
279 " Set the list of forwarding cores.\n\n"
281 "set portlist (x[,y]*)\n"
282 " Set the list of forwarding ports.\n\n"
284 "set tx loopback (port_id) (on|off)\n"
285 " Enable or disable tx loopback.\n\n"
287 "set all queues drop (port_id) (on|off)\n"
288 " Set drop enable bit for all queues.\n\n"
290 "set vf split drop (port_id) (vf_id) (on|off)\n"
291 " Set split drop enable bit for a VF from the PF.\n\n"
293 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
294 " Set MAC antispoof for a VF from the PF.\n\n"
296 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
297 " Enable MACsec offload.\n\n"
299 "set macsec offload (port_id) off\n"
300 " Disable MACsec offload.\n\n"
302 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
303 " Configure MACsec secure connection (SC).\n\n"
305 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
306 " Configure MACsec secure association (SA).\n\n"
308 "set vf broadcast (port_id) (vf_id) (on|off)\n"
309 " Set VF broadcast for a VF from the PF.\n\n"
311 "vlan set strip (on|off) (port_id)\n"
312 " Set the VLAN strip on a port.\n\n"
314 "vlan set stripq (on|off) (port_id,queue_id)\n"
315 " Set the VLAN strip for a queue on a port.\n\n"
317 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
318 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
320 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
321 " Set VLAN insert for a VF from the PF.\n\n"
323 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
324 " Set VLAN antispoof for a VF from the PF.\n\n"
326 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
327 " Set VLAN tag for a VF from the PF.\n\n"
329 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
330 " Set a VF's max bandwidth(Mbps).\n\n"
332 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
333 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
335 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
336 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
338 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
339 " Set some TCs' strict link priority mode on a physical port.\n\n"
341 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
342 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
344 "vlan set filter (on|off) (port_id)\n"
345 " Set the VLAN filter on a port.\n\n"
347 "vlan set qinq (on|off) (port_id)\n"
348 " Set the VLAN QinQ (extended queue in queue)"
351 "vlan set (inner|outer) tpid (value) (port_id)\n"
352 " Set the VLAN TPID for Packet Filtering on"
355 "rx_vlan add (vlan_id|all) (port_id)\n"
356 " Add a vlan_id, or all identifiers, to the set"
357 " of VLAN identifiers filtered by port_id.\n\n"
359 "rx_vlan rm (vlan_id|all) (port_id)\n"
360 " Remove a vlan_id, or all identifiers, from the set"
361 " of VLAN identifiers filtered by port_id.\n\n"
363 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
364 " Add a vlan_id, to the set of VLAN identifiers"
365 "filtered for VF(s) from port_id.\n\n"
367 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
368 " Remove a vlan_id, to the set of VLAN identifiers"
369 "filtered for VF(s) from port_id.\n\n"
371 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
372 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
373 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
374 " add a tunnel filter of a port.\n\n"
376 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
377 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
378 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
379 " remove a tunnel filter of a port.\n\n"
381 "rx_vxlan_port add (udp_port) (port_id)\n"
382 " Add an UDP port for VXLAN packet filter on a port\n\n"
384 "rx_vxlan_port rm (udp_port) (port_id)\n"
385 " Remove an UDP port for VXLAN packet filter on a port\n\n"
387 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
388 " Set hardware insertion of VLAN IDs (single or double VLAN "
389 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
391 "tx_vlan set pvid port_id vlan_id (on|off)\n"
392 " Set port based TX VLAN insertion.\n\n"
394 "tx_vlan reset (port_id)\n"
395 " Disable hardware insertion of a VLAN header in"
396 " packets sent on a port.\n\n"
398 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
399 " Select hardware or software calculation of the"
400 " checksum when transmitting a packet using the"
401 " csum forward engine.\n"
402 " ip|udp|tcp|sctp always concern the inner layer.\n"
403 " outer-ip concerns the outer IP layer in"
404 " case the packet is recognized as a tunnel packet by"
405 " the forward engine (vxlan, gre and ipip are supported)\n"
406 " Please check the NIC datasheet for HW limits.\n\n"
408 "csum parse-tunnel (on|off) (tx_port_id)\n"
409 " If disabled, treat tunnel packets as non-tunneled"
410 " packets (treat inner headers as payload). The port\n"
411 " argument is the port used for TX in csum forward"
414 "csum show (port_id)\n"
415 " Display tx checksum offload configuration\n\n"
417 "tso set (segsize) (portid)\n"
418 " Enable TCP Segmentation Offload in csum forward"
420 " Please check the NIC datasheet for HW limits.\n\n"
423 " Display the status of TCP Segmentation Offload.\n\n"
426 " Set packet forwarding mode.\n\n"
428 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
429 " Add a MAC address on port_id.\n\n"
431 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
432 " Remove a MAC address from port_id.\n\n"
434 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
435 " Set the default MAC address for port_id.\n\n"
437 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
438 " Add a MAC address for a VF on the port.\n\n"
440 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
441 " Set the MAC address for a VF from the PF.\n\n"
443 "set port (port_id) uta (mac_address|all) (on|off)\n"
444 " Add/Remove a or all unicast hash filter(s)"
447 "set promisc (port_id|all) (on|off)\n"
448 " Set the promiscuous mode on port_id, or all.\n\n"
450 "set allmulti (port_id|all) (on|off)\n"
451 " Set the allmulti mode on port_id, or all.\n\n"
453 "set vf promisc (port_id) (vf_id) (on|off)\n"
454 " Set unicast promiscuous mode for a VF from the PF.\n\n"
456 "set vf allmulti (port_id) (vf_id) (on|off)\n"
457 " Set multicast promiscuous mode for a VF from the PF.\n\n"
459 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
460 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
461 " (on|off) autoneg (on|off) (port_id)\n"
462 "set flow_ctrl rx (on|off) (portid)\n"
463 "set flow_ctrl tx (on|off) (portid)\n"
464 "set flow_ctrl high_water (high_water) (portid)\n"
465 "set flow_ctrl low_water (low_water) (portid)\n"
466 "set flow_ctrl pause_time (pause_time) (portid)\n"
467 "set flow_ctrl send_xon (send_xon) (portid)\n"
468 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
469 "set flow_ctrl autoneg (on|off) (port_id)\n"
470 " Set the link flow control parameter on a port.\n\n"
472 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
473 " (low_water) (pause_time) (priority) (port_id)\n"
474 " Set the priority flow control parameter on a"
477 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
478 " Set statistics mapping (qmapping 0..15) for RX/TX"
480 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
481 " on port 0 to mapping 5.\n\n"
483 "set port (port_id) vf (vf_id) rx|tx on|off\n"
484 " Enable/Disable a VF receive/tranmit from a port\n\n"
486 "set port (port_id) vf (vf_id) (mac_addr)"
487 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
488 " Add/Remove unicast or multicast MAC addr filter"
491 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
493 " AUPE:accepts untagged VLAN;"
494 "ROPE:accept unicast hash\n\n"
495 " BAM:accepts broadcast packets;"
496 "MPE:accepts all multicast packets\n\n"
497 " Enable/Disable a VF receive mode of a port\n\n"
499 "set port (port_id) queue (queue_id) rate (rate_num)\n"
500 " Set rate limit for a queue of a port\n\n"
502 "set port (port_id) vf (vf_id) rate (rate_num) "
503 "queue_mask (queue_mask_value)\n"
504 " Set rate limit for queues in VF of a port\n\n"
506 "set port (port_id) mirror-rule (rule_id)"
507 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
508 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
509 " Set pool or vlan type mirror rule on a port.\n"
510 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
511 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
514 "set port (port_id) mirror-rule (rule_id)"
515 " (uplink-mirror|downlink-mirror) dst-pool"
516 " (pool_id) (on|off)\n"
517 " Set uplink or downlink type mirror rule on a port.\n"
518 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
519 " 0 on' enable mirror income traffic to pool 0.\n\n"
521 "reset port (port_id) mirror-rule (rule_id)\n"
522 " Reset a mirror rule.\n\n"
524 "set flush_rx (on|off)\n"
525 " Flush (default) or don't flush RX streams before"
526 " forwarding. Mainly used with PCAP drivers.\n\n"
528 "set bypass mode (normal|bypass|isolate) (port_id)\n"
529 " Set the bypass mode for the lowest port on bypass enabled"
532 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
533 "mode (normal|bypass|isolate) (port_id)\n"
534 " Set the event required to initiate specified bypass mode for"
535 " the lowest port on a bypass enabled NIC where:\n"
536 " timeout = enable bypass after watchdog timeout.\n"
537 " os_on = enable bypass when OS/board is powered on.\n"
538 " os_off = enable bypass when OS/board is powered off.\n"
539 " power_on = enable bypass when power supply is turned on.\n"
540 " power_off = enable bypass when power supply is turned off."
543 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
544 " Set the bypass watchdog timeout to 'n' seconds"
545 " where 0 = instant.\n\n"
547 "show bypass config (port_id)\n"
548 " Show the bypass configuration for a bypass enabled NIC"
549 " using the lowest port on the NIC.\n\n"
551 #ifdef RTE_LIBRTE_PMD_BOND
552 "create bonded device (mode) (socket)\n"
553 " Create a new bonded device with specific bonding mode and socket.\n\n"
555 "add bonding slave (slave_id) (port_id)\n"
556 " Add a slave device to a bonded device.\n\n"
558 "remove bonding slave (slave_id) (port_id)\n"
559 " Remove a slave device from a bonded device.\n\n"
561 "set bonding mode (value) (port_id)\n"
562 " Set the bonding mode on a bonded device.\n\n"
564 "set bonding primary (slave_id) (port_id)\n"
565 " Set the primary slave for a bonded device.\n\n"
567 "show bonding config (port_id)\n"
568 " Show the bonding config for port_id.\n\n"
570 "set bonding mac_addr (port_id) (address)\n"
571 " Set the MAC address of a bonded device.\n\n"
573 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
574 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
576 "set bonding mon_period (port_id) (value)\n"
577 " Set the bonding link status monitoring polling period in ms.\n\n"
579 "set link-up port (port_id)\n"
580 " Set link up for a port.\n\n"
582 "set link-down port (port_id)\n"
583 " Set link down for a port.\n\n"
585 "E-tag set insertion on port-tag-id (value)"
586 " port (port_id) vf (vf_id)\n"
587 " Enable E-tag insertion for a VF on a port\n\n"
589 "E-tag set insertion off port (port_id) vf (vf_id)\n"
590 " Disable E-tag insertion for a VF on a port\n\n"
592 "E-tag set stripping (on|off) port (port_id)\n"
593 " Enable/disable E-tag stripping on a port\n\n"
595 "E-tag set forwarding (on|off) port (port_id)\n"
596 " Enable/disable E-tag based forwarding"
599 "E-tag set filter add e-tag-id (value) dst-pool"
600 " (pool_id) port (port_id)\n"
601 " Add an E-tag forwarding filter on a port\n\n"
603 "E-tag set filter del e-tag-id (value) port (port_id)\n"
604 " Delete an E-tag forwarding filter on a port\n\n"
606 "ddp add (port_id) (profile_path[,output_path])\n"
607 " Load a profile package on a port\n\n"
609 "ptype mapping get (port_id) (valid_only)\n"
610 " Get ptype mapping on a port\n\n"
612 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
613 " Replace target with the pkt_type in ptype mapping\n\n"
615 "ptype mapping reset (port_id)\n"
616 " Reset ptype mapping on a port\n\n"
618 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
619 " Update a ptype mapping item on a port\n\n"
621 , list_pkt_forwarding_modes()
625 if (show_all || !strcmp(res->section, "ports")) {
631 "----------------\n\n"
633 "port start (port_id|all)\n"
634 " Start all ports or port_id.\n\n"
636 "port stop (port_id|all)\n"
637 " Stop all ports or port_id.\n\n"
639 "port close (port_id|all)\n"
640 " Close all ports or port_id.\n\n"
642 "port attach (ident)\n"
643 " Attach physical or virtual dev by pci address or virtual device name\n\n"
645 "port detach (port_id)\n"
646 " Detach physical or virtual dev by port_id\n\n"
648 "port config (port_id|all)"
649 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
650 " duplex (half|full|auto)\n"
651 " Set speed and duplex for all ports or port_id\n\n"
653 "port config all (rxq|txq|rxd|txd) (value)\n"
654 " Set number for rxq/txq/rxd/txd.\n\n"
656 "port config all max-pkt-len (value)\n"
657 " Set the max packet length.\n\n"
659 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
660 "hw-vlan-strip|hw-vlan-extend|drop-en)"
662 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
665 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
666 " Set the RSS mode.\n\n"
668 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
669 " Set the RSS redirection table.\n\n"
671 "port config (port_id) dcb vt (on|off) (traffic_class)"
673 " Set the DCB mode.\n\n"
675 "port config all burst (value)\n"
676 " Set the number of packets per burst.\n\n"
678 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
680 " Set the ring prefetch/host/writeback threshold"
681 " for tx/rx queue.\n\n"
683 "port config all (txfreet|txrst|rxfreet) (value)\n"
684 " Set free threshold for rx/tx, or set"
685 " tx rs bit threshold.\n\n"
686 "port config mtu X value\n"
687 " Set the MTU of port X to a given value\n\n"
689 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
690 " Start/stop a rx/tx queue of port X. Only take effect"
691 " when port X is started\n\n"
693 "port config (port_id|all) l2-tunnel E-tag ether-type"
695 " Set the value of E-tag ether-type.\n\n"
697 "port config (port_id|all) l2-tunnel E-tag"
698 " (enable|disable)\n"
699 " Enable/disable the E-tag support.\n\n"
703 if (show_all || !strcmp(res->section, "registers")) {
711 "read reg (port_id) (address)\n"
712 " Display value of a port register.\n\n"
714 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
715 " Display a port register bit field.\n\n"
717 "read regbit (port_id) (address) (bit_x)\n"
718 " Display a single port register bit.\n\n"
720 "write reg (port_id) (address) (value)\n"
721 " Set value of a port register.\n\n"
723 "write regfield (port_id) (address) (bit_x) (bit_y)"
725 " Set bit field of a port register.\n\n"
727 "write regbit (port_id) (address) (bit_x) (value)\n"
728 " Set single bit value of a port register.\n\n"
731 if (show_all || !strcmp(res->section, "filters")) {
739 "ethertype_filter (port_id) (add|del)"
740 " (mac_addr|mac_ignr) (mac_address) ethertype"
741 " (ether_type) (drop|fwd) queue (queue_id)\n"
742 " Add/Del an ethertype filter.\n\n"
744 "2tuple_filter (port_id) (add|del)"
745 " dst_port (dst_port_value) protocol (protocol_value)"
746 " mask (mask_value) tcp_flags (tcp_flags_value)"
747 " priority (prio_value) queue (queue_id)\n"
748 " Add/Del a 2tuple filter.\n\n"
750 "5tuple_filter (port_id) (add|del)"
751 " dst_ip (dst_address) src_ip (src_address)"
752 " dst_port (dst_port_value) src_port (src_port_value)"
753 " protocol (protocol_value)"
754 " mask (mask_value) tcp_flags (tcp_flags_value)"
755 " priority (prio_value) queue (queue_id)\n"
756 " Add/Del a 5tuple filter.\n\n"
758 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
759 " Add/Del syn filter.\n\n"
761 "flex_filter (port_id) (add|del) len (len_value)"
762 " bytes (bytes_value) mask (mask_value)"
763 " priority (prio_value) queue (queue_id)\n"
764 " Add/Del a flex filter.\n\n"
766 "flow_director_filter (port_id) mode IP (add|del|update)"
767 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
768 " src (src_ip_address) dst (dst_ip_address)"
769 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
770 " vlan (vlan_value) flexbytes (flexbytes_value)"
771 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
772 " fd_id (fd_id_value)\n"
773 " Add/Del an IP type flow director filter.\n\n"
775 "flow_director_filter (port_id) mode IP (add|del|update)"
776 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
777 " src (src_ip_address) (src_port)"
778 " dst (dst_ip_address) (dst_port)"
779 " tos (tos_value) ttl (ttl_value)"
780 " vlan (vlan_value) flexbytes (flexbytes_value)"
781 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
782 " fd_id (fd_id_value)\n"
783 " Add/Del an UDP/TCP type flow director filter.\n\n"
785 "flow_director_filter (port_id) mode IP (add|del|update)"
786 " flow (ipv4-sctp|ipv6-sctp)"
787 " src (src_ip_address) (src_port)"
788 " dst (dst_ip_address) (dst_port)"
789 " tag (verification_tag) "
790 " tos (tos_value) ttl (ttl_value)"
792 " flexbytes (flexbytes_value) (drop|fwd)"
793 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
794 " Add/Del a SCTP type flow director filter.\n\n"
796 "flow_director_filter (port_id) mode IP (add|del|update)"
797 " flow l2_payload ether (ethertype)"
798 " flexbytes (flexbytes_value) (drop|fwd)"
799 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
800 " Add/Del a l2 payload type flow director filter.\n\n"
802 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
803 " mac (mac_address) vlan (vlan_value)"
804 " flexbytes (flexbytes_value) (drop|fwd)"
805 " queue (queue_id) fd_id (fd_id_value)\n"
806 " Add/Del a MAC-VLAN flow director filter.\n\n"
808 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
809 " mac (mac_address) vlan (vlan_value)"
810 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
811 " flexbytes (flexbytes_value) (drop|fwd)"
812 " queue (queue_id) fd_id (fd_id_value)\n"
813 " Add/Del a Tunnel flow director filter.\n\n"
815 "flush_flow_director (port_id)\n"
816 " Flush all flow director entries of a device.\n\n"
818 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
819 " src_mask (ipv4_src) (ipv6_src) (src_port)"
820 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
821 " Set flow director IP mask.\n\n"
823 "flow_director_mask (port_id) mode MAC-VLAN"
824 " vlan (vlan_value)\n"
825 " Set flow director MAC-VLAN mask.\n\n"
827 "flow_director_mask (port_id) mode Tunnel"
828 " vlan (vlan_value) mac (mac_value)"
829 " tunnel-type (tunnel_type_value)"
830 " tunnel-id (tunnel_id_value)\n"
831 " Set flow director Tunnel mask.\n\n"
833 "flow_director_flex_mask (port_id)"
834 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
835 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
837 " Configure mask of flex payload.\n\n"
839 "flow_director_flex_payload (port_id)"
840 " (raw|l2|l3|l4) (config)\n"
841 " Configure flex payload selection.\n\n"
843 "get_sym_hash_ena_per_port (port_id)\n"
844 " get symmetric hash enable configuration per port.\n\n"
846 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
847 " set symmetric hash enable configuration per port"
848 " to enable or disable.\n\n"
850 "get_hash_global_config (port_id)\n"
851 " Get the global configurations of hash filters.\n\n"
853 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
854 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
855 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
856 " (enable|disable)\n"
857 " Set the global configurations of hash filters.\n\n"
859 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
860 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
861 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
862 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
863 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
864 "ipv6-next-header|udp-src-port|udp-dst-port|"
865 "tcp-src-port|tcp-dst-port|sctp-src-port|"
866 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
867 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
868 "fld-8th|none) (select|add)\n"
869 " Set the input set for hash.\n\n"
871 "set_fdir_input_set (port_id) "
872 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
873 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
874 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
875 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
876 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
877 "udp-dst-port|tcp-src-port|tcp-dst-port|"
878 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
880 " Set the input set for FDir.\n\n"
882 "flow validate {port_id}"
883 " [group {group_id}] [priority {level}]"
884 " [ingress] [egress]"
885 " pattern {item} [/ {item} [...]] / end"
886 " actions {action} [/ {action} [...]] / end\n"
887 " Check whether a flow rule can be created.\n\n"
889 "flow create {port_id}"
890 " [group {group_id}] [priority {level}]"
891 " [ingress] [egress]"
892 " pattern {item} [/ {item} [...]] / end"
893 " actions {action} [/ {action} [...]] / end\n"
894 " Create a flow rule.\n\n"
896 "flow destroy {port_id} rule {rule_id} [...]\n"
897 " Destroy specific flow rules.\n\n"
899 "flow flush {port_id}\n"
900 " Destroy all flow rules.\n\n"
902 "flow query {port_id} {rule_id} {action}\n"
903 " Query an existing flow rule.\n\n"
905 "flow list {port_id} [group {group_id}] [...]\n"
906 " List existing flow rules sorted by priority,"
907 " filtered by group identifiers.\n\n"
909 "flow isolate {port_id} {boolean}\n"
910 " Restrict ingress traffic to the defined"
916 cmdline_parse_token_string_t cmd_help_long_help =
917 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
919 cmdline_parse_token_string_t cmd_help_long_section =
920 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
921 "all#control#display#config#"
922 "ports#registers#filters");
924 cmdline_parse_inst_t cmd_help_long = {
925 .f = cmd_help_long_parsed,
927 .help_str = "help all|control|display|config|ports|register|filters: "
930 (void *)&cmd_help_long_help,
931 (void *)&cmd_help_long_section,
937 /* *** start/stop/close all ports *** */
938 struct cmd_operate_port_result {
939 cmdline_fixed_string_t keyword;
940 cmdline_fixed_string_t name;
941 cmdline_fixed_string_t value;
944 static void cmd_operate_port_parsed(void *parsed_result,
945 __attribute__((unused)) struct cmdline *cl,
946 __attribute__((unused)) void *data)
948 struct cmd_operate_port_result *res = parsed_result;
950 if (!strcmp(res->name, "start"))
951 start_port(RTE_PORT_ALL);
952 else if (!strcmp(res->name, "stop"))
953 stop_port(RTE_PORT_ALL);
954 else if (!strcmp(res->name, "close"))
955 close_port(RTE_PORT_ALL);
957 printf("Unknown parameter\n");
960 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
961 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
963 cmdline_parse_token_string_t cmd_operate_port_all_port =
964 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
966 cmdline_parse_token_string_t cmd_operate_port_all_all =
967 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
969 cmdline_parse_inst_t cmd_operate_port = {
970 .f = cmd_operate_port_parsed,
972 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
974 (void *)&cmd_operate_port_all_cmd,
975 (void *)&cmd_operate_port_all_port,
976 (void *)&cmd_operate_port_all_all,
981 /* *** start/stop/close specific port *** */
982 struct cmd_operate_specific_port_result {
983 cmdline_fixed_string_t keyword;
984 cmdline_fixed_string_t name;
988 static void cmd_operate_specific_port_parsed(void *parsed_result,
989 __attribute__((unused)) struct cmdline *cl,
990 __attribute__((unused)) void *data)
992 struct cmd_operate_specific_port_result *res = parsed_result;
994 if (!strcmp(res->name, "start"))
995 start_port(res->value);
996 else if (!strcmp(res->name, "stop"))
997 stop_port(res->value);
998 else if (!strcmp(res->name, "close"))
999 close_port(res->value);
1001 printf("Unknown parameter\n");
1004 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1005 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1007 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1008 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1009 name, "start#stop#close");
1010 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1011 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1014 cmdline_parse_inst_t cmd_operate_specific_port = {
1015 .f = cmd_operate_specific_port_parsed,
1017 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1019 (void *)&cmd_operate_specific_port_cmd,
1020 (void *)&cmd_operate_specific_port_port,
1021 (void *)&cmd_operate_specific_port_id,
1026 /* *** attach a specified port *** */
1027 struct cmd_operate_attach_port_result {
1028 cmdline_fixed_string_t port;
1029 cmdline_fixed_string_t keyword;
1030 cmdline_fixed_string_t identifier;
1033 static void cmd_operate_attach_port_parsed(void *parsed_result,
1034 __attribute__((unused)) struct cmdline *cl,
1035 __attribute__((unused)) void *data)
1037 struct cmd_operate_attach_port_result *res = parsed_result;
1039 if (!strcmp(res->keyword, "attach"))
1040 attach_port(res->identifier);
1042 printf("Unknown parameter\n");
1045 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1046 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1048 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1049 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1051 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1052 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1055 cmdline_parse_inst_t cmd_operate_attach_port = {
1056 .f = cmd_operate_attach_port_parsed,
1058 .help_str = "port attach <identifier>: "
1059 "(identifier: pci address or virtual dev name)",
1061 (void *)&cmd_operate_attach_port_port,
1062 (void *)&cmd_operate_attach_port_keyword,
1063 (void *)&cmd_operate_attach_port_identifier,
1068 /* *** detach a specified port *** */
1069 struct cmd_operate_detach_port_result {
1070 cmdline_fixed_string_t port;
1071 cmdline_fixed_string_t keyword;
1075 static void cmd_operate_detach_port_parsed(void *parsed_result,
1076 __attribute__((unused)) struct cmdline *cl,
1077 __attribute__((unused)) void *data)
1079 struct cmd_operate_detach_port_result *res = parsed_result;
1081 if (!strcmp(res->keyword, "detach"))
1082 detach_port(res->port_id);
1084 printf("Unknown parameter\n");
1087 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1088 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1090 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1091 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1093 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1094 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1097 cmdline_parse_inst_t cmd_operate_detach_port = {
1098 .f = cmd_operate_detach_port_parsed,
1100 .help_str = "port detach <port_id>",
1102 (void *)&cmd_operate_detach_port_port,
1103 (void *)&cmd_operate_detach_port_keyword,
1104 (void *)&cmd_operate_detach_port_port_id,
1109 /* *** configure speed for all ports *** */
1110 struct cmd_config_speed_all {
1111 cmdline_fixed_string_t port;
1112 cmdline_fixed_string_t keyword;
1113 cmdline_fixed_string_t all;
1114 cmdline_fixed_string_t item1;
1115 cmdline_fixed_string_t item2;
1116 cmdline_fixed_string_t value1;
1117 cmdline_fixed_string_t value2;
1121 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1126 if (!strcmp(duplexstr, "half")) {
1127 duplex = ETH_LINK_HALF_DUPLEX;
1128 } else if (!strcmp(duplexstr, "full")) {
1129 duplex = ETH_LINK_FULL_DUPLEX;
1130 } else if (!strcmp(duplexstr, "auto")) {
1131 duplex = ETH_LINK_FULL_DUPLEX;
1133 printf("Unknown duplex parameter\n");
1137 if (!strcmp(speedstr, "10")) {
1138 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1139 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1140 } else if (!strcmp(speedstr, "100")) {
1141 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1142 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1144 if (duplex != ETH_LINK_FULL_DUPLEX) {
1145 printf("Invalid speed/duplex parameters\n");
1148 if (!strcmp(speedstr, "1000")) {
1149 *speed = ETH_LINK_SPEED_1G;
1150 } else if (!strcmp(speedstr, "10000")) {
1151 *speed = ETH_LINK_SPEED_10G;
1152 } else if (!strcmp(speedstr, "25000")) {
1153 *speed = ETH_LINK_SPEED_25G;
1154 } else if (!strcmp(speedstr, "40000")) {
1155 *speed = ETH_LINK_SPEED_40G;
1156 } else if (!strcmp(speedstr, "50000")) {
1157 *speed = ETH_LINK_SPEED_50G;
1158 } else if (!strcmp(speedstr, "100000")) {
1159 *speed = ETH_LINK_SPEED_100G;
1160 } else if (!strcmp(speedstr, "auto")) {
1161 *speed = ETH_LINK_SPEED_AUTONEG;
1163 printf("Unknown speed parameter\n");
1172 cmd_config_speed_all_parsed(void *parsed_result,
1173 __attribute__((unused)) struct cmdline *cl,
1174 __attribute__((unused)) void *data)
1176 struct cmd_config_speed_all *res = parsed_result;
1177 uint32_t link_speed;
1180 if (!all_ports_stopped()) {
1181 printf("Please stop all ports first\n");
1185 if (parse_and_check_speed_duplex(res->value1, res->value2,
1189 RTE_ETH_FOREACH_DEV(pid) {
1190 ports[pid].dev_conf.link_speeds = link_speed;
1193 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1196 cmdline_parse_token_string_t cmd_config_speed_all_port =
1197 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1198 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1199 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1201 cmdline_parse_token_string_t cmd_config_speed_all_all =
1202 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1203 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1204 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1205 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1206 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1207 "10#100#1000#10000#25000#40000#50000#100000#auto");
1208 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1209 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1210 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1211 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1214 cmdline_parse_inst_t cmd_config_speed_all = {
1215 .f = cmd_config_speed_all_parsed,
1217 .help_str = "port config all speed "
1218 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1221 (void *)&cmd_config_speed_all_port,
1222 (void *)&cmd_config_speed_all_keyword,
1223 (void *)&cmd_config_speed_all_all,
1224 (void *)&cmd_config_speed_all_item1,
1225 (void *)&cmd_config_speed_all_value1,
1226 (void *)&cmd_config_speed_all_item2,
1227 (void *)&cmd_config_speed_all_value2,
1232 /* *** configure speed for specific port *** */
1233 struct cmd_config_speed_specific {
1234 cmdline_fixed_string_t port;
1235 cmdline_fixed_string_t keyword;
1237 cmdline_fixed_string_t item1;
1238 cmdline_fixed_string_t item2;
1239 cmdline_fixed_string_t value1;
1240 cmdline_fixed_string_t value2;
1244 cmd_config_speed_specific_parsed(void *parsed_result,
1245 __attribute__((unused)) struct cmdline *cl,
1246 __attribute__((unused)) void *data)
1248 struct cmd_config_speed_specific *res = parsed_result;
1249 uint32_t link_speed;
1251 if (!all_ports_stopped()) {
1252 printf("Please stop all ports first\n");
1256 if (port_id_is_invalid(res->id, ENABLED_WARN))
1259 if (parse_and_check_speed_duplex(res->value1, res->value2,
1263 ports[res->id].dev_conf.link_speeds = link_speed;
1265 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1269 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1270 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1272 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1273 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1275 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1276 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1277 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1278 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1280 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1282 "10#100#1000#10000#25000#40000#50000#100000#auto");
1283 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1284 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1286 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1287 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1290 cmdline_parse_inst_t cmd_config_speed_specific = {
1291 .f = cmd_config_speed_specific_parsed,
1293 .help_str = "port config <port_id> speed "
1294 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1297 (void *)&cmd_config_speed_specific_port,
1298 (void *)&cmd_config_speed_specific_keyword,
1299 (void *)&cmd_config_speed_specific_id,
1300 (void *)&cmd_config_speed_specific_item1,
1301 (void *)&cmd_config_speed_specific_value1,
1302 (void *)&cmd_config_speed_specific_item2,
1303 (void *)&cmd_config_speed_specific_value2,
1308 /* *** configure txq/rxq, txd/rxd *** */
1309 struct cmd_config_rx_tx {
1310 cmdline_fixed_string_t port;
1311 cmdline_fixed_string_t keyword;
1312 cmdline_fixed_string_t all;
1313 cmdline_fixed_string_t name;
1318 cmd_config_rx_tx_parsed(void *parsed_result,
1319 __attribute__((unused)) struct cmdline *cl,
1320 __attribute__((unused)) void *data)
1322 struct cmd_config_rx_tx *res = parsed_result;
1324 if (!all_ports_stopped()) {
1325 printf("Please stop all ports first\n");
1328 if (!strcmp(res->name, "rxq")) {
1329 if (!res->value && !nb_txq) {
1330 printf("Warning: Either rx or tx queues should be non zero\n");
1333 nb_rxq = res->value;
1335 else if (!strcmp(res->name, "txq")) {
1336 if (!res->value && !nb_rxq) {
1337 printf("Warning: Either rx or tx queues should be non zero\n");
1340 nb_txq = res->value;
1342 else if (!strcmp(res->name, "rxd")) {
1343 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1344 printf("rxd %d invalid - must be > 0 && <= %d\n",
1345 res->value, RTE_TEST_RX_DESC_MAX);
1348 nb_rxd = res->value;
1349 } else if (!strcmp(res->name, "txd")) {
1350 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1351 printf("txd %d invalid - must be > 0 && <= %d\n",
1352 res->value, RTE_TEST_TX_DESC_MAX);
1355 nb_txd = res->value;
1357 printf("Unknown parameter\n");
1365 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1368 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1369 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1370 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1371 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1372 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1373 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1374 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1375 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1377 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1378 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1380 cmdline_parse_inst_t cmd_config_rx_tx = {
1381 .f = cmd_config_rx_tx_parsed,
1383 .help_str = "port config all rxq|txq|rxd|txd <value>",
1385 (void *)&cmd_config_rx_tx_port,
1386 (void *)&cmd_config_rx_tx_keyword,
1387 (void *)&cmd_config_rx_tx_all,
1388 (void *)&cmd_config_rx_tx_name,
1389 (void *)&cmd_config_rx_tx_value,
1394 /* *** config max packet length *** */
1395 struct cmd_config_max_pkt_len_result {
1396 cmdline_fixed_string_t port;
1397 cmdline_fixed_string_t keyword;
1398 cmdline_fixed_string_t all;
1399 cmdline_fixed_string_t name;
1404 cmd_config_max_pkt_len_parsed(void *parsed_result,
1405 __attribute__((unused)) struct cmdline *cl,
1406 __attribute__((unused)) void *data)
1408 struct cmd_config_max_pkt_len_result *res = parsed_result;
1410 if (!all_ports_stopped()) {
1411 printf("Please stop all ports first\n");
1415 if (!strcmp(res->name, "max-pkt-len")) {
1416 if (res->value < ETHER_MIN_LEN) {
1417 printf("max-pkt-len can not be less than %d\n",
1421 if (res->value == rx_mode.max_rx_pkt_len)
1424 rx_mode.max_rx_pkt_len = res->value;
1425 if (res->value > ETHER_MAX_LEN)
1426 rx_mode.jumbo_frame = 1;
1428 rx_mode.jumbo_frame = 0;
1430 printf("Unknown parameter\n");
1436 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1439 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1440 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1442 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1443 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1445 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1446 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1448 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1449 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1451 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1452 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1455 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1456 .f = cmd_config_max_pkt_len_parsed,
1458 .help_str = "port config all max-pkt-len <value>",
1460 (void *)&cmd_config_max_pkt_len_port,
1461 (void *)&cmd_config_max_pkt_len_keyword,
1462 (void *)&cmd_config_max_pkt_len_all,
1463 (void *)&cmd_config_max_pkt_len_name,
1464 (void *)&cmd_config_max_pkt_len_value,
1469 /* *** configure port MTU *** */
1470 struct cmd_config_mtu_result {
1471 cmdline_fixed_string_t port;
1472 cmdline_fixed_string_t keyword;
1473 cmdline_fixed_string_t mtu;
1479 cmd_config_mtu_parsed(void *parsed_result,
1480 __attribute__((unused)) struct cmdline *cl,
1481 __attribute__((unused)) void *data)
1483 struct cmd_config_mtu_result *res = parsed_result;
1485 if (res->value < ETHER_MIN_LEN) {
1486 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1489 port_mtu_set(res->port_id, res->value);
1492 cmdline_parse_token_string_t cmd_config_mtu_port =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1495 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1496 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1498 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1499 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1501 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1502 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1503 cmdline_parse_token_num_t cmd_config_mtu_value =
1504 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1506 cmdline_parse_inst_t cmd_config_mtu = {
1507 .f = cmd_config_mtu_parsed,
1509 .help_str = "port config mtu <port_id> <value>",
1511 (void *)&cmd_config_mtu_port,
1512 (void *)&cmd_config_mtu_keyword,
1513 (void *)&cmd_config_mtu_mtu,
1514 (void *)&cmd_config_mtu_port_id,
1515 (void *)&cmd_config_mtu_value,
1520 /* *** configure rx mode *** */
1521 struct cmd_config_rx_mode_flag {
1522 cmdline_fixed_string_t port;
1523 cmdline_fixed_string_t keyword;
1524 cmdline_fixed_string_t all;
1525 cmdline_fixed_string_t name;
1526 cmdline_fixed_string_t value;
1530 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1531 __attribute__((unused)) struct cmdline *cl,
1532 __attribute__((unused)) void *data)
1534 struct cmd_config_rx_mode_flag *res = parsed_result;
1536 if (!all_ports_stopped()) {
1537 printf("Please stop all ports first\n");
1541 if (!strcmp(res->name, "crc-strip")) {
1542 if (!strcmp(res->value, "on"))
1543 rx_mode.hw_strip_crc = 1;
1544 else if (!strcmp(res->value, "off"))
1545 rx_mode.hw_strip_crc = 0;
1547 printf("Unknown parameter\n");
1550 } else if (!strcmp(res->name, "scatter")) {
1551 if (!strcmp(res->value, "on"))
1552 rx_mode.enable_scatter = 1;
1553 else if (!strcmp(res->value, "off"))
1554 rx_mode.enable_scatter = 0;
1556 printf("Unknown parameter\n");
1559 } else if (!strcmp(res->name, "rx-cksum")) {
1560 if (!strcmp(res->value, "on"))
1561 rx_mode.hw_ip_checksum = 1;
1562 else if (!strcmp(res->value, "off"))
1563 rx_mode.hw_ip_checksum = 0;
1565 printf("Unknown parameter\n");
1568 } else if (!strcmp(res->name, "hw-vlan")) {
1569 if (!strcmp(res->value, "on")) {
1570 rx_mode.hw_vlan_filter = 1;
1571 rx_mode.hw_vlan_strip = 1;
1573 else if (!strcmp(res->value, "off")) {
1574 rx_mode.hw_vlan_filter = 0;
1575 rx_mode.hw_vlan_strip = 0;
1578 printf("Unknown parameter\n");
1581 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1582 if (!strcmp(res->value, "on"))
1583 rx_mode.hw_vlan_filter = 1;
1584 else if (!strcmp(res->value, "off"))
1585 rx_mode.hw_vlan_filter = 0;
1587 printf("Unknown parameter\n");
1590 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1591 if (!strcmp(res->value, "on"))
1592 rx_mode.hw_vlan_strip = 1;
1593 else if (!strcmp(res->value, "off"))
1594 rx_mode.hw_vlan_strip = 0;
1596 printf("Unknown parameter\n");
1599 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1600 if (!strcmp(res->value, "on"))
1601 rx_mode.hw_vlan_extend = 1;
1602 else if (!strcmp(res->value, "off"))
1603 rx_mode.hw_vlan_extend = 0;
1605 printf("Unknown parameter\n");
1608 } else if (!strcmp(res->name, "drop-en")) {
1609 if (!strcmp(res->value, "on"))
1611 else if (!strcmp(res->value, "off"))
1614 printf("Unknown parameter\n");
1618 printf("Unknown parameter\n");
1624 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1627 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1629 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1630 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1632 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1634 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1635 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1636 "crc-strip#scatter#rx-cksum#hw-vlan#"
1637 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1638 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1639 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1642 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1643 .f = cmd_config_rx_mode_flag_parsed,
1645 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1646 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1648 (void *)&cmd_config_rx_mode_flag_port,
1649 (void *)&cmd_config_rx_mode_flag_keyword,
1650 (void *)&cmd_config_rx_mode_flag_all,
1651 (void *)&cmd_config_rx_mode_flag_name,
1652 (void *)&cmd_config_rx_mode_flag_value,
1657 /* *** configure rss *** */
1658 struct cmd_config_rss {
1659 cmdline_fixed_string_t port;
1660 cmdline_fixed_string_t keyword;
1661 cmdline_fixed_string_t all;
1662 cmdline_fixed_string_t name;
1663 cmdline_fixed_string_t value;
1667 cmd_config_rss_parsed(void *parsed_result,
1668 __attribute__((unused)) struct cmdline *cl,
1669 __attribute__((unused)) void *data)
1671 struct cmd_config_rss *res = parsed_result;
1672 struct rte_eth_rss_conf rss_conf;
1676 if (!strcmp(res->value, "all"))
1677 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1678 ETH_RSS_UDP | ETH_RSS_SCTP |
1680 else if (!strcmp(res->value, "ip"))
1681 rss_conf.rss_hf = ETH_RSS_IP;
1682 else if (!strcmp(res->value, "udp"))
1683 rss_conf.rss_hf = ETH_RSS_UDP;
1684 else if (!strcmp(res->value, "tcp"))
1685 rss_conf.rss_hf = ETH_RSS_TCP;
1686 else if (!strcmp(res->value, "sctp"))
1687 rss_conf.rss_hf = ETH_RSS_SCTP;
1688 else if (!strcmp(res->value, "ether"))
1689 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1690 else if (!strcmp(res->value, "port"))
1691 rss_conf.rss_hf = ETH_RSS_PORT;
1692 else if (!strcmp(res->value, "vxlan"))
1693 rss_conf.rss_hf = ETH_RSS_VXLAN;
1694 else if (!strcmp(res->value, "geneve"))
1695 rss_conf.rss_hf = ETH_RSS_GENEVE;
1696 else if (!strcmp(res->value, "nvgre"))
1697 rss_conf.rss_hf = ETH_RSS_NVGRE;
1698 else if (!strcmp(res->value, "none"))
1699 rss_conf.rss_hf = 0;
1701 printf("Unknown parameter\n");
1704 rss_conf.rss_key = NULL;
1705 for (i = 0; i < rte_eth_dev_count(); i++) {
1706 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1708 printf("Configuration of RSS hash at ethernet port %d "
1709 "failed with error (%d): %s.\n",
1710 i, -diag, strerror(-diag));
1714 cmdline_parse_token_string_t cmd_config_rss_port =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1716 cmdline_parse_token_string_t cmd_config_rss_keyword =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1718 cmdline_parse_token_string_t cmd_config_rss_all =
1719 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1720 cmdline_parse_token_string_t cmd_config_rss_name =
1721 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1722 cmdline_parse_token_string_t cmd_config_rss_value =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1724 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1726 cmdline_parse_inst_t cmd_config_rss = {
1727 .f = cmd_config_rss_parsed,
1729 .help_str = "port config all rss "
1730 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1732 (void *)&cmd_config_rss_port,
1733 (void *)&cmd_config_rss_keyword,
1734 (void *)&cmd_config_rss_all,
1735 (void *)&cmd_config_rss_name,
1736 (void *)&cmd_config_rss_value,
1741 /* *** configure rss hash key *** */
1742 struct cmd_config_rss_hash_key {
1743 cmdline_fixed_string_t port;
1744 cmdline_fixed_string_t config;
1746 cmdline_fixed_string_t rss_hash_key;
1747 cmdline_fixed_string_t rss_type;
1748 cmdline_fixed_string_t key;
1752 hexa_digit_to_value(char hexa_digit)
1754 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1755 return (uint8_t) (hexa_digit - '0');
1756 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1757 return (uint8_t) ((hexa_digit - 'a') + 10);
1758 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1759 return (uint8_t) ((hexa_digit - 'A') + 10);
1760 /* Invalid hexa digit */
1765 parse_and_check_key_hexa_digit(char *key, int idx)
1769 hexa_v = hexa_digit_to_value(key[idx]);
1771 printf("invalid key: character %c at position %d is not a "
1772 "valid hexa digit\n", key[idx], idx);
1777 cmd_config_rss_hash_key_parsed(void *parsed_result,
1778 __attribute__((unused)) struct cmdline *cl,
1779 __attribute__((unused)) void *data)
1781 struct cmd_config_rss_hash_key *res = parsed_result;
1782 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1786 struct rte_eth_dev_info dev_info;
1787 uint8_t hash_key_size;
1790 memset(&dev_info, 0, sizeof(dev_info));
1791 rte_eth_dev_info_get(res->port_id, &dev_info);
1792 if (dev_info.hash_key_size > 0 &&
1793 dev_info.hash_key_size <= sizeof(hash_key))
1794 hash_key_size = dev_info.hash_key_size;
1796 printf("dev_info did not provide a valid hash key size\n");
1799 /* Check the length of the RSS hash key */
1800 key_len = strlen(res->key);
1801 if (key_len != (hash_key_size * 2)) {
1802 printf("key length: %d invalid - key must be a string of %d"
1803 " hexa-decimal numbers\n",
1804 (int) key_len, hash_key_size * 2);
1807 /* Translate RSS hash key into binary representation */
1808 for (i = 0; i < hash_key_size; i++) {
1809 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1812 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1815 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1817 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1821 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1822 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1823 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1824 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1826 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1827 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1828 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1829 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1830 rss_hash_key, "rss-hash-key");
1831 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1833 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1834 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1835 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1836 "ipv6-tcp-ex#ipv6-udp-ex");
1837 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1838 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1840 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1841 .f = cmd_config_rss_hash_key_parsed,
1843 .help_str = "port config <port_id> rss-hash-key "
1844 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1845 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1846 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1847 "<string of hex digits (variable length, NIC dependent)>",
1849 (void *)&cmd_config_rss_hash_key_port,
1850 (void *)&cmd_config_rss_hash_key_config,
1851 (void *)&cmd_config_rss_hash_key_port_id,
1852 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1853 (void *)&cmd_config_rss_hash_key_rss_type,
1854 (void *)&cmd_config_rss_hash_key_value,
1859 /* *** configure port rxq/txq start/stop *** */
1860 struct cmd_config_rxtx_queue {
1861 cmdline_fixed_string_t port;
1863 cmdline_fixed_string_t rxtxq;
1865 cmdline_fixed_string_t opname;
1869 cmd_config_rxtx_queue_parsed(void *parsed_result,
1870 __attribute__((unused)) struct cmdline *cl,
1871 __attribute__((unused)) void *data)
1873 struct cmd_config_rxtx_queue *res = parsed_result;
1878 if (test_done == 0) {
1879 printf("Please stop forwarding first\n");
1883 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1886 if (port_is_started(res->portid) != 1) {
1887 printf("Please start port %u first\n", res->portid);
1891 if (!strcmp(res->rxtxq, "rxq"))
1893 else if (!strcmp(res->rxtxq, "txq"))
1896 printf("Unknown parameter\n");
1900 if (isrx && rx_queue_id_is_invalid(res->qid))
1902 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1905 if (!strcmp(res->opname, "start"))
1907 else if (!strcmp(res->opname, "stop"))
1910 printf("Unknown parameter\n");
1914 if (isstart && isrx)
1915 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1916 else if (!isstart && isrx)
1917 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1918 else if (isstart && !isrx)
1919 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1921 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1923 if (ret == -ENOTSUP)
1924 printf("Function not supported in PMD driver\n");
1927 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1929 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1930 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1931 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1932 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1933 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1934 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1935 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1939 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1940 .f = cmd_config_rxtx_queue_parsed,
1942 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1944 (void *)&cmd_config_speed_all_port,
1945 (void *)&cmd_config_rxtx_queue_portid,
1946 (void *)&cmd_config_rxtx_queue_rxtxq,
1947 (void *)&cmd_config_rxtx_queue_qid,
1948 (void *)&cmd_config_rxtx_queue_opname,
1953 /* *** Configure RSS RETA *** */
1954 struct cmd_config_rss_reta {
1955 cmdline_fixed_string_t port;
1956 cmdline_fixed_string_t keyword;
1958 cmdline_fixed_string_t name;
1959 cmdline_fixed_string_t list_name;
1960 cmdline_fixed_string_t list_of_items;
1964 parse_reta_config(const char *str,
1965 struct rte_eth_rss_reta_entry64 *reta_conf,
1966 uint16_t nb_entries)
1970 uint16_t hash_index, idx, shift;
1973 const char *p, *p0 = str;
1980 unsigned long int_fld[_NUM_FLD];
1981 char *str_fld[_NUM_FLD];
1983 while ((p = strchr(p0,'(')) != NULL) {
1985 if((p0 = strchr(p,')')) == NULL)
1989 if(size >= sizeof(s))
1992 snprintf(s, sizeof(s), "%.*s", size, p);
1993 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1995 for (i = 0; i < _NUM_FLD; i++) {
1997 int_fld[i] = strtoul(str_fld[i], &end, 0);
1998 if (errno != 0 || end == str_fld[i] ||
2003 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2004 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2006 if (hash_index >= nb_entries) {
2007 printf("Invalid RETA hash index=%d\n", hash_index);
2011 idx = hash_index / RTE_RETA_GROUP_SIZE;
2012 shift = hash_index % RTE_RETA_GROUP_SIZE;
2013 reta_conf[idx].mask |= (1ULL << shift);
2014 reta_conf[idx].reta[shift] = nb_queue;
2021 cmd_set_rss_reta_parsed(void *parsed_result,
2022 __attribute__((unused)) struct cmdline *cl,
2023 __attribute__((unused)) void *data)
2026 struct rte_eth_dev_info dev_info;
2027 struct rte_eth_rss_reta_entry64 reta_conf[8];
2028 struct cmd_config_rss_reta *res = parsed_result;
2030 memset(&dev_info, 0, sizeof(dev_info));
2031 rte_eth_dev_info_get(res->port_id, &dev_info);
2032 if (dev_info.reta_size == 0) {
2033 printf("Redirection table size is 0 which is "
2034 "invalid for RSS\n");
2037 printf("The reta size of port %d is %u\n",
2038 res->port_id, dev_info.reta_size);
2039 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2040 printf("Currently do not support more than %u entries of "
2041 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2045 memset(reta_conf, 0, sizeof(reta_conf));
2046 if (!strcmp(res->list_name, "reta")) {
2047 if (parse_reta_config(res->list_of_items, reta_conf,
2048 dev_info.reta_size)) {
2049 printf("Invalid RSS Redirection Table "
2050 "config entered\n");
2053 ret = rte_eth_dev_rss_reta_update(res->port_id,
2054 reta_conf, dev_info.reta_size);
2056 printf("Bad redirection table parameter, "
2057 "return code = %d \n", ret);
2061 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2063 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2065 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2066 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2067 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2068 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2069 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2071 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2074 cmdline_parse_inst_t cmd_config_rss_reta = {
2075 .f = cmd_set_rss_reta_parsed,
2077 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2079 (void *)&cmd_config_rss_reta_port,
2080 (void *)&cmd_config_rss_reta_keyword,
2081 (void *)&cmd_config_rss_reta_port_id,
2082 (void *)&cmd_config_rss_reta_name,
2083 (void *)&cmd_config_rss_reta_list_name,
2084 (void *)&cmd_config_rss_reta_list_of_items,
2089 /* *** SHOW PORT RETA INFO *** */
2090 struct cmd_showport_reta {
2091 cmdline_fixed_string_t show;
2092 cmdline_fixed_string_t port;
2094 cmdline_fixed_string_t rss;
2095 cmdline_fixed_string_t reta;
2097 cmdline_fixed_string_t list_of_items;
2101 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2102 uint16_t nb_entries,
2106 const char *p, *p0 = str;
2111 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2112 RTE_RETA_GROUP_SIZE;
2115 p = strchr(p0, '(');
2119 p0 = strchr(p, ')');
2123 if (size >= sizeof(s)) {
2124 printf("The string size exceeds the internal buffer size\n");
2127 snprintf(s, sizeof(s), "%.*s", size, p);
2128 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2129 if (ret <= 0 || ret != num) {
2130 printf("The bits of masks do not match the number of "
2131 "reta entries: %u\n", num);
2134 for (i = 0; i < ret; i++)
2135 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2141 cmd_showport_reta_parsed(void *parsed_result,
2142 __attribute__((unused)) struct cmdline *cl,
2143 __attribute__((unused)) void *data)
2145 struct cmd_showport_reta *res = parsed_result;
2146 struct rte_eth_rss_reta_entry64 reta_conf[8];
2147 struct rte_eth_dev_info dev_info;
2149 memset(&dev_info, 0, sizeof(dev_info));
2150 rte_eth_dev_info_get(res->port_id, &dev_info);
2151 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2152 res->size > ETH_RSS_RETA_SIZE_512) {
2153 printf("Invalid redirection table size: %u\n", res->size);
2157 memset(reta_conf, 0, sizeof(reta_conf));
2158 if (showport_parse_reta_config(reta_conf, res->size,
2159 res->list_of_items) < 0) {
2160 printf("Invalid string: %s for reta masks\n",
2161 res->list_of_items);
2164 port_rss_reta_info(res->port_id, reta_conf, res->size);
2167 cmdline_parse_token_string_t cmd_showport_reta_show =
2168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2169 cmdline_parse_token_string_t cmd_showport_reta_port =
2170 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2171 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2172 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2173 cmdline_parse_token_string_t cmd_showport_reta_rss =
2174 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2175 cmdline_parse_token_string_t cmd_showport_reta_reta =
2176 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2177 cmdline_parse_token_num_t cmd_showport_reta_size =
2178 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2179 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2180 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2181 list_of_items, NULL);
2183 cmdline_parse_inst_t cmd_showport_reta = {
2184 .f = cmd_showport_reta_parsed,
2186 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2188 (void *)&cmd_showport_reta_show,
2189 (void *)&cmd_showport_reta_port,
2190 (void *)&cmd_showport_reta_port_id,
2191 (void *)&cmd_showport_reta_rss,
2192 (void *)&cmd_showport_reta_reta,
2193 (void *)&cmd_showport_reta_size,
2194 (void *)&cmd_showport_reta_list_of_items,
2199 /* *** Show RSS hash configuration *** */
2200 struct cmd_showport_rss_hash {
2201 cmdline_fixed_string_t show;
2202 cmdline_fixed_string_t port;
2204 cmdline_fixed_string_t rss_hash;
2205 cmdline_fixed_string_t rss_type;
2206 cmdline_fixed_string_t key; /* optional argument */
2209 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2210 __attribute__((unused)) struct cmdline *cl,
2213 struct cmd_showport_rss_hash *res = parsed_result;
2215 port_rss_hash_conf_show(res->port_id, res->rss_type,
2216 show_rss_key != NULL);
2219 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2220 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2221 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2222 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2223 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2224 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2225 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2226 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2228 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2229 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2230 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2231 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2232 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2233 "ipv6-tcp-ex#ipv6-udp-ex");
2234 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2235 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2237 cmdline_parse_inst_t cmd_showport_rss_hash = {
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",
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,
2254 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2255 .f = cmd_showport_rss_hash_parsed,
2257 .help_str = "show port <port_id> rss-hash "
2258 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2259 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2260 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2262 (void *)&cmd_showport_rss_hash_show,
2263 (void *)&cmd_showport_rss_hash_port,
2264 (void *)&cmd_showport_rss_hash_port_id,
2265 (void *)&cmd_showport_rss_hash_rss_hash,
2266 (void *)&cmd_showport_rss_hash_rss_hash_info,
2267 (void *)&cmd_showport_rss_hash_rss_key,
2272 /* *** Configure DCB *** */
2273 struct cmd_config_dcb {
2274 cmdline_fixed_string_t port;
2275 cmdline_fixed_string_t config;
2277 cmdline_fixed_string_t dcb;
2278 cmdline_fixed_string_t vt;
2279 cmdline_fixed_string_t vt_en;
2281 cmdline_fixed_string_t pfc;
2282 cmdline_fixed_string_t pfc_en;
2286 cmd_config_dcb_parsed(void *parsed_result,
2287 __attribute__((unused)) struct cmdline *cl,
2288 __attribute__((unused)) void *data)
2290 struct cmd_config_dcb *res = parsed_result;
2291 portid_t port_id = res->port_id;
2292 struct rte_port *port;
2296 port = &ports[port_id];
2297 /** Check if the port is not started **/
2298 if (port->port_status != RTE_PORT_STOPPED) {
2299 printf("Please stop port %d first\n", port_id);
2303 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2304 printf("The invalid number of traffic class,"
2305 " only 4 or 8 allowed.\n");
2309 if (nb_fwd_lcores < res->num_tcs) {
2310 printf("nb_cores shouldn't be less than number of TCs.\n");
2313 if (!strncmp(res->pfc_en, "on", 2))
2318 /* DCB in VT mode */
2319 if (!strncmp(res->vt_en, "on", 2))
2320 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2321 (enum rte_eth_nb_tcs)res->num_tcs,
2324 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2325 (enum rte_eth_nb_tcs)res->num_tcs,
2330 printf("Cannot initialize network ports.\n");
2334 cmd_reconfig_device_queue(port_id, 1, 1);
2337 cmdline_parse_token_string_t cmd_config_dcb_port =
2338 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2339 cmdline_parse_token_string_t cmd_config_dcb_config =
2340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2341 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2342 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2343 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2344 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2345 cmdline_parse_token_string_t cmd_config_dcb_vt =
2346 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2347 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2348 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2349 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2350 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2351 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2352 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2353 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2354 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2356 cmdline_parse_inst_t cmd_config_dcb = {
2357 .f = cmd_config_dcb_parsed,
2359 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2361 (void *)&cmd_config_dcb_port,
2362 (void *)&cmd_config_dcb_config,
2363 (void *)&cmd_config_dcb_port_id,
2364 (void *)&cmd_config_dcb_dcb,
2365 (void *)&cmd_config_dcb_vt,
2366 (void *)&cmd_config_dcb_vt_en,
2367 (void *)&cmd_config_dcb_num_tcs,
2368 (void *)&cmd_config_dcb_pfc,
2369 (void *)&cmd_config_dcb_pfc_en,
2374 /* *** configure number of packets per burst *** */
2375 struct cmd_config_burst {
2376 cmdline_fixed_string_t port;
2377 cmdline_fixed_string_t keyword;
2378 cmdline_fixed_string_t all;
2379 cmdline_fixed_string_t name;
2384 cmd_config_burst_parsed(void *parsed_result,
2385 __attribute__((unused)) struct cmdline *cl,
2386 __attribute__((unused)) void *data)
2388 struct cmd_config_burst *res = parsed_result;
2390 if (!all_ports_stopped()) {
2391 printf("Please stop all ports first\n");
2395 if (!strcmp(res->name, "burst")) {
2396 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2397 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2400 nb_pkt_per_burst = res->value;
2402 printf("Unknown parameter\n");
2408 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2411 cmdline_parse_token_string_t cmd_config_burst_port =
2412 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2413 cmdline_parse_token_string_t cmd_config_burst_keyword =
2414 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2415 cmdline_parse_token_string_t cmd_config_burst_all =
2416 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2417 cmdline_parse_token_string_t cmd_config_burst_name =
2418 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2419 cmdline_parse_token_num_t cmd_config_burst_value =
2420 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2422 cmdline_parse_inst_t cmd_config_burst = {
2423 .f = cmd_config_burst_parsed,
2425 .help_str = "port config all burst <value>",
2427 (void *)&cmd_config_burst_port,
2428 (void *)&cmd_config_burst_keyword,
2429 (void *)&cmd_config_burst_all,
2430 (void *)&cmd_config_burst_name,
2431 (void *)&cmd_config_burst_value,
2436 /* *** configure rx/tx queues *** */
2437 struct cmd_config_thresh {
2438 cmdline_fixed_string_t port;
2439 cmdline_fixed_string_t keyword;
2440 cmdline_fixed_string_t all;
2441 cmdline_fixed_string_t name;
2446 cmd_config_thresh_parsed(void *parsed_result,
2447 __attribute__((unused)) struct cmdline *cl,
2448 __attribute__((unused)) void *data)
2450 struct cmd_config_thresh *res = parsed_result;
2452 if (!all_ports_stopped()) {
2453 printf("Please stop all ports first\n");
2457 if (!strcmp(res->name, "txpt"))
2458 tx_pthresh = res->value;
2459 else if(!strcmp(res->name, "txht"))
2460 tx_hthresh = res->value;
2461 else if(!strcmp(res->name, "txwt"))
2462 tx_wthresh = res->value;
2463 else if(!strcmp(res->name, "rxpt"))
2464 rx_pthresh = res->value;
2465 else if(!strcmp(res->name, "rxht"))
2466 rx_hthresh = res->value;
2467 else if(!strcmp(res->name, "rxwt"))
2468 rx_wthresh = res->value;
2470 printf("Unknown parameter\n");
2476 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2479 cmdline_parse_token_string_t cmd_config_thresh_port =
2480 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2481 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2482 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2483 cmdline_parse_token_string_t cmd_config_thresh_all =
2484 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2485 cmdline_parse_token_string_t cmd_config_thresh_name =
2486 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2487 "txpt#txht#txwt#rxpt#rxht#rxwt");
2488 cmdline_parse_token_num_t cmd_config_thresh_value =
2489 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2491 cmdline_parse_inst_t cmd_config_thresh = {
2492 .f = cmd_config_thresh_parsed,
2494 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2496 (void *)&cmd_config_thresh_port,
2497 (void *)&cmd_config_thresh_keyword,
2498 (void *)&cmd_config_thresh_all,
2499 (void *)&cmd_config_thresh_name,
2500 (void *)&cmd_config_thresh_value,
2505 /* *** configure free/rs threshold *** */
2506 struct cmd_config_threshold {
2507 cmdline_fixed_string_t port;
2508 cmdline_fixed_string_t keyword;
2509 cmdline_fixed_string_t all;
2510 cmdline_fixed_string_t name;
2515 cmd_config_threshold_parsed(void *parsed_result,
2516 __attribute__((unused)) struct cmdline *cl,
2517 __attribute__((unused)) void *data)
2519 struct cmd_config_threshold *res = parsed_result;
2521 if (!all_ports_stopped()) {
2522 printf("Please stop all ports first\n");
2526 if (!strcmp(res->name, "txfreet"))
2527 tx_free_thresh = res->value;
2528 else if (!strcmp(res->name, "txrst"))
2529 tx_rs_thresh = res->value;
2530 else if (!strcmp(res->name, "rxfreet"))
2531 rx_free_thresh = res->value;
2533 printf("Unknown parameter\n");
2539 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2542 cmdline_parse_token_string_t cmd_config_threshold_port =
2543 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2544 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2545 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2547 cmdline_parse_token_string_t cmd_config_threshold_all =
2548 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2549 cmdline_parse_token_string_t cmd_config_threshold_name =
2550 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2551 "txfreet#txrst#rxfreet");
2552 cmdline_parse_token_num_t cmd_config_threshold_value =
2553 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2555 cmdline_parse_inst_t cmd_config_threshold = {
2556 .f = cmd_config_threshold_parsed,
2558 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2560 (void *)&cmd_config_threshold_port,
2561 (void *)&cmd_config_threshold_keyword,
2562 (void *)&cmd_config_threshold_all,
2563 (void *)&cmd_config_threshold_name,
2564 (void *)&cmd_config_threshold_value,
2570 struct cmd_stop_result {
2571 cmdline_fixed_string_t stop;
2574 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2575 __attribute__((unused)) struct cmdline *cl,
2576 __attribute__((unused)) void *data)
2578 stop_packet_forwarding();
2581 cmdline_parse_token_string_t cmd_stop_stop =
2582 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2584 cmdline_parse_inst_t cmd_stop = {
2585 .f = cmd_stop_parsed,
2587 .help_str = "stop: Stop packet forwarding",
2589 (void *)&cmd_stop_stop,
2594 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2597 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2598 unsigned int *parsed_items, int check_unique_values)
2600 unsigned int nb_item;
2608 * First parse all items in the list and store their value.
2613 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2615 if ((c >= '0') && (c <= '9')) {
2616 value = (unsigned int) (value * 10 + (c - '0'));
2621 printf("character %c is not a decimal digit\n", c);
2625 printf("No valid value before comma\n");
2628 if (nb_item < max_items) {
2629 parsed_items[nb_item] = value;
2635 if (nb_item >= max_items) {
2636 printf("Number of %s = %u > %u (maximum items)\n",
2637 item_name, nb_item + 1, max_items);
2640 parsed_items[nb_item++] = value;
2641 if (! check_unique_values)
2645 * Then, check that all values in the list are differents.
2646 * No optimization here...
2648 for (i = 0; i < nb_item; i++) {
2649 for (j = i + 1; j < nb_item; j++) {
2650 if (parsed_items[j] == parsed_items[i]) {
2651 printf("duplicated %s %u at index %u and %u\n",
2652 item_name, parsed_items[i], i, j);
2660 struct cmd_set_list_result {
2661 cmdline_fixed_string_t cmd_keyword;
2662 cmdline_fixed_string_t list_name;
2663 cmdline_fixed_string_t list_of_items;
2666 static void cmd_set_list_parsed(void *parsed_result,
2667 __attribute__((unused)) struct cmdline *cl,
2668 __attribute__((unused)) void *data)
2670 struct cmd_set_list_result *res;
2672 unsigned int lcorelist[RTE_MAX_LCORE];
2673 unsigned int portlist[RTE_MAX_ETHPORTS];
2675 unsigned int nb_item;
2677 if (test_done == 0) {
2678 printf("Please stop forwarding first\n");
2682 res = parsed_result;
2683 if (!strcmp(res->list_name, "corelist")) {
2684 nb_item = parse_item_list(res->list_of_items, "core",
2686 parsed_items.lcorelist, 1);
2688 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2693 if (!strcmp(res->list_name, "portlist")) {
2694 nb_item = parse_item_list(res->list_of_items, "port",
2696 parsed_items.portlist, 1);
2698 set_fwd_ports_list(parsed_items.portlist, nb_item);
2704 cmdline_parse_token_string_t cmd_set_list_keyword =
2705 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2707 cmdline_parse_token_string_t cmd_set_list_name =
2708 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2709 "corelist#portlist");
2710 cmdline_parse_token_string_t cmd_set_list_of_items =
2711 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2714 cmdline_parse_inst_t cmd_set_fwd_list = {
2715 .f = cmd_set_list_parsed,
2717 .help_str = "set corelist|portlist <list0[,list1]*>",
2719 (void *)&cmd_set_list_keyword,
2720 (void *)&cmd_set_list_name,
2721 (void *)&cmd_set_list_of_items,
2726 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2728 struct cmd_setmask_result {
2729 cmdline_fixed_string_t set;
2730 cmdline_fixed_string_t mask;
2734 static void cmd_set_mask_parsed(void *parsed_result,
2735 __attribute__((unused)) struct cmdline *cl,
2736 __attribute__((unused)) void *data)
2738 struct cmd_setmask_result *res = parsed_result;
2740 if (test_done == 0) {
2741 printf("Please stop forwarding first\n");
2744 if (!strcmp(res->mask, "coremask")) {
2745 set_fwd_lcores_mask(res->hexavalue);
2747 } else if (!strcmp(res->mask, "portmask")) {
2748 set_fwd_ports_mask(res->hexavalue);
2753 cmdline_parse_token_string_t cmd_setmask_set =
2754 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2755 cmdline_parse_token_string_t cmd_setmask_mask =
2756 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2757 "coremask#portmask");
2758 cmdline_parse_token_num_t cmd_setmask_value =
2759 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2761 cmdline_parse_inst_t cmd_set_fwd_mask = {
2762 .f = cmd_set_mask_parsed,
2764 .help_str = "set coremask|portmask <hexadecimal value>",
2766 (void *)&cmd_setmask_set,
2767 (void *)&cmd_setmask_mask,
2768 (void *)&cmd_setmask_value,
2774 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2776 struct cmd_set_result {
2777 cmdline_fixed_string_t set;
2778 cmdline_fixed_string_t what;
2782 static void cmd_set_parsed(void *parsed_result,
2783 __attribute__((unused)) struct cmdline *cl,
2784 __attribute__((unused)) void *data)
2786 struct cmd_set_result *res = parsed_result;
2787 if (!strcmp(res->what, "nbport")) {
2788 set_fwd_ports_number(res->value);
2790 } else if (!strcmp(res->what, "nbcore")) {
2791 set_fwd_lcores_number(res->value);
2793 } else if (!strcmp(res->what, "burst"))
2794 set_nb_pkt_per_burst(res->value);
2795 else if (!strcmp(res->what, "verbose"))
2796 set_verbose_level(res->value);
2799 cmdline_parse_token_string_t cmd_set_set =
2800 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2801 cmdline_parse_token_string_t cmd_set_what =
2802 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2803 "nbport#nbcore#burst#verbose");
2804 cmdline_parse_token_num_t cmd_set_value =
2805 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2807 cmdline_parse_inst_t cmd_set_numbers = {
2808 .f = cmd_set_parsed,
2810 .help_str = "set nbport|nbcore|burst|verbose <value>",
2812 (void *)&cmd_set_set,
2813 (void *)&cmd_set_what,
2814 (void *)&cmd_set_value,
2819 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2821 struct cmd_set_txpkts_result {
2822 cmdline_fixed_string_t cmd_keyword;
2823 cmdline_fixed_string_t txpkts;
2824 cmdline_fixed_string_t seg_lengths;
2828 cmd_set_txpkts_parsed(void *parsed_result,
2829 __attribute__((unused)) struct cmdline *cl,
2830 __attribute__((unused)) void *data)
2832 struct cmd_set_txpkts_result *res;
2833 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2834 unsigned int nb_segs;
2836 res = parsed_result;
2837 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2838 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2840 set_tx_pkt_segments(seg_lengths, nb_segs);
2843 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2844 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2845 cmd_keyword, "set");
2846 cmdline_parse_token_string_t cmd_set_txpkts_name =
2847 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2849 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2850 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2853 cmdline_parse_inst_t cmd_set_txpkts = {
2854 .f = cmd_set_txpkts_parsed,
2856 .help_str = "set txpkts <len0[,len1]*>",
2858 (void *)&cmd_set_txpkts_keyword,
2859 (void *)&cmd_set_txpkts_name,
2860 (void *)&cmd_set_txpkts_lengths,
2865 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2867 struct cmd_set_txsplit_result {
2868 cmdline_fixed_string_t cmd_keyword;
2869 cmdline_fixed_string_t txsplit;
2870 cmdline_fixed_string_t mode;
2874 cmd_set_txsplit_parsed(void *parsed_result,
2875 __attribute__((unused)) struct cmdline *cl,
2876 __attribute__((unused)) void *data)
2878 struct cmd_set_txsplit_result *res;
2880 res = parsed_result;
2881 set_tx_pkt_split(res->mode);
2884 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2885 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2886 cmd_keyword, "set");
2887 cmdline_parse_token_string_t cmd_set_txsplit_name =
2888 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2889 txsplit, "txsplit");
2890 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2891 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2894 cmdline_parse_inst_t cmd_set_txsplit = {
2895 .f = cmd_set_txsplit_parsed,
2897 .help_str = "set txsplit on|off|rand",
2899 (void *)&cmd_set_txsplit_keyword,
2900 (void *)&cmd_set_txsplit_name,
2901 (void *)&cmd_set_txsplit_mode,
2906 /* *** CONFIG TX QUEUE FLAGS *** */
2908 struct cmd_config_txqflags_result {
2909 cmdline_fixed_string_t port;
2910 cmdline_fixed_string_t config;
2911 cmdline_fixed_string_t all;
2912 cmdline_fixed_string_t what;
2916 static void cmd_config_txqflags_parsed(void *parsed_result,
2917 __attribute__((unused)) struct cmdline *cl,
2918 __attribute__((unused)) void *data)
2920 struct cmd_config_txqflags_result *res = parsed_result;
2922 if (!all_ports_stopped()) {
2923 printf("Please stop all ports first\n");
2927 if (strcmp(res->what, "txqflags")) {
2928 printf("Unknown parameter\n");
2932 if (res->hexvalue >= 0) {
2933 txq_flags = res->hexvalue;
2935 printf("txqflags must be >= 0\n");
2941 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2944 cmdline_parse_token_string_t cmd_config_txqflags_port =
2945 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2947 cmdline_parse_token_string_t cmd_config_txqflags_config =
2948 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2950 cmdline_parse_token_string_t cmd_config_txqflags_all =
2951 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2953 cmdline_parse_token_string_t cmd_config_txqflags_what =
2954 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2956 cmdline_parse_token_num_t cmd_config_txqflags_value =
2957 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2960 cmdline_parse_inst_t cmd_config_txqflags = {
2961 .f = cmd_config_txqflags_parsed,
2963 .help_str = "port config all txqflags <value>",
2965 (void *)&cmd_config_txqflags_port,
2966 (void *)&cmd_config_txqflags_config,
2967 (void *)&cmd_config_txqflags_all,
2968 (void *)&cmd_config_txqflags_what,
2969 (void *)&cmd_config_txqflags_value,
2974 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2975 struct cmd_rx_vlan_filter_all_result {
2976 cmdline_fixed_string_t rx_vlan;
2977 cmdline_fixed_string_t what;
2978 cmdline_fixed_string_t all;
2983 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2984 __attribute__((unused)) struct cmdline *cl,
2985 __attribute__((unused)) void *data)
2987 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2989 if (!strcmp(res->what, "add"))
2990 rx_vlan_all_filter_set(res->port_id, 1);
2992 rx_vlan_all_filter_set(res->port_id, 0);
2995 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2996 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2997 rx_vlan, "rx_vlan");
2998 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2999 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3001 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3002 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3004 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3005 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3008 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3009 .f = cmd_rx_vlan_filter_all_parsed,
3011 .help_str = "rx_vlan add|rm all <port_id>: "
3012 "Add/Remove all identifiers to/from the set of VLAN "
3013 "identifiers filtered by a port",
3015 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3016 (void *)&cmd_rx_vlan_filter_all_what,
3017 (void *)&cmd_rx_vlan_filter_all_all,
3018 (void *)&cmd_rx_vlan_filter_all_portid,
3023 /* *** VLAN OFFLOAD SET ON A PORT *** */
3024 struct cmd_vlan_offload_result {
3025 cmdline_fixed_string_t vlan;
3026 cmdline_fixed_string_t set;
3027 cmdline_fixed_string_t vlan_type;
3028 cmdline_fixed_string_t what;
3029 cmdline_fixed_string_t on;
3030 cmdline_fixed_string_t port_id;
3034 cmd_vlan_offload_parsed(void *parsed_result,
3035 __attribute__((unused)) struct cmdline *cl,
3036 __attribute__((unused)) void *data)
3039 struct cmd_vlan_offload_result *res = parsed_result;
3042 portid_t port_id = 0;
3046 len = strnlen(str, STR_TOKEN_SIZE);
3048 /* Get port_id first */
3056 tmp = strtoul(str, NULL, 0);
3057 /* If port_id greater that what portid_t can represent, return */
3058 if(tmp >= RTE_MAX_ETHPORTS)
3060 port_id = (portid_t)tmp;
3062 if (!strcmp(res->on, "on"))
3067 if (!strcmp(res->what, "strip"))
3068 rx_vlan_strip_set(port_id, on);
3069 else if(!strcmp(res->what, "stripq")){
3070 uint16_t queue_id = 0;
3072 /* No queue_id, return */
3074 printf("must specify (port,queue_id)\n");
3077 tmp = strtoul(str + i + 1, NULL, 0);
3078 /* If queue_id greater that what 16-bits can represent, return */
3082 queue_id = (uint16_t)tmp;
3083 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3085 else if (!strcmp(res->what, "filter"))
3086 rx_vlan_filter_set(port_id, on);
3088 vlan_extend_set(port_id, on);
3093 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3094 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3096 cmdline_parse_token_string_t cmd_vlan_offload_set =
3097 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3099 cmdline_parse_token_string_t cmd_vlan_offload_what =
3100 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3101 what, "strip#filter#qinq#stripq");
3102 cmdline_parse_token_string_t cmd_vlan_offload_on =
3103 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3105 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3106 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3109 cmdline_parse_inst_t cmd_vlan_offload = {
3110 .f = cmd_vlan_offload_parsed,
3112 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3113 "<port_id[,queue_id]>: "
3114 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3116 (void *)&cmd_vlan_offload_vlan,
3117 (void *)&cmd_vlan_offload_set,
3118 (void *)&cmd_vlan_offload_what,
3119 (void *)&cmd_vlan_offload_on,
3120 (void *)&cmd_vlan_offload_portid,
3125 /* *** VLAN TPID SET ON A PORT *** */
3126 struct cmd_vlan_tpid_result {
3127 cmdline_fixed_string_t vlan;
3128 cmdline_fixed_string_t set;
3129 cmdline_fixed_string_t vlan_type;
3130 cmdline_fixed_string_t what;
3136 cmd_vlan_tpid_parsed(void *parsed_result,
3137 __attribute__((unused)) struct cmdline *cl,
3138 __attribute__((unused)) void *data)
3140 struct cmd_vlan_tpid_result *res = parsed_result;
3141 enum rte_vlan_type vlan_type;
3143 if (!strcmp(res->vlan_type, "inner"))
3144 vlan_type = ETH_VLAN_TYPE_INNER;
3145 else if (!strcmp(res->vlan_type, "outer"))
3146 vlan_type = ETH_VLAN_TYPE_OUTER;
3148 printf("Unknown vlan type\n");
3151 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3154 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3155 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3157 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3158 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3160 cmdline_parse_token_string_t cmd_vlan_type =
3161 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3162 vlan_type, "inner#outer");
3163 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3164 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3166 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3167 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3169 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3170 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3173 cmdline_parse_inst_t cmd_vlan_tpid = {
3174 .f = cmd_vlan_tpid_parsed,
3176 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3177 "Set the VLAN Ether type",
3179 (void *)&cmd_vlan_tpid_vlan,
3180 (void *)&cmd_vlan_tpid_set,
3181 (void *)&cmd_vlan_type,
3182 (void *)&cmd_vlan_tpid_what,
3183 (void *)&cmd_vlan_tpid_tpid,
3184 (void *)&cmd_vlan_tpid_portid,
3189 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3190 struct cmd_rx_vlan_filter_result {
3191 cmdline_fixed_string_t rx_vlan;
3192 cmdline_fixed_string_t what;
3198 cmd_rx_vlan_filter_parsed(void *parsed_result,
3199 __attribute__((unused)) struct cmdline *cl,
3200 __attribute__((unused)) void *data)
3202 struct cmd_rx_vlan_filter_result *res = parsed_result;
3204 if (!strcmp(res->what, "add"))
3205 rx_vft_set(res->port_id, res->vlan_id, 1);
3207 rx_vft_set(res->port_id, res->vlan_id, 0);
3210 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3211 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3212 rx_vlan, "rx_vlan");
3213 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3214 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3216 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3217 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3219 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3220 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3223 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3224 .f = cmd_rx_vlan_filter_parsed,
3226 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3227 "Add/Remove a VLAN identifier to/from the set of VLAN "
3228 "identifiers filtered by a port",
3230 (void *)&cmd_rx_vlan_filter_rx_vlan,
3231 (void *)&cmd_rx_vlan_filter_what,
3232 (void *)&cmd_rx_vlan_filter_vlanid,
3233 (void *)&cmd_rx_vlan_filter_portid,
3238 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3239 struct cmd_tx_vlan_set_result {
3240 cmdline_fixed_string_t tx_vlan;
3241 cmdline_fixed_string_t set;
3247 cmd_tx_vlan_set_parsed(void *parsed_result,
3248 __attribute__((unused)) struct cmdline *cl,
3249 __attribute__((unused)) void *data)
3251 struct cmd_tx_vlan_set_result *res = parsed_result;
3253 tx_vlan_set(res->port_id, res->vlan_id);
3256 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3257 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3258 tx_vlan, "tx_vlan");
3259 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3260 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3262 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3263 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3265 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3266 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3269 cmdline_parse_inst_t cmd_tx_vlan_set = {
3270 .f = cmd_tx_vlan_set_parsed,
3272 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3273 "Enable hardware insertion of a single VLAN header "
3274 "with a given TAG Identifier in packets sent on a port",
3276 (void *)&cmd_tx_vlan_set_tx_vlan,
3277 (void *)&cmd_tx_vlan_set_set,
3278 (void *)&cmd_tx_vlan_set_portid,
3279 (void *)&cmd_tx_vlan_set_vlanid,
3284 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3285 struct cmd_tx_vlan_set_qinq_result {
3286 cmdline_fixed_string_t tx_vlan;
3287 cmdline_fixed_string_t set;
3290 uint16_t vlan_id_outer;
3294 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3295 __attribute__((unused)) struct cmdline *cl,
3296 __attribute__((unused)) void *data)
3298 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3300 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3303 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3304 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3305 tx_vlan, "tx_vlan");
3306 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3307 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3309 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3310 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3312 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3313 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3315 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3316 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3317 vlan_id_outer, UINT16);
3319 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3320 .f = cmd_tx_vlan_set_qinq_parsed,
3322 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3323 "Enable hardware insertion of double VLAN header "
3324 "with given TAG Identifiers in packets sent on a port",
3326 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3327 (void *)&cmd_tx_vlan_set_qinq_set,
3328 (void *)&cmd_tx_vlan_set_qinq_portid,
3329 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3330 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3335 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3336 struct cmd_tx_vlan_set_pvid_result {
3337 cmdline_fixed_string_t tx_vlan;
3338 cmdline_fixed_string_t set;
3339 cmdline_fixed_string_t pvid;
3342 cmdline_fixed_string_t mode;
3346 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3347 __attribute__((unused)) struct cmdline *cl,
3348 __attribute__((unused)) void *data)
3350 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3352 if (strcmp(res->mode, "on") == 0)
3353 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3355 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3358 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3359 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3360 tx_vlan, "tx_vlan");
3361 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3362 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3364 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3365 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3367 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3368 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3370 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3371 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3373 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3374 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3377 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3378 .f = cmd_tx_vlan_set_pvid_parsed,
3380 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3382 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3383 (void *)&cmd_tx_vlan_set_pvid_set,
3384 (void *)&cmd_tx_vlan_set_pvid_pvid,
3385 (void *)&cmd_tx_vlan_set_pvid_port_id,
3386 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3387 (void *)&cmd_tx_vlan_set_pvid_mode,
3392 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3393 struct cmd_tx_vlan_reset_result {
3394 cmdline_fixed_string_t tx_vlan;
3395 cmdline_fixed_string_t reset;
3400 cmd_tx_vlan_reset_parsed(void *parsed_result,
3401 __attribute__((unused)) struct cmdline *cl,
3402 __attribute__((unused)) void *data)
3404 struct cmd_tx_vlan_reset_result *res = parsed_result;
3406 tx_vlan_reset(res->port_id);
3409 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3410 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3411 tx_vlan, "tx_vlan");
3412 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3413 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3415 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3416 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3419 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3420 .f = cmd_tx_vlan_reset_parsed,
3422 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3423 "VLAN header in packets sent on a port",
3425 (void *)&cmd_tx_vlan_reset_tx_vlan,
3426 (void *)&cmd_tx_vlan_reset_reset,
3427 (void *)&cmd_tx_vlan_reset_portid,
3433 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3434 struct cmd_csum_result {
3435 cmdline_fixed_string_t csum;
3436 cmdline_fixed_string_t mode;
3437 cmdline_fixed_string_t proto;
3438 cmdline_fixed_string_t hwsw;
3443 csum_show(int port_id)
3445 struct rte_eth_dev_info dev_info;
3448 ol_flags = ports[port_id].tx_ol_flags;
3449 printf("Parse tunnel is %s\n",
3450 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3451 printf("IP checksum offload is %s\n",
3452 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3453 printf("UDP checksum offload is %s\n",
3454 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3455 printf("TCP checksum offload is %s\n",
3456 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3457 printf("SCTP checksum offload is %s\n",
3458 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3459 printf("Outer-Ip checksum offload is %s\n",
3460 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3462 /* display warnings if configuration is not supported by the NIC */
3463 rte_eth_dev_info_get(port_id, &dev_info);
3464 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3465 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3466 printf("Warning: hardware IP checksum enabled but not "
3467 "supported by port %d\n", port_id);
3469 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3470 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3471 printf("Warning: hardware UDP checksum enabled but not "
3472 "supported by port %d\n", port_id);
3474 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3475 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3476 printf("Warning: hardware TCP checksum enabled but not "
3477 "supported by port %d\n", port_id);
3479 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3480 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3481 printf("Warning: hardware SCTP checksum enabled but not "
3482 "supported by port %d\n", port_id);
3484 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3485 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3486 printf("Warning: hardware outer IP checksum enabled but not "
3487 "supported by port %d\n", port_id);
3492 cmd_csum_parsed(void *parsed_result,
3493 __attribute__((unused)) struct cmdline *cl,
3494 __attribute__((unused)) void *data)
3496 struct cmd_csum_result *res = parsed_result;
3500 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3501 printf("invalid port %d\n", res->port_id);
3505 if (!strcmp(res->mode, "set")) {
3507 if (!strcmp(res->hwsw, "hw"))
3510 if (!strcmp(res->proto, "ip")) {
3511 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3512 } else if (!strcmp(res->proto, "udp")) {
3513 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3514 } else if (!strcmp(res->proto, "tcp")) {
3515 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3516 } else if (!strcmp(res->proto, "sctp")) {
3517 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3518 } else if (!strcmp(res->proto, "outer-ip")) {
3519 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3523 ports[res->port_id].tx_ol_flags |= mask;
3525 ports[res->port_id].tx_ol_flags &= (~mask);
3527 csum_show(res->port_id);
3530 cmdline_parse_token_string_t cmd_csum_csum =
3531 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3533 cmdline_parse_token_string_t cmd_csum_mode =
3534 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3536 cmdline_parse_token_string_t cmd_csum_proto =
3537 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3538 proto, "ip#tcp#udp#sctp#outer-ip");
3539 cmdline_parse_token_string_t cmd_csum_hwsw =
3540 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3542 cmdline_parse_token_num_t cmd_csum_portid =
3543 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3546 cmdline_parse_inst_t cmd_csum_set = {
3547 .f = cmd_csum_parsed,
3549 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3550 "Enable/Disable hardware calculation of L3/L4 checksum when "
3551 "using csum forward engine",
3553 (void *)&cmd_csum_csum,
3554 (void *)&cmd_csum_mode,
3555 (void *)&cmd_csum_proto,
3556 (void *)&cmd_csum_hwsw,
3557 (void *)&cmd_csum_portid,
3562 cmdline_parse_token_string_t cmd_csum_mode_show =
3563 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3566 cmdline_parse_inst_t cmd_csum_show = {
3567 .f = cmd_csum_parsed,
3569 .help_str = "csum show <port_id>: Show checksum offload configuration",
3571 (void *)&cmd_csum_csum,
3572 (void *)&cmd_csum_mode_show,
3573 (void *)&cmd_csum_portid,
3578 /* Enable/disable tunnel parsing */
3579 struct cmd_csum_tunnel_result {
3580 cmdline_fixed_string_t csum;
3581 cmdline_fixed_string_t parse;
3582 cmdline_fixed_string_t onoff;
3587 cmd_csum_tunnel_parsed(void *parsed_result,
3588 __attribute__((unused)) struct cmdline *cl,
3589 __attribute__((unused)) void *data)
3591 struct cmd_csum_tunnel_result *res = parsed_result;
3593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3596 if (!strcmp(res->onoff, "on"))
3597 ports[res->port_id].tx_ol_flags |=
3598 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3600 ports[res->port_id].tx_ol_flags &=
3601 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3603 csum_show(res->port_id);
3606 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3607 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3609 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3610 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3611 parse, "parse_tunnel");
3612 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3613 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3615 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3616 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3619 cmdline_parse_inst_t cmd_csum_tunnel = {
3620 .f = cmd_csum_tunnel_parsed,
3622 .help_str = "csum parse_tunnel on|off <port_id>: "
3623 "Enable/Disable parsing of tunnels for csum engine",
3625 (void *)&cmd_csum_tunnel_csum,
3626 (void *)&cmd_csum_tunnel_parse,
3627 (void *)&cmd_csum_tunnel_onoff,
3628 (void *)&cmd_csum_tunnel_portid,
3633 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3634 struct cmd_tso_set_result {
3635 cmdline_fixed_string_t tso;
3636 cmdline_fixed_string_t mode;
3642 cmd_tso_set_parsed(void *parsed_result,
3643 __attribute__((unused)) struct cmdline *cl,
3644 __attribute__((unused)) void *data)
3646 struct cmd_tso_set_result *res = parsed_result;
3647 struct rte_eth_dev_info dev_info;
3649 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3652 if (!strcmp(res->mode, "set"))
3653 ports[res->port_id].tso_segsz = res->tso_segsz;
3655 if (ports[res->port_id].tso_segsz == 0)
3656 printf("TSO for non-tunneled packets is disabled\n");
3658 printf("TSO segment size for non-tunneled packets is %d\n",
3659 ports[res->port_id].tso_segsz);
3661 /* display warnings if configuration is not supported by the NIC */
3662 rte_eth_dev_info_get(res->port_id, &dev_info);
3663 if ((ports[res->port_id].tso_segsz != 0) &&
3664 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3665 printf("Warning: TSO enabled but not "
3666 "supported by port %d\n", res->port_id);
3670 cmdline_parse_token_string_t cmd_tso_set_tso =
3671 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3673 cmdline_parse_token_string_t cmd_tso_set_mode =
3674 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3676 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3677 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3679 cmdline_parse_token_num_t cmd_tso_set_portid =
3680 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3683 cmdline_parse_inst_t cmd_tso_set = {
3684 .f = cmd_tso_set_parsed,
3686 .help_str = "tso set <tso_segsz> <port_id>: "
3687 "Set TSO segment size of non-tunneled packets for csum engine "
3690 (void *)&cmd_tso_set_tso,
3691 (void *)&cmd_tso_set_mode,
3692 (void *)&cmd_tso_set_tso_segsz,
3693 (void *)&cmd_tso_set_portid,
3698 cmdline_parse_token_string_t cmd_tso_show_mode =
3699 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3703 cmdline_parse_inst_t cmd_tso_show = {
3704 .f = cmd_tso_set_parsed,
3706 .help_str = "tso show <port_id>: "
3707 "Show TSO segment size of non-tunneled packets for csum engine",
3709 (void *)&cmd_tso_set_tso,
3710 (void *)&cmd_tso_show_mode,
3711 (void *)&cmd_tso_set_portid,
3716 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3717 struct cmd_tunnel_tso_set_result {
3718 cmdline_fixed_string_t tso;
3719 cmdline_fixed_string_t mode;
3725 check_tunnel_tso_nic_support(uint8_t port_id)
3727 struct rte_eth_dev_info dev_info;
3729 rte_eth_dev_info_get(port_id, &dev_info);
3730 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3731 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3732 "supported by port %d\n", port_id);
3733 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3734 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3735 "supported by port %d\n", port_id);
3736 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3737 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3738 "supported by port %d\n", port_id);
3739 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3740 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3741 "supported by port %d\n", port_id);
3745 cmd_tunnel_tso_set_parsed(void *parsed_result,
3746 __attribute__((unused)) struct cmdline *cl,
3747 __attribute__((unused)) void *data)
3749 struct cmd_tunnel_tso_set_result *res = parsed_result;
3751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3754 if (!strcmp(res->mode, "set"))
3755 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3757 if (ports[res->port_id].tunnel_tso_segsz == 0)
3758 printf("TSO for tunneled packets is disabled\n");
3760 printf("TSO segment size for tunneled packets is %d\n",
3761 ports[res->port_id].tunnel_tso_segsz);
3763 /* Below conditions are needed to make it work:
3764 * (1) tunnel TSO is supported by the NIC;
3765 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3767 * (3) for tunneled pkts with outer L3 of IPv4,
3768 * "csum set outer-ip" must be set to hw, because after tso,
3769 * total_len of outer IP header is changed, and the checksum
3770 * of outer IP header calculated by sw should be wrong; that
3771 * is not necessary for IPv6 tunneled pkts because there's no
3772 * checksum in IP header anymore.
3774 check_tunnel_tso_nic_support(res->port_id);
3776 if (!(ports[res->port_id].tx_ol_flags &
3777 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3778 printf("Warning: csum parse_tunnel must be set "
3779 "so that tunneled packets are recognized\n");
3780 if (!(ports[res->port_id].tx_ol_flags &
3781 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3782 printf("Warning: csum set outer-ip must be set to hw "
3783 "if outer L3 is IPv4; not necessary for IPv6\n");
3787 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3788 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3790 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3791 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3793 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3794 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3796 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3797 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3800 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3801 .f = cmd_tunnel_tso_set_parsed,
3803 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3804 "Set TSO segment size of tunneled packets for csum engine "
3807 (void *)&cmd_tunnel_tso_set_tso,
3808 (void *)&cmd_tunnel_tso_set_mode,
3809 (void *)&cmd_tunnel_tso_set_tso_segsz,
3810 (void *)&cmd_tunnel_tso_set_portid,
3815 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3816 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3820 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3821 .f = cmd_tunnel_tso_set_parsed,
3823 .help_str = "tunnel_tso show <port_id> "
3824 "Show TSO segment size of tunneled packets for csum engine",
3826 (void *)&cmd_tunnel_tso_set_tso,
3827 (void *)&cmd_tunnel_tso_show_mode,
3828 (void *)&cmd_tunnel_tso_set_portid,
3833 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3834 struct cmd_set_flush_rx {
3835 cmdline_fixed_string_t set;
3836 cmdline_fixed_string_t flush_rx;
3837 cmdline_fixed_string_t mode;
3841 cmd_set_flush_rx_parsed(void *parsed_result,
3842 __attribute__((unused)) struct cmdline *cl,
3843 __attribute__((unused)) void *data)
3845 struct cmd_set_flush_rx *res = parsed_result;
3846 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3849 cmdline_parse_token_string_t cmd_setflushrx_set =
3850 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3852 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3853 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3854 flush_rx, "flush_rx");
3855 cmdline_parse_token_string_t cmd_setflushrx_mode =
3856 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3860 cmdline_parse_inst_t cmd_set_flush_rx = {
3861 .f = cmd_set_flush_rx_parsed,
3862 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3865 (void *)&cmd_setflushrx_set,
3866 (void *)&cmd_setflushrx_flush_rx,
3867 (void *)&cmd_setflushrx_mode,
3872 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3873 struct cmd_set_link_check {
3874 cmdline_fixed_string_t set;
3875 cmdline_fixed_string_t link_check;
3876 cmdline_fixed_string_t mode;
3880 cmd_set_link_check_parsed(void *parsed_result,
3881 __attribute__((unused)) struct cmdline *cl,
3882 __attribute__((unused)) void *data)
3884 struct cmd_set_link_check *res = parsed_result;
3885 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3888 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3891 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3892 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3893 link_check, "link_check");
3894 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3895 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3899 cmdline_parse_inst_t cmd_set_link_check = {
3900 .f = cmd_set_link_check_parsed,
3901 .help_str = "set link_check on|off: Enable/Disable link status check "
3902 "when starting/stopping a port",
3905 (void *)&cmd_setlinkcheck_set,
3906 (void *)&cmd_setlinkcheck_link_check,
3907 (void *)&cmd_setlinkcheck_mode,
3912 /* *** SET NIC BYPASS MODE *** */
3913 struct cmd_set_bypass_mode_result {
3914 cmdline_fixed_string_t set;
3915 cmdline_fixed_string_t bypass;
3916 cmdline_fixed_string_t mode;
3917 cmdline_fixed_string_t value;
3922 cmd_set_bypass_mode_parsed(void *parsed_result,
3923 __attribute__((unused)) struct cmdline *cl,
3924 __attribute__((unused)) void *data)
3926 struct cmd_set_bypass_mode_result *res = parsed_result;
3927 portid_t port_id = res->port_id;
3928 int32_t rc = -EINVAL;
3930 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
3931 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3933 if (!strcmp(res->value, "bypass"))
3934 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
3935 else if (!strcmp(res->value, "isolate"))
3936 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
3938 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3940 /* Set the bypass mode for the relevant port. */
3941 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
3944 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3947 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3950 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3953 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3956 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3957 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3958 value, "normal#bypass#isolate");
3959 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3960 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3963 cmdline_parse_inst_t cmd_set_bypass_mode = {
3964 .f = cmd_set_bypass_mode_parsed,
3965 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3966 "Set the NIC bypass mode for port_id",
3969 (void *)&cmd_setbypass_mode_set,
3970 (void *)&cmd_setbypass_mode_bypass,
3971 (void *)&cmd_setbypass_mode_mode,
3972 (void *)&cmd_setbypass_mode_value,
3973 (void *)&cmd_setbypass_mode_port,
3978 /* *** SET NIC BYPASS EVENT *** */
3979 struct cmd_set_bypass_event_result {
3980 cmdline_fixed_string_t set;
3981 cmdline_fixed_string_t bypass;
3982 cmdline_fixed_string_t event;
3983 cmdline_fixed_string_t event_value;
3984 cmdline_fixed_string_t mode;
3985 cmdline_fixed_string_t mode_value;
3990 cmd_set_bypass_event_parsed(void *parsed_result,
3991 __attribute__((unused)) struct cmdline *cl,
3992 __attribute__((unused)) void *data)
3994 int32_t rc = -EINVAL;
3995 struct cmd_set_bypass_event_result *res = parsed_result;
3996 portid_t port_id = res->port_id;
3998 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
3999 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4000 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4002 if (!strcmp(res->event_value, "timeout"))
4003 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4004 else if (!strcmp(res->event_value, "os_on"))
4005 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4006 else if (!strcmp(res->event_value, "os_off"))
4007 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4008 else if (!strcmp(res->event_value, "power_on"))
4009 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4010 else if (!strcmp(res->event_value, "power_off"))
4011 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4013 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4015 if (!strcmp(res->mode_value, "bypass"))
4016 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4017 else if (!strcmp(res->mode_value, "isolate"))
4018 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4020 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4022 /* Set the watchdog timeout. */
4023 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4026 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4027 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4031 printf("Failed to set timeout value %u "
4032 "for port %d, errto code: %d.\n",
4033 bypass_timeout, port_id, rc);
4037 /* Set the bypass event to transition to bypass mode. */
4038 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4043 printf("\t Failed to set bypass event for port = %d.\n",
4047 cmdline_parse_token_string_t cmd_setbypass_event_set =
4048 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4050 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4053 cmdline_parse_token_string_t cmd_setbypass_event_event =
4054 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4056 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4058 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4059 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4060 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4062 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4063 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4064 mode_value, "normal#bypass#isolate");
4065 cmdline_parse_token_num_t cmd_setbypass_event_port =
4066 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4069 cmdline_parse_inst_t cmd_set_bypass_event = {
4070 .f = cmd_set_bypass_event_parsed,
4071 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4072 "power_off mode normal|bypass|isolate <port_id>: "
4073 "Set the NIC bypass event mode for port_id",
4076 (void *)&cmd_setbypass_event_set,
4077 (void *)&cmd_setbypass_event_bypass,
4078 (void *)&cmd_setbypass_event_event,
4079 (void *)&cmd_setbypass_event_event_value,
4080 (void *)&cmd_setbypass_event_mode,
4081 (void *)&cmd_setbypass_event_mode_value,
4082 (void *)&cmd_setbypass_event_port,
4088 /* *** SET NIC BYPASS TIMEOUT *** */
4089 struct cmd_set_bypass_timeout_result {
4090 cmdline_fixed_string_t set;
4091 cmdline_fixed_string_t bypass;
4092 cmdline_fixed_string_t timeout;
4093 cmdline_fixed_string_t value;
4097 cmd_set_bypass_timeout_parsed(void *parsed_result,
4098 __attribute__((unused)) struct cmdline *cl,
4099 __attribute__((unused)) void *data)
4101 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4103 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4104 if (!strcmp(res->value, "1.5"))
4105 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4106 else if (!strcmp(res->value, "2"))
4107 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4108 else if (!strcmp(res->value, "3"))
4109 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4110 else if (!strcmp(res->value, "4"))
4111 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4112 else if (!strcmp(res->value, "8"))
4113 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4114 else if (!strcmp(res->value, "16"))
4115 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4116 else if (!strcmp(res->value, "32"))
4117 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4119 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4123 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4124 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4126 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4127 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4129 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4130 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4131 timeout, "timeout");
4132 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4133 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4134 value, "0#1.5#2#3#4#8#16#32");
4136 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4137 .f = cmd_set_bypass_timeout_parsed,
4138 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4139 "Set the NIC bypass watchdog timeout in seconds",
4142 (void *)&cmd_setbypass_timeout_set,
4143 (void *)&cmd_setbypass_timeout_bypass,
4144 (void *)&cmd_setbypass_timeout_timeout,
4145 (void *)&cmd_setbypass_timeout_value,
4150 /* *** SHOW NIC BYPASS MODE *** */
4151 struct cmd_show_bypass_config_result {
4152 cmdline_fixed_string_t show;
4153 cmdline_fixed_string_t bypass;
4154 cmdline_fixed_string_t config;
4159 cmd_show_bypass_config_parsed(void *parsed_result,
4160 __attribute__((unused)) struct cmdline *cl,
4161 __attribute__((unused)) void *data)
4163 struct cmd_show_bypass_config_result *res = parsed_result;
4164 portid_t port_id = res->port_id;
4166 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4167 uint32_t event_mode;
4168 uint32_t bypass_mode;
4169 uint32_t timeout = bypass_timeout;
4172 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4173 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4174 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4175 {"UNKNOWN", "normal", "bypass", "isolate"};
4176 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4183 int num_events = (sizeof events) / (sizeof events[0]);
4185 /* Display the bypass mode.*/
4186 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4187 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4191 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4192 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4194 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4197 /* Display the bypass timeout.*/
4198 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4199 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4201 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4203 /* Display the bypass events and associated modes. */
4204 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4206 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4207 printf("\tFailed to get bypass mode for event = %s\n",
4210 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4211 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4213 printf("\tbypass event: %-16s = %s\n", events[i],
4219 printf("\tFailed to get bypass configuration for port = %d\n",
4223 cmdline_parse_token_string_t cmd_showbypass_config_show =
4224 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4226 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4227 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4229 cmdline_parse_token_string_t cmd_showbypass_config_config =
4230 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4232 cmdline_parse_token_num_t cmd_showbypass_config_port =
4233 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4236 cmdline_parse_inst_t cmd_show_bypass_config = {
4237 .f = cmd_show_bypass_config_parsed,
4238 .help_str = "show bypass config <port_id>: "
4239 "Show the NIC bypass config for port_id",
4242 (void *)&cmd_showbypass_config_show,
4243 (void *)&cmd_showbypass_config_bypass,
4244 (void *)&cmd_showbypass_config_config,
4245 (void *)&cmd_showbypass_config_port,
4250 #ifdef RTE_LIBRTE_PMD_BOND
4251 /* *** SET BONDING MODE *** */
4252 struct cmd_set_bonding_mode_result {
4253 cmdline_fixed_string_t set;
4254 cmdline_fixed_string_t bonding;
4255 cmdline_fixed_string_t mode;
4260 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4261 __attribute__((unused)) struct cmdline *cl,
4262 __attribute__((unused)) void *data)
4264 struct cmd_set_bonding_mode_result *res = parsed_result;
4265 portid_t port_id = res->port_id;
4267 /* Set the bonding mode for the relevant port. */
4268 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4269 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4272 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4273 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4275 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4276 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4277 bonding, "bonding");
4278 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4279 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4281 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4282 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4284 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4285 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4288 cmdline_parse_inst_t cmd_set_bonding_mode = {
4289 .f = cmd_set_bonding_mode_parsed,
4290 .help_str = "set bonding mode <mode_value> <port_id>: "
4291 "Set the bonding mode for port_id",
4294 (void *) &cmd_setbonding_mode_set,
4295 (void *) &cmd_setbonding_mode_bonding,
4296 (void *) &cmd_setbonding_mode_mode,
4297 (void *) &cmd_setbonding_mode_value,
4298 (void *) &cmd_setbonding_mode_port,
4303 /* *** SET BALANCE XMIT POLICY *** */
4304 struct cmd_set_bonding_balance_xmit_policy_result {
4305 cmdline_fixed_string_t set;
4306 cmdline_fixed_string_t bonding;
4307 cmdline_fixed_string_t balance_xmit_policy;
4309 cmdline_fixed_string_t policy;
4312 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4313 __attribute__((unused)) struct cmdline *cl,
4314 __attribute__((unused)) void *data)
4316 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4317 portid_t port_id = res->port_id;
4320 if (!strcmp(res->policy, "l2")) {
4321 policy = BALANCE_XMIT_POLICY_LAYER2;
4322 } else if (!strcmp(res->policy, "l23")) {
4323 policy = BALANCE_XMIT_POLICY_LAYER23;
4324 } else if (!strcmp(res->policy, "l34")) {
4325 policy = BALANCE_XMIT_POLICY_LAYER34;
4327 printf("\t Invalid xmit policy selection");
4331 /* Set the bonding mode for the relevant port. */
4332 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4333 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4338 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4339 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4341 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4342 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4343 bonding, "bonding");
4344 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4345 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4346 balance_xmit_policy, "balance_xmit_policy");
4347 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4348 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4350 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4351 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4352 policy, "l2#l23#l34");
4354 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4355 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4356 .help_str = "set bonding balance_xmit_policy <port_id> "
4358 "Set the bonding balance_xmit_policy for port_id",
4361 (void *)&cmd_setbonding_balance_xmit_policy_set,
4362 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4363 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4364 (void *)&cmd_setbonding_balance_xmit_policy_port,
4365 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4370 /* *** SHOW NIC BONDING CONFIGURATION *** */
4371 struct cmd_show_bonding_config_result {
4372 cmdline_fixed_string_t show;
4373 cmdline_fixed_string_t bonding;
4374 cmdline_fixed_string_t config;
4378 static void cmd_show_bonding_config_parsed(void *parsed_result,
4379 __attribute__((unused)) struct cmdline *cl,
4380 __attribute__((unused)) void *data)
4382 struct cmd_show_bonding_config_result *res = parsed_result;
4384 uint8_t slaves[RTE_MAX_ETHPORTS];
4385 int num_slaves, num_active_slaves;
4388 portid_t port_id = res->port_id;
4390 /* Display the bonding mode.*/
4391 bonding_mode = rte_eth_bond_mode_get(port_id);
4392 if (bonding_mode < 0) {
4393 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4396 printf("\tBonding mode: %d\n", bonding_mode);
4398 if (bonding_mode == BONDING_MODE_BALANCE) {
4399 int balance_xmit_policy;
4401 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4402 if (balance_xmit_policy < 0) {
4403 printf("\tFailed to get balance xmit policy for port = %d\n",
4407 printf("\tBalance Xmit Policy: ");
4409 switch (balance_xmit_policy) {
4410 case BALANCE_XMIT_POLICY_LAYER2:
4411 printf("BALANCE_XMIT_POLICY_LAYER2");
4413 case BALANCE_XMIT_POLICY_LAYER23:
4414 printf("BALANCE_XMIT_POLICY_LAYER23");
4416 case BALANCE_XMIT_POLICY_LAYER34:
4417 printf("BALANCE_XMIT_POLICY_LAYER34");
4424 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4426 if (num_slaves < 0) {
4427 printf("\tFailed to get slave list for port = %d\n", port_id);
4430 if (num_slaves > 0) {
4431 printf("\tSlaves (%d): [", num_slaves);
4432 for (i = 0; i < num_slaves - 1; i++)
4433 printf("%d ", slaves[i]);
4435 printf("%d]\n", slaves[num_slaves - 1]);
4437 printf("\tSlaves: []\n");
4441 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4444 if (num_active_slaves < 0) {
4445 printf("\tFailed to get active slave list for port = %d\n", port_id);
4448 if (num_active_slaves > 0) {
4449 printf("\tActive Slaves (%d): [", num_active_slaves);
4450 for (i = 0; i < num_active_slaves - 1; i++)
4451 printf("%d ", slaves[i]);
4453 printf("%d]\n", slaves[num_active_slaves - 1]);
4456 printf("\tActive Slaves: []\n");
4460 primary_id = rte_eth_bond_primary_get(port_id);
4461 if (primary_id < 0) {
4462 printf("\tFailed to get primary slave for port = %d\n", port_id);
4465 printf("\tPrimary: [%d]\n", primary_id);
4469 cmdline_parse_token_string_t cmd_showbonding_config_show =
4470 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4472 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4473 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4474 bonding, "bonding");
4475 cmdline_parse_token_string_t cmd_showbonding_config_config =
4476 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4478 cmdline_parse_token_num_t cmd_showbonding_config_port =
4479 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4482 cmdline_parse_inst_t cmd_show_bonding_config = {
4483 .f = cmd_show_bonding_config_parsed,
4484 .help_str = "show bonding config <port_id>: "
4485 "Show the bonding config for port_id",
4488 (void *)&cmd_showbonding_config_show,
4489 (void *)&cmd_showbonding_config_bonding,
4490 (void *)&cmd_showbonding_config_config,
4491 (void *)&cmd_showbonding_config_port,
4496 /* *** SET BONDING PRIMARY *** */
4497 struct cmd_set_bonding_primary_result {
4498 cmdline_fixed_string_t set;
4499 cmdline_fixed_string_t bonding;
4500 cmdline_fixed_string_t primary;
4505 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4506 __attribute__((unused)) struct cmdline *cl,
4507 __attribute__((unused)) void *data)
4509 struct cmd_set_bonding_primary_result *res = parsed_result;
4510 portid_t master_port_id = res->port_id;
4511 portid_t slave_port_id = res->slave_id;
4513 /* Set the primary slave for a bonded device. */
4514 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4515 printf("\t Failed to set primary slave for port = %d.\n",
4522 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4523 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4525 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4526 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4527 bonding, "bonding");
4528 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4529 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4530 primary, "primary");
4531 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4532 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4534 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4535 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4538 cmdline_parse_inst_t cmd_set_bonding_primary = {
4539 .f = cmd_set_bonding_primary_parsed,
4540 .help_str = "set bonding primary <slave_id> <port_id>: "
4541 "Set the primary slave for port_id",
4544 (void *)&cmd_setbonding_primary_set,
4545 (void *)&cmd_setbonding_primary_bonding,
4546 (void *)&cmd_setbonding_primary_primary,
4547 (void *)&cmd_setbonding_primary_slave,
4548 (void *)&cmd_setbonding_primary_port,
4553 /* *** ADD SLAVE *** */
4554 struct cmd_add_bonding_slave_result {
4555 cmdline_fixed_string_t add;
4556 cmdline_fixed_string_t bonding;
4557 cmdline_fixed_string_t slave;
4562 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4563 __attribute__((unused)) struct cmdline *cl,
4564 __attribute__((unused)) void *data)
4566 struct cmd_add_bonding_slave_result *res = parsed_result;
4567 portid_t master_port_id = res->port_id;
4568 portid_t slave_port_id = res->slave_id;
4570 /* add the slave for a bonded device. */
4571 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4572 printf("\t Failed to add slave %d to master port = %d.\n",
4573 slave_port_id, master_port_id);
4577 set_port_slave_flag(slave_port_id);
4580 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4581 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4583 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4584 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4585 bonding, "bonding");
4586 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4587 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4589 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4590 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4592 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4593 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4596 cmdline_parse_inst_t cmd_add_bonding_slave = {
4597 .f = cmd_add_bonding_slave_parsed,
4598 .help_str = "add bonding slave <slave_id> <port_id>: "
4599 "Add a slave device to a bonded device",
4602 (void *)&cmd_addbonding_slave_add,
4603 (void *)&cmd_addbonding_slave_bonding,
4604 (void *)&cmd_addbonding_slave_slave,
4605 (void *)&cmd_addbonding_slave_slaveid,
4606 (void *)&cmd_addbonding_slave_port,
4611 /* *** REMOVE SLAVE *** */
4612 struct cmd_remove_bonding_slave_result {
4613 cmdline_fixed_string_t remove;
4614 cmdline_fixed_string_t bonding;
4615 cmdline_fixed_string_t slave;
4620 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4621 __attribute__((unused)) struct cmdline *cl,
4622 __attribute__((unused)) void *data)
4624 struct cmd_remove_bonding_slave_result *res = parsed_result;
4625 portid_t master_port_id = res->port_id;
4626 portid_t slave_port_id = res->slave_id;
4628 /* remove the slave from a bonded device. */
4629 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4630 printf("\t Failed to remove slave %d from master port = %d.\n",
4631 slave_port_id, master_port_id);
4635 clear_port_slave_flag(slave_port_id);
4638 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4639 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4641 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4642 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4643 bonding, "bonding");
4644 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4645 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4647 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4648 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4650 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4651 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4654 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4655 .f = cmd_remove_bonding_slave_parsed,
4656 .help_str = "remove bonding slave <slave_id> <port_id>: "
4657 "Remove a slave device from a bonded device",
4660 (void *)&cmd_removebonding_slave_remove,
4661 (void *)&cmd_removebonding_slave_bonding,
4662 (void *)&cmd_removebonding_slave_slave,
4663 (void *)&cmd_removebonding_slave_slaveid,
4664 (void *)&cmd_removebonding_slave_port,
4669 /* *** CREATE BONDED DEVICE *** */
4670 struct cmd_create_bonded_device_result {
4671 cmdline_fixed_string_t create;
4672 cmdline_fixed_string_t bonded;
4673 cmdline_fixed_string_t device;
4678 static int bond_dev_num = 0;
4680 static void cmd_create_bonded_device_parsed(void *parsed_result,
4681 __attribute__((unused)) struct cmdline *cl,
4682 __attribute__((unused)) void *data)
4684 struct cmd_create_bonded_device_result *res = parsed_result;
4685 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4688 if (test_done == 0) {
4689 printf("Please stop forwarding first\n");
4693 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4696 /* Create a new bonded device. */
4697 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4699 printf("\t Failed to create bonded device.\n");
4702 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4705 /* Update number of ports */
4706 nb_ports = rte_eth_dev_count();
4707 reconfig(port_id, res->socket);
4708 rte_eth_promiscuous_enable(port_id);
4713 cmdline_parse_token_string_t cmd_createbonded_device_create =
4714 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4716 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4717 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4719 cmdline_parse_token_string_t cmd_createbonded_device_device =
4720 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4722 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4723 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4725 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4726 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4729 cmdline_parse_inst_t cmd_create_bonded_device = {
4730 .f = cmd_create_bonded_device_parsed,
4731 .help_str = "create bonded device <mode> <socket>: "
4732 "Create a new bonded device with specific bonding mode and socket",
4735 (void *)&cmd_createbonded_device_create,
4736 (void *)&cmd_createbonded_device_bonded,
4737 (void *)&cmd_createbonded_device_device,
4738 (void *)&cmd_createbonded_device_mode,
4739 (void *)&cmd_createbonded_device_socket,
4744 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4745 struct cmd_set_bond_mac_addr_result {
4746 cmdline_fixed_string_t set;
4747 cmdline_fixed_string_t bonding;
4748 cmdline_fixed_string_t mac_addr;
4750 struct ether_addr address;
4753 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4754 __attribute__((unused)) struct cmdline *cl,
4755 __attribute__((unused)) void *data)
4757 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4760 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4763 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4765 /* check the return value and print it if is < 0 */
4767 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4770 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4771 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4772 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4773 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4775 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4776 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4778 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4779 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4780 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4781 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4783 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4784 .f = cmd_set_bond_mac_addr_parsed,
4786 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4788 (void *)&cmd_set_bond_mac_addr_set,
4789 (void *)&cmd_set_bond_mac_addr_bonding,
4790 (void *)&cmd_set_bond_mac_addr_mac,
4791 (void *)&cmd_set_bond_mac_addr_portnum,
4792 (void *)&cmd_set_bond_mac_addr_addr,
4798 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4799 struct cmd_set_bond_mon_period_result {
4800 cmdline_fixed_string_t set;
4801 cmdline_fixed_string_t bonding;
4802 cmdline_fixed_string_t mon_period;
4807 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4808 __attribute__((unused)) struct cmdline *cl,
4809 __attribute__((unused)) void *data)
4811 struct cmd_set_bond_mon_period_result *res = parsed_result;
4814 if (res->port_num >= nb_ports) {
4815 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4819 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4821 /* check the return value and print it if is < 0 */
4823 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4826 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4827 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4829 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4830 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4831 bonding, "bonding");
4832 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4833 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4834 mon_period, "mon_period");
4835 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4836 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4838 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4839 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4842 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4843 .f = cmd_set_bond_mon_period_parsed,
4845 .help_str = "set bonding mon_period <port_id> <period_ms>",
4847 (void *)&cmd_set_bond_mon_period_set,
4848 (void *)&cmd_set_bond_mon_period_bonding,
4849 (void *)&cmd_set_bond_mon_period_mon_period,
4850 (void *)&cmd_set_bond_mon_period_portnum,
4851 (void *)&cmd_set_bond_mon_period_period_ms,
4856 #endif /* RTE_LIBRTE_PMD_BOND */
4858 /* *** SET FORWARDING MODE *** */
4859 struct cmd_set_fwd_mode_result {
4860 cmdline_fixed_string_t set;
4861 cmdline_fixed_string_t fwd;
4862 cmdline_fixed_string_t mode;
4865 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4866 __attribute__((unused)) struct cmdline *cl,
4867 __attribute__((unused)) void *data)
4869 struct cmd_set_fwd_mode_result *res = parsed_result;
4872 set_pkt_forwarding_mode(res->mode);
4875 cmdline_parse_token_string_t cmd_setfwd_set =
4876 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4877 cmdline_parse_token_string_t cmd_setfwd_fwd =
4878 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4879 cmdline_parse_token_string_t cmd_setfwd_mode =
4880 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4881 "" /* defined at init */);
4883 cmdline_parse_inst_t cmd_set_fwd_mode = {
4884 .f = cmd_set_fwd_mode_parsed,
4886 .help_str = NULL, /* defined at init */
4888 (void *)&cmd_setfwd_set,
4889 (void *)&cmd_setfwd_fwd,
4890 (void *)&cmd_setfwd_mode,
4895 static void cmd_set_fwd_mode_init(void)
4898 static char token[128];
4899 static char help[256];
4900 cmdline_parse_token_string_t *token_struct;
4902 modes = list_pkt_forwarding_modes();
4903 snprintf(help, sizeof(help), "set fwd %s: "
4904 "Set packet forwarding mode", modes);
4905 cmd_set_fwd_mode.help_str = help;
4907 /* string token separator is # */
4908 for (c = token; *modes != '\0'; modes++)
4913 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4914 token_struct->string_data.str = token;
4917 /* *** SET RETRY FORWARDING MODE *** */
4918 struct cmd_set_fwd_retry_mode_result {
4919 cmdline_fixed_string_t set;
4920 cmdline_fixed_string_t fwd;
4921 cmdline_fixed_string_t mode;
4922 cmdline_fixed_string_t retry;
4925 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4926 __attribute__((unused)) struct cmdline *cl,
4927 __attribute__((unused)) void *data)
4929 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4932 set_pkt_forwarding_mode(res->mode);
4935 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4936 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4938 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4939 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4941 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4942 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4944 "" /* defined at init */);
4945 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4946 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4949 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4950 .f = cmd_set_fwd_retry_mode_parsed,
4952 .help_str = NULL, /* defined at init */
4954 (void *)&cmd_setfwd_retry_set,
4955 (void *)&cmd_setfwd_retry_fwd,
4956 (void *)&cmd_setfwd_retry_mode,
4957 (void *)&cmd_setfwd_retry_retry,
4962 static void cmd_set_fwd_retry_mode_init(void)
4965 static char token[128];
4966 static char help[256];
4967 cmdline_parse_token_string_t *token_struct;
4969 modes = list_pkt_forwarding_retry_modes();
4970 snprintf(help, sizeof(help), "set fwd %s retry: "
4971 "Set packet forwarding mode with retry", modes);
4972 cmd_set_fwd_retry_mode.help_str = help;
4974 /* string token separator is # */
4975 for (c = token; *modes != '\0'; modes++)
4980 token_struct = (cmdline_parse_token_string_t *)
4981 cmd_set_fwd_retry_mode.tokens[2];
4982 token_struct->string_data.str = token;
4985 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4986 struct cmd_set_burst_tx_retry_result {
4987 cmdline_fixed_string_t set;
4988 cmdline_fixed_string_t burst;
4989 cmdline_fixed_string_t tx;
4990 cmdline_fixed_string_t delay;
4992 cmdline_fixed_string_t retry;
4996 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4997 __attribute__((unused)) struct cmdline *cl,
4998 __attribute__((unused)) void *data)
5000 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5002 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5003 && !strcmp(res->tx, "tx")) {
5004 if (!strcmp(res->delay, "delay"))
5005 burst_tx_delay_time = res->time;
5006 if (!strcmp(res->retry, "retry"))
5007 burst_tx_retry_num = res->retry_num;
5012 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5013 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5014 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5015 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5017 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5018 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5019 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5020 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5021 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5022 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5023 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5024 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5025 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5026 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5028 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5029 .f = cmd_set_burst_tx_retry_parsed,
5030 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5032 (void *)&cmd_set_burst_tx_retry_set,
5033 (void *)&cmd_set_burst_tx_retry_burst,
5034 (void *)&cmd_set_burst_tx_retry_tx,
5035 (void *)&cmd_set_burst_tx_retry_delay,
5036 (void *)&cmd_set_burst_tx_retry_time,
5037 (void *)&cmd_set_burst_tx_retry_retry,
5038 (void *)&cmd_set_burst_tx_retry_retry_num,
5043 /* *** SET PROMISC MODE *** */
5044 struct cmd_set_promisc_mode_result {
5045 cmdline_fixed_string_t set;
5046 cmdline_fixed_string_t promisc;
5047 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5048 uint8_t port_num; /* valid if "allports" argument == 0 */
5049 cmdline_fixed_string_t mode;
5052 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5053 __attribute__((unused)) struct cmdline *cl,
5056 struct cmd_set_promisc_mode_result *res = parsed_result;
5060 if (!strcmp(res->mode, "on"))
5067 RTE_ETH_FOREACH_DEV(i) {
5069 rte_eth_promiscuous_enable(i);
5071 rte_eth_promiscuous_disable(i);
5076 rte_eth_promiscuous_enable(res->port_num);
5078 rte_eth_promiscuous_disable(res->port_num);
5082 cmdline_parse_token_string_t cmd_setpromisc_set =
5083 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5084 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5085 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5087 cmdline_parse_token_string_t cmd_setpromisc_portall =
5088 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5090 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5091 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5093 cmdline_parse_token_string_t cmd_setpromisc_mode =
5094 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5097 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5098 .f = cmd_set_promisc_mode_parsed,
5100 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5102 (void *)&cmd_setpromisc_set,
5103 (void *)&cmd_setpromisc_promisc,
5104 (void *)&cmd_setpromisc_portall,
5105 (void *)&cmd_setpromisc_mode,
5110 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5111 .f = cmd_set_promisc_mode_parsed,
5113 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5115 (void *)&cmd_setpromisc_set,
5116 (void *)&cmd_setpromisc_promisc,
5117 (void *)&cmd_setpromisc_portnum,
5118 (void *)&cmd_setpromisc_mode,
5123 /* *** SET ALLMULTI MODE *** */
5124 struct cmd_set_allmulti_mode_result {
5125 cmdline_fixed_string_t set;
5126 cmdline_fixed_string_t allmulti;
5127 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5128 uint8_t port_num; /* valid if "allports" argument == 0 */
5129 cmdline_fixed_string_t mode;
5132 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5133 __attribute__((unused)) struct cmdline *cl,
5136 struct cmd_set_allmulti_mode_result *res = parsed_result;
5140 if (!strcmp(res->mode, "on"))
5147 RTE_ETH_FOREACH_DEV(i) {
5149 rte_eth_allmulticast_enable(i);
5151 rte_eth_allmulticast_disable(i);
5156 rte_eth_allmulticast_enable(res->port_num);
5158 rte_eth_allmulticast_disable(res->port_num);
5162 cmdline_parse_token_string_t cmd_setallmulti_set =
5163 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5164 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5165 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5167 cmdline_parse_token_string_t cmd_setallmulti_portall =
5168 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5170 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5171 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5173 cmdline_parse_token_string_t cmd_setallmulti_mode =
5174 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5177 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5178 .f = cmd_set_allmulti_mode_parsed,
5180 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5182 (void *)&cmd_setallmulti_set,
5183 (void *)&cmd_setallmulti_allmulti,
5184 (void *)&cmd_setallmulti_portall,
5185 (void *)&cmd_setallmulti_mode,
5190 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5191 .f = cmd_set_allmulti_mode_parsed,
5193 .help_str = "set allmulti <port_id> on|off: "
5194 "Set allmulti mode on port_id",
5196 (void *)&cmd_setallmulti_set,
5197 (void *)&cmd_setallmulti_allmulti,
5198 (void *)&cmd_setallmulti_portnum,
5199 (void *)&cmd_setallmulti_mode,
5204 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5205 struct cmd_link_flow_ctrl_set_result {
5206 cmdline_fixed_string_t set;
5207 cmdline_fixed_string_t flow_ctrl;
5208 cmdline_fixed_string_t rx;
5209 cmdline_fixed_string_t rx_lfc_mode;
5210 cmdline_fixed_string_t tx;
5211 cmdline_fixed_string_t tx_lfc_mode;
5212 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5213 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5214 cmdline_fixed_string_t autoneg_str;
5215 cmdline_fixed_string_t autoneg;
5216 cmdline_fixed_string_t hw_str;
5217 uint32_t high_water;
5218 cmdline_fixed_string_t lw_str;
5220 cmdline_fixed_string_t pt_str;
5221 uint16_t pause_time;
5222 cmdline_fixed_string_t xon_str;
5227 cmdline_parse_token_string_t cmd_lfc_set_set =
5228 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5230 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5231 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5232 flow_ctrl, "flow_ctrl");
5233 cmdline_parse_token_string_t cmd_lfc_set_rx =
5234 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5236 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5237 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5238 rx_lfc_mode, "on#off");
5239 cmdline_parse_token_string_t cmd_lfc_set_tx =
5240 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5242 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5243 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5244 tx_lfc_mode, "on#off");
5245 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5246 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5247 hw_str, "high_water");
5248 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5249 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5250 high_water, UINT32);
5251 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5252 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5253 lw_str, "low_water");
5254 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5255 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5257 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5258 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5259 pt_str, "pause_time");
5260 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5261 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5262 pause_time, UINT16);
5263 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5264 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5265 xon_str, "send_xon");
5266 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5267 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5269 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5270 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5271 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5272 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5273 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5274 mac_ctrl_frame_fwd_mode, "on#off");
5275 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5276 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5277 autoneg_str, "autoneg");
5278 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5279 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5281 cmdline_parse_token_num_t cmd_lfc_set_portid =
5282 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5285 /* forward declaration */
5287 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5290 cmdline_parse_inst_t cmd_link_flow_control_set = {
5291 .f = cmd_link_flow_ctrl_set_parsed,
5293 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5294 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5295 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5297 (void *)&cmd_lfc_set_set,
5298 (void *)&cmd_lfc_set_flow_ctrl,
5299 (void *)&cmd_lfc_set_rx,
5300 (void *)&cmd_lfc_set_rx_mode,
5301 (void *)&cmd_lfc_set_tx,
5302 (void *)&cmd_lfc_set_tx_mode,
5303 (void *)&cmd_lfc_set_high_water,
5304 (void *)&cmd_lfc_set_low_water,
5305 (void *)&cmd_lfc_set_pause_time,
5306 (void *)&cmd_lfc_set_send_xon,
5307 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5308 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5309 (void *)&cmd_lfc_set_autoneg_str,
5310 (void *)&cmd_lfc_set_autoneg,
5311 (void *)&cmd_lfc_set_portid,
5316 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5317 .f = cmd_link_flow_ctrl_set_parsed,
5318 .data = (void *)&cmd_link_flow_control_set_rx,
5319 .help_str = "set flow_ctrl rx on|off <port_id>: "
5320 "Change rx flow control parameter",
5322 (void *)&cmd_lfc_set_set,
5323 (void *)&cmd_lfc_set_flow_ctrl,
5324 (void *)&cmd_lfc_set_rx,
5325 (void *)&cmd_lfc_set_rx_mode,
5326 (void *)&cmd_lfc_set_portid,
5331 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5332 .f = cmd_link_flow_ctrl_set_parsed,
5333 .data = (void *)&cmd_link_flow_control_set_tx,
5334 .help_str = "set flow_ctrl tx on|off <port_id>: "
5335 "Change tx flow control parameter",
5337 (void *)&cmd_lfc_set_set,
5338 (void *)&cmd_lfc_set_flow_ctrl,
5339 (void *)&cmd_lfc_set_tx,
5340 (void *)&cmd_lfc_set_tx_mode,
5341 (void *)&cmd_lfc_set_portid,
5346 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5347 .f = cmd_link_flow_ctrl_set_parsed,
5348 .data = (void *)&cmd_link_flow_control_set_hw,
5349 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5350 "Change high water flow control parameter",
5352 (void *)&cmd_lfc_set_set,
5353 (void *)&cmd_lfc_set_flow_ctrl,
5354 (void *)&cmd_lfc_set_high_water_str,
5355 (void *)&cmd_lfc_set_high_water,
5356 (void *)&cmd_lfc_set_portid,
5361 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5362 .f = cmd_link_flow_ctrl_set_parsed,
5363 .data = (void *)&cmd_link_flow_control_set_lw,
5364 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5365 "Change low water flow control parameter",
5367 (void *)&cmd_lfc_set_set,
5368 (void *)&cmd_lfc_set_flow_ctrl,
5369 (void *)&cmd_lfc_set_low_water_str,
5370 (void *)&cmd_lfc_set_low_water,
5371 (void *)&cmd_lfc_set_portid,
5376 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5377 .f = cmd_link_flow_ctrl_set_parsed,
5378 .data = (void *)&cmd_link_flow_control_set_pt,
5379 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5380 "Change pause time flow control parameter",
5382 (void *)&cmd_lfc_set_set,
5383 (void *)&cmd_lfc_set_flow_ctrl,
5384 (void *)&cmd_lfc_set_pause_time_str,
5385 (void *)&cmd_lfc_set_pause_time,
5386 (void *)&cmd_lfc_set_portid,
5391 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5392 .f = cmd_link_flow_ctrl_set_parsed,
5393 .data = (void *)&cmd_link_flow_control_set_xon,
5394 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5395 "Change send_xon flow control parameter",
5397 (void *)&cmd_lfc_set_set,
5398 (void *)&cmd_lfc_set_flow_ctrl,
5399 (void *)&cmd_lfc_set_send_xon_str,
5400 (void *)&cmd_lfc_set_send_xon,
5401 (void *)&cmd_lfc_set_portid,
5406 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5407 .f = cmd_link_flow_ctrl_set_parsed,
5408 .data = (void *)&cmd_link_flow_control_set_macfwd,
5409 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5410 "Change mac ctrl fwd flow control parameter",
5412 (void *)&cmd_lfc_set_set,
5413 (void *)&cmd_lfc_set_flow_ctrl,
5414 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5415 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5416 (void *)&cmd_lfc_set_portid,
5421 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5422 .f = cmd_link_flow_ctrl_set_parsed,
5423 .data = (void *)&cmd_link_flow_control_set_autoneg,
5424 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5425 "Change autoneg flow control parameter",
5427 (void *)&cmd_lfc_set_set,
5428 (void *)&cmd_lfc_set_flow_ctrl,
5429 (void *)&cmd_lfc_set_autoneg_str,
5430 (void *)&cmd_lfc_set_autoneg,
5431 (void *)&cmd_lfc_set_portid,
5437 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5438 __attribute__((unused)) struct cmdline *cl,
5441 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5442 cmdline_parse_inst_t *cmd = data;
5443 struct rte_eth_fc_conf fc_conf;
5449 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5450 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5451 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5452 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5454 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5455 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5458 /* Partial command line, retrieve current configuration */
5460 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5462 printf("cannot get current flow ctrl parameters, return"
5463 "code = %d\n", ret);
5467 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5468 (fc_conf.mode == RTE_FC_FULL))
5470 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5471 (fc_conf.mode == RTE_FC_FULL))
5475 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5476 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5478 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5479 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5481 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5483 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5484 fc_conf.high_water = res->high_water;
5486 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5487 fc_conf.low_water = res->low_water;
5489 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5490 fc_conf.pause_time = res->pause_time;
5492 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5493 fc_conf.send_xon = res->send_xon;
5495 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5496 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5497 fc_conf.mac_ctrl_frame_fwd = 1;
5499 fc_conf.mac_ctrl_frame_fwd = 0;
5502 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5503 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5505 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5507 printf("bad flow contrl parameter, return code = %d \n", ret);
5510 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5511 struct cmd_priority_flow_ctrl_set_result {
5512 cmdline_fixed_string_t set;
5513 cmdline_fixed_string_t pfc_ctrl;
5514 cmdline_fixed_string_t rx;
5515 cmdline_fixed_string_t rx_pfc_mode;
5516 cmdline_fixed_string_t tx;
5517 cmdline_fixed_string_t tx_pfc_mode;
5518 uint32_t high_water;
5520 uint16_t pause_time;
5526 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5527 __attribute__((unused)) struct cmdline *cl,
5528 __attribute__((unused)) void *data)
5530 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5531 struct rte_eth_pfc_conf pfc_conf;
5532 int rx_fc_enable, tx_fc_enable;
5536 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5537 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5538 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5539 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5541 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5542 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5545 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5546 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5547 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5548 pfc_conf.fc.high_water = res->high_water;
5549 pfc_conf.fc.low_water = res->low_water;
5550 pfc_conf.fc.pause_time = res->pause_time;
5551 pfc_conf.priority = res->priority;
5553 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5555 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5558 cmdline_parse_token_string_t cmd_pfc_set_set =
5559 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5561 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5562 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5563 pfc_ctrl, "pfc_ctrl");
5564 cmdline_parse_token_string_t cmd_pfc_set_rx =
5565 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5567 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5568 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5569 rx_pfc_mode, "on#off");
5570 cmdline_parse_token_string_t cmd_pfc_set_tx =
5571 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5573 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5574 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5575 tx_pfc_mode, "on#off");
5576 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5577 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5578 high_water, UINT32);
5579 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5580 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5582 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5583 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5584 pause_time, UINT16);
5585 cmdline_parse_token_num_t cmd_pfc_set_priority =
5586 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5588 cmdline_parse_token_num_t cmd_pfc_set_portid =
5589 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5592 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5593 .f = cmd_priority_flow_ctrl_set_parsed,
5595 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5596 "<pause_time> <priority> <port_id>: "
5597 "Configure the Ethernet priority flow control",
5599 (void *)&cmd_pfc_set_set,
5600 (void *)&cmd_pfc_set_flow_ctrl,
5601 (void *)&cmd_pfc_set_rx,
5602 (void *)&cmd_pfc_set_rx_mode,
5603 (void *)&cmd_pfc_set_tx,
5604 (void *)&cmd_pfc_set_tx_mode,
5605 (void *)&cmd_pfc_set_high_water,
5606 (void *)&cmd_pfc_set_low_water,
5607 (void *)&cmd_pfc_set_pause_time,
5608 (void *)&cmd_pfc_set_priority,
5609 (void *)&cmd_pfc_set_portid,
5614 /* *** RESET CONFIGURATION *** */
5615 struct cmd_reset_result {
5616 cmdline_fixed_string_t reset;
5617 cmdline_fixed_string_t def;
5620 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5622 __attribute__((unused)) void *data)
5624 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5625 set_def_fwd_config();
5628 cmdline_parse_token_string_t cmd_reset_set =
5629 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5630 cmdline_parse_token_string_t cmd_reset_def =
5631 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5634 cmdline_parse_inst_t cmd_reset = {
5635 .f = cmd_reset_parsed,
5637 .help_str = "set default: Reset default forwarding configuration",
5639 (void *)&cmd_reset_set,
5640 (void *)&cmd_reset_def,
5645 /* *** START FORWARDING *** */
5646 struct cmd_start_result {
5647 cmdline_fixed_string_t start;
5650 cmdline_parse_token_string_t cmd_start_start =
5651 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5653 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5654 __attribute__((unused)) struct cmdline *cl,
5655 __attribute__((unused)) void *data)
5657 start_packet_forwarding(0);
5660 cmdline_parse_inst_t cmd_start = {
5661 .f = cmd_start_parsed,
5663 .help_str = "start: Start packet forwarding",
5665 (void *)&cmd_start_start,
5670 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5671 struct cmd_start_tx_first_result {
5672 cmdline_fixed_string_t start;
5673 cmdline_fixed_string_t tx_first;
5677 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5678 __attribute__((unused)) struct cmdline *cl,
5679 __attribute__((unused)) void *data)
5681 start_packet_forwarding(1);
5684 cmdline_parse_token_string_t cmd_start_tx_first_start =
5685 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5687 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5688 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5689 tx_first, "tx_first");
5691 cmdline_parse_inst_t cmd_start_tx_first = {
5692 .f = cmd_start_tx_first_parsed,
5694 .help_str = "start tx_first: Start packet forwarding, "
5695 "after sending 1 burst of packets",
5697 (void *)&cmd_start_tx_first_start,
5698 (void *)&cmd_start_tx_first_tx_first,
5703 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5704 struct cmd_start_tx_first_n_result {
5705 cmdline_fixed_string_t start;
5706 cmdline_fixed_string_t tx_first;
5711 cmd_start_tx_first_n_parsed(void *parsed_result,
5712 __attribute__((unused)) struct cmdline *cl,
5713 __attribute__((unused)) void *data)
5715 struct cmd_start_tx_first_n_result *res = parsed_result;
5717 start_packet_forwarding(res->tx_num);
5720 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5721 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5723 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5724 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5725 tx_first, "tx_first");
5726 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5727 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5730 cmdline_parse_inst_t cmd_start_tx_first_n = {
5731 .f = cmd_start_tx_first_n_parsed,
5733 .help_str = "start tx_first <num>: "
5734 "packet forwarding, after sending <num> bursts of packets",
5736 (void *)&cmd_start_tx_first_n_start,
5737 (void *)&cmd_start_tx_first_n_tx_first,
5738 (void *)&cmd_start_tx_first_n_tx_num,
5743 /* *** SET LINK UP *** */
5744 struct cmd_set_link_up_result {
5745 cmdline_fixed_string_t set;
5746 cmdline_fixed_string_t link_up;
5747 cmdline_fixed_string_t port;
5751 cmdline_parse_token_string_t cmd_set_link_up_set =
5752 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5753 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5754 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5756 cmdline_parse_token_string_t cmd_set_link_up_port =
5757 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5758 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5759 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5761 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5762 __attribute__((unused)) struct cmdline *cl,
5763 __attribute__((unused)) void *data)
5765 struct cmd_set_link_up_result *res = parsed_result;
5766 dev_set_link_up(res->port_id);
5769 cmdline_parse_inst_t cmd_set_link_up = {
5770 .f = cmd_set_link_up_parsed,
5772 .help_str = "set link-up port <port id>",
5774 (void *)&cmd_set_link_up_set,
5775 (void *)&cmd_set_link_up_link_up,
5776 (void *)&cmd_set_link_up_port,
5777 (void *)&cmd_set_link_up_port_id,
5782 /* *** SET LINK DOWN *** */
5783 struct cmd_set_link_down_result {
5784 cmdline_fixed_string_t set;
5785 cmdline_fixed_string_t link_down;
5786 cmdline_fixed_string_t port;
5790 cmdline_parse_token_string_t cmd_set_link_down_set =
5791 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5792 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5793 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5795 cmdline_parse_token_string_t cmd_set_link_down_port =
5796 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5797 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5798 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5800 static void cmd_set_link_down_parsed(
5801 __attribute__((unused)) void *parsed_result,
5802 __attribute__((unused)) struct cmdline *cl,
5803 __attribute__((unused)) void *data)
5805 struct cmd_set_link_down_result *res = parsed_result;
5806 dev_set_link_down(res->port_id);
5809 cmdline_parse_inst_t cmd_set_link_down = {
5810 .f = cmd_set_link_down_parsed,
5812 .help_str = "set link-down port <port id>",
5814 (void *)&cmd_set_link_down_set,
5815 (void *)&cmd_set_link_down_link_down,
5816 (void *)&cmd_set_link_down_port,
5817 (void *)&cmd_set_link_down_port_id,
5822 /* *** SHOW CFG *** */
5823 struct cmd_showcfg_result {
5824 cmdline_fixed_string_t show;
5825 cmdline_fixed_string_t cfg;
5826 cmdline_fixed_string_t what;
5829 static void cmd_showcfg_parsed(void *parsed_result,
5830 __attribute__((unused)) struct cmdline *cl,
5831 __attribute__((unused)) void *data)
5833 struct cmd_showcfg_result *res = parsed_result;
5834 if (!strcmp(res->what, "rxtx"))
5835 rxtx_config_display();
5836 else if (!strcmp(res->what, "cores"))
5837 fwd_lcores_config_display();
5838 else if (!strcmp(res->what, "fwd"))
5839 pkt_fwd_config_display(&cur_fwd_config);
5840 else if (!strcmp(res->what, "txpkts"))
5841 show_tx_pkt_segments();
5844 cmdline_parse_token_string_t cmd_showcfg_show =
5845 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5846 cmdline_parse_token_string_t cmd_showcfg_port =
5847 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5848 cmdline_parse_token_string_t cmd_showcfg_what =
5849 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5850 "rxtx#cores#fwd#txpkts");
5852 cmdline_parse_inst_t cmd_showcfg = {
5853 .f = cmd_showcfg_parsed,
5855 .help_str = "show config rxtx|cores|fwd|txpkts",
5857 (void *)&cmd_showcfg_show,
5858 (void *)&cmd_showcfg_port,
5859 (void *)&cmd_showcfg_what,
5864 /* *** SHOW ALL PORT INFO *** */
5865 struct cmd_showportall_result {
5866 cmdline_fixed_string_t show;
5867 cmdline_fixed_string_t port;
5868 cmdline_fixed_string_t what;
5869 cmdline_fixed_string_t all;
5872 static void cmd_showportall_parsed(void *parsed_result,
5873 __attribute__((unused)) struct cmdline *cl,
5874 __attribute__((unused)) void *data)
5878 struct cmd_showportall_result *res = parsed_result;
5879 if (!strcmp(res->show, "clear")) {
5880 if (!strcmp(res->what, "stats"))
5881 RTE_ETH_FOREACH_DEV(i)
5883 else if (!strcmp(res->what, "xstats"))
5884 RTE_ETH_FOREACH_DEV(i)
5885 nic_xstats_clear(i);
5886 } else if (!strcmp(res->what, "info"))
5887 RTE_ETH_FOREACH_DEV(i)
5888 port_infos_display(i);
5889 else if (!strcmp(res->what, "stats"))
5890 RTE_ETH_FOREACH_DEV(i)
5891 nic_stats_display(i);
5892 else if (!strcmp(res->what, "xstats"))
5893 RTE_ETH_FOREACH_DEV(i)
5894 nic_xstats_display(i);
5895 else if (!strcmp(res->what, "fdir"))
5896 RTE_ETH_FOREACH_DEV(i)
5898 else if (!strcmp(res->what, "stat_qmap"))
5899 RTE_ETH_FOREACH_DEV(i)
5900 nic_stats_mapping_display(i);
5901 else if (!strcmp(res->what, "dcb_tc"))
5902 RTE_ETH_FOREACH_DEV(i)
5903 port_dcb_info_display(i);
5904 else if (!strcmp(res->what, "cap"))
5905 RTE_ETH_FOREACH_DEV(i)
5906 port_offload_cap_display(i);
5909 cmdline_parse_token_string_t cmd_showportall_show =
5910 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5912 cmdline_parse_token_string_t cmd_showportall_port =
5913 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5914 cmdline_parse_token_string_t cmd_showportall_what =
5915 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5916 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5917 cmdline_parse_token_string_t cmd_showportall_all =
5918 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5919 cmdline_parse_inst_t cmd_showportall = {
5920 .f = cmd_showportall_parsed,
5922 .help_str = "show|clear port "
5923 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5925 (void *)&cmd_showportall_show,
5926 (void *)&cmd_showportall_port,
5927 (void *)&cmd_showportall_what,
5928 (void *)&cmd_showportall_all,
5933 /* *** SHOW PORT INFO *** */
5934 struct cmd_showport_result {
5935 cmdline_fixed_string_t show;
5936 cmdline_fixed_string_t port;
5937 cmdline_fixed_string_t what;
5941 static void cmd_showport_parsed(void *parsed_result,
5942 __attribute__((unused)) struct cmdline *cl,
5943 __attribute__((unused)) void *data)
5945 struct cmd_showport_result *res = parsed_result;
5946 if (!strcmp(res->show, "clear")) {
5947 if (!strcmp(res->what, "stats"))
5948 nic_stats_clear(res->portnum);
5949 else if (!strcmp(res->what, "xstats"))
5950 nic_xstats_clear(res->portnum);
5951 } else if (!strcmp(res->what, "info"))
5952 port_infos_display(res->portnum);
5953 else if (!strcmp(res->what, "stats"))
5954 nic_stats_display(res->portnum);
5955 else if (!strcmp(res->what, "xstats"))
5956 nic_xstats_display(res->portnum);
5957 else if (!strcmp(res->what, "fdir"))
5958 fdir_get_infos(res->portnum);
5959 else if (!strcmp(res->what, "stat_qmap"))
5960 nic_stats_mapping_display(res->portnum);
5961 else if (!strcmp(res->what, "dcb_tc"))
5962 port_dcb_info_display(res->portnum);
5963 else if (!strcmp(res->what, "cap"))
5964 port_offload_cap_display(res->portnum);
5967 cmdline_parse_token_string_t cmd_showport_show =
5968 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5970 cmdline_parse_token_string_t cmd_showport_port =
5971 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5972 cmdline_parse_token_string_t cmd_showport_what =
5973 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5974 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5975 cmdline_parse_token_num_t cmd_showport_portnum =
5976 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5978 cmdline_parse_inst_t cmd_showport = {
5979 .f = cmd_showport_parsed,
5981 .help_str = "show|clear port "
5982 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5985 (void *)&cmd_showport_show,
5986 (void *)&cmd_showport_port,
5987 (void *)&cmd_showport_what,
5988 (void *)&cmd_showport_portnum,
5993 /* *** SHOW QUEUE INFO *** */
5994 struct cmd_showqueue_result {
5995 cmdline_fixed_string_t show;
5996 cmdline_fixed_string_t type;
5997 cmdline_fixed_string_t what;
6003 cmd_showqueue_parsed(void *parsed_result,
6004 __attribute__((unused)) struct cmdline *cl,
6005 __attribute__((unused)) void *data)
6007 struct cmd_showqueue_result *res = parsed_result;
6009 if (!strcmp(res->type, "rxq"))
6010 rx_queue_infos_display(res->portnum, res->queuenum);
6011 else if (!strcmp(res->type, "txq"))
6012 tx_queue_infos_display(res->portnum, res->queuenum);
6015 cmdline_parse_token_string_t cmd_showqueue_show =
6016 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6017 cmdline_parse_token_string_t cmd_showqueue_type =
6018 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6019 cmdline_parse_token_string_t cmd_showqueue_what =
6020 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6021 cmdline_parse_token_num_t cmd_showqueue_portnum =
6022 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6023 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6024 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6026 cmdline_parse_inst_t cmd_showqueue = {
6027 .f = cmd_showqueue_parsed,
6029 .help_str = "show rxq|txq info <port_id> <queue_id>",
6031 (void *)&cmd_showqueue_show,
6032 (void *)&cmd_showqueue_type,
6033 (void *)&cmd_showqueue_what,
6034 (void *)&cmd_showqueue_portnum,
6035 (void *)&cmd_showqueue_queuenum,
6040 /* *** READ PORT REGISTER *** */
6041 struct cmd_read_reg_result {
6042 cmdline_fixed_string_t read;
6043 cmdline_fixed_string_t reg;
6049 cmd_read_reg_parsed(void *parsed_result,
6050 __attribute__((unused)) struct cmdline *cl,
6051 __attribute__((unused)) void *data)
6053 struct cmd_read_reg_result *res = parsed_result;
6054 port_reg_display(res->port_id, res->reg_off);
6057 cmdline_parse_token_string_t cmd_read_reg_read =
6058 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6059 cmdline_parse_token_string_t cmd_read_reg_reg =
6060 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6061 cmdline_parse_token_num_t cmd_read_reg_port_id =
6062 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6063 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6064 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6066 cmdline_parse_inst_t cmd_read_reg = {
6067 .f = cmd_read_reg_parsed,
6069 .help_str = "read reg <port_id> <reg_off>",
6071 (void *)&cmd_read_reg_read,
6072 (void *)&cmd_read_reg_reg,
6073 (void *)&cmd_read_reg_port_id,
6074 (void *)&cmd_read_reg_reg_off,
6079 /* *** READ PORT REGISTER BIT FIELD *** */
6080 struct cmd_read_reg_bit_field_result {
6081 cmdline_fixed_string_t read;
6082 cmdline_fixed_string_t regfield;
6090 cmd_read_reg_bit_field_parsed(void *parsed_result,
6091 __attribute__((unused)) struct cmdline *cl,
6092 __attribute__((unused)) void *data)
6094 struct cmd_read_reg_bit_field_result *res = parsed_result;
6095 port_reg_bit_field_display(res->port_id, res->reg_off,
6096 res->bit1_pos, res->bit2_pos);
6099 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6100 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6102 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6103 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6104 regfield, "regfield");
6105 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6106 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6108 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6109 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6111 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6112 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6114 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6115 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6118 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6119 .f = cmd_read_reg_bit_field_parsed,
6121 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6122 "Read register bit field between bit_x and bit_y included",
6124 (void *)&cmd_read_reg_bit_field_read,
6125 (void *)&cmd_read_reg_bit_field_regfield,
6126 (void *)&cmd_read_reg_bit_field_port_id,
6127 (void *)&cmd_read_reg_bit_field_reg_off,
6128 (void *)&cmd_read_reg_bit_field_bit1_pos,
6129 (void *)&cmd_read_reg_bit_field_bit2_pos,
6134 /* *** READ PORT REGISTER BIT *** */
6135 struct cmd_read_reg_bit_result {
6136 cmdline_fixed_string_t read;
6137 cmdline_fixed_string_t regbit;
6144 cmd_read_reg_bit_parsed(void *parsed_result,
6145 __attribute__((unused)) struct cmdline *cl,
6146 __attribute__((unused)) void *data)
6148 struct cmd_read_reg_bit_result *res = parsed_result;
6149 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6152 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6153 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6154 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6155 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6157 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6158 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6159 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6160 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6161 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6162 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6164 cmdline_parse_inst_t cmd_read_reg_bit = {
6165 .f = cmd_read_reg_bit_parsed,
6167 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6169 (void *)&cmd_read_reg_bit_read,
6170 (void *)&cmd_read_reg_bit_regbit,
6171 (void *)&cmd_read_reg_bit_port_id,
6172 (void *)&cmd_read_reg_bit_reg_off,
6173 (void *)&cmd_read_reg_bit_bit_pos,
6178 /* *** WRITE PORT REGISTER *** */
6179 struct cmd_write_reg_result {
6180 cmdline_fixed_string_t write;
6181 cmdline_fixed_string_t reg;
6188 cmd_write_reg_parsed(void *parsed_result,
6189 __attribute__((unused)) struct cmdline *cl,
6190 __attribute__((unused)) void *data)
6192 struct cmd_write_reg_result *res = parsed_result;
6193 port_reg_set(res->port_id, res->reg_off, res->value);
6196 cmdline_parse_token_string_t cmd_write_reg_write =
6197 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6198 cmdline_parse_token_string_t cmd_write_reg_reg =
6199 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6200 cmdline_parse_token_num_t cmd_write_reg_port_id =
6201 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6202 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6203 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6204 cmdline_parse_token_num_t cmd_write_reg_value =
6205 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6207 cmdline_parse_inst_t cmd_write_reg = {
6208 .f = cmd_write_reg_parsed,
6210 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6212 (void *)&cmd_write_reg_write,
6213 (void *)&cmd_write_reg_reg,
6214 (void *)&cmd_write_reg_port_id,
6215 (void *)&cmd_write_reg_reg_off,
6216 (void *)&cmd_write_reg_value,
6221 /* *** WRITE PORT REGISTER BIT FIELD *** */
6222 struct cmd_write_reg_bit_field_result {
6223 cmdline_fixed_string_t write;
6224 cmdline_fixed_string_t regfield;
6233 cmd_write_reg_bit_field_parsed(void *parsed_result,
6234 __attribute__((unused)) struct cmdline *cl,
6235 __attribute__((unused)) void *data)
6237 struct cmd_write_reg_bit_field_result *res = parsed_result;
6238 port_reg_bit_field_set(res->port_id, res->reg_off,
6239 res->bit1_pos, res->bit2_pos, res->value);
6242 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6243 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6245 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6246 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6247 regfield, "regfield");
6248 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6249 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6251 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6252 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6254 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6255 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6257 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6258 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6260 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6261 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6264 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6265 .f = cmd_write_reg_bit_field_parsed,
6267 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6269 "Set register bit field between bit_x and bit_y included",
6271 (void *)&cmd_write_reg_bit_field_write,
6272 (void *)&cmd_write_reg_bit_field_regfield,
6273 (void *)&cmd_write_reg_bit_field_port_id,
6274 (void *)&cmd_write_reg_bit_field_reg_off,
6275 (void *)&cmd_write_reg_bit_field_bit1_pos,
6276 (void *)&cmd_write_reg_bit_field_bit2_pos,
6277 (void *)&cmd_write_reg_bit_field_value,
6282 /* *** WRITE PORT REGISTER BIT *** */
6283 struct cmd_write_reg_bit_result {
6284 cmdline_fixed_string_t write;
6285 cmdline_fixed_string_t regbit;
6293 cmd_write_reg_bit_parsed(void *parsed_result,
6294 __attribute__((unused)) struct cmdline *cl,
6295 __attribute__((unused)) void *data)
6297 struct cmd_write_reg_bit_result *res = parsed_result;
6298 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6301 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6302 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6304 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6305 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6307 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6308 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6309 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6310 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6311 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6312 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6313 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6314 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6316 cmdline_parse_inst_t cmd_write_reg_bit = {
6317 .f = cmd_write_reg_bit_parsed,
6319 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6322 (void *)&cmd_write_reg_bit_write,
6323 (void *)&cmd_write_reg_bit_regbit,
6324 (void *)&cmd_write_reg_bit_port_id,
6325 (void *)&cmd_write_reg_bit_reg_off,
6326 (void *)&cmd_write_reg_bit_bit_pos,
6327 (void *)&cmd_write_reg_bit_value,
6332 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6333 struct cmd_read_rxd_txd_result {
6334 cmdline_fixed_string_t read;
6335 cmdline_fixed_string_t rxd_txd;
6342 cmd_read_rxd_txd_parsed(void *parsed_result,
6343 __attribute__((unused)) struct cmdline *cl,
6344 __attribute__((unused)) void *data)
6346 struct cmd_read_rxd_txd_result *res = parsed_result;
6348 if (!strcmp(res->rxd_txd, "rxd"))
6349 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6350 else if (!strcmp(res->rxd_txd, "txd"))
6351 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6354 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6355 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6356 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6357 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6359 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6360 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6361 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6362 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6363 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6364 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6366 cmdline_parse_inst_t cmd_read_rxd_txd = {
6367 .f = cmd_read_rxd_txd_parsed,
6369 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6371 (void *)&cmd_read_rxd_txd_read,
6372 (void *)&cmd_read_rxd_txd_rxd_txd,
6373 (void *)&cmd_read_rxd_txd_port_id,
6374 (void *)&cmd_read_rxd_txd_queue_id,
6375 (void *)&cmd_read_rxd_txd_desc_id,
6381 struct cmd_quit_result {
6382 cmdline_fixed_string_t quit;
6385 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6387 __attribute__((unused)) void *data)
6393 cmdline_parse_token_string_t cmd_quit_quit =
6394 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6396 cmdline_parse_inst_t cmd_quit = {
6397 .f = cmd_quit_parsed,
6399 .help_str = "quit: Exit application",
6401 (void *)&cmd_quit_quit,
6406 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6407 struct cmd_mac_addr_result {
6408 cmdline_fixed_string_t mac_addr_cmd;
6409 cmdline_fixed_string_t what;
6411 struct ether_addr address;
6414 static void cmd_mac_addr_parsed(void *parsed_result,
6415 __attribute__((unused)) struct cmdline *cl,
6416 __attribute__((unused)) void *data)
6418 struct cmd_mac_addr_result *res = parsed_result;
6421 if (strcmp(res->what, "add") == 0)
6422 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6423 else if (strcmp(res->what, "set") == 0)
6424 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6427 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6429 /* check the return value and print it if is < 0 */
6431 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6435 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6436 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6438 cmdline_parse_token_string_t cmd_mac_addr_what =
6439 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6441 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6442 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6443 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6444 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6446 cmdline_parse_inst_t cmd_mac_addr = {
6447 .f = cmd_mac_addr_parsed,
6449 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6450 "Add/Remove/Set MAC address on port_id",
6452 (void *)&cmd_mac_addr_cmd,
6453 (void *)&cmd_mac_addr_what,
6454 (void *)&cmd_mac_addr_portnum,
6455 (void *)&cmd_mac_addr_addr,
6461 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6462 struct cmd_set_qmap_result {
6463 cmdline_fixed_string_t set;
6464 cmdline_fixed_string_t qmap;
6465 cmdline_fixed_string_t what;
6472 cmd_set_qmap_parsed(void *parsed_result,
6473 __attribute__((unused)) struct cmdline *cl,
6474 __attribute__((unused)) void *data)
6476 struct cmd_set_qmap_result *res = parsed_result;
6477 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6479 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6482 cmdline_parse_token_string_t cmd_setqmap_set =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6485 cmdline_parse_token_string_t cmd_setqmap_qmap =
6486 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6488 cmdline_parse_token_string_t cmd_setqmap_what =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6491 cmdline_parse_token_num_t cmd_setqmap_portid =
6492 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6494 cmdline_parse_token_num_t cmd_setqmap_queueid =
6495 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6497 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6498 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6501 cmdline_parse_inst_t cmd_set_qmap = {
6502 .f = cmd_set_qmap_parsed,
6504 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6505 "Set statistics mapping value on tx|rx queue_id of port_id",
6507 (void *)&cmd_setqmap_set,
6508 (void *)&cmd_setqmap_qmap,
6509 (void *)&cmd_setqmap_what,
6510 (void *)&cmd_setqmap_portid,
6511 (void *)&cmd_setqmap_queueid,
6512 (void *)&cmd_setqmap_mapvalue,
6517 /* *** CONFIGURE UNICAST HASH TABLE *** */
6518 struct cmd_set_uc_hash_table {
6519 cmdline_fixed_string_t set;
6520 cmdline_fixed_string_t port;
6522 cmdline_fixed_string_t what;
6523 struct ether_addr address;
6524 cmdline_fixed_string_t mode;
6528 cmd_set_uc_hash_parsed(void *parsed_result,
6529 __attribute__((unused)) struct cmdline *cl,
6530 __attribute__((unused)) void *data)
6533 struct cmd_set_uc_hash_table *res = parsed_result;
6535 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6537 if (strcmp(res->what, "uta") == 0)
6538 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6539 &res->address,(uint8_t)is_on);
6541 printf("bad unicast hash table parameter, return code = %d \n", ret);
6545 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6546 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6548 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6551 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6552 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6554 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6555 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6557 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6558 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6560 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6561 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6564 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6565 .f = cmd_set_uc_hash_parsed,
6567 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6569 (void *)&cmd_set_uc_hash_set,
6570 (void *)&cmd_set_uc_hash_port,
6571 (void *)&cmd_set_uc_hash_portid,
6572 (void *)&cmd_set_uc_hash_what,
6573 (void *)&cmd_set_uc_hash_mac,
6574 (void *)&cmd_set_uc_hash_mode,
6579 struct cmd_set_uc_all_hash_table {
6580 cmdline_fixed_string_t set;
6581 cmdline_fixed_string_t port;
6583 cmdline_fixed_string_t what;
6584 cmdline_fixed_string_t value;
6585 cmdline_fixed_string_t mode;
6589 cmd_set_uc_all_hash_parsed(void *parsed_result,
6590 __attribute__((unused)) struct cmdline *cl,
6591 __attribute__((unused)) void *data)
6594 struct cmd_set_uc_all_hash_table *res = parsed_result;
6596 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6598 if ((strcmp(res->what, "uta") == 0) &&
6599 (strcmp(res->value, "all") == 0))
6600 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6602 printf("bad unicast hash table parameter,"
6603 "return code = %d \n", ret);
6606 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6607 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6609 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6610 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6612 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6613 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6615 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6616 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6618 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6621 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6625 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6626 .f = cmd_set_uc_all_hash_parsed,
6628 .help_str = "set port <port_id> uta all on|off",
6630 (void *)&cmd_set_uc_all_hash_set,
6631 (void *)&cmd_set_uc_all_hash_port,
6632 (void *)&cmd_set_uc_all_hash_portid,
6633 (void *)&cmd_set_uc_all_hash_what,
6634 (void *)&cmd_set_uc_all_hash_value,
6635 (void *)&cmd_set_uc_all_hash_mode,
6640 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6641 struct cmd_set_vf_macvlan_filter {
6642 cmdline_fixed_string_t set;
6643 cmdline_fixed_string_t port;
6645 cmdline_fixed_string_t vf;
6647 struct ether_addr address;
6648 cmdline_fixed_string_t filter_type;
6649 cmdline_fixed_string_t mode;
6653 cmd_set_vf_macvlan_parsed(void *parsed_result,
6654 __attribute__((unused)) struct cmdline *cl,
6655 __attribute__((unused)) void *data)
6658 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6659 struct rte_eth_mac_filter filter;
6661 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6663 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6665 /* set VF MAC filter */
6669 filter.dst_id = res->vf_id;
6671 if (!strcmp(res->filter_type, "exact-mac"))
6672 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6673 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6674 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6675 else if (!strcmp(res->filter_type, "hashmac"))
6676 filter.filter_type = RTE_MAC_HASH_MATCH;
6677 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6678 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6680 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6683 ret = rte_eth_dev_filter_ctrl(res->port_id,
6684 RTE_ETH_FILTER_MACVLAN,
6688 ret = rte_eth_dev_filter_ctrl(res->port_id,
6689 RTE_ETH_FILTER_MACVLAN,
6690 RTE_ETH_FILTER_DELETE,
6694 printf("bad set MAC hash parameter, return code = %d\n", ret);
6698 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6699 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6701 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6704 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6705 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6707 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6708 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6710 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6711 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6713 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6714 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6716 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6717 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6718 filter_type, "exact-mac#exact-mac-vlan"
6719 "#hashmac#hashmac-vlan");
6720 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6721 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6724 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6725 .f = cmd_set_vf_macvlan_parsed,
6727 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6728 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6729 "Exact match rule: exact match of MAC or MAC and VLAN; "
6730 "hash match rule: hash match of MAC and exact match of VLAN",
6732 (void *)&cmd_set_vf_macvlan_set,
6733 (void *)&cmd_set_vf_macvlan_port,
6734 (void *)&cmd_set_vf_macvlan_portid,
6735 (void *)&cmd_set_vf_macvlan_vf,
6736 (void *)&cmd_set_vf_macvlan_vf_id,
6737 (void *)&cmd_set_vf_macvlan_mac,
6738 (void *)&cmd_set_vf_macvlan_filter_type,
6739 (void *)&cmd_set_vf_macvlan_mode,
6744 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6745 struct cmd_set_vf_traffic {
6746 cmdline_fixed_string_t set;
6747 cmdline_fixed_string_t port;
6749 cmdline_fixed_string_t vf;
6751 cmdline_fixed_string_t what;
6752 cmdline_fixed_string_t mode;
6756 cmd_set_vf_traffic_parsed(void *parsed_result,
6757 __attribute__((unused)) struct cmdline *cl,
6758 __attribute__((unused)) void *data)
6760 struct cmd_set_vf_traffic *res = parsed_result;
6761 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6762 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6764 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6767 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6768 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6770 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6771 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6773 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6774 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6776 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6777 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6779 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6780 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6782 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6783 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6785 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6786 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6789 cmdline_parse_inst_t cmd_set_vf_traffic = {
6790 .f = cmd_set_vf_traffic_parsed,
6792 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6794 (void *)&cmd_setvf_traffic_set,
6795 (void *)&cmd_setvf_traffic_port,
6796 (void *)&cmd_setvf_traffic_portid,
6797 (void *)&cmd_setvf_traffic_vf,
6798 (void *)&cmd_setvf_traffic_vfid,
6799 (void *)&cmd_setvf_traffic_what,
6800 (void *)&cmd_setvf_traffic_mode,
6805 /* *** CONFIGURE VF RECEIVE MODE *** */
6806 struct cmd_set_vf_rxmode {
6807 cmdline_fixed_string_t set;
6808 cmdline_fixed_string_t port;
6810 cmdline_fixed_string_t vf;
6812 cmdline_fixed_string_t what;
6813 cmdline_fixed_string_t mode;
6814 cmdline_fixed_string_t on;
6818 cmd_set_vf_rxmode_parsed(void *parsed_result,
6819 __attribute__((unused)) struct cmdline *cl,
6820 __attribute__((unused)) void *data)
6823 uint16_t rx_mode = 0;
6824 struct cmd_set_vf_rxmode *res = parsed_result;
6826 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6827 if (!strcmp(res->what,"rxmode")) {
6828 if (!strcmp(res->mode, "AUPE"))
6829 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6830 else if (!strcmp(res->mode, "ROPE"))
6831 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6832 else if (!strcmp(res->mode, "BAM"))
6833 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6834 else if (!strncmp(res->mode, "MPE",3))
6835 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6838 #ifdef RTE_LIBRTE_IXGBE_PMD
6839 if (ret == -ENOTSUP)
6840 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
6841 rx_mode, (uint8_t)is_on);
6843 #ifdef RTE_LIBRTE_BNXT_PMD
6844 if (ret == -ENOTSUP)
6845 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
6846 rx_mode, (uint8_t)is_on);
6849 printf("bad VF receive mode parameter, return code = %d \n",
6853 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6854 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6856 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6857 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6859 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6860 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6862 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6863 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6865 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6866 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6868 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6869 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6871 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6872 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6873 mode, "AUPE#ROPE#BAM#MPE");
6874 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6875 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6878 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6879 .f = cmd_set_vf_rxmode_parsed,
6881 .help_str = "set port <port_id> vf <vf_id> rxmode "
6882 "AUPE|ROPE|BAM|MPE on|off",
6884 (void *)&cmd_set_vf_rxmode_set,
6885 (void *)&cmd_set_vf_rxmode_port,
6886 (void *)&cmd_set_vf_rxmode_portid,
6887 (void *)&cmd_set_vf_rxmode_vf,
6888 (void *)&cmd_set_vf_rxmode_vfid,
6889 (void *)&cmd_set_vf_rxmode_what,
6890 (void *)&cmd_set_vf_rxmode_mode,
6891 (void *)&cmd_set_vf_rxmode_on,
6896 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6897 struct cmd_vf_mac_addr_result {
6898 cmdline_fixed_string_t mac_addr_cmd;
6899 cmdline_fixed_string_t what;
6900 cmdline_fixed_string_t port;
6902 cmdline_fixed_string_t vf;
6904 struct ether_addr address;
6907 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6908 __attribute__((unused)) struct cmdline *cl,
6909 __attribute__((unused)) void *data)
6911 struct cmd_vf_mac_addr_result *res = parsed_result;
6914 if (strcmp(res->what, "add") == 0)
6915 ret = rte_eth_dev_mac_addr_add(res->port_num,
6916 &res->address, res->vf_num);
6918 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6922 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6923 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6924 mac_addr_cmd,"mac_addr");
6925 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6926 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6928 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6929 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6931 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6932 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6934 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6935 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6937 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6938 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6940 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6941 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6944 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6945 .f = cmd_vf_mac_addr_parsed,
6947 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6948 "Add MAC address filtering for a VF on port_id",
6950 (void *)&cmd_vf_mac_addr_cmd,
6951 (void *)&cmd_vf_mac_addr_what,
6952 (void *)&cmd_vf_mac_addr_port,
6953 (void *)&cmd_vf_mac_addr_portnum,
6954 (void *)&cmd_vf_mac_addr_vf,
6955 (void *)&cmd_vf_mac_addr_vfnum,
6956 (void *)&cmd_vf_mac_addr_addr,
6961 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6962 struct cmd_vf_rx_vlan_filter {
6963 cmdline_fixed_string_t rx_vlan;
6964 cmdline_fixed_string_t what;
6966 cmdline_fixed_string_t port;
6968 cmdline_fixed_string_t vf;
6973 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6974 __attribute__((unused)) struct cmdline *cl,
6975 __attribute__((unused)) void *data)
6977 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6980 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6982 #ifdef RTE_LIBRTE_IXGBE_PMD
6983 if (ret == -ENOTSUP)
6984 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6985 res->vlan_id, res->vf_mask, is_add);
6987 #ifdef RTE_LIBRTE_I40E_PMD
6988 if (ret == -ENOTSUP)
6989 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6990 res->vlan_id, res->vf_mask, is_add);
6992 #ifdef RTE_LIBRTE_BNXT_PMD
6993 if (ret == -ENOTSUP)
6994 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
6995 res->vlan_id, res->vf_mask, is_add);
7002 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7003 res->vlan_id, res->vf_mask);
7006 printf("invalid port_id %d\n", res->port_id);
7009 printf("function not implemented or supported\n");
7012 printf("programming error: (%s)\n", strerror(-ret));
7016 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7017 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7018 rx_vlan, "rx_vlan");
7019 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7020 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7022 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7023 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7025 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7026 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7028 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7029 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7031 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7032 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7034 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7035 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7038 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7039 .f = cmd_vf_rx_vlan_filter_parsed,
7041 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7042 "(vf_mask = hexadecimal VF mask)",
7044 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7045 (void *)&cmd_vf_rx_vlan_filter_what,
7046 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7047 (void *)&cmd_vf_rx_vlan_filter_port,
7048 (void *)&cmd_vf_rx_vlan_filter_portid,
7049 (void *)&cmd_vf_rx_vlan_filter_vf,
7050 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7055 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7056 struct cmd_queue_rate_limit_result {
7057 cmdline_fixed_string_t set;
7058 cmdline_fixed_string_t port;
7060 cmdline_fixed_string_t queue;
7062 cmdline_fixed_string_t rate;
7066 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7067 __attribute__((unused)) struct cmdline *cl,
7068 __attribute__((unused)) void *data)
7070 struct cmd_queue_rate_limit_result *res = parsed_result;
7073 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7074 && (strcmp(res->queue, "queue") == 0)
7075 && (strcmp(res->rate, "rate") == 0))
7076 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7079 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7083 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7084 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7086 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7087 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7089 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7090 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7092 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7093 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7095 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7096 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7098 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7099 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7101 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7102 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7105 cmdline_parse_inst_t cmd_queue_rate_limit = {
7106 .f = cmd_queue_rate_limit_parsed,
7108 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7109 "Set rate limit for a queue on port_id",
7111 (void *)&cmd_queue_rate_limit_set,
7112 (void *)&cmd_queue_rate_limit_port,
7113 (void *)&cmd_queue_rate_limit_portnum,
7114 (void *)&cmd_queue_rate_limit_queue,
7115 (void *)&cmd_queue_rate_limit_queuenum,
7116 (void *)&cmd_queue_rate_limit_rate,
7117 (void *)&cmd_queue_rate_limit_ratenum,
7122 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7123 struct cmd_vf_rate_limit_result {
7124 cmdline_fixed_string_t set;
7125 cmdline_fixed_string_t port;
7127 cmdline_fixed_string_t vf;
7129 cmdline_fixed_string_t rate;
7131 cmdline_fixed_string_t q_msk;
7135 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7136 __attribute__((unused)) struct cmdline *cl,
7137 __attribute__((unused)) void *data)
7139 struct cmd_vf_rate_limit_result *res = parsed_result;
7142 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7143 && (strcmp(res->vf, "vf") == 0)
7144 && (strcmp(res->rate, "rate") == 0)
7145 && (strcmp(res->q_msk, "queue_mask") == 0))
7146 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7147 res->rate_num, res->q_msk_val);
7149 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7153 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7154 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7156 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7157 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7159 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7160 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7162 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7163 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7165 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7166 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7168 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7169 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7171 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7172 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7174 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7175 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7176 q_msk, "queue_mask");
7177 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7178 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7181 cmdline_parse_inst_t cmd_vf_rate_limit = {
7182 .f = cmd_vf_rate_limit_parsed,
7184 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7185 "queue_mask <queue_mask_value>: "
7186 "Set rate limit for queues of VF on port_id",
7188 (void *)&cmd_vf_rate_limit_set,
7189 (void *)&cmd_vf_rate_limit_port,
7190 (void *)&cmd_vf_rate_limit_portnum,
7191 (void *)&cmd_vf_rate_limit_vf,
7192 (void *)&cmd_vf_rate_limit_vfnum,
7193 (void *)&cmd_vf_rate_limit_rate,
7194 (void *)&cmd_vf_rate_limit_ratenum,
7195 (void *)&cmd_vf_rate_limit_q_msk,
7196 (void *)&cmd_vf_rate_limit_q_msk_val,
7201 /* *** ADD TUNNEL FILTER OF A PORT *** */
7202 struct cmd_tunnel_filter_result {
7203 cmdline_fixed_string_t cmd;
7204 cmdline_fixed_string_t what;
7206 struct ether_addr outer_mac;
7207 struct ether_addr inner_mac;
7208 cmdline_ipaddr_t ip_value;
7209 uint16_t inner_vlan;
7210 cmdline_fixed_string_t tunnel_type;
7211 cmdline_fixed_string_t filter_type;
7217 cmd_tunnel_filter_parsed(void *parsed_result,
7218 __attribute__((unused)) struct cmdline *cl,
7219 __attribute__((unused)) void *data)
7221 struct cmd_tunnel_filter_result *res = parsed_result;
7222 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7225 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7227 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7228 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7229 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7231 if (res->ip_value.family == AF_INET) {
7232 tunnel_filter_conf.ip_addr.ipv4_addr =
7233 res->ip_value.addr.ipv4.s_addr;
7234 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7236 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7237 &(res->ip_value.addr.ipv6),
7238 sizeof(struct in6_addr));
7239 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7242 if (!strcmp(res->filter_type, "imac-ivlan"))
7243 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7244 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7245 tunnel_filter_conf.filter_type =
7246 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7247 else if (!strcmp(res->filter_type, "imac-tenid"))
7248 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7249 else if (!strcmp(res->filter_type, "imac"))
7250 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7251 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7252 tunnel_filter_conf.filter_type =
7253 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7254 else if (!strcmp(res->filter_type, "oip"))
7255 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7256 else if (!strcmp(res->filter_type, "iip"))
7257 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7259 printf("The filter type is not supported");
7263 if (!strcmp(res->tunnel_type, "vxlan"))
7264 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7265 else if (!strcmp(res->tunnel_type, "nvgre"))
7266 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7267 else if (!strcmp(res->tunnel_type, "ipingre"))
7268 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7270 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7274 tunnel_filter_conf.tenant_id = res->tenant_id;
7275 tunnel_filter_conf.queue_id = res->queue_num;
7276 if (!strcmp(res->what, "add"))
7277 ret = rte_eth_dev_filter_ctrl(res->port_id,
7278 RTE_ETH_FILTER_TUNNEL,
7280 &tunnel_filter_conf);
7282 ret = rte_eth_dev_filter_ctrl(res->port_id,
7283 RTE_ETH_FILTER_TUNNEL,
7284 RTE_ETH_FILTER_DELETE,
7285 &tunnel_filter_conf);
7287 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7291 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7292 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7293 cmd, "tunnel_filter");
7294 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7295 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7297 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7298 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7300 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7301 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7303 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7304 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7306 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7307 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7308 inner_vlan, UINT16);
7309 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7310 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7312 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7313 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7314 tunnel_type, "vxlan#nvgre#ipingre");
7316 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7317 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7318 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7319 "imac#omac-imac-tenid");
7320 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7321 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7323 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7324 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7327 cmdline_parse_inst_t cmd_tunnel_filter = {
7328 .f = cmd_tunnel_filter_parsed,
7330 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7331 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7332 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7333 "<queue_id>: Add/Rm tunnel filter of a port",
7335 (void *)&cmd_tunnel_filter_cmd,
7336 (void *)&cmd_tunnel_filter_what,
7337 (void *)&cmd_tunnel_filter_port_id,
7338 (void *)&cmd_tunnel_filter_outer_mac,
7339 (void *)&cmd_tunnel_filter_inner_mac,
7340 (void *)&cmd_tunnel_filter_ip_value,
7341 (void *)&cmd_tunnel_filter_innner_vlan,
7342 (void *)&cmd_tunnel_filter_tunnel_type,
7343 (void *)&cmd_tunnel_filter_filter_type,
7344 (void *)&cmd_tunnel_filter_tenant_id,
7345 (void *)&cmd_tunnel_filter_queue_num,
7350 /* *** CONFIGURE TUNNEL UDP PORT *** */
7351 struct cmd_tunnel_udp_config {
7352 cmdline_fixed_string_t cmd;
7353 cmdline_fixed_string_t what;
7359 cmd_tunnel_udp_config_parsed(void *parsed_result,
7360 __attribute__((unused)) struct cmdline *cl,
7361 __attribute__((unused)) void *data)
7363 struct cmd_tunnel_udp_config *res = parsed_result;
7364 struct rte_eth_udp_tunnel tunnel_udp;
7367 tunnel_udp.udp_port = res->udp_port;
7369 if (!strcmp(res->cmd, "rx_vxlan_port"))
7370 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7372 if (!strcmp(res->what, "add"))
7373 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7376 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7380 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7383 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7384 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7385 cmd, "rx_vxlan_port");
7386 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7387 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7389 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7390 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7392 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7393 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7396 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7397 .f = cmd_tunnel_udp_config_parsed,
7399 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7400 "Add/Remove a tunneling UDP port filter",
7402 (void *)&cmd_tunnel_udp_config_cmd,
7403 (void *)&cmd_tunnel_udp_config_what,
7404 (void *)&cmd_tunnel_udp_config_udp_port,
7405 (void *)&cmd_tunnel_udp_config_port_id,
7410 /* *** GLOBAL CONFIG *** */
7411 struct cmd_global_config_result {
7412 cmdline_fixed_string_t cmd;
7414 cmdline_fixed_string_t cfg_type;
7419 cmd_global_config_parsed(void *parsed_result,
7420 __attribute__((unused)) struct cmdline *cl,
7421 __attribute__((unused)) void *data)
7423 struct cmd_global_config_result *res = parsed_result;
7424 struct rte_eth_global_cfg conf;
7427 memset(&conf, 0, sizeof(conf));
7428 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7429 conf.cfg.gre_key_len = res->len;
7430 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7431 RTE_ETH_FILTER_SET, &conf);
7433 printf("Global config error\n");
7436 cmdline_parse_token_string_t cmd_global_config_cmd =
7437 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7439 cmdline_parse_token_num_t cmd_global_config_port_id =
7440 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7441 cmdline_parse_token_string_t cmd_global_config_type =
7442 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7443 cfg_type, "gre-key-len");
7444 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7445 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7448 cmdline_parse_inst_t cmd_global_config = {
7449 .f = cmd_global_config_parsed,
7450 .data = (void *)NULL,
7451 .help_str = "global_config <port_id> gre-key-len <key_len>",
7453 (void *)&cmd_global_config_cmd,
7454 (void *)&cmd_global_config_port_id,
7455 (void *)&cmd_global_config_type,
7456 (void *)&cmd_global_config_gre_key_len,
7461 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7462 struct cmd_set_mirror_mask_result {
7463 cmdline_fixed_string_t set;
7464 cmdline_fixed_string_t port;
7466 cmdline_fixed_string_t mirror;
7468 cmdline_fixed_string_t what;
7469 cmdline_fixed_string_t value;
7470 cmdline_fixed_string_t dstpool;
7472 cmdline_fixed_string_t on;
7475 cmdline_parse_token_string_t cmd_mirror_mask_set =
7476 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7478 cmdline_parse_token_string_t cmd_mirror_mask_port =
7479 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7481 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7482 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7484 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7485 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7486 mirror, "mirror-rule");
7487 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7488 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7490 cmdline_parse_token_string_t cmd_mirror_mask_what =
7491 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7492 what, "pool-mirror-up#pool-mirror-down"
7494 cmdline_parse_token_string_t cmd_mirror_mask_value =
7495 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7497 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7498 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7499 dstpool, "dst-pool");
7500 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7501 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7503 cmdline_parse_token_string_t cmd_mirror_mask_on =
7504 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7508 cmd_set_mirror_mask_parsed(void *parsed_result,
7509 __attribute__((unused)) struct cmdline *cl,
7510 __attribute__((unused)) void *data)
7513 struct cmd_set_mirror_mask_result *res = parsed_result;
7514 struct rte_eth_mirror_conf mr_conf;
7516 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7518 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7520 mr_conf.dst_pool = res->dstpool_id;
7522 if (!strcmp(res->what, "pool-mirror-up")) {
7523 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7524 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7525 } else if (!strcmp(res->what, "pool-mirror-down")) {
7526 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7527 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7528 } else if (!strcmp(res->what, "vlan-mirror")) {
7529 mr_conf.rule_type = ETH_MIRROR_VLAN;
7530 nb_item = parse_item_list(res->value, "vlan",
7531 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7535 for (i = 0; i < nb_item; i++) {
7536 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7537 printf("Invalid vlan_id: must be < 4096\n");
7541 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7542 mr_conf.vlan.vlan_mask |= 1ULL << i;
7546 if (!strcmp(res->on, "on"))
7547 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7550 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7553 printf("mirror rule add error: (%s)\n", strerror(-ret));
7556 cmdline_parse_inst_t cmd_set_mirror_mask = {
7557 .f = cmd_set_mirror_mask_parsed,
7559 .help_str = "set port <port_id> mirror-rule <rule_id> "
7560 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7561 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7563 (void *)&cmd_mirror_mask_set,
7564 (void *)&cmd_mirror_mask_port,
7565 (void *)&cmd_mirror_mask_portid,
7566 (void *)&cmd_mirror_mask_mirror,
7567 (void *)&cmd_mirror_mask_ruleid,
7568 (void *)&cmd_mirror_mask_what,
7569 (void *)&cmd_mirror_mask_value,
7570 (void *)&cmd_mirror_mask_dstpool,
7571 (void *)&cmd_mirror_mask_poolid,
7572 (void *)&cmd_mirror_mask_on,
7577 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7578 struct cmd_set_mirror_link_result {
7579 cmdline_fixed_string_t set;
7580 cmdline_fixed_string_t port;
7582 cmdline_fixed_string_t mirror;
7584 cmdline_fixed_string_t what;
7585 cmdline_fixed_string_t dstpool;
7587 cmdline_fixed_string_t on;
7590 cmdline_parse_token_string_t cmd_mirror_link_set =
7591 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7593 cmdline_parse_token_string_t cmd_mirror_link_port =
7594 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7596 cmdline_parse_token_num_t cmd_mirror_link_portid =
7597 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7599 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7600 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7601 mirror, "mirror-rule");
7602 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7603 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7605 cmdline_parse_token_string_t cmd_mirror_link_what =
7606 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7607 what, "uplink-mirror#downlink-mirror");
7608 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7609 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7610 dstpool, "dst-pool");
7611 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7612 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7614 cmdline_parse_token_string_t cmd_mirror_link_on =
7615 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7619 cmd_set_mirror_link_parsed(void *parsed_result,
7620 __attribute__((unused)) struct cmdline *cl,
7621 __attribute__((unused)) void *data)
7624 struct cmd_set_mirror_link_result *res = parsed_result;
7625 struct rte_eth_mirror_conf mr_conf;
7627 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7628 if (!strcmp(res->what, "uplink-mirror"))
7629 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7631 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7633 mr_conf.dst_pool = res->dstpool_id;
7635 if (!strcmp(res->on, "on"))
7636 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7639 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7642 /* check the return value and print it if is < 0 */
7644 printf("mirror rule add error: (%s)\n", strerror(-ret));
7648 cmdline_parse_inst_t cmd_set_mirror_link = {
7649 .f = cmd_set_mirror_link_parsed,
7651 .help_str = "set port <port_id> mirror-rule <rule_id> "
7652 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7654 (void *)&cmd_mirror_link_set,
7655 (void *)&cmd_mirror_link_port,
7656 (void *)&cmd_mirror_link_portid,
7657 (void *)&cmd_mirror_link_mirror,
7658 (void *)&cmd_mirror_link_ruleid,
7659 (void *)&cmd_mirror_link_what,
7660 (void *)&cmd_mirror_link_dstpool,
7661 (void *)&cmd_mirror_link_poolid,
7662 (void *)&cmd_mirror_link_on,
7667 /* *** RESET VM MIRROR RULE *** */
7668 struct cmd_rm_mirror_rule_result {
7669 cmdline_fixed_string_t reset;
7670 cmdline_fixed_string_t port;
7672 cmdline_fixed_string_t mirror;
7676 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7677 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7679 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7680 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7682 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7683 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7685 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7686 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7687 mirror, "mirror-rule");
7688 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7689 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7693 cmd_reset_mirror_rule_parsed(void *parsed_result,
7694 __attribute__((unused)) struct cmdline *cl,
7695 __attribute__((unused)) void *data)
7698 struct cmd_set_mirror_link_result *res = parsed_result;
7700 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7702 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7705 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7706 .f = cmd_reset_mirror_rule_parsed,
7708 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7710 (void *)&cmd_rm_mirror_rule_reset,
7711 (void *)&cmd_rm_mirror_rule_port,
7712 (void *)&cmd_rm_mirror_rule_portid,
7713 (void *)&cmd_rm_mirror_rule_mirror,
7714 (void *)&cmd_rm_mirror_rule_ruleid,
7719 /* ******************************************************************************** */
7721 struct cmd_dump_result {
7722 cmdline_fixed_string_t dump;
7726 dump_struct_sizes(void)
7728 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7729 DUMP_SIZE(struct rte_mbuf);
7730 DUMP_SIZE(struct rte_mempool);
7731 DUMP_SIZE(struct rte_ring);
7735 static void cmd_dump_parsed(void *parsed_result,
7736 __attribute__((unused)) struct cmdline *cl,
7737 __attribute__((unused)) void *data)
7739 struct cmd_dump_result *res = parsed_result;
7741 if (!strcmp(res->dump, "dump_physmem"))
7742 rte_dump_physmem_layout(stdout);
7743 else if (!strcmp(res->dump, "dump_memzone"))
7744 rte_memzone_dump(stdout);
7745 else if (!strcmp(res->dump, "dump_struct_sizes"))
7746 dump_struct_sizes();
7747 else if (!strcmp(res->dump, "dump_ring"))
7748 rte_ring_list_dump(stdout);
7749 else if (!strcmp(res->dump, "dump_mempool"))
7750 rte_mempool_list_dump(stdout);
7751 else if (!strcmp(res->dump, "dump_devargs"))
7752 rte_eal_devargs_dump(stdout);
7753 else if (!strcmp(res->dump, "dump_log_types"))
7754 rte_log_dump(stdout);
7757 cmdline_parse_token_string_t cmd_dump_dump =
7758 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7761 "dump_struct_sizes#"
7767 cmdline_parse_inst_t cmd_dump = {
7768 .f = cmd_dump_parsed, /* function to call */
7769 .data = NULL, /* 2nd arg of func */
7770 .help_str = "Dump status",
7771 .tokens = { /* token list, NULL terminated */
7772 (void *)&cmd_dump_dump,
7777 /* ******************************************************************************** */
7779 struct cmd_dump_one_result {
7780 cmdline_fixed_string_t dump;
7781 cmdline_fixed_string_t name;
7784 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7785 __attribute__((unused)) void *data)
7787 struct cmd_dump_one_result *res = parsed_result;
7789 if (!strcmp(res->dump, "dump_ring")) {
7791 r = rte_ring_lookup(res->name);
7793 cmdline_printf(cl, "Cannot find ring\n");
7796 rte_ring_dump(stdout, r);
7797 } else if (!strcmp(res->dump, "dump_mempool")) {
7798 struct rte_mempool *mp;
7799 mp = rte_mempool_lookup(res->name);
7801 cmdline_printf(cl, "Cannot find mempool\n");
7804 rte_mempool_dump(stdout, mp);
7808 cmdline_parse_token_string_t cmd_dump_one_dump =
7809 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7810 "dump_ring#dump_mempool");
7812 cmdline_parse_token_string_t cmd_dump_one_name =
7813 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7815 cmdline_parse_inst_t cmd_dump_one = {
7816 .f = cmd_dump_one_parsed, /* function to call */
7817 .data = NULL, /* 2nd arg of func */
7818 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7819 .tokens = { /* token list, NULL terminated */
7820 (void *)&cmd_dump_one_dump,
7821 (void *)&cmd_dump_one_name,
7826 /* *** Add/Del syn filter *** */
7827 struct cmd_syn_filter_result {
7828 cmdline_fixed_string_t filter;
7830 cmdline_fixed_string_t ops;
7831 cmdline_fixed_string_t priority;
7832 cmdline_fixed_string_t high;
7833 cmdline_fixed_string_t queue;
7838 cmd_syn_filter_parsed(void *parsed_result,
7839 __attribute__((unused)) struct cmdline *cl,
7840 __attribute__((unused)) void *data)
7842 struct cmd_syn_filter_result *res = parsed_result;
7843 struct rte_eth_syn_filter syn_filter;
7846 ret = rte_eth_dev_filter_supported(res->port_id,
7847 RTE_ETH_FILTER_SYN);
7849 printf("syn filter is not supported on port %u.\n",
7854 memset(&syn_filter, 0, sizeof(syn_filter));
7856 if (!strcmp(res->ops, "add")) {
7857 if (!strcmp(res->high, "high"))
7858 syn_filter.hig_pri = 1;
7860 syn_filter.hig_pri = 0;
7862 syn_filter.queue = res->queue_id;
7863 ret = rte_eth_dev_filter_ctrl(res->port_id,
7868 ret = rte_eth_dev_filter_ctrl(res->port_id,
7870 RTE_ETH_FILTER_DELETE,
7874 printf("syn filter programming error: (%s)\n",
7878 cmdline_parse_token_string_t cmd_syn_filter_filter =
7879 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7880 filter, "syn_filter");
7881 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7882 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7884 cmdline_parse_token_string_t cmd_syn_filter_ops =
7885 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7887 cmdline_parse_token_string_t cmd_syn_filter_priority =
7888 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7889 priority, "priority");
7890 cmdline_parse_token_string_t cmd_syn_filter_high =
7891 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7893 cmdline_parse_token_string_t cmd_syn_filter_queue =
7894 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7896 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7897 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7900 cmdline_parse_inst_t cmd_syn_filter = {
7901 .f = cmd_syn_filter_parsed,
7903 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7904 "<queue_id>: Add/Delete syn filter",
7906 (void *)&cmd_syn_filter_filter,
7907 (void *)&cmd_syn_filter_port_id,
7908 (void *)&cmd_syn_filter_ops,
7909 (void *)&cmd_syn_filter_priority,
7910 (void *)&cmd_syn_filter_high,
7911 (void *)&cmd_syn_filter_queue,
7912 (void *)&cmd_syn_filter_queue_id,
7917 /* *** ADD/REMOVE A 2tuple FILTER *** */
7918 struct cmd_2tuple_filter_result {
7919 cmdline_fixed_string_t filter;
7921 cmdline_fixed_string_t ops;
7922 cmdline_fixed_string_t dst_port;
7923 uint16_t dst_port_value;
7924 cmdline_fixed_string_t protocol;
7925 uint8_t protocol_value;
7926 cmdline_fixed_string_t mask;
7928 cmdline_fixed_string_t tcp_flags;
7929 uint8_t tcp_flags_value;
7930 cmdline_fixed_string_t priority;
7931 uint8_t priority_value;
7932 cmdline_fixed_string_t queue;
7937 cmd_2tuple_filter_parsed(void *parsed_result,
7938 __attribute__((unused)) struct cmdline *cl,
7939 __attribute__((unused)) void *data)
7941 struct rte_eth_ntuple_filter filter;
7942 struct cmd_2tuple_filter_result *res = parsed_result;
7945 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7947 printf("ntuple filter is not supported on port %u.\n",
7952 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7954 filter.flags = RTE_2TUPLE_FLAGS;
7955 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7956 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7957 filter.proto = res->protocol_value;
7958 filter.priority = res->priority_value;
7959 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7960 printf("nonzero tcp_flags is only meaningful"
7961 " when protocol is TCP.\n");
7964 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7965 printf("invalid TCP flags.\n");
7969 if (res->tcp_flags_value != 0) {
7970 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7971 filter.tcp_flags = res->tcp_flags_value;
7974 /* need convert to big endian. */
7975 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7976 filter.queue = res->queue_id;
7978 if (!strcmp(res->ops, "add"))
7979 ret = rte_eth_dev_filter_ctrl(res->port_id,
7980 RTE_ETH_FILTER_NTUPLE,
7984 ret = rte_eth_dev_filter_ctrl(res->port_id,
7985 RTE_ETH_FILTER_NTUPLE,
7986 RTE_ETH_FILTER_DELETE,
7989 printf("2tuple filter programming error: (%s)\n",
7994 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7995 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7996 filter, "2tuple_filter");
7997 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7998 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8000 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8001 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8003 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8004 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8005 dst_port, "dst_port");
8006 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8007 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8008 dst_port_value, UINT16);
8009 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8010 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8011 protocol, "protocol");
8012 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8013 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8014 protocol_value, UINT8);
8015 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8016 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8018 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8019 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8021 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8022 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8023 tcp_flags, "tcp_flags");
8024 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8025 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8026 tcp_flags_value, UINT8);
8027 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8028 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8029 priority, "priority");
8030 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8031 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8032 priority_value, UINT8);
8033 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8034 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8036 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8037 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8040 cmdline_parse_inst_t cmd_2tuple_filter = {
8041 .f = cmd_2tuple_filter_parsed,
8043 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8044 "<value> mask <value> tcp_flags <value> priority <value> queue "
8045 "<queue_id>: Add a 2tuple filter",
8047 (void *)&cmd_2tuple_filter_filter,
8048 (void *)&cmd_2tuple_filter_port_id,
8049 (void *)&cmd_2tuple_filter_ops,
8050 (void *)&cmd_2tuple_filter_dst_port,
8051 (void *)&cmd_2tuple_filter_dst_port_value,
8052 (void *)&cmd_2tuple_filter_protocol,
8053 (void *)&cmd_2tuple_filter_protocol_value,
8054 (void *)&cmd_2tuple_filter_mask,
8055 (void *)&cmd_2tuple_filter_mask_value,
8056 (void *)&cmd_2tuple_filter_tcp_flags,
8057 (void *)&cmd_2tuple_filter_tcp_flags_value,
8058 (void *)&cmd_2tuple_filter_priority,
8059 (void *)&cmd_2tuple_filter_priority_value,
8060 (void *)&cmd_2tuple_filter_queue,
8061 (void *)&cmd_2tuple_filter_queue_id,
8066 /* *** ADD/REMOVE A 5tuple FILTER *** */
8067 struct cmd_5tuple_filter_result {
8068 cmdline_fixed_string_t filter;
8070 cmdline_fixed_string_t ops;
8071 cmdline_fixed_string_t dst_ip;
8072 cmdline_ipaddr_t dst_ip_value;
8073 cmdline_fixed_string_t src_ip;
8074 cmdline_ipaddr_t src_ip_value;
8075 cmdline_fixed_string_t dst_port;
8076 uint16_t dst_port_value;
8077 cmdline_fixed_string_t src_port;
8078 uint16_t src_port_value;
8079 cmdline_fixed_string_t protocol;
8080 uint8_t protocol_value;
8081 cmdline_fixed_string_t mask;
8083 cmdline_fixed_string_t tcp_flags;
8084 uint8_t tcp_flags_value;
8085 cmdline_fixed_string_t priority;
8086 uint8_t priority_value;
8087 cmdline_fixed_string_t queue;
8092 cmd_5tuple_filter_parsed(void *parsed_result,
8093 __attribute__((unused)) struct cmdline *cl,
8094 __attribute__((unused)) void *data)
8096 struct rte_eth_ntuple_filter filter;
8097 struct cmd_5tuple_filter_result *res = parsed_result;
8100 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8102 printf("ntuple filter is not supported on port %u.\n",
8107 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8109 filter.flags = RTE_5TUPLE_FLAGS;
8110 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8111 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8112 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8113 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8114 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8115 filter.proto = res->protocol_value;
8116 filter.priority = res->priority_value;
8117 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8118 printf("nonzero tcp_flags is only meaningful"
8119 " when protocol is TCP.\n");
8122 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8123 printf("invalid TCP flags.\n");
8127 if (res->tcp_flags_value != 0) {
8128 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8129 filter.tcp_flags = res->tcp_flags_value;
8132 if (res->dst_ip_value.family == AF_INET)
8133 /* no need to convert, already big endian. */
8134 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8136 if (filter.dst_ip_mask == 0) {
8137 printf("can not support ipv6 involved compare.\n");
8143 if (res->src_ip_value.family == AF_INET)
8144 /* no need to convert, already big endian. */
8145 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8147 if (filter.src_ip_mask == 0) {
8148 printf("can not support ipv6 involved compare.\n");
8153 /* need convert to big endian. */
8154 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8155 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8156 filter.queue = res->queue_id;
8158 if (!strcmp(res->ops, "add"))
8159 ret = rte_eth_dev_filter_ctrl(res->port_id,
8160 RTE_ETH_FILTER_NTUPLE,
8164 ret = rte_eth_dev_filter_ctrl(res->port_id,
8165 RTE_ETH_FILTER_NTUPLE,
8166 RTE_ETH_FILTER_DELETE,
8169 printf("5tuple filter programming error: (%s)\n",
8173 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8174 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8175 filter, "5tuple_filter");
8176 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8177 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8179 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8180 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8182 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8183 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8185 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8186 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8188 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8189 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8191 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8192 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8194 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8195 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8196 dst_port, "dst_port");
8197 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8198 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8199 dst_port_value, UINT16);
8200 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8201 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8202 src_port, "src_port");
8203 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8204 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8205 src_port_value, UINT16);
8206 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8207 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8208 protocol, "protocol");
8209 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8210 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8211 protocol_value, UINT8);
8212 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8213 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8215 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8216 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8218 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8219 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8220 tcp_flags, "tcp_flags");
8221 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8222 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8223 tcp_flags_value, UINT8);
8224 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8225 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8226 priority, "priority");
8227 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8228 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8229 priority_value, UINT8);
8230 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8231 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8233 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8234 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8237 cmdline_parse_inst_t cmd_5tuple_filter = {
8238 .f = cmd_5tuple_filter_parsed,
8240 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8241 "src_ip <value> dst_port <value> src_port <value> "
8242 "protocol <value> mask <value> tcp_flags <value> "
8243 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8245 (void *)&cmd_5tuple_filter_filter,
8246 (void *)&cmd_5tuple_filter_port_id,
8247 (void *)&cmd_5tuple_filter_ops,
8248 (void *)&cmd_5tuple_filter_dst_ip,
8249 (void *)&cmd_5tuple_filter_dst_ip_value,
8250 (void *)&cmd_5tuple_filter_src_ip,
8251 (void *)&cmd_5tuple_filter_src_ip_value,
8252 (void *)&cmd_5tuple_filter_dst_port,
8253 (void *)&cmd_5tuple_filter_dst_port_value,
8254 (void *)&cmd_5tuple_filter_src_port,
8255 (void *)&cmd_5tuple_filter_src_port_value,
8256 (void *)&cmd_5tuple_filter_protocol,
8257 (void *)&cmd_5tuple_filter_protocol_value,
8258 (void *)&cmd_5tuple_filter_mask,
8259 (void *)&cmd_5tuple_filter_mask_value,
8260 (void *)&cmd_5tuple_filter_tcp_flags,
8261 (void *)&cmd_5tuple_filter_tcp_flags_value,
8262 (void *)&cmd_5tuple_filter_priority,
8263 (void *)&cmd_5tuple_filter_priority_value,
8264 (void *)&cmd_5tuple_filter_queue,
8265 (void *)&cmd_5tuple_filter_queue_id,
8270 /* *** ADD/REMOVE A flex FILTER *** */
8271 struct cmd_flex_filter_result {
8272 cmdline_fixed_string_t filter;
8273 cmdline_fixed_string_t ops;
8275 cmdline_fixed_string_t len;
8277 cmdline_fixed_string_t bytes;
8278 cmdline_fixed_string_t bytes_value;
8279 cmdline_fixed_string_t mask;
8280 cmdline_fixed_string_t mask_value;
8281 cmdline_fixed_string_t priority;
8282 uint8_t priority_value;
8283 cmdline_fixed_string_t queue;
8287 static int xdigit2val(unsigned char c)
8292 else if (isupper(c))
8300 cmd_flex_filter_parsed(void *parsed_result,
8301 __attribute__((unused)) struct cmdline *cl,
8302 __attribute__((unused)) void *data)
8305 struct rte_eth_flex_filter filter;
8306 struct cmd_flex_filter_result *res = parsed_result;
8307 char *bytes_ptr, *mask_ptr;
8308 uint16_t len, i, j = 0;
8313 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8314 printf("the len exceed the max length 128\n");
8317 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8318 filter.len = res->len_value;
8319 filter.priority = res->priority_value;
8320 filter.queue = res->queue_id;
8321 bytes_ptr = res->bytes_value;
8322 mask_ptr = res->mask_value;
8324 /* translate bytes string to array. */
8325 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8326 (bytes_ptr[1] == 'X')))
8328 len = strnlen(bytes_ptr, res->len_value * 2);
8329 if (len == 0 || (len % 8 != 0)) {
8330 printf("please check len and bytes input\n");
8333 for (i = 0; i < len; i++) {
8335 if (isxdigit(c) == 0) {
8336 /* invalid characters. */
8337 printf("invalid input\n");
8340 val = xdigit2val(c);
8343 filter.bytes[j] = byte;
8344 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8351 /* translate mask string to uint8_t array. */
8352 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8353 (mask_ptr[1] == 'X')))
8355 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8357 printf("invalid input\n");
8362 for (i = 0; i < len; i++) {
8364 if (isxdigit(c) == 0) {
8365 /* invalid characters. */
8366 printf("invalid input\n");
8369 val = xdigit2val(c);
8372 filter.mask[j] = byte;
8373 printf("mask[%d]:%02x ", j, filter.mask[j]);
8381 if (!strcmp(res->ops, "add"))
8382 ret = rte_eth_dev_filter_ctrl(res->port_id,
8383 RTE_ETH_FILTER_FLEXIBLE,
8387 ret = rte_eth_dev_filter_ctrl(res->port_id,
8388 RTE_ETH_FILTER_FLEXIBLE,
8389 RTE_ETH_FILTER_DELETE,
8393 printf("flex filter setting error: (%s)\n", strerror(-ret));
8396 cmdline_parse_token_string_t cmd_flex_filter_filter =
8397 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8398 filter, "flex_filter");
8399 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8400 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8402 cmdline_parse_token_string_t cmd_flex_filter_ops =
8403 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8405 cmdline_parse_token_string_t cmd_flex_filter_len =
8406 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8408 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8409 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8411 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8412 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8414 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8415 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8417 cmdline_parse_token_string_t cmd_flex_filter_mask =
8418 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8420 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8421 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8423 cmdline_parse_token_string_t cmd_flex_filter_priority =
8424 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8425 priority, "priority");
8426 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8427 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8428 priority_value, UINT8);
8429 cmdline_parse_token_string_t cmd_flex_filter_queue =
8430 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8432 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8433 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8435 cmdline_parse_inst_t cmd_flex_filter = {
8436 .f = cmd_flex_filter_parsed,
8438 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8439 "<value> mask <value> priority <value> queue <queue_id>: "
8440 "Add/Del a flex filter",
8442 (void *)&cmd_flex_filter_filter,
8443 (void *)&cmd_flex_filter_port_id,
8444 (void *)&cmd_flex_filter_ops,
8445 (void *)&cmd_flex_filter_len,
8446 (void *)&cmd_flex_filter_len_value,
8447 (void *)&cmd_flex_filter_bytes,
8448 (void *)&cmd_flex_filter_bytes_value,
8449 (void *)&cmd_flex_filter_mask,
8450 (void *)&cmd_flex_filter_mask_value,
8451 (void *)&cmd_flex_filter_priority,
8452 (void *)&cmd_flex_filter_priority_value,
8453 (void *)&cmd_flex_filter_queue,
8454 (void *)&cmd_flex_filter_queue_id,
8459 /* *** Filters Control *** */
8461 /* *** deal with ethertype filter *** */
8462 struct cmd_ethertype_filter_result {
8463 cmdline_fixed_string_t filter;
8465 cmdline_fixed_string_t ops;
8466 cmdline_fixed_string_t mac;
8467 struct ether_addr mac_addr;
8468 cmdline_fixed_string_t ethertype;
8469 uint16_t ethertype_value;
8470 cmdline_fixed_string_t drop;
8471 cmdline_fixed_string_t queue;
8475 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8476 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8477 filter, "ethertype_filter");
8478 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8479 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8481 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8482 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8484 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8485 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8486 mac, "mac_addr#mac_ignr");
8487 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8488 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8490 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8491 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8492 ethertype, "ethertype");
8493 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8494 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8495 ethertype_value, UINT16);
8496 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8497 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8499 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8500 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8502 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8503 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8507 cmd_ethertype_filter_parsed(void *parsed_result,
8508 __attribute__((unused)) struct cmdline *cl,
8509 __attribute__((unused)) void *data)
8511 struct cmd_ethertype_filter_result *res = parsed_result;
8512 struct rte_eth_ethertype_filter filter;
8515 ret = rte_eth_dev_filter_supported(res->port_id,
8516 RTE_ETH_FILTER_ETHERTYPE);
8518 printf("ethertype filter is not supported on port %u.\n",
8523 memset(&filter, 0, sizeof(filter));
8524 if (!strcmp(res->mac, "mac_addr")) {
8525 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8526 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8527 sizeof(struct ether_addr));
8529 if (!strcmp(res->drop, "drop"))
8530 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8531 filter.ether_type = res->ethertype_value;
8532 filter.queue = res->queue_id;
8534 if (!strcmp(res->ops, "add"))
8535 ret = rte_eth_dev_filter_ctrl(res->port_id,
8536 RTE_ETH_FILTER_ETHERTYPE,
8540 ret = rte_eth_dev_filter_ctrl(res->port_id,
8541 RTE_ETH_FILTER_ETHERTYPE,
8542 RTE_ETH_FILTER_DELETE,
8545 printf("ethertype filter programming error: (%s)\n",
8549 cmdline_parse_inst_t cmd_ethertype_filter = {
8550 .f = cmd_ethertype_filter_parsed,
8552 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8553 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8554 "Add or delete an ethertype filter entry",
8556 (void *)&cmd_ethertype_filter_filter,
8557 (void *)&cmd_ethertype_filter_port_id,
8558 (void *)&cmd_ethertype_filter_ops,
8559 (void *)&cmd_ethertype_filter_mac,
8560 (void *)&cmd_ethertype_filter_mac_addr,
8561 (void *)&cmd_ethertype_filter_ethertype,
8562 (void *)&cmd_ethertype_filter_ethertype_value,
8563 (void *)&cmd_ethertype_filter_drop,
8564 (void *)&cmd_ethertype_filter_queue,
8565 (void *)&cmd_ethertype_filter_queue_id,
8570 /* *** deal with flow director filter *** */
8571 struct cmd_flow_director_result {
8572 cmdline_fixed_string_t flow_director_filter;
8574 cmdline_fixed_string_t mode;
8575 cmdline_fixed_string_t mode_value;
8576 cmdline_fixed_string_t ops;
8577 cmdline_fixed_string_t flow;
8578 cmdline_fixed_string_t flow_type;
8579 cmdline_fixed_string_t ether;
8580 uint16_t ether_type;
8581 cmdline_fixed_string_t src;
8582 cmdline_ipaddr_t ip_src;
8584 cmdline_fixed_string_t dst;
8585 cmdline_ipaddr_t ip_dst;
8587 cmdline_fixed_string_t verify_tag;
8588 uint32_t verify_tag_value;
8589 cmdline_ipaddr_t tos;
8591 cmdline_ipaddr_t proto;
8592 uint8_t proto_value;
8593 cmdline_ipaddr_t ttl;
8595 cmdline_fixed_string_t vlan;
8596 uint16_t vlan_value;
8597 cmdline_fixed_string_t flexbytes;
8598 cmdline_fixed_string_t flexbytes_value;
8599 cmdline_fixed_string_t pf_vf;
8600 cmdline_fixed_string_t drop;
8601 cmdline_fixed_string_t queue;
8603 cmdline_fixed_string_t fd_id;
8604 uint32_t fd_id_value;
8605 cmdline_fixed_string_t mac;
8606 struct ether_addr mac_addr;
8607 cmdline_fixed_string_t tunnel;
8608 cmdline_fixed_string_t tunnel_type;
8609 cmdline_fixed_string_t tunnel_id;
8610 uint32_t tunnel_id_value;
8614 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8617 const char *p, *p0 = q_arg;
8619 unsigned long int_fld;
8620 char *str_fld[max_num];
8625 p = strchr(p0, '(');
8629 p0 = strchr(p, ')');
8634 if (size >= sizeof(s))
8637 snprintf(s, sizeof(s), "%.*s", size, p);
8638 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8639 if (ret < 0 || ret > max_num)
8641 for (i = 0; i < ret; i++) {
8643 int_fld = strtoul(str_fld[i], &end, 0);
8644 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8646 flexbytes[i] = (uint8_t)int_fld;
8652 str2flowtype(char *string)
8655 static const struct {
8658 } flowtype_str[] = {
8659 {"raw", RTE_ETH_FLOW_RAW},
8660 {"ipv4", RTE_ETH_FLOW_IPV4},
8661 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8662 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8663 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8664 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8665 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8666 {"ipv6", RTE_ETH_FLOW_IPV6},
8667 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8668 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8669 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8670 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8671 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8672 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8675 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8676 if (!strcmp(flowtype_str[i].str, string))
8677 return flowtype_str[i].type;
8679 return RTE_ETH_FLOW_UNKNOWN;
8682 static enum rte_eth_fdir_tunnel_type
8683 str2fdir_tunneltype(char *string)
8687 static const struct {
8689 enum rte_eth_fdir_tunnel_type type;
8690 } tunneltype_str[] = {
8691 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8692 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8695 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8696 if (!strcmp(tunneltype_str[i].str, string))
8697 return tunneltype_str[i].type;
8699 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8702 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8704 if ((ip_addr).family == AF_INET) \
8705 (ip) = (ip_addr).addr.ipv4.s_addr; \
8707 printf("invalid parameter.\n"); \
8712 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8714 if ((ip_addr).family == AF_INET6) \
8715 (void)rte_memcpy(&(ip), \
8716 &((ip_addr).addr.ipv6), \
8717 sizeof(struct in6_addr)); \
8719 printf("invalid parameter.\n"); \
8725 cmd_flow_director_filter_parsed(void *parsed_result,
8726 __attribute__((unused)) struct cmdline *cl,
8727 __attribute__((unused)) void *data)
8729 struct cmd_flow_director_result *res = parsed_result;
8730 struct rte_eth_fdir_filter entry;
8731 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8733 unsigned long vf_id;
8736 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8738 printf("flow director is not supported on port %u.\n",
8742 memset(flexbytes, 0, sizeof(flexbytes));
8743 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8745 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8746 if (strcmp(res->mode_value, "MAC-VLAN")) {
8747 printf("Please set mode to MAC-VLAN.\n");
8750 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8751 if (strcmp(res->mode_value, "Tunnel")) {
8752 printf("Please set mode to Tunnel.\n");
8756 if (strcmp(res->mode_value, "IP")) {
8757 printf("Please set mode to IP.\n");
8760 entry.input.flow_type = str2flowtype(res->flow_type);
8763 ret = parse_flexbytes(res->flexbytes_value,
8765 RTE_ETH_FDIR_MAX_FLEXLEN);
8767 printf("error: Cannot parse flexbytes input.\n");
8771 switch (entry.input.flow_type) {
8772 case RTE_ETH_FLOW_FRAG_IPV4:
8773 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8774 entry.input.flow.ip4_flow.proto = res->proto_value;
8776 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8777 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8778 IPV4_ADDR_TO_UINT(res->ip_dst,
8779 entry.input.flow.ip4_flow.dst_ip);
8780 IPV4_ADDR_TO_UINT(res->ip_src,
8781 entry.input.flow.ip4_flow.src_ip);
8782 entry.input.flow.ip4_flow.tos = res->tos_value;
8783 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8784 /* need convert to big endian. */
8785 entry.input.flow.udp4_flow.dst_port =
8786 rte_cpu_to_be_16(res->port_dst);
8787 entry.input.flow.udp4_flow.src_port =
8788 rte_cpu_to_be_16(res->port_src);
8790 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8791 IPV4_ADDR_TO_UINT(res->ip_dst,
8792 entry.input.flow.sctp4_flow.ip.dst_ip);
8793 IPV4_ADDR_TO_UINT(res->ip_src,
8794 entry.input.flow.sctp4_flow.ip.src_ip);
8795 entry.input.flow.ip4_flow.tos = res->tos_value;
8796 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8797 /* need convert to big endian. */
8798 entry.input.flow.sctp4_flow.dst_port =
8799 rte_cpu_to_be_16(res->port_dst);
8800 entry.input.flow.sctp4_flow.src_port =
8801 rte_cpu_to_be_16(res->port_src);
8802 entry.input.flow.sctp4_flow.verify_tag =
8803 rte_cpu_to_be_32(res->verify_tag_value);
8805 case RTE_ETH_FLOW_FRAG_IPV6:
8806 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8807 entry.input.flow.ipv6_flow.proto = res->proto_value;
8809 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8810 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8811 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8812 entry.input.flow.ipv6_flow.dst_ip);
8813 IPV6_ADDR_TO_ARRAY(res->ip_src,
8814 entry.input.flow.ipv6_flow.src_ip);
8815 entry.input.flow.ipv6_flow.tc = res->tos_value;
8816 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8817 /* need convert to big endian. */
8818 entry.input.flow.udp6_flow.dst_port =
8819 rte_cpu_to_be_16(res->port_dst);
8820 entry.input.flow.udp6_flow.src_port =
8821 rte_cpu_to_be_16(res->port_src);
8823 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8824 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8825 entry.input.flow.sctp6_flow.ip.dst_ip);
8826 IPV6_ADDR_TO_ARRAY(res->ip_src,
8827 entry.input.flow.sctp6_flow.ip.src_ip);
8828 entry.input.flow.ipv6_flow.tc = res->tos_value;
8829 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8830 /* need convert to big endian. */
8831 entry.input.flow.sctp6_flow.dst_port =
8832 rte_cpu_to_be_16(res->port_dst);
8833 entry.input.flow.sctp6_flow.src_port =
8834 rte_cpu_to_be_16(res->port_src);
8835 entry.input.flow.sctp6_flow.verify_tag =
8836 rte_cpu_to_be_32(res->verify_tag_value);
8838 case RTE_ETH_FLOW_L2_PAYLOAD:
8839 entry.input.flow.l2_flow.ether_type =
8840 rte_cpu_to_be_16(res->ether_type);
8846 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8847 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8849 sizeof(struct ether_addr));
8851 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8852 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8854 sizeof(struct ether_addr));
8855 entry.input.flow.tunnel_flow.tunnel_type =
8856 str2fdir_tunneltype(res->tunnel_type);
8857 entry.input.flow.tunnel_flow.tunnel_id =
8858 rte_cpu_to_be_32(res->tunnel_id_value);
8861 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8863 RTE_ETH_FDIR_MAX_FLEXLEN);
8865 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8867 entry.action.flex_off = 0; /*use 0 by default */
8868 if (!strcmp(res->drop, "drop"))
8869 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8871 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8873 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8874 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8875 if (!strcmp(res->pf_vf, "pf"))
8876 entry.input.flow_ext.is_vf = 0;
8877 else if (!strncmp(res->pf_vf, "vf", 2)) {
8878 struct rte_eth_dev_info dev_info;
8880 memset(&dev_info, 0, sizeof(dev_info));
8881 rte_eth_dev_info_get(res->port_id, &dev_info);
8883 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8884 if (errno != 0 || *end != '\0' ||
8885 vf_id >= dev_info.max_vfs) {
8886 printf("invalid parameter %s.\n", res->pf_vf);
8889 entry.input.flow_ext.is_vf = 1;
8890 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8892 printf("invalid parameter %s.\n", res->pf_vf);
8897 /* set to report FD ID by default */
8898 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8899 entry.action.rx_queue = res->queue_id;
8900 entry.soft_id = res->fd_id_value;
8901 if (!strcmp(res->ops, "add"))
8902 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8903 RTE_ETH_FILTER_ADD, &entry);
8904 else if (!strcmp(res->ops, "del"))
8905 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8906 RTE_ETH_FILTER_DELETE, &entry);
8908 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8909 RTE_ETH_FILTER_UPDATE, &entry);
8911 printf("flow director programming error: (%s)\n",
8915 cmdline_parse_token_string_t cmd_flow_director_filter =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8917 flow_director_filter, "flow_director_filter");
8918 cmdline_parse_token_num_t cmd_flow_director_port_id =
8919 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8921 cmdline_parse_token_string_t cmd_flow_director_ops =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8923 ops, "add#del#update");
8924 cmdline_parse_token_string_t cmd_flow_director_flow =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8927 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8929 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8930 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8931 cmdline_parse_token_string_t cmd_flow_director_ether =
8932 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8934 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8935 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8936 ether_type, UINT16);
8937 cmdline_parse_token_string_t cmd_flow_director_src =
8938 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8940 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8941 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8943 cmdline_parse_token_num_t cmd_flow_director_port_src =
8944 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8946 cmdline_parse_token_string_t cmd_flow_director_dst =
8947 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8949 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8950 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8952 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8953 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8955 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8957 verify_tag, "verify_tag");
8958 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8959 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8960 verify_tag_value, UINT32);
8961 cmdline_parse_token_string_t cmd_flow_director_tos =
8962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8964 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8965 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8967 cmdline_parse_token_string_t cmd_flow_director_proto =
8968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8970 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8971 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8972 proto_value, UINT8);
8973 cmdline_parse_token_string_t cmd_flow_director_ttl =
8974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8976 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8977 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8979 cmdline_parse_token_string_t cmd_flow_director_vlan =
8980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8982 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8983 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8984 vlan_value, UINT16);
8985 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8986 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8987 flexbytes, "flexbytes");
8988 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8990 flexbytes_value, NULL);
8991 cmdline_parse_token_string_t cmd_flow_director_drop =
8992 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8994 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8995 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8997 cmdline_parse_token_string_t cmd_flow_director_queue =
8998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9000 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9001 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9003 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9004 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9006 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9007 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9008 fd_id_value, UINT32);
9010 cmdline_parse_token_string_t cmd_flow_director_mode =
9011 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9013 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9014 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9016 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9017 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9018 mode_value, "MAC-VLAN");
9019 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9020 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9021 mode_value, "Tunnel");
9022 cmdline_parse_token_string_t cmd_flow_director_mac =
9023 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9025 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9026 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9028 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9029 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9031 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9032 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9033 tunnel_type, "NVGRE#VxLAN");
9034 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9035 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9036 tunnel_id, "tunnel-id");
9037 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9038 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9039 tunnel_id_value, UINT32);
9041 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9042 .f = cmd_flow_director_filter_parsed,
9044 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9045 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9046 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9047 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9048 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9049 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9050 "fd_id <fd_id_value>: "
9051 "Add or delete an ip flow director entry on NIC",
9053 (void *)&cmd_flow_director_filter,
9054 (void *)&cmd_flow_director_port_id,
9055 (void *)&cmd_flow_director_mode,
9056 (void *)&cmd_flow_director_mode_ip,
9057 (void *)&cmd_flow_director_ops,
9058 (void *)&cmd_flow_director_flow,
9059 (void *)&cmd_flow_director_flow_type,
9060 (void *)&cmd_flow_director_src,
9061 (void *)&cmd_flow_director_ip_src,
9062 (void *)&cmd_flow_director_dst,
9063 (void *)&cmd_flow_director_ip_dst,
9064 (void *)&cmd_flow_director_tos,
9065 (void *)&cmd_flow_director_tos_value,
9066 (void *)&cmd_flow_director_proto,
9067 (void *)&cmd_flow_director_proto_value,
9068 (void *)&cmd_flow_director_ttl,
9069 (void *)&cmd_flow_director_ttl_value,
9070 (void *)&cmd_flow_director_vlan,
9071 (void *)&cmd_flow_director_vlan_value,
9072 (void *)&cmd_flow_director_flexbytes,
9073 (void *)&cmd_flow_director_flexbytes_value,
9074 (void *)&cmd_flow_director_drop,
9075 (void *)&cmd_flow_director_pf_vf,
9076 (void *)&cmd_flow_director_queue,
9077 (void *)&cmd_flow_director_queue_id,
9078 (void *)&cmd_flow_director_fd_id,
9079 (void *)&cmd_flow_director_fd_id_value,
9084 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9085 .f = cmd_flow_director_filter_parsed,
9087 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9088 "director entry on NIC",
9090 (void *)&cmd_flow_director_filter,
9091 (void *)&cmd_flow_director_port_id,
9092 (void *)&cmd_flow_director_mode,
9093 (void *)&cmd_flow_director_mode_ip,
9094 (void *)&cmd_flow_director_ops,
9095 (void *)&cmd_flow_director_flow,
9096 (void *)&cmd_flow_director_flow_type,
9097 (void *)&cmd_flow_director_src,
9098 (void *)&cmd_flow_director_ip_src,
9099 (void *)&cmd_flow_director_port_src,
9100 (void *)&cmd_flow_director_dst,
9101 (void *)&cmd_flow_director_ip_dst,
9102 (void *)&cmd_flow_director_port_dst,
9103 (void *)&cmd_flow_director_tos,
9104 (void *)&cmd_flow_director_tos_value,
9105 (void *)&cmd_flow_director_ttl,
9106 (void *)&cmd_flow_director_ttl_value,
9107 (void *)&cmd_flow_director_vlan,
9108 (void *)&cmd_flow_director_vlan_value,
9109 (void *)&cmd_flow_director_flexbytes,
9110 (void *)&cmd_flow_director_flexbytes_value,
9111 (void *)&cmd_flow_director_drop,
9112 (void *)&cmd_flow_director_pf_vf,
9113 (void *)&cmd_flow_director_queue,
9114 (void *)&cmd_flow_director_queue_id,
9115 (void *)&cmd_flow_director_fd_id,
9116 (void *)&cmd_flow_director_fd_id_value,
9121 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9122 .f = cmd_flow_director_filter_parsed,
9124 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9125 "director entry on NIC",
9127 (void *)&cmd_flow_director_filter,
9128 (void *)&cmd_flow_director_port_id,
9129 (void *)&cmd_flow_director_mode,
9130 (void *)&cmd_flow_director_mode_ip,
9131 (void *)&cmd_flow_director_ops,
9132 (void *)&cmd_flow_director_flow,
9133 (void *)&cmd_flow_director_flow_type,
9134 (void *)&cmd_flow_director_src,
9135 (void *)&cmd_flow_director_ip_src,
9136 (void *)&cmd_flow_director_port_dst,
9137 (void *)&cmd_flow_director_dst,
9138 (void *)&cmd_flow_director_ip_dst,
9139 (void *)&cmd_flow_director_port_dst,
9140 (void *)&cmd_flow_director_verify_tag,
9141 (void *)&cmd_flow_director_verify_tag_value,
9142 (void *)&cmd_flow_director_tos,
9143 (void *)&cmd_flow_director_tos_value,
9144 (void *)&cmd_flow_director_ttl,
9145 (void *)&cmd_flow_director_ttl_value,
9146 (void *)&cmd_flow_director_vlan,
9147 (void *)&cmd_flow_director_vlan_value,
9148 (void *)&cmd_flow_director_flexbytes,
9149 (void *)&cmd_flow_director_flexbytes_value,
9150 (void *)&cmd_flow_director_drop,
9151 (void *)&cmd_flow_director_pf_vf,
9152 (void *)&cmd_flow_director_queue,
9153 (void *)&cmd_flow_director_queue_id,
9154 (void *)&cmd_flow_director_fd_id,
9155 (void *)&cmd_flow_director_fd_id_value,
9160 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9161 .f = cmd_flow_director_filter_parsed,
9163 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9164 "director entry on NIC",
9166 (void *)&cmd_flow_director_filter,
9167 (void *)&cmd_flow_director_port_id,
9168 (void *)&cmd_flow_director_mode,
9169 (void *)&cmd_flow_director_mode_ip,
9170 (void *)&cmd_flow_director_ops,
9171 (void *)&cmd_flow_director_flow,
9172 (void *)&cmd_flow_director_flow_type,
9173 (void *)&cmd_flow_director_ether,
9174 (void *)&cmd_flow_director_ether_type,
9175 (void *)&cmd_flow_director_flexbytes,
9176 (void *)&cmd_flow_director_flexbytes_value,
9177 (void *)&cmd_flow_director_drop,
9178 (void *)&cmd_flow_director_pf_vf,
9179 (void *)&cmd_flow_director_queue,
9180 (void *)&cmd_flow_director_queue_id,
9181 (void *)&cmd_flow_director_fd_id,
9182 (void *)&cmd_flow_director_fd_id_value,
9187 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9188 .f = cmd_flow_director_filter_parsed,
9190 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9191 "director entry on NIC",
9193 (void *)&cmd_flow_director_filter,
9194 (void *)&cmd_flow_director_port_id,
9195 (void *)&cmd_flow_director_mode,
9196 (void *)&cmd_flow_director_mode_mac_vlan,
9197 (void *)&cmd_flow_director_ops,
9198 (void *)&cmd_flow_director_mac,
9199 (void *)&cmd_flow_director_mac_addr,
9200 (void *)&cmd_flow_director_vlan,
9201 (void *)&cmd_flow_director_vlan_value,
9202 (void *)&cmd_flow_director_flexbytes,
9203 (void *)&cmd_flow_director_flexbytes_value,
9204 (void *)&cmd_flow_director_drop,
9205 (void *)&cmd_flow_director_queue,
9206 (void *)&cmd_flow_director_queue_id,
9207 (void *)&cmd_flow_director_fd_id,
9208 (void *)&cmd_flow_director_fd_id_value,
9213 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9214 .f = cmd_flow_director_filter_parsed,
9216 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9217 "director entry on NIC",
9219 (void *)&cmd_flow_director_filter,
9220 (void *)&cmd_flow_director_port_id,
9221 (void *)&cmd_flow_director_mode,
9222 (void *)&cmd_flow_director_mode_tunnel,
9223 (void *)&cmd_flow_director_ops,
9224 (void *)&cmd_flow_director_mac,
9225 (void *)&cmd_flow_director_mac_addr,
9226 (void *)&cmd_flow_director_vlan,
9227 (void *)&cmd_flow_director_vlan_value,
9228 (void *)&cmd_flow_director_tunnel,
9229 (void *)&cmd_flow_director_tunnel_type,
9230 (void *)&cmd_flow_director_tunnel_id,
9231 (void *)&cmd_flow_director_tunnel_id_value,
9232 (void *)&cmd_flow_director_flexbytes,
9233 (void *)&cmd_flow_director_flexbytes_value,
9234 (void *)&cmd_flow_director_drop,
9235 (void *)&cmd_flow_director_queue,
9236 (void *)&cmd_flow_director_queue_id,
9237 (void *)&cmd_flow_director_fd_id,
9238 (void *)&cmd_flow_director_fd_id_value,
9243 struct cmd_flush_flow_director_result {
9244 cmdline_fixed_string_t flush_flow_director;
9248 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9249 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9250 flush_flow_director, "flush_flow_director");
9251 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9252 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9256 cmd_flush_flow_director_parsed(void *parsed_result,
9257 __attribute__((unused)) struct cmdline *cl,
9258 __attribute__((unused)) void *data)
9260 struct cmd_flow_director_result *res = parsed_result;
9263 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9265 printf("flow director is not supported on port %u.\n",
9270 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9271 RTE_ETH_FILTER_FLUSH, NULL);
9273 printf("flow director table flushing error: (%s)\n",
9277 cmdline_parse_inst_t cmd_flush_flow_director = {
9278 .f = cmd_flush_flow_director_parsed,
9280 .help_str = "flush_flow_director <port_id>: "
9281 "Flush all flow director entries of a device on NIC",
9283 (void *)&cmd_flush_flow_director_flush,
9284 (void *)&cmd_flush_flow_director_port_id,
9289 /* *** deal with flow director mask *** */
9290 struct cmd_flow_director_mask_result {
9291 cmdline_fixed_string_t flow_director_mask;
9293 cmdline_fixed_string_t mode;
9294 cmdline_fixed_string_t mode_value;
9295 cmdline_fixed_string_t vlan;
9297 cmdline_fixed_string_t src_mask;
9298 cmdline_ipaddr_t ipv4_src;
9299 cmdline_ipaddr_t ipv6_src;
9301 cmdline_fixed_string_t dst_mask;
9302 cmdline_ipaddr_t ipv4_dst;
9303 cmdline_ipaddr_t ipv6_dst;
9305 cmdline_fixed_string_t mac;
9306 uint8_t mac_addr_byte_mask;
9307 cmdline_fixed_string_t tunnel_id;
9308 uint32_t tunnel_id_mask;
9309 cmdline_fixed_string_t tunnel_type;
9310 uint8_t tunnel_type_mask;
9314 cmd_flow_director_mask_parsed(void *parsed_result,
9315 __attribute__((unused)) struct cmdline *cl,
9316 __attribute__((unused)) void *data)
9318 struct cmd_flow_director_mask_result *res = parsed_result;
9319 struct rte_eth_fdir_masks *mask;
9320 struct rte_port *port;
9322 if (res->port_id > nb_ports) {
9323 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9327 port = &ports[res->port_id];
9328 /** Check if the port is not started **/
9329 if (port->port_status != RTE_PORT_STOPPED) {
9330 printf("Please stop port %d first\n", res->port_id);
9334 mask = &port->dev_conf.fdir_conf.mask;
9336 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9337 if (strcmp(res->mode_value, "MAC-VLAN")) {
9338 printf("Please set mode to MAC-VLAN.\n");
9342 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9343 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9344 if (strcmp(res->mode_value, "Tunnel")) {
9345 printf("Please set mode to Tunnel.\n");
9349 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9350 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9351 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9352 mask->tunnel_type_mask = res->tunnel_type_mask;
9354 if (strcmp(res->mode_value, "IP")) {
9355 printf("Please set mode to IP.\n");
9359 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9360 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9361 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9362 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9363 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9364 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9365 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9368 cmd_reconfig_device_queue(res->port_id, 1, 1);
9371 cmdline_parse_token_string_t cmd_flow_director_mask =
9372 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9373 flow_director_mask, "flow_director_mask");
9374 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9375 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9377 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9378 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9380 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9381 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9383 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9385 src_mask, "src_mask");
9386 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9387 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9389 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9390 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9392 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9393 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9395 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9397 dst_mask, "dst_mask");
9398 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9399 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9401 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9402 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9404 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9405 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9408 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9409 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9411 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9414 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9416 mode_value, "MAC-VLAN");
9417 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9419 mode_value, "Tunnel");
9420 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9423 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9424 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9425 mac_addr_byte_mask, UINT8);
9426 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9427 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9428 tunnel_type, "tunnel-type");
9429 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9430 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9431 tunnel_type_mask, UINT8);
9432 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9434 tunnel_id, "tunnel-id");
9435 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9436 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9437 tunnel_id_mask, UINT32);
9439 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9440 .f = cmd_flow_director_mask_parsed,
9442 .help_str = "flow_director_mask ... : "
9443 "Set IP mode flow director's mask on NIC",
9445 (void *)&cmd_flow_director_mask,
9446 (void *)&cmd_flow_director_mask_port_id,
9447 (void *)&cmd_flow_director_mask_mode,
9448 (void *)&cmd_flow_director_mask_mode_ip,
9449 (void *)&cmd_flow_director_mask_vlan,
9450 (void *)&cmd_flow_director_mask_vlan_value,
9451 (void *)&cmd_flow_director_mask_src,
9452 (void *)&cmd_flow_director_mask_ipv4_src,
9453 (void *)&cmd_flow_director_mask_ipv6_src,
9454 (void *)&cmd_flow_director_mask_port_src,
9455 (void *)&cmd_flow_director_mask_dst,
9456 (void *)&cmd_flow_director_mask_ipv4_dst,
9457 (void *)&cmd_flow_director_mask_ipv6_dst,
9458 (void *)&cmd_flow_director_mask_port_dst,
9463 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9464 .f = cmd_flow_director_mask_parsed,
9466 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9467 "flow director's mask on NIC",
9469 (void *)&cmd_flow_director_mask,
9470 (void *)&cmd_flow_director_mask_port_id,
9471 (void *)&cmd_flow_director_mask_mode,
9472 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9473 (void *)&cmd_flow_director_mask_vlan,
9474 (void *)&cmd_flow_director_mask_vlan_value,
9479 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9480 .f = cmd_flow_director_mask_parsed,
9482 .help_str = "flow_director_mask ... : Set tunnel mode "
9483 "flow director's mask on NIC",
9485 (void *)&cmd_flow_director_mask,
9486 (void *)&cmd_flow_director_mask_port_id,
9487 (void *)&cmd_flow_director_mask_mode,
9488 (void *)&cmd_flow_director_mask_mode_tunnel,
9489 (void *)&cmd_flow_director_mask_vlan,
9490 (void *)&cmd_flow_director_mask_vlan_value,
9491 (void *)&cmd_flow_director_mask_mac,
9492 (void *)&cmd_flow_director_mask_mac_value,
9493 (void *)&cmd_flow_director_mask_tunnel_type,
9494 (void *)&cmd_flow_director_mask_tunnel_type_value,
9495 (void *)&cmd_flow_director_mask_tunnel_id,
9496 (void *)&cmd_flow_director_mask_tunnel_id_value,
9501 /* *** deal with flow director mask on flexible payload *** */
9502 struct cmd_flow_director_flex_mask_result {
9503 cmdline_fixed_string_t flow_director_flexmask;
9505 cmdline_fixed_string_t flow;
9506 cmdline_fixed_string_t flow_type;
9507 cmdline_fixed_string_t mask;
9511 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9512 __attribute__((unused)) struct cmdline *cl,
9513 __attribute__((unused)) void *data)
9515 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9516 struct rte_eth_fdir_info fdir_info;
9517 struct rte_eth_fdir_flex_mask flex_mask;
9518 struct rte_port *port;
9519 uint32_t flow_type_mask;
9523 if (res->port_id > nb_ports) {
9524 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9528 port = &ports[res->port_id];
9529 /** Check if the port is not started **/
9530 if (port->port_status != RTE_PORT_STOPPED) {
9531 printf("Please stop port %d first\n", res->port_id);
9535 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9536 ret = parse_flexbytes(res->mask,
9538 RTE_ETH_FDIR_MAX_FLEXLEN);
9540 printf("error: Cannot parse mask input.\n");
9544 memset(&fdir_info, 0, sizeof(fdir_info));
9545 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9546 RTE_ETH_FILTER_INFO, &fdir_info);
9548 printf("Cannot get FDir filter info\n");
9552 if (!strcmp(res->flow_type, "none")) {
9553 /* means don't specify the flow type */
9554 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9555 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9556 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9557 0, sizeof(struct rte_eth_fdir_flex_mask));
9558 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9559 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9561 sizeof(struct rte_eth_fdir_flex_mask));
9562 cmd_reconfig_device_queue(res->port_id, 1, 1);
9565 flow_type_mask = fdir_info.flow_types_mask[0];
9566 if (!strcmp(res->flow_type, "all")) {
9567 if (!flow_type_mask) {
9568 printf("No flow type supported\n");
9571 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9572 if (flow_type_mask & (1 << i)) {
9573 flex_mask.flow_type = i;
9574 fdir_set_flex_mask(res->port_id, &flex_mask);
9577 cmd_reconfig_device_queue(res->port_id, 1, 1);
9580 flex_mask.flow_type = str2flowtype(res->flow_type);
9581 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9582 printf("Flow type %s not supported on port %d\n",
9583 res->flow_type, res->port_id);
9586 fdir_set_flex_mask(res->port_id, &flex_mask);
9587 cmd_reconfig_device_queue(res->port_id, 1, 1);
9590 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9592 flow_director_flexmask,
9593 "flow_director_flex_mask");
9594 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9595 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9597 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9598 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9600 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9601 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9602 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9603 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9604 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9608 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9609 .f = cmd_flow_director_flex_mask_parsed,
9611 .help_str = "flow_director_flex_mask ... : "
9612 "Set flow director's flex mask on NIC",
9614 (void *)&cmd_flow_director_flexmask,
9615 (void *)&cmd_flow_director_flexmask_port_id,
9616 (void *)&cmd_flow_director_flexmask_flow,
9617 (void *)&cmd_flow_director_flexmask_flow_type,
9618 (void *)&cmd_flow_director_flexmask_mask,
9623 /* *** deal with flow director flexible payload configuration *** */
9624 struct cmd_flow_director_flexpayload_result {
9625 cmdline_fixed_string_t flow_director_flexpayload;
9627 cmdline_fixed_string_t payload_layer;
9628 cmdline_fixed_string_t payload_cfg;
9632 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9635 const char *p, *p0 = q_arg;
9637 unsigned long int_fld;
9638 char *str_fld[max_num];
9643 p = strchr(p0, '(');
9647 p0 = strchr(p, ')');
9652 if (size >= sizeof(s))
9655 snprintf(s, sizeof(s), "%.*s", size, p);
9656 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9657 if (ret < 0 || ret > max_num)
9659 for (i = 0; i < ret; i++) {
9661 int_fld = strtoul(str_fld[i], &end, 0);
9662 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9664 offsets[i] = (uint16_t)int_fld;
9670 cmd_flow_director_flxpld_parsed(void *parsed_result,
9671 __attribute__((unused)) struct cmdline *cl,
9672 __attribute__((unused)) void *data)
9674 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9675 struct rte_eth_flex_payload_cfg flex_cfg;
9676 struct rte_port *port;
9679 if (res->port_id > nb_ports) {
9680 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9684 port = &ports[res->port_id];
9685 /** Check if the port is not started **/
9686 if (port->port_status != RTE_PORT_STOPPED) {
9687 printf("Please stop port %d first\n", res->port_id);
9691 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9693 if (!strcmp(res->payload_layer, "raw"))
9694 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9695 else if (!strcmp(res->payload_layer, "l2"))
9696 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9697 else if (!strcmp(res->payload_layer, "l3"))
9698 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9699 else if (!strcmp(res->payload_layer, "l4"))
9700 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9702 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9703 RTE_ETH_FDIR_MAX_FLEXLEN);
9705 printf("error: Cannot parse flex payload input.\n");
9709 fdir_set_flex_payload(res->port_id, &flex_cfg);
9710 cmd_reconfig_device_queue(res->port_id, 1, 1);
9713 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9714 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9715 flow_director_flexpayload,
9716 "flow_director_flex_payload");
9717 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9718 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9720 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9721 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9722 payload_layer, "raw#l2#l3#l4");
9723 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9727 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9728 .f = cmd_flow_director_flxpld_parsed,
9730 .help_str = "flow_director_flexpayload ... : "
9731 "Set flow director's flex payload on NIC",
9733 (void *)&cmd_flow_director_flexpayload,
9734 (void *)&cmd_flow_director_flexpayload_port_id,
9735 (void *)&cmd_flow_director_flexpayload_payload_layer,
9736 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9741 /* Generic flow interface command. */
9742 extern cmdline_parse_inst_t cmd_flow;
9744 /* *** Classification Filters Control *** */
9745 /* *** Get symmetric hash enable per port *** */
9746 struct cmd_get_sym_hash_ena_per_port_result {
9747 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9752 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9753 __rte_unused struct cmdline *cl,
9754 __rte_unused void *data)
9756 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9757 struct rte_eth_hash_filter_info info;
9760 if (rte_eth_dev_filter_supported(res->port_id,
9761 RTE_ETH_FILTER_HASH) < 0) {
9762 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9767 memset(&info, 0, sizeof(info));
9768 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9769 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9770 RTE_ETH_FILTER_GET, &info);
9773 printf("Cannot get symmetric hash enable per port "
9774 "on port %u\n", res->port_id);
9778 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9779 "enabled" : "disabled", res->port_id);
9782 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9783 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9784 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9785 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9786 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9789 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9790 .f = cmd_get_sym_hash_per_port_parsed,
9792 .help_str = "get_sym_hash_ena_per_port <port_id>",
9794 (void *)&cmd_get_sym_hash_ena_per_port_all,
9795 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9800 /* *** Set symmetric hash enable per port *** */
9801 struct cmd_set_sym_hash_ena_per_port_result {
9802 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9803 cmdline_fixed_string_t enable;
9808 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9809 __rte_unused struct cmdline *cl,
9810 __rte_unused void *data)
9812 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9813 struct rte_eth_hash_filter_info info;
9816 if (rte_eth_dev_filter_supported(res->port_id,
9817 RTE_ETH_FILTER_HASH) < 0) {
9818 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9823 memset(&info, 0, sizeof(info));
9824 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9825 if (!strcmp(res->enable, "enable"))
9826 info.info.enable = 1;
9827 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9828 RTE_ETH_FILTER_SET, &info);
9830 printf("Cannot set symmetric hash enable per port on "
9831 "port %u\n", res->port_id);
9834 printf("Symmetric hash has been set to %s on port %u\n",
9835 res->enable, res->port_id);
9838 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9839 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9840 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9841 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9842 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9844 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9845 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9846 enable, "enable#disable");
9848 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9849 .f = cmd_set_sym_hash_per_port_parsed,
9851 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9853 (void *)&cmd_set_sym_hash_ena_per_port_all,
9854 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9855 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9860 /* Get global config of hash function */
9861 struct cmd_get_hash_global_config_result {
9862 cmdline_fixed_string_t get_hash_global_config;
9867 flowtype_to_str(uint16_t ftype)
9874 {"ipv4", RTE_ETH_FLOW_IPV4},
9875 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9876 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9877 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9878 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9879 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9880 {"ipv6", RTE_ETH_FLOW_IPV6},
9881 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9882 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9883 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9884 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9885 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9886 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9887 {"port", RTE_ETH_FLOW_PORT},
9888 {"vxlan", RTE_ETH_FLOW_VXLAN},
9889 {"geneve", RTE_ETH_FLOW_GENEVE},
9890 {"nvgre", RTE_ETH_FLOW_NVGRE},
9893 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9894 if (ftype_table[i].ftype == ftype)
9895 return ftype_table[i].str;
9902 cmd_get_hash_global_config_parsed(void *parsed_result,
9903 __rte_unused struct cmdline *cl,
9904 __rte_unused void *data)
9906 struct cmd_get_hash_global_config_result *res = parsed_result;
9907 struct rte_eth_hash_filter_info info;
9908 uint32_t idx, offset;
9913 if (rte_eth_dev_filter_supported(res->port_id,
9914 RTE_ETH_FILTER_HASH) < 0) {
9915 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9920 memset(&info, 0, sizeof(info));
9921 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9922 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9923 RTE_ETH_FILTER_GET, &info);
9925 printf("Cannot get hash global configurations by port %d\n",
9930 switch (info.info.global_conf.hash_func) {
9931 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9932 printf("Hash function is Toeplitz\n");
9934 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9935 printf("Hash function is Simple XOR\n");
9938 printf("Unknown hash function\n");
9942 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9943 idx = i / UINT32_BIT;
9944 offset = i % UINT32_BIT;
9945 if (!(info.info.global_conf.valid_bit_mask[idx] &
9948 str = flowtype_to_str(i);
9951 printf("Symmetric hash is %s globally for flow type %s "
9953 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9954 (1UL << offset)) ? "enabled" : "disabled"), str,
9959 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9960 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9961 get_hash_global_config, "get_hash_global_config");
9962 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9963 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9966 cmdline_parse_inst_t cmd_get_hash_global_config = {
9967 .f = cmd_get_hash_global_config_parsed,
9969 .help_str = "get_hash_global_config <port_id>",
9971 (void *)&cmd_get_hash_global_config_all,
9972 (void *)&cmd_get_hash_global_config_port_id,
9977 /* Set global config of hash function */
9978 struct cmd_set_hash_global_config_result {
9979 cmdline_fixed_string_t set_hash_global_config;
9981 cmdline_fixed_string_t hash_func;
9982 cmdline_fixed_string_t flow_type;
9983 cmdline_fixed_string_t enable;
9987 cmd_set_hash_global_config_parsed(void *parsed_result,
9988 __rte_unused struct cmdline *cl,
9989 __rte_unused void *data)
9991 struct cmd_set_hash_global_config_result *res = parsed_result;
9992 struct rte_eth_hash_filter_info info;
9993 uint32_t ftype, idx, offset;
9996 if (rte_eth_dev_filter_supported(res->port_id,
9997 RTE_ETH_FILTER_HASH) < 0) {
9998 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10002 memset(&info, 0, sizeof(info));
10003 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10004 if (!strcmp(res->hash_func, "toeplitz"))
10005 info.info.global_conf.hash_func =
10006 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10007 else if (!strcmp(res->hash_func, "simple_xor"))
10008 info.info.global_conf.hash_func =
10009 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10010 else if (!strcmp(res->hash_func, "default"))
10011 info.info.global_conf.hash_func =
10012 RTE_ETH_HASH_FUNCTION_DEFAULT;
10014 ftype = str2flowtype(res->flow_type);
10015 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10016 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10017 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10018 if (!strcmp(res->enable, "enable"))
10019 info.info.global_conf.sym_hash_enable_mask[idx] |=
10021 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10022 RTE_ETH_FILTER_SET, &info);
10024 printf("Cannot set global hash configurations by port %d\n",
10027 printf("Global hash configurations have been set "
10028 "succcessfully by port %d\n", res->port_id);
10031 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10032 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10033 set_hash_global_config, "set_hash_global_config");
10034 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10035 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10037 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10038 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10039 hash_func, "toeplitz#simple_xor#default");
10040 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10041 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10043 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10044 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10045 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10046 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10047 enable, "enable#disable");
10049 cmdline_parse_inst_t cmd_set_hash_global_config = {
10050 .f = cmd_set_hash_global_config_parsed,
10052 .help_str = "set_hash_global_config <port_id> "
10053 "toeplitz|simple_xor|default "
10054 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10055 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10056 "l2_payload enable|disable",
10058 (void *)&cmd_set_hash_global_config_all,
10059 (void *)&cmd_set_hash_global_config_port_id,
10060 (void *)&cmd_set_hash_global_config_hash_func,
10061 (void *)&cmd_set_hash_global_config_flow_type,
10062 (void *)&cmd_set_hash_global_config_enable,
10067 /* Set hash input set */
10068 struct cmd_set_hash_input_set_result {
10069 cmdline_fixed_string_t set_hash_input_set;
10071 cmdline_fixed_string_t flow_type;
10072 cmdline_fixed_string_t inset_field;
10073 cmdline_fixed_string_t select;
10076 static enum rte_eth_input_set_field
10077 str2inset(char *string)
10081 static const struct {
10083 enum rte_eth_input_set_field inset;
10084 } inset_table[] = {
10085 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10086 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10087 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10088 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10089 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10090 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10091 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10092 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10093 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10094 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10095 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10096 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10097 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10098 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10099 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10100 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10101 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10102 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10103 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10104 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10105 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10106 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10107 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10108 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10109 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10110 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10111 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10112 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10113 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10114 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10115 {"none", RTE_ETH_INPUT_SET_NONE},
10118 for (i = 0; i < RTE_DIM(inset_table); i++) {
10119 if (!strcmp(string, inset_table[i].str))
10120 return inset_table[i].inset;
10123 return RTE_ETH_INPUT_SET_UNKNOWN;
10127 cmd_set_hash_input_set_parsed(void *parsed_result,
10128 __rte_unused struct cmdline *cl,
10129 __rte_unused void *data)
10131 struct cmd_set_hash_input_set_result *res = parsed_result;
10132 struct rte_eth_hash_filter_info info;
10134 memset(&info, 0, sizeof(info));
10135 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10136 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10137 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10138 info.info.input_set_conf.inset_size = 1;
10139 if (!strcmp(res->select, "select"))
10140 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10141 else if (!strcmp(res->select, "add"))
10142 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10143 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10144 RTE_ETH_FILTER_SET, &info);
10147 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10148 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10149 set_hash_input_set, "set_hash_input_set");
10150 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10151 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10153 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10154 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10156 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10157 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10158 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10159 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10161 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10162 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10163 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10164 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10165 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10167 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10168 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10169 select, "select#add");
10171 cmdline_parse_inst_t cmd_set_hash_input_set = {
10172 .f = cmd_set_hash_input_set_parsed,
10174 .help_str = "set_hash_input_set <port_id> "
10175 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10176 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10177 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10178 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10179 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10180 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10181 "fld-7th|fld-8th|none select|add",
10183 (void *)&cmd_set_hash_input_set_cmd,
10184 (void *)&cmd_set_hash_input_set_port_id,
10185 (void *)&cmd_set_hash_input_set_flow_type,
10186 (void *)&cmd_set_hash_input_set_field,
10187 (void *)&cmd_set_hash_input_set_select,
10192 /* Set flow director input set */
10193 struct cmd_set_fdir_input_set_result {
10194 cmdline_fixed_string_t set_fdir_input_set;
10196 cmdline_fixed_string_t flow_type;
10197 cmdline_fixed_string_t inset_field;
10198 cmdline_fixed_string_t select;
10202 cmd_set_fdir_input_set_parsed(void *parsed_result,
10203 __rte_unused struct cmdline *cl,
10204 __rte_unused void *data)
10206 struct cmd_set_fdir_input_set_result *res = parsed_result;
10207 struct rte_eth_fdir_filter_info info;
10209 memset(&info, 0, sizeof(info));
10210 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10211 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10212 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10213 info.info.input_set_conf.inset_size = 1;
10214 if (!strcmp(res->select, "select"))
10215 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10216 else if (!strcmp(res->select, "add"))
10217 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10218 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10219 RTE_ETH_FILTER_SET, &info);
10222 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10223 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10224 set_fdir_input_set, "set_fdir_input_set");
10225 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10226 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10228 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10229 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10231 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10232 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10233 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10234 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10236 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10237 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10238 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10239 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10240 "sctp-veri-tag#none");
10241 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10242 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10243 select, "select#add");
10245 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10246 .f = cmd_set_fdir_input_set_parsed,
10248 .help_str = "set_fdir_input_set <port_id> "
10249 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10250 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10251 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10252 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10253 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10254 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10255 "sctp-veri-tag|none select|add",
10257 (void *)&cmd_set_fdir_input_set_cmd,
10258 (void *)&cmd_set_fdir_input_set_port_id,
10259 (void *)&cmd_set_fdir_input_set_flow_type,
10260 (void *)&cmd_set_fdir_input_set_field,
10261 (void *)&cmd_set_fdir_input_set_select,
10266 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10267 struct cmd_mcast_addr_result {
10268 cmdline_fixed_string_t mcast_addr_cmd;
10269 cmdline_fixed_string_t what;
10271 struct ether_addr mc_addr;
10274 static void cmd_mcast_addr_parsed(void *parsed_result,
10275 __attribute__((unused)) struct cmdline *cl,
10276 __attribute__((unused)) void *data)
10278 struct cmd_mcast_addr_result *res = parsed_result;
10280 if (!is_multicast_ether_addr(&res->mc_addr)) {
10281 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10282 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10283 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10284 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10287 if (strcmp(res->what, "add") == 0)
10288 mcast_addr_add(res->port_num, &res->mc_addr);
10290 mcast_addr_remove(res->port_num, &res->mc_addr);
10293 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10294 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10295 mcast_addr_cmd, "mcast_addr");
10296 cmdline_parse_token_string_t cmd_mcast_addr_what =
10297 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10299 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10300 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10301 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10302 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10304 cmdline_parse_inst_t cmd_mcast_addr = {
10305 .f = cmd_mcast_addr_parsed,
10307 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10308 "Add/Remove multicast MAC address on port_id",
10310 (void *)&cmd_mcast_addr_cmd,
10311 (void *)&cmd_mcast_addr_what,
10312 (void *)&cmd_mcast_addr_portnum,
10313 (void *)&cmd_mcast_addr_addr,
10318 /* l2 tunnel config
10319 * only support E-tag now.
10322 /* Ether type config */
10323 struct cmd_config_l2_tunnel_eth_type_result {
10324 cmdline_fixed_string_t port;
10325 cmdline_fixed_string_t config;
10326 cmdline_fixed_string_t all;
10328 cmdline_fixed_string_t l2_tunnel;
10329 cmdline_fixed_string_t l2_tunnel_type;
10330 cmdline_fixed_string_t eth_type;
10331 uint16_t eth_type_val;
10334 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10335 TOKEN_STRING_INITIALIZER
10336 (struct cmd_config_l2_tunnel_eth_type_result,
10338 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10339 TOKEN_STRING_INITIALIZER
10340 (struct cmd_config_l2_tunnel_eth_type_result,
10342 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10343 TOKEN_STRING_INITIALIZER
10344 (struct cmd_config_l2_tunnel_eth_type_result,
10346 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10347 TOKEN_NUM_INITIALIZER
10348 (struct cmd_config_l2_tunnel_eth_type_result,
10350 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10351 TOKEN_STRING_INITIALIZER
10352 (struct cmd_config_l2_tunnel_eth_type_result,
10353 l2_tunnel, "l2-tunnel");
10354 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10355 TOKEN_STRING_INITIALIZER
10356 (struct cmd_config_l2_tunnel_eth_type_result,
10357 l2_tunnel_type, "E-tag");
10358 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10359 TOKEN_STRING_INITIALIZER
10360 (struct cmd_config_l2_tunnel_eth_type_result,
10361 eth_type, "ether-type");
10362 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10363 TOKEN_NUM_INITIALIZER
10364 (struct cmd_config_l2_tunnel_eth_type_result,
10365 eth_type_val, UINT16);
10367 static enum rte_eth_tunnel_type
10368 str2fdir_l2_tunnel_type(char *string)
10372 static const struct {
10374 enum rte_eth_tunnel_type type;
10375 } l2_tunnel_type_str[] = {
10376 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10379 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10380 if (!strcmp(l2_tunnel_type_str[i].str, string))
10381 return l2_tunnel_type_str[i].type;
10383 return RTE_TUNNEL_TYPE_NONE;
10386 /* ether type config for all ports */
10388 cmd_config_l2_tunnel_eth_type_all_parsed
10389 (void *parsed_result,
10390 __attribute__((unused)) struct cmdline *cl,
10391 __attribute__((unused)) void *data)
10393 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10394 struct rte_eth_l2_tunnel_conf entry;
10397 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10398 entry.ether_type = res->eth_type_val;
10400 RTE_ETH_FOREACH_DEV(pid) {
10401 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10405 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10406 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10408 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10410 (void *)&cmd_config_l2_tunnel_eth_type_port,
10411 (void *)&cmd_config_l2_tunnel_eth_type_config,
10412 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10413 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10414 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10415 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10416 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10421 /* ether type config for a specific port */
10423 cmd_config_l2_tunnel_eth_type_specific_parsed(
10424 void *parsed_result,
10425 __attribute__((unused)) struct cmdline *cl,
10426 __attribute__((unused)) void *data)
10428 struct cmd_config_l2_tunnel_eth_type_result *res =
10430 struct rte_eth_l2_tunnel_conf entry;
10432 if (port_id_is_invalid(res->id, ENABLED_WARN))
10435 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10436 entry.ether_type = res->eth_type_val;
10438 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10441 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10442 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10444 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10446 (void *)&cmd_config_l2_tunnel_eth_type_port,
10447 (void *)&cmd_config_l2_tunnel_eth_type_config,
10448 (void *)&cmd_config_l2_tunnel_eth_type_id,
10449 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10450 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10451 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10452 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10457 /* Enable/disable l2 tunnel */
10458 struct cmd_config_l2_tunnel_en_dis_result {
10459 cmdline_fixed_string_t port;
10460 cmdline_fixed_string_t config;
10461 cmdline_fixed_string_t all;
10463 cmdline_fixed_string_t l2_tunnel;
10464 cmdline_fixed_string_t l2_tunnel_type;
10465 cmdline_fixed_string_t en_dis;
10468 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10469 TOKEN_STRING_INITIALIZER
10470 (struct cmd_config_l2_tunnel_en_dis_result,
10472 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10473 TOKEN_STRING_INITIALIZER
10474 (struct cmd_config_l2_tunnel_en_dis_result,
10476 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10477 TOKEN_STRING_INITIALIZER
10478 (struct cmd_config_l2_tunnel_en_dis_result,
10480 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10481 TOKEN_NUM_INITIALIZER
10482 (struct cmd_config_l2_tunnel_en_dis_result,
10484 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10485 TOKEN_STRING_INITIALIZER
10486 (struct cmd_config_l2_tunnel_en_dis_result,
10487 l2_tunnel, "l2-tunnel");
10488 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10489 TOKEN_STRING_INITIALIZER
10490 (struct cmd_config_l2_tunnel_en_dis_result,
10491 l2_tunnel_type, "E-tag");
10492 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10493 TOKEN_STRING_INITIALIZER
10494 (struct cmd_config_l2_tunnel_en_dis_result,
10495 en_dis, "enable#disable");
10497 /* enable/disable l2 tunnel for all ports */
10499 cmd_config_l2_tunnel_en_dis_all_parsed(
10500 void *parsed_result,
10501 __attribute__((unused)) struct cmdline *cl,
10502 __attribute__((unused)) void *data)
10504 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10505 struct rte_eth_l2_tunnel_conf entry;
10509 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10511 if (!strcmp("enable", res->en_dis))
10516 RTE_ETH_FOREACH_DEV(pid) {
10517 rte_eth_dev_l2_tunnel_offload_set(pid,
10519 ETH_L2_TUNNEL_ENABLE_MASK,
10524 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10525 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10527 .help_str = "port config all l2-tunnel E-tag enable|disable",
10529 (void *)&cmd_config_l2_tunnel_en_dis_port,
10530 (void *)&cmd_config_l2_tunnel_en_dis_config,
10531 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10532 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10533 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10534 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10539 /* enable/disable l2 tunnel for a port */
10541 cmd_config_l2_tunnel_en_dis_specific_parsed(
10542 void *parsed_result,
10543 __attribute__((unused)) struct cmdline *cl,
10544 __attribute__((unused)) void *data)
10546 struct cmd_config_l2_tunnel_en_dis_result *res =
10548 struct rte_eth_l2_tunnel_conf entry;
10550 if (port_id_is_invalid(res->id, ENABLED_WARN))
10553 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10555 if (!strcmp("enable", res->en_dis))
10556 rte_eth_dev_l2_tunnel_offload_set(res->id,
10558 ETH_L2_TUNNEL_ENABLE_MASK,
10561 rte_eth_dev_l2_tunnel_offload_set(res->id,
10563 ETH_L2_TUNNEL_ENABLE_MASK,
10567 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10568 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10570 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10572 (void *)&cmd_config_l2_tunnel_en_dis_port,
10573 (void *)&cmd_config_l2_tunnel_en_dis_config,
10574 (void *)&cmd_config_l2_tunnel_en_dis_id,
10575 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10576 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10577 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10582 /* E-tag configuration */
10584 /* Common result structure for all E-tag configuration */
10585 struct cmd_config_e_tag_result {
10586 cmdline_fixed_string_t e_tag;
10587 cmdline_fixed_string_t set;
10588 cmdline_fixed_string_t insertion;
10589 cmdline_fixed_string_t stripping;
10590 cmdline_fixed_string_t forwarding;
10591 cmdline_fixed_string_t filter;
10592 cmdline_fixed_string_t add;
10593 cmdline_fixed_string_t del;
10594 cmdline_fixed_string_t on;
10595 cmdline_fixed_string_t off;
10596 cmdline_fixed_string_t on_off;
10597 cmdline_fixed_string_t port_tag_id;
10598 uint32_t port_tag_id_val;
10599 cmdline_fixed_string_t e_tag_id;
10600 uint16_t e_tag_id_val;
10601 cmdline_fixed_string_t dst_pool;
10602 uint8_t dst_pool_val;
10603 cmdline_fixed_string_t port;
10605 cmdline_fixed_string_t vf;
10609 /* Common CLI fields for all E-tag configuration */
10610 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10611 TOKEN_STRING_INITIALIZER
10612 (struct cmd_config_e_tag_result,
10614 cmdline_parse_token_string_t cmd_config_e_tag_set =
10615 TOKEN_STRING_INITIALIZER
10616 (struct cmd_config_e_tag_result,
10618 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10619 TOKEN_STRING_INITIALIZER
10620 (struct cmd_config_e_tag_result,
10621 insertion, "insertion");
10622 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10623 TOKEN_STRING_INITIALIZER
10624 (struct cmd_config_e_tag_result,
10625 stripping, "stripping");
10626 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10627 TOKEN_STRING_INITIALIZER
10628 (struct cmd_config_e_tag_result,
10629 forwarding, "forwarding");
10630 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10631 TOKEN_STRING_INITIALIZER
10632 (struct cmd_config_e_tag_result,
10634 cmdline_parse_token_string_t cmd_config_e_tag_add =
10635 TOKEN_STRING_INITIALIZER
10636 (struct cmd_config_e_tag_result,
10638 cmdline_parse_token_string_t cmd_config_e_tag_del =
10639 TOKEN_STRING_INITIALIZER
10640 (struct cmd_config_e_tag_result,
10642 cmdline_parse_token_string_t cmd_config_e_tag_on =
10643 TOKEN_STRING_INITIALIZER
10644 (struct cmd_config_e_tag_result,
10646 cmdline_parse_token_string_t cmd_config_e_tag_off =
10647 TOKEN_STRING_INITIALIZER
10648 (struct cmd_config_e_tag_result,
10650 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10651 TOKEN_STRING_INITIALIZER
10652 (struct cmd_config_e_tag_result,
10654 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10655 TOKEN_STRING_INITIALIZER
10656 (struct cmd_config_e_tag_result,
10657 port_tag_id, "port-tag-id");
10658 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10659 TOKEN_NUM_INITIALIZER
10660 (struct cmd_config_e_tag_result,
10661 port_tag_id_val, UINT32);
10662 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10663 TOKEN_STRING_INITIALIZER
10664 (struct cmd_config_e_tag_result,
10665 e_tag_id, "e-tag-id");
10666 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10667 TOKEN_NUM_INITIALIZER
10668 (struct cmd_config_e_tag_result,
10669 e_tag_id_val, UINT16);
10670 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10671 TOKEN_STRING_INITIALIZER
10672 (struct cmd_config_e_tag_result,
10673 dst_pool, "dst-pool");
10674 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10675 TOKEN_NUM_INITIALIZER
10676 (struct cmd_config_e_tag_result,
10677 dst_pool_val, UINT8);
10678 cmdline_parse_token_string_t cmd_config_e_tag_port =
10679 TOKEN_STRING_INITIALIZER
10680 (struct cmd_config_e_tag_result,
10682 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10683 TOKEN_NUM_INITIALIZER
10684 (struct cmd_config_e_tag_result,
10686 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10687 TOKEN_STRING_INITIALIZER
10688 (struct cmd_config_e_tag_result,
10690 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10691 TOKEN_NUM_INITIALIZER
10692 (struct cmd_config_e_tag_result,
10695 /* E-tag insertion configuration */
10697 cmd_config_e_tag_insertion_en_parsed(
10698 void *parsed_result,
10699 __attribute__((unused)) struct cmdline *cl,
10700 __attribute__((unused)) void *data)
10702 struct cmd_config_e_tag_result *res =
10704 struct rte_eth_l2_tunnel_conf entry;
10706 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10709 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10710 entry.tunnel_id = res->port_tag_id_val;
10711 entry.vf_id = res->vf_id;
10712 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10714 ETH_L2_TUNNEL_INSERTION_MASK,
10719 cmd_config_e_tag_insertion_dis_parsed(
10720 void *parsed_result,
10721 __attribute__((unused)) struct cmdline *cl,
10722 __attribute__((unused)) void *data)
10724 struct cmd_config_e_tag_result *res =
10726 struct rte_eth_l2_tunnel_conf entry;
10728 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10731 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10732 entry.vf_id = res->vf_id;
10734 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10736 ETH_L2_TUNNEL_INSERTION_MASK,
10740 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10741 .f = cmd_config_e_tag_insertion_en_parsed,
10743 .help_str = "E-tag ... : E-tag insertion enable",
10745 (void *)&cmd_config_e_tag_e_tag,
10746 (void *)&cmd_config_e_tag_set,
10747 (void *)&cmd_config_e_tag_insertion,
10748 (void *)&cmd_config_e_tag_on,
10749 (void *)&cmd_config_e_tag_port_tag_id,
10750 (void *)&cmd_config_e_tag_port_tag_id_val,
10751 (void *)&cmd_config_e_tag_port,
10752 (void *)&cmd_config_e_tag_port_id,
10753 (void *)&cmd_config_e_tag_vf,
10754 (void *)&cmd_config_e_tag_vf_id,
10759 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10760 .f = cmd_config_e_tag_insertion_dis_parsed,
10762 .help_str = "E-tag ... : E-tag insertion disable",
10764 (void *)&cmd_config_e_tag_e_tag,
10765 (void *)&cmd_config_e_tag_set,
10766 (void *)&cmd_config_e_tag_insertion,
10767 (void *)&cmd_config_e_tag_off,
10768 (void *)&cmd_config_e_tag_port,
10769 (void *)&cmd_config_e_tag_port_id,
10770 (void *)&cmd_config_e_tag_vf,
10771 (void *)&cmd_config_e_tag_vf_id,
10776 /* E-tag stripping configuration */
10778 cmd_config_e_tag_stripping_parsed(
10779 void *parsed_result,
10780 __attribute__((unused)) struct cmdline *cl,
10781 __attribute__((unused)) void *data)
10783 struct cmd_config_e_tag_result *res =
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_STRIPPING_MASK,
10799 rte_eth_dev_l2_tunnel_offload_set
10802 ETH_L2_TUNNEL_STRIPPING_MASK,
10806 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10807 .f = cmd_config_e_tag_stripping_parsed,
10809 .help_str = "E-tag ... : E-tag stripping enable/disable",
10811 (void *)&cmd_config_e_tag_e_tag,
10812 (void *)&cmd_config_e_tag_set,
10813 (void *)&cmd_config_e_tag_stripping,
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 forwarding configuration */
10823 cmd_config_e_tag_forwarding_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;
10831 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10834 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10836 if (!strcmp(res->on_off, "on"))
10837 rte_eth_dev_l2_tunnel_offload_set
10840 ETH_L2_TUNNEL_FORWARDING_MASK,
10843 rte_eth_dev_l2_tunnel_offload_set
10846 ETH_L2_TUNNEL_FORWARDING_MASK,
10850 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10851 .f = cmd_config_e_tag_forwarding_parsed,
10853 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10855 (void *)&cmd_config_e_tag_e_tag,
10856 (void *)&cmd_config_e_tag_set,
10857 (void *)&cmd_config_e_tag_forwarding,
10858 (void *)&cmd_config_e_tag_on_off,
10859 (void *)&cmd_config_e_tag_port,
10860 (void *)&cmd_config_e_tag_port_id,
10865 /* E-tag filter configuration */
10867 cmd_config_e_tag_filter_add_parsed(
10868 void *parsed_result,
10869 __attribute__((unused)) struct cmdline *cl,
10870 __attribute__((unused)) void *data)
10872 struct cmd_config_e_tag_result *res = parsed_result;
10873 struct rte_eth_l2_tunnel_conf entry;
10876 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10879 if (res->e_tag_id_val > 0x3fff) {
10880 printf("e-tag-id must be equal or less than 0x3fff.\n");
10884 ret = rte_eth_dev_filter_supported(res->port_id,
10885 RTE_ETH_FILTER_L2_TUNNEL);
10887 printf("E-tag filter is not supported on port %u.\n",
10892 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10893 entry.tunnel_id = res->e_tag_id_val;
10894 entry.pool = res->dst_pool_val;
10896 ret = rte_eth_dev_filter_ctrl(res->port_id,
10897 RTE_ETH_FILTER_L2_TUNNEL,
10898 RTE_ETH_FILTER_ADD,
10901 printf("E-tag filter programming error: (%s)\n",
10905 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10906 .f = cmd_config_e_tag_filter_add_parsed,
10908 .help_str = "E-tag ... : E-tag filter add",
10910 (void *)&cmd_config_e_tag_e_tag,
10911 (void *)&cmd_config_e_tag_set,
10912 (void *)&cmd_config_e_tag_filter,
10913 (void *)&cmd_config_e_tag_add,
10914 (void *)&cmd_config_e_tag_e_tag_id,
10915 (void *)&cmd_config_e_tag_e_tag_id_val,
10916 (void *)&cmd_config_e_tag_dst_pool,
10917 (void *)&cmd_config_e_tag_dst_pool_val,
10918 (void *)&cmd_config_e_tag_port,
10919 (void *)&cmd_config_e_tag_port_id,
10925 cmd_config_e_tag_filter_del_parsed(
10926 void *parsed_result,
10927 __attribute__((unused)) struct cmdline *cl,
10928 __attribute__((unused)) void *data)
10930 struct cmd_config_e_tag_result *res = parsed_result;
10931 struct rte_eth_l2_tunnel_conf entry;
10934 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10937 if (res->e_tag_id_val > 0x3fff) {
10938 printf("e-tag-id must be less than 0x3fff.\n");
10942 ret = rte_eth_dev_filter_supported(res->port_id,
10943 RTE_ETH_FILTER_L2_TUNNEL);
10945 printf("E-tag filter is not supported on port %u.\n",
10950 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10951 entry.tunnel_id = res->e_tag_id_val;
10953 ret = rte_eth_dev_filter_ctrl(res->port_id,
10954 RTE_ETH_FILTER_L2_TUNNEL,
10955 RTE_ETH_FILTER_DELETE,
10958 printf("E-tag filter programming error: (%s)\n",
10962 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10963 .f = cmd_config_e_tag_filter_del_parsed,
10965 .help_str = "E-tag ... : E-tag filter delete",
10967 (void *)&cmd_config_e_tag_e_tag,
10968 (void *)&cmd_config_e_tag_set,
10969 (void *)&cmd_config_e_tag_filter,
10970 (void *)&cmd_config_e_tag_del,
10971 (void *)&cmd_config_e_tag_e_tag_id,
10972 (void *)&cmd_config_e_tag_e_tag_id_val,
10973 (void *)&cmd_config_e_tag_port,
10974 (void *)&cmd_config_e_tag_port_id,
10979 /* vf vlan anti spoof configuration */
10981 /* Common result structure for vf vlan anti spoof */
10982 struct cmd_vf_vlan_anti_spoof_result {
10983 cmdline_fixed_string_t set;
10984 cmdline_fixed_string_t vf;
10985 cmdline_fixed_string_t vlan;
10986 cmdline_fixed_string_t antispoof;
10989 cmdline_fixed_string_t on_off;
10992 /* Common CLI fields for vf vlan anti spoof enable disable */
10993 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10994 TOKEN_STRING_INITIALIZER
10995 (struct cmd_vf_vlan_anti_spoof_result,
10997 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10998 TOKEN_STRING_INITIALIZER
10999 (struct cmd_vf_vlan_anti_spoof_result,
11001 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11002 TOKEN_STRING_INITIALIZER
11003 (struct cmd_vf_vlan_anti_spoof_result,
11005 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11006 TOKEN_STRING_INITIALIZER
11007 (struct cmd_vf_vlan_anti_spoof_result,
11008 antispoof, "antispoof");
11009 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11010 TOKEN_NUM_INITIALIZER
11011 (struct cmd_vf_vlan_anti_spoof_result,
11013 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11014 TOKEN_NUM_INITIALIZER
11015 (struct cmd_vf_vlan_anti_spoof_result,
11017 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11018 TOKEN_STRING_INITIALIZER
11019 (struct cmd_vf_vlan_anti_spoof_result,
11023 cmd_set_vf_vlan_anti_spoof_parsed(
11024 void *parsed_result,
11025 __attribute__((unused)) struct cmdline *cl,
11026 __attribute__((unused)) void *data)
11028 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11029 int ret = -ENOTSUP;
11031 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11033 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11036 #ifdef RTE_LIBRTE_IXGBE_PMD
11037 if (ret == -ENOTSUP)
11038 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11039 res->vf_id, is_on);
11041 #ifdef RTE_LIBRTE_I40E_PMD
11042 if (ret == -ENOTSUP)
11043 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11044 res->vf_id, is_on);
11046 #ifdef RTE_LIBRTE_BNXT_PMD
11047 if (ret == -ENOTSUP)
11048 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11049 res->vf_id, is_on);
11056 printf("invalid vf_id %d\n", res->vf_id);
11059 printf("invalid port_id %d\n", res->port_id);
11062 printf("function not implemented\n");
11065 printf("programming error: (%s)\n", strerror(-ret));
11069 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11070 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11072 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11074 (void *)&cmd_vf_vlan_anti_spoof_set,
11075 (void *)&cmd_vf_vlan_anti_spoof_vf,
11076 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11077 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11078 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11079 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11080 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11085 /* vf mac anti spoof configuration */
11087 /* Common result structure for vf mac anti spoof */
11088 struct cmd_vf_mac_anti_spoof_result {
11089 cmdline_fixed_string_t set;
11090 cmdline_fixed_string_t vf;
11091 cmdline_fixed_string_t mac;
11092 cmdline_fixed_string_t antispoof;
11095 cmdline_fixed_string_t on_off;
11098 /* Common CLI fields for vf mac anti spoof enable disable */
11099 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11100 TOKEN_STRING_INITIALIZER
11101 (struct cmd_vf_mac_anti_spoof_result,
11103 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11104 TOKEN_STRING_INITIALIZER
11105 (struct cmd_vf_mac_anti_spoof_result,
11107 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11108 TOKEN_STRING_INITIALIZER
11109 (struct cmd_vf_mac_anti_spoof_result,
11111 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11112 TOKEN_STRING_INITIALIZER
11113 (struct cmd_vf_mac_anti_spoof_result,
11114 antispoof, "antispoof");
11115 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11116 TOKEN_NUM_INITIALIZER
11117 (struct cmd_vf_mac_anti_spoof_result,
11119 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11120 TOKEN_NUM_INITIALIZER
11121 (struct cmd_vf_mac_anti_spoof_result,
11123 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11124 TOKEN_STRING_INITIALIZER
11125 (struct cmd_vf_mac_anti_spoof_result,
11129 cmd_set_vf_mac_anti_spoof_parsed(
11130 void *parsed_result,
11131 __attribute__((unused)) struct cmdline *cl,
11132 __attribute__((unused)) void *data)
11134 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11135 int ret = -ENOTSUP;
11137 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11139 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11142 #ifdef RTE_LIBRTE_IXGBE_PMD
11143 if (ret == -ENOTSUP)
11144 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11145 res->vf_id, is_on);
11147 #ifdef RTE_LIBRTE_I40E_PMD
11148 if (ret == -ENOTSUP)
11149 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11150 res->vf_id, is_on);
11152 #ifdef RTE_LIBRTE_BNXT_PMD
11153 if (ret == -ENOTSUP)
11154 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11155 res->vf_id, is_on);
11162 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11165 printf("invalid port_id %d\n", res->port_id);
11168 printf("function not implemented\n");
11171 printf("programming error: (%s)\n", strerror(-ret));
11175 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11176 .f = cmd_set_vf_mac_anti_spoof_parsed,
11178 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11180 (void *)&cmd_vf_mac_anti_spoof_set,
11181 (void *)&cmd_vf_mac_anti_spoof_vf,
11182 (void *)&cmd_vf_mac_anti_spoof_mac,
11183 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11184 (void *)&cmd_vf_mac_anti_spoof_port_id,
11185 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11186 (void *)&cmd_vf_mac_anti_spoof_on_off,
11191 /* vf vlan strip queue configuration */
11193 /* Common result structure for vf mac anti spoof */
11194 struct cmd_vf_vlan_stripq_result {
11195 cmdline_fixed_string_t set;
11196 cmdline_fixed_string_t vf;
11197 cmdline_fixed_string_t vlan;
11198 cmdline_fixed_string_t stripq;
11201 cmdline_fixed_string_t on_off;
11204 /* Common CLI fields for vf vlan strip enable disable */
11205 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11206 TOKEN_STRING_INITIALIZER
11207 (struct cmd_vf_vlan_stripq_result,
11209 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11210 TOKEN_STRING_INITIALIZER
11211 (struct cmd_vf_vlan_stripq_result,
11213 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11214 TOKEN_STRING_INITIALIZER
11215 (struct cmd_vf_vlan_stripq_result,
11217 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11218 TOKEN_STRING_INITIALIZER
11219 (struct cmd_vf_vlan_stripq_result,
11221 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11222 TOKEN_NUM_INITIALIZER
11223 (struct cmd_vf_vlan_stripq_result,
11225 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11226 TOKEN_NUM_INITIALIZER
11227 (struct cmd_vf_vlan_stripq_result,
11229 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11230 TOKEN_STRING_INITIALIZER
11231 (struct cmd_vf_vlan_stripq_result,
11235 cmd_set_vf_vlan_stripq_parsed(
11236 void *parsed_result,
11237 __attribute__((unused)) struct cmdline *cl,
11238 __attribute__((unused)) void *data)
11240 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11241 int ret = -ENOTSUP;
11243 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11245 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11248 #ifdef RTE_LIBRTE_IXGBE_PMD
11249 if (ret == -ENOTSUP)
11250 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11251 res->vf_id, is_on);
11253 #ifdef RTE_LIBRTE_I40E_PMD
11254 if (ret == -ENOTSUP)
11255 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11256 res->vf_id, is_on);
11258 #ifdef RTE_LIBRTE_BNXT_PMD
11259 if (ret == -ENOTSUP)
11260 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11261 res->vf_id, is_on);
11268 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11271 printf("invalid port_id %d\n", res->port_id);
11274 printf("function not implemented\n");
11277 printf("programming error: (%s)\n", strerror(-ret));
11281 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11282 .f = cmd_set_vf_vlan_stripq_parsed,
11284 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11286 (void *)&cmd_vf_vlan_stripq_set,
11287 (void *)&cmd_vf_vlan_stripq_vf,
11288 (void *)&cmd_vf_vlan_stripq_vlan,
11289 (void *)&cmd_vf_vlan_stripq_stripq,
11290 (void *)&cmd_vf_vlan_stripq_port_id,
11291 (void *)&cmd_vf_vlan_stripq_vf_id,
11292 (void *)&cmd_vf_vlan_stripq_on_off,
11297 /* vf vlan insert configuration */
11299 /* Common result structure for vf vlan insert */
11300 struct cmd_vf_vlan_insert_result {
11301 cmdline_fixed_string_t set;
11302 cmdline_fixed_string_t vf;
11303 cmdline_fixed_string_t vlan;
11304 cmdline_fixed_string_t insert;
11310 /* Common CLI fields for vf vlan insert enable disable */
11311 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11312 TOKEN_STRING_INITIALIZER
11313 (struct cmd_vf_vlan_insert_result,
11315 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11316 TOKEN_STRING_INITIALIZER
11317 (struct cmd_vf_vlan_insert_result,
11319 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11320 TOKEN_STRING_INITIALIZER
11321 (struct cmd_vf_vlan_insert_result,
11323 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11324 TOKEN_STRING_INITIALIZER
11325 (struct cmd_vf_vlan_insert_result,
11327 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11328 TOKEN_NUM_INITIALIZER
11329 (struct cmd_vf_vlan_insert_result,
11331 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11332 TOKEN_NUM_INITIALIZER
11333 (struct cmd_vf_vlan_insert_result,
11335 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11336 TOKEN_NUM_INITIALIZER
11337 (struct cmd_vf_vlan_insert_result,
11341 cmd_set_vf_vlan_insert_parsed(
11342 void *parsed_result,
11343 __attribute__((unused)) struct cmdline *cl,
11344 __attribute__((unused)) void *data)
11346 struct cmd_vf_vlan_insert_result *res = parsed_result;
11347 int ret = -ENOTSUP;
11349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11352 #ifdef RTE_LIBRTE_IXGBE_PMD
11353 if (ret == -ENOTSUP)
11354 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11357 #ifdef RTE_LIBRTE_I40E_PMD
11358 if (ret == -ENOTSUP)
11359 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11362 #ifdef RTE_LIBRTE_BNXT_PMD
11363 if (ret == -ENOTSUP)
11364 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11372 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11375 printf("invalid port_id %d\n", res->port_id);
11378 printf("function not implemented\n");
11381 printf("programming error: (%s)\n", strerror(-ret));
11385 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11386 .f = cmd_set_vf_vlan_insert_parsed,
11388 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11390 (void *)&cmd_vf_vlan_insert_set,
11391 (void *)&cmd_vf_vlan_insert_vf,
11392 (void *)&cmd_vf_vlan_insert_vlan,
11393 (void *)&cmd_vf_vlan_insert_insert,
11394 (void *)&cmd_vf_vlan_insert_port_id,
11395 (void *)&cmd_vf_vlan_insert_vf_id,
11396 (void *)&cmd_vf_vlan_insert_vlan_id,
11401 /* tx loopback configuration */
11403 /* Common result structure for tx loopback */
11404 struct cmd_tx_loopback_result {
11405 cmdline_fixed_string_t set;
11406 cmdline_fixed_string_t tx;
11407 cmdline_fixed_string_t loopback;
11409 cmdline_fixed_string_t on_off;
11412 /* Common CLI fields for tx loopback enable disable */
11413 cmdline_parse_token_string_t cmd_tx_loopback_set =
11414 TOKEN_STRING_INITIALIZER
11415 (struct cmd_tx_loopback_result,
11417 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11418 TOKEN_STRING_INITIALIZER
11419 (struct cmd_tx_loopback_result,
11421 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11422 TOKEN_STRING_INITIALIZER
11423 (struct cmd_tx_loopback_result,
11424 loopback, "loopback");
11425 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11426 TOKEN_NUM_INITIALIZER
11427 (struct cmd_tx_loopback_result,
11429 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11430 TOKEN_STRING_INITIALIZER
11431 (struct cmd_tx_loopback_result,
11435 cmd_set_tx_loopback_parsed(
11436 void *parsed_result,
11437 __attribute__((unused)) struct cmdline *cl,
11438 __attribute__((unused)) void *data)
11440 struct cmd_tx_loopback_result *res = parsed_result;
11441 int ret = -ENOTSUP;
11443 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11445 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11448 #ifdef RTE_LIBRTE_IXGBE_PMD
11449 if (ret == -ENOTSUP)
11450 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11452 #ifdef RTE_LIBRTE_I40E_PMD
11453 if (ret == -ENOTSUP)
11454 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11456 #ifdef RTE_LIBRTE_BNXT_PMD
11457 if (ret == -ENOTSUP)
11458 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11465 printf("invalid is_on %d\n", is_on);
11468 printf("invalid port_id %d\n", res->port_id);
11471 printf("function not implemented\n");
11474 printf("programming error: (%s)\n", strerror(-ret));
11478 cmdline_parse_inst_t cmd_set_tx_loopback = {
11479 .f = cmd_set_tx_loopback_parsed,
11481 .help_str = "set tx loopback <port_id> on|off",
11483 (void *)&cmd_tx_loopback_set,
11484 (void *)&cmd_tx_loopback_tx,
11485 (void *)&cmd_tx_loopback_loopback,
11486 (void *)&cmd_tx_loopback_port_id,
11487 (void *)&cmd_tx_loopback_on_off,
11492 /* all queues drop enable configuration */
11494 /* Common result structure for all queues drop enable */
11495 struct cmd_all_queues_drop_en_result {
11496 cmdline_fixed_string_t set;
11497 cmdline_fixed_string_t all;
11498 cmdline_fixed_string_t queues;
11499 cmdline_fixed_string_t drop;
11501 cmdline_fixed_string_t on_off;
11504 /* Common CLI fields for tx loopback enable disable */
11505 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11506 TOKEN_STRING_INITIALIZER
11507 (struct cmd_all_queues_drop_en_result,
11509 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11510 TOKEN_STRING_INITIALIZER
11511 (struct cmd_all_queues_drop_en_result,
11513 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11514 TOKEN_STRING_INITIALIZER
11515 (struct cmd_all_queues_drop_en_result,
11517 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11518 TOKEN_STRING_INITIALIZER
11519 (struct cmd_all_queues_drop_en_result,
11521 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11522 TOKEN_NUM_INITIALIZER
11523 (struct cmd_all_queues_drop_en_result,
11525 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11526 TOKEN_STRING_INITIALIZER
11527 (struct cmd_all_queues_drop_en_result,
11531 cmd_set_all_queues_drop_en_parsed(
11532 void *parsed_result,
11533 __attribute__((unused)) struct cmdline *cl,
11534 __attribute__((unused)) void *data)
11536 struct cmd_all_queues_drop_en_result *res = parsed_result;
11537 int ret = -ENOTSUP;
11538 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11540 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11543 #ifdef RTE_LIBRTE_IXGBE_PMD
11544 if (ret == -ENOTSUP)
11545 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11547 #ifdef RTE_LIBRTE_BNXT_PMD
11548 if (ret == -ENOTSUP)
11549 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11555 printf("invalid is_on %d\n", is_on);
11558 printf("invalid port_id %d\n", res->port_id);
11561 printf("function not implemented\n");
11564 printf("programming error: (%s)\n", strerror(-ret));
11568 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11569 .f = cmd_set_all_queues_drop_en_parsed,
11571 .help_str = "set all queues drop <port_id> on|off",
11573 (void *)&cmd_all_queues_drop_en_set,
11574 (void *)&cmd_all_queues_drop_en_all,
11575 (void *)&cmd_all_queues_drop_en_queues,
11576 (void *)&cmd_all_queues_drop_en_drop,
11577 (void *)&cmd_all_queues_drop_en_port_id,
11578 (void *)&cmd_all_queues_drop_en_on_off,
11583 /* vf split drop enable configuration */
11585 /* Common result structure for vf split drop enable */
11586 struct cmd_vf_split_drop_en_result {
11587 cmdline_fixed_string_t set;
11588 cmdline_fixed_string_t vf;
11589 cmdline_fixed_string_t split;
11590 cmdline_fixed_string_t drop;
11593 cmdline_fixed_string_t on_off;
11596 /* Common CLI fields for vf split drop enable disable */
11597 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11598 TOKEN_STRING_INITIALIZER
11599 (struct cmd_vf_split_drop_en_result,
11601 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11602 TOKEN_STRING_INITIALIZER
11603 (struct cmd_vf_split_drop_en_result,
11605 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11606 TOKEN_STRING_INITIALIZER
11607 (struct cmd_vf_split_drop_en_result,
11609 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11610 TOKEN_STRING_INITIALIZER
11611 (struct cmd_vf_split_drop_en_result,
11613 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11614 TOKEN_NUM_INITIALIZER
11615 (struct cmd_vf_split_drop_en_result,
11617 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11618 TOKEN_NUM_INITIALIZER
11619 (struct cmd_vf_split_drop_en_result,
11621 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11622 TOKEN_STRING_INITIALIZER
11623 (struct cmd_vf_split_drop_en_result,
11627 cmd_set_vf_split_drop_en_parsed(
11628 void *parsed_result,
11629 __attribute__((unused)) struct cmdline *cl,
11630 __attribute__((unused)) void *data)
11632 struct cmd_vf_split_drop_en_result *res = parsed_result;
11633 int ret = -ENOTSUP;
11634 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11636 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11639 #ifdef RTE_LIBRTE_IXGBE_PMD
11640 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11647 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11650 printf("invalid port_id %d\n", res->port_id);
11653 printf("not supported on port %d\n", res->port_id);
11656 printf("programming error: (%s)\n", strerror(-ret));
11660 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11661 .f = cmd_set_vf_split_drop_en_parsed,
11663 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11665 (void *)&cmd_vf_split_drop_en_set,
11666 (void *)&cmd_vf_split_drop_en_vf,
11667 (void *)&cmd_vf_split_drop_en_split,
11668 (void *)&cmd_vf_split_drop_en_drop,
11669 (void *)&cmd_vf_split_drop_en_port_id,
11670 (void *)&cmd_vf_split_drop_en_vf_id,
11671 (void *)&cmd_vf_split_drop_en_on_off,
11676 /* vf mac address configuration */
11678 /* Common result structure for vf mac address */
11679 struct cmd_set_vf_mac_addr_result {
11680 cmdline_fixed_string_t set;
11681 cmdline_fixed_string_t vf;
11682 cmdline_fixed_string_t mac;
11683 cmdline_fixed_string_t addr;
11686 struct ether_addr mac_addr;
11690 /* Common CLI fields for vf split drop enable disable */
11691 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11692 TOKEN_STRING_INITIALIZER
11693 (struct cmd_set_vf_mac_addr_result,
11695 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11696 TOKEN_STRING_INITIALIZER
11697 (struct cmd_set_vf_mac_addr_result,
11699 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11700 TOKEN_STRING_INITIALIZER
11701 (struct cmd_set_vf_mac_addr_result,
11703 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11704 TOKEN_STRING_INITIALIZER
11705 (struct cmd_set_vf_mac_addr_result,
11707 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11708 TOKEN_NUM_INITIALIZER
11709 (struct cmd_set_vf_mac_addr_result,
11711 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11712 TOKEN_NUM_INITIALIZER
11713 (struct cmd_set_vf_mac_addr_result,
11715 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11716 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11720 cmd_set_vf_mac_addr_parsed(
11721 void *parsed_result,
11722 __attribute__((unused)) struct cmdline *cl,
11723 __attribute__((unused)) void *data)
11725 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11726 int ret = -ENOTSUP;
11728 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11731 #ifdef RTE_LIBRTE_IXGBE_PMD
11732 if (ret == -ENOTSUP)
11733 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11736 #ifdef RTE_LIBRTE_I40E_PMD
11737 if (ret == -ENOTSUP)
11738 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11741 #ifdef RTE_LIBRTE_BNXT_PMD
11742 if (ret == -ENOTSUP)
11743 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11751 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11754 printf("invalid port_id %d\n", res->port_id);
11757 printf("function not implemented\n");
11760 printf("programming error: (%s)\n", strerror(-ret));
11764 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11765 .f = cmd_set_vf_mac_addr_parsed,
11767 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11769 (void *)&cmd_set_vf_mac_addr_set,
11770 (void *)&cmd_set_vf_mac_addr_vf,
11771 (void *)&cmd_set_vf_mac_addr_mac,
11772 (void *)&cmd_set_vf_mac_addr_addr,
11773 (void *)&cmd_set_vf_mac_addr_port_id,
11774 (void *)&cmd_set_vf_mac_addr_vf_id,
11775 (void *)&cmd_set_vf_mac_addr_mac_addr,
11780 /* MACsec configuration */
11782 /* Common result structure for MACsec offload enable */
11783 struct cmd_macsec_offload_on_result {
11784 cmdline_fixed_string_t set;
11785 cmdline_fixed_string_t macsec;
11786 cmdline_fixed_string_t offload;
11788 cmdline_fixed_string_t on;
11789 cmdline_fixed_string_t encrypt;
11790 cmdline_fixed_string_t en_on_off;
11791 cmdline_fixed_string_t replay_protect;
11792 cmdline_fixed_string_t rp_on_off;
11795 /* Common CLI fields for MACsec offload disable */
11796 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11797 TOKEN_STRING_INITIALIZER
11798 (struct cmd_macsec_offload_on_result,
11800 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11801 TOKEN_STRING_INITIALIZER
11802 (struct cmd_macsec_offload_on_result,
11804 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11805 TOKEN_STRING_INITIALIZER
11806 (struct cmd_macsec_offload_on_result,
11807 offload, "offload");
11808 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11809 TOKEN_NUM_INITIALIZER
11810 (struct cmd_macsec_offload_on_result,
11812 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11813 TOKEN_STRING_INITIALIZER
11814 (struct cmd_macsec_offload_on_result,
11816 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11817 TOKEN_STRING_INITIALIZER
11818 (struct cmd_macsec_offload_on_result,
11819 encrypt, "encrypt");
11820 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11821 TOKEN_STRING_INITIALIZER
11822 (struct cmd_macsec_offload_on_result,
11823 en_on_off, "on#off");
11824 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11825 TOKEN_STRING_INITIALIZER
11826 (struct cmd_macsec_offload_on_result,
11827 replay_protect, "replay-protect");
11828 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11829 TOKEN_STRING_INITIALIZER
11830 (struct cmd_macsec_offload_on_result,
11831 rp_on_off, "on#off");
11834 cmd_set_macsec_offload_on_parsed(
11835 void *parsed_result,
11836 __attribute__((unused)) struct cmdline *cl,
11837 __attribute__((unused)) void *data)
11839 struct cmd_macsec_offload_on_result *res = parsed_result;
11840 int ret = -ENOTSUP;
11841 portid_t port_id = res->port_id;
11842 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11843 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11845 if (port_id_is_invalid(port_id, ENABLED_WARN))
11848 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11849 #ifdef RTE_LIBRTE_IXGBE_PMD
11850 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11859 printf("invalid port_id %d\n", port_id);
11862 printf("not supported on port %d\n", port_id);
11865 printf("programming error: (%s)\n", strerror(-ret));
11869 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11870 .f = cmd_set_macsec_offload_on_parsed,
11872 .help_str = "set macsec offload <port_id> on "
11873 "encrypt on|off replay-protect on|off",
11875 (void *)&cmd_macsec_offload_on_set,
11876 (void *)&cmd_macsec_offload_on_macsec,
11877 (void *)&cmd_macsec_offload_on_offload,
11878 (void *)&cmd_macsec_offload_on_port_id,
11879 (void *)&cmd_macsec_offload_on_on,
11880 (void *)&cmd_macsec_offload_on_encrypt,
11881 (void *)&cmd_macsec_offload_on_en_on_off,
11882 (void *)&cmd_macsec_offload_on_replay_protect,
11883 (void *)&cmd_macsec_offload_on_rp_on_off,
11888 /* Common result structure for MACsec offload disable */
11889 struct cmd_macsec_offload_off_result {
11890 cmdline_fixed_string_t set;
11891 cmdline_fixed_string_t macsec;
11892 cmdline_fixed_string_t offload;
11894 cmdline_fixed_string_t off;
11897 /* Common CLI fields for MACsec offload disable */
11898 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11899 TOKEN_STRING_INITIALIZER
11900 (struct cmd_macsec_offload_off_result,
11902 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11903 TOKEN_STRING_INITIALIZER
11904 (struct cmd_macsec_offload_off_result,
11906 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11907 TOKEN_STRING_INITIALIZER
11908 (struct cmd_macsec_offload_off_result,
11909 offload, "offload");
11910 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11911 TOKEN_NUM_INITIALIZER
11912 (struct cmd_macsec_offload_off_result,
11914 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11915 TOKEN_STRING_INITIALIZER
11916 (struct cmd_macsec_offload_off_result,
11920 cmd_set_macsec_offload_off_parsed(
11921 void *parsed_result,
11922 __attribute__((unused)) struct cmdline *cl,
11923 __attribute__((unused)) void *data)
11925 struct cmd_macsec_offload_off_result *res = parsed_result;
11926 int ret = -ENOTSUP;
11927 portid_t port_id = res->port_id;
11929 if (port_id_is_invalid(port_id, ENABLED_WARN))
11932 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11933 #ifdef RTE_LIBRTE_IXGBE_PMD
11934 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11941 printf("invalid port_id %d\n", port_id);
11944 printf("not supported on port %d\n", port_id);
11947 printf("programming error: (%s)\n", strerror(-ret));
11951 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11952 .f = cmd_set_macsec_offload_off_parsed,
11954 .help_str = "set macsec offload <port_id> off",
11956 (void *)&cmd_macsec_offload_off_set,
11957 (void *)&cmd_macsec_offload_off_macsec,
11958 (void *)&cmd_macsec_offload_off_offload,
11959 (void *)&cmd_macsec_offload_off_port_id,
11960 (void *)&cmd_macsec_offload_off_off,
11965 /* Common result structure for MACsec secure connection configure */
11966 struct cmd_macsec_sc_result {
11967 cmdline_fixed_string_t set;
11968 cmdline_fixed_string_t macsec;
11969 cmdline_fixed_string_t sc;
11970 cmdline_fixed_string_t tx_rx;
11972 struct ether_addr mac;
11976 /* Common CLI fields for MACsec secure connection configure */
11977 cmdline_parse_token_string_t cmd_macsec_sc_set =
11978 TOKEN_STRING_INITIALIZER
11979 (struct cmd_macsec_sc_result,
11981 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11982 TOKEN_STRING_INITIALIZER
11983 (struct cmd_macsec_sc_result,
11985 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11986 TOKEN_STRING_INITIALIZER
11987 (struct cmd_macsec_sc_result,
11989 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11990 TOKEN_STRING_INITIALIZER
11991 (struct cmd_macsec_sc_result,
11993 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11994 TOKEN_NUM_INITIALIZER
11995 (struct cmd_macsec_sc_result,
11997 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11998 TOKEN_ETHERADDR_INITIALIZER
11999 (struct cmd_macsec_sc_result,
12001 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12002 TOKEN_NUM_INITIALIZER
12003 (struct cmd_macsec_sc_result,
12007 cmd_set_macsec_sc_parsed(
12008 void *parsed_result,
12009 __attribute__((unused)) struct cmdline *cl,
12010 __attribute__((unused)) void *data)
12012 struct cmd_macsec_sc_result *res = parsed_result;
12013 int ret = -ENOTSUP;
12014 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12016 #ifdef RTE_LIBRTE_IXGBE_PMD
12018 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12019 res->mac.addr_bytes) :
12020 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12021 res->mac.addr_bytes, res->pi);
12023 RTE_SET_USED(is_tx);
12029 printf("invalid port_id %d\n", res->port_id);
12032 printf("not supported on port %d\n", res->port_id);
12035 printf("programming error: (%s)\n", strerror(-ret));
12039 cmdline_parse_inst_t cmd_set_macsec_sc = {
12040 .f = cmd_set_macsec_sc_parsed,
12042 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12044 (void *)&cmd_macsec_sc_set,
12045 (void *)&cmd_macsec_sc_macsec,
12046 (void *)&cmd_macsec_sc_sc,
12047 (void *)&cmd_macsec_sc_tx_rx,
12048 (void *)&cmd_macsec_sc_port_id,
12049 (void *)&cmd_macsec_sc_mac,
12050 (void *)&cmd_macsec_sc_pi,
12055 /* Common result structure for MACsec secure connection configure */
12056 struct cmd_macsec_sa_result {
12057 cmdline_fixed_string_t set;
12058 cmdline_fixed_string_t macsec;
12059 cmdline_fixed_string_t sa;
12060 cmdline_fixed_string_t tx_rx;
12065 cmdline_fixed_string_t key;
12068 /* Common CLI fields for MACsec secure connection configure */
12069 cmdline_parse_token_string_t cmd_macsec_sa_set =
12070 TOKEN_STRING_INITIALIZER
12071 (struct cmd_macsec_sa_result,
12073 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12074 TOKEN_STRING_INITIALIZER
12075 (struct cmd_macsec_sa_result,
12077 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12078 TOKEN_STRING_INITIALIZER
12079 (struct cmd_macsec_sa_result,
12081 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12082 TOKEN_STRING_INITIALIZER
12083 (struct cmd_macsec_sa_result,
12085 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12086 TOKEN_NUM_INITIALIZER
12087 (struct cmd_macsec_sa_result,
12089 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12090 TOKEN_NUM_INITIALIZER
12091 (struct cmd_macsec_sa_result,
12093 cmdline_parse_token_num_t cmd_macsec_sa_an =
12094 TOKEN_NUM_INITIALIZER
12095 (struct cmd_macsec_sa_result,
12097 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12098 TOKEN_NUM_INITIALIZER
12099 (struct cmd_macsec_sa_result,
12101 cmdline_parse_token_string_t cmd_macsec_sa_key =
12102 TOKEN_STRING_INITIALIZER
12103 (struct cmd_macsec_sa_result,
12107 cmd_set_macsec_sa_parsed(
12108 void *parsed_result,
12109 __attribute__((unused)) struct cmdline *cl,
12110 __attribute__((unused)) void *data)
12112 struct cmd_macsec_sa_result *res = parsed_result;
12113 int ret = -ENOTSUP;
12114 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12115 uint8_t key[16] = { 0 };
12121 key_len = strlen(res->key) / 2;
12125 for (i = 0; i < key_len; i++) {
12126 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12129 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12132 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12135 #ifdef RTE_LIBRTE_IXGBE_PMD
12137 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12138 res->idx, res->an, res->pn, key) :
12139 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12140 res->idx, res->an, res->pn, key);
12142 RTE_SET_USED(is_tx);
12149 printf("invalid idx %d or an %d\n", res->idx, res->an);
12152 printf("invalid port_id %d\n", res->port_id);
12155 printf("not supported on port %d\n", res->port_id);
12158 printf("programming error: (%s)\n", strerror(-ret));
12162 cmdline_parse_inst_t cmd_set_macsec_sa = {
12163 .f = cmd_set_macsec_sa_parsed,
12165 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12167 (void *)&cmd_macsec_sa_set,
12168 (void *)&cmd_macsec_sa_macsec,
12169 (void *)&cmd_macsec_sa_sa,
12170 (void *)&cmd_macsec_sa_tx_rx,
12171 (void *)&cmd_macsec_sa_port_id,
12172 (void *)&cmd_macsec_sa_idx,
12173 (void *)&cmd_macsec_sa_an,
12174 (void *)&cmd_macsec_sa_pn,
12175 (void *)&cmd_macsec_sa_key,
12180 /* VF unicast promiscuous mode configuration */
12182 /* Common result structure for VF unicast promiscuous mode */
12183 struct cmd_vf_promisc_result {
12184 cmdline_fixed_string_t set;
12185 cmdline_fixed_string_t vf;
12186 cmdline_fixed_string_t promisc;
12189 cmdline_fixed_string_t on_off;
12192 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12193 cmdline_parse_token_string_t cmd_vf_promisc_set =
12194 TOKEN_STRING_INITIALIZER
12195 (struct cmd_vf_promisc_result,
12197 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12198 TOKEN_STRING_INITIALIZER
12199 (struct cmd_vf_promisc_result,
12201 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12202 TOKEN_STRING_INITIALIZER
12203 (struct cmd_vf_promisc_result,
12204 promisc, "promisc");
12205 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12206 TOKEN_NUM_INITIALIZER
12207 (struct cmd_vf_promisc_result,
12209 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12210 TOKEN_NUM_INITIALIZER
12211 (struct cmd_vf_promisc_result,
12213 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12214 TOKEN_STRING_INITIALIZER
12215 (struct cmd_vf_promisc_result,
12219 cmd_set_vf_promisc_parsed(
12220 void *parsed_result,
12221 __attribute__((unused)) struct cmdline *cl,
12222 __attribute__((unused)) void *data)
12224 struct cmd_vf_promisc_result *res = parsed_result;
12225 int ret = -ENOTSUP;
12227 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12232 #ifdef RTE_LIBRTE_I40E_PMD
12233 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12234 res->vf_id, is_on);
12241 printf("invalid vf_id %d\n", res->vf_id);
12244 printf("invalid port_id %d\n", res->port_id);
12247 printf("function not implemented\n");
12250 printf("programming error: (%s)\n", strerror(-ret));
12254 cmdline_parse_inst_t cmd_set_vf_promisc = {
12255 .f = cmd_set_vf_promisc_parsed,
12257 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12258 "Set unicast promiscuous mode for a VF from the PF",
12260 (void *)&cmd_vf_promisc_set,
12261 (void *)&cmd_vf_promisc_vf,
12262 (void *)&cmd_vf_promisc_promisc,
12263 (void *)&cmd_vf_promisc_port_id,
12264 (void *)&cmd_vf_promisc_vf_id,
12265 (void *)&cmd_vf_promisc_on_off,
12270 /* VF multicast promiscuous mode configuration */
12272 /* Common result structure for VF multicast promiscuous mode */
12273 struct cmd_vf_allmulti_result {
12274 cmdline_fixed_string_t set;
12275 cmdline_fixed_string_t vf;
12276 cmdline_fixed_string_t allmulti;
12279 cmdline_fixed_string_t on_off;
12282 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12283 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12284 TOKEN_STRING_INITIALIZER
12285 (struct cmd_vf_allmulti_result,
12287 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12288 TOKEN_STRING_INITIALIZER
12289 (struct cmd_vf_allmulti_result,
12291 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12292 TOKEN_STRING_INITIALIZER
12293 (struct cmd_vf_allmulti_result,
12294 allmulti, "allmulti");
12295 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12296 TOKEN_NUM_INITIALIZER
12297 (struct cmd_vf_allmulti_result,
12299 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12300 TOKEN_NUM_INITIALIZER
12301 (struct cmd_vf_allmulti_result,
12303 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12304 TOKEN_STRING_INITIALIZER
12305 (struct cmd_vf_allmulti_result,
12309 cmd_set_vf_allmulti_parsed(
12310 void *parsed_result,
12311 __attribute__((unused)) struct cmdline *cl,
12312 __attribute__((unused)) void *data)
12314 struct cmd_vf_allmulti_result *res = parsed_result;
12315 int ret = -ENOTSUP;
12317 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12319 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12322 #ifdef RTE_LIBRTE_I40E_PMD
12323 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12324 res->vf_id, is_on);
12331 printf("invalid vf_id %d\n", res->vf_id);
12334 printf("invalid port_id %d\n", res->port_id);
12337 printf("function not implemented\n");
12340 printf("programming error: (%s)\n", strerror(-ret));
12344 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12345 .f = cmd_set_vf_allmulti_parsed,
12347 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12348 "Set multicast promiscuous mode for a VF from the PF",
12350 (void *)&cmd_vf_allmulti_set,
12351 (void *)&cmd_vf_allmulti_vf,
12352 (void *)&cmd_vf_allmulti_allmulti,
12353 (void *)&cmd_vf_allmulti_port_id,
12354 (void *)&cmd_vf_allmulti_vf_id,
12355 (void *)&cmd_vf_allmulti_on_off,
12360 /* vf broadcast mode configuration */
12362 /* Common result structure for vf broadcast */
12363 struct cmd_set_vf_broadcast_result {
12364 cmdline_fixed_string_t set;
12365 cmdline_fixed_string_t vf;
12366 cmdline_fixed_string_t broadcast;
12369 cmdline_fixed_string_t on_off;
12372 /* Common CLI fields for vf broadcast enable disable */
12373 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_set_vf_broadcast_result,
12377 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_set_vf_broadcast_result,
12381 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_set_vf_broadcast_result,
12384 broadcast, "broadcast");
12385 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12386 TOKEN_NUM_INITIALIZER
12387 (struct cmd_set_vf_broadcast_result,
12389 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12390 TOKEN_NUM_INITIALIZER
12391 (struct cmd_set_vf_broadcast_result,
12393 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12394 TOKEN_STRING_INITIALIZER
12395 (struct cmd_set_vf_broadcast_result,
12399 cmd_set_vf_broadcast_parsed(
12400 void *parsed_result,
12401 __attribute__((unused)) struct cmdline *cl,
12402 __attribute__((unused)) void *data)
12404 struct cmd_set_vf_broadcast_result *res = parsed_result;
12405 int ret = -ENOTSUP;
12407 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12412 #ifdef RTE_LIBRTE_I40E_PMD
12413 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12414 res->vf_id, is_on);
12421 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12424 printf("invalid port_id %d\n", res->port_id);
12427 printf("function not implemented\n");
12430 printf("programming error: (%s)\n", strerror(-ret));
12434 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12435 .f = cmd_set_vf_broadcast_parsed,
12437 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12439 (void *)&cmd_set_vf_broadcast_set,
12440 (void *)&cmd_set_vf_broadcast_vf,
12441 (void *)&cmd_set_vf_broadcast_broadcast,
12442 (void *)&cmd_set_vf_broadcast_port_id,
12443 (void *)&cmd_set_vf_broadcast_vf_id,
12444 (void *)&cmd_set_vf_broadcast_on_off,
12449 /* vf vlan tag configuration */
12451 /* Common result structure for vf vlan tag */
12452 struct cmd_set_vf_vlan_tag_result {
12453 cmdline_fixed_string_t set;
12454 cmdline_fixed_string_t vf;
12455 cmdline_fixed_string_t vlan;
12456 cmdline_fixed_string_t tag;
12459 cmdline_fixed_string_t on_off;
12462 /* Common CLI fields for vf vlan tag enable disable */
12463 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12464 TOKEN_STRING_INITIALIZER
12465 (struct cmd_set_vf_vlan_tag_result,
12467 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12468 TOKEN_STRING_INITIALIZER
12469 (struct cmd_set_vf_vlan_tag_result,
12471 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12472 TOKEN_STRING_INITIALIZER
12473 (struct cmd_set_vf_vlan_tag_result,
12475 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12476 TOKEN_STRING_INITIALIZER
12477 (struct cmd_set_vf_vlan_tag_result,
12479 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12480 TOKEN_NUM_INITIALIZER
12481 (struct cmd_set_vf_vlan_tag_result,
12483 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12484 TOKEN_NUM_INITIALIZER
12485 (struct cmd_set_vf_vlan_tag_result,
12487 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12488 TOKEN_STRING_INITIALIZER
12489 (struct cmd_set_vf_vlan_tag_result,
12493 cmd_set_vf_vlan_tag_parsed(
12494 void *parsed_result,
12495 __attribute__((unused)) struct cmdline *cl,
12496 __attribute__((unused)) void *data)
12498 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12499 int ret = -ENOTSUP;
12501 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12503 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12506 #ifdef RTE_LIBRTE_I40E_PMD
12507 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12508 res->vf_id, is_on);
12515 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12518 printf("invalid port_id %d\n", res->port_id);
12521 printf("function not implemented\n");
12524 printf("programming error: (%s)\n", strerror(-ret));
12528 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12529 .f = cmd_set_vf_vlan_tag_parsed,
12531 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12533 (void *)&cmd_set_vf_vlan_tag_set,
12534 (void *)&cmd_set_vf_vlan_tag_vf,
12535 (void *)&cmd_set_vf_vlan_tag_vlan,
12536 (void *)&cmd_set_vf_vlan_tag_tag,
12537 (void *)&cmd_set_vf_vlan_tag_port_id,
12538 (void *)&cmd_set_vf_vlan_tag_vf_id,
12539 (void *)&cmd_set_vf_vlan_tag_on_off,
12544 /* Common definition of VF and TC TX bandwidth configuration */
12545 struct cmd_vf_tc_bw_result {
12546 cmdline_fixed_string_t set;
12547 cmdline_fixed_string_t vf;
12548 cmdline_fixed_string_t tc;
12549 cmdline_fixed_string_t tx;
12550 cmdline_fixed_string_t min_bw;
12551 cmdline_fixed_string_t max_bw;
12552 cmdline_fixed_string_t strict_link_prio;
12557 cmdline_fixed_string_t bw_list;
12561 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12562 TOKEN_STRING_INITIALIZER
12563 (struct cmd_vf_tc_bw_result,
12565 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12566 TOKEN_STRING_INITIALIZER
12567 (struct cmd_vf_tc_bw_result,
12569 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12570 TOKEN_STRING_INITIALIZER
12571 (struct cmd_vf_tc_bw_result,
12573 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12574 TOKEN_STRING_INITIALIZER
12575 (struct cmd_vf_tc_bw_result,
12577 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12578 TOKEN_STRING_INITIALIZER
12579 (struct cmd_vf_tc_bw_result,
12580 strict_link_prio, "strict-link-priority");
12581 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12582 TOKEN_STRING_INITIALIZER
12583 (struct cmd_vf_tc_bw_result,
12584 min_bw, "min-bandwidth");
12585 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12586 TOKEN_STRING_INITIALIZER
12587 (struct cmd_vf_tc_bw_result,
12588 max_bw, "max-bandwidth");
12589 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12590 TOKEN_NUM_INITIALIZER
12591 (struct cmd_vf_tc_bw_result,
12593 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12594 TOKEN_NUM_INITIALIZER
12595 (struct cmd_vf_tc_bw_result,
12597 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12598 TOKEN_NUM_INITIALIZER
12599 (struct cmd_vf_tc_bw_result,
12601 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12602 TOKEN_NUM_INITIALIZER
12603 (struct cmd_vf_tc_bw_result,
12605 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12606 TOKEN_STRING_INITIALIZER
12607 (struct cmd_vf_tc_bw_result,
12609 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12610 TOKEN_NUM_INITIALIZER
12611 (struct cmd_vf_tc_bw_result,
12614 /* VF max bandwidth setting */
12616 cmd_vf_max_bw_parsed(
12617 void *parsed_result,
12618 __attribute__((unused)) struct cmdline *cl,
12619 __attribute__((unused)) void *data)
12621 struct cmd_vf_tc_bw_result *res = parsed_result;
12622 int ret = -ENOTSUP;
12624 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12627 #ifdef RTE_LIBRTE_I40E_PMD
12628 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12629 res->vf_id, res->bw);
12636 printf("invalid vf_id %d or bandwidth %d\n",
12637 res->vf_id, res->bw);
12640 printf("invalid port_id %d\n", res->port_id);
12643 printf("function not implemented\n");
12646 printf("programming error: (%s)\n", strerror(-ret));
12650 cmdline_parse_inst_t cmd_vf_max_bw = {
12651 .f = cmd_vf_max_bw_parsed,
12653 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12655 (void *)&cmd_vf_tc_bw_set,
12656 (void *)&cmd_vf_tc_bw_vf,
12657 (void *)&cmd_vf_tc_bw_tx,
12658 (void *)&cmd_vf_tc_bw_max_bw,
12659 (void *)&cmd_vf_tc_bw_port_id,
12660 (void *)&cmd_vf_tc_bw_vf_id,
12661 (void *)&cmd_vf_tc_bw_bw,
12667 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12672 const char *p, *p0 = str;
12679 p = strchr(p0, '(');
12681 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12685 p0 = strchr(p, ')');
12687 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12691 if (size >= sizeof(s)) {
12692 printf("The string size exceeds the internal buffer size\n");
12695 snprintf(s, sizeof(s), "%.*s", size, p);
12696 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12698 printf("Failed to get the bandwidth list. ");
12702 for (i = 0; i < ret; i++)
12703 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12708 /* TC min bandwidth setting */
12710 cmd_vf_tc_min_bw_parsed(
12711 void *parsed_result,
12712 __attribute__((unused)) struct cmdline *cl,
12713 __attribute__((unused)) void *data)
12715 struct cmd_vf_tc_bw_result *res = parsed_result;
12718 int ret = -ENOTSUP;
12720 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12723 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12727 #ifdef RTE_LIBRTE_I40E_PMD
12728 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12736 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12739 printf("invalid port_id %d\n", res->port_id);
12742 printf("function not implemented\n");
12745 printf("programming error: (%s)\n", strerror(-ret));
12749 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12750 .f = cmd_vf_tc_min_bw_parsed,
12752 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12753 " <bw1, bw2, ...>",
12755 (void *)&cmd_vf_tc_bw_set,
12756 (void *)&cmd_vf_tc_bw_vf,
12757 (void *)&cmd_vf_tc_bw_tc,
12758 (void *)&cmd_vf_tc_bw_tx,
12759 (void *)&cmd_vf_tc_bw_min_bw,
12760 (void *)&cmd_vf_tc_bw_port_id,
12761 (void *)&cmd_vf_tc_bw_vf_id,
12762 (void *)&cmd_vf_tc_bw_bw_list,
12768 cmd_tc_min_bw_parsed(
12769 void *parsed_result,
12770 __attribute__((unused)) struct cmdline *cl,
12771 __attribute__((unused)) void *data)
12773 struct cmd_vf_tc_bw_result *res = parsed_result;
12774 struct rte_port *port;
12777 int ret = -ENOTSUP;
12779 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12782 port = &ports[res->port_id];
12783 /** Check if the port is not started **/
12784 if (port->port_status != RTE_PORT_STOPPED) {
12785 printf("Please stop port %d first\n", res->port_id);
12789 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12793 #ifdef RTE_LIBRTE_IXGBE_PMD
12794 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12801 printf("invalid bandwidth\n");
12804 printf("invalid port_id %d\n", res->port_id);
12807 printf("function not implemented\n");
12810 printf("programming error: (%s)\n", strerror(-ret));
12814 cmdline_parse_inst_t cmd_tc_min_bw = {
12815 .f = cmd_tc_min_bw_parsed,
12817 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12819 (void *)&cmd_vf_tc_bw_set,
12820 (void *)&cmd_vf_tc_bw_tc,
12821 (void *)&cmd_vf_tc_bw_tx,
12822 (void *)&cmd_vf_tc_bw_min_bw,
12823 (void *)&cmd_vf_tc_bw_port_id,
12824 (void *)&cmd_vf_tc_bw_bw_list,
12829 /* TC max bandwidth setting */
12831 cmd_vf_tc_max_bw_parsed(
12832 void *parsed_result,
12833 __attribute__((unused)) struct cmdline *cl,
12834 __attribute__((unused)) void *data)
12836 struct cmd_vf_tc_bw_result *res = parsed_result;
12837 int ret = -ENOTSUP;
12839 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12842 #ifdef RTE_LIBRTE_I40E_PMD
12843 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12844 res->tc_no, res->bw);
12851 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12852 res->vf_id, res->tc_no, res->bw);
12855 printf("invalid port_id %d\n", res->port_id);
12858 printf("function not implemented\n");
12861 printf("programming error: (%s)\n", strerror(-ret));
12865 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12866 .f = cmd_vf_tc_max_bw_parsed,
12868 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12871 (void *)&cmd_vf_tc_bw_set,
12872 (void *)&cmd_vf_tc_bw_vf,
12873 (void *)&cmd_vf_tc_bw_tc,
12874 (void *)&cmd_vf_tc_bw_tx,
12875 (void *)&cmd_vf_tc_bw_max_bw,
12876 (void *)&cmd_vf_tc_bw_port_id,
12877 (void *)&cmd_vf_tc_bw_vf_id,
12878 (void *)&cmd_vf_tc_bw_tc_no,
12879 (void *)&cmd_vf_tc_bw_bw,
12884 /* Strict link priority scheduling mode setting */
12886 cmd_strict_link_prio_parsed(
12887 void *parsed_result,
12888 __attribute__((unused)) struct cmdline *cl,
12889 __attribute__((unused)) void *data)
12891 struct cmd_vf_tc_bw_result *res = parsed_result;
12892 int ret = -ENOTSUP;
12894 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12897 #ifdef RTE_LIBRTE_I40E_PMD
12898 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12905 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12908 printf("invalid port_id %d\n", res->port_id);
12911 printf("function not implemented\n");
12914 printf("programming error: (%s)\n", strerror(-ret));
12918 cmdline_parse_inst_t cmd_strict_link_prio = {
12919 .f = cmd_strict_link_prio_parsed,
12921 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12923 (void *)&cmd_vf_tc_bw_set,
12924 (void *)&cmd_vf_tc_bw_tx,
12925 (void *)&cmd_vf_tc_bw_strict_link_prio,
12926 (void *)&cmd_vf_tc_bw_port_id,
12927 (void *)&cmd_vf_tc_bw_tc_map,
12932 /* Load dynamic device personalization*/
12933 struct cmd_ddp_add_result {
12934 cmdline_fixed_string_t ddp;
12935 cmdline_fixed_string_t add;
12940 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12941 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12942 cmdline_parse_token_string_t cmd_ddp_add_add =
12943 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12944 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12945 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12946 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12947 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12950 cmd_ddp_add_parsed(
12951 void *parsed_result,
12952 __attribute__((unused)) struct cmdline *cl,
12953 __attribute__((unused)) void *data)
12955 struct cmd_ddp_add_result *res = parsed_result;
12961 int ret = -ENOTSUP;
12963 if (res->port_id > nb_ports) {
12964 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12968 if (!all_ports_stopped()) {
12969 printf("Please stop all ports first\n");
12973 filepath = strdup(res->filepath);
12974 if (filepath == NULL) {
12975 printf("Failed to allocate memory\n");
12978 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
12980 buff = open_ddp_package_file(file_fld[0], &size);
12982 free((void *)filepath);
12986 #ifdef RTE_LIBRTE_I40E_PMD
12987 if (ret == -ENOTSUP)
12988 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12990 RTE_PMD_I40E_PKG_OP_WR_ADD);
12993 if (ret == -EEXIST)
12994 printf("Profile has already existed.\n");
12996 printf("Failed to load profile.\n");
12997 else if (file_num == 2)
12998 save_ddp_package_file(file_fld[1], buff, size);
13000 close_ddp_package_file(buff);
13001 free((void *)filepath);
13004 cmdline_parse_inst_t cmd_ddp_add = {
13005 .f = cmd_ddp_add_parsed,
13007 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13009 (void *)&cmd_ddp_add_ddp,
13010 (void *)&cmd_ddp_add_add,
13011 (void *)&cmd_ddp_add_port_id,
13012 (void *)&cmd_ddp_add_filepath,
13017 /* Get dynamic device personalization profile info */
13018 struct cmd_ddp_info_result {
13019 cmdline_fixed_string_t ddp;
13020 cmdline_fixed_string_t get;
13021 cmdline_fixed_string_t info;
13025 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13026 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13027 cmdline_parse_token_string_t cmd_ddp_info_get =
13028 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13029 cmdline_parse_token_string_t cmd_ddp_info_info =
13030 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13031 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13032 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13035 cmd_ddp_info_parsed(
13036 void *parsed_result,
13037 __attribute__((unused)) struct cmdline *cl,
13038 __attribute__((unused)) void *data)
13040 struct cmd_ddp_info_result *res = parsed_result;
13043 int ret = -ENOTSUP;
13044 #ifdef RTE_LIBRTE_I40E_PMD
13047 uint32_t buff_size;
13048 struct rte_pmd_i40e_profile_info info;
13050 struct rte_pmd_i40e_ddp_device_id *devs;
13053 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13057 #ifdef RTE_LIBRTE_I40E_PMD
13058 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13059 (uint8_t *)&info, sizeof(info),
13060 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13062 printf("Global Track id: 0x%x\n", info.track_id);
13063 printf("Global Version: %d.%d.%d.%d\n",
13064 info.version.major,
13065 info.version.minor,
13066 info.version.update,
13067 info.version.draft);
13068 printf("Global Package name: %s\n\n", info.name);
13071 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13072 (uint8_t *)&info, sizeof(info),
13073 RTE_PMD_I40E_PKG_INFO_HEADER);
13075 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13076 printf("i40e Profile Version: %d.%d.%d.%d\n",
13077 info.version.major,
13078 info.version.minor,
13079 info.version.update,
13080 info.version.draft);
13081 printf("i40e Profile name: %s\n\n", info.name);
13084 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13085 (uint8_t *)&buff_size, sizeof(buff_size),
13086 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13087 if (!ret && buff_size) {
13088 buff = (uint8_t *)malloc(buff_size);
13090 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13092 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13094 printf("Package Notes:\n%s\n\n", buff);
13099 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13100 (uint8_t *)&dev_num, sizeof(dev_num),
13101 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13102 if (!ret && dev_num) {
13103 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
13104 sizeof(struct rte_pmd_i40e_ddp_device_id));
13106 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13107 (uint8_t *)devs, dev_num *
13108 sizeof(struct rte_pmd_i40e_ddp_device_id),
13109 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13111 printf("List of supported devices:\n");
13112 for (i = 0; i < dev_num; i++) {
13113 printf(" %04X:%04X %04X:%04X\n",
13114 devs[i].vendor_dev_id >> 16,
13115 devs[i].vendor_dev_id & 0xFFFF,
13116 devs[i].sub_vendor_dev_id >> 16,
13117 devs[i].sub_vendor_dev_id & 0xFFFF);
13126 if (ret == -ENOTSUP)
13127 printf("Function not supported in PMD driver\n");
13128 close_ddp_package_file(pkg);
13131 cmdline_parse_inst_t cmd_ddp_get_info = {
13132 .f = cmd_ddp_info_parsed,
13134 .help_str = "ddp get info <profile_path>",
13136 (void *)&cmd_ddp_info_ddp,
13137 (void *)&cmd_ddp_info_get,
13138 (void *)&cmd_ddp_info_info,
13139 (void *)&cmd_ddp_info_filepath,
13144 /* Get dynamic device personalization profile info list*/
13145 #define PROFILE_INFO_SIZE 48
13146 #define MAX_PROFILE_NUM 16
13148 struct cmd_ddp_get_list_result {
13149 cmdline_fixed_string_t ddp;
13150 cmdline_fixed_string_t get;
13151 cmdline_fixed_string_t list;
13155 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13156 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13157 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13158 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13159 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13160 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13161 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13162 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13165 cmd_ddp_get_list_parsed(
13166 void *parsed_result,
13167 __attribute__((unused)) struct cmdline *cl,
13168 __attribute__((unused)) void *data)
13170 struct cmd_ddp_get_list_result *res = parsed_result;
13171 #ifdef RTE_LIBRTE_I40E_PMD
13172 struct rte_pmd_i40e_profile_list *p_list;
13173 struct rte_pmd_i40e_profile_info *p_info;
13178 int ret = -ENOTSUP;
13180 if (res->port_id > nb_ports) {
13181 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13185 #ifdef RTE_LIBRTE_I40E_PMD
13186 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13187 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13189 printf("%s: Failed to malloc buffer\n", __func__);
13191 if (ret == -ENOTSUP)
13192 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13193 (uint8_t *)p_list, size);
13196 p_num = p_list->p_count;
13197 printf("Profile number is: %d\n\n", p_num);
13199 for (i = 0; i < p_num; i++) {
13200 p_info = &p_list->p_info[i];
13201 printf("Profile %d:\n", i);
13202 printf("Track id: 0x%x\n", p_info->track_id);
13203 printf("Version: %d.%d.%d.%d\n",
13204 p_info->version.major,
13205 p_info->version.minor,
13206 p_info->version.update,
13207 p_info->version.draft);
13208 printf("Profile name: %s\n\n", p_info->name);
13216 printf("Failed to get ddp list\n");
13219 cmdline_parse_inst_t cmd_ddp_get_list = {
13220 .f = cmd_ddp_get_list_parsed,
13222 .help_str = "ddp get list <port_id>",
13224 (void *)&cmd_ddp_get_list_ddp,
13225 (void *)&cmd_ddp_get_list_get,
13226 (void *)&cmd_ddp_get_list_list,
13227 (void *)&cmd_ddp_get_list_port_id,
13232 /* show vf stats */
13234 /* Common result structure for show vf stats */
13235 struct cmd_show_vf_stats_result {
13236 cmdline_fixed_string_t show;
13237 cmdline_fixed_string_t vf;
13238 cmdline_fixed_string_t stats;
13243 /* Common CLI fields show vf stats*/
13244 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13245 TOKEN_STRING_INITIALIZER
13246 (struct cmd_show_vf_stats_result,
13248 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13249 TOKEN_STRING_INITIALIZER
13250 (struct cmd_show_vf_stats_result,
13252 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13253 TOKEN_STRING_INITIALIZER
13254 (struct cmd_show_vf_stats_result,
13256 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13257 TOKEN_NUM_INITIALIZER
13258 (struct cmd_show_vf_stats_result,
13260 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13261 TOKEN_NUM_INITIALIZER
13262 (struct cmd_show_vf_stats_result,
13266 cmd_show_vf_stats_parsed(
13267 void *parsed_result,
13268 __attribute__((unused)) struct cmdline *cl,
13269 __attribute__((unused)) void *data)
13271 struct cmd_show_vf_stats_result *res = parsed_result;
13272 struct rte_eth_stats stats;
13273 int ret = -ENOTSUP;
13274 static const char *nic_stats_border = "########################";
13276 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13279 memset(&stats, 0, sizeof(stats));
13281 #ifdef RTE_LIBRTE_I40E_PMD
13282 if (ret == -ENOTSUP)
13283 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13287 #ifdef RTE_LIBRTE_BNXT_PMD
13288 if (ret == -ENOTSUP)
13289 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13298 printf("invalid vf_id %d\n", res->vf_id);
13301 printf("invalid port_id %d\n", res->port_id);
13304 printf("function not implemented\n");
13307 printf("programming error: (%s)\n", strerror(-ret));
13310 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13311 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13313 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13315 stats.ipackets, stats.imissed, stats.ibytes);
13316 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13317 printf(" RX-nombuf: %-10"PRIu64"\n",
13319 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13321 stats.opackets, stats.oerrors, stats.obytes);
13323 printf(" %s############################%s\n",
13324 nic_stats_border, nic_stats_border);
13327 cmdline_parse_inst_t cmd_show_vf_stats = {
13328 .f = cmd_show_vf_stats_parsed,
13330 .help_str = "show vf stats <port_id> <vf_id>",
13332 (void *)&cmd_show_vf_stats_show,
13333 (void *)&cmd_show_vf_stats_vf,
13334 (void *)&cmd_show_vf_stats_stats,
13335 (void *)&cmd_show_vf_stats_port_id,
13336 (void *)&cmd_show_vf_stats_vf_id,
13341 /* clear vf stats */
13343 /* Common result structure for clear vf stats */
13344 struct cmd_clear_vf_stats_result {
13345 cmdline_fixed_string_t clear;
13346 cmdline_fixed_string_t vf;
13347 cmdline_fixed_string_t stats;
13352 /* Common CLI fields clear vf stats*/
13353 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13354 TOKEN_STRING_INITIALIZER
13355 (struct cmd_clear_vf_stats_result,
13357 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13358 TOKEN_STRING_INITIALIZER
13359 (struct cmd_clear_vf_stats_result,
13361 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13362 TOKEN_STRING_INITIALIZER
13363 (struct cmd_clear_vf_stats_result,
13365 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13366 TOKEN_NUM_INITIALIZER
13367 (struct cmd_clear_vf_stats_result,
13369 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13370 TOKEN_NUM_INITIALIZER
13371 (struct cmd_clear_vf_stats_result,
13375 cmd_clear_vf_stats_parsed(
13376 void *parsed_result,
13377 __attribute__((unused)) struct cmdline *cl,
13378 __attribute__((unused)) void *data)
13380 struct cmd_clear_vf_stats_result *res = parsed_result;
13381 int ret = -ENOTSUP;
13383 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13386 #ifdef RTE_LIBRTE_I40E_PMD
13387 if (ret == -ENOTSUP)
13388 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13391 #ifdef RTE_LIBRTE_BNXT_PMD
13392 if (ret == -ENOTSUP)
13393 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13401 printf("invalid vf_id %d\n", res->vf_id);
13404 printf("invalid port_id %d\n", res->port_id);
13407 printf("function not implemented\n");
13410 printf("programming error: (%s)\n", strerror(-ret));
13414 cmdline_parse_inst_t cmd_clear_vf_stats = {
13415 .f = cmd_clear_vf_stats_parsed,
13417 .help_str = "clear vf stats <port_id> <vf_id>",
13419 (void *)&cmd_clear_vf_stats_clear,
13420 (void *)&cmd_clear_vf_stats_vf,
13421 (void *)&cmd_clear_vf_stats_stats,
13422 (void *)&cmd_clear_vf_stats_port_id,
13423 (void *)&cmd_clear_vf_stats_vf_id,
13428 /* ptype mapping get */
13430 /* Common result structure for ptype mapping get */
13431 struct cmd_ptype_mapping_get_result {
13432 cmdline_fixed_string_t ptype;
13433 cmdline_fixed_string_t mapping;
13434 cmdline_fixed_string_t get;
13436 uint8_t valid_only;
13439 /* Common CLI fields for ptype mapping get */
13440 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13441 TOKEN_STRING_INITIALIZER
13442 (struct cmd_ptype_mapping_get_result,
13444 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13445 TOKEN_STRING_INITIALIZER
13446 (struct cmd_ptype_mapping_get_result,
13447 mapping, "mapping");
13448 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13449 TOKEN_STRING_INITIALIZER
13450 (struct cmd_ptype_mapping_get_result,
13452 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13453 TOKEN_NUM_INITIALIZER
13454 (struct cmd_ptype_mapping_get_result,
13456 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13457 TOKEN_NUM_INITIALIZER
13458 (struct cmd_ptype_mapping_get_result,
13459 valid_only, UINT8);
13462 cmd_ptype_mapping_get_parsed(
13463 void *parsed_result,
13464 __attribute__((unused)) struct cmdline *cl,
13465 __attribute__((unused)) void *data)
13467 struct cmd_ptype_mapping_get_result *res = parsed_result;
13468 int ret = -ENOTSUP;
13469 #ifdef RTE_LIBRTE_I40E_PMD
13470 int max_ptype_num = 256;
13471 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13476 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13479 #ifdef RTE_LIBRTE_I40E_PMD
13480 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13491 printf("invalid port_id %d\n", res->port_id);
13494 printf("function not implemented\n");
13497 printf("programming error: (%s)\n", strerror(-ret));
13500 #ifdef RTE_LIBRTE_I40E_PMD
13502 for (i = 0; i < count; i++)
13503 printf("%3d\t0x%08x\n",
13504 mapping[i].hw_ptype, mapping[i].sw_ptype);
13509 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13510 .f = cmd_ptype_mapping_get_parsed,
13512 .help_str = "ptype mapping get <port_id> <valid_only>",
13514 (void *)&cmd_ptype_mapping_get_ptype,
13515 (void *)&cmd_ptype_mapping_get_mapping,
13516 (void *)&cmd_ptype_mapping_get_get,
13517 (void *)&cmd_ptype_mapping_get_port_id,
13518 (void *)&cmd_ptype_mapping_get_valid_only,
13523 /* ptype mapping replace */
13525 /* Common result structure for ptype mapping replace */
13526 struct cmd_ptype_mapping_replace_result {
13527 cmdline_fixed_string_t ptype;
13528 cmdline_fixed_string_t mapping;
13529 cmdline_fixed_string_t replace;
13536 /* Common CLI fields for ptype mapping replace */
13537 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_ptype_mapping_replace_result,
13541 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13542 TOKEN_STRING_INITIALIZER
13543 (struct cmd_ptype_mapping_replace_result,
13544 mapping, "mapping");
13545 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13546 TOKEN_STRING_INITIALIZER
13547 (struct cmd_ptype_mapping_replace_result,
13548 replace, "replace");
13549 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13550 TOKEN_NUM_INITIALIZER
13551 (struct cmd_ptype_mapping_replace_result,
13553 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13554 TOKEN_NUM_INITIALIZER
13555 (struct cmd_ptype_mapping_replace_result,
13557 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13558 TOKEN_NUM_INITIALIZER
13559 (struct cmd_ptype_mapping_replace_result,
13561 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13562 TOKEN_NUM_INITIALIZER
13563 (struct cmd_ptype_mapping_replace_result,
13567 cmd_ptype_mapping_replace_parsed(
13568 void *parsed_result,
13569 __attribute__((unused)) struct cmdline *cl,
13570 __attribute__((unused)) void *data)
13572 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13573 int ret = -ENOTSUP;
13575 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13578 #ifdef RTE_LIBRTE_I40E_PMD
13579 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13589 printf("invalid ptype 0x%8x or 0x%8x\n",
13590 res->target, res->pkt_type);
13593 printf("invalid port_id %d\n", res->port_id);
13596 printf("function not implemented\n");
13599 printf("programming error: (%s)\n", strerror(-ret));
13603 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13604 .f = cmd_ptype_mapping_replace_parsed,
13607 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13609 (void *)&cmd_ptype_mapping_replace_ptype,
13610 (void *)&cmd_ptype_mapping_replace_mapping,
13611 (void *)&cmd_ptype_mapping_replace_replace,
13612 (void *)&cmd_ptype_mapping_replace_port_id,
13613 (void *)&cmd_ptype_mapping_replace_target,
13614 (void *)&cmd_ptype_mapping_replace_mask,
13615 (void *)&cmd_ptype_mapping_replace_pkt_type,
13620 /* ptype mapping reset */
13622 /* Common result structure for ptype mapping reset */
13623 struct cmd_ptype_mapping_reset_result {
13624 cmdline_fixed_string_t ptype;
13625 cmdline_fixed_string_t mapping;
13626 cmdline_fixed_string_t reset;
13630 /* Common CLI fields for ptype mapping reset*/
13631 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
13632 TOKEN_STRING_INITIALIZER
13633 (struct cmd_ptype_mapping_reset_result,
13635 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
13636 TOKEN_STRING_INITIALIZER
13637 (struct cmd_ptype_mapping_reset_result,
13638 mapping, "mapping");
13639 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
13640 TOKEN_STRING_INITIALIZER
13641 (struct cmd_ptype_mapping_reset_result,
13643 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
13644 TOKEN_NUM_INITIALIZER
13645 (struct cmd_ptype_mapping_reset_result,
13649 cmd_ptype_mapping_reset_parsed(
13650 void *parsed_result,
13651 __attribute__((unused)) struct cmdline *cl,
13652 __attribute__((unused)) void *data)
13654 struct cmd_ptype_mapping_reset_result *res = parsed_result;
13655 int ret = -ENOTSUP;
13657 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13660 #ifdef RTE_LIBRTE_I40E_PMD
13661 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
13668 printf("invalid port_id %d\n", res->port_id);
13671 printf("function not implemented\n");
13674 printf("programming error: (%s)\n", strerror(-ret));
13678 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
13679 .f = cmd_ptype_mapping_reset_parsed,
13681 .help_str = "ptype mapping reset <port_id>",
13683 (void *)&cmd_ptype_mapping_reset_ptype,
13684 (void *)&cmd_ptype_mapping_reset_mapping,
13685 (void *)&cmd_ptype_mapping_reset_reset,
13686 (void *)&cmd_ptype_mapping_reset_port_id,
13691 /* ptype mapping update */
13693 /* Common result structure for ptype mapping update */
13694 struct cmd_ptype_mapping_update_result {
13695 cmdline_fixed_string_t ptype;
13696 cmdline_fixed_string_t mapping;
13697 cmdline_fixed_string_t reset;
13703 /* Common CLI fields for ptype mapping update*/
13704 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
13705 TOKEN_STRING_INITIALIZER
13706 (struct cmd_ptype_mapping_update_result,
13708 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
13709 TOKEN_STRING_INITIALIZER
13710 (struct cmd_ptype_mapping_update_result,
13711 mapping, "mapping");
13712 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
13713 TOKEN_STRING_INITIALIZER
13714 (struct cmd_ptype_mapping_update_result,
13716 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
13717 TOKEN_NUM_INITIALIZER
13718 (struct cmd_ptype_mapping_update_result,
13720 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
13721 TOKEN_NUM_INITIALIZER
13722 (struct cmd_ptype_mapping_update_result,
13724 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
13725 TOKEN_NUM_INITIALIZER
13726 (struct cmd_ptype_mapping_update_result,
13730 cmd_ptype_mapping_update_parsed(
13731 void *parsed_result,
13732 __attribute__((unused)) struct cmdline *cl,
13733 __attribute__((unused)) void *data)
13735 struct cmd_ptype_mapping_update_result *res = parsed_result;
13736 int ret = -ENOTSUP;
13737 #ifdef RTE_LIBRTE_I40E_PMD
13738 struct rte_pmd_i40e_ptype_mapping mapping;
13740 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13743 #ifdef RTE_LIBRTE_I40E_PMD
13744 mapping.hw_ptype = res->hw_ptype;
13745 mapping.sw_ptype = res->sw_ptype;
13746 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
13756 printf("invalid ptype 0x%8x\n", res->sw_ptype);
13759 printf("invalid port_id %d\n", res->port_id);
13762 printf("function not implemented\n");
13765 printf("programming error: (%s)\n", strerror(-ret));
13769 cmdline_parse_inst_t cmd_ptype_mapping_update = {
13770 .f = cmd_ptype_mapping_update_parsed,
13772 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
13774 (void *)&cmd_ptype_mapping_update_ptype,
13775 (void *)&cmd_ptype_mapping_update_mapping,
13776 (void *)&cmd_ptype_mapping_update_update,
13777 (void *)&cmd_ptype_mapping_update_port_id,
13778 (void *)&cmd_ptype_mapping_update_hw_ptype,
13779 (void *)&cmd_ptype_mapping_update_sw_ptype,
13784 /* Common result structure for file commands */
13785 struct cmd_cmdfile_result {
13786 cmdline_fixed_string_t load;
13787 cmdline_fixed_string_t filename;
13790 /* Common CLI fields for file commands */
13791 cmdline_parse_token_string_t cmd_load_cmdfile =
13792 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
13793 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
13794 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
13797 cmd_load_from_file_parsed(
13798 void *parsed_result,
13799 __attribute__((unused)) struct cmdline *cl,
13800 __attribute__((unused)) void *data)
13802 struct cmd_cmdfile_result *res = parsed_result;
13804 cmdline_read_from_file(res->filename);
13807 cmdline_parse_inst_t cmd_load_from_file = {
13808 .f = cmd_load_from_file_parsed,
13810 .help_str = "load <filename>",
13812 (void *)&cmd_load_cmdfile,
13813 (void *)&cmd_load_cmdfile_filename,
13818 /* ******************************************************************************** */
13820 /* list of instructions */
13821 cmdline_parse_ctx_t main_ctx[] = {
13822 (cmdline_parse_inst_t *)&cmd_help_brief,
13823 (cmdline_parse_inst_t *)&cmd_help_long,
13824 (cmdline_parse_inst_t *)&cmd_quit,
13825 (cmdline_parse_inst_t *)&cmd_load_from_file,
13826 (cmdline_parse_inst_t *)&cmd_showport,
13827 (cmdline_parse_inst_t *)&cmd_showqueue,
13828 (cmdline_parse_inst_t *)&cmd_showportall,
13829 (cmdline_parse_inst_t *)&cmd_showcfg,
13830 (cmdline_parse_inst_t *)&cmd_start,
13831 (cmdline_parse_inst_t *)&cmd_start_tx_first,
13832 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13833 (cmdline_parse_inst_t *)&cmd_set_link_up,
13834 (cmdline_parse_inst_t *)&cmd_set_link_down,
13835 (cmdline_parse_inst_t *)&cmd_reset,
13836 (cmdline_parse_inst_t *)&cmd_set_numbers,
13837 (cmdline_parse_inst_t *)&cmd_set_txpkts,
13838 (cmdline_parse_inst_t *)&cmd_set_txsplit,
13839 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13840 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13841 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13842 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13843 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13844 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13845 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13846 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13847 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13848 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13849 (cmdline_parse_inst_t *)&cmd_set_link_check,
13850 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13851 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13852 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13853 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13854 #ifdef RTE_LIBRTE_PMD_BOND
13855 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13856 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13857 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13858 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13859 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13860 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13861 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13862 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13863 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13865 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13866 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13867 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13868 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13869 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13870 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13871 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13872 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13873 (cmdline_parse_inst_t *)&cmd_csum_set,
13874 (cmdline_parse_inst_t *)&cmd_csum_show,
13875 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13876 (cmdline_parse_inst_t *)&cmd_tso_set,
13877 (cmdline_parse_inst_t *)&cmd_tso_show,
13878 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13879 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13880 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13881 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13882 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13883 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13884 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13885 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13886 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13887 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13888 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13889 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13890 (cmdline_parse_inst_t *)&cmd_config_dcb,
13891 (cmdline_parse_inst_t *)&cmd_read_reg,
13892 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13893 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13894 (cmdline_parse_inst_t *)&cmd_write_reg,
13895 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13896 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13897 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13898 (cmdline_parse_inst_t *)&cmd_stop,
13899 (cmdline_parse_inst_t *)&cmd_mac_addr,
13900 (cmdline_parse_inst_t *)&cmd_set_qmap,
13901 (cmdline_parse_inst_t *)&cmd_operate_port,
13902 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13903 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13904 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13905 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13906 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13907 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13908 (cmdline_parse_inst_t *)&cmd_config_mtu,
13909 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13910 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13911 (cmdline_parse_inst_t *)&cmd_config_rss,
13912 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13913 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13914 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13915 (cmdline_parse_inst_t *)&cmd_showport_reta,
13916 (cmdline_parse_inst_t *)&cmd_config_burst,
13917 (cmdline_parse_inst_t *)&cmd_config_thresh,
13918 (cmdline_parse_inst_t *)&cmd_config_threshold,
13919 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13920 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13921 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13922 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13923 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13924 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13925 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13926 (cmdline_parse_inst_t *)&cmd_global_config,
13927 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13928 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13929 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13930 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13931 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13932 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13933 (cmdline_parse_inst_t *)&cmd_dump,
13934 (cmdline_parse_inst_t *)&cmd_dump_one,
13935 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13936 (cmdline_parse_inst_t *)&cmd_syn_filter,
13937 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13938 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13939 (cmdline_parse_inst_t *)&cmd_flex_filter,
13940 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13941 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13942 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13943 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13944 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13945 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13946 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13947 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13948 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13949 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13950 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13951 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13952 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13953 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13954 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13955 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13956 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13957 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13958 (cmdline_parse_inst_t *)&cmd_flow,
13959 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13960 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13961 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13962 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13963 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13964 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13965 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13966 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13967 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13968 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13969 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13970 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13971 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13972 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13973 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13974 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13975 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13976 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13977 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13978 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13979 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13980 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13981 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13982 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13983 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13984 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13985 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13986 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13987 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13988 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13989 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13990 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13991 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13992 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13993 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13994 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
13995 (cmdline_parse_inst_t *)&cmd_ddp_add,
13996 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13997 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
13998 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13999 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
14000 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
14001 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
14002 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
14003 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
14007 /* read cmdline commands from file */
14009 cmdline_read_from_file(const char *filename)
14011 struct cmdline *cl;
14013 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14015 printf("Failed to create file based cmdline context: %s\n",
14020 cmdline_interact(cl);
14025 printf("Read CLI commands from %s\n", filename);
14028 /* prompt function, called from main on MASTER lcore */
14032 /* initialize non-constant commands */
14033 cmd_set_fwd_mode_init();
14034 cmd_set_fwd_retry_mode_init();
14036 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14037 if (testpmd_cl == NULL)
14039 cmdline_interact(testpmd_cl);
14040 cmdline_stdin_exit(testpmd_cl);
14046 if (testpmd_cl != NULL)
14047 cmdline_quit(testpmd_cl);
14051 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14053 if (id == (portid_t)RTE_PORT_ALL) {
14056 RTE_ETH_FOREACH_DEV(pid) {
14057 /* check if need_reconfig has been set to 1 */
14058 if (ports[pid].need_reconfig == 0)
14059 ports[pid].need_reconfig = dev;
14060 /* check if need_reconfig_queues has been set to 1 */
14061 if (ports[pid].need_reconfig_queues == 0)
14062 ports[pid].need_reconfig_queues = queue;
14064 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14065 /* check if need_reconfig has been set to 1 */
14066 if (ports[id].need_reconfig == 0)
14067 ports[id].need_reconfig = dev;
14068 /* check if need_reconfig_queues has been set to 1 */
14069 if (ports[id].need_reconfig_queues == 0)
14070 ports[id].need_reconfig_queues = queue;