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>
90 #include <rte_eth_bond_8023ad.h>
92 #ifdef RTE_LIBRTE_IXGBE_PMD
93 #include <rte_pmd_ixgbe.h>
95 #ifdef RTE_LIBRTE_I40E_PMD
96 #include <rte_pmd_i40e.h>
98 #ifdef RTE_LIBRTE_BNXT_PMD
99 #include <rte_pmd_bnxt.h>
103 static struct cmdline *testpmd_cl;
105 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
107 /* *** Help command with introduction. *** */
108 struct cmd_help_brief_result {
109 cmdline_fixed_string_t help;
112 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
114 __attribute__((unused)) void *data)
119 "Help is available for the following sections:\n\n"
120 " help control : Start and stop forwarding.\n"
121 " help display : Displaying port, stats and config "
123 " help config : Configuration information.\n"
124 " help ports : Configuring ports.\n"
125 " help registers : Reading and setting port registers.\n"
126 " help filters : Filters configuration help.\n"
127 " help all : All of the above sections.\n\n"
132 cmdline_parse_token_string_t cmd_help_brief_help =
133 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
135 cmdline_parse_inst_t cmd_help_brief = {
136 .f = cmd_help_brief_parsed,
138 .help_str = "help: Show help",
140 (void *)&cmd_help_brief_help,
145 /* *** Help command with help sections. *** */
146 struct cmd_help_long_result {
147 cmdline_fixed_string_t help;
148 cmdline_fixed_string_t section;
151 static void cmd_help_long_parsed(void *parsed_result,
153 __attribute__((unused)) void *data)
156 struct cmd_help_long_result *res = parsed_result;
158 if (!strcmp(res->section, "all"))
161 if (show_all || !strcmp(res->section, "control")) {
166 "Control forwarding:\n"
167 "-------------------\n\n"
170 " Start packet forwarding with current configuration.\n\n"
173 " Start packet forwarding with current config"
174 " after sending one burst of packets.\n\n"
177 " Stop packet forwarding, and display accumulated"
181 " Quit to prompt.\n\n"
185 if (show_all || !strcmp(res->section, "display")) {
193 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
194 " Display information for port_id, or all.\n\n"
196 "show port X rss reta (size) (mask0,mask1,...)\n"
197 " Display the rss redirection table entry indicated"
198 " by masks on port X. size is used to indicate the"
199 " hardware supported reta size\n\n"
201 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
202 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
203 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
204 " Display the RSS hash functions and RSS hash key"
207 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
208 " Clear information for port_id, or all.\n\n"
210 "show (rxq|txq) info (port_id) (queue_id)\n"
211 " Display information for configured RX/TX queue.\n\n"
213 "show config (rxtx|cores|fwd|txpkts)\n"
214 " Display the given configuration.\n\n"
216 "read rxd (port_id) (queue_id) (rxd_id)\n"
217 " Display an RX descriptor of a port RX queue.\n\n"
219 "read txd (port_id) (queue_id) (txd_id)\n"
220 " Display a TX descriptor of a port TX queue.\n\n"
222 "ddp get list (port_id)\n"
223 " Get ddp profile info list\n\n"
225 "ddp get info (profile_path)\n"
226 " Get ddp profile information.\n\n"
228 "show vf stats (port_id) (vf_id)\n"
229 " Display a VF's statistics.\n\n"
231 "clear vf stats (port_id) (vf_id)\n"
232 " Reset a VF's statistics.\n\n"
236 if (show_all || !strcmp(res->section, "config")) {
242 "Configuration changes only become active when"
243 " forwarding is started/restarted.\n\n"
246 " Reset forwarding to the default configuration.\n\n"
248 "set verbose (level)\n"
249 " Set the debug verbosity level X.\n\n"
252 " Set number of ports.\n\n"
255 " Set number of cores.\n\n"
257 "set coremask (mask)\n"
258 " Set the forwarding cores hexadecimal mask.\n\n"
260 "set portmask (mask)\n"
261 " Set the forwarding ports hexadecimal mask.\n\n"
264 " Set number of packets per burst.\n\n"
266 "set burst tx delay (microseconds) retry (num)\n"
267 " Set the transmit delay time and number of retries,"
268 " effective when retry is enabled.\n\n"
270 "set txpkts (x[,y]*)\n"
271 " Set the length of each segment of TXONLY"
272 " and optionally CSUM packets.\n\n"
274 "set txsplit (off|on|rand)\n"
275 " Set the split policy for the TX packets."
276 " Right now only applicable for CSUM and TXONLY"
279 "set corelist (x[,y]*)\n"
280 " Set the list of forwarding cores.\n\n"
282 "set portlist (x[,y]*)\n"
283 " Set the list of forwarding ports.\n\n"
285 "set tx loopback (port_id) (on|off)\n"
286 " Enable or disable tx loopback.\n\n"
288 "set all queues drop (port_id) (on|off)\n"
289 " Set drop enable bit for all queues.\n\n"
291 "set vf split drop (port_id) (vf_id) (on|off)\n"
292 " Set split drop enable bit for a VF from the PF.\n\n"
294 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
295 " Set MAC antispoof for a VF from the PF.\n\n"
297 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
298 " Enable MACsec offload.\n\n"
300 "set macsec offload (port_id) off\n"
301 " Disable MACsec offload.\n\n"
303 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
304 " Configure MACsec secure connection (SC).\n\n"
306 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
307 " Configure MACsec secure association (SA).\n\n"
309 "set vf broadcast (port_id) (vf_id) (on|off)\n"
310 " Set VF broadcast for a VF from the PF.\n\n"
312 "vlan set strip (on|off) (port_id)\n"
313 " Set the VLAN strip on a port.\n\n"
315 "vlan set stripq (on|off) (port_id,queue_id)\n"
316 " Set the VLAN strip for a queue on a port.\n\n"
318 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
319 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
321 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
322 " Set VLAN insert for a VF from the PF.\n\n"
324 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
325 " Set VLAN antispoof for a VF from the PF.\n\n"
327 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
328 " Set VLAN tag for a VF from the PF.\n\n"
330 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
331 " Set a VF's max bandwidth(Mbps).\n\n"
333 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
334 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
336 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
337 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
339 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
340 " Set some TCs' strict link priority mode on a physical port.\n\n"
342 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
343 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
345 "vlan set filter (on|off) (port_id)\n"
346 " Set the VLAN filter on a port.\n\n"
348 "vlan set qinq (on|off) (port_id)\n"
349 " Set the VLAN QinQ (extended queue in queue)"
352 "vlan set (inner|outer) tpid (value) (port_id)\n"
353 " Set the VLAN TPID for Packet Filtering on"
356 "rx_vlan add (vlan_id|all) (port_id)\n"
357 " Add a vlan_id, or all identifiers, to the set"
358 " of VLAN identifiers filtered by port_id.\n\n"
360 "rx_vlan rm (vlan_id|all) (port_id)\n"
361 " Remove a vlan_id, or all identifiers, from the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
365 " Add a vlan_id, to the set of VLAN identifiers"
366 "filtered for VF(s) from port_id.\n\n"
368 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Remove a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
373 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
374 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
375 " add a tunnel filter of a port.\n\n"
377 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
378 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
379 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
380 " remove a tunnel filter of a port.\n\n"
382 "rx_vxlan_port add (udp_port) (port_id)\n"
383 " Add an UDP port for VXLAN packet filter on a port\n\n"
385 "rx_vxlan_port rm (udp_port) (port_id)\n"
386 " Remove an UDP port for VXLAN packet filter on a port\n\n"
388 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
389 " Set hardware insertion of VLAN IDs (single or double VLAN "
390 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
392 "tx_vlan set pvid port_id vlan_id (on|off)\n"
393 " Set port based TX VLAN insertion.\n\n"
395 "tx_vlan reset (port_id)\n"
396 " Disable hardware insertion of a VLAN header in"
397 " packets sent on a port.\n\n"
399 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
400 " Select hardware or software calculation of the"
401 " checksum when transmitting a packet using the"
402 " csum forward engine.\n"
403 " ip|udp|tcp|sctp always concern the inner layer.\n"
404 " outer-ip concerns the outer IP layer in"
405 " case the packet is recognized as a tunnel packet by"
406 " the forward engine (vxlan, gre and ipip are supported)\n"
407 " Please check the NIC datasheet for HW limits.\n\n"
409 "csum parse-tunnel (on|off) (tx_port_id)\n"
410 " If disabled, treat tunnel packets as non-tunneled"
411 " packets (treat inner headers as payload). The port\n"
412 " argument is the port used for TX in csum forward"
415 "csum show (port_id)\n"
416 " Display tx checksum offload configuration\n\n"
418 "tso set (segsize) (portid)\n"
419 " Enable TCP Segmentation Offload in csum forward"
421 " Please check the NIC datasheet for HW limits.\n\n"
424 " Display the status of TCP Segmentation Offload.\n\n"
427 " Set packet forwarding mode.\n\n"
429 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
430 " Add a MAC address on port_id.\n\n"
432 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
433 " Remove a MAC address from port_id.\n\n"
435 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
436 " Set the default MAC address for port_id.\n\n"
438 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
439 " Add a MAC address for a VF on the port.\n\n"
441 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
442 " Set the MAC address for a VF from the PF.\n\n"
444 "set port (port_id) uta (mac_address|all) (on|off)\n"
445 " Add/Remove a or all unicast hash filter(s)"
448 "set promisc (port_id|all) (on|off)\n"
449 " Set the promiscuous mode on port_id, or all.\n\n"
451 "set allmulti (port_id|all) (on|off)\n"
452 " Set the allmulti mode on port_id, or all.\n\n"
454 "set vf promisc (port_id) (vf_id) (on|off)\n"
455 " Set unicast promiscuous mode for a VF from the PF.\n\n"
457 "set vf allmulti (port_id) (vf_id) (on|off)\n"
458 " Set multicast promiscuous mode for a VF from the PF.\n\n"
460 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
461 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
462 " (on|off) autoneg (on|off) (port_id)\n"
463 "set flow_ctrl rx (on|off) (portid)\n"
464 "set flow_ctrl tx (on|off) (portid)\n"
465 "set flow_ctrl high_water (high_water) (portid)\n"
466 "set flow_ctrl low_water (low_water) (portid)\n"
467 "set flow_ctrl pause_time (pause_time) (portid)\n"
468 "set flow_ctrl send_xon (send_xon) (portid)\n"
469 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
470 "set flow_ctrl autoneg (on|off) (port_id)\n"
471 " Set the link flow control parameter on a port.\n\n"
473 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
474 " (low_water) (pause_time) (priority) (port_id)\n"
475 " Set the priority flow control parameter on a"
478 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
479 " Set statistics mapping (qmapping 0..15) for RX/TX"
481 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
482 " on port 0 to mapping 5.\n\n"
484 "set port (port_id) vf (vf_id) rx|tx on|off\n"
485 " Enable/Disable a VF receive/tranmit from a port\n\n"
487 "set port (port_id) vf (vf_id) (mac_addr)"
488 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
489 " Add/Remove unicast or multicast MAC addr filter"
492 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
494 " AUPE:accepts untagged VLAN;"
495 "ROPE:accept unicast hash\n\n"
496 " BAM:accepts broadcast packets;"
497 "MPE:accepts all multicast packets\n\n"
498 " Enable/Disable a VF receive mode of a port\n\n"
500 "set port (port_id) queue (queue_id) rate (rate_num)\n"
501 " Set rate limit for a queue of a port\n\n"
503 "set port (port_id) vf (vf_id) rate (rate_num) "
504 "queue_mask (queue_mask_value)\n"
505 " Set rate limit for queues in VF of a port\n\n"
507 "set port (port_id) mirror-rule (rule_id)"
508 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
509 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
510 " Set pool or vlan type mirror rule on a port.\n"
511 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
512 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
515 "set port (port_id) mirror-rule (rule_id)"
516 " (uplink-mirror|downlink-mirror) dst-pool"
517 " (pool_id) (on|off)\n"
518 " Set uplink or downlink type mirror rule on a port.\n"
519 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
520 " 0 on' enable mirror income traffic to pool 0.\n\n"
522 "reset port (port_id) mirror-rule (rule_id)\n"
523 " Reset a mirror rule.\n\n"
525 "set flush_rx (on|off)\n"
526 " Flush (default) or don't flush RX streams before"
527 " forwarding. Mainly used with PCAP drivers.\n\n"
529 "set bypass mode (normal|bypass|isolate) (port_id)\n"
530 " Set the bypass mode for the lowest port on bypass enabled"
533 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
534 "mode (normal|bypass|isolate) (port_id)\n"
535 " Set the event required to initiate specified bypass mode for"
536 " the lowest port on a bypass enabled NIC where:\n"
537 " timeout = enable bypass after watchdog timeout.\n"
538 " os_on = enable bypass when OS/board is powered on.\n"
539 " os_off = enable bypass when OS/board is powered off.\n"
540 " power_on = enable bypass when power supply is turned on.\n"
541 " power_off = enable bypass when power supply is turned off."
544 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
545 " Set the bypass watchdog timeout to 'n' seconds"
546 " where 0 = instant.\n\n"
548 "show bypass config (port_id)\n"
549 " Show the bypass configuration for a bypass enabled NIC"
550 " using the lowest port on the NIC.\n\n"
552 #ifdef RTE_LIBRTE_PMD_BOND
553 "create bonded device (mode) (socket)\n"
554 " Create a new bonded device with specific bonding mode and socket.\n\n"
556 "add bonding slave (slave_id) (port_id)\n"
557 " Add a slave device to a bonded device.\n\n"
559 "remove bonding slave (slave_id) (port_id)\n"
560 " Remove a slave device from a bonded device.\n\n"
562 "set bonding mode (value) (port_id)\n"
563 " Set the bonding mode on a bonded device.\n\n"
565 "set bonding primary (slave_id) (port_id)\n"
566 " Set the primary slave for a bonded device.\n\n"
568 "show bonding config (port_id)\n"
569 " Show the bonding config for port_id.\n\n"
571 "set bonding mac_addr (port_id) (address)\n"
572 " Set the MAC address of a bonded device.\n\n"
574 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
575 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
577 "set bonding mon_period (port_id) (value)\n"
578 " Set the bonding link status monitoring polling period in ms.\n\n"
580 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
581 " Enable/disable dedicated queues for LACP control traffic.\n\n"
584 "set link-up port (port_id)\n"
585 " Set link up for a port.\n\n"
587 "set link-down port (port_id)\n"
588 " Set link down for a port.\n\n"
590 "E-tag set insertion on port-tag-id (value)"
591 " port (port_id) vf (vf_id)\n"
592 " Enable E-tag insertion for a VF on a port\n\n"
594 "E-tag set insertion off port (port_id) vf (vf_id)\n"
595 " Disable E-tag insertion for a VF on a port\n\n"
597 "E-tag set stripping (on|off) port (port_id)\n"
598 " Enable/disable E-tag stripping on a port\n\n"
600 "E-tag set forwarding (on|off) port (port_id)\n"
601 " Enable/disable E-tag based forwarding"
604 "E-tag set filter add e-tag-id (value) dst-pool"
605 " (pool_id) port (port_id)\n"
606 " Add an E-tag forwarding filter on a port\n\n"
608 "E-tag set filter del e-tag-id (value) port (port_id)\n"
609 " Delete an E-tag forwarding filter on a port\n\n"
611 "ddp add (port_id) (profile_path[,output_path])\n"
612 " Load a profile package on a port\n\n"
614 "ddp del (port_id) (profile_path)\n"
615 " Delete a profile package from a port\n\n"
617 "ptype mapping get (port_id) (valid_only)\n"
618 " Get ptype mapping on a port\n\n"
620 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
621 " Replace target with the pkt_type in ptype mapping\n\n"
623 "ptype mapping reset (port_id)\n"
624 " Reset ptype mapping on a port\n\n"
626 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
627 " Update a ptype mapping item on a port\n\n"
629 , list_pkt_forwarding_modes()
633 if (show_all || !strcmp(res->section, "ports")) {
639 "----------------\n\n"
641 "port start (port_id|all)\n"
642 " Start all ports or port_id.\n\n"
644 "port stop (port_id|all)\n"
645 " Stop all ports or port_id.\n\n"
647 "port close (port_id|all)\n"
648 " Close all ports or port_id.\n\n"
650 "port attach (ident)\n"
651 " Attach physical or virtual dev by pci address or virtual device name\n\n"
653 "port detach (port_id)\n"
654 " Detach physical or virtual dev by port_id\n\n"
656 "port config (port_id|all)"
657 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
658 " duplex (half|full|auto)\n"
659 " Set speed and duplex for all ports or port_id\n\n"
661 "port config all (rxq|txq|rxd|txd) (value)\n"
662 " Set number for rxq/txq/rxd/txd.\n\n"
664 "port config all max-pkt-len (value)\n"
665 " Set the max packet length.\n\n"
667 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
668 "hw-vlan-strip|hw-vlan-extend|drop-en)"
670 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
673 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
674 " Set the RSS mode.\n\n"
676 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
677 " Set the RSS redirection table.\n\n"
679 "port config (port_id) dcb vt (on|off) (traffic_class)"
681 " Set the DCB mode.\n\n"
683 "port config all burst (value)\n"
684 " Set the number of packets per burst.\n\n"
686 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
688 " Set the ring prefetch/host/writeback threshold"
689 " for tx/rx queue.\n\n"
691 "port config all (txfreet|txrst|rxfreet) (value)\n"
692 " Set free threshold for rx/tx, or set"
693 " tx rs bit threshold.\n\n"
694 "port config mtu X value\n"
695 " Set the MTU of port X to a given value\n\n"
697 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
698 " Start/stop a rx/tx queue of port X. Only take effect"
699 " when port X is started\n\n"
701 "port config (port_id|all) l2-tunnel E-tag ether-type"
703 " Set the value of E-tag ether-type.\n\n"
705 "port config (port_id|all) l2-tunnel E-tag"
706 " (enable|disable)\n"
707 " Enable/disable the E-tag support.\n\n"
711 if (show_all || !strcmp(res->section, "registers")) {
719 "read reg (port_id) (address)\n"
720 " Display value of a port register.\n\n"
722 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
723 " Display a port register bit field.\n\n"
725 "read regbit (port_id) (address) (bit_x)\n"
726 " Display a single port register bit.\n\n"
728 "write reg (port_id) (address) (value)\n"
729 " Set value of a port register.\n\n"
731 "write regfield (port_id) (address) (bit_x) (bit_y)"
733 " Set bit field of a port register.\n\n"
735 "write regbit (port_id) (address) (bit_x) (value)\n"
736 " Set single bit value of a port register.\n\n"
739 if (show_all || !strcmp(res->section, "filters")) {
747 "ethertype_filter (port_id) (add|del)"
748 " (mac_addr|mac_ignr) (mac_address) ethertype"
749 " (ether_type) (drop|fwd) queue (queue_id)\n"
750 " Add/Del an ethertype filter.\n\n"
752 "2tuple_filter (port_id) (add|del)"
753 " dst_port (dst_port_value) protocol (protocol_value)"
754 " mask (mask_value) tcp_flags (tcp_flags_value)"
755 " priority (prio_value) queue (queue_id)\n"
756 " Add/Del a 2tuple filter.\n\n"
758 "5tuple_filter (port_id) (add|del)"
759 " dst_ip (dst_address) src_ip (src_address)"
760 " dst_port (dst_port_value) src_port (src_port_value)"
761 " protocol (protocol_value)"
762 " mask (mask_value) tcp_flags (tcp_flags_value)"
763 " priority (prio_value) queue (queue_id)\n"
764 " Add/Del a 5tuple filter.\n\n"
766 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
767 " Add/Del syn filter.\n\n"
769 "flex_filter (port_id) (add|del) len (len_value)"
770 " bytes (bytes_value) mask (mask_value)"
771 " priority (prio_value) queue (queue_id)\n"
772 " Add/Del a flex filter.\n\n"
774 "flow_director_filter (port_id) mode IP (add|del|update)"
775 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
776 " src (src_ip_address) dst (dst_ip_address)"
777 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
778 " vlan (vlan_value) flexbytes (flexbytes_value)"
779 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
780 " fd_id (fd_id_value)\n"
781 " Add/Del an IP type flow director filter.\n\n"
783 "flow_director_filter (port_id) mode IP (add|del|update)"
784 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
785 " src (src_ip_address) (src_port)"
786 " dst (dst_ip_address) (dst_port)"
787 " tos (tos_value) ttl (ttl_value)"
788 " vlan (vlan_value) flexbytes (flexbytes_value)"
789 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
790 " fd_id (fd_id_value)\n"
791 " Add/Del an UDP/TCP type flow director filter.\n\n"
793 "flow_director_filter (port_id) mode IP (add|del|update)"
794 " flow (ipv4-sctp|ipv6-sctp)"
795 " src (src_ip_address) (src_port)"
796 " dst (dst_ip_address) (dst_port)"
797 " tag (verification_tag) "
798 " tos (tos_value) ttl (ttl_value)"
800 " flexbytes (flexbytes_value) (drop|fwd)"
801 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
802 " Add/Del a SCTP type flow director filter.\n\n"
804 "flow_director_filter (port_id) mode IP (add|del|update)"
805 " flow l2_payload ether (ethertype)"
806 " flexbytes (flexbytes_value) (drop|fwd)"
807 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
808 " Add/Del a l2 payload type flow director filter.\n\n"
810 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
811 " mac (mac_address) vlan (vlan_value)"
812 " flexbytes (flexbytes_value) (drop|fwd)"
813 " queue (queue_id) fd_id (fd_id_value)\n"
814 " Add/Del a MAC-VLAN flow director filter.\n\n"
816 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
817 " mac (mac_address) vlan (vlan_value)"
818 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
819 " flexbytes (flexbytes_value) (drop|fwd)"
820 " queue (queue_id) fd_id (fd_id_value)\n"
821 " Add/Del a Tunnel flow director filter.\n\n"
823 "flush_flow_director (port_id)\n"
824 " Flush all flow director entries of a device.\n\n"
826 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
827 " src_mask (ipv4_src) (ipv6_src) (src_port)"
828 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
829 " Set flow director IP mask.\n\n"
831 "flow_director_mask (port_id) mode MAC-VLAN"
832 " vlan (vlan_value)\n"
833 " Set flow director MAC-VLAN mask.\n\n"
835 "flow_director_mask (port_id) mode Tunnel"
836 " vlan (vlan_value) mac (mac_value)"
837 " tunnel-type (tunnel_type_value)"
838 " tunnel-id (tunnel_id_value)\n"
839 " Set flow director Tunnel mask.\n\n"
841 "flow_director_flex_mask (port_id)"
842 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
843 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
845 " Configure mask of flex payload.\n\n"
847 "flow_director_flex_payload (port_id)"
848 " (raw|l2|l3|l4) (config)\n"
849 " Configure flex payload selection.\n\n"
851 "get_sym_hash_ena_per_port (port_id)\n"
852 " get symmetric hash enable configuration per port.\n\n"
854 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
855 " set symmetric hash enable configuration per port"
856 " to enable or disable.\n\n"
858 "get_hash_global_config (port_id)\n"
859 " Get the global configurations of hash filters.\n\n"
861 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
862 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
863 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
864 " (enable|disable)\n"
865 " Set the global configurations of hash filters.\n\n"
867 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
868 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
869 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
870 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
871 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
872 "ipv6-next-header|udp-src-port|udp-dst-port|"
873 "tcp-src-port|tcp-dst-port|sctp-src-port|"
874 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
875 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
876 "fld-8th|none) (select|add)\n"
877 " Set the input set for hash.\n\n"
879 "set_fdir_input_set (port_id) "
880 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
881 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
882 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
883 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
884 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
885 "udp-dst-port|tcp-src-port|tcp-dst-port|"
886 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
888 " Set the input set for FDir.\n\n"
890 "flow validate {port_id}"
891 " [group {group_id}] [priority {level}]"
892 " [ingress] [egress]"
893 " pattern {item} [/ {item} [...]] / end"
894 " actions {action} [/ {action} [...]] / end\n"
895 " Check whether a flow rule can be created.\n\n"
897 "flow create {port_id}"
898 " [group {group_id}] [priority {level}]"
899 " [ingress] [egress]"
900 " pattern {item} [/ {item} [...]] / end"
901 " actions {action} [/ {action} [...]] / end\n"
902 " Create a flow rule.\n\n"
904 "flow destroy {port_id} rule {rule_id} [...]\n"
905 " Destroy specific flow rules.\n\n"
907 "flow flush {port_id}\n"
908 " Destroy all flow rules.\n\n"
910 "flow query {port_id} {rule_id} {action}\n"
911 " Query an existing flow rule.\n\n"
913 "flow list {port_id} [group {group_id}] [...]\n"
914 " List existing flow rules sorted by priority,"
915 " filtered by group identifiers.\n\n"
917 "flow isolate {port_id} {boolean}\n"
918 " Restrict ingress traffic to the defined"
924 cmdline_parse_token_string_t cmd_help_long_help =
925 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
927 cmdline_parse_token_string_t cmd_help_long_section =
928 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
929 "all#control#display#config#"
930 "ports#registers#filters");
932 cmdline_parse_inst_t cmd_help_long = {
933 .f = cmd_help_long_parsed,
935 .help_str = "help all|control|display|config|ports|register|filters: "
938 (void *)&cmd_help_long_help,
939 (void *)&cmd_help_long_section,
945 /* *** start/stop/close all ports *** */
946 struct cmd_operate_port_result {
947 cmdline_fixed_string_t keyword;
948 cmdline_fixed_string_t name;
949 cmdline_fixed_string_t value;
952 static void cmd_operate_port_parsed(void *parsed_result,
953 __attribute__((unused)) struct cmdline *cl,
954 __attribute__((unused)) void *data)
956 struct cmd_operate_port_result *res = parsed_result;
958 if (!strcmp(res->name, "start"))
959 start_port(RTE_PORT_ALL);
960 else if (!strcmp(res->name, "stop"))
961 stop_port(RTE_PORT_ALL);
962 else if (!strcmp(res->name, "close"))
963 close_port(RTE_PORT_ALL);
965 printf("Unknown parameter\n");
968 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
969 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
971 cmdline_parse_token_string_t cmd_operate_port_all_port =
972 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
974 cmdline_parse_token_string_t cmd_operate_port_all_all =
975 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
977 cmdline_parse_inst_t cmd_operate_port = {
978 .f = cmd_operate_port_parsed,
980 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
982 (void *)&cmd_operate_port_all_cmd,
983 (void *)&cmd_operate_port_all_port,
984 (void *)&cmd_operate_port_all_all,
989 /* *** start/stop/close specific port *** */
990 struct cmd_operate_specific_port_result {
991 cmdline_fixed_string_t keyword;
992 cmdline_fixed_string_t name;
996 static void cmd_operate_specific_port_parsed(void *parsed_result,
997 __attribute__((unused)) struct cmdline *cl,
998 __attribute__((unused)) void *data)
1000 struct cmd_operate_specific_port_result *res = parsed_result;
1002 if (!strcmp(res->name, "start"))
1003 start_port(res->value);
1004 else if (!strcmp(res->name, "stop"))
1005 stop_port(res->value);
1006 else if (!strcmp(res->name, "close"))
1007 close_port(res->value);
1009 printf("Unknown parameter\n");
1012 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1013 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1015 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1016 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1017 name, "start#stop#close");
1018 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1019 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1022 cmdline_parse_inst_t cmd_operate_specific_port = {
1023 .f = cmd_operate_specific_port_parsed,
1025 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1027 (void *)&cmd_operate_specific_port_cmd,
1028 (void *)&cmd_operate_specific_port_port,
1029 (void *)&cmd_operate_specific_port_id,
1034 /* *** attach a specified port *** */
1035 struct cmd_operate_attach_port_result {
1036 cmdline_fixed_string_t port;
1037 cmdline_fixed_string_t keyword;
1038 cmdline_fixed_string_t identifier;
1041 static void cmd_operate_attach_port_parsed(void *parsed_result,
1042 __attribute__((unused)) struct cmdline *cl,
1043 __attribute__((unused)) void *data)
1045 struct cmd_operate_attach_port_result *res = parsed_result;
1047 if (!strcmp(res->keyword, "attach"))
1048 attach_port(res->identifier);
1050 printf("Unknown parameter\n");
1053 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1054 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1056 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1057 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1059 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1060 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1063 cmdline_parse_inst_t cmd_operate_attach_port = {
1064 .f = cmd_operate_attach_port_parsed,
1066 .help_str = "port attach <identifier>: "
1067 "(identifier: pci address or virtual dev name)",
1069 (void *)&cmd_operate_attach_port_port,
1070 (void *)&cmd_operate_attach_port_keyword,
1071 (void *)&cmd_operate_attach_port_identifier,
1076 /* *** detach a specified port *** */
1077 struct cmd_operate_detach_port_result {
1078 cmdline_fixed_string_t port;
1079 cmdline_fixed_string_t keyword;
1083 static void cmd_operate_detach_port_parsed(void *parsed_result,
1084 __attribute__((unused)) struct cmdline *cl,
1085 __attribute__((unused)) void *data)
1087 struct cmd_operate_detach_port_result *res = parsed_result;
1089 if (!strcmp(res->keyword, "detach"))
1090 detach_port(res->port_id);
1092 printf("Unknown parameter\n");
1095 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1096 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1098 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1099 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1101 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1102 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1105 cmdline_parse_inst_t cmd_operate_detach_port = {
1106 .f = cmd_operate_detach_port_parsed,
1108 .help_str = "port detach <port_id>",
1110 (void *)&cmd_operate_detach_port_port,
1111 (void *)&cmd_operate_detach_port_keyword,
1112 (void *)&cmd_operate_detach_port_port_id,
1117 /* *** configure speed for all ports *** */
1118 struct cmd_config_speed_all {
1119 cmdline_fixed_string_t port;
1120 cmdline_fixed_string_t keyword;
1121 cmdline_fixed_string_t all;
1122 cmdline_fixed_string_t item1;
1123 cmdline_fixed_string_t item2;
1124 cmdline_fixed_string_t value1;
1125 cmdline_fixed_string_t value2;
1129 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1134 if (!strcmp(duplexstr, "half")) {
1135 duplex = ETH_LINK_HALF_DUPLEX;
1136 } else if (!strcmp(duplexstr, "full")) {
1137 duplex = ETH_LINK_FULL_DUPLEX;
1138 } else if (!strcmp(duplexstr, "auto")) {
1139 duplex = ETH_LINK_FULL_DUPLEX;
1141 printf("Unknown duplex parameter\n");
1145 if (!strcmp(speedstr, "10")) {
1146 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1147 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1148 } else if (!strcmp(speedstr, "100")) {
1149 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1150 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1152 if (duplex != ETH_LINK_FULL_DUPLEX) {
1153 printf("Invalid speed/duplex parameters\n");
1156 if (!strcmp(speedstr, "1000")) {
1157 *speed = ETH_LINK_SPEED_1G;
1158 } else if (!strcmp(speedstr, "10000")) {
1159 *speed = ETH_LINK_SPEED_10G;
1160 } else if (!strcmp(speedstr, "25000")) {
1161 *speed = ETH_LINK_SPEED_25G;
1162 } else if (!strcmp(speedstr, "40000")) {
1163 *speed = ETH_LINK_SPEED_40G;
1164 } else if (!strcmp(speedstr, "50000")) {
1165 *speed = ETH_LINK_SPEED_50G;
1166 } else if (!strcmp(speedstr, "100000")) {
1167 *speed = ETH_LINK_SPEED_100G;
1168 } else if (!strcmp(speedstr, "auto")) {
1169 *speed = ETH_LINK_SPEED_AUTONEG;
1171 printf("Unknown speed parameter\n");
1180 cmd_config_speed_all_parsed(void *parsed_result,
1181 __attribute__((unused)) struct cmdline *cl,
1182 __attribute__((unused)) void *data)
1184 struct cmd_config_speed_all *res = parsed_result;
1185 uint32_t link_speed;
1188 if (!all_ports_stopped()) {
1189 printf("Please stop all ports first\n");
1193 if (parse_and_check_speed_duplex(res->value1, res->value2,
1197 RTE_ETH_FOREACH_DEV(pid) {
1198 ports[pid].dev_conf.link_speeds = link_speed;
1201 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1204 cmdline_parse_token_string_t cmd_config_speed_all_port =
1205 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1206 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1207 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1209 cmdline_parse_token_string_t cmd_config_speed_all_all =
1210 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1211 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1212 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1213 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1214 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1215 "10#100#1000#10000#25000#40000#50000#100000#auto");
1216 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1217 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1218 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1219 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1222 cmdline_parse_inst_t cmd_config_speed_all = {
1223 .f = cmd_config_speed_all_parsed,
1225 .help_str = "port config all speed "
1226 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1229 (void *)&cmd_config_speed_all_port,
1230 (void *)&cmd_config_speed_all_keyword,
1231 (void *)&cmd_config_speed_all_all,
1232 (void *)&cmd_config_speed_all_item1,
1233 (void *)&cmd_config_speed_all_value1,
1234 (void *)&cmd_config_speed_all_item2,
1235 (void *)&cmd_config_speed_all_value2,
1240 /* *** configure speed for specific port *** */
1241 struct cmd_config_speed_specific {
1242 cmdline_fixed_string_t port;
1243 cmdline_fixed_string_t keyword;
1245 cmdline_fixed_string_t item1;
1246 cmdline_fixed_string_t item2;
1247 cmdline_fixed_string_t value1;
1248 cmdline_fixed_string_t value2;
1252 cmd_config_speed_specific_parsed(void *parsed_result,
1253 __attribute__((unused)) struct cmdline *cl,
1254 __attribute__((unused)) void *data)
1256 struct cmd_config_speed_specific *res = parsed_result;
1257 uint32_t link_speed;
1259 if (!all_ports_stopped()) {
1260 printf("Please stop all ports first\n");
1264 if (port_id_is_invalid(res->id, ENABLED_WARN))
1267 if (parse_and_check_speed_duplex(res->value1, res->value2,
1271 ports[res->id].dev_conf.link_speeds = link_speed;
1273 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1277 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1278 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1280 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1283 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1284 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1285 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1286 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1288 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1289 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1290 "10#100#1000#10000#25000#40000#50000#100000#auto");
1291 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1292 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1294 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1295 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1298 cmdline_parse_inst_t cmd_config_speed_specific = {
1299 .f = cmd_config_speed_specific_parsed,
1301 .help_str = "port config <port_id> speed "
1302 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1305 (void *)&cmd_config_speed_specific_port,
1306 (void *)&cmd_config_speed_specific_keyword,
1307 (void *)&cmd_config_speed_specific_id,
1308 (void *)&cmd_config_speed_specific_item1,
1309 (void *)&cmd_config_speed_specific_value1,
1310 (void *)&cmd_config_speed_specific_item2,
1311 (void *)&cmd_config_speed_specific_value2,
1316 /* *** configure txq/rxq, txd/rxd *** */
1317 struct cmd_config_rx_tx {
1318 cmdline_fixed_string_t port;
1319 cmdline_fixed_string_t keyword;
1320 cmdline_fixed_string_t all;
1321 cmdline_fixed_string_t name;
1326 cmd_config_rx_tx_parsed(void *parsed_result,
1327 __attribute__((unused)) struct cmdline *cl,
1328 __attribute__((unused)) void *data)
1330 struct cmd_config_rx_tx *res = parsed_result;
1332 if (!all_ports_stopped()) {
1333 printf("Please stop all ports first\n");
1336 if (!strcmp(res->name, "rxq")) {
1337 if (!res->value && !nb_txq) {
1338 printf("Warning: Either rx or tx queues should be non zero\n");
1341 nb_rxq = res->value;
1343 else if (!strcmp(res->name, "txq")) {
1344 if (!res->value && !nb_rxq) {
1345 printf("Warning: Either rx or tx queues should be non zero\n");
1348 nb_txq = res->value;
1350 else if (!strcmp(res->name, "rxd")) {
1351 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1352 printf("rxd %d invalid - must be > 0 && <= %d\n",
1353 res->value, RTE_TEST_RX_DESC_MAX);
1356 nb_rxd = res->value;
1357 } else if (!strcmp(res->name, "txd")) {
1358 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1359 printf("txd %d invalid - must be > 0 && <= %d\n",
1360 res->value, RTE_TEST_TX_DESC_MAX);
1363 nb_txd = res->value;
1365 printf("Unknown parameter\n");
1373 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1376 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1377 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1378 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1379 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1380 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1381 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1382 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1383 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1385 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1386 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1388 cmdline_parse_inst_t cmd_config_rx_tx = {
1389 .f = cmd_config_rx_tx_parsed,
1391 .help_str = "port config all rxq|txq|rxd|txd <value>",
1393 (void *)&cmd_config_rx_tx_port,
1394 (void *)&cmd_config_rx_tx_keyword,
1395 (void *)&cmd_config_rx_tx_all,
1396 (void *)&cmd_config_rx_tx_name,
1397 (void *)&cmd_config_rx_tx_value,
1402 /* *** config max packet length *** */
1403 struct cmd_config_max_pkt_len_result {
1404 cmdline_fixed_string_t port;
1405 cmdline_fixed_string_t keyword;
1406 cmdline_fixed_string_t all;
1407 cmdline_fixed_string_t name;
1412 cmd_config_max_pkt_len_parsed(void *parsed_result,
1413 __attribute__((unused)) struct cmdline *cl,
1414 __attribute__((unused)) void *data)
1416 struct cmd_config_max_pkt_len_result *res = parsed_result;
1418 if (!all_ports_stopped()) {
1419 printf("Please stop all ports first\n");
1423 if (!strcmp(res->name, "max-pkt-len")) {
1424 if (res->value < ETHER_MIN_LEN) {
1425 printf("max-pkt-len can not be less than %d\n",
1429 if (res->value == rx_mode.max_rx_pkt_len)
1432 rx_mode.max_rx_pkt_len = res->value;
1433 if (res->value > ETHER_MAX_LEN)
1434 rx_mode.jumbo_frame = 1;
1436 rx_mode.jumbo_frame = 0;
1438 printf("Unknown parameter\n");
1444 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1447 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1448 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1450 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1451 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1453 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1454 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1456 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1457 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1459 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1460 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1463 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1464 .f = cmd_config_max_pkt_len_parsed,
1466 .help_str = "port config all max-pkt-len <value>",
1468 (void *)&cmd_config_max_pkt_len_port,
1469 (void *)&cmd_config_max_pkt_len_keyword,
1470 (void *)&cmd_config_max_pkt_len_all,
1471 (void *)&cmd_config_max_pkt_len_name,
1472 (void *)&cmd_config_max_pkt_len_value,
1477 /* *** configure port MTU *** */
1478 struct cmd_config_mtu_result {
1479 cmdline_fixed_string_t port;
1480 cmdline_fixed_string_t keyword;
1481 cmdline_fixed_string_t mtu;
1487 cmd_config_mtu_parsed(void *parsed_result,
1488 __attribute__((unused)) struct cmdline *cl,
1489 __attribute__((unused)) void *data)
1491 struct cmd_config_mtu_result *res = parsed_result;
1493 if (res->value < ETHER_MIN_LEN) {
1494 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1497 port_mtu_set(res->port_id, res->value);
1500 cmdline_parse_token_string_t cmd_config_mtu_port =
1501 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1503 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1504 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1506 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1507 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1509 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1510 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1511 cmdline_parse_token_num_t cmd_config_mtu_value =
1512 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1514 cmdline_parse_inst_t cmd_config_mtu = {
1515 .f = cmd_config_mtu_parsed,
1517 .help_str = "port config mtu <port_id> <value>",
1519 (void *)&cmd_config_mtu_port,
1520 (void *)&cmd_config_mtu_keyword,
1521 (void *)&cmd_config_mtu_mtu,
1522 (void *)&cmd_config_mtu_port_id,
1523 (void *)&cmd_config_mtu_value,
1528 /* *** configure rx mode *** */
1529 struct cmd_config_rx_mode_flag {
1530 cmdline_fixed_string_t port;
1531 cmdline_fixed_string_t keyword;
1532 cmdline_fixed_string_t all;
1533 cmdline_fixed_string_t name;
1534 cmdline_fixed_string_t value;
1538 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1539 __attribute__((unused)) struct cmdline *cl,
1540 __attribute__((unused)) void *data)
1542 struct cmd_config_rx_mode_flag *res = parsed_result;
1544 if (!all_ports_stopped()) {
1545 printf("Please stop all ports first\n");
1549 if (!strcmp(res->name, "crc-strip")) {
1550 if (!strcmp(res->value, "on"))
1551 rx_mode.hw_strip_crc = 1;
1552 else if (!strcmp(res->value, "off"))
1553 rx_mode.hw_strip_crc = 0;
1555 printf("Unknown parameter\n");
1558 } else if (!strcmp(res->name, "scatter")) {
1559 if (!strcmp(res->value, "on"))
1560 rx_mode.enable_scatter = 1;
1561 else if (!strcmp(res->value, "off"))
1562 rx_mode.enable_scatter = 0;
1564 printf("Unknown parameter\n");
1567 } else if (!strcmp(res->name, "rx-cksum")) {
1568 if (!strcmp(res->value, "on"))
1569 rx_mode.hw_ip_checksum = 1;
1570 else if (!strcmp(res->value, "off"))
1571 rx_mode.hw_ip_checksum = 0;
1573 printf("Unknown parameter\n");
1576 } else if (!strcmp(res->name, "hw-vlan")) {
1577 if (!strcmp(res->value, "on")) {
1578 rx_mode.hw_vlan_filter = 1;
1579 rx_mode.hw_vlan_strip = 1;
1581 else if (!strcmp(res->value, "off")) {
1582 rx_mode.hw_vlan_filter = 0;
1583 rx_mode.hw_vlan_strip = 0;
1586 printf("Unknown parameter\n");
1589 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1590 if (!strcmp(res->value, "on"))
1591 rx_mode.hw_vlan_filter = 1;
1592 else if (!strcmp(res->value, "off"))
1593 rx_mode.hw_vlan_filter = 0;
1595 printf("Unknown parameter\n");
1598 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1599 if (!strcmp(res->value, "on"))
1600 rx_mode.hw_vlan_strip = 1;
1601 else if (!strcmp(res->value, "off"))
1602 rx_mode.hw_vlan_strip = 0;
1604 printf("Unknown parameter\n");
1607 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1608 if (!strcmp(res->value, "on"))
1609 rx_mode.hw_vlan_extend = 1;
1610 else if (!strcmp(res->value, "off"))
1611 rx_mode.hw_vlan_extend = 0;
1613 printf("Unknown parameter\n");
1616 } else if (!strcmp(res->name, "drop-en")) {
1617 if (!strcmp(res->value, "on"))
1619 else if (!strcmp(res->value, "off"))
1622 printf("Unknown parameter\n");
1626 printf("Unknown parameter\n");
1632 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1635 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1636 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1637 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1638 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1640 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1642 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1644 "crc-strip#scatter#rx-cksum#hw-vlan#"
1645 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1646 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1650 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1651 .f = cmd_config_rx_mode_flag_parsed,
1653 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1654 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1656 (void *)&cmd_config_rx_mode_flag_port,
1657 (void *)&cmd_config_rx_mode_flag_keyword,
1658 (void *)&cmd_config_rx_mode_flag_all,
1659 (void *)&cmd_config_rx_mode_flag_name,
1660 (void *)&cmd_config_rx_mode_flag_value,
1665 /* *** configure rss *** */
1666 struct cmd_config_rss {
1667 cmdline_fixed_string_t port;
1668 cmdline_fixed_string_t keyword;
1669 cmdline_fixed_string_t all;
1670 cmdline_fixed_string_t name;
1671 cmdline_fixed_string_t value;
1675 cmd_config_rss_parsed(void *parsed_result,
1676 __attribute__((unused)) struct cmdline *cl,
1677 __attribute__((unused)) void *data)
1679 struct cmd_config_rss *res = parsed_result;
1680 struct rte_eth_rss_conf rss_conf;
1684 if (!strcmp(res->value, "all"))
1685 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1686 ETH_RSS_UDP | ETH_RSS_SCTP |
1688 else if (!strcmp(res->value, "ip"))
1689 rss_conf.rss_hf = ETH_RSS_IP;
1690 else if (!strcmp(res->value, "udp"))
1691 rss_conf.rss_hf = ETH_RSS_UDP;
1692 else if (!strcmp(res->value, "tcp"))
1693 rss_conf.rss_hf = ETH_RSS_TCP;
1694 else if (!strcmp(res->value, "sctp"))
1695 rss_conf.rss_hf = ETH_RSS_SCTP;
1696 else if (!strcmp(res->value, "ether"))
1697 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1698 else if (!strcmp(res->value, "port"))
1699 rss_conf.rss_hf = ETH_RSS_PORT;
1700 else if (!strcmp(res->value, "vxlan"))
1701 rss_conf.rss_hf = ETH_RSS_VXLAN;
1702 else if (!strcmp(res->value, "geneve"))
1703 rss_conf.rss_hf = ETH_RSS_GENEVE;
1704 else if (!strcmp(res->value, "nvgre"))
1705 rss_conf.rss_hf = ETH_RSS_NVGRE;
1706 else if (!strcmp(res->value, "none"))
1707 rss_conf.rss_hf = 0;
1709 printf("Unknown parameter\n");
1712 rss_conf.rss_key = NULL;
1713 for (i = 0; i < rte_eth_dev_count(); i++) {
1714 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1716 printf("Configuration of RSS hash at ethernet port %d "
1717 "failed with error (%d): %s.\n",
1718 i, -diag, strerror(-diag));
1722 cmdline_parse_token_string_t cmd_config_rss_port =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1724 cmdline_parse_token_string_t cmd_config_rss_keyword =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1726 cmdline_parse_token_string_t cmd_config_rss_all =
1727 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1728 cmdline_parse_token_string_t cmd_config_rss_name =
1729 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1730 cmdline_parse_token_string_t cmd_config_rss_value =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1732 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1734 cmdline_parse_inst_t cmd_config_rss = {
1735 .f = cmd_config_rss_parsed,
1737 .help_str = "port config all rss "
1738 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1740 (void *)&cmd_config_rss_port,
1741 (void *)&cmd_config_rss_keyword,
1742 (void *)&cmd_config_rss_all,
1743 (void *)&cmd_config_rss_name,
1744 (void *)&cmd_config_rss_value,
1749 /* *** configure rss hash key *** */
1750 struct cmd_config_rss_hash_key {
1751 cmdline_fixed_string_t port;
1752 cmdline_fixed_string_t config;
1754 cmdline_fixed_string_t rss_hash_key;
1755 cmdline_fixed_string_t rss_type;
1756 cmdline_fixed_string_t key;
1760 hexa_digit_to_value(char hexa_digit)
1762 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1763 return (uint8_t) (hexa_digit - '0');
1764 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1765 return (uint8_t) ((hexa_digit - 'a') + 10);
1766 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1767 return (uint8_t) ((hexa_digit - 'A') + 10);
1768 /* Invalid hexa digit */
1773 parse_and_check_key_hexa_digit(char *key, int idx)
1777 hexa_v = hexa_digit_to_value(key[idx]);
1779 printf("invalid key: character %c at position %d is not a "
1780 "valid hexa digit\n", key[idx], idx);
1785 cmd_config_rss_hash_key_parsed(void *parsed_result,
1786 __attribute__((unused)) struct cmdline *cl,
1787 __attribute__((unused)) void *data)
1789 struct cmd_config_rss_hash_key *res = parsed_result;
1790 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1794 struct rte_eth_dev_info dev_info;
1795 uint8_t hash_key_size;
1798 memset(&dev_info, 0, sizeof(dev_info));
1799 rte_eth_dev_info_get(res->port_id, &dev_info);
1800 if (dev_info.hash_key_size > 0 &&
1801 dev_info.hash_key_size <= sizeof(hash_key))
1802 hash_key_size = dev_info.hash_key_size;
1804 printf("dev_info did not provide a valid hash key size\n");
1807 /* Check the length of the RSS hash key */
1808 key_len = strlen(res->key);
1809 if (key_len != (hash_key_size * 2)) {
1810 printf("key length: %d invalid - key must be a string of %d"
1811 " hexa-decimal numbers\n",
1812 (int) key_len, hash_key_size * 2);
1815 /* Translate RSS hash key into binary representation */
1816 for (i = 0; i < hash_key_size; i++) {
1817 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1820 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1823 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1825 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1829 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1831 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1834 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1835 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1836 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1838 rss_hash_key, "rss-hash-key");
1839 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1840 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1841 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1842 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1843 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1844 "ipv6-tcp-ex#ipv6-udp-ex");
1845 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1846 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1848 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1849 .f = cmd_config_rss_hash_key_parsed,
1851 .help_str = "port config <port_id> rss-hash-key "
1852 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1853 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1854 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1855 "<string of hex digits (variable length, NIC dependent)>",
1857 (void *)&cmd_config_rss_hash_key_port,
1858 (void *)&cmd_config_rss_hash_key_config,
1859 (void *)&cmd_config_rss_hash_key_port_id,
1860 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1861 (void *)&cmd_config_rss_hash_key_rss_type,
1862 (void *)&cmd_config_rss_hash_key_value,
1867 /* *** configure port rxq/txq start/stop *** */
1868 struct cmd_config_rxtx_queue {
1869 cmdline_fixed_string_t port;
1871 cmdline_fixed_string_t rxtxq;
1873 cmdline_fixed_string_t opname;
1877 cmd_config_rxtx_queue_parsed(void *parsed_result,
1878 __attribute__((unused)) struct cmdline *cl,
1879 __attribute__((unused)) void *data)
1881 struct cmd_config_rxtx_queue *res = parsed_result;
1886 if (test_done == 0) {
1887 printf("Please stop forwarding first\n");
1891 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1894 if (port_is_started(res->portid) != 1) {
1895 printf("Please start port %u first\n", res->portid);
1899 if (!strcmp(res->rxtxq, "rxq"))
1901 else if (!strcmp(res->rxtxq, "txq"))
1904 printf("Unknown parameter\n");
1908 if (isrx && rx_queue_id_is_invalid(res->qid))
1910 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1913 if (!strcmp(res->opname, "start"))
1915 else if (!strcmp(res->opname, "stop"))
1918 printf("Unknown parameter\n");
1922 if (isstart && isrx)
1923 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1924 else if (!isstart && isrx)
1925 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1926 else if (isstart && !isrx)
1927 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1929 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1931 if (ret == -ENOTSUP)
1932 printf("Function not supported in PMD driver\n");
1935 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1937 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1938 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1939 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1941 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1942 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1943 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1944 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1947 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1948 .f = cmd_config_rxtx_queue_parsed,
1950 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1952 (void *)&cmd_config_speed_all_port,
1953 (void *)&cmd_config_rxtx_queue_portid,
1954 (void *)&cmd_config_rxtx_queue_rxtxq,
1955 (void *)&cmd_config_rxtx_queue_qid,
1956 (void *)&cmd_config_rxtx_queue_opname,
1961 /* *** Configure RSS RETA *** */
1962 struct cmd_config_rss_reta {
1963 cmdline_fixed_string_t port;
1964 cmdline_fixed_string_t keyword;
1966 cmdline_fixed_string_t name;
1967 cmdline_fixed_string_t list_name;
1968 cmdline_fixed_string_t list_of_items;
1972 parse_reta_config(const char *str,
1973 struct rte_eth_rss_reta_entry64 *reta_conf,
1974 uint16_t nb_entries)
1978 uint16_t hash_index, idx, shift;
1981 const char *p, *p0 = str;
1988 unsigned long int_fld[_NUM_FLD];
1989 char *str_fld[_NUM_FLD];
1991 while ((p = strchr(p0,'(')) != NULL) {
1993 if((p0 = strchr(p,')')) == NULL)
1997 if(size >= sizeof(s))
2000 snprintf(s, sizeof(s), "%.*s", size, p);
2001 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2003 for (i = 0; i < _NUM_FLD; i++) {
2005 int_fld[i] = strtoul(str_fld[i], &end, 0);
2006 if (errno != 0 || end == str_fld[i] ||
2011 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2012 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2014 if (hash_index >= nb_entries) {
2015 printf("Invalid RETA hash index=%d\n", hash_index);
2019 idx = hash_index / RTE_RETA_GROUP_SIZE;
2020 shift = hash_index % RTE_RETA_GROUP_SIZE;
2021 reta_conf[idx].mask |= (1ULL << shift);
2022 reta_conf[idx].reta[shift] = nb_queue;
2029 cmd_set_rss_reta_parsed(void *parsed_result,
2030 __attribute__((unused)) struct cmdline *cl,
2031 __attribute__((unused)) void *data)
2034 struct rte_eth_dev_info dev_info;
2035 struct rte_eth_rss_reta_entry64 reta_conf[8];
2036 struct cmd_config_rss_reta *res = parsed_result;
2038 memset(&dev_info, 0, sizeof(dev_info));
2039 rte_eth_dev_info_get(res->port_id, &dev_info);
2040 if (dev_info.reta_size == 0) {
2041 printf("Redirection table size is 0 which is "
2042 "invalid for RSS\n");
2045 printf("The reta size of port %d is %u\n",
2046 res->port_id, dev_info.reta_size);
2047 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2048 printf("Currently do not support more than %u entries of "
2049 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2053 memset(reta_conf, 0, sizeof(reta_conf));
2054 if (!strcmp(res->list_name, "reta")) {
2055 if (parse_reta_config(res->list_of_items, reta_conf,
2056 dev_info.reta_size)) {
2057 printf("Invalid RSS Redirection Table "
2058 "config entered\n");
2061 ret = rte_eth_dev_rss_reta_update(res->port_id,
2062 reta_conf, dev_info.reta_size);
2064 printf("Bad redirection table parameter, "
2065 "return code = %d \n", ret);
2069 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2071 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2073 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2074 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2075 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2076 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2077 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2078 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2079 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2080 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2082 cmdline_parse_inst_t cmd_config_rss_reta = {
2083 .f = cmd_set_rss_reta_parsed,
2085 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2087 (void *)&cmd_config_rss_reta_port,
2088 (void *)&cmd_config_rss_reta_keyword,
2089 (void *)&cmd_config_rss_reta_port_id,
2090 (void *)&cmd_config_rss_reta_name,
2091 (void *)&cmd_config_rss_reta_list_name,
2092 (void *)&cmd_config_rss_reta_list_of_items,
2097 /* *** SHOW PORT RETA INFO *** */
2098 struct cmd_showport_reta {
2099 cmdline_fixed_string_t show;
2100 cmdline_fixed_string_t port;
2102 cmdline_fixed_string_t rss;
2103 cmdline_fixed_string_t reta;
2105 cmdline_fixed_string_t list_of_items;
2109 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2110 uint16_t nb_entries,
2114 const char *p, *p0 = str;
2119 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2120 RTE_RETA_GROUP_SIZE;
2123 p = strchr(p0, '(');
2127 p0 = strchr(p, ')');
2131 if (size >= sizeof(s)) {
2132 printf("The string size exceeds the internal buffer size\n");
2135 snprintf(s, sizeof(s), "%.*s", size, p);
2136 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2137 if (ret <= 0 || ret != num) {
2138 printf("The bits of masks do not match the number of "
2139 "reta entries: %u\n", num);
2142 for (i = 0; i < ret; i++)
2143 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2149 cmd_showport_reta_parsed(void *parsed_result,
2150 __attribute__((unused)) struct cmdline *cl,
2151 __attribute__((unused)) void *data)
2153 struct cmd_showport_reta *res = parsed_result;
2154 struct rte_eth_rss_reta_entry64 reta_conf[8];
2155 struct rte_eth_dev_info dev_info;
2157 memset(&dev_info, 0, sizeof(dev_info));
2158 rte_eth_dev_info_get(res->port_id, &dev_info);
2159 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2160 res->size > ETH_RSS_RETA_SIZE_512) {
2161 printf("Invalid redirection table size: %u\n", res->size);
2165 memset(reta_conf, 0, sizeof(reta_conf));
2166 if (showport_parse_reta_config(reta_conf, res->size,
2167 res->list_of_items) < 0) {
2168 printf("Invalid string: %s for reta masks\n",
2169 res->list_of_items);
2172 port_rss_reta_info(res->port_id, reta_conf, res->size);
2175 cmdline_parse_token_string_t cmd_showport_reta_show =
2176 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2177 cmdline_parse_token_string_t cmd_showport_reta_port =
2178 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2179 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2180 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2181 cmdline_parse_token_string_t cmd_showport_reta_rss =
2182 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2183 cmdline_parse_token_string_t cmd_showport_reta_reta =
2184 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2185 cmdline_parse_token_num_t cmd_showport_reta_size =
2186 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2187 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2188 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2189 list_of_items, NULL);
2191 cmdline_parse_inst_t cmd_showport_reta = {
2192 .f = cmd_showport_reta_parsed,
2194 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2196 (void *)&cmd_showport_reta_show,
2197 (void *)&cmd_showport_reta_port,
2198 (void *)&cmd_showport_reta_port_id,
2199 (void *)&cmd_showport_reta_rss,
2200 (void *)&cmd_showport_reta_reta,
2201 (void *)&cmd_showport_reta_size,
2202 (void *)&cmd_showport_reta_list_of_items,
2207 /* *** Show RSS hash configuration *** */
2208 struct cmd_showport_rss_hash {
2209 cmdline_fixed_string_t show;
2210 cmdline_fixed_string_t port;
2212 cmdline_fixed_string_t rss_hash;
2213 cmdline_fixed_string_t rss_type;
2214 cmdline_fixed_string_t key; /* optional argument */
2217 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2218 __attribute__((unused)) struct cmdline *cl,
2221 struct cmd_showport_rss_hash *res = parsed_result;
2223 port_rss_hash_conf_show(res->port_id, res->rss_type,
2224 show_rss_key != NULL);
2227 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2228 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2229 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2230 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2231 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2232 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2233 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2234 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2236 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2237 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2238 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2239 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2240 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2241 "ipv6-tcp-ex#ipv6-udp-ex");
2242 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2243 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2245 cmdline_parse_inst_t cmd_showport_rss_hash = {
2246 .f = cmd_showport_rss_hash_parsed,
2248 .help_str = "show port <port_id> rss-hash "
2249 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2250 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2251 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2253 (void *)&cmd_showport_rss_hash_show,
2254 (void *)&cmd_showport_rss_hash_port,
2255 (void *)&cmd_showport_rss_hash_port_id,
2256 (void *)&cmd_showport_rss_hash_rss_hash,
2257 (void *)&cmd_showport_rss_hash_rss_hash_info,
2262 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2263 .f = cmd_showport_rss_hash_parsed,
2265 .help_str = "show port <port_id> rss-hash "
2266 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2267 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2268 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2270 (void *)&cmd_showport_rss_hash_show,
2271 (void *)&cmd_showport_rss_hash_port,
2272 (void *)&cmd_showport_rss_hash_port_id,
2273 (void *)&cmd_showport_rss_hash_rss_hash,
2274 (void *)&cmd_showport_rss_hash_rss_hash_info,
2275 (void *)&cmd_showport_rss_hash_rss_key,
2280 /* *** Configure DCB *** */
2281 struct cmd_config_dcb {
2282 cmdline_fixed_string_t port;
2283 cmdline_fixed_string_t config;
2285 cmdline_fixed_string_t dcb;
2286 cmdline_fixed_string_t vt;
2287 cmdline_fixed_string_t vt_en;
2289 cmdline_fixed_string_t pfc;
2290 cmdline_fixed_string_t pfc_en;
2294 cmd_config_dcb_parsed(void *parsed_result,
2295 __attribute__((unused)) struct cmdline *cl,
2296 __attribute__((unused)) void *data)
2298 struct cmd_config_dcb *res = parsed_result;
2299 portid_t port_id = res->port_id;
2300 struct rte_port *port;
2304 port = &ports[port_id];
2305 /** Check if the port is not started **/
2306 if (port->port_status != RTE_PORT_STOPPED) {
2307 printf("Please stop port %d first\n", port_id);
2311 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2312 printf("The invalid number of traffic class,"
2313 " only 4 or 8 allowed.\n");
2317 if (nb_fwd_lcores < res->num_tcs) {
2318 printf("nb_cores shouldn't be less than number of TCs.\n");
2321 if (!strncmp(res->pfc_en, "on", 2))
2326 /* DCB in VT mode */
2327 if (!strncmp(res->vt_en, "on", 2))
2328 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2329 (enum rte_eth_nb_tcs)res->num_tcs,
2332 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2333 (enum rte_eth_nb_tcs)res->num_tcs,
2338 printf("Cannot initialize network ports.\n");
2342 cmd_reconfig_device_queue(port_id, 1, 1);
2345 cmdline_parse_token_string_t cmd_config_dcb_port =
2346 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2347 cmdline_parse_token_string_t cmd_config_dcb_config =
2348 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2349 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2350 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2351 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2352 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2353 cmdline_parse_token_string_t cmd_config_dcb_vt =
2354 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2355 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2356 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2357 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2358 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2359 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2360 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2361 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2362 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2364 cmdline_parse_inst_t cmd_config_dcb = {
2365 .f = cmd_config_dcb_parsed,
2367 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2369 (void *)&cmd_config_dcb_port,
2370 (void *)&cmd_config_dcb_config,
2371 (void *)&cmd_config_dcb_port_id,
2372 (void *)&cmd_config_dcb_dcb,
2373 (void *)&cmd_config_dcb_vt,
2374 (void *)&cmd_config_dcb_vt_en,
2375 (void *)&cmd_config_dcb_num_tcs,
2376 (void *)&cmd_config_dcb_pfc,
2377 (void *)&cmd_config_dcb_pfc_en,
2382 /* *** configure number of packets per burst *** */
2383 struct cmd_config_burst {
2384 cmdline_fixed_string_t port;
2385 cmdline_fixed_string_t keyword;
2386 cmdline_fixed_string_t all;
2387 cmdline_fixed_string_t name;
2392 cmd_config_burst_parsed(void *parsed_result,
2393 __attribute__((unused)) struct cmdline *cl,
2394 __attribute__((unused)) void *data)
2396 struct cmd_config_burst *res = parsed_result;
2398 if (!all_ports_stopped()) {
2399 printf("Please stop all ports first\n");
2403 if (!strcmp(res->name, "burst")) {
2404 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2405 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2408 nb_pkt_per_burst = res->value;
2410 printf("Unknown parameter\n");
2416 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2419 cmdline_parse_token_string_t cmd_config_burst_port =
2420 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2421 cmdline_parse_token_string_t cmd_config_burst_keyword =
2422 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2423 cmdline_parse_token_string_t cmd_config_burst_all =
2424 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2425 cmdline_parse_token_string_t cmd_config_burst_name =
2426 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2427 cmdline_parse_token_num_t cmd_config_burst_value =
2428 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2430 cmdline_parse_inst_t cmd_config_burst = {
2431 .f = cmd_config_burst_parsed,
2433 .help_str = "port config all burst <value>",
2435 (void *)&cmd_config_burst_port,
2436 (void *)&cmd_config_burst_keyword,
2437 (void *)&cmd_config_burst_all,
2438 (void *)&cmd_config_burst_name,
2439 (void *)&cmd_config_burst_value,
2444 /* *** configure rx/tx queues *** */
2445 struct cmd_config_thresh {
2446 cmdline_fixed_string_t port;
2447 cmdline_fixed_string_t keyword;
2448 cmdline_fixed_string_t all;
2449 cmdline_fixed_string_t name;
2454 cmd_config_thresh_parsed(void *parsed_result,
2455 __attribute__((unused)) struct cmdline *cl,
2456 __attribute__((unused)) void *data)
2458 struct cmd_config_thresh *res = parsed_result;
2460 if (!all_ports_stopped()) {
2461 printf("Please stop all ports first\n");
2465 if (!strcmp(res->name, "txpt"))
2466 tx_pthresh = res->value;
2467 else if(!strcmp(res->name, "txht"))
2468 tx_hthresh = res->value;
2469 else if(!strcmp(res->name, "txwt"))
2470 tx_wthresh = res->value;
2471 else if(!strcmp(res->name, "rxpt"))
2472 rx_pthresh = res->value;
2473 else if(!strcmp(res->name, "rxht"))
2474 rx_hthresh = res->value;
2475 else if(!strcmp(res->name, "rxwt"))
2476 rx_wthresh = res->value;
2478 printf("Unknown parameter\n");
2484 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2487 cmdline_parse_token_string_t cmd_config_thresh_port =
2488 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2489 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2490 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2491 cmdline_parse_token_string_t cmd_config_thresh_all =
2492 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2493 cmdline_parse_token_string_t cmd_config_thresh_name =
2494 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2495 "txpt#txht#txwt#rxpt#rxht#rxwt");
2496 cmdline_parse_token_num_t cmd_config_thresh_value =
2497 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2499 cmdline_parse_inst_t cmd_config_thresh = {
2500 .f = cmd_config_thresh_parsed,
2502 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2504 (void *)&cmd_config_thresh_port,
2505 (void *)&cmd_config_thresh_keyword,
2506 (void *)&cmd_config_thresh_all,
2507 (void *)&cmd_config_thresh_name,
2508 (void *)&cmd_config_thresh_value,
2513 /* *** configure free/rs threshold *** */
2514 struct cmd_config_threshold {
2515 cmdline_fixed_string_t port;
2516 cmdline_fixed_string_t keyword;
2517 cmdline_fixed_string_t all;
2518 cmdline_fixed_string_t name;
2523 cmd_config_threshold_parsed(void *parsed_result,
2524 __attribute__((unused)) struct cmdline *cl,
2525 __attribute__((unused)) void *data)
2527 struct cmd_config_threshold *res = parsed_result;
2529 if (!all_ports_stopped()) {
2530 printf("Please stop all ports first\n");
2534 if (!strcmp(res->name, "txfreet"))
2535 tx_free_thresh = res->value;
2536 else if (!strcmp(res->name, "txrst"))
2537 tx_rs_thresh = res->value;
2538 else if (!strcmp(res->name, "rxfreet"))
2539 rx_free_thresh = res->value;
2541 printf("Unknown parameter\n");
2547 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2550 cmdline_parse_token_string_t cmd_config_threshold_port =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2552 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2555 cmdline_parse_token_string_t cmd_config_threshold_all =
2556 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2557 cmdline_parse_token_string_t cmd_config_threshold_name =
2558 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2559 "txfreet#txrst#rxfreet");
2560 cmdline_parse_token_num_t cmd_config_threshold_value =
2561 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2563 cmdline_parse_inst_t cmd_config_threshold = {
2564 .f = cmd_config_threshold_parsed,
2566 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2568 (void *)&cmd_config_threshold_port,
2569 (void *)&cmd_config_threshold_keyword,
2570 (void *)&cmd_config_threshold_all,
2571 (void *)&cmd_config_threshold_name,
2572 (void *)&cmd_config_threshold_value,
2578 struct cmd_stop_result {
2579 cmdline_fixed_string_t stop;
2582 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2583 __attribute__((unused)) struct cmdline *cl,
2584 __attribute__((unused)) void *data)
2586 stop_packet_forwarding();
2589 cmdline_parse_token_string_t cmd_stop_stop =
2590 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2592 cmdline_parse_inst_t cmd_stop = {
2593 .f = cmd_stop_parsed,
2595 .help_str = "stop: Stop packet forwarding",
2597 (void *)&cmd_stop_stop,
2602 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2605 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2606 unsigned int *parsed_items, int check_unique_values)
2608 unsigned int nb_item;
2616 * First parse all items in the list and store their value.
2621 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2623 if ((c >= '0') && (c <= '9')) {
2624 value = (unsigned int) (value * 10 + (c - '0'));
2629 printf("character %c is not a decimal digit\n", c);
2633 printf("No valid value before comma\n");
2636 if (nb_item < max_items) {
2637 parsed_items[nb_item] = value;
2643 if (nb_item >= max_items) {
2644 printf("Number of %s = %u > %u (maximum items)\n",
2645 item_name, nb_item + 1, max_items);
2648 parsed_items[nb_item++] = value;
2649 if (! check_unique_values)
2653 * Then, check that all values in the list are differents.
2654 * No optimization here...
2656 for (i = 0; i < nb_item; i++) {
2657 for (j = i + 1; j < nb_item; j++) {
2658 if (parsed_items[j] == parsed_items[i]) {
2659 printf("duplicated %s %u at index %u and %u\n",
2660 item_name, parsed_items[i], i, j);
2668 struct cmd_set_list_result {
2669 cmdline_fixed_string_t cmd_keyword;
2670 cmdline_fixed_string_t list_name;
2671 cmdline_fixed_string_t list_of_items;
2674 static void cmd_set_list_parsed(void *parsed_result,
2675 __attribute__((unused)) struct cmdline *cl,
2676 __attribute__((unused)) void *data)
2678 struct cmd_set_list_result *res;
2680 unsigned int lcorelist[RTE_MAX_LCORE];
2681 unsigned int portlist[RTE_MAX_ETHPORTS];
2683 unsigned int nb_item;
2685 if (test_done == 0) {
2686 printf("Please stop forwarding first\n");
2690 res = parsed_result;
2691 if (!strcmp(res->list_name, "corelist")) {
2692 nb_item = parse_item_list(res->list_of_items, "core",
2694 parsed_items.lcorelist, 1);
2696 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2701 if (!strcmp(res->list_name, "portlist")) {
2702 nb_item = parse_item_list(res->list_of_items, "port",
2704 parsed_items.portlist, 1);
2706 set_fwd_ports_list(parsed_items.portlist, nb_item);
2712 cmdline_parse_token_string_t cmd_set_list_keyword =
2713 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2715 cmdline_parse_token_string_t cmd_set_list_name =
2716 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2717 "corelist#portlist");
2718 cmdline_parse_token_string_t cmd_set_list_of_items =
2719 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2722 cmdline_parse_inst_t cmd_set_fwd_list = {
2723 .f = cmd_set_list_parsed,
2725 .help_str = "set corelist|portlist <list0[,list1]*>",
2727 (void *)&cmd_set_list_keyword,
2728 (void *)&cmd_set_list_name,
2729 (void *)&cmd_set_list_of_items,
2734 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2736 struct cmd_setmask_result {
2737 cmdline_fixed_string_t set;
2738 cmdline_fixed_string_t mask;
2742 static void cmd_set_mask_parsed(void *parsed_result,
2743 __attribute__((unused)) struct cmdline *cl,
2744 __attribute__((unused)) void *data)
2746 struct cmd_setmask_result *res = parsed_result;
2748 if (test_done == 0) {
2749 printf("Please stop forwarding first\n");
2752 if (!strcmp(res->mask, "coremask")) {
2753 set_fwd_lcores_mask(res->hexavalue);
2755 } else if (!strcmp(res->mask, "portmask")) {
2756 set_fwd_ports_mask(res->hexavalue);
2761 cmdline_parse_token_string_t cmd_setmask_set =
2762 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2763 cmdline_parse_token_string_t cmd_setmask_mask =
2764 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2765 "coremask#portmask");
2766 cmdline_parse_token_num_t cmd_setmask_value =
2767 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2769 cmdline_parse_inst_t cmd_set_fwd_mask = {
2770 .f = cmd_set_mask_parsed,
2772 .help_str = "set coremask|portmask <hexadecimal value>",
2774 (void *)&cmd_setmask_set,
2775 (void *)&cmd_setmask_mask,
2776 (void *)&cmd_setmask_value,
2782 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2784 struct cmd_set_result {
2785 cmdline_fixed_string_t set;
2786 cmdline_fixed_string_t what;
2790 static void cmd_set_parsed(void *parsed_result,
2791 __attribute__((unused)) struct cmdline *cl,
2792 __attribute__((unused)) void *data)
2794 struct cmd_set_result *res = parsed_result;
2795 if (!strcmp(res->what, "nbport")) {
2796 set_fwd_ports_number(res->value);
2798 } else if (!strcmp(res->what, "nbcore")) {
2799 set_fwd_lcores_number(res->value);
2801 } else if (!strcmp(res->what, "burst"))
2802 set_nb_pkt_per_burst(res->value);
2803 else if (!strcmp(res->what, "verbose"))
2804 set_verbose_level(res->value);
2807 cmdline_parse_token_string_t cmd_set_set =
2808 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2809 cmdline_parse_token_string_t cmd_set_what =
2810 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2811 "nbport#nbcore#burst#verbose");
2812 cmdline_parse_token_num_t cmd_set_value =
2813 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2815 cmdline_parse_inst_t cmd_set_numbers = {
2816 .f = cmd_set_parsed,
2818 .help_str = "set nbport|nbcore|burst|verbose <value>",
2820 (void *)&cmd_set_set,
2821 (void *)&cmd_set_what,
2822 (void *)&cmd_set_value,
2827 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2829 struct cmd_set_txpkts_result {
2830 cmdline_fixed_string_t cmd_keyword;
2831 cmdline_fixed_string_t txpkts;
2832 cmdline_fixed_string_t seg_lengths;
2836 cmd_set_txpkts_parsed(void *parsed_result,
2837 __attribute__((unused)) struct cmdline *cl,
2838 __attribute__((unused)) void *data)
2840 struct cmd_set_txpkts_result *res;
2841 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2842 unsigned int nb_segs;
2844 res = parsed_result;
2845 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2846 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2848 set_tx_pkt_segments(seg_lengths, nb_segs);
2851 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2852 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2853 cmd_keyword, "set");
2854 cmdline_parse_token_string_t cmd_set_txpkts_name =
2855 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2857 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2858 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2861 cmdline_parse_inst_t cmd_set_txpkts = {
2862 .f = cmd_set_txpkts_parsed,
2864 .help_str = "set txpkts <len0[,len1]*>",
2866 (void *)&cmd_set_txpkts_keyword,
2867 (void *)&cmd_set_txpkts_name,
2868 (void *)&cmd_set_txpkts_lengths,
2873 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2875 struct cmd_set_txsplit_result {
2876 cmdline_fixed_string_t cmd_keyword;
2877 cmdline_fixed_string_t txsplit;
2878 cmdline_fixed_string_t mode;
2882 cmd_set_txsplit_parsed(void *parsed_result,
2883 __attribute__((unused)) struct cmdline *cl,
2884 __attribute__((unused)) void *data)
2886 struct cmd_set_txsplit_result *res;
2888 res = parsed_result;
2889 set_tx_pkt_split(res->mode);
2892 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2893 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2894 cmd_keyword, "set");
2895 cmdline_parse_token_string_t cmd_set_txsplit_name =
2896 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2897 txsplit, "txsplit");
2898 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2899 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2902 cmdline_parse_inst_t cmd_set_txsplit = {
2903 .f = cmd_set_txsplit_parsed,
2905 .help_str = "set txsplit on|off|rand",
2907 (void *)&cmd_set_txsplit_keyword,
2908 (void *)&cmd_set_txsplit_name,
2909 (void *)&cmd_set_txsplit_mode,
2914 /* *** CONFIG TX QUEUE FLAGS *** */
2916 struct cmd_config_txqflags_result {
2917 cmdline_fixed_string_t port;
2918 cmdline_fixed_string_t config;
2919 cmdline_fixed_string_t all;
2920 cmdline_fixed_string_t what;
2924 static void cmd_config_txqflags_parsed(void *parsed_result,
2925 __attribute__((unused)) struct cmdline *cl,
2926 __attribute__((unused)) void *data)
2928 struct cmd_config_txqflags_result *res = parsed_result;
2930 if (!all_ports_stopped()) {
2931 printf("Please stop all ports first\n");
2935 if (strcmp(res->what, "txqflags")) {
2936 printf("Unknown parameter\n");
2940 if (res->hexvalue >= 0) {
2941 txq_flags = res->hexvalue;
2943 printf("txqflags must be >= 0\n");
2949 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2952 cmdline_parse_token_string_t cmd_config_txqflags_port =
2953 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2955 cmdline_parse_token_string_t cmd_config_txqflags_config =
2956 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2958 cmdline_parse_token_string_t cmd_config_txqflags_all =
2959 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2961 cmdline_parse_token_string_t cmd_config_txqflags_what =
2962 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2964 cmdline_parse_token_num_t cmd_config_txqflags_value =
2965 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2968 cmdline_parse_inst_t cmd_config_txqflags = {
2969 .f = cmd_config_txqflags_parsed,
2971 .help_str = "port config all txqflags <value>",
2973 (void *)&cmd_config_txqflags_port,
2974 (void *)&cmd_config_txqflags_config,
2975 (void *)&cmd_config_txqflags_all,
2976 (void *)&cmd_config_txqflags_what,
2977 (void *)&cmd_config_txqflags_value,
2982 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2983 struct cmd_rx_vlan_filter_all_result {
2984 cmdline_fixed_string_t rx_vlan;
2985 cmdline_fixed_string_t what;
2986 cmdline_fixed_string_t all;
2991 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2992 __attribute__((unused)) struct cmdline *cl,
2993 __attribute__((unused)) void *data)
2995 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2997 if (!strcmp(res->what, "add"))
2998 rx_vlan_all_filter_set(res->port_id, 1);
3000 rx_vlan_all_filter_set(res->port_id, 0);
3003 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3004 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3005 rx_vlan, "rx_vlan");
3006 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3007 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3009 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3010 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3012 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3013 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3016 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3017 .f = cmd_rx_vlan_filter_all_parsed,
3019 .help_str = "rx_vlan add|rm all <port_id>: "
3020 "Add/Remove all identifiers to/from the set of VLAN "
3021 "identifiers filtered by a port",
3023 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3024 (void *)&cmd_rx_vlan_filter_all_what,
3025 (void *)&cmd_rx_vlan_filter_all_all,
3026 (void *)&cmd_rx_vlan_filter_all_portid,
3031 /* *** VLAN OFFLOAD SET ON A PORT *** */
3032 struct cmd_vlan_offload_result {
3033 cmdline_fixed_string_t vlan;
3034 cmdline_fixed_string_t set;
3035 cmdline_fixed_string_t vlan_type;
3036 cmdline_fixed_string_t what;
3037 cmdline_fixed_string_t on;
3038 cmdline_fixed_string_t port_id;
3042 cmd_vlan_offload_parsed(void *parsed_result,
3043 __attribute__((unused)) struct cmdline *cl,
3044 __attribute__((unused)) void *data)
3047 struct cmd_vlan_offload_result *res = parsed_result;
3050 portid_t port_id = 0;
3054 len = strnlen(str, STR_TOKEN_SIZE);
3056 /* Get port_id first */
3064 tmp = strtoul(str, NULL, 0);
3065 /* If port_id greater that what portid_t can represent, return */
3066 if(tmp >= RTE_MAX_ETHPORTS)
3068 port_id = (portid_t)tmp;
3070 if (!strcmp(res->on, "on"))
3075 if (!strcmp(res->what, "strip"))
3076 rx_vlan_strip_set(port_id, on);
3077 else if(!strcmp(res->what, "stripq")){
3078 uint16_t queue_id = 0;
3080 /* No queue_id, return */
3082 printf("must specify (port,queue_id)\n");
3085 tmp = strtoul(str + i + 1, NULL, 0);
3086 /* If queue_id greater that what 16-bits can represent, return */
3090 queue_id = (uint16_t)tmp;
3091 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3093 else if (!strcmp(res->what, "filter"))
3094 rx_vlan_filter_set(port_id, on);
3096 vlan_extend_set(port_id, on);
3101 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3102 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3104 cmdline_parse_token_string_t cmd_vlan_offload_set =
3105 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3107 cmdline_parse_token_string_t cmd_vlan_offload_what =
3108 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3109 what, "strip#filter#qinq#stripq");
3110 cmdline_parse_token_string_t cmd_vlan_offload_on =
3111 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3113 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3114 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3117 cmdline_parse_inst_t cmd_vlan_offload = {
3118 .f = cmd_vlan_offload_parsed,
3120 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3121 "<port_id[,queue_id]>: "
3122 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3124 (void *)&cmd_vlan_offload_vlan,
3125 (void *)&cmd_vlan_offload_set,
3126 (void *)&cmd_vlan_offload_what,
3127 (void *)&cmd_vlan_offload_on,
3128 (void *)&cmd_vlan_offload_portid,
3133 /* *** VLAN TPID SET ON A PORT *** */
3134 struct cmd_vlan_tpid_result {
3135 cmdline_fixed_string_t vlan;
3136 cmdline_fixed_string_t set;
3137 cmdline_fixed_string_t vlan_type;
3138 cmdline_fixed_string_t what;
3144 cmd_vlan_tpid_parsed(void *parsed_result,
3145 __attribute__((unused)) struct cmdline *cl,
3146 __attribute__((unused)) void *data)
3148 struct cmd_vlan_tpid_result *res = parsed_result;
3149 enum rte_vlan_type vlan_type;
3151 if (!strcmp(res->vlan_type, "inner"))
3152 vlan_type = ETH_VLAN_TYPE_INNER;
3153 else if (!strcmp(res->vlan_type, "outer"))
3154 vlan_type = ETH_VLAN_TYPE_OUTER;
3156 printf("Unknown vlan type\n");
3159 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3162 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3163 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3165 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3166 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3168 cmdline_parse_token_string_t cmd_vlan_type =
3169 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3170 vlan_type, "inner#outer");
3171 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3172 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3174 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3175 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3177 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3178 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3181 cmdline_parse_inst_t cmd_vlan_tpid = {
3182 .f = cmd_vlan_tpid_parsed,
3184 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3185 "Set the VLAN Ether type",
3187 (void *)&cmd_vlan_tpid_vlan,
3188 (void *)&cmd_vlan_tpid_set,
3189 (void *)&cmd_vlan_type,
3190 (void *)&cmd_vlan_tpid_what,
3191 (void *)&cmd_vlan_tpid_tpid,
3192 (void *)&cmd_vlan_tpid_portid,
3197 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3198 struct cmd_rx_vlan_filter_result {
3199 cmdline_fixed_string_t rx_vlan;
3200 cmdline_fixed_string_t what;
3206 cmd_rx_vlan_filter_parsed(void *parsed_result,
3207 __attribute__((unused)) struct cmdline *cl,
3208 __attribute__((unused)) void *data)
3210 struct cmd_rx_vlan_filter_result *res = parsed_result;
3212 if (!strcmp(res->what, "add"))
3213 rx_vft_set(res->port_id, res->vlan_id, 1);
3215 rx_vft_set(res->port_id, res->vlan_id, 0);
3218 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3219 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3220 rx_vlan, "rx_vlan");
3221 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3222 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3224 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3225 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3227 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3228 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3231 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3232 .f = cmd_rx_vlan_filter_parsed,
3234 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3235 "Add/Remove a VLAN identifier to/from the set of VLAN "
3236 "identifiers filtered by a port",
3238 (void *)&cmd_rx_vlan_filter_rx_vlan,
3239 (void *)&cmd_rx_vlan_filter_what,
3240 (void *)&cmd_rx_vlan_filter_vlanid,
3241 (void *)&cmd_rx_vlan_filter_portid,
3246 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3247 struct cmd_tx_vlan_set_result {
3248 cmdline_fixed_string_t tx_vlan;
3249 cmdline_fixed_string_t set;
3255 cmd_tx_vlan_set_parsed(void *parsed_result,
3256 __attribute__((unused)) struct cmdline *cl,
3257 __attribute__((unused)) void *data)
3259 struct cmd_tx_vlan_set_result *res = parsed_result;
3261 tx_vlan_set(res->port_id, res->vlan_id);
3264 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3265 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3266 tx_vlan, "tx_vlan");
3267 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3268 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3270 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3271 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3273 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3274 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3277 cmdline_parse_inst_t cmd_tx_vlan_set = {
3278 .f = cmd_tx_vlan_set_parsed,
3280 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3281 "Enable hardware insertion of a single VLAN header "
3282 "with a given TAG Identifier in packets sent on a port",
3284 (void *)&cmd_tx_vlan_set_tx_vlan,
3285 (void *)&cmd_tx_vlan_set_set,
3286 (void *)&cmd_tx_vlan_set_portid,
3287 (void *)&cmd_tx_vlan_set_vlanid,
3292 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3293 struct cmd_tx_vlan_set_qinq_result {
3294 cmdline_fixed_string_t tx_vlan;
3295 cmdline_fixed_string_t set;
3298 uint16_t vlan_id_outer;
3302 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3303 __attribute__((unused)) struct cmdline *cl,
3304 __attribute__((unused)) void *data)
3306 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3308 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3311 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3312 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3313 tx_vlan, "tx_vlan");
3314 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3315 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3317 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3318 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3320 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3321 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3323 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3324 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3325 vlan_id_outer, UINT16);
3327 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3328 .f = cmd_tx_vlan_set_qinq_parsed,
3330 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3331 "Enable hardware insertion of double VLAN header "
3332 "with given TAG Identifiers in packets sent on a port",
3334 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3335 (void *)&cmd_tx_vlan_set_qinq_set,
3336 (void *)&cmd_tx_vlan_set_qinq_portid,
3337 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3338 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3343 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3344 struct cmd_tx_vlan_set_pvid_result {
3345 cmdline_fixed_string_t tx_vlan;
3346 cmdline_fixed_string_t set;
3347 cmdline_fixed_string_t pvid;
3350 cmdline_fixed_string_t mode;
3354 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3355 __attribute__((unused)) struct cmdline *cl,
3356 __attribute__((unused)) void *data)
3358 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3360 if (strcmp(res->mode, "on") == 0)
3361 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3363 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3366 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3367 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3368 tx_vlan, "tx_vlan");
3369 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3370 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3372 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3373 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3375 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3376 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3378 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3379 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3381 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3382 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3385 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3386 .f = cmd_tx_vlan_set_pvid_parsed,
3388 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3390 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3391 (void *)&cmd_tx_vlan_set_pvid_set,
3392 (void *)&cmd_tx_vlan_set_pvid_pvid,
3393 (void *)&cmd_tx_vlan_set_pvid_port_id,
3394 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3395 (void *)&cmd_tx_vlan_set_pvid_mode,
3400 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3401 struct cmd_tx_vlan_reset_result {
3402 cmdline_fixed_string_t tx_vlan;
3403 cmdline_fixed_string_t reset;
3408 cmd_tx_vlan_reset_parsed(void *parsed_result,
3409 __attribute__((unused)) struct cmdline *cl,
3410 __attribute__((unused)) void *data)
3412 struct cmd_tx_vlan_reset_result *res = parsed_result;
3414 tx_vlan_reset(res->port_id);
3417 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3418 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3419 tx_vlan, "tx_vlan");
3420 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3421 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3423 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3424 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3427 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3428 .f = cmd_tx_vlan_reset_parsed,
3430 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3431 "VLAN header in packets sent on a port",
3433 (void *)&cmd_tx_vlan_reset_tx_vlan,
3434 (void *)&cmd_tx_vlan_reset_reset,
3435 (void *)&cmd_tx_vlan_reset_portid,
3441 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3442 struct cmd_csum_result {
3443 cmdline_fixed_string_t csum;
3444 cmdline_fixed_string_t mode;
3445 cmdline_fixed_string_t proto;
3446 cmdline_fixed_string_t hwsw;
3451 csum_show(int port_id)
3453 struct rte_eth_dev_info dev_info;
3456 ol_flags = ports[port_id].tx_ol_flags;
3457 printf("Parse tunnel is %s\n",
3458 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3459 printf("IP checksum offload is %s\n",
3460 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3461 printf("UDP checksum offload is %s\n",
3462 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3463 printf("TCP checksum offload is %s\n",
3464 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3465 printf("SCTP checksum offload is %s\n",
3466 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3467 printf("Outer-Ip checksum offload is %s\n",
3468 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3470 /* display warnings if configuration is not supported by the NIC */
3471 rte_eth_dev_info_get(port_id, &dev_info);
3472 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3473 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3474 printf("Warning: hardware IP checksum enabled but not "
3475 "supported by port %d\n", port_id);
3477 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3478 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3479 printf("Warning: hardware UDP checksum enabled but not "
3480 "supported by port %d\n", port_id);
3482 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3483 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3484 printf("Warning: hardware TCP checksum enabled but not "
3485 "supported by port %d\n", port_id);
3487 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3488 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3489 printf("Warning: hardware SCTP checksum enabled but not "
3490 "supported by port %d\n", port_id);
3492 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3493 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3494 printf("Warning: hardware outer IP checksum enabled but not "
3495 "supported by port %d\n", port_id);
3500 cmd_csum_parsed(void *parsed_result,
3501 __attribute__((unused)) struct cmdline *cl,
3502 __attribute__((unused)) void *data)
3504 struct cmd_csum_result *res = parsed_result;
3508 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3509 printf("invalid port %d\n", res->port_id);
3513 if (!strcmp(res->mode, "set")) {
3515 if (!strcmp(res->hwsw, "hw"))
3518 if (!strcmp(res->proto, "ip")) {
3519 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3520 } else if (!strcmp(res->proto, "udp")) {
3521 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3522 } else if (!strcmp(res->proto, "tcp")) {
3523 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3524 } else if (!strcmp(res->proto, "sctp")) {
3525 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3526 } else if (!strcmp(res->proto, "outer-ip")) {
3527 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3531 ports[res->port_id].tx_ol_flags |= mask;
3533 ports[res->port_id].tx_ol_flags &= (~mask);
3535 csum_show(res->port_id);
3538 cmdline_parse_token_string_t cmd_csum_csum =
3539 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3541 cmdline_parse_token_string_t cmd_csum_mode =
3542 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3544 cmdline_parse_token_string_t cmd_csum_proto =
3545 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3546 proto, "ip#tcp#udp#sctp#outer-ip");
3547 cmdline_parse_token_string_t cmd_csum_hwsw =
3548 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3550 cmdline_parse_token_num_t cmd_csum_portid =
3551 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3554 cmdline_parse_inst_t cmd_csum_set = {
3555 .f = cmd_csum_parsed,
3557 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3558 "Enable/Disable hardware calculation of L3/L4 checksum when "
3559 "using csum forward engine",
3561 (void *)&cmd_csum_csum,
3562 (void *)&cmd_csum_mode,
3563 (void *)&cmd_csum_proto,
3564 (void *)&cmd_csum_hwsw,
3565 (void *)&cmd_csum_portid,
3570 cmdline_parse_token_string_t cmd_csum_mode_show =
3571 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3574 cmdline_parse_inst_t cmd_csum_show = {
3575 .f = cmd_csum_parsed,
3577 .help_str = "csum show <port_id>: Show checksum offload configuration",
3579 (void *)&cmd_csum_csum,
3580 (void *)&cmd_csum_mode_show,
3581 (void *)&cmd_csum_portid,
3586 /* Enable/disable tunnel parsing */
3587 struct cmd_csum_tunnel_result {
3588 cmdline_fixed_string_t csum;
3589 cmdline_fixed_string_t parse;
3590 cmdline_fixed_string_t onoff;
3595 cmd_csum_tunnel_parsed(void *parsed_result,
3596 __attribute__((unused)) struct cmdline *cl,
3597 __attribute__((unused)) void *data)
3599 struct cmd_csum_tunnel_result *res = parsed_result;
3601 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3604 if (!strcmp(res->onoff, "on"))
3605 ports[res->port_id].tx_ol_flags |=
3606 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3608 ports[res->port_id].tx_ol_flags &=
3609 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3611 csum_show(res->port_id);
3614 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3615 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3617 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3618 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3619 parse, "parse_tunnel");
3620 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3621 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3623 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3624 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3627 cmdline_parse_inst_t cmd_csum_tunnel = {
3628 .f = cmd_csum_tunnel_parsed,
3630 .help_str = "csum parse_tunnel on|off <port_id>: "
3631 "Enable/Disable parsing of tunnels for csum engine",
3633 (void *)&cmd_csum_tunnel_csum,
3634 (void *)&cmd_csum_tunnel_parse,
3635 (void *)&cmd_csum_tunnel_onoff,
3636 (void *)&cmd_csum_tunnel_portid,
3641 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3642 struct cmd_tso_set_result {
3643 cmdline_fixed_string_t tso;
3644 cmdline_fixed_string_t mode;
3650 cmd_tso_set_parsed(void *parsed_result,
3651 __attribute__((unused)) struct cmdline *cl,
3652 __attribute__((unused)) void *data)
3654 struct cmd_tso_set_result *res = parsed_result;
3655 struct rte_eth_dev_info dev_info;
3657 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3660 if (!strcmp(res->mode, "set"))
3661 ports[res->port_id].tso_segsz = res->tso_segsz;
3663 if (ports[res->port_id].tso_segsz == 0)
3664 printf("TSO for non-tunneled packets is disabled\n");
3666 printf("TSO segment size for non-tunneled packets is %d\n",
3667 ports[res->port_id].tso_segsz);
3669 /* display warnings if configuration is not supported by the NIC */
3670 rte_eth_dev_info_get(res->port_id, &dev_info);
3671 if ((ports[res->port_id].tso_segsz != 0) &&
3672 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3673 printf("Warning: TSO enabled but not "
3674 "supported by port %d\n", res->port_id);
3678 cmdline_parse_token_string_t cmd_tso_set_tso =
3679 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3681 cmdline_parse_token_string_t cmd_tso_set_mode =
3682 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3684 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3685 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3687 cmdline_parse_token_num_t cmd_tso_set_portid =
3688 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3691 cmdline_parse_inst_t cmd_tso_set = {
3692 .f = cmd_tso_set_parsed,
3694 .help_str = "tso set <tso_segsz> <port_id>: "
3695 "Set TSO segment size of non-tunneled packets for csum engine "
3698 (void *)&cmd_tso_set_tso,
3699 (void *)&cmd_tso_set_mode,
3700 (void *)&cmd_tso_set_tso_segsz,
3701 (void *)&cmd_tso_set_portid,
3706 cmdline_parse_token_string_t cmd_tso_show_mode =
3707 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3711 cmdline_parse_inst_t cmd_tso_show = {
3712 .f = cmd_tso_set_parsed,
3714 .help_str = "tso show <port_id>: "
3715 "Show TSO segment size of non-tunneled packets for csum engine",
3717 (void *)&cmd_tso_set_tso,
3718 (void *)&cmd_tso_show_mode,
3719 (void *)&cmd_tso_set_portid,
3724 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3725 struct cmd_tunnel_tso_set_result {
3726 cmdline_fixed_string_t tso;
3727 cmdline_fixed_string_t mode;
3733 check_tunnel_tso_nic_support(uint8_t port_id)
3735 struct rte_eth_dev_info dev_info;
3737 rte_eth_dev_info_get(port_id, &dev_info);
3738 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3739 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3740 "supported by port %d\n", port_id);
3741 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3742 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3743 "supported by port %d\n", port_id);
3744 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3745 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3746 "supported by port %d\n", port_id);
3747 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3748 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3749 "supported by port %d\n", port_id);
3753 cmd_tunnel_tso_set_parsed(void *parsed_result,
3754 __attribute__((unused)) struct cmdline *cl,
3755 __attribute__((unused)) void *data)
3757 struct cmd_tunnel_tso_set_result *res = parsed_result;
3759 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3762 if (!strcmp(res->mode, "set"))
3763 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3765 if (ports[res->port_id].tunnel_tso_segsz == 0)
3766 printf("TSO for tunneled packets is disabled\n");
3768 printf("TSO segment size for tunneled packets is %d\n",
3769 ports[res->port_id].tunnel_tso_segsz);
3771 /* Below conditions are needed to make it work:
3772 * (1) tunnel TSO is supported by the NIC;
3773 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3775 * (3) for tunneled pkts with outer L3 of IPv4,
3776 * "csum set outer-ip" must be set to hw, because after tso,
3777 * total_len of outer IP header is changed, and the checksum
3778 * of outer IP header calculated by sw should be wrong; that
3779 * is not necessary for IPv6 tunneled pkts because there's no
3780 * checksum in IP header anymore.
3782 check_tunnel_tso_nic_support(res->port_id);
3784 if (!(ports[res->port_id].tx_ol_flags &
3785 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3786 printf("Warning: csum parse_tunnel must be set "
3787 "so that tunneled packets are recognized\n");
3788 if (!(ports[res->port_id].tx_ol_flags &
3789 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3790 printf("Warning: csum set outer-ip must be set to hw "
3791 "if outer L3 is IPv4; not necessary for IPv6\n");
3795 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3796 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3798 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3799 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3801 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3802 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3804 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3805 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3808 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3809 .f = cmd_tunnel_tso_set_parsed,
3811 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3812 "Set TSO segment size of tunneled packets for csum engine "
3815 (void *)&cmd_tunnel_tso_set_tso,
3816 (void *)&cmd_tunnel_tso_set_mode,
3817 (void *)&cmd_tunnel_tso_set_tso_segsz,
3818 (void *)&cmd_tunnel_tso_set_portid,
3823 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3824 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3828 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3829 .f = cmd_tunnel_tso_set_parsed,
3831 .help_str = "tunnel_tso show <port_id> "
3832 "Show TSO segment size of tunneled packets for csum engine",
3834 (void *)&cmd_tunnel_tso_set_tso,
3835 (void *)&cmd_tunnel_tso_show_mode,
3836 (void *)&cmd_tunnel_tso_set_portid,
3841 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3842 struct cmd_set_flush_rx {
3843 cmdline_fixed_string_t set;
3844 cmdline_fixed_string_t flush_rx;
3845 cmdline_fixed_string_t mode;
3849 cmd_set_flush_rx_parsed(void *parsed_result,
3850 __attribute__((unused)) struct cmdline *cl,
3851 __attribute__((unused)) void *data)
3853 struct cmd_set_flush_rx *res = parsed_result;
3854 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3857 cmdline_parse_token_string_t cmd_setflushrx_set =
3858 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3860 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3861 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3862 flush_rx, "flush_rx");
3863 cmdline_parse_token_string_t cmd_setflushrx_mode =
3864 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3868 cmdline_parse_inst_t cmd_set_flush_rx = {
3869 .f = cmd_set_flush_rx_parsed,
3870 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3873 (void *)&cmd_setflushrx_set,
3874 (void *)&cmd_setflushrx_flush_rx,
3875 (void *)&cmd_setflushrx_mode,
3880 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3881 struct cmd_set_link_check {
3882 cmdline_fixed_string_t set;
3883 cmdline_fixed_string_t link_check;
3884 cmdline_fixed_string_t mode;
3888 cmd_set_link_check_parsed(void *parsed_result,
3889 __attribute__((unused)) struct cmdline *cl,
3890 __attribute__((unused)) void *data)
3892 struct cmd_set_link_check *res = parsed_result;
3893 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3896 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3897 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3899 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3900 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3901 link_check, "link_check");
3902 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3903 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3907 cmdline_parse_inst_t cmd_set_link_check = {
3908 .f = cmd_set_link_check_parsed,
3909 .help_str = "set link_check on|off: Enable/Disable link status check "
3910 "when starting/stopping a port",
3913 (void *)&cmd_setlinkcheck_set,
3914 (void *)&cmd_setlinkcheck_link_check,
3915 (void *)&cmd_setlinkcheck_mode,
3920 /* *** SET NIC BYPASS MODE *** */
3921 struct cmd_set_bypass_mode_result {
3922 cmdline_fixed_string_t set;
3923 cmdline_fixed_string_t bypass;
3924 cmdline_fixed_string_t mode;
3925 cmdline_fixed_string_t value;
3930 cmd_set_bypass_mode_parsed(void *parsed_result,
3931 __attribute__((unused)) struct cmdline *cl,
3932 __attribute__((unused)) void *data)
3934 struct cmd_set_bypass_mode_result *res = parsed_result;
3935 portid_t port_id = res->port_id;
3936 int32_t rc = -EINVAL;
3938 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
3939 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3941 if (!strcmp(res->value, "bypass"))
3942 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
3943 else if (!strcmp(res->value, "isolate"))
3944 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
3946 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3948 /* Set the bypass mode for the relevant port. */
3949 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
3952 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3955 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3956 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3958 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3959 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3961 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3962 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3964 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3965 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3966 value, "normal#bypass#isolate");
3967 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3968 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3971 cmdline_parse_inst_t cmd_set_bypass_mode = {
3972 .f = cmd_set_bypass_mode_parsed,
3973 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3974 "Set the NIC bypass mode for port_id",
3977 (void *)&cmd_setbypass_mode_set,
3978 (void *)&cmd_setbypass_mode_bypass,
3979 (void *)&cmd_setbypass_mode_mode,
3980 (void *)&cmd_setbypass_mode_value,
3981 (void *)&cmd_setbypass_mode_port,
3986 /* *** SET NIC BYPASS EVENT *** */
3987 struct cmd_set_bypass_event_result {
3988 cmdline_fixed_string_t set;
3989 cmdline_fixed_string_t bypass;
3990 cmdline_fixed_string_t event;
3991 cmdline_fixed_string_t event_value;
3992 cmdline_fixed_string_t mode;
3993 cmdline_fixed_string_t mode_value;
3998 cmd_set_bypass_event_parsed(void *parsed_result,
3999 __attribute__((unused)) struct cmdline *cl,
4000 __attribute__((unused)) void *data)
4002 int32_t rc = -EINVAL;
4003 struct cmd_set_bypass_event_result *res = parsed_result;
4004 portid_t port_id = res->port_id;
4006 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4007 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4008 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4010 if (!strcmp(res->event_value, "timeout"))
4011 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4012 else if (!strcmp(res->event_value, "os_on"))
4013 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4014 else if (!strcmp(res->event_value, "os_off"))
4015 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4016 else if (!strcmp(res->event_value, "power_on"))
4017 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4018 else if (!strcmp(res->event_value, "power_off"))
4019 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4021 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4023 if (!strcmp(res->mode_value, "bypass"))
4024 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4025 else if (!strcmp(res->mode_value, "isolate"))
4026 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4028 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4030 /* Set the watchdog timeout. */
4031 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4034 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4035 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4039 printf("Failed to set timeout value %u "
4040 "for port %d, errto code: %d.\n",
4041 bypass_timeout, port_id, rc);
4045 /* Set the bypass event to transition to bypass mode. */
4046 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4051 printf("\t Failed to set bypass event for port = %d.\n",
4055 cmdline_parse_token_string_t cmd_setbypass_event_set =
4056 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4058 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4059 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4061 cmdline_parse_token_string_t cmd_setbypass_event_event =
4062 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4064 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4065 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4066 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4067 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4068 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4070 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4071 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4072 mode_value, "normal#bypass#isolate");
4073 cmdline_parse_token_num_t cmd_setbypass_event_port =
4074 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4077 cmdline_parse_inst_t cmd_set_bypass_event = {
4078 .f = cmd_set_bypass_event_parsed,
4079 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4080 "power_off mode normal|bypass|isolate <port_id>: "
4081 "Set the NIC bypass event mode for port_id",
4084 (void *)&cmd_setbypass_event_set,
4085 (void *)&cmd_setbypass_event_bypass,
4086 (void *)&cmd_setbypass_event_event,
4087 (void *)&cmd_setbypass_event_event_value,
4088 (void *)&cmd_setbypass_event_mode,
4089 (void *)&cmd_setbypass_event_mode_value,
4090 (void *)&cmd_setbypass_event_port,
4096 /* *** SET NIC BYPASS TIMEOUT *** */
4097 struct cmd_set_bypass_timeout_result {
4098 cmdline_fixed_string_t set;
4099 cmdline_fixed_string_t bypass;
4100 cmdline_fixed_string_t timeout;
4101 cmdline_fixed_string_t value;
4105 cmd_set_bypass_timeout_parsed(void *parsed_result,
4106 __attribute__((unused)) struct cmdline *cl,
4107 __attribute__((unused)) void *data)
4109 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4111 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4112 if (!strcmp(res->value, "1.5"))
4113 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4114 else if (!strcmp(res->value, "2"))
4115 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4116 else if (!strcmp(res->value, "3"))
4117 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4118 else if (!strcmp(res->value, "4"))
4119 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4120 else if (!strcmp(res->value, "8"))
4121 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4122 else if (!strcmp(res->value, "16"))
4123 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4124 else if (!strcmp(res->value, "32"))
4125 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4127 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4131 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4132 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4134 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4135 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4137 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4138 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4139 timeout, "timeout");
4140 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4141 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4142 value, "0#1.5#2#3#4#8#16#32");
4144 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4145 .f = cmd_set_bypass_timeout_parsed,
4146 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4147 "Set the NIC bypass watchdog timeout in seconds",
4150 (void *)&cmd_setbypass_timeout_set,
4151 (void *)&cmd_setbypass_timeout_bypass,
4152 (void *)&cmd_setbypass_timeout_timeout,
4153 (void *)&cmd_setbypass_timeout_value,
4158 /* *** SHOW NIC BYPASS MODE *** */
4159 struct cmd_show_bypass_config_result {
4160 cmdline_fixed_string_t show;
4161 cmdline_fixed_string_t bypass;
4162 cmdline_fixed_string_t config;
4167 cmd_show_bypass_config_parsed(void *parsed_result,
4168 __attribute__((unused)) struct cmdline *cl,
4169 __attribute__((unused)) void *data)
4171 struct cmd_show_bypass_config_result *res = parsed_result;
4172 portid_t port_id = res->port_id;
4174 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4175 uint32_t event_mode;
4176 uint32_t bypass_mode;
4177 uint32_t timeout = bypass_timeout;
4180 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4181 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4182 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4183 {"UNKNOWN", "normal", "bypass", "isolate"};
4184 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4191 int num_events = (sizeof events) / (sizeof events[0]);
4193 /* Display the bypass mode.*/
4194 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4195 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4199 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4200 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4202 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4205 /* Display the bypass timeout.*/
4206 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4207 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4209 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4211 /* Display the bypass events and associated modes. */
4212 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4214 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4215 printf("\tFailed to get bypass mode for event = %s\n",
4218 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4219 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4221 printf("\tbypass event: %-16s = %s\n", events[i],
4227 printf("\tFailed to get bypass configuration for port = %d\n",
4231 cmdline_parse_token_string_t cmd_showbypass_config_show =
4232 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4234 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4235 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4237 cmdline_parse_token_string_t cmd_showbypass_config_config =
4238 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4240 cmdline_parse_token_num_t cmd_showbypass_config_port =
4241 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4244 cmdline_parse_inst_t cmd_show_bypass_config = {
4245 .f = cmd_show_bypass_config_parsed,
4246 .help_str = "show bypass config <port_id>: "
4247 "Show the NIC bypass config for port_id",
4250 (void *)&cmd_showbypass_config_show,
4251 (void *)&cmd_showbypass_config_bypass,
4252 (void *)&cmd_showbypass_config_config,
4253 (void *)&cmd_showbypass_config_port,
4258 #ifdef RTE_LIBRTE_PMD_BOND
4259 /* *** SET BONDING MODE *** */
4260 struct cmd_set_bonding_mode_result {
4261 cmdline_fixed_string_t set;
4262 cmdline_fixed_string_t bonding;
4263 cmdline_fixed_string_t mode;
4268 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4269 __attribute__((unused)) struct cmdline *cl,
4270 __attribute__((unused)) void *data)
4272 struct cmd_set_bonding_mode_result *res = parsed_result;
4273 portid_t port_id = res->port_id;
4275 /* Set the bonding mode for the relevant port. */
4276 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4277 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4280 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4281 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4283 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4284 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4285 bonding, "bonding");
4286 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4287 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4289 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4290 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4292 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4293 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4296 cmdline_parse_inst_t cmd_set_bonding_mode = {
4297 .f = cmd_set_bonding_mode_parsed,
4298 .help_str = "set bonding mode <mode_value> <port_id>: "
4299 "Set the bonding mode for port_id",
4302 (void *) &cmd_setbonding_mode_set,
4303 (void *) &cmd_setbonding_mode_bonding,
4304 (void *) &cmd_setbonding_mode_mode,
4305 (void *) &cmd_setbonding_mode_value,
4306 (void *) &cmd_setbonding_mode_port,
4311 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4312 struct cmd_set_bonding_lacp_dedicated_queues_result {
4313 cmdline_fixed_string_t set;
4314 cmdline_fixed_string_t bonding;
4315 cmdline_fixed_string_t lacp;
4316 cmdline_fixed_string_t dedicated_queues;
4318 cmdline_fixed_string_t mode;
4321 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4322 __attribute__((unused)) struct cmdline *cl,
4323 __attribute__((unused)) void *data)
4325 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4326 portid_t port_id = res->port_id;
4327 struct rte_port *port;
4329 port = &ports[port_id];
4331 /** Check if the port is not started **/
4332 if (port->port_status != RTE_PORT_STOPPED) {
4333 printf("Please stop port %d first\n", port_id);
4337 if (!strcmp(res->mode, "enable")) {
4338 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4339 printf("Dedicate queues for LACP control packets"
4342 printf("Enabling dedicate queues for LACP control "
4343 "packets on port %d failed\n", port_id);
4344 } else if (!strcmp(res->mode, "disable")) {
4345 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4346 printf("Dedicated queues for LACP control packets "
4349 printf("Disabling dedicated queues for LACP control "
4350 "traffic on port %d failed\n", port_id);
4354 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4355 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4357 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4358 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4359 bonding, "bonding");
4360 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4361 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4363 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4364 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4365 dedicated_queues, "dedicated_queues");
4366 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4367 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4369 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4370 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4371 mode, "enable#disable");
4373 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4374 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4375 .help_str = "set bonding lacp dedicated_queues <port_id> "
4377 "Enable/disable dedicated queues for LACP control traffic for port_id",
4380 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4381 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4382 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4383 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4384 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4385 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4390 /* *** SET BALANCE XMIT POLICY *** */
4391 struct cmd_set_bonding_balance_xmit_policy_result {
4392 cmdline_fixed_string_t set;
4393 cmdline_fixed_string_t bonding;
4394 cmdline_fixed_string_t balance_xmit_policy;
4396 cmdline_fixed_string_t policy;
4399 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4400 __attribute__((unused)) struct cmdline *cl,
4401 __attribute__((unused)) void *data)
4403 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4404 portid_t port_id = res->port_id;
4407 if (!strcmp(res->policy, "l2")) {
4408 policy = BALANCE_XMIT_POLICY_LAYER2;
4409 } else if (!strcmp(res->policy, "l23")) {
4410 policy = BALANCE_XMIT_POLICY_LAYER23;
4411 } else if (!strcmp(res->policy, "l34")) {
4412 policy = BALANCE_XMIT_POLICY_LAYER34;
4414 printf("\t Invalid xmit policy selection");
4418 /* Set the bonding mode for the relevant port. */
4419 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4420 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4425 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4426 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4428 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4429 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4430 bonding, "bonding");
4431 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4432 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4433 balance_xmit_policy, "balance_xmit_policy");
4434 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4435 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4437 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4438 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4439 policy, "l2#l23#l34");
4441 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4442 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4443 .help_str = "set bonding balance_xmit_policy <port_id> "
4445 "Set the bonding balance_xmit_policy for port_id",
4448 (void *)&cmd_setbonding_balance_xmit_policy_set,
4449 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4450 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4451 (void *)&cmd_setbonding_balance_xmit_policy_port,
4452 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4457 /* *** SHOW NIC BONDING CONFIGURATION *** */
4458 struct cmd_show_bonding_config_result {
4459 cmdline_fixed_string_t show;
4460 cmdline_fixed_string_t bonding;
4461 cmdline_fixed_string_t config;
4465 static void cmd_show_bonding_config_parsed(void *parsed_result,
4466 __attribute__((unused)) struct cmdline *cl,
4467 __attribute__((unused)) void *data)
4469 struct cmd_show_bonding_config_result *res = parsed_result;
4471 uint8_t slaves[RTE_MAX_ETHPORTS];
4472 int num_slaves, num_active_slaves;
4475 portid_t port_id = res->port_id;
4477 /* Display the bonding mode.*/
4478 bonding_mode = rte_eth_bond_mode_get(port_id);
4479 if (bonding_mode < 0) {
4480 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4483 printf("\tBonding mode: %d\n", bonding_mode);
4485 if (bonding_mode == BONDING_MODE_BALANCE) {
4486 int balance_xmit_policy;
4488 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4489 if (balance_xmit_policy < 0) {
4490 printf("\tFailed to get balance xmit policy for port = %d\n",
4494 printf("\tBalance Xmit Policy: ");
4496 switch (balance_xmit_policy) {
4497 case BALANCE_XMIT_POLICY_LAYER2:
4498 printf("BALANCE_XMIT_POLICY_LAYER2");
4500 case BALANCE_XMIT_POLICY_LAYER23:
4501 printf("BALANCE_XMIT_POLICY_LAYER23");
4503 case BALANCE_XMIT_POLICY_LAYER34:
4504 printf("BALANCE_XMIT_POLICY_LAYER34");
4511 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4513 if (num_slaves < 0) {
4514 printf("\tFailed to get slave list for port = %d\n", port_id);
4517 if (num_slaves > 0) {
4518 printf("\tSlaves (%d): [", num_slaves);
4519 for (i = 0; i < num_slaves - 1; i++)
4520 printf("%d ", slaves[i]);
4522 printf("%d]\n", slaves[num_slaves - 1]);
4524 printf("\tSlaves: []\n");
4528 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4531 if (num_active_slaves < 0) {
4532 printf("\tFailed to get active slave list for port = %d\n", port_id);
4535 if (num_active_slaves > 0) {
4536 printf("\tActive Slaves (%d): [", num_active_slaves);
4537 for (i = 0; i < num_active_slaves - 1; i++)
4538 printf("%d ", slaves[i]);
4540 printf("%d]\n", slaves[num_active_slaves - 1]);
4543 printf("\tActive Slaves: []\n");
4547 primary_id = rte_eth_bond_primary_get(port_id);
4548 if (primary_id < 0) {
4549 printf("\tFailed to get primary slave for port = %d\n", port_id);
4552 printf("\tPrimary: [%d]\n", primary_id);
4556 cmdline_parse_token_string_t cmd_showbonding_config_show =
4557 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4559 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4560 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4561 bonding, "bonding");
4562 cmdline_parse_token_string_t cmd_showbonding_config_config =
4563 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4565 cmdline_parse_token_num_t cmd_showbonding_config_port =
4566 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4569 cmdline_parse_inst_t cmd_show_bonding_config = {
4570 .f = cmd_show_bonding_config_parsed,
4571 .help_str = "show bonding config <port_id>: "
4572 "Show the bonding config for port_id",
4575 (void *)&cmd_showbonding_config_show,
4576 (void *)&cmd_showbonding_config_bonding,
4577 (void *)&cmd_showbonding_config_config,
4578 (void *)&cmd_showbonding_config_port,
4583 /* *** SET BONDING PRIMARY *** */
4584 struct cmd_set_bonding_primary_result {
4585 cmdline_fixed_string_t set;
4586 cmdline_fixed_string_t bonding;
4587 cmdline_fixed_string_t primary;
4592 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4593 __attribute__((unused)) struct cmdline *cl,
4594 __attribute__((unused)) void *data)
4596 struct cmd_set_bonding_primary_result *res = parsed_result;
4597 portid_t master_port_id = res->port_id;
4598 portid_t slave_port_id = res->slave_id;
4600 /* Set the primary slave for a bonded device. */
4601 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4602 printf("\t Failed to set primary slave for port = %d.\n",
4609 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4610 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4612 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4613 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4614 bonding, "bonding");
4615 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4616 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4617 primary, "primary");
4618 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4619 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4621 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4622 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4625 cmdline_parse_inst_t cmd_set_bonding_primary = {
4626 .f = cmd_set_bonding_primary_parsed,
4627 .help_str = "set bonding primary <slave_id> <port_id>: "
4628 "Set the primary slave for port_id",
4631 (void *)&cmd_setbonding_primary_set,
4632 (void *)&cmd_setbonding_primary_bonding,
4633 (void *)&cmd_setbonding_primary_primary,
4634 (void *)&cmd_setbonding_primary_slave,
4635 (void *)&cmd_setbonding_primary_port,
4640 /* *** ADD SLAVE *** */
4641 struct cmd_add_bonding_slave_result {
4642 cmdline_fixed_string_t add;
4643 cmdline_fixed_string_t bonding;
4644 cmdline_fixed_string_t slave;
4649 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4650 __attribute__((unused)) struct cmdline *cl,
4651 __attribute__((unused)) void *data)
4653 struct cmd_add_bonding_slave_result *res = parsed_result;
4654 portid_t master_port_id = res->port_id;
4655 portid_t slave_port_id = res->slave_id;
4657 /* add the slave for a bonded device. */
4658 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4659 printf("\t Failed to add slave %d to master port = %d.\n",
4660 slave_port_id, master_port_id);
4664 set_port_slave_flag(slave_port_id);
4667 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4668 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4670 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4671 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4672 bonding, "bonding");
4673 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4674 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4676 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4677 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4679 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4680 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4683 cmdline_parse_inst_t cmd_add_bonding_slave = {
4684 .f = cmd_add_bonding_slave_parsed,
4685 .help_str = "add bonding slave <slave_id> <port_id>: "
4686 "Add a slave device to a bonded device",
4689 (void *)&cmd_addbonding_slave_add,
4690 (void *)&cmd_addbonding_slave_bonding,
4691 (void *)&cmd_addbonding_slave_slave,
4692 (void *)&cmd_addbonding_slave_slaveid,
4693 (void *)&cmd_addbonding_slave_port,
4698 /* *** REMOVE SLAVE *** */
4699 struct cmd_remove_bonding_slave_result {
4700 cmdline_fixed_string_t remove;
4701 cmdline_fixed_string_t bonding;
4702 cmdline_fixed_string_t slave;
4707 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4708 __attribute__((unused)) struct cmdline *cl,
4709 __attribute__((unused)) void *data)
4711 struct cmd_remove_bonding_slave_result *res = parsed_result;
4712 portid_t master_port_id = res->port_id;
4713 portid_t slave_port_id = res->slave_id;
4715 /* remove the slave from a bonded device. */
4716 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4717 printf("\t Failed to remove slave %d from master port = %d.\n",
4718 slave_port_id, master_port_id);
4722 clear_port_slave_flag(slave_port_id);
4725 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4726 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4728 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4729 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4730 bonding, "bonding");
4731 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4732 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4734 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4735 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4737 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4738 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4741 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4742 .f = cmd_remove_bonding_slave_parsed,
4743 .help_str = "remove bonding slave <slave_id> <port_id>: "
4744 "Remove a slave device from a bonded device",
4747 (void *)&cmd_removebonding_slave_remove,
4748 (void *)&cmd_removebonding_slave_bonding,
4749 (void *)&cmd_removebonding_slave_slave,
4750 (void *)&cmd_removebonding_slave_slaveid,
4751 (void *)&cmd_removebonding_slave_port,
4756 /* *** CREATE BONDED DEVICE *** */
4757 struct cmd_create_bonded_device_result {
4758 cmdline_fixed_string_t create;
4759 cmdline_fixed_string_t bonded;
4760 cmdline_fixed_string_t device;
4765 static int bond_dev_num = 0;
4767 static void cmd_create_bonded_device_parsed(void *parsed_result,
4768 __attribute__((unused)) struct cmdline *cl,
4769 __attribute__((unused)) void *data)
4771 struct cmd_create_bonded_device_result *res = parsed_result;
4772 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4775 if (test_done == 0) {
4776 printf("Please stop forwarding first\n");
4780 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4783 /* Create a new bonded device. */
4784 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4786 printf("\t Failed to create bonded device.\n");
4789 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4792 /* Update number of ports */
4793 nb_ports = rte_eth_dev_count();
4794 reconfig(port_id, res->socket);
4795 rte_eth_promiscuous_enable(port_id);
4800 cmdline_parse_token_string_t cmd_createbonded_device_create =
4801 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4803 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4804 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4806 cmdline_parse_token_string_t cmd_createbonded_device_device =
4807 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4809 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4810 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4812 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4813 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4816 cmdline_parse_inst_t cmd_create_bonded_device = {
4817 .f = cmd_create_bonded_device_parsed,
4818 .help_str = "create bonded device <mode> <socket>: "
4819 "Create a new bonded device with specific bonding mode and socket",
4822 (void *)&cmd_createbonded_device_create,
4823 (void *)&cmd_createbonded_device_bonded,
4824 (void *)&cmd_createbonded_device_device,
4825 (void *)&cmd_createbonded_device_mode,
4826 (void *)&cmd_createbonded_device_socket,
4831 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4832 struct cmd_set_bond_mac_addr_result {
4833 cmdline_fixed_string_t set;
4834 cmdline_fixed_string_t bonding;
4835 cmdline_fixed_string_t mac_addr;
4837 struct ether_addr address;
4840 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4841 __attribute__((unused)) struct cmdline *cl,
4842 __attribute__((unused)) void *data)
4844 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4847 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4850 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4852 /* check the return value and print it if is < 0 */
4854 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4857 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4858 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4859 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4862 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4865 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4866 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4867 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4868 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4870 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4871 .f = cmd_set_bond_mac_addr_parsed,
4873 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4875 (void *)&cmd_set_bond_mac_addr_set,
4876 (void *)&cmd_set_bond_mac_addr_bonding,
4877 (void *)&cmd_set_bond_mac_addr_mac,
4878 (void *)&cmd_set_bond_mac_addr_portnum,
4879 (void *)&cmd_set_bond_mac_addr_addr,
4885 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4886 struct cmd_set_bond_mon_period_result {
4887 cmdline_fixed_string_t set;
4888 cmdline_fixed_string_t bonding;
4889 cmdline_fixed_string_t mon_period;
4894 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4895 __attribute__((unused)) struct cmdline *cl,
4896 __attribute__((unused)) void *data)
4898 struct cmd_set_bond_mon_period_result *res = parsed_result;
4901 if (res->port_num >= nb_ports) {
4902 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4906 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4908 /* check the return value and print it if is < 0 */
4910 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4913 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4914 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4916 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4917 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4918 bonding, "bonding");
4919 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4920 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4921 mon_period, "mon_period");
4922 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4923 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4925 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4926 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4929 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4930 .f = cmd_set_bond_mon_period_parsed,
4932 .help_str = "set bonding mon_period <port_id> <period_ms>",
4934 (void *)&cmd_set_bond_mon_period_set,
4935 (void *)&cmd_set_bond_mon_period_bonding,
4936 (void *)&cmd_set_bond_mon_period_mon_period,
4937 (void *)&cmd_set_bond_mon_period_portnum,
4938 (void *)&cmd_set_bond_mon_period_period_ms,
4943 #endif /* RTE_LIBRTE_PMD_BOND */
4945 /* *** SET FORWARDING MODE *** */
4946 struct cmd_set_fwd_mode_result {
4947 cmdline_fixed_string_t set;
4948 cmdline_fixed_string_t fwd;
4949 cmdline_fixed_string_t mode;
4952 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4953 __attribute__((unused)) struct cmdline *cl,
4954 __attribute__((unused)) void *data)
4956 struct cmd_set_fwd_mode_result *res = parsed_result;
4959 set_pkt_forwarding_mode(res->mode);
4962 cmdline_parse_token_string_t cmd_setfwd_set =
4963 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4964 cmdline_parse_token_string_t cmd_setfwd_fwd =
4965 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4966 cmdline_parse_token_string_t cmd_setfwd_mode =
4967 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4968 "" /* defined at init */);
4970 cmdline_parse_inst_t cmd_set_fwd_mode = {
4971 .f = cmd_set_fwd_mode_parsed,
4973 .help_str = NULL, /* defined at init */
4975 (void *)&cmd_setfwd_set,
4976 (void *)&cmd_setfwd_fwd,
4977 (void *)&cmd_setfwd_mode,
4982 static void cmd_set_fwd_mode_init(void)
4985 static char token[128];
4986 static char help[256];
4987 cmdline_parse_token_string_t *token_struct;
4989 modes = list_pkt_forwarding_modes();
4990 snprintf(help, sizeof(help), "set fwd %s: "
4991 "Set packet forwarding mode", modes);
4992 cmd_set_fwd_mode.help_str = help;
4994 /* string token separator is # */
4995 for (c = token; *modes != '\0'; modes++)
5000 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5001 token_struct->string_data.str = token;
5004 /* *** SET RETRY FORWARDING MODE *** */
5005 struct cmd_set_fwd_retry_mode_result {
5006 cmdline_fixed_string_t set;
5007 cmdline_fixed_string_t fwd;
5008 cmdline_fixed_string_t mode;
5009 cmdline_fixed_string_t retry;
5012 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5013 __attribute__((unused)) struct cmdline *cl,
5014 __attribute__((unused)) void *data)
5016 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5019 set_pkt_forwarding_mode(res->mode);
5022 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5023 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5025 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5026 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5028 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5029 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5031 "" /* defined at init */);
5032 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5033 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5036 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5037 .f = cmd_set_fwd_retry_mode_parsed,
5039 .help_str = NULL, /* defined at init */
5041 (void *)&cmd_setfwd_retry_set,
5042 (void *)&cmd_setfwd_retry_fwd,
5043 (void *)&cmd_setfwd_retry_mode,
5044 (void *)&cmd_setfwd_retry_retry,
5049 static void cmd_set_fwd_retry_mode_init(void)
5052 static char token[128];
5053 static char help[256];
5054 cmdline_parse_token_string_t *token_struct;
5056 modes = list_pkt_forwarding_retry_modes();
5057 snprintf(help, sizeof(help), "set fwd %s retry: "
5058 "Set packet forwarding mode with retry", modes);
5059 cmd_set_fwd_retry_mode.help_str = help;
5061 /* string token separator is # */
5062 for (c = token; *modes != '\0'; modes++)
5067 token_struct = (cmdline_parse_token_string_t *)
5068 cmd_set_fwd_retry_mode.tokens[2];
5069 token_struct->string_data.str = token;
5072 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5073 struct cmd_set_burst_tx_retry_result {
5074 cmdline_fixed_string_t set;
5075 cmdline_fixed_string_t burst;
5076 cmdline_fixed_string_t tx;
5077 cmdline_fixed_string_t delay;
5079 cmdline_fixed_string_t retry;
5083 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5084 __attribute__((unused)) struct cmdline *cl,
5085 __attribute__((unused)) void *data)
5087 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5089 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5090 && !strcmp(res->tx, "tx")) {
5091 if (!strcmp(res->delay, "delay"))
5092 burst_tx_delay_time = res->time;
5093 if (!strcmp(res->retry, "retry"))
5094 burst_tx_retry_num = res->retry_num;
5099 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5100 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5101 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5102 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5104 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5105 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5106 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5107 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5108 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5109 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5110 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5111 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5112 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5113 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5115 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5116 .f = cmd_set_burst_tx_retry_parsed,
5117 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5119 (void *)&cmd_set_burst_tx_retry_set,
5120 (void *)&cmd_set_burst_tx_retry_burst,
5121 (void *)&cmd_set_burst_tx_retry_tx,
5122 (void *)&cmd_set_burst_tx_retry_delay,
5123 (void *)&cmd_set_burst_tx_retry_time,
5124 (void *)&cmd_set_burst_tx_retry_retry,
5125 (void *)&cmd_set_burst_tx_retry_retry_num,
5130 /* *** SET PROMISC MODE *** */
5131 struct cmd_set_promisc_mode_result {
5132 cmdline_fixed_string_t set;
5133 cmdline_fixed_string_t promisc;
5134 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5135 uint8_t port_num; /* valid if "allports" argument == 0 */
5136 cmdline_fixed_string_t mode;
5139 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5140 __attribute__((unused)) struct cmdline *cl,
5143 struct cmd_set_promisc_mode_result *res = parsed_result;
5147 if (!strcmp(res->mode, "on"))
5154 RTE_ETH_FOREACH_DEV(i) {
5156 rte_eth_promiscuous_enable(i);
5158 rte_eth_promiscuous_disable(i);
5163 rte_eth_promiscuous_enable(res->port_num);
5165 rte_eth_promiscuous_disable(res->port_num);
5169 cmdline_parse_token_string_t cmd_setpromisc_set =
5170 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5171 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5172 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5174 cmdline_parse_token_string_t cmd_setpromisc_portall =
5175 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5177 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5178 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5180 cmdline_parse_token_string_t cmd_setpromisc_mode =
5181 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5184 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5185 .f = cmd_set_promisc_mode_parsed,
5187 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5189 (void *)&cmd_setpromisc_set,
5190 (void *)&cmd_setpromisc_promisc,
5191 (void *)&cmd_setpromisc_portall,
5192 (void *)&cmd_setpromisc_mode,
5197 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5198 .f = cmd_set_promisc_mode_parsed,
5200 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5202 (void *)&cmd_setpromisc_set,
5203 (void *)&cmd_setpromisc_promisc,
5204 (void *)&cmd_setpromisc_portnum,
5205 (void *)&cmd_setpromisc_mode,
5210 /* *** SET ALLMULTI MODE *** */
5211 struct cmd_set_allmulti_mode_result {
5212 cmdline_fixed_string_t set;
5213 cmdline_fixed_string_t allmulti;
5214 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5215 uint8_t port_num; /* valid if "allports" argument == 0 */
5216 cmdline_fixed_string_t mode;
5219 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5220 __attribute__((unused)) struct cmdline *cl,
5223 struct cmd_set_allmulti_mode_result *res = parsed_result;
5227 if (!strcmp(res->mode, "on"))
5234 RTE_ETH_FOREACH_DEV(i) {
5236 rte_eth_allmulticast_enable(i);
5238 rte_eth_allmulticast_disable(i);
5243 rte_eth_allmulticast_enable(res->port_num);
5245 rte_eth_allmulticast_disable(res->port_num);
5249 cmdline_parse_token_string_t cmd_setallmulti_set =
5250 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5251 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5252 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5254 cmdline_parse_token_string_t cmd_setallmulti_portall =
5255 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5257 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5258 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5260 cmdline_parse_token_string_t cmd_setallmulti_mode =
5261 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5264 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5265 .f = cmd_set_allmulti_mode_parsed,
5267 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5269 (void *)&cmd_setallmulti_set,
5270 (void *)&cmd_setallmulti_allmulti,
5271 (void *)&cmd_setallmulti_portall,
5272 (void *)&cmd_setallmulti_mode,
5277 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5278 .f = cmd_set_allmulti_mode_parsed,
5280 .help_str = "set allmulti <port_id> on|off: "
5281 "Set allmulti mode on port_id",
5283 (void *)&cmd_setallmulti_set,
5284 (void *)&cmd_setallmulti_allmulti,
5285 (void *)&cmd_setallmulti_portnum,
5286 (void *)&cmd_setallmulti_mode,
5291 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5292 struct cmd_link_flow_ctrl_set_result {
5293 cmdline_fixed_string_t set;
5294 cmdline_fixed_string_t flow_ctrl;
5295 cmdline_fixed_string_t rx;
5296 cmdline_fixed_string_t rx_lfc_mode;
5297 cmdline_fixed_string_t tx;
5298 cmdline_fixed_string_t tx_lfc_mode;
5299 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5300 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5301 cmdline_fixed_string_t autoneg_str;
5302 cmdline_fixed_string_t autoneg;
5303 cmdline_fixed_string_t hw_str;
5304 uint32_t high_water;
5305 cmdline_fixed_string_t lw_str;
5307 cmdline_fixed_string_t pt_str;
5308 uint16_t pause_time;
5309 cmdline_fixed_string_t xon_str;
5314 cmdline_parse_token_string_t cmd_lfc_set_set =
5315 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5317 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5318 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5319 flow_ctrl, "flow_ctrl");
5320 cmdline_parse_token_string_t cmd_lfc_set_rx =
5321 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5323 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5324 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5325 rx_lfc_mode, "on#off");
5326 cmdline_parse_token_string_t cmd_lfc_set_tx =
5327 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5329 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5330 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5331 tx_lfc_mode, "on#off");
5332 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5333 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5334 hw_str, "high_water");
5335 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5336 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5337 high_water, UINT32);
5338 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5339 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5340 lw_str, "low_water");
5341 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5342 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5344 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5345 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5346 pt_str, "pause_time");
5347 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5348 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5349 pause_time, UINT16);
5350 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5351 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5352 xon_str, "send_xon");
5353 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5354 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5356 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5357 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5358 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5359 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5360 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5361 mac_ctrl_frame_fwd_mode, "on#off");
5362 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5363 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5364 autoneg_str, "autoneg");
5365 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5366 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5368 cmdline_parse_token_num_t cmd_lfc_set_portid =
5369 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5372 /* forward declaration */
5374 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5377 cmdline_parse_inst_t cmd_link_flow_control_set = {
5378 .f = cmd_link_flow_ctrl_set_parsed,
5380 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5381 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5382 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5384 (void *)&cmd_lfc_set_set,
5385 (void *)&cmd_lfc_set_flow_ctrl,
5386 (void *)&cmd_lfc_set_rx,
5387 (void *)&cmd_lfc_set_rx_mode,
5388 (void *)&cmd_lfc_set_tx,
5389 (void *)&cmd_lfc_set_tx_mode,
5390 (void *)&cmd_lfc_set_high_water,
5391 (void *)&cmd_lfc_set_low_water,
5392 (void *)&cmd_lfc_set_pause_time,
5393 (void *)&cmd_lfc_set_send_xon,
5394 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5395 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5396 (void *)&cmd_lfc_set_autoneg_str,
5397 (void *)&cmd_lfc_set_autoneg,
5398 (void *)&cmd_lfc_set_portid,
5403 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5404 .f = cmd_link_flow_ctrl_set_parsed,
5405 .data = (void *)&cmd_link_flow_control_set_rx,
5406 .help_str = "set flow_ctrl rx on|off <port_id>: "
5407 "Change rx flow control parameter",
5409 (void *)&cmd_lfc_set_set,
5410 (void *)&cmd_lfc_set_flow_ctrl,
5411 (void *)&cmd_lfc_set_rx,
5412 (void *)&cmd_lfc_set_rx_mode,
5413 (void *)&cmd_lfc_set_portid,
5418 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5419 .f = cmd_link_flow_ctrl_set_parsed,
5420 .data = (void *)&cmd_link_flow_control_set_tx,
5421 .help_str = "set flow_ctrl tx on|off <port_id>: "
5422 "Change tx flow control parameter",
5424 (void *)&cmd_lfc_set_set,
5425 (void *)&cmd_lfc_set_flow_ctrl,
5426 (void *)&cmd_lfc_set_tx,
5427 (void *)&cmd_lfc_set_tx_mode,
5428 (void *)&cmd_lfc_set_portid,
5433 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5434 .f = cmd_link_flow_ctrl_set_parsed,
5435 .data = (void *)&cmd_link_flow_control_set_hw,
5436 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5437 "Change high water flow control parameter",
5439 (void *)&cmd_lfc_set_set,
5440 (void *)&cmd_lfc_set_flow_ctrl,
5441 (void *)&cmd_lfc_set_high_water_str,
5442 (void *)&cmd_lfc_set_high_water,
5443 (void *)&cmd_lfc_set_portid,
5448 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5449 .f = cmd_link_flow_ctrl_set_parsed,
5450 .data = (void *)&cmd_link_flow_control_set_lw,
5451 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5452 "Change low water flow control parameter",
5454 (void *)&cmd_lfc_set_set,
5455 (void *)&cmd_lfc_set_flow_ctrl,
5456 (void *)&cmd_lfc_set_low_water_str,
5457 (void *)&cmd_lfc_set_low_water,
5458 (void *)&cmd_lfc_set_portid,
5463 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5464 .f = cmd_link_flow_ctrl_set_parsed,
5465 .data = (void *)&cmd_link_flow_control_set_pt,
5466 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5467 "Change pause time flow control parameter",
5469 (void *)&cmd_lfc_set_set,
5470 (void *)&cmd_lfc_set_flow_ctrl,
5471 (void *)&cmd_lfc_set_pause_time_str,
5472 (void *)&cmd_lfc_set_pause_time,
5473 (void *)&cmd_lfc_set_portid,
5478 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5479 .f = cmd_link_flow_ctrl_set_parsed,
5480 .data = (void *)&cmd_link_flow_control_set_xon,
5481 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5482 "Change send_xon flow control parameter",
5484 (void *)&cmd_lfc_set_set,
5485 (void *)&cmd_lfc_set_flow_ctrl,
5486 (void *)&cmd_lfc_set_send_xon_str,
5487 (void *)&cmd_lfc_set_send_xon,
5488 (void *)&cmd_lfc_set_portid,
5493 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5494 .f = cmd_link_flow_ctrl_set_parsed,
5495 .data = (void *)&cmd_link_flow_control_set_macfwd,
5496 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5497 "Change mac ctrl fwd flow control parameter",
5499 (void *)&cmd_lfc_set_set,
5500 (void *)&cmd_lfc_set_flow_ctrl,
5501 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5502 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5503 (void *)&cmd_lfc_set_portid,
5508 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5509 .f = cmd_link_flow_ctrl_set_parsed,
5510 .data = (void *)&cmd_link_flow_control_set_autoneg,
5511 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5512 "Change autoneg flow control parameter",
5514 (void *)&cmd_lfc_set_set,
5515 (void *)&cmd_lfc_set_flow_ctrl,
5516 (void *)&cmd_lfc_set_autoneg_str,
5517 (void *)&cmd_lfc_set_autoneg,
5518 (void *)&cmd_lfc_set_portid,
5524 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5525 __attribute__((unused)) struct cmdline *cl,
5528 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5529 cmdline_parse_inst_t *cmd = data;
5530 struct rte_eth_fc_conf fc_conf;
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_lfc_mode[2][2] = {
5542 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5545 /* Partial command line, retrieve current configuration */
5547 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5549 printf("cannot get current flow ctrl parameters, return"
5550 "code = %d\n", ret);
5554 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5555 (fc_conf.mode == RTE_FC_FULL))
5557 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5558 (fc_conf.mode == RTE_FC_FULL))
5562 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5563 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5565 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5566 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5568 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5570 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5571 fc_conf.high_water = res->high_water;
5573 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5574 fc_conf.low_water = res->low_water;
5576 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5577 fc_conf.pause_time = res->pause_time;
5579 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5580 fc_conf.send_xon = res->send_xon;
5582 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5583 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5584 fc_conf.mac_ctrl_frame_fwd = 1;
5586 fc_conf.mac_ctrl_frame_fwd = 0;
5589 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5590 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5592 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5594 printf("bad flow contrl parameter, return code = %d \n", ret);
5597 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5598 struct cmd_priority_flow_ctrl_set_result {
5599 cmdline_fixed_string_t set;
5600 cmdline_fixed_string_t pfc_ctrl;
5601 cmdline_fixed_string_t rx;
5602 cmdline_fixed_string_t rx_pfc_mode;
5603 cmdline_fixed_string_t tx;
5604 cmdline_fixed_string_t tx_pfc_mode;
5605 uint32_t high_water;
5607 uint16_t pause_time;
5613 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5614 __attribute__((unused)) struct cmdline *cl,
5615 __attribute__((unused)) void *data)
5617 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5618 struct rte_eth_pfc_conf pfc_conf;
5619 int rx_fc_enable, tx_fc_enable;
5623 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5624 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5625 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5626 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5628 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5629 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5632 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5633 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5634 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5635 pfc_conf.fc.high_water = res->high_water;
5636 pfc_conf.fc.low_water = res->low_water;
5637 pfc_conf.fc.pause_time = res->pause_time;
5638 pfc_conf.priority = res->priority;
5640 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5642 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5645 cmdline_parse_token_string_t cmd_pfc_set_set =
5646 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5648 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5649 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5650 pfc_ctrl, "pfc_ctrl");
5651 cmdline_parse_token_string_t cmd_pfc_set_rx =
5652 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5654 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5655 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5656 rx_pfc_mode, "on#off");
5657 cmdline_parse_token_string_t cmd_pfc_set_tx =
5658 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5660 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5661 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5662 tx_pfc_mode, "on#off");
5663 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5664 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5665 high_water, UINT32);
5666 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5667 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5669 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5670 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5671 pause_time, UINT16);
5672 cmdline_parse_token_num_t cmd_pfc_set_priority =
5673 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5675 cmdline_parse_token_num_t cmd_pfc_set_portid =
5676 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5679 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5680 .f = cmd_priority_flow_ctrl_set_parsed,
5682 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5683 "<pause_time> <priority> <port_id>: "
5684 "Configure the Ethernet priority flow control",
5686 (void *)&cmd_pfc_set_set,
5687 (void *)&cmd_pfc_set_flow_ctrl,
5688 (void *)&cmd_pfc_set_rx,
5689 (void *)&cmd_pfc_set_rx_mode,
5690 (void *)&cmd_pfc_set_tx,
5691 (void *)&cmd_pfc_set_tx_mode,
5692 (void *)&cmd_pfc_set_high_water,
5693 (void *)&cmd_pfc_set_low_water,
5694 (void *)&cmd_pfc_set_pause_time,
5695 (void *)&cmd_pfc_set_priority,
5696 (void *)&cmd_pfc_set_portid,
5701 /* *** RESET CONFIGURATION *** */
5702 struct cmd_reset_result {
5703 cmdline_fixed_string_t reset;
5704 cmdline_fixed_string_t def;
5707 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5709 __attribute__((unused)) void *data)
5711 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5712 set_def_fwd_config();
5715 cmdline_parse_token_string_t cmd_reset_set =
5716 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5717 cmdline_parse_token_string_t cmd_reset_def =
5718 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5721 cmdline_parse_inst_t cmd_reset = {
5722 .f = cmd_reset_parsed,
5724 .help_str = "set default: Reset default forwarding configuration",
5726 (void *)&cmd_reset_set,
5727 (void *)&cmd_reset_def,
5732 /* *** START FORWARDING *** */
5733 struct cmd_start_result {
5734 cmdline_fixed_string_t start;
5737 cmdline_parse_token_string_t cmd_start_start =
5738 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5740 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5741 __attribute__((unused)) struct cmdline *cl,
5742 __attribute__((unused)) void *data)
5744 start_packet_forwarding(0);
5747 cmdline_parse_inst_t cmd_start = {
5748 .f = cmd_start_parsed,
5750 .help_str = "start: Start packet forwarding",
5752 (void *)&cmd_start_start,
5757 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5758 struct cmd_start_tx_first_result {
5759 cmdline_fixed_string_t start;
5760 cmdline_fixed_string_t tx_first;
5764 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5765 __attribute__((unused)) struct cmdline *cl,
5766 __attribute__((unused)) void *data)
5768 start_packet_forwarding(1);
5771 cmdline_parse_token_string_t cmd_start_tx_first_start =
5772 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5774 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5775 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5776 tx_first, "tx_first");
5778 cmdline_parse_inst_t cmd_start_tx_first = {
5779 .f = cmd_start_tx_first_parsed,
5781 .help_str = "start tx_first: Start packet forwarding, "
5782 "after sending 1 burst of packets",
5784 (void *)&cmd_start_tx_first_start,
5785 (void *)&cmd_start_tx_first_tx_first,
5790 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5791 struct cmd_start_tx_first_n_result {
5792 cmdline_fixed_string_t start;
5793 cmdline_fixed_string_t tx_first;
5798 cmd_start_tx_first_n_parsed(void *parsed_result,
5799 __attribute__((unused)) struct cmdline *cl,
5800 __attribute__((unused)) void *data)
5802 struct cmd_start_tx_first_n_result *res = parsed_result;
5804 start_packet_forwarding(res->tx_num);
5807 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5808 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5810 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5811 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5812 tx_first, "tx_first");
5813 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5814 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5817 cmdline_parse_inst_t cmd_start_tx_first_n = {
5818 .f = cmd_start_tx_first_n_parsed,
5820 .help_str = "start tx_first <num>: "
5821 "packet forwarding, after sending <num> bursts of packets",
5823 (void *)&cmd_start_tx_first_n_start,
5824 (void *)&cmd_start_tx_first_n_tx_first,
5825 (void *)&cmd_start_tx_first_n_tx_num,
5830 /* *** SET LINK UP *** */
5831 struct cmd_set_link_up_result {
5832 cmdline_fixed_string_t set;
5833 cmdline_fixed_string_t link_up;
5834 cmdline_fixed_string_t port;
5838 cmdline_parse_token_string_t cmd_set_link_up_set =
5839 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5840 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5843 cmdline_parse_token_string_t cmd_set_link_up_port =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5845 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5846 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5848 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5849 __attribute__((unused)) struct cmdline *cl,
5850 __attribute__((unused)) void *data)
5852 struct cmd_set_link_up_result *res = parsed_result;
5853 dev_set_link_up(res->port_id);
5856 cmdline_parse_inst_t cmd_set_link_up = {
5857 .f = cmd_set_link_up_parsed,
5859 .help_str = "set link-up port <port id>",
5861 (void *)&cmd_set_link_up_set,
5862 (void *)&cmd_set_link_up_link_up,
5863 (void *)&cmd_set_link_up_port,
5864 (void *)&cmd_set_link_up_port_id,
5869 /* *** SET LINK DOWN *** */
5870 struct cmd_set_link_down_result {
5871 cmdline_fixed_string_t set;
5872 cmdline_fixed_string_t link_down;
5873 cmdline_fixed_string_t port;
5877 cmdline_parse_token_string_t cmd_set_link_down_set =
5878 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5879 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5880 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5882 cmdline_parse_token_string_t cmd_set_link_down_port =
5883 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5884 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5885 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5887 static void cmd_set_link_down_parsed(
5888 __attribute__((unused)) void *parsed_result,
5889 __attribute__((unused)) struct cmdline *cl,
5890 __attribute__((unused)) void *data)
5892 struct cmd_set_link_down_result *res = parsed_result;
5893 dev_set_link_down(res->port_id);
5896 cmdline_parse_inst_t cmd_set_link_down = {
5897 .f = cmd_set_link_down_parsed,
5899 .help_str = "set link-down port <port id>",
5901 (void *)&cmd_set_link_down_set,
5902 (void *)&cmd_set_link_down_link_down,
5903 (void *)&cmd_set_link_down_port,
5904 (void *)&cmd_set_link_down_port_id,
5909 /* *** SHOW CFG *** */
5910 struct cmd_showcfg_result {
5911 cmdline_fixed_string_t show;
5912 cmdline_fixed_string_t cfg;
5913 cmdline_fixed_string_t what;
5916 static void cmd_showcfg_parsed(void *parsed_result,
5917 __attribute__((unused)) struct cmdline *cl,
5918 __attribute__((unused)) void *data)
5920 struct cmd_showcfg_result *res = parsed_result;
5921 if (!strcmp(res->what, "rxtx"))
5922 rxtx_config_display();
5923 else if (!strcmp(res->what, "cores"))
5924 fwd_lcores_config_display();
5925 else if (!strcmp(res->what, "fwd"))
5926 pkt_fwd_config_display(&cur_fwd_config);
5927 else if (!strcmp(res->what, "txpkts"))
5928 show_tx_pkt_segments();
5931 cmdline_parse_token_string_t cmd_showcfg_show =
5932 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5933 cmdline_parse_token_string_t cmd_showcfg_port =
5934 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5935 cmdline_parse_token_string_t cmd_showcfg_what =
5936 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5937 "rxtx#cores#fwd#txpkts");
5939 cmdline_parse_inst_t cmd_showcfg = {
5940 .f = cmd_showcfg_parsed,
5942 .help_str = "show config rxtx|cores|fwd|txpkts",
5944 (void *)&cmd_showcfg_show,
5945 (void *)&cmd_showcfg_port,
5946 (void *)&cmd_showcfg_what,
5951 /* *** SHOW ALL PORT INFO *** */
5952 struct cmd_showportall_result {
5953 cmdline_fixed_string_t show;
5954 cmdline_fixed_string_t port;
5955 cmdline_fixed_string_t what;
5956 cmdline_fixed_string_t all;
5959 static void cmd_showportall_parsed(void *parsed_result,
5960 __attribute__((unused)) struct cmdline *cl,
5961 __attribute__((unused)) void *data)
5965 struct cmd_showportall_result *res = parsed_result;
5966 if (!strcmp(res->show, "clear")) {
5967 if (!strcmp(res->what, "stats"))
5968 RTE_ETH_FOREACH_DEV(i)
5970 else if (!strcmp(res->what, "xstats"))
5971 RTE_ETH_FOREACH_DEV(i)
5972 nic_xstats_clear(i);
5973 } else if (!strcmp(res->what, "info"))
5974 RTE_ETH_FOREACH_DEV(i)
5975 port_infos_display(i);
5976 else if (!strcmp(res->what, "stats"))
5977 RTE_ETH_FOREACH_DEV(i)
5978 nic_stats_display(i);
5979 else if (!strcmp(res->what, "xstats"))
5980 RTE_ETH_FOREACH_DEV(i)
5981 nic_xstats_display(i);
5982 else if (!strcmp(res->what, "fdir"))
5983 RTE_ETH_FOREACH_DEV(i)
5985 else if (!strcmp(res->what, "stat_qmap"))
5986 RTE_ETH_FOREACH_DEV(i)
5987 nic_stats_mapping_display(i);
5988 else if (!strcmp(res->what, "dcb_tc"))
5989 RTE_ETH_FOREACH_DEV(i)
5990 port_dcb_info_display(i);
5991 else if (!strcmp(res->what, "cap"))
5992 RTE_ETH_FOREACH_DEV(i)
5993 port_offload_cap_display(i);
5996 cmdline_parse_token_string_t cmd_showportall_show =
5997 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5999 cmdline_parse_token_string_t cmd_showportall_port =
6000 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6001 cmdline_parse_token_string_t cmd_showportall_what =
6002 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6003 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6004 cmdline_parse_token_string_t cmd_showportall_all =
6005 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6006 cmdline_parse_inst_t cmd_showportall = {
6007 .f = cmd_showportall_parsed,
6009 .help_str = "show|clear port "
6010 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6012 (void *)&cmd_showportall_show,
6013 (void *)&cmd_showportall_port,
6014 (void *)&cmd_showportall_what,
6015 (void *)&cmd_showportall_all,
6020 /* *** SHOW PORT INFO *** */
6021 struct cmd_showport_result {
6022 cmdline_fixed_string_t show;
6023 cmdline_fixed_string_t port;
6024 cmdline_fixed_string_t what;
6028 static void cmd_showport_parsed(void *parsed_result,
6029 __attribute__((unused)) struct cmdline *cl,
6030 __attribute__((unused)) void *data)
6032 struct cmd_showport_result *res = parsed_result;
6033 if (!strcmp(res->show, "clear")) {
6034 if (!strcmp(res->what, "stats"))
6035 nic_stats_clear(res->portnum);
6036 else if (!strcmp(res->what, "xstats"))
6037 nic_xstats_clear(res->portnum);
6038 } else if (!strcmp(res->what, "info"))
6039 port_infos_display(res->portnum);
6040 else if (!strcmp(res->what, "stats"))
6041 nic_stats_display(res->portnum);
6042 else if (!strcmp(res->what, "xstats"))
6043 nic_xstats_display(res->portnum);
6044 else if (!strcmp(res->what, "fdir"))
6045 fdir_get_infos(res->portnum);
6046 else if (!strcmp(res->what, "stat_qmap"))
6047 nic_stats_mapping_display(res->portnum);
6048 else if (!strcmp(res->what, "dcb_tc"))
6049 port_dcb_info_display(res->portnum);
6050 else if (!strcmp(res->what, "cap"))
6051 port_offload_cap_display(res->portnum);
6054 cmdline_parse_token_string_t cmd_showport_show =
6055 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6057 cmdline_parse_token_string_t cmd_showport_port =
6058 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6059 cmdline_parse_token_string_t cmd_showport_what =
6060 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6061 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6062 cmdline_parse_token_num_t cmd_showport_portnum =
6063 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
6065 cmdline_parse_inst_t cmd_showport = {
6066 .f = cmd_showport_parsed,
6068 .help_str = "show|clear port "
6069 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6072 (void *)&cmd_showport_show,
6073 (void *)&cmd_showport_port,
6074 (void *)&cmd_showport_what,
6075 (void *)&cmd_showport_portnum,
6080 /* *** SHOW QUEUE INFO *** */
6081 struct cmd_showqueue_result {
6082 cmdline_fixed_string_t show;
6083 cmdline_fixed_string_t type;
6084 cmdline_fixed_string_t what;
6090 cmd_showqueue_parsed(void *parsed_result,
6091 __attribute__((unused)) struct cmdline *cl,
6092 __attribute__((unused)) void *data)
6094 struct cmd_showqueue_result *res = parsed_result;
6096 if (!strcmp(res->type, "rxq"))
6097 rx_queue_infos_display(res->portnum, res->queuenum);
6098 else if (!strcmp(res->type, "txq"))
6099 tx_queue_infos_display(res->portnum, res->queuenum);
6102 cmdline_parse_token_string_t cmd_showqueue_show =
6103 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6104 cmdline_parse_token_string_t cmd_showqueue_type =
6105 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6106 cmdline_parse_token_string_t cmd_showqueue_what =
6107 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6108 cmdline_parse_token_num_t cmd_showqueue_portnum =
6109 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6110 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6111 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6113 cmdline_parse_inst_t cmd_showqueue = {
6114 .f = cmd_showqueue_parsed,
6116 .help_str = "show rxq|txq info <port_id> <queue_id>",
6118 (void *)&cmd_showqueue_show,
6119 (void *)&cmd_showqueue_type,
6120 (void *)&cmd_showqueue_what,
6121 (void *)&cmd_showqueue_portnum,
6122 (void *)&cmd_showqueue_queuenum,
6127 /* *** READ PORT REGISTER *** */
6128 struct cmd_read_reg_result {
6129 cmdline_fixed_string_t read;
6130 cmdline_fixed_string_t reg;
6136 cmd_read_reg_parsed(void *parsed_result,
6137 __attribute__((unused)) struct cmdline *cl,
6138 __attribute__((unused)) void *data)
6140 struct cmd_read_reg_result *res = parsed_result;
6141 port_reg_display(res->port_id, res->reg_off);
6144 cmdline_parse_token_string_t cmd_read_reg_read =
6145 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6146 cmdline_parse_token_string_t cmd_read_reg_reg =
6147 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6148 cmdline_parse_token_num_t cmd_read_reg_port_id =
6149 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6150 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6151 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6153 cmdline_parse_inst_t cmd_read_reg = {
6154 .f = cmd_read_reg_parsed,
6156 .help_str = "read reg <port_id> <reg_off>",
6158 (void *)&cmd_read_reg_read,
6159 (void *)&cmd_read_reg_reg,
6160 (void *)&cmd_read_reg_port_id,
6161 (void *)&cmd_read_reg_reg_off,
6166 /* *** READ PORT REGISTER BIT FIELD *** */
6167 struct cmd_read_reg_bit_field_result {
6168 cmdline_fixed_string_t read;
6169 cmdline_fixed_string_t regfield;
6177 cmd_read_reg_bit_field_parsed(void *parsed_result,
6178 __attribute__((unused)) struct cmdline *cl,
6179 __attribute__((unused)) void *data)
6181 struct cmd_read_reg_bit_field_result *res = parsed_result;
6182 port_reg_bit_field_display(res->port_id, res->reg_off,
6183 res->bit1_pos, res->bit2_pos);
6186 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6187 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6189 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6190 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6191 regfield, "regfield");
6192 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6193 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6195 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6196 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6198 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6199 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6201 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6202 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6205 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6206 .f = cmd_read_reg_bit_field_parsed,
6208 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6209 "Read register bit field between bit_x and bit_y included",
6211 (void *)&cmd_read_reg_bit_field_read,
6212 (void *)&cmd_read_reg_bit_field_regfield,
6213 (void *)&cmd_read_reg_bit_field_port_id,
6214 (void *)&cmd_read_reg_bit_field_reg_off,
6215 (void *)&cmd_read_reg_bit_field_bit1_pos,
6216 (void *)&cmd_read_reg_bit_field_bit2_pos,
6221 /* *** READ PORT REGISTER BIT *** */
6222 struct cmd_read_reg_bit_result {
6223 cmdline_fixed_string_t read;
6224 cmdline_fixed_string_t regbit;
6231 cmd_read_reg_bit_parsed(void *parsed_result,
6232 __attribute__((unused)) struct cmdline *cl,
6233 __attribute__((unused)) void *data)
6235 struct cmd_read_reg_bit_result *res = parsed_result;
6236 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6239 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6240 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6241 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6242 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6244 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6245 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6246 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6247 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6248 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6249 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6251 cmdline_parse_inst_t cmd_read_reg_bit = {
6252 .f = cmd_read_reg_bit_parsed,
6254 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6256 (void *)&cmd_read_reg_bit_read,
6257 (void *)&cmd_read_reg_bit_regbit,
6258 (void *)&cmd_read_reg_bit_port_id,
6259 (void *)&cmd_read_reg_bit_reg_off,
6260 (void *)&cmd_read_reg_bit_bit_pos,
6265 /* *** WRITE PORT REGISTER *** */
6266 struct cmd_write_reg_result {
6267 cmdline_fixed_string_t write;
6268 cmdline_fixed_string_t reg;
6275 cmd_write_reg_parsed(void *parsed_result,
6276 __attribute__((unused)) struct cmdline *cl,
6277 __attribute__((unused)) void *data)
6279 struct cmd_write_reg_result *res = parsed_result;
6280 port_reg_set(res->port_id, res->reg_off, res->value);
6283 cmdline_parse_token_string_t cmd_write_reg_write =
6284 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6285 cmdline_parse_token_string_t cmd_write_reg_reg =
6286 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6287 cmdline_parse_token_num_t cmd_write_reg_port_id =
6288 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6289 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6290 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6291 cmdline_parse_token_num_t cmd_write_reg_value =
6292 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6294 cmdline_parse_inst_t cmd_write_reg = {
6295 .f = cmd_write_reg_parsed,
6297 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6299 (void *)&cmd_write_reg_write,
6300 (void *)&cmd_write_reg_reg,
6301 (void *)&cmd_write_reg_port_id,
6302 (void *)&cmd_write_reg_reg_off,
6303 (void *)&cmd_write_reg_value,
6308 /* *** WRITE PORT REGISTER BIT FIELD *** */
6309 struct cmd_write_reg_bit_field_result {
6310 cmdline_fixed_string_t write;
6311 cmdline_fixed_string_t regfield;
6320 cmd_write_reg_bit_field_parsed(void *parsed_result,
6321 __attribute__((unused)) struct cmdline *cl,
6322 __attribute__((unused)) void *data)
6324 struct cmd_write_reg_bit_field_result *res = parsed_result;
6325 port_reg_bit_field_set(res->port_id, res->reg_off,
6326 res->bit1_pos, res->bit2_pos, res->value);
6329 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6330 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6332 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6333 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6334 regfield, "regfield");
6335 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6336 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6338 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6339 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6341 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6342 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6344 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6345 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6347 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6348 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6351 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6352 .f = cmd_write_reg_bit_field_parsed,
6354 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6356 "Set register bit field between bit_x and bit_y included",
6358 (void *)&cmd_write_reg_bit_field_write,
6359 (void *)&cmd_write_reg_bit_field_regfield,
6360 (void *)&cmd_write_reg_bit_field_port_id,
6361 (void *)&cmd_write_reg_bit_field_reg_off,
6362 (void *)&cmd_write_reg_bit_field_bit1_pos,
6363 (void *)&cmd_write_reg_bit_field_bit2_pos,
6364 (void *)&cmd_write_reg_bit_field_value,
6369 /* *** WRITE PORT REGISTER BIT *** */
6370 struct cmd_write_reg_bit_result {
6371 cmdline_fixed_string_t write;
6372 cmdline_fixed_string_t regbit;
6380 cmd_write_reg_bit_parsed(void *parsed_result,
6381 __attribute__((unused)) struct cmdline *cl,
6382 __attribute__((unused)) void *data)
6384 struct cmd_write_reg_bit_result *res = parsed_result;
6385 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6388 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6389 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6391 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6392 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6394 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6395 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6396 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6397 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6398 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6399 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6400 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6401 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6403 cmdline_parse_inst_t cmd_write_reg_bit = {
6404 .f = cmd_write_reg_bit_parsed,
6406 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6409 (void *)&cmd_write_reg_bit_write,
6410 (void *)&cmd_write_reg_bit_regbit,
6411 (void *)&cmd_write_reg_bit_port_id,
6412 (void *)&cmd_write_reg_bit_reg_off,
6413 (void *)&cmd_write_reg_bit_bit_pos,
6414 (void *)&cmd_write_reg_bit_value,
6419 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6420 struct cmd_read_rxd_txd_result {
6421 cmdline_fixed_string_t read;
6422 cmdline_fixed_string_t rxd_txd;
6429 cmd_read_rxd_txd_parsed(void *parsed_result,
6430 __attribute__((unused)) struct cmdline *cl,
6431 __attribute__((unused)) void *data)
6433 struct cmd_read_rxd_txd_result *res = parsed_result;
6435 if (!strcmp(res->rxd_txd, "rxd"))
6436 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6437 else if (!strcmp(res->rxd_txd, "txd"))
6438 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6441 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6442 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6443 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6444 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6446 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6447 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6448 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6449 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6450 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6451 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6453 cmdline_parse_inst_t cmd_read_rxd_txd = {
6454 .f = cmd_read_rxd_txd_parsed,
6456 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6458 (void *)&cmd_read_rxd_txd_read,
6459 (void *)&cmd_read_rxd_txd_rxd_txd,
6460 (void *)&cmd_read_rxd_txd_port_id,
6461 (void *)&cmd_read_rxd_txd_queue_id,
6462 (void *)&cmd_read_rxd_txd_desc_id,
6468 struct cmd_quit_result {
6469 cmdline_fixed_string_t quit;
6472 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6474 __attribute__((unused)) void *data)
6480 cmdline_parse_token_string_t cmd_quit_quit =
6481 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6483 cmdline_parse_inst_t cmd_quit = {
6484 .f = cmd_quit_parsed,
6486 .help_str = "quit: Exit application",
6488 (void *)&cmd_quit_quit,
6493 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6494 struct cmd_mac_addr_result {
6495 cmdline_fixed_string_t mac_addr_cmd;
6496 cmdline_fixed_string_t what;
6498 struct ether_addr address;
6501 static void cmd_mac_addr_parsed(void *parsed_result,
6502 __attribute__((unused)) struct cmdline *cl,
6503 __attribute__((unused)) void *data)
6505 struct cmd_mac_addr_result *res = parsed_result;
6508 if (strcmp(res->what, "add") == 0)
6509 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6510 else if (strcmp(res->what, "set") == 0)
6511 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6514 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6516 /* check the return value and print it if is < 0 */
6518 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6522 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6523 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6525 cmdline_parse_token_string_t cmd_mac_addr_what =
6526 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6528 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6529 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6530 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6531 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6533 cmdline_parse_inst_t cmd_mac_addr = {
6534 .f = cmd_mac_addr_parsed,
6536 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6537 "Add/Remove/Set MAC address on port_id",
6539 (void *)&cmd_mac_addr_cmd,
6540 (void *)&cmd_mac_addr_what,
6541 (void *)&cmd_mac_addr_portnum,
6542 (void *)&cmd_mac_addr_addr,
6548 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6549 struct cmd_set_qmap_result {
6550 cmdline_fixed_string_t set;
6551 cmdline_fixed_string_t qmap;
6552 cmdline_fixed_string_t what;
6559 cmd_set_qmap_parsed(void *parsed_result,
6560 __attribute__((unused)) struct cmdline *cl,
6561 __attribute__((unused)) void *data)
6563 struct cmd_set_qmap_result *res = parsed_result;
6564 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6566 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6569 cmdline_parse_token_string_t cmd_setqmap_set =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6572 cmdline_parse_token_string_t cmd_setqmap_qmap =
6573 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6575 cmdline_parse_token_string_t cmd_setqmap_what =
6576 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6578 cmdline_parse_token_num_t cmd_setqmap_portid =
6579 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6581 cmdline_parse_token_num_t cmd_setqmap_queueid =
6582 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6584 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6585 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6588 cmdline_parse_inst_t cmd_set_qmap = {
6589 .f = cmd_set_qmap_parsed,
6591 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6592 "Set statistics mapping value on tx|rx queue_id of port_id",
6594 (void *)&cmd_setqmap_set,
6595 (void *)&cmd_setqmap_qmap,
6596 (void *)&cmd_setqmap_what,
6597 (void *)&cmd_setqmap_portid,
6598 (void *)&cmd_setqmap_queueid,
6599 (void *)&cmd_setqmap_mapvalue,
6604 /* *** CONFIGURE UNICAST HASH TABLE *** */
6605 struct cmd_set_uc_hash_table {
6606 cmdline_fixed_string_t set;
6607 cmdline_fixed_string_t port;
6609 cmdline_fixed_string_t what;
6610 struct ether_addr address;
6611 cmdline_fixed_string_t mode;
6615 cmd_set_uc_hash_parsed(void *parsed_result,
6616 __attribute__((unused)) struct cmdline *cl,
6617 __attribute__((unused)) void *data)
6620 struct cmd_set_uc_hash_table *res = parsed_result;
6622 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6624 if (strcmp(res->what, "uta") == 0)
6625 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6626 &res->address,(uint8_t)is_on);
6628 printf("bad unicast hash table parameter, return code = %d \n", ret);
6632 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6633 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6635 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6636 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6638 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6639 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6641 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6642 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6644 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6645 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6647 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6648 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6651 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6652 .f = cmd_set_uc_hash_parsed,
6654 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6656 (void *)&cmd_set_uc_hash_set,
6657 (void *)&cmd_set_uc_hash_port,
6658 (void *)&cmd_set_uc_hash_portid,
6659 (void *)&cmd_set_uc_hash_what,
6660 (void *)&cmd_set_uc_hash_mac,
6661 (void *)&cmd_set_uc_hash_mode,
6666 struct cmd_set_uc_all_hash_table {
6667 cmdline_fixed_string_t set;
6668 cmdline_fixed_string_t port;
6670 cmdline_fixed_string_t what;
6671 cmdline_fixed_string_t value;
6672 cmdline_fixed_string_t mode;
6676 cmd_set_uc_all_hash_parsed(void *parsed_result,
6677 __attribute__((unused)) struct cmdline *cl,
6678 __attribute__((unused)) void *data)
6681 struct cmd_set_uc_all_hash_table *res = parsed_result;
6683 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6685 if ((strcmp(res->what, "uta") == 0) &&
6686 (strcmp(res->value, "all") == 0))
6687 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6689 printf("bad unicast hash table parameter,"
6690 "return code = %d \n", ret);
6693 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6694 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6696 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6697 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6699 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6700 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6702 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6703 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6705 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6706 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6708 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6709 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6712 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6713 .f = cmd_set_uc_all_hash_parsed,
6715 .help_str = "set port <port_id> uta all on|off",
6717 (void *)&cmd_set_uc_all_hash_set,
6718 (void *)&cmd_set_uc_all_hash_port,
6719 (void *)&cmd_set_uc_all_hash_portid,
6720 (void *)&cmd_set_uc_all_hash_what,
6721 (void *)&cmd_set_uc_all_hash_value,
6722 (void *)&cmd_set_uc_all_hash_mode,
6727 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6728 struct cmd_set_vf_macvlan_filter {
6729 cmdline_fixed_string_t set;
6730 cmdline_fixed_string_t port;
6732 cmdline_fixed_string_t vf;
6734 struct ether_addr address;
6735 cmdline_fixed_string_t filter_type;
6736 cmdline_fixed_string_t mode;
6740 cmd_set_vf_macvlan_parsed(void *parsed_result,
6741 __attribute__((unused)) struct cmdline *cl,
6742 __attribute__((unused)) void *data)
6745 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6746 struct rte_eth_mac_filter filter;
6748 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6750 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6752 /* set VF MAC filter */
6756 filter.dst_id = res->vf_id;
6758 if (!strcmp(res->filter_type, "exact-mac"))
6759 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6760 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6761 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6762 else if (!strcmp(res->filter_type, "hashmac"))
6763 filter.filter_type = RTE_MAC_HASH_MATCH;
6764 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6765 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6767 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6770 ret = rte_eth_dev_filter_ctrl(res->port_id,
6771 RTE_ETH_FILTER_MACVLAN,
6775 ret = rte_eth_dev_filter_ctrl(res->port_id,
6776 RTE_ETH_FILTER_MACVLAN,
6777 RTE_ETH_FILTER_DELETE,
6781 printf("bad set MAC hash parameter, return code = %d\n", ret);
6785 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6786 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6788 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6789 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6791 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6792 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6794 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6795 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6797 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6798 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6800 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6801 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6803 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6804 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6805 filter_type, "exact-mac#exact-mac-vlan"
6806 "#hashmac#hashmac-vlan");
6807 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6808 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6811 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6812 .f = cmd_set_vf_macvlan_parsed,
6814 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6815 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6816 "Exact match rule: exact match of MAC or MAC and VLAN; "
6817 "hash match rule: hash match of MAC and exact match of VLAN",
6819 (void *)&cmd_set_vf_macvlan_set,
6820 (void *)&cmd_set_vf_macvlan_port,
6821 (void *)&cmd_set_vf_macvlan_portid,
6822 (void *)&cmd_set_vf_macvlan_vf,
6823 (void *)&cmd_set_vf_macvlan_vf_id,
6824 (void *)&cmd_set_vf_macvlan_mac,
6825 (void *)&cmd_set_vf_macvlan_filter_type,
6826 (void *)&cmd_set_vf_macvlan_mode,
6831 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6832 struct cmd_set_vf_traffic {
6833 cmdline_fixed_string_t set;
6834 cmdline_fixed_string_t port;
6836 cmdline_fixed_string_t vf;
6838 cmdline_fixed_string_t what;
6839 cmdline_fixed_string_t mode;
6843 cmd_set_vf_traffic_parsed(void *parsed_result,
6844 __attribute__((unused)) struct cmdline *cl,
6845 __attribute__((unused)) void *data)
6847 struct cmd_set_vf_traffic *res = parsed_result;
6848 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6849 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6851 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6854 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6855 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6857 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6858 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6860 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6861 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6863 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6864 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6866 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6867 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6869 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6870 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6872 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6873 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6876 cmdline_parse_inst_t cmd_set_vf_traffic = {
6877 .f = cmd_set_vf_traffic_parsed,
6879 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6881 (void *)&cmd_setvf_traffic_set,
6882 (void *)&cmd_setvf_traffic_port,
6883 (void *)&cmd_setvf_traffic_portid,
6884 (void *)&cmd_setvf_traffic_vf,
6885 (void *)&cmd_setvf_traffic_vfid,
6886 (void *)&cmd_setvf_traffic_what,
6887 (void *)&cmd_setvf_traffic_mode,
6892 /* *** CONFIGURE VF RECEIVE MODE *** */
6893 struct cmd_set_vf_rxmode {
6894 cmdline_fixed_string_t set;
6895 cmdline_fixed_string_t port;
6897 cmdline_fixed_string_t vf;
6899 cmdline_fixed_string_t what;
6900 cmdline_fixed_string_t mode;
6901 cmdline_fixed_string_t on;
6905 cmd_set_vf_rxmode_parsed(void *parsed_result,
6906 __attribute__((unused)) struct cmdline *cl,
6907 __attribute__((unused)) void *data)
6910 uint16_t rx_mode = 0;
6911 struct cmd_set_vf_rxmode *res = parsed_result;
6913 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6914 if (!strcmp(res->what,"rxmode")) {
6915 if (!strcmp(res->mode, "AUPE"))
6916 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6917 else if (!strcmp(res->mode, "ROPE"))
6918 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6919 else if (!strcmp(res->mode, "BAM"))
6920 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6921 else if (!strncmp(res->mode, "MPE",3))
6922 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6925 #ifdef RTE_LIBRTE_IXGBE_PMD
6926 if (ret == -ENOTSUP)
6927 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
6928 rx_mode, (uint8_t)is_on);
6930 #ifdef RTE_LIBRTE_BNXT_PMD
6931 if (ret == -ENOTSUP)
6932 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
6933 rx_mode, (uint8_t)is_on);
6936 printf("bad VF receive mode parameter, return code = %d \n",
6940 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6941 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6943 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6944 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6946 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6947 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6949 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6950 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6952 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6953 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6955 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6956 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6958 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6959 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6960 mode, "AUPE#ROPE#BAM#MPE");
6961 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6962 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6965 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6966 .f = cmd_set_vf_rxmode_parsed,
6968 .help_str = "set port <port_id> vf <vf_id> rxmode "
6969 "AUPE|ROPE|BAM|MPE on|off",
6971 (void *)&cmd_set_vf_rxmode_set,
6972 (void *)&cmd_set_vf_rxmode_port,
6973 (void *)&cmd_set_vf_rxmode_portid,
6974 (void *)&cmd_set_vf_rxmode_vf,
6975 (void *)&cmd_set_vf_rxmode_vfid,
6976 (void *)&cmd_set_vf_rxmode_what,
6977 (void *)&cmd_set_vf_rxmode_mode,
6978 (void *)&cmd_set_vf_rxmode_on,
6983 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6984 struct cmd_vf_mac_addr_result {
6985 cmdline_fixed_string_t mac_addr_cmd;
6986 cmdline_fixed_string_t what;
6987 cmdline_fixed_string_t port;
6989 cmdline_fixed_string_t vf;
6991 struct ether_addr address;
6994 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6995 __attribute__((unused)) struct cmdline *cl,
6996 __attribute__((unused)) void *data)
6998 struct cmd_vf_mac_addr_result *res = parsed_result;
7001 if (strcmp(res->what, "add") == 0)
7002 ret = rte_eth_dev_mac_addr_add(res->port_num,
7003 &res->address, res->vf_num);
7005 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7009 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7010 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7011 mac_addr_cmd,"mac_addr");
7012 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7013 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7015 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7016 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7018 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7019 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7021 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7022 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7024 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7025 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7027 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7028 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7031 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7032 .f = cmd_vf_mac_addr_parsed,
7034 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7035 "Add MAC address filtering for a VF on port_id",
7037 (void *)&cmd_vf_mac_addr_cmd,
7038 (void *)&cmd_vf_mac_addr_what,
7039 (void *)&cmd_vf_mac_addr_port,
7040 (void *)&cmd_vf_mac_addr_portnum,
7041 (void *)&cmd_vf_mac_addr_vf,
7042 (void *)&cmd_vf_mac_addr_vfnum,
7043 (void *)&cmd_vf_mac_addr_addr,
7048 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7049 struct cmd_vf_rx_vlan_filter {
7050 cmdline_fixed_string_t rx_vlan;
7051 cmdline_fixed_string_t what;
7053 cmdline_fixed_string_t port;
7055 cmdline_fixed_string_t vf;
7060 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7061 __attribute__((unused)) struct cmdline *cl,
7062 __attribute__((unused)) void *data)
7064 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7067 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7069 #ifdef RTE_LIBRTE_IXGBE_PMD
7070 if (ret == -ENOTSUP)
7071 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7072 res->vlan_id, res->vf_mask, is_add);
7074 #ifdef RTE_LIBRTE_I40E_PMD
7075 if (ret == -ENOTSUP)
7076 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7077 res->vlan_id, res->vf_mask, is_add);
7079 #ifdef RTE_LIBRTE_BNXT_PMD
7080 if (ret == -ENOTSUP)
7081 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7082 res->vlan_id, res->vf_mask, is_add);
7089 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7090 res->vlan_id, res->vf_mask);
7093 printf("invalid port_id %d\n", res->port_id);
7096 printf("function not implemented or supported\n");
7099 printf("programming error: (%s)\n", strerror(-ret));
7103 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7104 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7105 rx_vlan, "rx_vlan");
7106 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7107 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7109 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7110 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7112 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7113 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7115 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7116 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7118 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7119 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7121 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7122 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7125 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7126 .f = cmd_vf_rx_vlan_filter_parsed,
7128 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7129 "(vf_mask = hexadecimal VF mask)",
7131 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7132 (void *)&cmd_vf_rx_vlan_filter_what,
7133 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7134 (void *)&cmd_vf_rx_vlan_filter_port,
7135 (void *)&cmd_vf_rx_vlan_filter_portid,
7136 (void *)&cmd_vf_rx_vlan_filter_vf,
7137 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7142 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7143 struct cmd_queue_rate_limit_result {
7144 cmdline_fixed_string_t set;
7145 cmdline_fixed_string_t port;
7147 cmdline_fixed_string_t queue;
7149 cmdline_fixed_string_t rate;
7153 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7154 __attribute__((unused)) struct cmdline *cl,
7155 __attribute__((unused)) void *data)
7157 struct cmd_queue_rate_limit_result *res = parsed_result;
7160 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7161 && (strcmp(res->queue, "queue") == 0)
7162 && (strcmp(res->rate, "rate") == 0))
7163 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7166 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7170 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7171 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7173 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7174 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7176 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7177 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7179 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7180 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7182 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7183 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7185 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7186 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7188 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7189 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7192 cmdline_parse_inst_t cmd_queue_rate_limit = {
7193 .f = cmd_queue_rate_limit_parsed,
7195 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7196 "Set rate limit for a queue on port_id",
7198 (void *)&cmd_queue_rate_limit_set,
7199 (void *)&cmd_queue_rate_limit_port,
7200 (void *)&cmd_queue_rate_limit_portnum,
7201 (void *)&cmd_queue_rate_limit_queue,
7202 (void *)&cmd_queue_rate_limit_queuenum,
7203 (void *)&cmd_queue_rate_limit_rate,
7204 (void *)&cmd_queue_rate_limit_ratenum,
7209 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7210 struct cmd_vf_rate_limit_result {
7211 cmdline_fixed_string_t set;
7212 cmdline_fixed_string_t port;
7214 cmdline_fixed_string_t vf;
7216 cmdline_fixed_string_t rate;
7218 cmdline_fixed_string_t q_msk;
7222 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7223 __attribute__((unused)) struct cmdline *cl,
7224 __attribute__((unused)) void *data)
7226 struct cmd_vf_rate_limit_result *res = parsed_result;
7229 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7230 && (strcmp(res->vf, "vf") == 0)
7231 && (strcmp(res->rate, "rate") == 0)
7232 && (strcmp(res->q_msk, "queue_mask") == 0))
7233 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7234 res->rate_num, res->q_msk_val);
7236 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7240 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7241 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7243 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7244 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7246 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7247 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7249 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7250 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7252 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7253 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7255 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7256 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7258 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7259 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7261 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7262 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7263 q_msk, "queue_mask");
7264 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7265 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7268 cmdline_parse_inst_t cmd_vf_rate_limit = {
7269 .f = cmd_vf_rate_limit_parsed,
7271 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7272 "queue_mask <queue_mask_value>: "
7273 "Set rate limit for queues of VF on port_id",
7275 (void *)&cmd_vf_rate_limit_set,
7276 (void *)&cmd_vf_rate_limit_port,
7277 (void *)&cmd_vf_rate_limit_portnum,
7278 (void *)&cmd_vf_rate_limit_vf,
7279 (void *)&cmd_vf_rate_limit_vfnum,
7280 (void *)&cmd_vf_rate_limit_rate,
7281 (void *)&cmd_vf_rate_limit_ratenum,
7282 (void *)&cmd_vf_rate_limit_q_msk,
7283 (void *)&cmd_vf_rate_limit_q_msk_val,
7288 /* *** ADD TUNNEL FILTER OF A PORT *** */
7289 struct cmd_tunnel_filter_result {
7290 cmdline_fixed_string_t cmd;
7291 cmdline_fixed_string_t what;
7293 struct ether_addr outer_mac;
7294 struct ether_addr inner_mac;
7295 cmdline_ipaddr_t ip_value;
7296 uint16_t inner_vlan;
7297 cmdline_fixed_string_t tunnel_type;
7298 cmdline_fixed_string_t filter_type;
7304 cmd_tunnel_filter_parsed(void *parsed_result,
7305 __attribute__((unused)) struct cmdline *cl,
7306 __attribute__((unused)) void *data)
7308 struct cmd_tunnel_filter_result *res = parsed_result;
7309 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7312 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7314 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7315 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7316 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7318 if (res->ip_value.family == AF_INET) {
7319 tunnel_filter_conf.ip_addr.ipv4_addr =
7320 res->ip_value.addr.ipv4.s_addr;
7321 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7323 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7324 &(res->ip_value.addr.ipv6),
7325 sizeof(struct in6_addr));
7326 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7329 if (!strcmp(res->filter_type, "imac-ivlan"))
7330 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7331 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7332 tunnel_filter_conf.filter_type =
7333 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7334 else if (!strcmp(res->filter_type, "imac-tenid"))
7335 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7336 else if (!strcmp(res->filter_type, "imac"))
7337 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7338 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7339 tunnel_filter_conf.filter_type =
7340 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7341 else if (!strcmp(res->filter_type, "oip"))
7342 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7343 else if (!strcmp(res->filter_type, "iip"))
7344 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7346 printf("The filter type is not supported");
7350 if (!strcmp(res->tunnel_type, "vxlan"))
7351 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7352 else if (!strcmp(res->tunnel_type, "nvgre"))
7353 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7354 else if (!strcmp(res->tunnel_type, "ipingre"))
7355 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7357 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7361 tunnel_filter_conf.tenant_id = res->tenant_id;
7362 tunnel_filter_conf.queue_id = res->queue_num;
7363 if (!strcmp(res->what, "add"))
7364 ret = rte_eth_dev_filter_ctrl(res->port_id,
7365 RTE_ETH_FILTER_TUNNEL,
7367 &tunnel_filter_conf);
7369 ret = rte_eth_dev_filter_ctrl(res->port_id,
7370 RTE_ETH_FILTER_TUNNEL,
7371 RTE_ETH_FILTER_DELETE,
7372 &tunnel_filter_conf);
7374 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7378 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7379 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7380 cmd, "tunnel_filter");
7381 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7382 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7384 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7385 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7387 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7388 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7390 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7391 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7393 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7394 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7395 inner_vlan, UINT16);
7396 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7397 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7399 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7400 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7401 tunnel_type, "vxlan#nvgre#ipingre");
7403 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7404 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7405 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7406 "imac#omac-imac-tenid");
7407 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7408 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7410 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7411 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7414 cmdline_parse_inst_t cmd_tunnel_filter = {
7415 .f = cmd_tunnel_filter_parsed,
7417 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7418 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7419 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7420 "<queue_id>: Add/Rm tunnel filter of a port",
7422 (void *)&cmd_tunnel_filter_cmd,
7423 (void *)&cmd_tunnel_filter_what,
7424 (void *)&cmd_tunnel_filter_port_id,
7425 (void *)&cmd_tunnel_filter_outer_mac,
7426 (void *)&cmd_tunnel_filter_inner_mac,
7427 (void *)&cmd_tunnel_filter_ip_value,
7428 (void *)&cmd_tunnel_filter_innner_vlan,
7429 (void *)&cmd_tunnel_filter_tunnel_type,
7430 (void *)&cmd_tunnel_filter_filter_type,
7431 (void *)&cmd_tunnel_filter_tenant_id,
7432 (void *)&cmd_tunnel_filter_queue_num,
7437 /* *** CONFIGURE TUNNEL UDP PORT *** */
7438 struct cmd_tunnel_udp_config {
7439 cmdline_fixed_string_t cmd;
7440 cmdline_fixed_string_t what;
7446 cmd_tunnel_udp_config_parsed(void *parsed_result,
7447 __attribute__((unused)) struct cmdline *cl,
7448 __attribute__((unused)) void *data)
7450 struct cmd_tunnel_udp_config *res = parsed_result;
7451 struct rte_eth_udp_tunnel tunnel_udp;
7454 tunnel_udp.udp_port = res->udp_port;
7456 if (!strcmp(res->cmd, "rx_vxlan_port"))
7457 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7459 if (!strcmp(res->what, "add"))
7460 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7463 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7467 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7470 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7471 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7472 cmd, "rx_vxlan_port");
7473 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7474 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7476 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7477 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7479 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7480 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7483 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7484 .f = cmd_tunnel_udp_config_parsed,
7486 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7487 "Add/Remove a tunneling UDP port filter",
7489 (void *)&cmd_tunnel_udp_config_cmd,
7490 (void *)&cmd_tunnel_udp_config_what,
7491 (void *)&cmd_tunnel_udp_config_udp_port,
7492 (void *)&cmd_tunnel_udp_config_port_id,
7497 /* *** GLOBAL CONFIG *** */
7498 struct cmd_global_config_result {
7499 cmdline_fixed_string_t cmd;
7501 cmdline_fixed_string_t cfg_type;
7506 cmd_global_config_parsed(void *parsed_result,
7507 __attribute__((unused)) struct cmdline *cl,
7508 __attribute__((unused)) void *data)
7510 struct cmd_global_config_result *res = parsed_result;
7511 struct rte_eth_global_cfg conf;
7514 memset(&conf, 0, sizeof(conf));
7515 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7516 conf.cfg.gre_key_len = res->len;
7517 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7518 RTE_ETH_FILTER_SET, &conf);
7520 printf("Global config error\n");
7523 cmdline_parse_token_string_t cmd_global_config_cmd =
7524 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7526 cmdline_parse_token_num_t cmd_global_config_port_id =
7527 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7528 cmdline_parse_token_string_t cmd_global_config_type =
7529 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7530 cfg_type, "gre-key-len");
7531 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7532 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7535 cmdline_parse_inst_t cmd_global_config = {
7536 .f = cmd_global_config_parsed,
7537 .data = (void *)NULL,
7538 .help_str = "global_config <port_id> gre-key-len <key_len>",
7540 (void *)&cmd_global_config_cmd,
7541 (void *)&cmd_global_config_port_id,
7542 (void *)&cmd_global_config_type,
7543 (void *)&cmd_global_config_gre_key_len,
7548 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7549 struct cmd_set_mirror_mask_result {
7550 cmdline_fixed_string_t set;
7551 cmdline_fixed_string_t port;
7553 cmdline_fixed_string_t mirror;
7555 cmdline_fixed_string_t what;
7556 cmdline_fixed_string_t value;
7557 cmdline_fixed_string_t dstpool;
7559 cmdline_fixed_string_t on;
7562 cmdline_parse_token_string_t cmd_mirror_mask_set =
7563 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7565 cmdline_parse_token_string_t cmd_mirror_mask_port =
7566 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7568 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7569 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7571 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7572 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7573 mirror, "mirror-rule");
7574 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7575 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7577 cmdline_parse_token_string_t cmd_mirror_mask_what =
7578 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7579 what, "pool-mirror-up#pool-mirror-down"
7581 cmdline_parse_token_string_t cmd_mirror_mask_value =
7582 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7584 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7585 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7586 dstpool, "dst-pool");
7587 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7588 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7590 cmdline_parse_token_string_t cmd_mirror_mask_on =
7591 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7595 cmd_set_mirror_mask_parsed(void *parsed_result,
7596 __attribute__((unused)) struct cmdline *cl,
7597 __attribute__((unused)) void *data)
7600 struct cmd_set_mirror_mask_result *res = parsed_result;
7601 struct rte_eth_mirror_conf mr_conf;
7603 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7605 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7607 mr_conf.dst_pool = res->dstpool_id;
7609 if (!strcmp(res->what, "pool-mirror-up")) {
7610 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7611 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7612 } else if (!strcmp(res->what, "pool-mirror-down")) {
7613 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7614 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7615 } else if (!strcmp(res->what, "vlan-mirror")) {
7616 mr_conf.rule_type = ETH_MIRROR_VLAN;
7617 nb_item = parse_item_list(res->value, "vlan",
7618 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7622 for (i = 0; i < nb_item; i++) {
7623 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7624 printf("Invalid vlan_id: must be < 4096\n");
7628 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7629 mr_conf.vlan.vlan_mask |= 1ULL << i;
7633 if (!strcmp(res->on, "on"))
7634 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7637 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7640 printf("mirror rule add error: (%s)\n", strerror(-ret));
7643 cmdline_parse_inst_t cmd_set_mirror_mask = {
7644 .f = cmd_set_mirror_mask_parsed,
7646 .help_str = "set port <port_id> mirror-rule <rule_id> "
7647 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7648 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7650 (void *)&cmd_mirror_mask_set,
7651 (void *)&cmd_mirror_mask_port,
7652 (void *)&cmd_mirror_mask_portid,
7653 (void *)&cmd_mirror_mask_mirror,
7654 (void *)&cmd_mirror_mask_ruleid,
7655 (void *)&cmd_mirror_mask_what,
7656 (void *)&cmd_mirror_mask_value,
7657 (void *)&cmd_mirror_mask_dstpool,
7658 (void *)&cmd_mirror_mask_poolid,
7659 (void *)&cmd_mirror_mask_on,
7664 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7665 struct cmd_set_mirror_link_result {
7666 cmdline_fixed_string_t set;
7667 cmdline_fixed_string_t port;
7669 cmdline_fixed_string_t mirror;
7671 cmdline_fixed_string_t what;
7672 cmdline_fixed_string_t dstpool;
7674 cmdline_fixed_string_t on;
7677 cmdline_parse_token_string_t cmd_mirror_link_set =
7678 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7680 cmdline_parse_token_string_t cmd_mirror_link_port =
7681 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7683 cmdline_parse_token_num_t cmd_mirror_link_portid =
7684 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7686 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7687 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7688 mirror, "mirror-rule");
7689 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7690 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7692 cmdline_parse_token_string_t cmd_mirror_link_what =
7693 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7694 what, "uplink-mirror#downlink-mirror");
7695 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7696 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7697 dstpool, "dst-pool");
7698 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7699 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7701 cmdline_parse_token_string_t cmd_mirror_link_on =
7702 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7706 cmd_set_mirror_link_parsed(void *parsed_result,
7707 __attribute__((unused)) struct cmdline *cl,
7708 __attribute__((unused)) void *data)
7711 struct cmd_set_mirror_link_result *res = parsed_result;
7712 struct rte_eth_mirror_conf mr_conf;
7714 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7715 if (!strcmp(res->what, "uplink-mirror"))
7716 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7718 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7720 mr_conf.dst_pool = res->dstpool_id;
7722 if (!strcmp(res->on, "on"))
7723 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7726 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7729 /* check the return value and print it if is < 0 */
7731 printf("mirror rule add error: (%s)\n", strerror(-ret));
7735 cmdline_parse_inst_t cmd_set_mirror_link = {
7736 .f = cmd_set_mirror_link_parsed,
7738 .help_str = "set port <port_id> mirror-rule <rule_id> "
7739 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7741 (void *)&cmd_mirror_link_set,
7742 (void *)&cmd_mirror_link_port,
7743 (void *)&cmd_mirror_link_portid,
7744 (void *)&cmd_mirror_link_mirror,
7745 (void *)&cmd_mirror_link_ruleid,
7746 (void *)&cmd_mirror_link_what,
7747 (void *)&cmd_mirror_link_dstpool,
7748 (void *)&cmd_mirror_link_poolid,
7749 (void *)&cmd_mirror_link_on,
7754 /* *** RESET VM MIRROR RULE *** */
7755 struct cmd_rm_mirror_rule_result {
7756 cmdline_fixed_string_t reset;
7757 cmdline_fixed_string_t port;
7759 cmdline_fixed_string_t mirror;
7763 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7764 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7766 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7767 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7769 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7770 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7772 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7773 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7774 mirror, "mirror-rule");
7775 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7776 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7780 cmd_reset_mirror_rule_parsed(void *parsed_result,
7781 __attribute__((unused)) struct cmdline *cl,
7782 __attribute__((unused)) void *data)
7785 struct cmd_set_mirror_link_result *res = parsed_result;
7787 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7789 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7792 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7793 .f = cmd_reset_mirror_rule_parsed,
7795 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7797 (void *)&cmd_rm_mirror_rule_reset,
7798 (void *)&cmd_rm_mirror_rule_port,
7799 (void *)&cmd_rm_mirror_rule_portid,
7800 (void *)&cmd_rm_mirror_rule_mirror,
7801 (void *)&cmd_rm_mirror_rule_ruleid,
7806 /* ******************************************************************************** */
7808 struct cmd_dump_result {
7809 cmdline_fixed_string_t dump;
7813 dump_struct_sizes(void)
7815 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7816 DUMP_SIZE(struct rte_mbuf);
7817 DUMP_SIZE(struct rte_mempool);
7818 DUMP_SIZE(struct rte_ring);
7822 static void cmd_dump_parsed(void *parsed_result,
7823 __attribute__((unused)) struct cmdline *cl,
7824 __attribute__((unused)) void *data)
7826 struct cmd_dump_result *res = parsed_result;
7828 if (!strcmp(res->dump, "dump_physmem"))
7829 rte_dump_physmem_layout(stdout);
7830 else if (!strcmp(res->dump, "dump_memzone"))
7831 rte_memzone_dump(stdout);
7832 else if (!strcmp(res->dump, "dump_struct_sizes"))
7833 dump_struct_sizes();
7834 else if (!strcmp(res->dump, "dump_ring"))
7835 rte_ring_list_dump(stdout);
7836 else if (!strcmp(res->dump, "dump_mempool"))
7837 rte_mempool_list_dump(stdout);
7838 else if (!strcmp(res->dump, "dump_devargs"))
7839 rte_eal_devargs_dump(stdout);
7840 else if (!strcmp(res->dump, "dump_log_types"))
7841 rte_log_dump(stdout);
7844 cmdline_parse_token_string_t cmd_dump_dump =
7845 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7848 "dump_struct_sizes#"
7854 cmdline_parse_inst_t cmd_dump = {
7855 .f = cmd_dump_parsed, /* function to call */
7856 .data = NULL, /* 2nd arg of func */
7857 .help_str = "Dump status",
7858 .tokens = { /* token list, NULL terminated */
7859 (void *)&cmd_dump_dump,
7864 /* ******************************************************************************** */
7866 struct cmd_dump_one_result {
7867 cmdline_fixed_string_t dump;
7868 cmdline_fixed_string_t name;
7871 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7872 __attribute__((unused)) void *data)
7874 struct cmd_dump_one_result *res = parsed_result;
7876 if (!strcmp(res->dump, "dump_ring")) {
7878 r = rte_ring_lookup(res->name);
7880 cmdline_printf(cl, "Cannot find ring\n");
7883 rte_ring_dump(stdout, r);
7884 } else if (!strcmp(res->dump, "dump_mempool")) {
7885 struct rte_mempool *mp;
7886 mp = rte_mempool_lookup(res->name);
7888 cmdline_printf(cl, "Cannot find mempool\n");
7891 rte_mempool_dump(stdout, mp);
7895 cmdline_parse_token_string_t cmd_dump_one_dump =
7896 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7897 "dump_ring#dump_mempool");
7899 cmdline_parse_token_string_t cmd_dump_one_name =
7900 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7902 cmdline_parse_inst_t cmd_dump_one = {
7903 .f = cmd_dump_one_parsed, /* function to call */
7904 .data = NULL, /* 2nd arg of func */
7905 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7906 .tokens = { /* token list, NULL terminated */
7907 (void *)&cmd_dump_one_dump,
7908 (void *)&cmd_dump_one_name,
7913 /* *** Add/Del syn filter *** */
7914 struct cmd_syn_filter_result {
7915 cmdline_fixed_string_t filter;
7917 cmdline_fixed_string_t ops;
7918 cmdline_fixed_string_t priority;
7919 cmdline_fixed_string_t high;
7920 cmdline_fixed_string_t queue;
7925 cmd_syn_filter_parsed(void *parsed_result,
7926 __attribute__((unused)) struct cmdline *cl,
7927 __attribute__((unused)) void *data)
7929 struct cmd_syn_filter_result *res = parsed_result;
7930 struct rte_eth_syn_filter syn_filter;
7933 ret = rte_eth_dev_filter_supported(res->port_id,
7934 RTE_ETH_FILTER_SYN);
7936 printf("syn filter is not supported on port %u.\n",
7941 memset(&syn_filter, 0, sizeof(syn_filter));
7943 if (!strcmp(res->ops, "add")) {
7944 if (!strcmp(res->high, "high"))
7945 syn_filter.hig_pri = 1;
7947 syn_filter.hig_pri = 0;
7949 syn_filter.queue = res->queue_id;
7950 ret = rte_eth_dev_filter_ctrl(res->port_id,
7955 ret = rte_eth_dev_filter_ctrl(res->port_id,
7957 RTE_ETH_FILTER_DELETE,
7961 printf("syn filter programming error: (%s)\n",
7965 cmdline_parse_token_string_t cmd_syn_filter_filter =
7966 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7967 filter, "syn_filter");
7968 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7969 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7971 cmdline_parse_token_string_t cmd_syn_filter_ops =
7972 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7974 cmdline_parse_token_string_t cmd_syn_filter_priority =
7975 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7976 priority, "priority");
7977 cmdline_parse_token_string_t cmd_syn_filter_high =
7978 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7980 cmdline_parse_token_string_t cmd_syn_filter_queue =
7981 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7983 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7984 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7987 cmdline_parse_inst_t cmd_syn_filter = {
7988 .f = cmd_syn_filter_parsed,
7990 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7991 "<queue_id>: Add/Delete syn filter",
7993 (void *)&cmd_syn_filter_filter,
7994 (void *)&cmd_syn_filter_port_id,
7995 (void *)&cmd_syn_filter_ops,
7996 (void *)&cmd_syn_filter_priority,
7997 (void *)&cmd_syn_filter_high,
7998 (void *)&cmd_syn_filter_queue,
7999 (void *)&cmd_syn_filter_queue_id,
8004 /* *** ADD/REMOVE A 2tuple FILTER *** */
8005 struct cmd_2tuple_filter_result {
8006 cmdline_fixed_string_t filter;
8008 cmdline_fixed_string_t ops;
8009 cmdline_fixed_string_t dst_port;
8010 uint16_t dst_port_value;
8011 cmdline_fixed_string_t protocol;
8012 uint8_t protocol_value;
8013 cmdline_fixed_string_t mask;
8015 cmdline_fixed_string_t tcp_flags;
8016 uint8_t tcp_flags_value;
8017 cmdline_fixed_string_t priority;
8018 uint8_t priority_value;
8019 cmdline_fixed_string_t queue;
8024 cmd_2tuple_filter_parsed(void *parsed_result,
8025 __attribute__((unused)) struct cmdline *cl,
8026 __attribute__((unused)) void *data)
8028 struct rte_eth_ntuple_filter filter;
8029 struct cmd_2tuple_filter_result *res = parsed_result;
8032 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8034 printf("ntuple filter is not supported on port %u.\n",
8039 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8041 filter.flags = RTE_2TUPLE_FLAGS;
8042 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8043 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8044 filter.proto = res->protocol_value;
8045 filter.priority = res->priority_value;
8046 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8047 printf("nonzero tcp_flags is only meaningful"
8048 " when protocol is TCP.\n");
8051 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8052 printf("invalid TCP flags.\n");
8056 if (res->tcp_flags_value != 0) {
8057 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8058 filter.tcp_flags = res->tcp_flags_value;
8061 /* need convert to big endian. */
8062 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8063 filter.queue = res->queue_id;
8065 if (!strcmp(res->ops, "add"))
8066 ret = rte_eth_dev_filter_ctrl(res->port_id,
8067 RTE_ETH_FILTER_NTUPLE,
8071 ret = rte_eth_dev_filter_ctrl(res->port_id,
8072 RTE_ETH_FILTER_NTUPLE,
8073 RTE_ETH_FILTER_DELETE,
8076 printf("2tuple filter programming error: (%s)\n",
8081 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8082 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8083 filter, "2tuple_filter");
8084 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8085 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8087 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8088 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8090 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8091 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8092 dst_port, "dst_port");
8093 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8094 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8095 dst_port_value, UINT16);
8096 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8097 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8098 protocol, "protocol");
8099 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8100 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8101 protocol_value, UINT8);
8102 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8103 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8105 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8106 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8108 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8109 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8110 tcp_flags, "tcp_flags");
8111 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8112 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8113 tcp_flags_value, UINT8);
8114 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8115 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8116 priority, "priority");
8117 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8118 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8119 priority_value, UINT8);
8120 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8121 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8123 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8124 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8127 cmdline_parse_inst_t cmd_2tuple_filter = {
8128 .f = cmd_2tuple_filter_parsed,
8130 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8131 "<value> mask <value> tcp_flags <value> priority <value> queue "
8132 "<queue_id>: Add a 2tuple filter",
8134 (void *)&cmd_2tuple_filter_filter,
8135 (void *)&cmd_2tuple_filter_port_id,
8136 (void *)&cmd_2tuple_filter_ops,
8137 (void *)&cmd_2tuple_filter_dst_port,
8138 (void *)&cmd_2tuple_filter_dst_port_value,
8139 (void *)&cmd_2tuple_filter_protocol,
8140 (void *)&cmd_2tuple_filter_protocol_value,
8141 (void *)&cmd_2tuple_filter_mask,
8142 (void *)&cmd_2tuple_filter_mask_value,
8143 (void *)&cmd_2tuple_filter_tcp_flags,
8144 (void *)&cmd_2tuple_filter_tcp_flags_value,
8145 (void *)&cmd_2tuple_filter_priority,
8146 (void *)&cmd_2tuple_filter_priority_value,
8147 (void *)&cmd_2tuple_filter_queue,
8148 (void *)&cmd_2tuple_filter_queue_id,
8153 /* *** ADD/REMOVE A 5tuple FILTER *** */
8154 struct cmd_5tuple_filter_result {
8155 cmdline_fixed_string_t filter;
8157 cmdline_fixed_string_t ops;
8158 cmdline_fixed_string_t dst_ip;
8159 cmdline_ipaddr_t dst_ip_value;
8160 cmdline_fixed_string_t src_ip;
8161 cmdline_ipaddr_t src_ip_value;
8162 cmdline_fixed_string_t dst_port;
8163 uint16_t dst_port_value;
8164 cmdline_fixed_string_t src_port;
8165 uint16_t src_port_value;
8166 cmdline_fixed_string_t protocol;
8167 uint8_t protocol_value;
8168 cmdline_fixed_string_t mask;
8170 cmdline_fixed_string_t tcp_flags;
8171 uint8_t tcp_flags_value;
8172 cmdline_fixed_string_t priority;
8173 uint8_t priority_value;
8174 cmdline_fixed_string_t queue;
8179 cmd_5tuple_filter_parsed(void *parsed_result,
8180 __attribute__((unused)) struct cmdline *cl,
8181 __attribute__((unused)) void *data)
8183 struct rte_eth_ntuple_filter filter;
8184 struct cmd_5tuple_filter_result *res = parsed_result;
8187 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8189 printf("ntuple filter is not supported on port %u.\n",
8194 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8196 filter.flags = RTE_5TUPLE_FLAGS;
8197 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8198 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8199 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8200 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8201 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8202 filter.proto = res->protocol_value;
8203 filter.priority = res->priority_value;
8204 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8205 printf("nonzero tcp_flags is only meaningful"
8206 " when protocol is TCP.\n");
8209 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8210 printf("invalid TCP flags.\n");
8214 if (res->tcp_flags_value != 0) {
8215 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8216 filter.tcp_flags = res->tcp_flags_value;
8219 if (res->dst_ip_value.family == AF_INET)
8220 /* no need to convert, already big endian. */
8221 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8223 if (filter.dst_ip_mask == 0) {
8224 printf("can not support ipv6 involved compare.\n");
8230 if (res->src_ip_value.family == AF_INET)
8231 /* no need to convert, already big endian. */
8232 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8234 if (filter.src_ip_mask == 0) {
8235 printf("can not support ipv6 involved compare.\n");
8240 /* need convert to big endian. */
8241 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8242 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8243 filter.queue = res->queue_id;
8245 if (!strcmp(res->ops, "add"))
8246 ret = rte_eth_dev_filter_ctrl(res->port_id,
8247 RTE_ETH_FILTER_NTUPLE,
8251 ret = rte_eth_dev_filter_ctrl(res->port_id,
8252 RTE_ETH_FILTER_NTUPLE,
8253 RTE_ETH_FILTER_DELETE,
8256 printf("5tuple filter programming error: (%s)\n",
8260 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8261 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8262 filter, "5tuple_filter");
8263 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8264 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8266 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8267 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8269 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8270 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8272 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8273 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8275 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8276 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8278 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8279 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8281 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8282 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8283 dst_port, "dst_port");
8284 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8285 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8286 dst_port_value, UINT16);
8287 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8288 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8289 src_port, "src_port");
8290 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8291 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8292 src_port_value, UINT16);
8293 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8294 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8295 protocol, "protocol");
8296 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8297 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8298 protocol_value, UINT8);
8299 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8300 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8302 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8303 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8305 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8306 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8307 tcp_flags, "tcp_flags");
8308 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8309 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8310 tcp_flags_value, UINT8);
8311 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8312 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8313 priority, "priority");
8314 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8315 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8316 priority_value, UINT8);
8317 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8318 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8320 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8321 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8324 cmdline_parse_inst_t cmd_5tuple_filter = {
8325 .f = cmd_5tuple_filter_parsed,
8327 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8328 "src_ip <value> dst_port <value> src_port <value> "
8329 "protocol <value> mask <value> tcp_flags <value> "
8330 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8332 (void *)&cmd_5tuple_filter_filter,
8333 (void *)&cmd_5tuple_filter_port_id,
8334 (void *)&cmd_5tuple_filter_ops,
8335 (void *)&cmd_5tuple_filter_dst_ip,
8336 (void *)&cmd_5tuple_filter_dst_ip_value,
8337 (void *)&cmd_5tuple_filter_src_ip,
8338 (void *)&cmd_5tuple_filter_src_ip_value,
8339 (void *)&cmd_5tuple_filter_dst_port,
8340 (void *)&cmd_5tuple_filter_dst_port_value,
8341 (void *)&cmd_5tuple_filter_src_port,
8342 (void *)&cmd_5tuple_filter_src_port_value,
8343 (void *)&cmd_5tuple_filter_protocol,
8344 (void *)&cmd_5tuple_filter_protocol_value,
8345 (void *)&cmd_5tuple_filter_mask,
8346 (void *)&cmd_5tuple_filter_mask_value,
8347 (void *)&cmd_5tuple_filter_tcp_flags,
8348 (void *)&cmd_5tuple_filter_tcp_flags_value,
8349 (void *)&cmd_5tuple_filter_priority,
8350 (void *)&cmd_5tuple_filter_priority_value,
8351 (void *)&cmd_5tuple_filter_queue,
8352 (void *)&cmd_5tuple_filter_queue_id,
8357 /* *** ADD/REMOVE A flex FILTER *** */
8358 struct cmd_flex_filter_result {
8359 cmdline_fixed_string_t filter;
8360 cmdline_fixed_string_t ops;
8362 cmdline_fixed_string_t len;
8364 cmdline_fixed_string_t bytes;
8365 cmdline_fixed_string_t bytes_value;
8366 cmdline_fixed_string_t mask;
8367 cmdline_fixed_string_t mask_value;
8368 cmdline_fixed_string_t priority;
8369 uint8_t priority_value;
8370 cmdline_fixed_string_t queue;
8374 static int xdigit2val(unsigned char c)
8379 else if (isupper(c))
8387 cmd_flex_filter_parsed(void *parsed_result,
8388 __attribute__((unused)) struct cmdline *cl,
8389 __attribute__((unused)) void *data)
8392 struct rte_eth_flex_filter filter;
8393 struct cmd_flex_filter_result *res = parsed_result;
8394 char *bytes_ptr, *mask_ptr;
8395 uint16_t len, i, j = 0;
8400 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8401 printf("the len exceed the max length 128\n");
8404 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8405 filter.len = res->len_value;
8406 filter.priority = res->priority_value;
8407 filter.queue = res->queue_id;
8408 bytes_ptr = res->bytes_value;
8409 mask_ptr = res->mask_value;
8411 /* translate bytes string to array. */
8412 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8413 (bytes_ptr[1] == 'X')))
8415 len = strnlen(bytes_ptr, res->len_value * 2);
8416 if (len == 0 || (len % 8 != 0)) {
8417 printf("please check len and bytes input\n");
8420 for (i = 0; i < len; i++) {
8422 if (isxdigit(c) == 0) {
8423 /* invalid characters. */
8424 printf("invalid input\n");
8427 val = xdigit2val(c);
8430 filter.bytes[j] = byte;
8431 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8438 /* translate mask string to uint8_t array. */
8439 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8440 (mask_ptr[1] == 'X')))
8442 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8444 printf("invalid input\n");
8449 for (i = 0; i < len; i++) {
8451 if (isxdigit(c) == 0) {
8452 /* invalid characters. */
8453 printf("invalid input\n");
8456 val = xdigit2val(c);
8459 filter.mask[j] = byte;
8460 printf("mask[%d]:%02x ", j, filter.mask[j]);
8468 if (!strcmp(res->ops, "add"))
8469 ret = rte_eth_dev_filter_ctrl(res->port_id,
8470 RTE_ETH_FILTER_FLEXIBLE,
8474 ret = rte_eth_dev_filter_ctrl(res->port_id,
8475 RTE_ETH_FILTER_FLEXIBLE,
8476 RTE_ETH_FILTER_DELETE,
8480 printf("flex filter setting error: (%s)\n", strerror(-ret));
8483 cmdline_parse_token_string_t cmd_flex_filter_filter =
8484 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8485 filter, "flex_filter");
8486 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8487 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8489 cmdline_parse_token_string_t cmd_flex_filter_ops =
8490 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8492 cmdline_parse_token_string_t cmd_flex_filter_len =
8493 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8495 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8496 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8498 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8499 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8501 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8502 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8504 cmdline_parse_token_string_t cmd_flex_filter_mask =
8505 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8507 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8508 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8510 cmdline_parse_token_string_t cmd_flex_filter_priority =
8511 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8512 priority, "priority");
8513 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8514 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8515 priority_value, UINT8);
8516 cmdline_parse_token_string_t cmd_flex_filter_queue =
8517 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8519 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8520 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8522 cmdline_parse_inst_t cmd_flex_filter = {
8523 .f = cmd_flex_filter_parsed,
8525 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8526 "<value> mask <value> priority <value> queue <queue_id>: "
8527 "Add/Del a flex filter",
8529 (void *)&cmd_flex_filter_filter,
8530 (void *)&cmd_flex_filter_port_id,
8531 (void *)&cmd_flex_filter_ops,
8532 (void *)&cmd_flex_filter_len,
8533 (void *)&cmd_flex_filter_len_value,
8534 (void *)&cmd_flex_filter_bytes,
8535 (void *)&cmd_flex_filter_bytes_value,
8536 (void *)&cmd_flex_filter_mask,
8537 (void *)&cmd_flex_filter_mask_value,
8538 (void *)&cmd_flex_filter_priority,
8539 (void *)&cmd_flex_filter_priority_value,
8540 (void *)&cmd_flex_filter_queue,
8541 (void *)&cmd_flex_filter_queue_id,
8546 /* *** Filters Control *** */
8548 /* *** deal with ethertype filter *** */
8549 struct cmd_ethertype_filter_result {
8550 cmdline_fixed_string_t filter;
8552 cmdline_fixed_string_t ops;
8553 cmdline_fixed_string_t mac;
8554 struct ether_addr mac_addr;
8555 cmdline_fixed_string_t ethertype;
8556 uint16_t ethertype_value;
8557 cmdline_fixed_string_t drop;
8558 cmdline_fixed_string_t queue;
8562 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8563 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8564 filter, "ethertype_filter");
8565 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8566 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8568 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8569 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8571 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8572 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8573 mac, "mac_addr#mac_ignr");
8574 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8575 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8577 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8578 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8579 ethertype, "ethertype");
8580 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8581 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8582 ethertype_value, UINT16);
8583 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8584 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8586 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8587 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8589 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8590 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8594 cmd_ethertype_filter_parsed(void *parsed_result,
8595 __attribute__((unused)) struct cmdline *cl,
8596 __attribute__((unused)) void *data)
8598 struct cmd_ethertype_filter_result *res = parsed_result;
8599 struct rte_eth_ethertype_filter filter;
8602 ret = rte_eth_dev_filter_supported(res->port_id,
8603 RTE_ETH_FILTER_ETHERTYPE);
8605 printf("ethertype filter is not supported on port %u.\n",
8610 memset(&filter, 0, sizeof(filter));
8611 if (!strcmp(res->mac, "mac_addr")) {
8612 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8613 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8614 sizeof(struct ether_addr));
8616 if (!strcmp(res->drop, "drop"))
8617 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8618 filter.ether_type = res->ethertype_value;
8619 filter.queue = res->queue_id;
8621 if (!strcmp(res->ops, "add"))
8622 ret = rte_eth_dev_filter_ctrl(res->port_id,
8623 RTE_ETH_FILTER_ETHERTYPE,
8627 ret = rte_eth_dev_filter_ctrl(res->port_id,
8628 RTE_ETH_FILTER_ETHERTYPE,
8629 RTE_ETH_FILTER_DELETE,
8632 printf("ethertype filter programming error: (%s)\n",
8636 cmdline_parse_inst_t cmd_ethertype_filter = {
8637 .f = cmd_ethertype_filter_parsed,
8639 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8640 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8641 "Add or delete an ethertype filter entry",
8643 (void *)&cmd_ethertype_filter_filter,
8644 (void *)&cmd_ethertype_filter_port_id,
8645 (void *)&cmd_ethertype_filter_ops,
8646 (void *)&cmd_ethertype_filter_mac,
8647 (void *)&cmd_ethertype_filter_mac_addr,
8648 (void *)&cmd_ethertype_filter_ethertype,
8649 (void *)&cmd_ethertype_filter_ethertype_value,
8650 (void *)&cmd_ethertype_filter_drop,
8651 (void *)&cmd_ethertype_filter_queue,
8652 (void *)&cmd_ethertype_filter_queue_id,
8657 /* *** deal with flow director filter *** */
8658 struct cmd_flow_director_result {
8659 cmdline_fixed_string_t flow_director_filter;
8661 cmdline_fixed_string_t mode;
8662 cmdline_fixed_string_t mode_value;
8663 cmdline_fixed_string_t ops;
8664 cmdline_fixed_string_t flow;
8665 cmdline_fixed_string_t flow_type;
8666 cmdline_fixed_string_t ether;
8667 uint16_t ether_type;
8668 cmdline_fixed_string_t src;
8669 cmdline_ipaddr_t ip_src;
8671 cmdline_fixed_string_t dst;
8672 cmdline_ipaddr_t ip_dst;
8674 cmdline_fixed_string_t verify_tag;
8675 uint32_t verify_tag_value;
8676 cmdline_ipaddr_t tos;
8678 cmdline_ipaddr_t proto;
8679 uint8_t proto_value;
8680 cmdline_ipaddr_t ttl;
8682 cmdline_fixed_string_t vlan;
8683 uint16_t vlan_value;
8684 cmdline_fixed_string_t flexbytes;
8685 cmdline_fixed_string_t flexbytes_value;
8686 cmdline_fixed_string_t pf_vf;
8687 cmdline_fixed_string_t drop;
8688 cmdline_fixed_string_t queue;
8690 cmdline_fixed_string_t fd_id;
8691 uint32_t fd_id_value;
8692 cmdline_fixed_string_t mac;
8693 struct ether_addr mac_addr;
8694 cmdline_fixed_string_t tunnel;
8695 cmdline_fixed_string_t tunnel_type;
8696 cmdline_fixed_string_t tunnel_id;
8697 uint32_t tunnel_id_value;
8701 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8704 const char *p, *p0 = q_arg;
8706 unsigned long int_fld;
8707 char *str_fld[max_num];
8712 p = strchr(p0, '(');
8716 p0 = strchr(p, ')');
8721 if (size >= sizeof(s))
8724 snprintf(s, sizeof(s), "%.*s", size, p);
8725 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8726 if (ret < 0 || ret > max_num)
8728 for (i = 0; i < ret; i++) {
8730 int_fld = strtoul(str_fld[i], &end, 0);
8731 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8733 flexbytes[i] = (uint8_t)int_fld;
8739 str2flowtype(char *string)
8742 static const struct {
8745 } flowtype_str[] = {
8746 {"raw", RTE_ETH_FLOW_RAW},
8747 {"ipv4", RTE_ETH_FLOW_IPV4},
8748 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8749 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8750 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8751 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8752 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8753 {"ipv6", RTE_ETH_FLOW_IPV6},
8754 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8755 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8756 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8757 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8758 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8759 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8762 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8763 if (!strcmp(flowtype_str[i].str, string))
8764 return flowtype_str[i].type;
8766 return RTE_ETH_FLOW_UNKNOWN;
8769 static enum rte_eth_fdir_tunnel_type
8770 str2fdir_tunneltype(char *string)
8774 static const struct {
8776 enum rte_eth_fdir_tunnel_type type;
8777 } tunneltype_str[] = {
8778 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8779 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8782 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8783 if (!strcmp(tunneltype_str[i].str, string))
8784 return tunneltype_str[i].type;
8786 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8789 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8791 if ((ip_addr).family == AF_INET) \
8792 (ip) = (ip_addr).addr.ipv4.s_addr; \
8794 printf("invalid parameter.\n"); \
8799 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8801 if ((ip_addr).family == AF_INET6) \
8802 (void)rte_memcpy(&(ip), \
8803 &((ip_addr).addr.ipv6), \
8804 sizeof(struct in6_addr)); \
8806 printf("invalid parameter.\n"); \
8812 cmd_flow_director_filter_parsed(void *parsed_result,
8813 __attribute__((unused)) struct cmdline *cl,
8814 __attribute__((unused)) void *data)
8816 struct cmd_flow_director_result *res = parsed_result;
8817 struct rte_eth_fdir_filter entry;
8818 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8820 unsigned long vf_id;
8823 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8825 printf("flow director is not supported on port %u.\n",
8829 memset(flexbytes, 0, sizeof(flexbytes));
8830 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8832 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8833 if (strcmp(res->mode_value, "MAC-VLAN")) {
8834 printf("Please set mode to MAC-VLAN.\n");
8837 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8838 if (strcmp(res->mode_value, "Tunnel")) {
8839 printf("Please set mode to Tunnel.\n");
8843 if (strcmp(res->mode_value, "IP")) {
8844 printf("Please set mode to IP.\n");
8847 entry.input.flow_type = str2flowtype(res->flow_type);
8850 ret = parse_flexbytes(res->flexbytes_value,
8852 RTE_ETH_FDIR_MAX_FLEXLEN);
8854 printf("error: Cannot parse flexbytes input.\n");
8858 switch (entry.input.flow_type) {
8859 case RTE_ETH_FLOW_FRAG_IPV4:
8860 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8861 entry.input.flow.ip4_flow.proto = res->proto_value;
8863 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8864 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8865 IPV4_ADDR_TO_UINT(res->ip_dst,
8866 entry.input.flow.ip4_flow.dst_ip);
8867 IPV4_ADDR_TO_UINT(res->ip_src,
8868 entry.input.flow.ip4_flow.src_ip);
8869 entry.input.flow.ip4_flow.tos = res->tos_value;
8870 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8871 /* need convert to big endian. */
8872 entry.input.flow.udp4_flow.dst_port =
8873 rte_cpu_to_be_16(res->port_dst);
8874 entry.input.flow.udp4_flow.src_port =
8875 rte_cpu_to_be_16(res->port_src);
8877 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8878 IPV4_ADDR_TO_UINT(res->ip_dst,
8879 entry.input.flow.sctp4_flow.ip.dst_ip);
8880 IPV4_ADDR_TO_UINT(res->ip_src,
8881 entry.input.flow.sctp4_flow.ip.src_ip);
8882 entry.input.flow.ip4_flow.tos = res->tos_value;
8883 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8884 /* need convert to big endian. */
8885 entry.input.flow.sctp4_flow.dst_port =
8886 rte_cpu_to_be_16(res->port_dst);
8887 entry.input.flow.sctp4_flow.src_port =
8888 rte_cpu_to_be_16(res->port_src);
8889 entry.input.flow.sctp4_flow.verify_tag =
8890 rte_cpu_to_be_32(res->verify_tag_value);
8892 case RTE_ETH_FLOW_FRAG_IPV6:
8893 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8894 entry.input.flow.ipv6_flow.proto = res->proto_value;
8896 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8897 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8898 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8899 entry.input.flow.ipv6_flow.dst_ip);
8900 IPV6_ADDR_TO_ARRAY(res->ip_src,
8901 entry.input.flow.ipv6_flow.src_ip);
8902 entry.input.flow.ipv6_flow.tc = res->tos_value;
8903 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8904 /* need convert to big endian. */
8905 entry.input.flow.udp6_flow.dst_port =
8906 rte_cpu_to_be_16(res->port_dst);
8907 entry.input.flow.udp6_flow.src_port =
8908 rte_cpu_to_be_16(res->port_src);
8910 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8911 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8912 entry.input.flow.sctp6_flow.ip.dst_ip);
8913 IPV6_ADDR_TO_ARRAY(res->ip_src,
8914 entry.input.flow.sctp6_flow.ip.src_ip);
8915 entry.input.flow.ipv6_flow.tc = res->tos_value;
8916 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8917 /* need convert to big endian. */
8918 entry.input.flow.sctp6_flow.dst_port =
8919 rte_cpu_to_be_16(res->port_dst);
8920 entry.input.flow.sctp6_flow.src_port =
8921 rte_cpu_to_be_16(res->port_src);
8922 entry.input.flow.sctp6_flow.verify_tag =
8923 rte_cpu_to_be_32(res->verify_tag_value);
8925 case RTE_ETH_FLOW_L2_PAYLOAD:
8926 entry.input.flow.l2_flow.ether_type =
8927 rte_cpu_to_be_16(res->ether_type);
8933 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8934 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8936 sizeof(struct ether_addr));
8938 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8939 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8941 sizeof(struct ether_addr));
8942 entry.input.flow.tunnel_flow.tunnel_type =
8943 str2fdir_tunneltype(res->tunnel_type);
8944 entry.input.flow.tunnel_flow.tunnel_id =
8945 rte_cpu_to_be_32(res->tunnel_id_value);
8948 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8950 RTE_ETH_FDIR_MAX_FLEXLEN);
8952 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8954 entry.action.flex_off = 0; /*use 0 by default */
8955 if (!strcmp(res->drop, "drop"))
8956 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8958 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8960 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8961 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8962 if (!strcmp(res->pf_vf, "pf"))
8963 entry.input.flow_ext.is_vf = 0;
8964 else if (!strncmp(res->pf_vf, "vf", 2)) {
8965 struct rte_eth_dev_info dev_info;
8967 memset(&dev_info, 0, sizeof(dev_info));
8968 rte_eth_dev_info_get(res->port_id, &dev_info);
8970 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8971 if (errno != 0 || *end != '\0' ||
8972 vf_id >= dev_info.max_vfs) {
8973 printf("invalid parameter %s.\n", res->pf_vf);
8976 entry.input.flow_ext.is_vf = 1;
8977 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8979 printf("invalid parameter %s.\n", res->pf_vf);
8984 /* set to report FD ID by default */
8985 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8986 entry.action.rx_queue = res->queue_id;
8987 entry.soft_id = res->fd_id_value;
8988 if (!strcmp(res->ops, "add"))
8989 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8990 RTE_ETH_FILTER_ADD, &entry);
8991 else if (!strcmp(res->ops, "del"))
8992 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8993 RTE_ETH_FILTER_DELETE, &entry);
8995 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8996 RTE_ETH_FILTER_UPDATE, &entry);
8998 printf("flow director programming error: (%s)\n",
9002 cmdline_parse_token_string_t cmd_flow_director_filter =
9003 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9004 flow_director_filter, "flow_director_filter");
9005 cmdline_parse_token_num_t cmd_flow_director_port_id =
9006 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9008 cmdline_parse_token_string_t cmd_flow_director_ops =
9009 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9010 ops, "add#del#update");
9011 cmdline_parse_token_string_t cmd_flow_director_flow =
9012 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9014 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9015 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9016 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9017 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9018 cmdline_parse_token_string_t cmd_flow_director_ether =
9019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9021 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9022 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9023 ether_type, UINT16);
9024 cmdline_parse_token_string_t cmd_flow_director_src =
9025 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9027 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9028 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9030 cmdline_parse_token_num_t cmd_flow_director_port_src =
9031 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9033 cmdline_parse_token_string_t cmd_flow_director_dst =
9034 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9036 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9037 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9039 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9040 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9042 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9043 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9044 verify_tag, "verify_tag");
9045 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9046 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9047 verify_tag_value, UINT32);
9048 cmdline_parse_token_string_t cmd_flow_director_tos =
9049 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9051 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9052 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9054 cmdline_parse_token_string_t cmd_flow_director_proto =
9055 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9057 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9058 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9059 proto_value, UINT8);
9060 cmdline_parse_token_string_t cmd_flow_director_ttl =
9061 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9063 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9064 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9066 cmdline_parse_token_string_t cmd_flow_director_vlan =
9067 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9069 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9070 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9071 vlan_value, UINT16);
9072 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9073 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9074 flexbytes, "flexbytes");
9075 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9076 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9077 flexbytes_value, NULL);
9078 cmdline_parse_token_string_t cmd_flow_director_drop =
9079 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9081 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9082 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9084 cmdline_parse_token_string_t cmd_flow_director_queue =
9085 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9087 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9088 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9090 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9091 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9093 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9094 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9095 fd_id_value, UINT32);
9097 cmdline_parse_token_string_t cmd_flow_director_mode =
9098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9100 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9101 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9103 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9104 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9105 mode_value, "MAC-VLAN");
9106 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9108 mode_value, "Tunnel");
9109 cmdline_parse_token_string_t cmd_flow_director_mac =
9110 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9112 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9113 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9115 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9116 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9118 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9119 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9120 tunnel_type, "NVGRE#VxLAN");
9121 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9122 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9123 tunnel_id, "tunnel-id");
9124 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9125 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9126 tunnel_id_value, UINT32);
9128 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9129 .f = cmd_flow_director_filter_parsed,
9131 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9132 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9133 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9134 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9135 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9136 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9137 "fd_id <fd_id_value>: "
9138 "Add or delete an ip flow director entry on NIC",
9140 (void *)&cmd_flow_director_filter,
9141 (void *)&cmd_flow_director_port_id,
9142 (void *)&cmd_flow_director_mode,
9143 (void *)&cmd_flow_director_mode_ip,
9144 (void *)&cmd_flow_director_ops,
9145 (void *)&cmd_flow_director_flow,
9146 (void *)&cmd_flow_director_flow_type,
9147 (void *)&cmd_flow_director_src,
9148 (void *)&cmd_flow_director_ip_src,
9149 (void *)&cmd_flow_director_dst,
9150 (void *)&cmd_flow_director_ip_dst,
9151 (void *)&cmd_flow_director_tos,
9152 (void *)&cmd_flow_director_tos_value,
9153 (void *)&cmd_flow_director_proto,
9154 (void *)&cmd_flow_director_proto_value,
9155 (void *)&cmd_flow_director_ttl,
9156 (void *)&cmd_flow_director_ttl_value,
9157 (void *)&cmd_flow_director_vlan,
9158 (void *)&cmd_flow_director_vlan_value,
9159 (void *)&cmd_flow_director_flexbytes,
9160 (void *)&cmd_flow_director_flexbytes_value,
9161 (void *)&cmd_flow_director_drop,
9162 (void *)&cmd_flow_director_pf_vf,
9163 (void *)&cmd_flow_director_queue,
9164 (void *)&cmd_flow_director_queue_id,
9165 (void *)&cmd_flow_director_fd_id,
9166 (void *)&cmd_flow_director_fd_id_value,
9171 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9172 .f = cmd_flow_director_filter_parsed,
9174 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9175 "director entry on NIC",
9177 (void *)&cmd_flow_director_filter,
9178 (void *)&cmd_flow_director_port_id,
9179 (void *)&cmd_flow_director_mode,
9180 (void *)&cmd_flow_director_mode_ip,
9181 (void *)&cmd_flow_director_ops,
9182 (void *)&cmd_flow_director_flow,
9183 (void *)&cmd_flow_director_flow_type,
9184 (void *)&cmd_flow_director_src,
9185 (void *)&cmd_flow_director_ip_src,
9186 (void *)&cmd_flow_director_port_src,
9187 (void *)&cmd_flow_director_dst,
9188 (void *)&cmd_flow_director_ip_dst,
9189 (void *)&cmd_flow_director_port_dst,
9190 (void *)&cmd_flow_director_tos,
9191 (void *)&cmd_flow_director_tos_value,
9192 (void *)&cmd_flow_director_ttl,
9193 (void *)&cmd_flow_director_ttl_value,
9194 (void *)&cmd_flow_director_vlan,
9195 (void *)&cmd_flow_director_vlan_value,
9196 (void *)&cmd_flow_director_flexbytes,
9197 (void *)&cmd_flow_director_flexbytes_value,
9198 (void *)&cmd_flow_director_drop,
9199 (void *)&cmd_flow_director_pf_vf,
9200 (void *)&cmd_flow_director_queue,
9201 (void *)&cmd_flow_director_queue_id,
9202 (void *)&cmd_flow_director_fd_id,
9203 (void *)&cmd_flow_director_fd_id_value,
9208 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9209 .f = cmd_flow_director_filter_parsed,
9211 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9212 "director entry on NIC",
9214 (void *)&cmd_flow_director_filter,
9215 (void *)&cmd_flow_director_port_id,
9216 (void *)&cmd_flow_director_mode,
9217 (void *)&cmd_flow_director_mode_ip,
9218 (void *)&cmd_flow_director_ops,
9219 (void *)&cmd_flow_director_flow,
9220 (void *)&cmd_flow_director_flow_type,
9221 (void *)&cmd_flow_director_src,
9222 (void *)&cmd_flow_director_ip_src,
9223 (void *)&cmd_flow_director_port_dst,
9224 (void *)&cmd_flow_director_dst,
9225 (void *)&cmd_flow_director_ip_dst,
9226 (void *)&cmd_flow_director_port_dst,
9227 (void *)&cmd_flow_director_verify_tag,
9228 (void *)&cmd_flow_director_verify_tag_value,
9229 (void *)&cmd_flow_director_tos,
9230 (void *)&cmd_flow_director_tos_value,
9231 (void *)&cmd_flow_director_ttl,
9232 (void *)&cmd_flow_director_ttl_value,
9233 (void *)&cmd_flow_director_vlan,
9234 (void *)&cmd_flow_director_vlan_value,
9235 (void *)&cmd_flow_director_flexbytes,
9236 (void *)&cmd_flow_director_flexbytes_value,
9237 (void *)&cmd_flow_director_drop,
9238 (void *)&cmd_flow_director_pf_vf,
9239 (void *)&cmd_flow_director_queue,
9240 (void *)&cmd_flow_director_queue_id,
9241 (void *)&cmd_flow_director_fd_id,
9242 (void *)&cmd_flow_director_fd_id_value,
9247 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9248 .f = cmd_flow_director_filter_parsed,
9250 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9251 "director entry on NIC",
9253 (void *)&cmd_flow_director_filter,
9254 (void *)&cmd_flow_director_port_id,
9255 (void *)&cmd_flow_director_mode,
9256 (void *)&cmd_flow_director_mode_ip,
9257 (void *)&cmd_flow_director_ops,
9258 (void *)&cmd_flow_director_flow,
9259 (void *)&cmd_flow_director_flow_type,
9260 (void *)&cmd_flow_director_ether,
9261 (void *)&cmd_flow_director_ether_type,
9262 (void *)&cmd_flow_director_flexbytes,
9263 (void *)&cmd_flow_director_flexbytes_value,
9264 (void *)&cmd_flow_director_drop,
9265 (void *)&cmd_flow_director_pf_vf,
9266 (void *)&cmd_flow_director_queue,
9267 (void *)&cmd_flow_director_queue_id,
9268 (void *)&cmd_flow_director_fd_id,
9269 (void *)&cmd_flow_director_fd_id_value,
9274 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9275 .f = cmd_flow_director_filter_parsed,
9277 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9278 "director entry on NIC",
9280 (void *)&cmd_flow_director_filter,
9281 (void *)&cmd_flow_director_port_id,
9282 (void *)&cmd_flow_director_mode,
9283 (void *)&cmd_flow_director_mode_mac_vlan,
9284 (void *)&cmd_flow_director_ops,
9285 (void *)&cmd_flow_director_mac,
9286 (void *)&cmd_flow_director_mac_addr,
9287 (void *)&cmd_flow_director_vlan,
9288 (void *)&cmd_flow_director_vlan_value,
9289 (void *)&cmd_flow_director_flexbytes,
9290 (void *)&cmd_flow_director_flexbytes_value,
9291 (void *)&cmd_flow_director_drop,
9292 (void *)&cmd_flow_director_queue,
9293 (void *)&cmd_flow_director_queue_id,
9294 (void *)&cmd_flow_director_fd_id,
9295 (void *)&cmd_flow_director_fd_id_value,
9300 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9301 .f = cmd_flow_director_filter_parsed,
9303 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9304 "director entry on NIC",
9306 (void *)&cmd_flow_director_filter,
9307 (void *)&cmd_flow_director_port_id,
9308 (void *)&cmd_flow_director_mode,
9309 (void *)&cmd_flow_director_mode_tunnel,
9310 (void *)&cmd_flow_director_ops,
9311 (void *)&cmd_flow_director_mac,
9312 (void *)&cmd_flow_director_mac_addr,
9313 (void *)&cmd_flow_director_vlan,
9314 (void *)&cmd_flow_director_vlan_value,
9315 (void *)&cmd_flow_director_tunnel,
9316 (void *)&cmd_flow_director_tunnel_type,
9317 (void *)&cmd_flow_director_tunnel_id,
9318 (void *)&cmd_flow_director_tunnel_id_value,
9319 (void *)&cmd_flow_director_flexbytes,
9320 (void *)&cmd_flow_director_flexbytes_value,
9321 (void *)&cmd_flow_director_drop,
9322 (void *)&cmd_flow_director_queue,
9323 (void *)&cmd_flow_director_queue_id,
9324 (void *)&cmd_flow_director_fd_id,
9325 (void *)&cmd_flow_director_fd_id_value,
9330 struct cmd_flush_flow_director_result {
9331 cmdline_fixed_string_t flush_flow_director;
9335 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9336 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9337 flush_flow_director, "flush_flow_director");
9338 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9339 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9343 cmd_flush_flow_director_parsed(void *parsed_result,
9344 __attribute__((unused)) struct cmdline *cl,
9345 __attribute__((unused)) void *data)
9347 struct cmd_flow_director_result *res = parsed_result;
9350 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9352 printf("flow director is not supported on port %u.\n",
9357 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9358 RTE_ETH_FILTER_FLUSH, NULL);
9360 printf("flow director table flushing error: (%s)\n",
9364 cmdline_parse_inst_t cmd_flush_flow_director = {
9365 .f = cmd_flush_flow_director_parsed,
9367 .help_str = "flush_flow_director <port_id>: "
9368 "Flush all flow director entries of a device on NIC",
9370 (void *)&cmd_flush_flow_director_flush,
9371 (void *)&cmd_flush_flow_director_port_id,
9376 /* *** deal with flow director mask *** */
9377 struct cmd_flow_director_mask_result {
9378 cmdline_fixed_string_t flow_director_mask;
9380 cmdline_fixed_string_t mode;
9381 cmdline_fixed_string_t mode_value;
9382 cmdline_fixed_string_t vlan;
9384 cmdline_fixed_string_t src_mask;
9385 cmdline_ipaddr_t ipv4_src;
9386 cmdline_ipaddr_t ipv6_src;
9388 cmdline_fixed_string_t dst_mask;
9389 cmdline_ipaddr_t ipv4_dst;
9390 cmdline_ipaddr_t ipv6_dst;
9392 cmdline_fixed_string_t mac;
9393 uint8_t mac_addr_byte_mask;
9394 cmdline_fixed_string_t tunnel_id;
9395 uint32_t tunnel_id_mask;
9396 cmdline_fixed_string_t tunnel_type;
9397 uint8_t tunnel_type_mask;
9401 cmd_flow_director_mask_parsed(void *parsed_result,
9402 __attribute__((unused)) struct cmdline *cl,
9403 __attribute__((unused)) void *data)
9405 struct cmd_flow_director_mask_result *res = parsed_result;
9406 struct rte_eth_fdir_masks *mask;
9407 struct rte_port *port;
9409 if (res->port_id > nb_ports) {
9410 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9414 port = &ports[res->port_id];
9415 /** Check if the port is not started **/
9416 if (port->port_status != RTE_PORT_STOPPED) {
9417 printf("Please stop port %d first\n", res->port_id);
9421 mask = &port->dev_conf.fdir_conf.mask;
9423 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9424 if (strcmp(res->mode_value, "MAC-VLAN")) {
9425 printf("Please set mode to MAC-VLAN.\n");
9429 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9430 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9431 if (strcmp(res->mode_value, "Tunnel")) {
9432 printf("Please set mode to Tunnel.\n");
9436 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9437 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9438 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9439 mask->tunnel_type_mask = res->tunnel_type_mask;
9441 if (strcmp(res->mode_value, "IP")) {
9442 printf("Please set mode to IP.\n");
9446 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9447 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9448 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9449 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9450 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9451 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9452 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9455 cmd_reconfig_device_queue(res->port_id, 1, 1);
9458 cmdline_parse_token_string_t cmd_flow_director_mask =
9459 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9460 flow_director_mask, "flow_director_mask");
9461 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9462 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9464 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9465 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9467 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9468 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9470 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9471 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9472 src_mask, "src_mask");
9473 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9474 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9476 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9477 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9479 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9480 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9482 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9483 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9484 dst_mask, "dst_mask");
9485 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9486 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9488 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9489 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9491 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9492 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9495 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9496 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9498 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9499 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9501 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9502 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9503 mode_value, "MAC-VLAN");
9504 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9505 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9506 mode_value, "Tunnel");
9507 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9508 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9510 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9511 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9512 mac_addr_byte_mask, UINT8);
9513 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9514 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9515 tunnel_type, "tunnel-type");
9516 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9517 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9518 tunnel_type_mask, UINT8);
9519 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9520 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9521 tunnel_id, "tunnel-id");
9522 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9523 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9524 tunnel_id_mask, UINT32);
9526 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9527 .f = cmd_flow_director_mask_parsed,
9529 .help_str = "flow_director_mask ... : "
9530 "Set IP mode flow director's mask on NIC",
9532 (void *)&cmd_flow_director_mask,
9533 (void *)&cmd_flow_director_mask_port_id,
9534 (void *)&cmd_flow_director_mask_mode,
9535 (void *)&cmd_flow_director_mask_mode_ip,
9536 (void *)&cmd_flow_director_mask_vlan,
9537 (void *)&cmd_flow_director_mask_vlan_value,
9538 (void *)&cmd_flow_director_mask_src,
9539 (void *)&cmd_flow_director_mask_ipv4_src,
9540 (void *)&cmd_flow_director_mask_ipv6_src,
9541 (void *)&cmd_flow_director_mask_port_src,
9542 (void *)&cmd_flow_director_mask_dst,
9543 (void *)&cmd_flow_director_mask_ipv4_dst,
9544 (void *)&cmd_flow_director_mask_ipv6_dst,
9545 (void *)&cmd_flow_director_mask_port_dst,
9550 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9551 .f = cmd_flow_director_mask_parsed,
9553 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9554 "flow director's mask on NIC",
9556 (void *)&cmd_flow_director_mask,
9557 (void *)&cmd_flow_director_mask_port_id,
9558 (void *)&cmd_flow_director_mask_mode,
9559 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9560 (void *)&cmd_flow_director_mask_vlan,
9561 (void *)&cmd_flow_director_mask_vlan_value,
9566 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9567 .f = cmd_flow_director_mask_parsed,
9569 .help_str = "flow_director_mask ... : Set tunnel mode "
9570 "flow director's mask on NIC",
9572 (void *)&cmd_flow_director_mask,
9573 (void *)&cmd_flow_director_mask_port_id,
9574 (void *)&cmd_flow_director_mask_mode,
9575 (void *)&cmd_flow_director_mask_mode_tunnel,
9576 (void *)&cmd_flow_director_mask_vlan,
9577 (void *)&cmd_flow_director_mask_vlan_value,
9578 (void *)&cmd_flow_director_mask_mac,
9579 (void *)&cmd_flow_director_mask_mac_value,
9580 (void *)&cmd_flow_director_mask_tunnel_type,
9581 (void *)&cmd_flow_director_mask_tunnel_type_value,
9582 (void *)&cmd_flow_director_mask_tunnel_id,
9583 (void *)&cmd_flow_director_mask_tunnel_id_value,
9588 /* *** deal with flow director mask on flexible payload *** */
9589 struct cmd_flow_director_flex_mask_result {
9590 cmdline_fixed_string_t flow_director_flexmask;
9592 cmdline_fixed_string_t flow;
9593 cmdline_fixed_string_t flow_type;
9594 cmdline_fixed_string_t mask;
9598 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9599 __attribute__((unused)) struct cmdline *cl,
9600 __attribute__((unused)) void *data)
9602 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9603 struct rte_eth_fdir_info fdir_info;
9604 struct rte_eth_fdir_flex_mask flex_mask;
9605 struct rte_port *port;
9606 uint32_t flow_type_mask;
9610 if (res->port_id > nb_ports) {
9611 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9615 port = &ports[res->port_id];
9616 /** Check if the port is not started **/
9617 if (port->port_status != RTE_PORT_STOPPED) {
9618 printf("Please stop port %d first\n", res->port_id);
9622 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9623 ret = parse_flexbytes(res->mask,
9625 RTE_ETH_FDIR_MAX_FLEXLEN);
9627 printf("error: Cannot parse mask input.\n");
9631 memset(&fdir_info, 0, sizeof(fdir_info));
9632 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9633 RTE_ETH_FILTER_INFO, &fdir_info);
9635 printf("Cannot get FDir filter info\n");
9639 if (!strcmp(res->flow_type, "none")) {
9640 /* means don't specify the flow type */
9641 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9642 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9643 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9644 0, sizeof(struct rte_eth_fdir_flex_mask));
9645 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9646 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9648 sizeof(struct rte_eth_fdir_flex_mask));
9649 cmd_reconfig_device_queue(res->port_id, 1, 1);
9652 flow_type_mask = fdir_info.flow_types_mask[0];
9653 if (!strcmp(res->flow_type, "all")) {
9654 if (!flow_type_mask) {
9655 printf("No flow type supported\n");
9658 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9659 if (flow_type_mask & (1 << i)) {
9660 flex_mask.flow_type = i;
9661 fdir_set_flex_mask(res->port_id, &flex_mask);
9664 cmd_reconfig_device_queue(res->port_id, 1, 1);
9667 flex_mask.flow_type = str2flowtype(res->flow_type);
9668 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9669 printf("Flow type %s not supported on port %d\n",
9670 res->flow_type, res->port_id);
9673 fdir_set_flex_mask(res->port_id, &flex_mask);
9674 cmd_reconfig_device_queue(res->port_id, 1, 1);
9677 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9678 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9679 flow_director_flexmask,
9680 "flow_director_flex_mask");
9681 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9682 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9684 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9687 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9689 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9690 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9691 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9692 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9695 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9696 .f = cmd_flow_director_flex_mask_parsed,
9698 .help_str = "flow_director_flex_mask ... : "
9699 "Set flow director's flex mask on NIC",
9701 (void *)&cmd_flow_director_flexmask,
9702 (void *)&cmd_flow_director_flexmask_port_id,
9703 (void *)&cmd_flow_director_flexmask_flow,
9704 (void *)&cmd_flow_director_flexmask_flow_type,
9705 (void *)&cmd_flow_director_flexmask_mask,
9710 /* *** deal with flow director flexible payload configuration *** */
9711 struct cmd_flow_director_flexpayload_result {
9712 cmdline_fixed_string_t flow_director_flexpayload;
9714 cmdline_fixed_string_t payload_layer;
9715 cmdline_fixed_string_t payload_cfg;
9719 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9722 const char *p, *p0 = q_arg;
9724 unsigned long int_fld;
9725 char *str_fld[max_num];
9730 p = strchr(p0, '(');
9734 p0 = strchr(p, ')');
9739 if (size >= sizeof(s))
9742 snprintf(s, sizeof(s), "%.*s", size, p);
9743 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9744 if (ret < 0 || ret > max_num)
9746 for (i = 0; i < ret; i++) {
9748 int_fld = strtoul(str_fld[i], &end, 0);
9749 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9751 offsets[i] = (uint16_t)int_fld;
9757 cmd_flow_director_flxpld_parsed(void *parsed_result,
9758 __attribute__((unused)) struct cmdline *cl,
9759 __attribute__((unused)) void *data)
9761 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9762 struct rte_eth_flex_payload_cfg flex_cfg;
9763 struct rte_port *port;
9766 if (res->port_id > nb_ports) {
9767 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9771 port = &ports[res->port_id];
9772 /** Check if the port is not started **/
9773 if (port->port_status != RTE_PORT_STOPPED) {
9774 printf("Please stop port %d first\n", res->port_id);
9778 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9780 if (!strcmp(res->payload_layer, "raw"))
9781 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9782 else if (!strcmp(res->payload_layer, "l2"))
9783 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9784 else if (!strcmp(res->payload_layer, "l3"))
9785 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9786 else if (!strcmp(res->payload_layer, "l4"))
9787 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9789 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9790 RTE_ETH_FDIR_MAX_FLEXLEN);
9792 printf("error: Cannot parse flex payload input.\n");
9796 fdir_set_flex_payload(res->port_id, &flex_cfg);
9797 cmd_reconfig_device_queue(res->port_id, 1, 1);
9800 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9802 flow_director_flexpayload,
9803 "flow_director_flex_payload");
9804 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9805 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9807 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9809 payload_layer, "raw#l2#l3#l4");
9810 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9811 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9814 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9815 .f = cmd_flow_director_flxpld_parsed,
9817 .help_str = "flow_director_flexpayload ... : "
9818 "Set flow director's flex payload on NIC",
9820 (void *)&cmd_flow_director_flexpayload,
9821 (void *)&cmd_flow_director_flexpayload_port_id,
9822 (void *)&cmd_flow_director_flexpayload_payload_layer,
9823 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9828 /* Generic flow interface command. */
9829 extern cmdline_parse_inst_t cmd_flow;
9831 /* *** Classification Filters Control *** */
9832 /* *** Get symmetric hash enable per port *** */
9833 struct cmd_get_sym_hash_ena_per_port_result {
9834 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9839 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9840 __rte_unused struct cmdline *cl,
9841 __rte_unused void *data)
9843 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9844 struct rte_eth_hash_filter_info info;
9847 if (rte_eth_dev_filter_supported(res->port_id,
9848 RTE_ETH_FILTER_HASH) < 0) {
9849 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9854 memset(&info, 0, sizeof(info));
9855 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9856 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9857 RTE_ETH_FILTER_GET, &info);
9860 printf("Cannot get symmetric hash enable per port "
9861 "on port %u\n", res->port_id);
9865 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9866 "enabled" : "disabled", res->port_id);
9869 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9870 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9871 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9872 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9873 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9876 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9877 .f = cmd_get_sym_hash_per_port_parsed,
9879 .help_str = "get_sym_hash_ena_per_port <port_id>",
9881 (void *)&cmd_get_sym_hash_ena_per_port_all,
9882 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9887 /* *** Set symmetric hash enable per port *** */
9888 struct cmd_set_sym_hash_ena_per_port_result {
9889 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9890 cmdline_fixed_string_t enable;
9895 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9896 __rte_unused struct cmdline *cl,
9897 __rte_unused void *data)
9899 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9900 struct rte_eth_hash_filter_info info;
9903 if (rte_eth_dev_filter_supported(res->port_id,
9904 RTE_ETH_FILTER_HASH) < 0) {
9905 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9910 memset(&info, 0, sizeof(info));
9911 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9912 if (!strcmp(res->enable, "enable"))
9913 info.info.enable = 1;
9914 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9915 RTE_ETH_FILTER_SET, &info);
9917 printf("Cannot set symmetric hash enable per port on "
9918 "port %u\n", res->port_id);
9921 printf("Symmetric hash has been set to %s on port %u\n",
9922 res->enable, res->port_id);
9925 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9926 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9927 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9928 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9929 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9931 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9932 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9933 enable, "enable#disable");
9935 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9936 .f = cmd_set_sym_hash_per_port_parsed,
9938 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9940 (void *)&cmd_set_sym_hash_ena_per_port_all,
9941 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9942 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9947 /* Get global config of hash function */
9948 struct cmd_get_hash_global_config_result {
9949 cmdline_fixed_string_t get_hash_global_config;
9954 flowtype_to_str(uint16_t ftype)
9961 {"ipv4", RTE_ETH_FLOW_IPV4},
9962 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9963 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9964 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9965 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9966 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9967 {"ipv6", RTE_ETH_FLOW_IPV6},
9968 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9969 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9970 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9971 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9972 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9973 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9974 {"port", RTE_ETH_FLOW_PORT},
9975 {"vxlan", RTE_ETH_FLOW_VXLAN},
9976 {"geneve", RTE_ETH_FLOW_GENEVE},
9977 {"nvgre", RTE_ETH_FLOW_NVGRE},
9980 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9981 if (ftype_table[i].ftype == ftype)
9982 return ftype_table[i].str;
9989 cmd_get_hash_global_config_parsed(void *parsed_result,
9990 __rte_unused struct cmdline *cl,
9991 __rte_unused void *data)
9993 struct cmd_get_hash_global_config_result *res = parsed_result;
9994 struct rte_eth_hash_filter_info info;
9995 uint32_t idx, offset;
10000 if (rte_eth_dev_filter_supported(res->port_id,
10001 RTE_ETH_FILTER_HASH) < 0) {
10002 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10007 memset(&info, 0, sizeof(info));
10008 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10009 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10010 RTE_ETH_FILTER_GET, &info);
10012 printf("Cannot get hash global configurations by port %d\n",
10017 switch (info.info.global_conf.hash_func) {
10018 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10019 printf("Hash function is Toeplitz\n");
10021 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10022 printf("Hash function is Simple XOR\n");
10025 printf("Unknown hash function\n");
10029 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10030 idx = i / UINT32_BIT;
10031 offset = i % UINT32_BIT;
10032 if (!(info.info.global_conf.valid_bit_mask[idx] &
10035 str = flowtype_to_str(i);
10038 printf("Symmetric hash is %s globally for flow type %s "
10040 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10041 (1UL << offset)) ? "enabled" : "disabled"), str,
10046 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10047 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10048 get_hash_global_config, "get_hash_global_config");
10049 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10050 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10053 cmdline_parse_inst_t cmd_get_hash_global_config = {
10054 .f = cmd_get_hash_global_config_parsed,
10056 .help_str = "get_hash_global_config <port_id>",
10058 (void *)&cmd_get_hash_global_config_all,
10059 (void *)&cmd_get_hash_global_config_port_id,
10064 /* Set global config of hash function */
10065 struct cmd_set_hash_global_config_result {
10066 cmdline_fixed_string_t set_hash_global_config;
10068 cmdline_fixed_string_t hash_func;
10069 cmdline_fixed_string_t flow_type;
10070 cmdline_fixed_string_t enable;
10074 cmd_set_hash_global_config_parsed(void *parsed_result,
10075 __rte_unused struct cmdline *cl,
10076 __rte_unused void *data)
10078 struct cmd_set_hash_global_config_result *res = parsed_result;
10079 struct rte_eth_hash_filter_info info;
10080 uint32_t ftype, idx, offset;
10083 if (rte_eth_dev_filter_supported(res->port_id,
10084 RTE_ETH_FILTER_HASH) < 0) {
10085 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10089 memset(&info, 0, sizeof(info));
10090 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10091 if (!strcmp(res->hash_func, "toeplitz"))
10092 info.info.global_conf.hash_func =
10093 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10094 else if (!strcmp(res->hash_func, "simple_xor"))
10095 info.info.global_conf.hash_func =
10096 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10097 else if (!strcmp(res->hash_func, "default"))
10098 info.info.global_conf.hash_func =
10099 RTE_ETH_HASH_FUNCTION_DEFAULT;
10101 ftype = str2flowtype(res->flow_type);
10102 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10103 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10104 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10105 if (!strcmp(res->enable, "enable"))
10106 info.info.global_conf.sym_hash_enable_mask[idx] |=
10108 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10109 RTE_ETH_FILTER_SET, &info);
10111 printf("Cannot set global hash configurations by port %d\n",
10114 printf("Global hash configurations have been set "
10115 "succcessfully by port %d\n", res->port_id);
10118 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10119 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10120 set_hash_global_config, "set_hash_global_config");
10121 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10122 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10124 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10125 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10126 hash_func, "toeplitz#simple_xor#default");
10127 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10128 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10130 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10131 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10132 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10133 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10134 enable, "enable#disable");
10136 cmdline_parse_inst_t cmd_set_hash_global_config = {
10137 .f = cmd_set_hash_global_config_parsed,
10139 .help_str = "set_hash_global_config <port_id> "
10140 "toeplitz|simple_xor|default "
10141 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10142 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10143 "l2_payload enable|disable",
10145 (void *)&cmd_set_hash_global_config_all,
10146 (void *)&cmd_set_hash_global_config_port_id,
10147 (void *)&cmd_set_hash_global_config_hash_func,
10148 (void *)&cmd_set_hash_global_config_flow_type,
10149 (void *)&cmd_set_hash_global_config_enable,
10154 /* Set hash input set */
10155 struct cmd_set_hash_input_set_result {
10156 cmdline_fixed_string_t set_hash_input_set;
10158 cmdline_fixed_string_t flow_type;
10159 cmdline_fixed_string_t inset_field;
10160 cmdline_fixed_string_t select;
10163 static enum rte_eth_input_set_field
10164 str2inset(char *string)
10168 static const struct {
10170 enum rte_eth_input_set_field inset;
10171 } inset_table[] = {
10172 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10173 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10174 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10175 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10176 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10177 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10178 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10179 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10180 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10181 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10182 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10183 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10184 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10185 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10186 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10187 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10188 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10189 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10190 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10191 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10192 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10193 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10194 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10195 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10196 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10197 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10198 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10199 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10200 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10201 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10202 {"none", RTE_ETH_INPUT_SET_NONE},
10205 for (i = 0; i < RTE_DIM(inset_table); i++) {
10206 if (!strcmp(string, inset_table[i].str))
10207 return inset_table[i].inset;
10210 return RTE_ETH_INPUT_SET_UNKNOWN;
10214 cmd_set_hash_input_set_parsed(void *parsed_result,
10215 __rte_unused struct cmdline *cl,
10216 __rte_unused void *data)
10218 struct cmd_set_hash_input_set_result *res = parsed_result;
10219 struct rte_eth_hash_filter_info info;
10221 memset(&info, 0, sizeof(info));
10222 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10223 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10224 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10225 info.info.input_set_conf.inset_size = 1;
10226 if (!strcmp(res->select, "select"))
10227 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10228 else if (!strcmp(res->select, "add"))
10229 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10230 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10231 RTE_ETH_FILTER_SET, &info);
10234 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10235 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10236 set_hash_input_set, "set_hash_input_set");
10237 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10238 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10240 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10241 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10243 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10244 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10245 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10246 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10248 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10249 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10250 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10251 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10252 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10254 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10255 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10256 select, "select#add");
10258 cmdline_parse_inst_t cmd_set_hash_input_set = {
10259 .f = cmd_set_hash_input_set_parsed,
10261 .help_str = "set_hash_input_set <port_id> "
10262 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10263 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10264 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10265 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10266 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10267 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10268 "fld-7th|fld-8th|none select|add",
10270 (void *)&cmd_set_hash_input_set_cmd,
10271 (void *)&cmd_set_hash_input_set_port_id,
10272 (void *)&cmd_set_hash_input_set_flow_type,
10273 (void *)&cmd_set_hash_input_set_field,
10274 (void *)&cmd_set_hash_input_set_select,
10279 /* Set flow director input set */
10280 struct cmd_set_fdir_input_set_result {
10281 cmdline_fixed_string_t set_fdir_input_set;
10283 cmdline_fixed_string_t flow_type;
10284 cmdline_fixed_string_t inset_field;
10285 cmdline_fixed_string_t select;
10289 cmd_set_fdir_input_set_parsed(void *parsed_result,
10290 __rte_unused struct cmdline *cl,
10291 __rte_unused void *data)
10293 struct cmd_set_fdir_input_set_result *res = parsed_result;
10294 struct rte_eth_fdir_filter_info info;
10296 memset(&info, 0, sizeof(info));
10297 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10298 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10299 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10300 info.info.input_set_conf.inset_size = 1;
10301 if (!strcmp(res->select, "select"))
10302 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10303 else if (!strcmp(res->select, "add"))
10304 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10305 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10306 RTE_ETH_FILTER_SET, &info);
10309 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10310 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10311 set_fdir_input_set, "set_fdir_input_set");
10312 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10313 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10315 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10316 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10318 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10319 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10320 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10321 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10323 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10324 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10325 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10326 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10327 "sctp-veri-tag#none");
10328 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10329 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10330 select, "select#add");
10332 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10333 .f = cmd_set_fdir_input_set_parsed,
10335 .help_str = "set_fdir_input_set <port_id> "
10336 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10337 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10338 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10339 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10340 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10341 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10342 "sctp-veri-tag|none select|add",
10344 (void *)&cmd_set_fdir_input_set_cmd,
10345 (void *)&cmd_set_fdir_input_set_port_id,
10346 (void *)&cmd_set_fdir_input_set_flow_type,
10347 (void *)&cmd_set_fdir_input_set_field,
10348 (void *)&cmd_set_fdir_input_set_select,
10353 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10354 struct cmd_mcast_addr_result {
10355 cmdline_fixed_string_t mcast_addr_cmd;
10356 cmdline_fixed_string_t what;
10358 struct ether_addr mc_addr;
10361 static void cmd_mcast_addr_parsed(void *parsed_result,
10362 __attribute__((unused)) struct cmdline *cl,
10363 __attribute__((unused)) void *data)
10365 struct cmd_mcast_addr_result *res = parsed_result;
10367 if (!is_multicast_ether_addr(&res->mc_addr)) {
10368 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10369 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10370 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10371 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10374 if (strcmp(res->what, "add") == 0)
10375 mcast_addr_add(res->port_num, &res->mc_addr);
10377 mcast_addr_remove(res->port_num, &res->mc_addr);
10380 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10381 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10382 mcast_addr_cmd, "mcast_addr");
10383 cmdline_parse_token_string_t cmd_mcast_addr_what =
10384 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10386 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10387 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10388 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10389 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10391 cmdline_parse_inst_t cmd_mcast_addr = {
10392 .f = cmd_mcast_addr_parsed,
10394 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10395 "Add/Remove multicast MAC address on port_id",
10397 (void *)&cmd_mcast_addr_cmd,
10398 (void *)&cmd_mcast_addr_what,
10399 (void *)&cmd_mcast_addr_portnum,
10400 (void *)&cmd_mcast_addr_addr,
10405 /* l2 tunnel config
10406 * only support E-tag now.
10409 /* Ether type config */
10410 struct cmd_config_l2_tunnel_eth_type_result {
10411 cmdline_fixed_string_t port;
10412 cmdline_fixed_string_t config;
10413 cmdline_fixed_string_t all;
10415 cmdline_fixed_string_t l2_tunnel;
10416 cmdline_fixed_string_t l2_tunnel_type;
10417 cmdline_fixed_string_t eth_type;
10418 uint16_t eth_type_val;
10421 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10422 TOKEN_STRING_INITIALIZER
10423 (struct cmd_config_l2_tunnel_eth_type_result,
10425 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10426 TOKEN_STRING_INITIALIZER
10427 (struct cmd_config_l2_tunnel_eth_type_result,
10429 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10430 TOKEN_STRING_INITIALIZER
10431 (struct cmd_config_l2_tunnel_eth_type_result,
10433 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10434 TOKEN_NUM_INITIALIZER
10435 (struct cmd_config_l2_tunnel_eth_type_result,
10437 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10438 TOKEN_STRING_INITIALIZER
10439 (struct cmd_config_l2_tunnel_eth_type_result,
10440 l2_tunnel, "l2-tunnel");
10441 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10442 TOKEN_STRING_INITIALIZER
10443 (struct cmd_config_l2_tunnel_eth_type_result,
10444 l2_tunnel_type, "E-tag");
10445 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10446 TOKEN_STRING_INITIALIZER
10447 (struct cmd_config_l2_tunnel_eth_type_result,
10448 eth_type, "ether-type");
10449 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10450 TOKEN_NUM_INITIALIZER
10451 (struct cmd_config_l2_tunnel_eth_type_result,
10452 eth_type_val, UINT16);
10454 static enum rte_eth_tunnel_type
10455 str2fdir_l2_tunnel_type(char *string)
10459 static const struct {
10461 enum rte_eth_tunnel_type type;
10462 } l2_tunnel_type_str[] = {
10463 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10466 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10467 if (!strcmp(l2_tunnel_type_str[i].str, string))
10468 return l2_tunnel_type_str[i].type;
10470 return RTE_TUNNEL_TYPE_NONE;
10473 /* ether type config for all ports */
10475 cmd_config_l2_tunnel_eth_type_all_parsed
10476 (void *parsed_result,
10477 __attribute__((unused)) struct cmdline *cl,
10478 __attribute__((unused)) void *data)
10480 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10481 struct rte_eth_l2_tunnel_conf entry;
10484 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10485 entry.ether_type = res->eth_type_val;
10487 RTE_ETH_FOREACH_DEV(pid) {
10488 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10492 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10493 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10495 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10497 (void *)&cmd_config_l2_tunnel_eth_type_port,
10498 (void *)&cmd_config_l2_tunnel_eth_type_config,
10499 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10500 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10501 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10502 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10503 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10508 /* ether type config for a specific port */
10510 cmd_config_l2_tunnel_eth_type_specific_parsed(
10511 void *parsed_result,
10512 __attribute__((unused)) struct cmdline *cl,
10513 __attribute__((unused)) void *data)
10515 struct cmd_config_l2_tunnel_eth_type_result *res =
10517 struct rte_eth_l2_tunnel_conf entry;
10519 if (port_id_is_invalid(res->id, ENABLED_WARN))
10522 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10523 entry.ether_type = res->eth_type_val;
10525 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10528 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10529 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10531 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10533 (void *)&cmd_config_l2_tunnel_eth_type_port,
10534 (void *)&cmd_config_l2_tunnel_eth_type_config,
10535 (void *)&cmd_config_l2_tunnel_eth_type_id,
10536 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10537 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10538 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10539 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10544 /* Enable/disable l2 tunnel */
10545 struct cmd_config_l2_tunnel_en_dis_result {
10546 cmdline_fixed_string_t port;
10547 cmdline_fixed_string_t config;
10548 cmdline_fixed_string_t all;
10550 cmdline_fixed_string_t l2_tunnel;
10551 cmdline_fixed_string_t l2_tunnel_type;
10552 cmdline_fixed_string_t en_dis;
10555 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10556 TOKEN_STRING_INITIALIZER
10557 (struct cmd_config_l2_tunnel_en_dis_result,
10559 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10560 TOKEN_STRING_INITIALIZER
10561 (struct cmd_config_l2_tunnel_en_dis_result,
10563 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10564 TOKEN_STRING_INITIALIZER
10565 (struct cmd_config_l2_tunnel_en_dis_result,
10567 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10568 TOKEN_NUM_INITIALIZER
10569 (struct cmd_config_l2_tunnel_en_dis_result,
10571 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10572 TOKEN_STRING_INITIALIZER
10573 (struct cmd_config_l2_tunnel_en_dis_result,
10574 l2_tunnel, "l2-tunnel");
10575 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10576 TOKEN_STRING_INITIALIZER
10577 (struct cmd_config_l2_tunnel_en_dis_result,
10578 l2_tunnel_type, "E-tag");
10579 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10580 TOKEN_STRING_INITIALIZER
10581 (struct cmd_config_l2_tunnel_en_dis_result,
10582 en_dis, "enable#disable");
10584 /* enable/disable l2 tunnel for all ports */
10586 cmd_config_l2_tunnel_en_dis_all_parsed(
10587 void *parsed_result,
10588 __attribute__((unused)) struct cmdline *cl,
10589 __attribute__((unused)) void *data)
10591 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10592 struct rte_eth_l2_tunnel_conf entry;
10596 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10598 if (!strcmp("enable", res->en_dis))
10603 RTE_ETH_FOREACH_DEV(pid) {
10604 rte_eth_dev_l2_tunnel_offload_set(pid,
10606 ETH_L2_TUNNEL_ENABLE_MASK,
10611 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10612 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10614 .help_str = "port config all l2-tunnel E-tag enable|disable",
10616 (void *)&cmd_config_l2_tunnel_en_dis_port,
10617 (void *)&cmd_config_l2_tunnel_en_dis_config,
10618 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10619 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10620 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10621 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10626 /* enable/disable l2 tunnel for a port */
10628 cmd_config_l2_tunnel_en_dis_specific_parsed(
10629 void *parsed_result,
10630 __attribute__((unused)) struct cmdline *cl,
10631 __attribute__((unused)) void *data)
10633 struct cmd_config_l2_tunnel_en_dis_result *res =
10635 struct rte_eth_l2_tunnel_conf entry;
10637 if (port_id_is_invalid(res->id, ENABLED_WARN))
10640 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10642 if (!strcmp("enable", res->en_dis))
10643 rte_eth_dev_l2_tunnel_offload_set(res->id,
10645 ETH_L2_TUNNEL_ENABLE_MASK,
10648 rte_eth_dev_l2_tunnel_offload_set(res->id,
10650 ETH_L2_TUNNEL_ENABLE_MASK,
10654 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10655 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10657 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10659 (void *)&cmd_config_l2_tunnel_en_dis_port,
10660 (void *)&cmd_config_l2_tunnel_en_dis_config,
10661 (void *)&cmd_config_l2_tunnel_en_dis_id,
10662 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10663 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10664 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10669 /* E-tag configuration */
10671 /* Common result structure for all E-tag configuration */
10672 struct cmd_config_e_tag_result {
10673 cmdline_fixed_string_t e_tag;
10674 cmdline_fixed_string_t set;
10675 cmdline_fixed_string_t insertion;
10676 cmdline_fixed_string_t stripping;
10677 cmdline_fixed_string_t forwarding;
10678 cmdline_fixed_string_t filter;
10679 cmdline_fixed_string_t add;
10680 cmdline_fixed_string_t del;
10681 cmdline_fixed_string_t on;
10682 cmdline_fixed_string_t off;
10683 cmdline_fixed_string_t on_off;
10684 cmdline_fixed_string_t port_tag_id;
10685 uint32_t port_tag_id_val;
10686 cmdline_fixed_string_t e_tag_id;
10687 uint16_t e_tag_id_val;
10688 cmdline_fixed_string_t dst_pool;
10689 uint8_t dst_pool_val;
10690 cmdline_fixed_string_t port;
10692 cmdline_fixed_string_t vf;
10696 /* Common CLI fields for all E-tag configuration */
10697 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10698 TOKEN_STRING_INITIALIZER
10699 (struct cmd_config_e_tag_result,
10701 cmdline_parse_token_string_t cmd_config_e_tag_set =
10702 TOKEN_STRING_INITIALIZER
10703 (struct cmd_config_e_tag_result,
10705 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10706 TOKEN_STRING_INITIALIZER
10707 (struct cmd_config_e_tag_result,
10708 insertion, "insertion");
10709 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10710 TOKEN_STRING_INITIALIZER
10711 (struct cmd_config_e_tag_result,
10712 stripping, "stripping");
10713 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10714 TOKEN_STRING_INITIALIZER
10715 (struct cmd_config_e_tag_result,
10716 forwarding, "forwarding");
10717 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10718 TOKEN_STRING_INITIALIZER
10719 (struct cmd_config_e_tag_result,
10721 cmdline_parse_token_string_t cmd_config_e_tag_add =
10722 TOKEN_STRING_INITIALIZER
10723 (struct cmd_config_e_tag_result,
10725 cmdline_parse_token_string_t cmd_config_e_tag_del =
10726 TOKEN_STRING_INITIALIZER
10727 (struct cmd_config_e_tag_result,
10729 cmdline_parse_token_string_t cmd_config_e_tag_on =
10730 TOKEN_STRING_INITIALIZER
10731 (struct cmd_config_e_tag_result,
10733 cmdline_parse_token_string_t cmd_config_e_tag_off =
10734 TOKEN_STRING_INITIALIZER
10735 (struct cmd_config_e_tag_result,
10737 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10738 TOKEN_STRING_INITIALIZER
10739 (struct cmd_config_e_tag_result,
10741 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10742 TOKEN_STRING_INITIALIZER
10743 (struct cmd_config_e_tag_result,
10744 port_tag_id, "port-tag-id");
10745 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10746 TOKEN_NUM_INITIALIZER
10747 (struct cmd_config_e_tag_result,
10748 port_tag_id_val, UINT32);
10749 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10750 TOKEN_STRING_INITIALIZER
10751 (struct cmd_config_e_tag_result,
10752 e_tag_id, "e-tag-id");
10753 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10754 TOKEN_NUM_INITIALIZER
10755 (struct cmd_config_e_tag_result,
10756 e_tag_id_val, UINT16);
10757 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10758 TOKEN_STRING_INITIALIZER
10759 (struct cmd_config_e_tag_result,
10760 dst_pool, "dst-pool");
10761 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10762 TOKEN_NUM_INITIALIZER
10763 (struct cmd_config_e_tag_result,
10764 dst_pool_val, UINT8);
10765 cmdline_parse_token_string_t cmd_config_e_tag_port =
10766 TOKEN_STRING_INITIALIZER
10767 (struct cmd_config_e_tag_result,
10769 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10770 TOKEN_NUM_INITIALIZER
10771 (struct cmd_config_e_tag_result,
10773 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10774 TOKEN_STRING_INITIALIZER
10775 (struct cmd_config_e_tag_result,
10777 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10778 TOKEN_NUM_INITIALIZER
10779 (struct cmd_config_e_tag_result,
10782 /* E-tag insertion configuration */
10784 cmd_config_e_tag_insertion_en_parsed(
10785 void *parsed_result,
10786 __attribute__((unused)) struct cmdline *cl,
10787 __attribute__((unused)) void *data)
10789 struct cmd_config_e_tag_result *res =
10791 struct rte_eth_l2_tunnel_conf entry;
10793 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10796 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10797 entry.tunnel_id = res->port_tag_id_val;
10798 entry.vf_id = res->vf_id;
10799 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10801 ETH_L2_TUNNEL_INSERTION_MASK,
10806 cmd_config_e_tag_insertion_dis_parsed(
10807 void *parsed_result,
10808 __attribute__((unused)) struct cmdline *cl,
10809 __attribute__((unused)) void *data)
10811 struct cmd_config_e_tag_result *res =
10813 struct rte_eth_l2_tunnel_conf entry;
10815 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10818 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10819 entry.vf_id = res->vf_id;
10821 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10823 ETH_L2_TUNNEL_INSERTION_MASK,
10827 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10828 .f = cmd_config_e_tag_insertion_en_parsed,
10830 .help_str = "E-tag ... : E-tag insertion enable",
10832 (void *)&cmd_config_e_tag_e_tag,
10833 (void *)&cmd_config_e_tag_set,
10834 (void *)&cmd_config_e_tag_insertion,
10835 (void *)&cmd_config_e_tag_on,
10836 (void *)&cmd_config_e_tag_port_tag_id,
10837 (void *)&cmd_config_e_tag_port_tag_id_val,
10838 (void *)&cmd_config_e_tag_port,
10839 (void *)&cmd_config_e_tag_port_id,
10840 (void *)&cmd_config_e_tag_vf,
10841 (void *)&cmd_config_e_tag_vf_id,
10846 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10847 .f = cmd_config_e_tag_insertion_dis_parsed,
10849 .help_str = "E-tag ... : E-tag insertion disable",
10851 (void *)&cmd_config_e_tag_e_tag,
10852 (void *)&cmd_config_e_tag_set,
10853 (void *)&cmd_config_e_tag_insertion,
10854 (void *)&cmd_config_e_tag_off,
10855 (void *)&cmd_config_e_tag_port,
10856 (void *)&cmd_config_e_tag_port_id,
10857 (void *)&cmd_config_e_tag_vf,
10858 (void *)&cmd_config_e_tag_vf_id,
10863 /* E-tag stripping configuration */
10865 cmd_config_e_tag_stripping_parsed(
10866 void *parsed_result,
10867 __attribute__((unused)) struct cmdline *cl,
10868 __attribute__((unused)) void *data)
10870 struct cmd_config_e_tag_result *res =
10872 struct rte_eth_l2_tunnel_conf entry;
10874 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10877 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10879 if (!strcmp(res->on_off, "on"))
10880 rte_eth_dev_l2_tunnel_offload_set
10883 ETH_L2_TUNNEL_STRIPPING_MASK,
10886 rte_eth_dev_l2_tunnel_offload_set
10889 ETH_L2_TUNNEL_STRIPPING_MASK,
10893 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10894 .f = cmd_config_e_tag_stripping_parsed,
10896 .help_str = "E-tag ... : E-tag stripping enable/disable",
10898 (void *)&cmd_config_e_tag_e_tag,
10899 (void *)&cmd_config_e_tag_set,
10900 (void *)&cmd_config_e_tag_stripping,
10901 (void *)&cmd_config_e_tag_on_off,
10902 (void *)&cmd_config_e_tag_port,
10903 (void *)&cmd_config_e_tag_port_id,
10908 /* E-tag forwarding configuration */
10910 cmd_config_e_tag_forwarding_parsed(
10911 void *parsed_result,
10912 __attribute__((unused)) struct cmdline *cl,
10913 __attribute__((unused)) void *data)
10915 struct cmd_config_e_tag_result *res = parsed_result;
10916 struct rte_eth_l2_tunnel_conf entry;
10918 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10921 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10923 if (!strcmp(res->on_off, "on"))
10924 rte_eth_dev_l2_tunnel_offload_set
10927 ETH_L2_TUNNEL_FORWARDING_MASK,
10930 rte_eth_dev_l2_tunnel_offload_set
10933 ETH_L2_TUNNEL_FORWARDING_MASK,
10937 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10938 .f = cmd_config_e_tag_forwarding_parsed,
10940 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10942 (void *)&cmd_config_e_tag_e_tag,
10943 (void *)&cmd_config_e_tag_set,
10944 (void *)&cmd_config_e_tag_forwarding,
10945 (void *)&cmd_config_e_tag_on_off,
10946 (void *)&cmd_config_e_tag_port,
10947 (void *)&cmd_config_e_tag_port_id,
10952 /* E-tag filter configuration */
10954 cmd_config_e_tag_filter_add_parsed(
10955 void *parsed_result,
10956 __attribute__((unused)) struct cmdline *cl,
10957 __attribute__((unused)) void *data)
10959 struct cmd_config_e_tag_result *res = parsed_result;
10960 struct rte_eth_l2_tunnel_conf entry;
10963 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10966 if (res->e_tag_id_val > 0x3fff) {
10967 printf("e-tag-id must be equal or less than 0x3fff.\n");
10971 ret = rte_eth_dev_filter_supported(res->port_id,
10972 RTE_ETH_FILTER_L2_TUNNEL);
10974 printf("E-tag filter is not supported on port %u.\n",
10979 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10980 entry.tunnel_id = res->e_tag_id_val;
10981 entry.pool = res->dst_pool_val;
10983 ret = rte_eth_dev_filter_ctrl(res->port_id,
10984 RTE_ETH_FILTER_L2_TUNNEL,
10985 RTE_ETH_FILTER_ADD,
10988 printf("E-tag filter programming error: (%s)\n",
10992 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10993 .f = cmd_config_e_tag_filter_add_parsed,
10995 .help_str = "E-tag ... : E-tag filter add",
10997 (void *)&cmd_config_e_tag_e_tag,
10998 (void *)&cmd_config_e_tag_set,
10999 (void *)&cmd_config_e_tag_filter,
11000 (void *)&cmd_config_e_tag_add,
11001 (void *)&cmd_config_e_tag_e_tag_id,
11002 (void *)&cmd_config_e_tag_e_tag_id_val,
11003 (void *)&cmd_config_e_tag_dst_pool,
11004 (void *)&cmd_config_e_tag_dst_pool_val,
11005 (void *)&cmd_config_e_tag_port,
11006 (void *)&cmd_config_e_tag_port_id,
11012 cmd_config_e_tag_filter_del_parsed(
11013 void *parsed_result,
11014 __attribute__((unused)) struct cmdline *cl,
11015 __attribute__((unused)) void *data)
11017 struct cmd_config_e_tag_result *res = parsed_result;
11018 struct rte_eth_l2_tunnel_conf entry;
11021 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11024 if (res->e_tag_id_val > 0x3fff) {
11025 printf("e-tag-id must be less than 0x3fff.\n");
11029 ret = rte_eth_dev_filter_supported(res->port_id,
11030 RTE_ETH_FILTER_L2_TUNNEL);
11032 printf("E-tag filter is not supported on port %u.\n",
11037 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11038 entry.tunnel_id = res->e_tag_id_val;
11040 ret = rte_eth_dev_filter_ctrl(res->port_id,
11041 RTE_ETH_FILTER_L2_TUNNEL,
11042 RTE_ETH_FILTER_DELETE,
11045 printf("E-tag filter programming error: (%s)\n",
11049 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11050 .f = cmd_config_e_tag_filter_del_parsed,
11052 .help_str = "E-tag ... : E-tag filter delete",
11054 (void *)&cmd_config_e_tag_e_tag,
11055 (void *)&cmd_config_e_tag_set,
11056 (void *)&cmd_config_e_tag_filter,
11057 (void *)&cmd_config_e_tag_del,
11058 (void *)&cmd_config_e_tag_e_tag_id,
11059 (void *)&cmd_config_e_tag_e_tag_id_val,
11060 (void *)&cmd_config_e_tag_port,
11061 (void *)&cmd_config_e_tag_port_id,
11066 /* vf vlan anti spoof configuration */
11068 /* Common result structure for vf vlan anti spoof */
11069 struct cmd_vf_vlan_anti_spoof_result {
11070 cmdline_fixed_string_t set;
11071 cmdline_fixed_string_t vf;
11072 cmdline_fixed_string_t vlan;
11073 cmdline_fixed_string_t antispoof;
11076 cmdline_fixed_string_t on_off;
11079 /* Common CLI fields for vf vlan anti spoof enable disable */
11080 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11081 TOKEN_STRING_INITIALIZER
11082 (struct cmd_vf_vlan_anti_spoof_result,
11084 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11085 TOKEN_STRING_INITIALIZER
11086 (struct cmd_vf_vlan_anti_spoof_result,
11088 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11089 TOKEN_STRING_INITIALIZER
11090 (struct cmd_vf_vlan_anti_spoof_result,
11092 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11093 TOKEN_STRING_INITIALIZER
11094 (struct cmd_vf_vlan_anti_spoof_result,
11095 antispoof, "antispoof");
11096 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11097 TOKEN_NUM_INITIALIZER
11098 (struct cmd_vf_vlan_anti_spoof_result,
11100 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11101 TOKEN_NUM_INITIALIZER
11102 (struct cmd_vf_vlan_anti_spoof_result,
11104 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11105 TOKEN_STRING_INITIALIZER
11106 (struct cmd_vf_vlan_anti_spoof_result,
11110 cmd_set_vf_vlan_anti_spoof_parsed(
11111 void *parsed_result,
11112 __attribute__((unused)) struct cmdline *cl,
11113 __attribute__((unused)) void *data)
11115 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11116 int ret = -ENOTSUP;
11118 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11120 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11123 #ifdef RTE_LIBRTE_IXGBE_PMD
11124 if (ret == -ENOTSUP)
11125 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11126 res->vf_id, is_on);
11128 #ifdef RTE_LIBRTE_I40E_PMD
11129 if (ret == -ENOTSUP)
11130 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11131 res->vf_id, is_on);
11133 #ifdef RTE_LIBRTE_BNXT_PMD
11134 if (ret == -ENOTSUP)
11135 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11136 res->vf_id, is_on);
11143 printf("invalid vf_id %d\n", res->vf_id);
11146 printf("invalid port_id %d\n", res->port_id);
11149 printf("function not implemented\n");
11152 printf("programming error: (%s)\n", strerror(-ret));
11156 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11157 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11159 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11161 (void *)&cmd_vf_vlan_anti_spoof_set,
11162 (void *)&cmd_vf_vlan_anti_spoof_vf,
11163 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11164 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11165 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11166 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11167 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11172 /* vf mac anti spoof configuration */
11174 /* Common result structure for vf mac anti spoof */
11175 struct cmd_vf_mac_anti_spoof_result {
11176 cmdline_fixed_string_t set;
11177 cmdline_fixed_string_t vf;
11178 cmdline_fixed_string_t mac;
11179 cmdline_fixed_string_t antispoof;
11182 cmdline_fixed_string_t on_off;
11185 /* Common CLI fields for vf mac anti spoof enable disable */
11186 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11187 TOKEN_STRING_INITIALIZER
11188 (struct cmd_vf_mac_anti_spoof_result,
11190 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11191 TOKEN_STRING_INITIALIZER
11192 (struct cmd_vf_mac_anti_spoof_result,
11194 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11195 TOKEN_STRING_INITIALIZER
11196 (struct cmd_vf_mac_anti_spoof_result,
11198 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11199 TOKEN_STRING_INITIALIZER
11200 (struct cmd_vf_mac_anti_spoof_result,
11201 antispoof, "antispoof");
11202 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11203 TOKEN_NUM_INITIALIZER
11204 (struct cmd_vf_mac_anti_spoof_result,
11206 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11207 TOKEN_NUM_INITIALIZER
11208 (struct cmd_vf_mac_anti_spoof_result,
11210 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11211 TOKEN_STRING_INITIALIZER
11212 (struct cmd_vf_mac_anti_spoof_result,
11216 cmd_set_vf_mac_anti_spoof_parsed(
11217 void *parsed_result,
11218 __attribute__((unused)) struct cmdline *cl,
11219 __attribute__((unused)) void *data)
11221 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11222 int ret = -ENOTSUP;
11224 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11229 #ifdef RTE_LIBRTE_IXGBE_PMD
11230 if (ret == -ENOTSUP)
11231 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11232 res->vf_id, is_on);
11234 #ifdef RTE_LIBRTE_I40E_PMD
11235 if (ret == -ENOTSUP)
11236 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11237 res->vf_id, is_on);
11239 #ifdef RTE_LIBRTE_BNXT_PMD
11240 if (ret == -ENOTSUP)
11241 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11242 res->vf_id, is_on);
11249 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11252 printf("invalid port_id %d\n", res->port_id);
11255 printf("function not implemented\n");
11258 printf("programming error: (%s)\n", strerror(-ret));
11262 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11263 .f = cmd_set_vf_mac_anti_spoof_parsed,
11265 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11267 (void *)&cmd_vf_mac_anti_spoof_set,
11268 (void *)&cmd_vf_mac_anti_spoof_vf,
11269 (void *)&cmd_vf_mac_anti_spoof_mac,
11270 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11271 (void *)&cmd_vf_mac_anti_spoof_port_id,
11272 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11273 (void *)&cmd_vf_mac_anti_spoof_on_off,
11278 /* vf vlan strip queue configuration */
11280 /* Common result structure for vf mac anti spoof */
11281 struct cmd_vf_vlan_stripq_result {
11282 cmdline_fixed_string_t set;
11283 cmdline_fixed_string_t vf;
11284 cmdline_fixed_string_t vlan;
11285 cmdline_fixed_string_t stripq;
11288 cmdline_fixed_string_t on_off;
11291 /* Common CLI fields for vf vlan strip enable disable */
11292 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11293 TOKEN_STRING_INITIALIZER
11294 (struct cmd_vf_vlan_stripq_result,
11296 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11297 TOKEN_STRING_INITIALIZER
11298 (struct cmd_vf_vlan_stripq_result,
11300 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11301 TOKEN_STRING_INITIALIZER
11302 (struct cmd_vf_vlan_stripq_result,
11304 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11305 TOKEN_STRING_INITIALIZER
11306 (struct cmd_vf_vlan_stripq_result,
11308 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11309 TOKEN_NUM_INITIALIZER
11310 (struct cmd_vf_vlan_stripq_result,
11312 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11313 TOKEN_NUM_INITIALIZER
11314 (struct cmd_vf_vlan_stripq_result,
11316 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11317 TOKEN_STRING_INITIALIZER
11318 (struct cmd_vf_vlan_stripq_result,
11322 cmd_set_vf_vlan_stripq_parsed(
11323 void *parsed_result,
11324 __attribute__((unused)) struct cmdline *cl,
11325 __attribute__((unused)) void *data)
11327 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11328 int ret = -ENOTSUP;
11330 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11332 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11335 #ifdef RTE_LIBRTE_IXGBE_PMD
11336 if (ret == -ENOTSUP)
11337 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11338 res->vf_id, is_on);
11340 #ifdef RTE_LIBRTE_I40E_PMD
11341 if (ret == -ENOTSUP)
11342 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11343 res->vf_id, is_on);
11345 #ifdef RTE_LIBRTE_BNXT_PMD
11346 if (ret == -ENOTSUP)
11347 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11348 res->vf_id, is_on);
11355 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11358 printf("invalid port_id %d\n", res->port_id);
11361 printf("function not implemented\n");
11364 printf("programming error: (%s)\n", strerror(-ret));
11368 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11369 .f = cmd_set_vf_vlan_stripq_parsed,
11371 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11373 (void *)&cmd_vf_vlan_stripq_set,
11374 (void *)&cmd_vf_vlan_stripq_vf,
11375 (void *)&cmd_vf_vlan_stripq_vlan,
11376 (void *)&cmd_vf_vlan_stripq_stripq,
11377 (void *)&cmd_vf_vlan_stripq_port_id,
11378 (void *)&cmd_vf_vlan_stripq_vf_id,
11379 (void *)&cmd_vf_vlan_stripq_on_off,
11384 /* vf vlan insert configuration */
11386 /* Common result structure for vf vlan insert */
11387 struct cmd_vf_vlan_insert_result {
11388 cmdline_fixed_string_t set;
11389 cmdline_fixed_string_t vf;
11390 cmdline_fixed_string_t vlan;
11391 cmdline_fixed_string_t insert;
11397 /* Common CLI fields for vf vlan insert enable disable */
11398 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11399 TOKEN_STRING_INITIALIZER
11400 (struct cmd_vf_vlan_insert_result,
11402 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11403 TOKEN_STRING_INITIALIZER
11404 (struct cmd_vf_vlan_insert_result,
11406 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11407 TOKEN_STRING_INITIALIZER
11408 (struct cmd_vf_vlan_insert_result,
11410 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11411 TOKEN_STRING_INITIALIZER
11412 (struct cmd_vf_vlan_insert_result,
11414 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11415 TOKEN_NUM_INITIALIZER
11416 (struct cmd_vf_vlan_insert_result,
11418 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11419 TOKEN_NUM_INITIALIZER
11420 (struct cmd_vf_vlan_insert_result,
11422 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11423 TOKEN_NUM_INITIALIZER
11424 (struct cmd_vf_vlan_insert_result,
11428 cmd_set_vf_vlan_insert_parsed(
11429 void *parsed_result,
11430 __attribute__((unused)) struct cmdline *cl,
11431 __attribute__((unused)) void *data)
11433 struct cmd_vf_vlan_insert_result *res = parsed_result;
11434 int ret = -ENOTSUP;
11436 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11439 #ifdef RTE_LIBRTE_IXGBE_PMD
11440 if (ret == -ENOTSUP)
11441 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11444 #ifdef RTE_LIBRTE_I40E_PMD
11445 if (ret == -ENOTSUP)
11446 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11449 #ifdef RTE_LIBRTE_BNXT_PMD
11450 if (ret == -ENOTSUP)
11451 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11459 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11462 printf("invalid port_id %d\n", res->port_id);
11465 printf("function not implemented\n");
11468 printf("programming error: (%s)\n", strerror(-ret));
11472 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11473 .f = cmd_set_vf_vlan_insert_parsed,
11475 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11477 (void *)&cmd_vf_vlan_insert_set,
11478 (void *)&cmd_vf_vlan_insert_vf,
11479 (void *)&cmd_vf_vlan_insert_vlan,
11480 (void *)&cmd_vf_vlan_insert_insert,
11481 (void *)&cmd_vf_vlan_insert_port_id,
11482 (void *)&cmd_vf_vlan_insert_vf_id,
11483 (void *)&cmd_vf_vlan_insert_vlan_id,
11488 /* tx loopback configuration */
11490 /* Common result structure for tx loopback */
11491 struct cmd_tx_loopback_result {
11492 cmdline_fixed_string_t set;
11493 cmdline_fixed_string_t tx;
11494 cmdline_fixed_string_t loopback;
11496 cmdline_fixed_string_t on_off;
11499 /* Common CLI fields for tx loopback enable disable */
11500 cmdline_parse_token_string_t cmd_tx_loopback_set =
11501 TOKEN_STRING_INITIALIZER
11502 (struct cmd_tx_loopback_result,
11504 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11505 TOKEN_STRING_INITIALIZER
11506 (struct cmd_tx_loopback_result,
11508 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11509 TOKEN_STRING_INITIALIZER
11510 (struct cmd_tx_loopback_result,
11511 loopback, "loopback");
11512 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11513 TOKEN_NUM_INITIALIZER
11514 (struct cmd_tx_loopback_result,
11516 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11517 TOKEN_STRING_INITIALIZER
11518 (struct cmd_tx_loopback_result,
11522 cmd_set_tx_loopback_parsed(
11523 void *parsed_result,
11524 __attribute__((unused)) struct cmdline *cl,
11525 __attribute__((unused)) void *data)
11527 struct cmd_tx_loopback_result *res = parsed_result;
11528 int ret = -ENOTSUP;
11530 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11532 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11535 #ifdef RTE_LIBRTE_IXGBE_PMD
11536 if (ret == -ENOTSUP)
11537 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11539 #ifdef RTE_LIBRTE_I40E_PMD
11540 if (ret == -ENOTSUP)
11541 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11543 #ifdef RTE_LIBRTE_BNXT_PMD
11544 if (ret == -ENOTSUP)
11545 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11552 printf("invalid is_on %d\n", is_on);
11555 printf("invalid port_id %d\n", res->port_id);
11558 printf("function not implemented\n");
11561 printf("programming error: (%s)\n", strerror(-ret));
11565 cmdline_parse_inst_t cmd_set_tx_loopback = {
11566 .f = cmd_set_tx_loopback_parsed,
11568 .help_str = "set tx loopback <port_id> on|off",
11570 (void *)&cmd_tx_loopback_set,
11571 (void *)&cmd_tx_loopback_tx,
11572 (void *)&cmd_tx_loopback_loopback,
11573 (void *)&cmd_tx_loopback_port_id,
11574 (void *)&cmd_tx_loopback_on_off,
11579 /* all queues drop enable configuration */
11581 /* Common result structure for all queues drop enable */
11582 struct cmd_all_queues_drop_en_result {
11583 cmdline_fixed_string_t set;
11584 cmdline_fixed_string_t all;
11585 cmdline_fixed_string_t queues;
11586 cmdline_fixed_string_t drop;
11588 cmdline_fixed_string_t on_off;
11591 /* Common CLI fields for tx loopback enable disable */
11592 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11593 TOKEN_STRING_INITIALIZER
11594 (struct cmd_all_queues_drop_en_result,
11596 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11597 TOKEN_STRING_INITIALIZER
11598 (struct cmd_all_queues_drop_en_result,
11600 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11601 TOKEN_STRING_INITIALIZER
11602 (struct cmd_all_queues_drop_en_result,
11604 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11605 TOKEN_STRING_INITIALIZER
11606 (struct cmd_all_queues_drop_en_result,
11608 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11609 TOKEN_NUM_INITIALIZER
11610 (struct cmd_all_queues_drop_en_result,
11612 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11613 TOKEN_STRING_INITIALIZER
11614 (struct cmd_all_queues_drop_en_result,
11618 cmd_set_all_queues_drop_en_parsed(
11619 void *parsed_result,
11620 __attribute__((unused)) struct cmdline *cl,
11621 __attribute__((unused)) void *data)
11623 struct cmd_all_queues_drop_en_result *res = parsed_result;
11624 int ret = -ENOTSUP;
11625 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11630 #ifdef RTE_LIBRTE_IXGBE_PMD
11631 if (ret == -ENOTSUP)
11632 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11634 #ifdef RTE_LIBRTE_BNXT_PMD
11635 if (ret == -ENOTSUP)
11636 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11642 printf("invalid is_on %d\n", is_on);
11645 printf("invalid port_id %d\n", res->port_id);
11648 printf("function not implemented\n");
11651 printf("programming error: (%s)\n", strerror(-ret));
11655 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11656 .f = cmd_set_all_queues_drop_en_parsed,
11658 .help_str = "set all queues drop <port_id> on|off",
11660 (void *)&cmd_all_queues_drop_en_set,
11661 (void *)&cmd_all_queues_drop_en_all,
11662 (void *)&cmd_all_queues_drop_en_queues,
11663 (void *)&cmd_all_queues_drop_en_drop,
11664 (void *)&cmd_all_queues_drop_en_port_id,
11665 (void *)&cmd_all_queues_drop_en_on_off,
11670 /* vf split drop enable configuration */
11672 /* Common result structure for vf split drop enable */
11673 struct cmd_vf_split_drop_en_result {
11674 cmdline_fixed_string_t set;
11675 cmdline_fixed_string_t vf;
11676 cmdline_fixed_string_t split;
11677 cmdline_fixed_string_t drop;
11680 cmdline_fixed_string_t on_off;
11683 /* Common CLI fields for vf split drop enable disable */
11684 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11685 TOKEN_STRING_INITIALIZER
11686 (struct cmd_vf_split_drop_en_result,
11688 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11689 TOKEN_STRING_INITIALIZER
11690 (struct cmd_vf_split_drop_en_result,
11692 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11693 TOKEN_STRING_INITIALIZER
11694 (struct cmd_vf_split_drop_en_result,
11696 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11697 TOKEN_STRING_INITIALIZER
11698 (struct cmd_vf_split_drop_en_result,
11700 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11701 TOKEN_NUM_INITIALIZER
11702 (struct cmd_vf_split_drop_en_result,
11704 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11705 TOKEN_NUM_INITIALIZER
11706 (struct cmd_vf_split_drop_en_result,
11708 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11709 TOKEN_STRING_INITIALIZER
11710 (struct cmd_vf_split_drop_en_result,
11714 cmd_set_vf_split_drop_en_parsed(
11715 void *parsed_result,
11716 __attribute__((unused)) struct cmdline *cl,
11717 __attribute__((unused)) void *data)
11719 struct cmd_vf_split_drop_en_result *res = parsed_result;
11720 int ret = -ENOTSUP;
11721 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11723 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11726 #ifdef RTE_LIBRTE_IXGBE_PMD
11727 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11734 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11737 printf("invalid port_id %d\n", res->port_id);
11740 printf("not supported on port %d\n", res->port_id);
11743 printf("programming error: (%s)\n", strerror(-ret));
11747 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11748 .f = cmd_set_vf_split_drop_en_parsed,
11750 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11752 (void *)&cmd_vf_split_drop_en_set,
11753 (void *)&cmd_vf_split_drop_en_vf,
11754 (void *)&cmd_vf_split_drop_en_split,
11755 (void *)&cmd_vf_split_drop_en_drop,
11756 (void *)&cmd_vf_split_drop_en_port_id,
11757 (void *)&cmd_vf_split_drop_en_vf_id,
11758 (void *)&cmd_vf_split_drop_en_on_off,
11763 /* vf mac address configuration */
11765 /* Common result structure for vf mac address */
11766 struct cmd_set_vf_mac_addr_result {
11767 cmdline_fixed_string_t set;
11768 cmdline_fixed_string_t vf;
11769 cmdline_fixed_string_t mac;
11770 cmdline_fixed_string_t addr;
11773 struct ether_addr mac_addr;
11777 /* Common CLI fields for vf split drop enable disable */
11778 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11779 TOKEN_STRING_INITIALIZER
11780 (struct cmd_set_vf_mac_addr_result,
11782 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11783 TOKEN_STRING_INITIALIZER
11784 (struct cmd_set_vf_mac_addr_result,
11786 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11787 TOKEN_STRING_INITIALIZER
11788 (struct cmd_set_vf_mac_addr_result,
11790 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11791 TOKEN_STRING_INITIALIZER
11792 (struct cmd_set_vf_mac_addr_result,
11794 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11795 TOKEN_NUM_INITIALIZER
11796 (struct cmd_set_vf_mac_addr_result,
11798 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11799 TOKEN_NUM_INITIALIZER
11800 (struct cmd_set_vf_mac_addr_result,
11802 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11803 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11807 cmd_set_vf_mac_addr_parsed(
11808 void *parsed_result,
11809 __attribute__((unused)) struct cmdline *cl,
11810 __attribute__((unused)) void *data)
11812 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11813 int ret = -ENOTSUP;
11815 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11818 #ifdef RTE_LIBRTE_IXGBE_PMD
11819 if (ret == -ENOTSUP)
11820 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11823 #ifdef RTE_LIBRTE_I40E_PMD
11824 if (ret == -ENOTSUP)
11825 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11828 #ifdef RTE_LIBRTE_BNXT_PMD
11829 if (ret == -ENOTSUP)
11830 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11838 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11841 printf("invalid port_id %d\n", res->port_id);
11844 printf("function not implemented\n");
11847 printf("programming error: (%s)\n", strerror(-ret));
11851 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11852 .f = cmd_set_vf_mac_addr_parsed,
11854 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11856 (void *)&cmd_set_vf_mac_addr_set,
11857 (void *)&cmd_set_vf_mac_addr_vf,
11858 (void *)&cmd_set_vf_mac_addr_mac,
11859 (void *)&cmd_set_vf_mac_addr_addr,
11860 (void *)&cmd_set_vf_mac_addr_port_id,
11861 (void *)&cmd_set_vf_mac_addr_vf_id,
11862 (void *)&cmd_set_vf_mac_addr_mac_addr,
11867 /* MACsec configuration */
11869 /* Common result structure for MACsec offload enable */
11870 struct cmd_macsec_offload_on_result {
11871 cmdline_fixed_string_t set;
11872 cmdline_fixed_string_t macsec;
11873 cmdline_fixed_string_t offload;
11875 cmdline_fixed_string_t on;
11876 cmdline_fixed_string_t encrypt;
11877 cmdline_fixed_string_t en_on_off;
11878 cmdline_fixed_string_t replay_protect;
11879 cmdline_fixed_string_t rp_on_off;
11882 /* Common CLI fields for MACsec offload disable */
11883 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11884 TOKEN_STRING_INITIALIZER
11885 (struct cmd_macsec_offload_on_result,
11887 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11888 TOKEN_STRING_INITIALIZER
11889 (struct cmd_macsec_offload_on_result,
11891 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11892 TOKEN_STRING_INITIALIZER
11893 (struct cmd_macsec_offload_on_result,
11894 offload, "offload");
11895 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11896 TOKEN_NUM_INITIALIZER
11897 (struct cmd_macsec_offload_on_result,
11899 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11900 TOKEN_STRING_INITIALIZER
11901 (struct cmd_macsec_offload_on_result,
11903 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11904 TOKEN_STRING_INITIALIZER
11905 (struct cmd_macsec_offload_on_result,
11906 encrypt, "encrypt");
11907 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11908 TOKEN_STRING_INITIALIZER
11909 (struct cmd_macsec_offload_on_result,
11910 en_on_off, "on#off");
11911 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11912 TOKEN_STRING_INITIALIZER
11913 (struct cmd_macsec_offload_on_result,
11914 replay_protect, "replay-protect");
11915 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11916 TOKEN_STRING_INITIALIZER
11917 (struct cmd_macsec_offload_on_result,
11918 rp_on_off, "on#off");
11921 cmd_set_macsec_offload_on_parsed(
11922 void *parsed_result,
11923 __attribute__((unused)) struct cmdline *cl,
11924 __attribute__((unused)) void *data)
11926 struct cmd_macsec_offload_on_result *res = parsed_result;
11927 int ret = -ENOTSUP;
11928 portid_t port_id = res->port_id;
11929 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11930 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11932 if (port_id_is_invalid(port_id, ENABLED_WARN))
11935 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11936 #ifdef RTE_LIBRTE_IXGBE_PMD
11937 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11946 printf("invalid port_id %d\n", port_id);
11949 printf("not supported on port %d\n", port_id);
11952 printf("programming error: (%s)\n", strerror(-ret));
11956 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11957 .f = cmd_set_macsec_offload_on_parsed,
11959 .help_str = "set macsec offload <port_id> on "
11960 "encrypt on|off replay-protect on|off",
11962 (void *)&cmd_macsec_offload_on_set,
11963 (void *)&cmd_macsec_offload_on_macsec,
11964 (void *)&cmd_macsec_offload_on_offload,
11965 (void *)&cmd_macsec_offload_on_port_id,
11966 (void *)&cmd_macsec_offload_on_on,
11967 (void *)&cmd_macsec_offload_on_encrypt,
11968 (void *)&cmd_macsec_offload_on_en_on_off,
11969 (void *)&cmd_macsec_offload_on_replay_protect,
11970 (void *)&cmd_macsec_offload_on_rp_on_off,
11975 /* Common result structure for MACsec offload disable */
11976 struct cmd_macsec_offload_off_result {
11977 cmdline_fixed_string_t set;
11978 cmdline_fixed_string_t macsec;
11979 cmdline_fixed_string_t offload;
11981 cmdline_fixed_string_t off;
11984 /* Common CLI fields for MACsec offload disable */
11985 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11986 TOKEN_STRING_INITIALIZER
11987 (struct cmd_macsec_offload_off_result,
11989 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11990 TOKEN_STRING_INITIALIZER
11991 (struct cmd_macsec_offload_off_result,
11993 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11994 TOKEN_STRING_INITIALIZER
11995 (struct cmd_macsec_offload_off_result,
11996 offload, "offload");
11997 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11998 TOKEN_NUM_INITIALIZER
11999 (struct cmd_macsec_offload_off_result,
12001 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12002 TOKEN_STRING_INITIALIZER
12003 (struct cmd_macsec_offload_off_result,
12007 cmd_set_macsec_offload_off_parsed(
12008 void *parsed_result,
12009 __attribute__((unused)) struct cmdline *cl,
12010 __attribute__((unused)) void *data)
12012 struct cmd_macsec_offload_off_result *res = parsed_result;
12013 int ret = -ENOTSUP;
12014 portid_t port_id = res->port_id;
12016 if (port_id_is_invalid(port_id, ENABLED_WARN))
12019 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12020 #ifdef RTE_LIBRTE_IXGBE_PMD
12021 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12028 printf("invalid port_id %d\n", port_id);
12031 printf("not supported on port %d\n", port_id);
12034 printf("programming error: (%s)\n", strerror(-ret));
12038 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12039 .f = cmd_set_macsec_offload_off_parsed,
12041 .help_str = "set macsec offload <port_id> off",
12043 (void *)&cmd_macsec_offload_off_set,
12044 (void *)&cmd_macsec_offload_off_macsec,
12045 (void *)&cmd_macsec_offload_off_offload,
12046 (void *)&cmd_macsec_offload_off_port_id,
12047 (void *)&cmd_macsec_offload_off_off,
12052 /* Common result structure for MACsec secure connection configure */
12053 struct cmd_macsec_sc_result {
12054 cmdline_fixed_string_t set;
12055 cmdline_fixed_string_t macsec;
12056 cmdline_fixed_string_t sc;
12057 cmdline_fixed_string_t tx_rx;
12059 struct ether_addr mac;
12063 /* Common CLI fields for MACsec secure connection configure */
12064 cmdline_parse_token_string_t cmd_macsec_sc_set =
12065 TOKEN_STRING_INITIALIZER
12066 (struct cmd_macsec_sc_result,
12068 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12069 TOKEN_STRING_INITIALIZER
12070 (struct cmd_macsec_sc_result,
12072 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12073 TOKEN_STRING_INITIALIZER
12074 (struct cmd_macsec_sc_result,
12076 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12077 TOKEN_STRING_INITIALIZER
12078 (struct cmd_macsec_sc_result,
12080 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12081 TOKEN_NUM_INITIALIZER
12082 (struct cmd_macsec_sc_result,
12084 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12085 TOKEN_ETHERADDR_INITIALIZER
12086 (struct cmd_macsec_sc_result,
12088 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12089 TOKEN_NUM_INITIALIZER
12090 (struct cmd_macsec_sc_result,
12094 cmd_set_macsec_sc_parsed(
12095 void *parsed_result,
12096 __attribute__((unused)) struct cmdline *cl,
12097 __attribute__((unused)) void *data)
12099 struct cmd_macsec_sc_result *res = parsed_result;
12100 int ret = -ENOTSUP;
12101 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12103 #ifdef RTE_LIBRTE_IXGBE_PMD
12105 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12106 res->mac.addr_bytes) :
12107 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12108 res->mac.addr_bytes, res->pi);
12110 RTE_SET_USED(is_tx);
12116 printf("invalid port_id %d\n", res->port_id);
12119 printf("not supported on port %d\n", res->port_id);
12122 printf("programming error: (%s)\n", strerror(-ret));
12126 cmdline_parse_inst_t cmd_set_macsec_sc = {
12127 .f = cmd_set_macsec_sc_parsed,
12129 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12131 (void *)&cmd_macsec_sc_set,
12132 (void *)&cmd_macsec_sc_macsec,
12133 (void *)&cmd_macsec_sc_sc,
12134 (void *)&cmd_macsec_sc_tx_rx,
12135 (void *)&cmd_macsec_sc_port_id,
12136 (void *)&cmd_macsec_sc_mac,
12137 (void *)&cmd_macsec_sc_pi,
12142 /* Common result structure for MACsec secure connection configure */
12143 struct cmd_macsec_sa_result {
12144 cmdline_fixed_string_t set;
12145 cmdline_fixed_string_t macsec;
12146 cmdline_fixed_string_t sa;
12147 cmdline_fixed_string_t tx_rx;
12152 cmdline_fixed_string_t key;
12155 /* Common CLI fields for MACsec secure connection configure */
12156 cmdline_parse_token_string_t cmd_macsec_sa_set =
12157 TOKEN_STRING_INITIALIZER
12158 (struct cmd_macsec_sa_result,
12160 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12161 TOKEN_STRING_INITIALIZER
12162 (struct cmd_macsec_sa_result,
12164 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12165 TOKEN_STRING_INITIALIZER
12166 (struct cmd_macsec_sa_result,
12168 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12169 TOKEN_STRING_INITIALIZER
12170 (struct cmd_macsec_sa_result,
12172 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12173 TOKEN_NUM_INITIALIZER
12174 (struct cmd_macsec_sa_result,
12176 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12177 TOKEN_NUM_INITIALIZER
12178 (struct cmd_macsec_sa_result,
12180 cmdline_parse_token_num_t cmd_macsec_sa_an =
12181 TOKEN_NUM_INITIALIZER
12182 (struct cmd_macsec_sa_result,
12184 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12185 TOKEN_NUM_INITIALIZER
12186 (struct cmd_macsec_sa_result,
12188 cmdline_parse_token_string_t cmd_macsec_sa_key =
12189 TOKEN_STRING_INITIALIZER
12190 (struct cmd_macsec_sa_result,
12194 cmd_set_macsec_sa_parsed(
12195 void *parsed_result,
12196 __attribute__((unused)) struct cmdline *cl,
12197 __attribute__((unused)) void *data)
12199 struct cmd_macsec_sa_result *res = parsed_result;
12200 int ret = -ENOTSUP;
12201 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12202 uint8_t key[16] = { 0 };
12208 key_len = strlen(res->key) / 2;
12212 for (i = 0; i < key_len; i++) {
12213 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12216 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12219 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12222 #ifdef RTE_LIBRTE_IXGBE_PMD
12224 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12225 res->idx, res->an, res->pn, key) :
12226 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12227 res->idx, res->an, res->pn, key);
12229 RTE_SET_USED(is_tx);
12236 printf("invalid idx %d or an %d\n", res->idx, res->an);
12239 printf("invalid port_id %d\n", res->port_id);
12242 printf("not supported on port %d\n", res->port_id);
12245 printf("programming error: (%s)\n", strerror(-ret));
12249 cmdline_parse_inst_t cmd_set_macsec_sa = {
12250 .f = cmd_set_macsec_sa_parsed,
12252 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12254 (void *)&cmd_macsec_sa_set,
12255 (void *)&cmd_macsec_sa_macsec,
12256 (void *)&cmd_macsec_sa_sa,
12257 (void *)&cmd_macsec_sa_tx_rx,
12258 (void *)&cmd_macsec_sa_port_id,
12259 (void *)&cmd_macsec_sa_idx,
12260 (void *)&cmd_macsec_sa_an,
12261 (void *)&cmd_macsec_sa_pn,
12262 (void *)&cmd_macsec_sa_key,
12267 /* VF unicast promiscuous mode configuration */
12269 /* Common result structure for VF unicast promiscuous mode */
12270 struct cmd_vf_promisc_result {
12271 cmdline_fixed_string_t set;
12272 cmdline_fixed_string_t vf;
12273 cmdline_fixed_string_t promisc;
12276 cmdline_fixed_string_t on_off;
12279 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12280 cmdline_parse_token_string_t cmd_vf_promisc_set =
12281 TOKEN_STRING_INITIALIZER
12282 (struct cmd_vf_promisc_result,
12284 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12285 TOKEN_STRING_INITIALIZER
12286 (struct cmd_vf_promisc_result,
12288 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12289 TOKEN_STRING_INITIALIZER
12290 (struct cmd_vf_promisc_result,
12291 promisc, "promisc");
12292 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12293 TOKEN_NUM_INITIALIZER
12294 (struct cmd_vf_promisc_result,
12296 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12297 TOKEN_NUM_INITIALIZER
12298 (struct cmd_vf_promisc_result,
12300 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12301 TOKEN_STRING_INITIALIZER
12302 (struct cmd_vf_promisc_result,
12306 cmd_set_vf_promisc_parsed(
12307 void *parsed_result,
12308 __attribute__((unused)) struct cmdline *cl,
12309 __attribute__((unused)) void *data)
12311 struct cmd_vf_promisc_result *res = parsed_result;
12312 int ret = -ENOTSUP;
12314 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12316 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12319 #ifdef RTE_LIBRTE_I40E_PMD
12320 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12321 res->vf_id, is_on);
12328 printf("invalid vf_id %d\n", res->vf_id);
12331 printf("invalid port_id %d\n", res->port_id);
12334 printf("function not implemented\n");
12337 printf("programming error: (%s)\n", strerror(-ret));
12341 cmdline_parse_inst_t cmd_set_vf_promisc = {
12342 .f = cmd_set_vf_promisc_parsed,
12344 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12345 "Set unicast promiscuous mode for a VF from the PF",
12347 (void *)&cmd_vf_promisc_set,
12348 (void *)&cmd_vf_promisc_vf,
12349 (void *)&cmd_vf_promisc_promisc,
12350 (void *)&cmd_vf_promisc_port_id,
12351 (void *)&cmd_vf_promisc_vf_id,
12352 (void *)&cmd_vf_promisc_on_off,
12357 /* VF multicast promiscuous mode configuration */
12359 /* Common result structure for VF multicast promiscuous mode */
12360 struct cmd_vf_allmulti_result {
12361 cmdline_fixed_string_t set;
12362 cmdline_fixed_string_t vf;
12363 cmdline_fixed_string_t allmulti;
12366 cmdline_fixed_string_t on_off;
12369 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12370 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12371 TOKEN_STRING_INITIALIZER
12372 (struct cmd_vf_allmulti_result,
12374 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12375 TOKEN_STRING_INITIALIZER
12376 (struct cmd_vf_allmulti_result,
12378 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_vf_allmulti_result,
12381 allmulti, "allmulti");
12382 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12383 TOKEN_NUM_INITIALIZER
12384 (struct cmd_vf_allmulti_result,
12386 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12387 TOKEN_NUM_INITIALIZER
12388 (struct cmd_vf_allmulti_result,
12390 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12391 TOKEN_STRING_INITIALIZER
12392 (struct cmd_vf_allmulti_result,
12396 cmd_set_vf_allmulti_parsed(
12397 void *parsed_result,
12398 __attribute__((unused)) struct cmdline *cl,
12399 __attribute__((unused)) void *data)
12401 struct cmd_vf_allmulti_result *res = parsed_result;
12402 int ret = -ENOTSUP;
12404 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12406 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12409 #ifdef RTE_LIBRTE_I40E_PMD
12410 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12411 res->vf_id, is_on);
12418 printf("invalid vf_id %d\n", res->vf_id);
12421 printf("invalid port_id %d\n", res->port_id);
12424 printf("function not implemented\n");
12427 printf("programming error: (%s)\n", strerror(-ret));
12431 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12432 .f = cmd_set_vf_allmulti_parsed,
12434 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12435 "Set multicast promiscuous mode for a VF from the PF",
12437 (void *)&cmd_vf_allmulti_set,
12438 (void *)&cmd_vf_allmulti_vf,
12439 (void *)&cmd_vf_allmulti_allmulti,
12440 (void *)&cmd_vf_allmulti_port_id,
12441 (void *)&cmd_vf_allmulti_vf_id,
12442 (void *)&cmd_vf_allmulti_on_off,
12447 /* vf broadcast mode configuration */
12449 /* Common result structure for vf broadcast */
12450 struct cmd_set_vf_broadcast_result {
12451 cmdline_fixed_string_t set;
12452 cmdline_fixed_string_t vf;
12453 cmdline_fixed_string_t broadcast;
12456 cmdline_fixed_string_t on_off;
12459 /* Common CLI fields for vf broadcast enable disable */
12460 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12461 TOKEN_STRING_INITIALIZER
12462 (struct cmd_set_vf_broadcast_result,
12464 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_set_vf_broadcast_result,
12468 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_set_vf_broadcast_result,
12471 broadcast, "broadcast");
12472 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12473 TOKEN_NUM_INITIALIZER
12474 (struct cmd_set_vf_broadcast_result,
12476 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12477 TOKEN_NUM_INITIALIZER
12478 (struct cmd_set_vf_broadcast_result,
12480 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12481 TOKEN_STRING_INITIALIZER
12482 (struct cmd_set_vf_broadcast_result,
12486 cmd_set_vf_broadcast_parsed(
12487 void *parsed_result,
12488 __attribute__((unused)) struct cmdline *cl,
12489 __attribute__((unused)) void *data)
12491 struct cmd_set_vf_broadcast_result *res = parsed_result;
12492 int ret = -ENOTSUP;
12494 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12496 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12499 #ifdef RTE_LIBRTE_I40E_PMD
12500 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12501 res->vf_id, is_on);
12508 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12511 printf("invalid port_id %d\n", res->port_id);
12514 printf("function not implemented\n");
12517 printf("programming error: (%s)\n", strerror(-ret));
12521 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12522 .f = cmd_set_vf_broadcast_parsed,
12524 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12526 (void *)&cmd_set_vf_broadcast_set,
12527 (void *)&cmd_set_vf_broadcast_vf,
12528 (void *)&cmd_set_vf_broadcast_broadcast,
12529 (void *)&cmd_set_vf_broadcast_port_id,
12530 (void *)&cmd_set_vf_broadcast_vf_id,
12531 (void *)&cmd_set_vf_broadcast_on_off,
12536 /* vf vlan tag configuration */
12538 /* Common result structure for vf vlan tag */
12539 struct cmd_set_vf_vlan_tag_result {
12540 cmdline_fixed_string_t set;
12541 cmdline_fixed_string_t vf;
12542 cmdline_fixed_string_t vlan;
12543 cmdline_fixed_string_t tag;
12546 cmdline_fixed_string_t on_off;
12549 /* Common CLI fields for vf vlan tag enable disable */
12550 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12551 TOKEN_STRING_INITIALIZER
12552 (struct cmd_set_vf_vlan_tag_result,
12554 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12555 TOKEN_STRING_INITIALIZER
12556 (struct cmd_set_vf_vlan_tag_result,
12558 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12559 TOKEN_STRING_INITIALIZER
12560 (struct cmd_set_vf_vlan_tag_result,
12562 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12563 TOKEN_STRING_INITIALIZER
12564 (struct cmd_set_vf_vlan_tag_result,
12566 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12567 TOKEN_NUM_INITIALIZER
12568 (struct cmd_set_vf_vlan_tag_result,
12570 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12571 TOKEN_NUM_INITIALIZER
12572 (struct cmd_set_vf_vlan_tag_result,
12574 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12575 TOKEN_STRING_INITIALIZER
12576 (struct cmd_set_vf_vlan_tag_result,
12580 cmd_set_vf_vlan_tag_parsed(
12581 void *parsed_result,
12582 __attribute__((unused)) struct cmdline *cl,
12583 __attribute__((unused)) void *data)
12585 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12586 int ret = -ENOTSUP;
12588 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12590 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12593 #ifdef RTE_LIBRTE_I40E_PMD
12594 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12595 res->vf_id, is_on);
12602 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12605 printf("invalid port_id %d\n", res->port_id);
12608 printf("function not implemented\n");
12611 printf("programming error: (%s)\n", strerror(-ret));
12615 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12616 .f = cmd_set_vf_vlan_tag_parsed,
12618 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12620 (void *)&cmd_set_vf_vlan_tag_set,
12621 (void *)&cmd_set_vf_vlan_tag_vf,
12622 (void *)&cmd_set_vf_vlan_tag_vlan,
12623 (void *)&cmd_set_vf_vlan_tag_tag,
12624 (void *)&cmd_set_vf_vlan_tag_port_id,
12625 (void *)&cmd_set_vf_vlan_tag_vf_id,
12626 (void *)&cmd_set_vf_vlan_tag_on_off,
12631 /* Common definition of VF and TC TX bandwidth configuration */
12632 struct cmd_vf_tc_bw_result {
12633 cmdline_fixed_string_t set;
12634 cmdline_fixed_string_t vf;
12635 cmdline_fixed_string_t tc;
12636 cmdline_fixed_string_t tx;
12637 cmdline_fixed_string_t min_bw;
12638 cmdline_fixed_string_t max_bw;
12639 cmdline_fixed_string_t strict_link_prio;
12644 cmdline_fixed_string_t bw_list;
12648 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12649 TOKEN_STRING_INITIALIZER
12650 (struct cmd_vf_tc_bw_result,
12652 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12653 TOKEN_STRING_INITIALIZER
12654 (struct cmd_vf_tc_bw_result,
12656 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12657 TOKEN_STRING_INITIALIZER
12658 (struct cmd_vf_tc_bw_result,
12660 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12661 TOKEN_STRING_INITIALIZER
12662 (struct cmd_vf_tc_bw_result,
12664 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12665 TOKEN_STRING_INITIALIZER
12666 (struct cmd_vf_tc_bw_result,
12667 strict_link_prio, "strict-link-priority");
12668 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12669 TOKEN_STRING_INITIALIZER
12670 (struct cmd_vf_tc_bw_result,
12671 min_bw, "min-bandwidth");
12672 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12673 TOKEN_STRING_INITIALIZER
12674 (struct cmd_vf_tc_bw_result,
12675 max_bw, "max-bandwidth");
12676 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12677 TOKEN_NUM_INITIALIZER
12678 (struct cmd_vf_tc_bw_result,
12680 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12681 TOKEN_NUM_INITIALIZER
12682 (struct cmd_vf_tc_bw_result,
12684 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12685 TOKEN_NUM_INITIALIZER
12686 (struct cmd_vf_tc_bw_result,
12688 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12689 TOKEN_NUM_INITIALIZER
12690 (struct cmd_vf_tc_bw_result,
12692 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12693 TOKEN_STRING_INITIALIZER
12694 (struct cmd_vf_tc_bw_result,
12696 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12697 TOKEN_NUM_INITIALIZER
12698 (struct cmd_vf_tc_bw_result,
12701 /* VF max bandwidth setting */
12703 cmd_vf_max_bw_parsed(
12704 void *parsed_result,
12705 __attribute__((unused)) struct cmdline *cl,
12706 __attribute__((unused)) void *data)
12708 struct cmd_vf_tc_bw_result *res = parsed_result;
12709 int ret = -ENOTSUP;
12711 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12714 #ifdef RTE_LIBRTE_I40E_PMD
12715 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12716 res->vf_id, res->bw);
12723 printf("invalid vf_id %d or bandwidth %d\n",
12724 res->vf_id, res->bw);
12727 printf("invalid port_id %d\n", res->port_id);
12730 printf("function not implemented\n");
12733 printf("programming error: (%s)\n", strerror(-ret));
12737 cmdline_parse_inst_t cmd_vf_max_bw = {
12738 .f = cmd_vf_max_bw_parsed,
12740 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12742 (void *)&cmd_vf_tc_bw_set,
12743 (void *)&cmd_vf_tc_bw_vf,
12744 (void *)&cmd_vf_tc_bw_tx,
12745 (void *)&cmd_vf_tc_bw_max_bw,
12746 (void *)&cmd_vf_tc_bw_port_id,
12747 (void *)&cmd_vf_tc_bw_vf_id,
12748 (void *)&cmd_vf_tc_bw_bw,
12754 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12759 const char *p, *p0 = str;
12766 p = strchr(p0, '(');
12768 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12772 p0 = strchr(p, ')');
12774 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12778 if (size >= sizeof(s)) {
12779 printf("The string size exceeds the internal buffer size\n");
12782 snprintf(s, sizeof(s), "%.*s", size, p);
12783 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12785 printf("Failed to get the bandwidth list. ");
12789 for (i = 0; i < ret; i++)
12790 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12795 /* TC min bandwidth setting */
12797 cmd_vf_tc_min_bw_parsed(
12798 void *parsed_result,
12799 __attribute__((unused)) struct cmdline *cl,
12800 __attribute__((unused)) void *data)
12802 struct cmd_vf_tc_bw_result *res = parsed_result;
12805 int ret = -ENOTSUP;
12807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12810 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12814 #ifdef RTE_LIBRTE_I40E_PMD
12815 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12823 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12826 printf("invalid port_id %d\n", res->port_id);
12829 printf("function not implemented\n");
12832 printf("programming error: (%s)\n", strerror(-ret));
12836 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12837 .f = cmd_vf_tc_min_bw_parsed,
12839 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12840 " <bw1, bw2, ...>",
12842 (void *)&cmd_vf_tc_bw_set,
12843 (void *)&cmd_vf_tc_bw_vf,
12844 (void *)&cmd_vf_tc_bw_tc,
12845 (void *)&cmd_vf_tc_bw_tx,
12846 (void *)&cmd_vf_tc_bw_min_bw,
12847 (void *)&cmd_vf_tc_bw_port_id,
12848 (void *)&cmd_vf_tc_bw_vf_id,
12849 (void *)&cmd_vf_tc_bw_bw_list,
12855 cmd_tc_min_bw_parsed(
12856 void *parsed_result,
12857 __attribute__((unused)) struct cmdline *cl,
12858 __attribute__((unused)) void *data)
12860 struct cmd_vf_tc_bw_result *res = parsed_result;
12861 struct rte_port *port;
12864 int ret = -ENOTSUP;
12866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12869 port = &ports[res->port_id];
12870 /** Check if the port is not started **/
12871 if (port->port_status != RTE_PORT_STOPPED) {
12872 printf("Please stop port %d first\n", res->port_id);
12876 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12880 #ifdef RTE_LIBRTE_IXGBE_PMD
12881 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12888 printf("invalid bandwidth\n");
12891 printf("invalid port_id %d\n", res->port_id);
12894 printf("function not implemented\n");
12897 printf("programming error: (%s)\n", strerror(-ret));
12901 cmdline_parse_inst_t cmd_tc_min_bw = {
12902 .f = cmd_tc_min_bw_parsed,
12904 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12906 (void *)&cmd_vf_tc_bw_set,
12907 (void *)&cmd_vf_tc_bw_tc,
12908 (void *)&cmd_vf_tc_bw_tx,
12909 (void *)&cmd_vf_tc_bw_min_bw,
12910 (void *)&cmd_vf_tc_bw_port_id,
12911 (void *)&cmd_vf_tc_bw_bw_list,
12916 /* TC max bandwidth setting */
12918 cmd_vf_tc_max_bw_parsed(
12919 void *parsed_result,
12920 __attribute__((unused)) struct cmdline *cl,
12921 __attribute__((unused)) void *data)
12923 struct cmd_vf_tc_bw_result *res = parsed_result;
12924 int ret = -ENOTSUP;
12926 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12929 #ifdef RTE_LIBRTE_I40E_PMD
12930 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12931 res->tc_no, res->bw);
12938 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12939 res->vf_id, res->tc_no, res->bw);
12942 printf("invalid port_id %d\n", res->port_id);
12945 printf("function not implemented\n");
12948 printf("programming error: (%s)\n", strerror(-ret));
12952 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12953 .f = cmd_vf_tc_max_bw_parsed,
12955 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12958 (void *)&cmd_vf_tc_bw_set,
12959 (void *)&cmd_vf_tc_bw_vf,
12960 (void *)&cmd_vf_tc_bw_tc,
12961 (void *)&cmd_vf_tc_bw_tx,
12962 (void *)&cmd_vf_tc_bw_max_bw,
12963 (void *)&cmd_vf_tc_bw_port_id,
12964 (void *)&cmd_vf_tc_bw_vf_id,
12965 (void *)&cmd_vf_tc_bw_tc_no,
12966 (void *)&cmd_vf_tc_bw_bw,
12971 /* Strict link priority scheduling mode setting */
12973 cmd_strict_link_prio_parsed(
12974 void *parsed_result,
12975 __attribute__((unused)) struct cmdline *cl,
12976 __attribute__((unused)) void *data)
12978 struct cmd_vf_tc_bw_result *res = parsed_result;
12979 int ret = -ENOTSUP;
12981 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12984 #ifdef RTE_LIBRTE_I40E_PMD
12985 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12992 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12995 printf("invalid port_id %d\n", res->port_id);
12998 printf("function not implemented\n");
13001 printf("programming error: (%s)\n", strerror(-ret));
13005 cmdline_parse_inst_t cmd_strict_link_prio = {
13006 .f = cmd_strict_link_prio_parsed,
13008 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13010 (void *)&cmd_vf_tc_bw_set,
13011 (void *)&cmd_vf_tc_bw_tx,
13012 (void *)&cmd_vf_tc_bw_strict_link_prio,
13013 (void *)&cmd_vf_tc_bw_port_id,
13014 (void *)&cmd_vf_tc_bw_tc_map,
13019 /* Load dynamic device personalization*/
13020 struct cmd_ddp_add_result {
13021 cmdline_fixed_string_t ddp;
13022 cmdline_fixed_string_t add;
13027 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13028 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13029 cmdline_parse_token_string_t cmd_ddp_add_add =
13030 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13031 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13032 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13033 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13034 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13037 cmd_ddp_add_parsed(
13038 void *parsed_result,
13039 __attribute__((unused)) struct cmdline *cl,
13040 __attribute__((unused)) void *data)
13042 struct cmd_ddp_add_result *res = parsed_result;
13048 int ret = -ENOTSUP;
13050 if (res->port_id > nb_ports) {
13051 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13055 if (!all_ports_stopped()) {
13056 printf("Please stop all ports first\n");
13060 filepath = strdup(res->filepath);
13061 if (filepath == NULL) {
13062 printf("Failed to allocate memory\n");
13065 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13067 buff = open_ddp_package_file(file_fld[0], &size);
13069 free((void *)filepath);
13073 #ifdef RTE_LIBRTE_I40E_PMD
13074 if (ret == -ENOTSUP)
13075 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13077 RTE_PMD_I40E_PKG_OP_WR_ADD);
13080 if (ret == -EEXIST)
13081 printf("Profile has already existed.\n");
13083 printf("Failed to load profile.\n");
13084 else if (file_num == 2)
13085 save_ddp_package_file(file_fld[1], buff, size);
13087 close_ddp_package_file(buff);
13088 free((void *)filepath);
13091 cmdline_parse_inst_t cmd_ddp_add = {
13092 .f = cmd_ddp_add_parsed,
13094 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13096 (void *)&cmd_ddp_add_ddp,
13097 (void *)&cmd_ddp_add_add,
13098 (void *)&cmd_ddp_add_port_id,
13099 (void *)&cmd_ddp_add_filepath,
13104 /* Delete dynamic device personalization*/
13105 struct cmd_ddp_del_result {
13106 cmdline_fixed_string_t ddp;
13107 cmdline_fixed_string_t del;
13112 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13113 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13114 cmdline_parse_token_string_t cmd_ddp_del_del =
13115 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13116 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13117 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13118 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13119 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13122 cmd_ddp_del_parsed(
13123 void *parsed_result,
13124 __attribute__((unused)) struct cmdline *cl,
13125 __attribute__((unused)) void *data)
13127 struct cmd_ddp_del_result *res = parsed_result;
13130 int ret = -ENOTSUP;
13132 if (res->port_id > nb_ports) {
13133 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13137 if (!all_ports_stopped()) {
13138 printf("Please stop all ports first\n");
13142 buff = open_ddp_package_file(res->filepath, &size);
13146 #ifdef RTE_LIBRTE_I40E_PMD
13147 if (ret == -ENOTSUP)
13148 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13150 RTE_PMD_I40E_PKG_OP_WR_DEL);
13153 if (ret == -EACCES)
13154 printf("Profile does not exist.\n");
13156 printf("Failed to delete profile.\n");
13158 close_ddp_package_file(buff);
13161 cmdline_parse_inst_t cmd_ddp_del = {
13162 .f = cmd_ddp_del_parsed,
13164 .help_str = "ddp del <port_id> <profile_path>",
13166 (void *)&cmd_ddp_del_ddp,
13167 (void *)&cmd_ddp_del_del,
13168 (void *)&cmd_ddp_del_port_id,
13169 (void *)&cmd_ddp_del_filepath,
13174 /* Get dynamic device personalization profile info */
13175 struct cmd_ddp_info_result {
13176 cmdline_fixed_string_t ddp;
13177 cmdline_fixed_string_t get;
13178 cmdline_fixed_string_t info;
13182 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13183 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13184 cmdline_parse_token_string_t cmd_ddp_info_get =
13185 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13186 cmdline_parse_token_string_t cmd_ddp_info_info =
13187 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13188 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13189 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13192 cmd_ddp_info_parsed(
13193 void *parsed_result,
13194 __attribute__((unused)) struct cmdline *cl,
13195 __attribute__((unused)) void *data)
13197 struct cmd_ddp_info_result *res = parsed_result;
13200 int ret = -ENOTSUP;
13201 #ifdef RTE_LIBRTE_I40E_PMD
13204 uint32_t buff_size;
13205 struct rte_pmd_i40e_profile_info info;
13207 struct rte_pmd_i40e_ddp_device_id *devs;
13210 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13214 #ifdef RTE_LIBRTE_I40E_PMD
13215 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13216 (uint8_t *)&info, sizeof(info),
13217 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13219 printf("Global Track id: 0x%x\n", info.track_id);
13220 printf("Global Version: %d.%d.%d.%d\n",
13221 info.version.major,
13222 info.version.minor,
13223 info.version.update,
13224 info.version.draft);
13225 printf("Global Package name: %s\n\n", info.name);
13228 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13229 (uint8_t *)&info, sizeof(info),
13230 RTE_PMD_I40E_PKG_INFO_HEADER);
13232 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13233 printf("i40e Profile Version: %d.%d.%d.%d\n",
13234 info.version.major,
13235 info.version.minor,
13236 info.version.update,
13237 info.version.draft);
13238 printf("i40e Profile name: %s\n\n", info.name);
13241 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13242 (uint8_t *)&buff_size, sizeof(buff_size),
13243 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13244 if (!ret && buff_size) {
13245 buff = (uint8_t *)malloc(buff_size);
13247 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13249 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13251 printf("Package Notes:\n%s\n\n", buff);
13256 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13257 (uint8_t *)&dev_num, sizeof(dev_num),
13258 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13259 if (!ret && dev_num) {
13260 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
13261 sizeof(struct rte_pmd_i40e_ddp_device_id));
13263 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13264 (uint8_t *)devs, dev_num *
13265 sizeof(struct rte_pmd_i40e_ddp_device_id),
13266 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13268 printf("List of supported devices:\n");
13269 for (i = 0; i < dev_num; i++) {
13270 printf(" %04X:%04X %04X:%04X\n",
13271 devs[i].vendor_dev_id >> 16,
13272 devs[i].vendor_dev_id & 0xFFFF,
13273 devs[i].sub_vendor_dev_id >> 16,
13274 devs[i].sub_vendor_dev_id & 0xFFFF);
13283 if (ret == -ENOTSUP)
13284 printf("Function not supported in PMD driver\n");
13285 close_ddp_package_file(pkg);
13288 cmdline_parse_inst_t cmd_ddp_get_info = {
13289 .f = cmd_ddp_info_parsed,
13291 .help_str = "ddp get info <profile_path>",
13293 (void *)&cmd_ddp_info_ddp,
13294 (void *)&cmd_ddp_info_get,
13295 (void *)&cmd_ddp_info_info,
13296 (void *)&cmd_ddp_info_filepath,
13301 /* Get dynamic device personalization profile info list*/
13302 #define PROFILE_INFO_SIZE 48
13303 #define MAX_PROFILE_NUM 16
13305 struct cmd_ddp_get_list_result {
13306 cmdline_fixed_string_t ddp;
13307 cmdline_fixed_string_t get;
13308 cmdline_fixed_string_t list;
13312 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13313 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13314 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13315 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13316 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13317 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13318 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13319 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13322 cmd_ddp_get_list_parsed(
13323 void *parsed_result,
13324 __attribute__((unused)) struct cmdline *cl,
13325 __attribute__((unused)) void *data)
13327 struct cmd_ddp_get_list_result *res = parsed_result;
13328 #ifdef RTE_LIBRTE_I40E_PMD
13329 struct rte_pmd_i40e_profile_list *p_list;
13330 struct rte_pmd_i40e_profile_info *p_info;
13335 int ret = -ENOTSUP;
13337 if (res->port_id > nb_ports) {
13338 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13342 #ifdef RTE_LIBRTE_I40E_PMD
13343 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13344 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13346 printf("%s: Failed to malloc buffer\n", __func__);
13348 if (ret == -ENOTSUP)
13349 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13350 (uint8_t *)p_list, size);
13353 p_num = p_list->p_count;
13354 printf("Profile number is: %d\n\n", p_num);
13356 for (i = 0; i < p_num; i++) {
13357 p_info = &p_list->p_info[i];
13358 printf("Profile %d:\n", i);
13359 printf("Track id: 0x%x\n", p_info->track_id);
13360 printf("Version: %d.%d.%d.%d\n",
13361 p_info->version.major,
13362 p_info->version.minor,
13363 p_info->version.update,
13364 p_info->version.draft);
13365 printf("Profile name: %s\n\n", p_info->name);
13373 printf("Failed to get ddp list\n");
13376 cmdline_parse_inst_t cmd_ddp_get_list = {
13377 .f = cmd_ddp_get_list_parsed,
13379 .help_str = "ddp get list <port_id>",
13381 (void *)&cmd_ddp_get_list_ddp,
13382 (void *)&cmd_ddp_get_list_get,
13383 (void *)&cmd_ddp_get_list_list,
13384 (void *)&cmd_ddp_get_list_port_id,
13389 /* show vf stats */
13391 /* Common result structure for show vf stats */
13392 struct cmd_show_vf_stats_result {
13393 cmdline_fixed_string_t show;
13394 cmdline_fixed_string_t vf;
13395 cmdline_fixed_string_t stats;
13400 /* Common CLI fields show vf stats*/
13401 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13402 TOKEN_STRING_INITIALIZER
13403 (struct cmd_show_vf_stats_result,
13405 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13406 TOKEN_STRING_INITIALIZER
13407 (struct cmd_show_vf_stats_result,
13409 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13410 TOKEN_STRING_INITIALIZER
13411 (struct cmd_show_vf_stats_result,
13413 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13414 TOKEN_NUM_INITIALIZER
13415 (struct cmd_show_vf_stats_result,
13417 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13418 TOKEN_NUM_INITIALIZER
13419 (struct cmd_show_vf_stats_result,
13423 cmd_show_vf_stats_parsed(
13424 void *parsed_result,
13425 __attribute__((unused)) struct cmdline *cl,
13426 __attribute__((unused)) void *data)
13428 struct cmd_show_vf_stats_result *res = parsed_result;
13429 struct rte_eth_stats stats;
13430 int ret = -ENOTSUP;
13431 static const char *nic_stats_border = "########################";
13433 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13436 memset(&stats, 0, sizeof(stats));
13438 #ifdef RTE_LIBRTE_I40E_PMD
13439 if (ret == -ENOTSUP)
13440 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13444 #ifdef RTE_LIBRTE_BNXT_PMD
13445 if (ret == -ENOTSUP)
13446 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13455 printf("invalid vf_id %d\n", res->vf_id);
13458 printf("invalid port_id %d\n", res->port_id);
13461 printf("function not implemented\n");
13464 printf("programming error: (%s)\n", strerror(-ret));
13467 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13468 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13470 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13472 stats.ipackets, stats.imissed, stats.ibytes);
13473 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13474 printf(" RX-nombuf: %-10"PRIu64"\n",
13476 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13478 stats.opackets, stats.oerrors, stats.obytes);
13480 printf(" %s############################%s\n",
13481 nic_stats_border, nic_stats_border);
13484 cmdline_parse_inst_t cmd_show_vf_stats = {
13485 .f = cmd_show_vf_stats_parsed,
13487 .help_str = "show vf stats <port_id> <vf_id>",
13489 (void *)&cmd_show_vf_stats_show,
13490 (void *)&cmd_show_vf_stats_vf,
13491 (void *)&cmd_show_vf_stats_stats,
13492 (void *)&cmd_show_vf_stats_port_id,
13493 (void *)&cmd_show_vf_stats_vf_id,
13498 /* clear vf stats */
13500 /* Common result structure for clear vf stats */
13501 struct cmd_clear_vf_stats_result {
13502 cmdline_fixed_string_t clear;
13503 cmdline_fixed_string_t vf;
13504 cmdline_fixed_string_t stats;
13509 /* Common CLI fields clear vf stats*/
13510 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13511 TOKEN_STRING_INITIALIZER
13512 (struct cmd_clear_vf_stats_result,
13514 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13515 TOKEN_STRING_INITIALIZER
13516 (struct cmd_clear_vf_stats_result,
13518 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13519 TOKEN_STRING_INITIALIZER
13520 (struct cmd_clear_vf_stats_result,
13522 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13523 TOKEN_NUM_INITIALIZER
13524 (struct cmd_clear_vf_stats_result,
13526 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13527 TOKEN_NUM_INITIALIZER
13528 (struct cmd_clear_vf_stats_result,
13532 cmd_clear_vf_stats_parsed(
13533 void *parsed_result,
13534 __attribute__((unused)) struct cmdline *cl,
13535 __attribute__((unused)) void *data)
13537 struct cmd_clear_vf_stats_result *res = parsed_result;
13538 int ret = -ENOTSUP;
13540 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13543 #ifdef RTE_LIBRTE_I40E_PMD
13544 if (ret == -ENOTSUP)
13545 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13548 #ifdef RTE_LIBRTE_BNXT_PMD
13549 if (ret == -ENOTSUP)
13550 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13558 printf("invalid vf_id %d\n", res->vf_id);
13561 printf("invalid port_id %d\n", res->port_id);
13564 printf("function not implemented\n");
13567 printf("programming error: (%s)\n", strerror(-ret));
13571 cmdline_parse_inst_t cmd_clear_vf_stats = {
13572 .f = cmd_clear_vf_stats_parsed,
13574 .help_str = "clear vf stats <port_id> <vf_id>",
13576 (void *)&cmd_clear_vf_stats_clear,
13577 (void *)&cmd_clear_vf_stats_vf,
13578 (void *)&cmd_clear_vf_stats_stats,
13579 (void *)&cmd_clear_vf_stats_port_id,
13580 (void *)&cmd_clear_vf_stats_vf_id,
13585 /* ptype mapping get */
13587 /* Common result structure for ptype mapping get */
13588 struct cmd_ptype_mapping_get_result {
13589 cmdline_fixed_string_t ptype;
13590 cmdline_fixed_string_t mapping;
13591 cmdline_fixed_string_t get;
13593 uint8_t valid_only;
13596 /* Common CLI fields for ptype mapping get */
13597 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13598 TOKEN_STRING_INITIALIZER
13599 (struct cmd_ptype_mapping_get_result,
13601 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13602 TOKEN_STRING_INITIALIZER
13603 (struct cmd_ptype_mapping_get_result,
13604 mapping, "mapping");
13605 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13606 TOKEN_STRING_INITIALIZER
13607 (struct cmd_ptype_mapping_get_result,
13609 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13610 TOKEN_NUM_INITIALIZER
13611 (struct cmd_ptype_mapping_get_result,
13613 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13614 TOKEN_NUM_INITIALIZER
13615 (struct cmd_ptype_mapping_get_result,
13616 valid_only, UINT8);
13619 cmd_ptype_mapping_get_parsed(
13620 void *parsed_result,
13621 __attribute__((unused)) struct cmdline *cl,
13622 __attribute__((unused)) void *data)
13624 struct cmd_ptype_mapping_get_result *res = parsed_result;
13625 int ret = -ENOTSUP;
13626 #ifdef RTE_LIBRTE_I40E_PMD
13627 int max_ptype_num = 256;
13628 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13633 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13636 #ifdef RTE_LIBRTE_I40E_PMD
13637 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13648 printf("invalid port_id %d\n", res->port_id);
13651 printf("function not implemented\n");
13654 printf("programming error: (%s)\n", strerror(-ret));
13657 #ifdef RTE_LIBRTE_I40E_PMD
13659 for (i = 0; i < count; i++)
13660 printf("%3d\t0x%08x\n",
13661 mapping[i].hw_ptype, mapping[i].sw_ptype);
13666 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13667 .f = cmd_ptype_mapping_get_parsed,
13669 .help_str = "ptype mapping get <port_id> <valid_only>",
13671 (void *)&cmd_ptype_mapping_get_ptype,
13672 (void *)&cmd_ptype_mapping_get_mapping,
13673 (void *)&cmd_ptype_mapping_get_get,
13674 (void *)&cmd_ptype_mapping_get_port_id,
13675 (void *)&cmd_ptype_mapping_get_valid_only,
13680 /* ptype mapping replace */
13682 /* Common result structure for ptype mapping replace */
13683 struct cmd_ptype_mapping_replace_result {
13684 cmdline_fixed_string_t ptype;
13685 cmdline_fixed_string_t mapping;
13686 cmdline_fixed_string_t replace;
13693 /* Common CLI fields for ptype mapping replace */
13694 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13695 TOKEN_STRING_INITIALIZER
13696 (struct cmd_ptype_mapping_replace_result,
13698 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13699 TOKEN_STRING_INITIALIZER
13700 (struct cmd_ptype_mapping_replace_result,
13701 mapping, "mapping");
13702 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13703 TOKEN_STRING_INITIALIZER
13704 (struct cmd_ptype_mapping_replace_result,
13705 replace, "replace");
13706 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13707 TOKEN_NUM_INITIALIZER
13708 (struct cmd_ptype_mapping_replace_result,
13710 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13711 TOKEN_NUM_INITIALIZER
13712 (struct cmd_ptype_mapping_replace_result,
13714 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13715 TOKEN_NUM_INITIALIZER
13716 (struct cmd_ptype_mapping_replace_result,
13718 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13719 TOKEN_NUM_INITIALIZER
13720 (struct cmd_ptype_mapping_replace_result,
13724 cmd_ptype_mapping_replace_parsed(
13725 void *parsed_result,
13726 __attribute__((unused)) struct cmdline *cl,
13727 __attribute__((unused)) void *data)
13729 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13730 int ret = -ENOTSUP;
13732 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13735 #ifdef RTE_LIBRTE_I40E_PMD
13736 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13746 printf("invalid ptype 0x%8x or 0x%8x\n",
13747 res->target, res->pkt_type);
13750 printf("invalid port_id %d\n", res->port_id);
13753 printf("function not implemented\n");
13756 printf("programming error: (%s)\n", strerror(-ret));
13760 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13761 .f = cmd_ptype_mapping_replace_parsed,
13764 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13766 (void *)&cmd_ptype_mapping_replace_ptype,
13767 (void *)&cmd_ptype_mapping_replace_mapping,
13768 (void *)&cmd_ptype_mapping_replace_replace,
13769 (void *)&cmd_ptype_mapping_replace_port_id,
13770 (void *)&cmd_ptype_mapping_replace_target,
13771 (void *)&cmd_ptype_mapping_replace_mask,
13772 (void *)&cmd_ptype_mapping_replace_pkt_type,
13777 /* ptype mapping reset */
13779 /* Common result structure for ptype mapping reset */
13780 struct cmd_ptype_mapping_reset_result {
13781 cmdline_fixed_string_t ptype;
13782 cmdline_fixed_string_t mapping;
13783 cmdline_fixed_string_t reset;
13787 /* Common CLI fields for ptype mapping reset*/
13788 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
13789 TOKEN_STRING_INITIALIZER
13790 (struct cmd_ptype_mapping_reset_result,
13792 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
13793 TOKEN_STRING_INITIALIZER
13794 (struct cmd_ptype_mapping_reset_result,
13795 mapping, "mapping");
13796 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
13797 TOKEN_STRING_INITIALIZER
13798 (struct cmd_ptype_mapping_reset_result,
13800 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
13801 TOKEN_NUM_INITIALIZER
13802 (struct cmd_ptype_mapping_reset_result,
13806 cmd_ptype_mapping_reset_parsed(
13807 void *parsed_result,
13808 __attribute__((unused)) struct cmdline *cl,
13809 __attribute__((unused)) void *data)
13811 struct cmd_ptype_mapping_reset_result *res = parsed_result;
13812 int ret = -ENOTSUP;
13814 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13817 #ifdef RTE_LIBRTE_I40E_PMD
13818 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
13825 printf("invalid port_id %d\n", res->port_id);
13828 printf("function not implemented\n");
13831 printf("programming error: (%s)\n", strerror(-ret));
13835 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
13836 .f = cmd_ptype_mapping_reset_parsed,
13838 .help_str = "ptype mapping reset <port_id>",
13840 (void *)&cmd_ptype_mapping_reset_ptype,
13841 (void *)&cmd_ptype_mapping_reset_mapping,
13842 (void *)&cmd_ptype_mapping_reset_reset,
13843 (void *)&cmd_ptype_mapping_reset_port_id,
13848 /* ptype mapping update */
13850 /* Common result structure for ptype mapping update */
13851 struct cmd_ptype_mapping_update_result {
13852 cmdline_fixed_string_t ptype;
13853 cmdline_fixed_string_t mapping;
13854 cmdline_fixed_string_t reset;
13860 /* Common CLI fields for ptype mapping update*/
13861 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
13862 TOKEN_STRING_INITIALIZER
13863 (struct cmd_ptype_mapping_update_result,
13865 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
13866 TOKEN_STRING_INITIALIZER
13867 (struct cmd_ptype_mapping_update_result,
13868 mapping, "mapping");
13869 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
13870 TOKEN_STRING_INITIALIZER
13871 (struct cmd_ptype_mapping_update_result,
13873 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
13874 TOKEN_NUM_INITIALIZER
13875 (struct cmd_ptype_mapping_update_result,
13877 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
13878 TOKEN_NUM_INITIALIZER
13879 (struct cmd_ptype_mapping_update_result,
13881 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
13882 TOKEN_NUM_INITIALIZER
13883 (struct cmd_ptype_mapping_update_result,
13887 cmd_ptype_mapping_update_parsed(
13888 void *parsed_result,
13889 __attribute__((unused)) struct cmdline *cl,
13890 __attribute__((unused)) void *data)
13892 struct cmd_ptype_mapping_update_result *res = parsed_result;
13893 int ret = -ENOTSUP;
13894 #ifdef RTE_LIBRTE_I40E_PMD
13895 struct rte_pmd_i40e_ptype_mapping mapping;
13897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13900 #ifdef RTE_LIBRTE_I40E_PMD
13901 mapping.hw_ptype = res->hw_ptype;
13902 mapping.sw_ptype = res->sw_ptype;
13903 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
13913 printf("invalid ptype 0x%8x\n", res->sw_ptype);
13916 printf("invalid port_id %d\n", res->port_id);
13919 printf("function not implemented\n");
13922 printf("programming error: (%s)\n", strerror(-ret));
13926 cmdline_parse_inst_t cmd_ptype_mapping_update = {
13927 .f = cmd_ptype_mapping_update_parsed,
13929 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
13931 (void *)&cmd_ptype_mapping_update_ptype,
13932 (void *)&cmd_ptype_mapping_update_mapping,
13933 (void *)&cmd_ptype_mapping_update_update,
13934 (void *)&cmd_ptype_mapping_update_port_id,
13935 (void *)&cmd_ptype_mapping_update_hw_ptype,
13936 (void *)&cmd_ptype_mapping_update_sw_ptype,
13941 /* Common result structure for file commands */
13942 struct cmd_cmdfile_result {
13943 cmdline_fixed_string_t load;
13944 cmdline_fixed_string_t filename;
13947 /* Common CLI fields for file commands */
13948 cmdline_parse_token_string_t cmd_load_cmdfile =
13949 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
13950 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
13951 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
13954 cmd_load_from_file_parsed(
13955 void *parsed_result,
13956 __attribute__((unused)) struct cmdline *cl,
13957 __attribute__((unused)) void *data)
13959 struct cmd_cmdfile_result *res = parsed_result;
13961 cmdline_read_from_file(res->filename);
13964 cmdline_parse_inst_t cmd_load_from_file = {
13965 .f = cmd_load_from_file_parsed,
13967 .help_str = "load <filename>",
13969 (void *)&cmd_load_cmdfile,
13970 (void *)&cmd_load_cmdfile_filename,
13975 /* ******************************************************************************** */
13977 /* list of instructions */
13978 cmdline_parse_ctx_t main_ctx[] = {
13979 (cmdline_parse_inst_t *)&cmd_help_brief,
13980 (cmdline_parse_inst_t *)&cmd_help_long,
13981 (cmdline_parse_inst_t *)&cmd_quit,
13982 (cmdline_parse_inst_t *)&cmd_load_from_file,
13983 (cmdline_parse_inst_t *)&cmd_showport,
13984 (cmdline_parse_inst_t *)&cmd_showqueue,
13985 (cmdline_parse_inst_t *)&cmd_showportall,
13986 (cmdline_parse_inst_t *)&cmd_showcfg,
13987 (cmdline_parse_inst_t *)&cmd_start,
13988 (cmdline_parse_inst_t *)&cmd_start_tx_first,
13989 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13990 (cmdline_parse_inst_t *)&cmd_set_link_up,
13991 (cmdline_parse_inst_t *)&cmd_set_link_down,
13992 (cmdline_parse_inst_t *)&cmd_reset,
13993 (cmdline_parse_inst_t *)&cmd_set_numbers,
13994 (cmdline_parse_inst_t *)&cmd_set_txpkts,
13995 (cmdline_parse_inst_t *)&cmd_set_txsplit,
13996 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13997 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13998 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13999 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14000 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14001 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14002 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14003 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14004 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14005 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14006 (cmdline_parse_inst_t *)&cmd_set_link_check,
14007 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14008 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14009 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14010 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14011 #ifdef RTE_LIBRTE_PMD_BOND
14012 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14013 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14014 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14015 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14016 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14017 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14018 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14019 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14020 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14021 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14023 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14024 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14025 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14026 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14027 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14028 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14029 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14030 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14031 (cmdline_parse_inst_t *)&cmd_csum_set,
14032 (cmdline_parse_inst_t *)&cmd_csum_show,
14033 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14034 (cmdline_parse_inst_t *)&cmd_tso_set,
14035 (cmdline_parse_inst_t *)&cmd_tso_show,
14036 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14037 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14038 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
14039 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
14040 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
14041 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
14042 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
14043 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
14044 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
14045 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
14046 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
14047 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
14048 (cmdline_parse_inst_t *)&cmd_config_dcb,
14049 (cmdline_parse_inst_t *)&cmd_read_reg,
14050 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
14051 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
14052 (cmdline_parse_inst_t *)&cmd_write_reg,
14053 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
14054 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
14055 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
14056 (cmdline_parse_inst_t *)&cmd_stop,
14057 (cmdline_parse_inst_t *)&cmd_mac_addr,
14058 (cmdline_parse_inst_t *)&cmd_set_qmap,
14059 (cmdline_parse_inst_t *)&cmd_operate_port,
14060 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
14061 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
14062 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
14063 (cmdline_parse_inst_t *)&cmd_config_speed_all,
14064 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
14065 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
14066 (cmdline_parse_inst_t *)&cmd_config_mtu,
14067 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
14068 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
14069 (cmdline_parse_inst_t *)&cmd_config_rss,
14070 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
14071 (cmdline_parse_inst_t *)&cmd_config_txqflags,
14072 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
14073 (cmdline_parse_inst_t *)&cmd_showport_reta,
14074 (cmdline_parse_inst_t *)&cmd_config_burst,
14075 (cmdline_parse_inst_t *)&cmd_config_thresh,
14076 (cmdline_parse_inst_t *)&cmd_config_threshold,
14077 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
14078 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
14079 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
14080 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
14081 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
14082 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
14083 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
14084 (cmdline_parse_inst_t *)&cmd_global_config,
14085 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
14086 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
14087 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
14088 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
14089 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
14090 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
14091 (cmdline_parse_inst_t *)&cmd_dump,
14092 (cmdline_parse_inst_t *)&cmd_dump_one,
14093 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
14094 (cmdline_parse_inst_t *)&cmd_syn_filter,
14095 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
14096 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
14097 (cmdline_parse_inst_t *)&cmd_flex_filter,
14098 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
14099 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
14100 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
14101 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
14102 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
14103 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
14104 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
14105 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
14106 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
14107 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
14108 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
14109 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
14110 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
14111 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
14112 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
14113 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
14114 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
14115 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
14116 (cmdline_parse_inst_t *)&cmd_flow,
14117 (cmdline_parse_inst_t *)&cmd_mcast_addr,
14118 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
14119 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
14120 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
14121 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
14122 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
14123 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
14124 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
14125 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
14126 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
14127 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
14128 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
14129 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
14130 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
14131 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
14132 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
14133 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
14134 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
14135 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
14136 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
14137 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
14138 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
14139 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
14140 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
14141 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
14142 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
14143 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
14144 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
14145 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
14146 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
14147 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
14148 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
14149 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
14150 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
14151 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
14152 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
14153 (cmdline_parse_inst_t *)&cmd_ddp_add,
14154 (cmdline_parse_inst_t *)&cmd_ddp_del,
14155 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
14156 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
14157 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
14158 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
14159 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
14160 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
14161 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
14162 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
14166 /* read cmdline commands from file */
14168 cmdline_read_from_file(const char *filename)
14170 struct cmdline *cl;
14172 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14174 printf("Failed to create file based cmdline context: %s\n",
14179 cmdline_interact(cl);
14184 printf("Read CLI commands from %s\n", filename);
14187 /* prompt function, called from main on MASTER lcore */
14191 /* initialize non-constant commands */
14192 cmd_set_fwd_mode_init();
14193 cmd_set_fwd_retry_mode_init();
14195 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14196 if (testpmd_cl == NULL)
14198 cmdline_interact(testpmd_cl);
14199 cmdline_stdin_exit(testpmd_cl);
14205 if (testpmd_cl != NULL)
14206 cmdline_quit(testpmd_cl);
14210 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14212 if (id == (portid_t)RTE_PORT_ALL) {
14215 RTE_ETH_FOREACH_DEV(pid) {
14216 /* check if need_reconfig has been set to 1 */
14217 if (ports[pid].need_reconfig == 0)
14218 ports[pid].need_reconfig = dev;
14219 /* check if need_reconfig_queues has been set to 1 */
14220 if (ports[pid].need_reconfig_queues == 0)
14221 ports[pid].need_reconfig_queues = queue;
14223 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14224 /* check if need_reconfig has been set to 1 */
14225 if (ports[id].need_reconfig == 0)
14226 ports[id].need_reconfig = dev;
14227 /* check if need_reconfig_queues has been set to 1 */
14228 if (ports[id].need_reconfig_queues == 0)
14229 ports[id].need_reconfig_queues = queue;