4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_malloc.h>
63 #include <rte_launch.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
77 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
91 #ifdef RTE_LIBRTE_IXGBE_PMD
92 #include <rte_pmd_ixgbe.h>
94 #ifdef RTE_LIBRTE_I40E_PMD
95 #include <rte_pmd_i40e.h>
97 #ifdef RTE_LIBRTE_BNXT_PMD
98 #include <rte_pmd_bnxt.h>
102 static struct cmdline *testpmd_cl;
104 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
106 /* *** Help command with introduction. *** */
107 struct cmd_help_brief_result {
108 cmdline_fixed_string_t help;
111 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
113 __attribute__((unused)) void *data)
118 "Help is available for the following sections:\n\n"
119 " help control : Start and stop forwarding.\n"
120 " help display : Displaying port, stats and config "
122 " help config : Configuration information.\n"
123 " help ports : Configuring ports.\n"
124 " help registers : Reading and setting port registers.\n"
125 " help filters : Filters configuration help.\n"
126 " help all : All of the above sections.\n\n"
131 cmdline_parse_token_string_t cmd_help_brief_help =
132 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
134 cmdline_parse_inst_t cmd_help_brief = {
135 .f = cmd_help_brief_parsed,
137 .help_str = "help: Show help",
139 (void *)&cmd_help_brief_help,
144 /* *** Help command with help sections. *** */
145 struct cmd_help_long_result {
146 cmdline_fixed_string_t help;
147 cmdline_fixed_string_t section;
150 static void cmd_help_long_parsed(void *parsed_result,
152 __attribute__((unused)) void *data)
155 struct cmd_help_long_result *res = parsed_result;
157 if (!strcmp(res->section, "all"))
160 if (show_all || !strcmp(res->section, "control")) {
165 "Control forwarding:\n"
166 "-------------------\n\n"
169 " Start packet forwarding with current configuration.\n\n"
172 " Start packet forwarding with current config"
173 " after sending one burst of packets.\n\n"
176 " Stop packet forwarding, and display accumulated"
180 " Quit to prompt.\n\n"
184 if (show_all || !strcmp(res->section, "display")) {
192 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
193 " Display information for port_id, or all.\n\n"
195 "show port X rss reta (size) (mask0,mask1,...)\n"
196 " Display the rss redirection table entry indicated"
197 " by masks on port X. size is used to indicate the"
198 " hardware supported reta size\n\n"
200 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
201 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
202 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
203 " Display the RSS hash functions and RSS hash key"
206 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
207 " Clear information for port_id, or all.\n\n"
209 "show (rxq|txq) info (port_id) (queue_id)\n"
210 " Display information for configured RX/TX queue.\n\n"
212 "show config (rxtx|cores|fwd|txpkts)\n"
213 " Display the given configuration.\n\n"
215 "read rxd (port_id) (queue_id) (rxd_id)\n"
216 " Display an RX descriptor of a port RX queue.\n\n"
218 "read txd (port_id) (queue_id) (txd_id)\n"
219 " Display a TX descriptor of a port TX queue.\n\n"
221 "ddp get list (port_id)\n"
222 " Get ddp profile info list\n\n"
224 "ddp get info (profile_path)\n"
225 " Get ddp profile information.\n\n"
227 "show vf stats (port_id) (vf_id)\n"
228 " Display a VF's statistics.\n\n"
230 "clear vf stats (port_id) (vf_id)\n"
231 " Reset a VF's statistics.\n\n"
235 if (show_all || !strcmp(res->section, "config")) {
241 "Configuration changes only become active when"
242 " forwarding is started/restarted.\n\n"
245 " Reset forwarding to the default configuration.\n\n"
247 "set verbose (level)\n"
248 " Set the debug verbosity level X.\n\n"
251 " Set number of ports.\n\n"
254 " Set number of cores.\n\n"
256 "set coremask (mask)\n"
257 " Set the forwarding cores hexadecimal mask.\n\n"
259 "set portmask (mask)\n"
260 " Set the forwarding ports hexadecimal mask.\n\n"
263 " Set number of packets per burst.\n\n"
265 "set burst tx delay (microseconds) retry (num)\n"
266 " Set the transmit delay time and number of retries,"
267 " effective when retry is enabled.\n\n"
269 "set txpkts (x[,y]*)\n"
270 " Set the length of each segment of TXONLY"
271 " and optionally CSUM packets.\n\n"
273 "set txsplit (off|on|rand)\n"
274 " Set the split policy for the TX packets."
275 " Right now only applicable for CSUM and TXONLY"
278 "set corelist (x[,y]*)\n"
279 " Set the list of forwarding cores.\n\n"
281 "set portlist (x[,y]*)\n"
282 " Set the list of forwarding ports.\n\n"
284 "set tx loopback (port_id) (on|off)\n"
285 " Enable or disable tx loopback.\n\n"
287 "set all queues drop (port_id) (on|off)\n"
288 " Set drop enable bit for all queues.\n\n"
290 "set vf split drop (port_id) (vf_id) (on|off)\n"
291 " Set split drop enable bit for a VF from the PF.\n\n"
293 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
294 " Set MAC antispoof for a VF from the PF.\n\n"
296 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
297 " Enable MACsec offload.\n\n"
299 "set macsec offload (port_id) off\n"
300 " Disable MACsec offload.\n\n"
302 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
303 " Configure MACsec secure connection (SC).\n\n"
305 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
306 " Configure MACsec secure association (SA).\n\n"
308 "set vf broadcast (port_id) (vf_id) (on|off)\n"
309 " Set VF broadcast for a VF from the PF.\n\n"
311 "vlan set strip (on|off) (port_id)\n"
312 " Set the VLAN strip on a port.\n\n"
314 "vlan set stripq (on|off) (port_id,queue_id)\n"
315 " Set the VLAN strip for a queue on a port.\n\n"
317 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
318 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
320 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
321 " Set VLAN insert for a VF from the PF.\n\n"
323 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
324 " Set VLAN antispoof for a VF from the PF.\n\n"
326 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
327 " Set VLAN tag for a VF from the PF.\n\n"
329 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
330 " Set a VF's max bandwidth(Mbps).\n\n"
332 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
333 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
335 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
336 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
338 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
339 " Set some TCs' strict link priority mode on a physical port.\n\n"
341 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
342 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
344 "vlan set filter (on|off) (port_id)\n"
345 " Set the VLAN filter on a port.\n\n"
347 "vlan set qinq (on|off) (port_id)\n"
348 " Set the VLAN QinQ (extended queue in queue)"
351 "vlan set (inner|outer) tpid (value) (port_id)\n"
352 " Set the VLAN TPID for Packet Filtering on"
355 "rx_vlan add (vlan_id|all) (port_id)\n"
356 " Add a vlan_id, or all identifiers, to the set"
357 " of VLAN identifiers filtered by port_id.\n\n"
359 "rx_vlan rm (vlan_id|all) (port_id)\n"
360 " Remove a vlan_id, or all identifiers, from the set"
361 " of VLAN identifiers filtered by port_id.\n\n"
363 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
364 " Add a vlan_id, to the set of VLAN identifiers"
365 "filtered for VF(s) from port_id.\n\n"
367 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
368 " Remove a vlan_id, to the set of VLAN identifiers"
369 "filtered for VF(s) from port_id.\n\n"
371 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
372 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
373 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
374 " add a tunnel filter of a port.\n\n"
376 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
377 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
378 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
379 " remove a tunnel filter of a port.\n\n"
381 "rx_vxlan_port add (udp_port) (port_id)\n"
382 " Add an UDP port for VXLAN packet filter on a port\n\n"
384 "rx_vxlan_port rm (udp_port) (port_id)\n"
385 " Remove an UDP port for VXLAN packet filter on a port\n\n"
387 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
388 " Set hardware insertion of VLAN IDs (single or double VLAN "
389 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
391 "tx_vlan set pvid port_id vlan_id (on|off)\n"
392 " Set port based TX VLAN insertion.\n\n"
394 "tx_vlan reset (port_id)\n"
395 " Disable hardware insertion of a VLAN header in"
396 " packets sent on a port.\n\n"
398 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
399 " Select hardware or software calculation of the"
400 " checksum when transmitting a packet using the"
401 " csum forward engine.\n"
402 " ip|udp|tcp|sctp always concern the inner layer.\n"
403 " outer-ip concerns the outer IP layer in"
404 " case the packet is recognized as a tunnel packet by"
405 " the forward engine (vxlan, gre and ipip are supported)\n"
406 " Please check the NIC datasheet for HW limits.\n\n"
408 "csum parse-tunnel (on|off) (tx_port_id)\n"
409 " If disabled, treat tunnel packets as non-tunneled"
410 " packets (treat inner headers as payload). The port\n"
411 " argument is the port used for TX in csum forward"
414 "csum show (port_id)\n"
415 " Display tx checksum offload configuration\n\n"
417 "tso set (segsize) (portid)\n"
418 " Enable TCP Segmentation Offload in csum forward"
420 " Please check the NIC datasheet for HW limits.\n\n"
423 " Display the status of TCP Segmentation Offload.\n\n"
426 " Set packet forwarding mode.\n\n"
428 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
429 " Add a MAC address on port_id.\n\n"
431 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
432 " Remove a MAC address from port_id.\n\n"
434 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
435 " Set the default MAC address for port_id.\n\n"
437 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
438 " Add a MAC address for a VF on the port.\n\n"
440 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
441 " Set the MAC address for a VF from the PF.\n\n"
443 "set port (port_id) uta (mac_address|all) (on|off)\n"
444 " Add/Remove a or all unicast hash filter(s)"
447 "set promisc (port_id|all) (on|off)\n"
448 " Set the promiscuous mode on port_id, or all.\n\n"
450 "set allmulti (port_id|all) (on|off)\n"
451 " Set the allmulti mode on port_id, or all.\n\n"
453 "set vf promisc (port_id) (vf_id) (on|off)\n"
454 " Set unicast promiscuous mode for a VF from the PF.\n\n"
456 "set vf allmulti (port_id) (vf_id) (on|off)\n"
457 " Set multicast promiscuous mode for a VF from the PF.\n\n"
459 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
460 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
461 " (on|off) autoneg (on|off) (port_id)\n"
462 "set flow_ctrl rx (on|off) (portid)\n"
463 "set flow_ctrl tx (on|off) (portid)\n"
464 "set flow_ctrl high_water (high_water) (portid)\n"
465 "set flow_ctrl low_water (low_water) (portid)\n"
466 "set flow_ctrl pause_time (pause_time) (portid)\n"
467 "set flow_ctrl send_xon (send_xon) (portid)\n"
468 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
469 "set flow_ctrl autoneg (on|off) (port_id)\n"
470 " Set the link flow control parameter on a port.\n\n"
472 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
473 " (low_water) (pause_time) (priority) (port_id)\n"
474 " Set the priority flow control parameter on a"
477 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
478 " Set statistics mapping (qmapping 0..15) for RX/TX"
480 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
481 " on port 0 to mapping 5.\n\n"
483 "set port (port_id) vf (vf_id) rx|tx on|off\n"
484 " Enable/Disable a VF receive/tranmit from a port\n\n"
486 "set port (port_id) vf (vf_id) (mac_addr)"
487 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
488 " Add/Remove unicast or multicast MAC addr filter"
491 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
493 " AUPE:accepts untagged VLAN;"
494 "ROPE:accept unicast hash\n\n"
495 " BAM:accepts broadcast packets;"
496 "MPE:accepts all multicast packets\n\n"
497 " Enable/Disable a VF receive mode of a port\n\n"
499 "set port (port_id) queue (queue_id) rate (rate_num)\n"
500 " Set rate limit for a queue of a port\n\n"
502 "set port (port_id) vf (vf_id) rate (rate_num) "
503 "queue_mask (queue_mask_value)\n"
504 " Set rate limit for queues in VF of a port\n\n"
506 "set port (port_id) mirror-rule (rule_id)"
507 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
508 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
509 " Set pool or vlan type mirror rule on a port.\n"
510 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
511 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
514 "set port (port_id) mirror-rule (rule_id)"
515 " (uplink-mirror|downlink-mirror) dst-pool"
516 " (pool_id) (on|off)\n"
517 " Set uplink or downlink type mirror rule on a port.\n"
518 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
519 " 0 on' enable mirror income traffic to pool 0.\n\n"
521 "reset port (port_id) mirror-rule (rule_id)\n"
522 " Reset a mirror rule.\n\n"
524 "set flush_rx (on|off)\n"
525 " Flush (default) or don't flush RX streams before"
526 " forwarding. Mainly used with PCAP drivers.\n\n"
528 "set bypass mode (normal|bypass|isolate) (port_id)\n"
529 " Set the bypass mode for the lowest port on bypass enabled"
532 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
533 "mode (normal|bypass|isolate) (port_id)\n"
534 " Set the event required to initiate specified bypass mode for"
535 " the lowest port on a bypass enabled NIC where:\n"
536 " timeout = enable bypass after watchdog timeout.\n"
537 " os_on = enable bypass when OS/board is powered on.\n"
538 " os_off = enable bypass when OS/board is powered off.\n"
539 " power_on = enable bypass when power supply is turned on.\n"
540 " power_off = enable bypass when power supply is turned off."
543 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
544 " Set the bypass watchdog timeout to 'n' seconds"
545 " where 0 = instant.\n\n"
547 "show bypass config (port_id)\n"
548 " Show the bypass configuration for a bypass enabled NIC"
549 " using the lowest port on the NIC.\n\n"
551 #ifdef RTE_LIBRTE_PMD_BOND
552 "create bonded device (mode) (socket)\n"
553 " Create a new bonded device with specific bonding mode and socket.\n\n"
555 "add bonding slave (slave_id) (port_id)\n"
556 " Add a slave device to a bonded device.\n\n"
558 "remove bonding slave (slave_id) (port_id)\n"
559 " Remove a slave device from a bonded device.\n\n"
561 "set bonding mode (value) (port_id)\n"
562 " Set the bonding mode on a bonded device.\n\n"
564 "set bonding primary (slave_id) (port_id)\n"
565 " Set the primary slave for a bonded device.\n\n"
567 "show bonding config (port_id)\n"
568 " Show the bonding config for port_id.\n\n"
570 "set bonding mac_addr (port_id) (address)\n"
571 " Set the MAC address of a bonded device.\n\n"
573 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
574 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
576 "set bonding mon_period (port_id) (value)\n"
577 " Set the bonding link status monitoring polling period in ms.\n\n"
579 "set link-up port (port_id)\n"
580 " Set link up for a port.\n\n"
582 "set link-down port (port_id)\n"
583 " Set link down for a port.\n\n"
585 "E-tag set insertion on port-tag-id (value)"
586 " port (port_id) vf (vf_id)\n"
587 " Enable E-tag insertion for a VF on a port\n\n"
589 "E-tag set insertion off port (port_id) vf (vf_id)\n"
590 " Disable E-tag insertion for a VF on a port\n\n"
592 "E-tag set stripping (on|off) port (port_id)\n"
593 " Enable/disable E-tag stripping on a port\n\n"
595 "E-tag set forwarding (on|off) port (port_id)\n"
596 " Enable/disable E-tag based forwarding"
599 "E-tag set filter add e-tag-id (value) dst-pool"
600 " (pool_id) port (port_id)\n"
601 " Add an E-tag forwarding filter on a port\n\n"
603 "E-tag set filter del e-tag-id (value) port (port_id)\n"
604 " Delete an E-tag forwarding filter on a port\n\n"
606 "ddp add (port_id) (profile_path[,output_path])\n"
607 " Load a profile package on a port\n\n"
609 "ddp del (port_id) (profile_path)\n"
610 " Delete a profile package from a port\n\n"
612 "ptype mapping get (port_id) (valid_only)\n"
613 " Get ptype mapping on a port\n\n"
615 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
616 " Replace target with the pkt_type in ptype mapping\n\n"
618 "ptype mapping reset (port_id)\n"
619 " Reset ptype mapping on a port\n\n"
621 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
622 " Update a ptype mapping item on a port\n\n"
624 , list_pkt_forwarding_modes()
628 if (show_all || !strcmp(res->section, "ports")) {
634 "----------------\n\n"
636 "port start (port_id|all)\n"
637 " Start all ports or port_id.\n\n"
639 "port stop (port_id|all)\n"
640 " Stop all ports or port_id.\n\n"
642 "port close (port_id|all)\n"
643 " Close all ports or port_id.\n\n"
645 "port attach (ident)\n"
646 " Attach physical or virtual dev by pci address or virtual device name\n\n"
648 "port detach (port_id)\n"
649 " Detach physical or virtual dev by port_id\n\n"
651 "port config (port_id|all)"
652 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
653 " duplex (half|full|auto)\n"
654 " Set speed and duplex for all ports or port_id\n\n"
656 "port config all (rxq|txq|rxd|txd) (value)\n"
657 " Set number for rxq/txq/rxd/txd.\n\n"
659 "port config all max-pkt-len (value)\n"
660 " Set the max packet length.\n\n"
662 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
663 "hw-vlan-strip|hw-vlan-extend|drop-en)"
665 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
668 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
669 " Set the RSS mode.\n\n"
671 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
672 " Set the RSS redirection table.\n\n"
674 "port config (port_id) dcb vt (on|off) (traffic_class)"
676 " Set the DCB mode.\n\n"
678 "port config all burst (value)\n"
679 " Set the number of packets per burst.\n\n"
681 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
683 " Set the ring prefetch/host/writeback threshold"
684 " for tx/rx queue.\n\n"
686 "port config all (txfreet|txrst|rxfreet) (value)\n"
687 " Set free threshold for rx/tx, or set"
688 " tx rs bit threshold.\n\n"
689 "port config mtu X value\n"
690 " Set the MTU of port X to a given value\n\n"
692 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
693 " Start/stop a rx/tx queue of port X. Only take effect"
694 " when port X is started\n\n"
696 "port config (port_id|all) l2-tunnel E-tag ether-type"
698 " Set the value of E-tag ether-type.\n\n"
700 "port config (port_id|all) l2-tunnel E-tag"
701 " (enable|disable)\n"
702 " Enable/disable the E-tag support.\n\n"
706 if (show_all || !strcmp(res->section, "registers")) {
714 "read reg (port_id) (address)\n"
715 " Display value of a port register.\n\n"
717 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
718 " Display a port register bit field.\n\n"
720 "read regbit (port_id) (address) (bit_x)\n"
721 " Display a single port register bit.\n\n"
723 "write reg (port_id) (address) (value)\n"
724 " Set value of a port register.\n\n"
726 "write regfield (port_id) (address) (bit_x) (bit_y)"
728 " Set bit field of a port register.\n\n"
730 "write regbit (port_id) (address) (bit_x) (value)\n"
731 " Set single bit value of a port register.\n\n"
734 if (show_all || !strcmp(res->section, "filters")) {
742 "ethertype_filter (port_id) (add|del)"
743 " (mac_addr|mac_ignr) (mac_address) ethertype"
744 " (ether_type) (drop|fwd) queue (queue_id)\n"
745 " Add/Del an ethertype filter.\n\n"
747 "2tuple_filter (port_id) (add|del)"
748 " dst_port (dst_port_value) protocol (protocol_value)"
749 " mask (mask_value) tcp_flags (tcp_flags_value)"
750 " priority (prio_value) queue (queue_id)\n"
751 " Add/Del a 2tuple filter.\n\n"
753 "5tuple_filter (port_id) (add|del)"
754 " dst_ip (dst_address) src_ip (src_address)"
755 " dst_port (dst_port_value) src_port (src_port_value)"
756 " protocol (protocol_value)"
757 " mask (mask_value) tcp_flags (tcp_flags_value)"
758 " priority (prio_value) queue (queue_id)\n"
759 " Add/Del a 5tuple filter.\n\n"
761 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
762 " Add/Del syn filter.\n\n"
764 "flex_filter (port_id) (add|del) len (len_value)"
765 " bytes (bytes_value) mask (mask_value)"
766 " priority (prio_value) queue (queue_id)\n"
767 " Add/Del a flex filter.\n\n"
769 "flow_director_filter (port_id) mode IP (add|del|update)"
770 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
771 " src (src_ip_address) dst (dst_ip_address)"
772 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
773 " vlan (vlan_value) flexbytes (flexbytes_value)"
774 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
775 " fd_id (fd_id_value)\n"
776 " Add/Del an IP type flow director filter.\n\n"
778 "flow_director_filter (port_id) mode IP (add|del|update)"
779 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
780 " src (src_ip_address) (src_port)"
781 " dst (dst_ip_address) (dst_port)"
782 " tos (tos_value) ttl (ttl_value)"
783 " vlan (vlan_value) flexbytes (flexbytes_value)"
784 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
785 " fd_id (fd_id_value)\n"
786 " Add/Del an UDP/TCP type flow director filter.\n\n"
788 "flow_director_filter (port_id) mode IP (add|del|update)"
789 " flow (ipv4-sctp|ipv6-sctp)"
790 " src (src_ip_address) (src_port)"
791 " dst (dst_ip_address) (dst_port)"
792 " tag (verification_tag) "
793 " tos (tos_value) ttl (ttl_value)"
795 " flexbytes (flexbytes_value) (drop|fwd)"
796 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
797 " Add/Del a SCTP type flow director filter.\n\n"
799 "flow_director_filter (port_id) mode IP (add|del|update)"
800 " flow l2_payload ether (ethertype)"
801 " flexbytes (flexbytes_value) (drop|fwd)"
802 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
803 " Add/Del a l2 payload type flow director filter.\n\n"
805 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
806 " mac (mac_address) vlan (vlan_value)"
807 " flexbytes (flexbytes_value) (drop|fwd)"
808 " queue (queue_id) fd_id (fd_id_value)\n"
809 " Add/Del a MAC-VLAN flow director filter.\n\n"
811 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
812 " mac (mac_address) vlan (vlan_value)"
813 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
814 " flexbytes (flexbytes_value) (drop|fwd)"
815 " queue (queue_id) fd_id (fd_id_value)\n"
816 " Add/Del a Tunnel flow director filter.\n\n"
818 "flush_flow_director (port_id)\n"
819 " Flush all flow director entries of a device.\n\n"
821 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
822 " src_mask (ipv4_src) (ipv6_src) (src_port)"
823 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
824 " Set flow director IP mask.\n\n"
826 "flow_director_mask (port_id) mode MAC-VLAN"
827 " vlan (vlan_value)\n"
828 " Set flow director MAC-VLAN mask.\n\n"
830 "flow_director_mask (port_id) mode Tunnel"
831 " vlan (vlan_value) mac (mac_value)"
832 " tunnel-type (tunnel_type_value)"
833 " tunnel-id (tunnel_id_value)\n"
834 " Set flow director Tunnel mask.\n\n"
836 "flow_director_flex_mask (port_id)"
837 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
838 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
840 " Configure mask of flex payload.\n\n"
842 "flow_director_flex_payload (port_id)"
843 " (raw|l2|l3|l4) (config)\n"
844 " Configure flex payload selection.\n\n"
846 "get_sym_hash_ena_per_port (port_id)\n"
847 " get symmetric hash enable configuration per port.\n\n"
849 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
850 " set symmetric hash enable configuration per port"
851 " to enable or disable.\n\n"
853 "get_hash_global_config (port_id)\n"
854 " Get the global configurations of hash filters.\n\n"
856 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
857 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
858 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
859 " (enable|disable)\n"
860 " Set the global configurations of hash filters.\n\n"
862 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
863 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
864 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
865 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
866 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
867 "ipv6-next-header|udp-src-port|udp-dst-port|"
868 "tcp-src-port|tcp-dst-port|sctp-src-port|"
869 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
870 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
871 "fld-8th|none) (select|add)\n"
872 " Set the input set for hash.\n\n"
874 "set_fdir_input_set (port_id) "
875 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
876 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
877 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
878 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
879 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
880 "udp-dst-port|tcp-src-port|tcp-dst-port|"
881 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
883 " Set the input set for FDir.\n\n"
885 "flow validate {port_id}"
886 " [group {group_id}] [priority {level}]"
887 " [ingress] [egress]"
888 " pattern {item} [/ {item} [...]] / end"
889 " actions {action} [/ {action} [...]] / end\n"
890 " Check whether a flow rule can be created.\n\n"
892 "flow create {port_id}"
893 " [group {group_id}] [priority {level}]"
894 " [ingress] [egress]"
895 " pattern {item} [/ {item} [...]] / end"
896 " actions {action} [/ {action} [...]] / end\n"
897 " Create a flow rule.\n\n"
899 "flow destroy {port_id} rule {rule_id} [...]\n"
900 " Destroy specific flow rules.\n\n"
902 "flow flush {port_id}\n"
903 " Destroy all flow rules.\n\n"
905 "flow query {port_id} {rule_id} {action}\n"
906 " Query an existing flow rule.\n\n"
908 "flow list {port_id} [group {group_id}] [...]\n"
909 " List existing flow rules sorted by priority,"
910 " filtered by group identifiers.\n\n"
912 "flow isolate {port_id} {boolean}\n"
913 " Restrict ingress traffic to the defined"
919 cmdline_parse_token_string_t cmd_help_long_help =
920 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
922 cmdline_parse_token_string_t cmd_help_long_section =
923 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
924 "all#control#display#config#"
925 "ports#registers#filters");
927 cmdline_parse_inst_t cmd_help_long = {
928 .f = cmd_help_long_parsed,
930 .help_str = "help all|control|display|config|ports|register|filters: "
933 (void *)&cmd_help_long_help,
934 (void *)&cmd_help_long_section,
940 /* *** start/stop/close all ports *** */
941 struct cmd_operate_port_result {
942 cmdline_fixed_string_t keyword;
943 cmdline_fixed_string_t name;
944 cmdline_fixed_string_t value;
947 static void cmd_operate_port_parsed(void *parsed_result,
948 __attribute__((unused)) struct cmdline *cl,
949 __attribute__((unused)) void *data)
951 struct cmd_operate_port_result *res = parsed_result;
953 if (!strcmp(res->name, "start"))
954 start_port(RTE_PORT_ALL);
955 else if (!strcmp(res->name, "stop"))
956 stop_port(RTE_PORT_ALL);
957 else if (!strcmp(res->name, "close"))
958 close_port(RTE_PORT_ALL);
960 printf("Unknown parameter\n");
963 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
964 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
966 cmdline_parse_token_string_t cmd_operate_port_all_port =
967 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
969 cmdline_parse_token_string_t cmd_operate_port_all_all =
970 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
972 cmdline_parse_inst_t cmd_operate_port = {
973 .f = cmd_operate_port_parsed,
975 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
977 (void *)&cmd_operate_port_all_cmd,
978 (void *)&cmd_operate_port_all_port,
979 (void *)&cmd_operate_port_all_all,
984 /* *** start/stop/close specific port *** */
985 struct cmd_operate_specific_port_result {
986 cmdline_fixed_string_t keyword;
987 cmdline_fixed_string_t name;
991 static void cmd_operate_specific_port_parsed(void *parsed_result,
992 __attribute__((unused)) struct cmdline *cl,
993 __attribute__((unused)) void *data)
995 struct cmd_operate_specific_port_result *res = parsed_result;
997 if (!strcmp(res->name, "start"))
998 start_port(res->value);
999 else if (!strcmp(res->name, "stop"))
1000 stop_port(res->value);
1001 else if (!strcmp(res->name, "close"))
1002 close_port(res->value);
1004 printf("Unknown parameter\n");
1007 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1008 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1010 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1011 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1012 name, "start#stop#close");
1013 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1014 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1017 cmdline_parse_inst_t cmd_operate_specific_port = {
1018 .f = cmd_operate_specific_port_parsed,
1020 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1022 (void *)&cmd_operate_specific_port_cmd,
1023 (void *)&cmd_operate_specific_port_port,
1024 (void *)&cmd_operate_specific_port_id,
1029 /* *** attach a specified port *** */
1030 struct cmd_operate_attach_port_result {
1031 cmdline_fixed_string_t port;
1032 cmdline_fixed_string_t keyword;
1033 cmdline_fixed_string_t identifier;
1036 static void cmd_operate_attach_port_parsed(void *parsed_result,
1037 __attribute__((unused)) struct cmdline *cl,
1038 __attribute__((unused)) void *data)
1040 struct cmd_operate_attach_port_result *res = parsed_result;
1042 if (!strcmp(res->keyword, "attach"))
1043 attach_port(res->identifier);
1045 printf("Unknown parameter\n");
1048 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1049 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1051 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1052 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1054 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1055 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1058 cmdline_parse_inst_t cmd_operate_attach_port = {
1059 .f = cmd_operate_attach_port_parsed,
1061 .help_str = "port attach <identifier>: "
1062 "(identifier: pci address or virtual dev name)",
1064 (void *)&cmd_operate_attach_port_port,
1065 (void *)&cmd_operate_attach_port_keyword,
1066 (void *)&cmd_operate_attach_port_identifier,
1071 /* *** detach a specified port *** */
1072 struct cmd_operate_detach_port_result {
1073 cmdline_fixed_string_t port;
1074 cmdline_fixed_string_t keyword;
1078 static void cmd_operate_detach_port_parsed(void *parsed_result,
1079 __attribute__((unused)) struct cmdline *cl,
1080 __attribute__((unused)) void *data)
1082 struct cmd_operate_detach_port_result *res = parsed_result;
1084 if (!strcmp(res->keyword, "detach"))
1085 detach_port(res->port_id);
1087 printf("Unknown parameter\n");
1090 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1091 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1093 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1094 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1096 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1097 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1100 cmdline_parse_inst_t cmd_operate_detach_port = {
1101 .f = cmd_operate_detach_port_parsed,
1103 .help_str = "port detach <port_id>",
1105 (void *)&cmd_operate_detach_port_port,
1106 (void *)&cmd_operate_detach_port_keyword,
1107 (void *)&cmd_operate_detach_port_port_id,
1112 /* *** configure speed for all ports *** */
1113 struct cmd_config_speed_all {
1114 cmdline_fixed_string_t port;
1115 cmdline_fixed_string_t keyword;
1116 cmdline_fixed_string_t all;
1117 cmdline_fixed_string_t item1;
1118 cmdline_fixed_string_t item2;
1119 cmdline_fixed_string_t value1;
1120 cmdline_fixed_string_t value2;
1124 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1129 if (!strcmp(duplexstr, "half")) {
1130 duplex = ETH_LINK_HALF_DUPLEX;
1131 } else if (!strcmp(duplexstr, "full")) {
1132 duplex = ETH_LINK_FULL_DUPLEX;
1133 } else if (!strcmp(duplexstr, "auto")) {
1134 duplex = ETH_LINK_FULL_DUPLEX;
1136 printf("Unknown duplex parameter\n");
1140 if (!strcmp(speedstr, "10")) {
1141 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1142 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1143 } else if (!strcmp(speedstr, "100")) {
1144 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1145 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1147 if (duplex != ETH_LINK_FULL_DUPLEX) {
1148 printf("Invalid speed/duplex parameters\n");
1151 if (!strcmp(speedstr, "1000")) {
1152 *speed = ETH_LINK_SPEED_1G;
1153 } else if (!strcmp(speedstr, "10000")) {
1154 *speed = ETH_LINK_SPEED_10G;
1155 } else if (!strcmp(speedstr, "25000")) {
1156 *speed = ETH_LINK_SPEED_25G;
1157 } else if (!strcmp(speedstr, "40000")) {
1158 *speed = ETH_LINK_SPEED_40G;
1159 } else if (!strcmp(speedstr, "50000")) {
1160 *speed = ETH_LINK_SPEED_50G;
1161 } else if (!strcmp(speedstr, "100000")) {
1162 *speed = ETH_LINK_SPEED_100G;
1163 } else if (!strcmp(speedstr, "auto")) {
1164 *speed = ETH_LINK_SPEED_AUTONEG;
1166 printf("Unknown speed parameter\n");
1175 cmd_config_speed_all_parsed(void *parsed_result,
1176 __attribute__((unused)) struct cmdline *cl,
1177 __attribute__((unused)) void *data)
1179 struct cmd_config_speed_all *res = parsed_result;
1180 uint32_t link_speed;
1183 if (!all_ports_stopped()) {
1184 printf("Please stop all ports first\n");
1188 if (parse_and_check_speed_duplex(res->value1, res->value2,
1192 RTE_ETH_FOREACH_DEV(pid) {
1193 ports[pid].dev_conf.link_speeds = link_speed;
1196 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1199 cmdline_parse_token_string_t cmd_config_speed_all_port =
1200 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1201 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1202 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1204 cmdline_parse_token_string_t cmd_config_speed_all_all =
1205 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1206 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1207 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1208 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1209 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1210 "10#100#1000#10000#25000#40000#50000#100000#auto");
1211 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1212 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1213 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1214 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1217 cmdline_parse_inst_t cmd_config_speed_all = {
1218 .f = cmd_config_speed_all_parsed,
1220 .help_str = "port config all speed "
1221 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1224 (void *)&cmd_config_speed_all_port,
1225 (void *)&cmd_config_speed_all_keyword,
1226 (void *)&cmd_config_speed_all_all,
1227 (void *)&cmd_config_speed_all_item1,
1228 (void *)&cmd_config_speed_all_value1,
1229 (void *)&cmd_config_speed_all_item2,
1230 (void *)&cmd_config_speed_all_value2,
1235 /* *** configure speed for specific port *** */
1236 struct cmd_config_speed_specific {
1237 cmdline_fixed_string_t port;
1238 cmdline_fixed_string_t keyword;
1240 cmdline_fixed_string_t item1;
1241 cmdline_fixed_string_t item2;
1242 cmdline_fixed_string_t value1;
1243 cmdline_fixed_string_t value2;
1247 cmd_config_speed_specific_parsed(void *parsed_result,
1248 __attribute__((unused)) struct cmdline *cl,
1249 __attribute__((unused)) void *data)
1251 struct cmd_config_speed_specific *res = parsed_result;
1252 uint32_t link_speed;
1254 if (!all_ports_stopped()) {
1255 printf("Please stop all ports first\n");
1259 if (port_id_is_invalid(res->id, ENABLED_WARN))
1262 if (parse_and_check_speed_duplex(res->value1, res->value2,
1266 ports[res->id].dev_conf.link_speeds = link_speed;
1268 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1272 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1273 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1275 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1276 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1278 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1279 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1280 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1283 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1284 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1285 "10#100#1000#10000#25000#40000#50000#100000#auto");
1286 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1287 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1289 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1290 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1293 cmdline_parse_inst_t cmd_config_speed_specific = {
1294 .f = cmd_config_speed_specific_parsed,
1296 .help_str = "port config <port_id> speed "
1297 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1300 (void *)&cmd_config_speed_specific_port,
1301 (void *)&cmd_config_speed_specific_keyword,
1302 (void *)&cmd_config_speed_specific_id,
1303 (void *)&cmd_config_speed_specific_item1,
1304 (void *)&cmd_config_speed_specific_value1,
1305 (void *)&cmd_config_speed_specific_item2,
1306 (void *)&cmd_config_speed_specific_value2,
1311 /* *** configure txq/rxq, txd/rxd *** */
1312 struct cmd_config_rx_tx {
1313 cmdline_fixed_string_t port;
1314 cmdline_fixed_string_t keyword;
1315 cmdline_fixed_string_t all;
1316 cmdline_fixed_string_t name;
1321 cmd_config_rx_tx_parsed(void *parsed_result,
1322 __attribute__((unused)) struct cmdline *cl,
1323 __attribute__((unused)) void *data)
1325 struct cmd_config_rx_tx *res = parsed_result;
1327 if (!all_ports_stopped()) {
1328 printf("Please stop all ports first\n");
1331 if (!strcmp(res->name, "rxq")) {
1332 if (!res->value && !nb_txq) {
1333 printf("Warning: Either rx or tx queues should be non zero\n");
1336 nb_rxq = res->value;
1338 else if (!strcmp(res->name, "txq")) {
1339 if (!res->value && !nb_rxq) {
1340 printf("Warning: Either rx or tx queues should be non zero\n");
1343 nb_txq = res->value;
1345 else if (!strcmp(res->name, "rxd")) {
1346 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1347 printf("rxd %d invalid - must be > 0 && <= %d\n",
1348 res->value, RTE_TEST_RX_DESC_MAX);
1351 nb_rxd = res->value;
1352 } else if (!strcmp(res->name, "txd")) {
1353 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1354 printf("txd %d invalid - must be > 0 && <= %d\n",
1355 res->value, RTE_TEST_TX_DESC_MAX);
1358 nb_txd = res->value;
1360 printf("Unknown parameter\n");
1368 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1371 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1372 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1373 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1374 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1375 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1376 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1377 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1378 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1380 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1381 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1383 cmdline_parse_inst_t cmd_config_rx_tx = {
1384 .f = cmd_config_rx_tx_parsed,
1386 .help_str = "port config all rxq|txq|rxd|txd <value>",
1388 (void *)&cmd_config_rx_tx_port,
1389 (void *)&cmd_config_rx_tx_keyword,
1390 (void *)&cmd_config_rx_tx_all,
1391 (void *)&cmd_config_rx_tx_name,
1392 (void *)&cmd_config_rx_tx_value,
1397 /* *** config max packet length *** */
1398 struct cmd_config_max_pkt_len_result {
1399 cmdline_fixed_string_t port;
1400 cmdline_fixed_string_t keyword;
1401 cmdline_fixed_string_t all;
1402 cmdline_fixed_string_t name;
1407 cmd_config_max_pkt_len_parsed(void *parsed_result,
1408 __attribute__((unused)) struct cmdline *cl,
1409 __attribute__((unused)) void *data)
1411 struct cmd_config_max_pkt_len_result *res = parsed_result;
1413 if (!all_ports_stopped()) {
1414 printf("Please stop all ports first\n");
1418 if (!strcmp(res->name, "max-pkt-len")) {
1419 if (res->value < ETHER_MIN_LEN) {
1420 printf("max-pkt-len can not be less than %d\n",
1424 if (res->value == rx_mode.max_rx_pkt_len)
1427 rx_mode.max_rx_pkt_len = res->value;
1428 if (res->value > ETHER_MAX_LEN)
1429 rx_mode.jumbo_frame = 1;
1431 rx_mode.jumbo_frame = 0;
1433 printf("Unknown parameter\n");
1439 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1442 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1443 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1445 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1446 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1448 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1449 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1451 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1452 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1454 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1455 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1458 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1459 .f = cmd_config_max_pkt_len_parsed,
1461 .help_str = "port config all max-pkt-len <value>",
1463 (void *)&cmd_config_max_pkt_len_port,
1464 (void *)&cmd_config_max_pkt_len_keyword,
1465 (void *)&cmd_config_max_pkt_len_all,
1466 (void *)&cmd_config_max_pkt_len_name,
1467 (void *)&cmd_config_max_pkt_len_value,
1472 /* *** configure port MTU *** */
1473 struct cmd_config_mtu_result {
1474 cmdline_fixed_string_t port;
1475 cmdline_fixed_string_t keyword;
1476 cmdline_fixed_string_t mtu;
1482 cmd_config_mtu_parsed(void *parsed_result,
1483 __attribute__((unused)) struct cmdline *cl,
1484 __attribute__((unused)) void *data)
1486 struct cmd_config_mtu_result *res = parsed_result;
1488 if (res->value < ETHER_MIN_LEN) {
1489 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1492 port_mtu_set(res->port_id, res->value);
1495 cmdline_parse_token_string_t cmd_config_mtu_port =
1496 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1498 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1499 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1501 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1502 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1504 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1505 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1506 cmdline_parse_token_num_t cmd_config_mtu_value =
1507 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1509 cmdline_parse_inst_t cmd_config_mtu = {
1510 .f = cmd_config_mtu_parsed,
1512 .help_str = "port config mtu <port_id> <value>",
1514 (void *)&cmd_config_mtu_port,
1515 (void *)&cmd_config_mtu_keyword,
1516 (void *)&cmd_config_mtu_mtu,
1517 (void *)&cmd_config_mtu_port_id,
1518 (void *)&cmd_config_mtu_value,
1523 /* *** configure rx mode *** */
1524 struct cmd_config_rx_mode_flag {
1525 cmdline_fixed_string_t port;
1526 cmdline_fixed_string_t keyword;
1527 cmdline_fixed_string_t all;
1528 cmdline_fixed_string_t name;
1529 cmdline_fixed_string_t value;
1533 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1534 __attribute__((unused)) struct cmdline *cl,
1535 __attribute__((unused)) void *data)
1537 struct cmd_config_rx_mode_flag *res = parsed_result;
1539 if (!all_ports_stopped()) {
1540 printf("Please stop all ports first\n");
1544 if (!strcmp(res->name, "crc-strip")) {
1545 if (!strcmp(res->value, "on"))
1546 rx_mode.hw_strip_crc = 1;
1547 else if (!strcmp(res->value, "off"))
1548 rx_mode.hw_strip_crc = 0;
1550 printf("Unknown parameter\n");
1553 } else if (!strcmp(res->name, "scatter")) {
1554 if (!strcmp(res->value, "on"))
1555 rx_mode.enable_scatter = 1;
1556 else if (!strcmp(res->value, "off"))
1557 rx_mode.enable_scatter = 0;
1559 printf("Unknown parameter\n");
1562 } else if (!strcmp(res->name, "rx-cksum")) {
1563 if (!strcmp(res->value, "on"))
1564 rx_mode.hw_ip_checksum = 1;
1565 else if (!strcmp(res->value, "off"))
1566 rx_mode.hw_ip_checksum = 0;
1568 printf("Unknown parameter\n");
1571 } else if (!strcmp(res->name, "hw-vlan")) {
1572 if (!strcmp(res->value, "on")) {
1573 rx_mode.hw_vlan_filter = 1;
1574 rx_mode.hw_vlan_strip = 1;
1576 else if (!strcmp(res->value, "off")) {
1577 rx_mode.hw_vlan_filter = 0;
1578 rx_mode.hw_vlan_strip = 0;
1581 printf("Unknown parameter\n");
1584 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1585 if (!strcmp(res->value, "on"))
1586 rx_mode.hw_vlan_filter = 1;
1587 else if (!strcmp(res->value, "off"))
1588 rx_mode.hw_vlan_filter = 0;
1590 printf("Unknown parameter\n");
1593 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1594 if (!strcmp(res->value, "on"))
1595 rx_mode.hw_vlan_strip = 1;
1596 else if (!strcmp(res->value, "off"))
1597 rx_mode.hw_vlan_strip = 0;
1599 printf("Unknown parameter\n");
1602 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1603 if (!strcmp(res->value, "on"))
1604 rx_mode.hw_vlan_extend = 1;
1605 else if (!strcmp(res->value, "off"))
1606 rx_mode.hw_vlan_extend = 0;
1608 printf("Unknown parameter\n");
1611 } else if (!strcmp(res->name, "drop-en")) {
1612 if (!strcmp(res->value, "on"))
1614 else if (!strcmp(res->value, "off"))
1617 printf("Unknown parameter\n");
1621 printf("Unknown parameter\n");
1627 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1630 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1632 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1635 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1636 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1637 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1638 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1639 "crc-strip#scatter#rx-cksum#hw-vlan#"
1640 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1641 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1645 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1646 .f = cmd_config_rx_mode_flag_parsed,
1648 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1649 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1651 (void *)&cmd_config_rx_mode_flag_port,
1652 (void *)&cmd_config_rx_mode_flag_keyword,
1653 (void *)&cmd_config_rx_mode_flag_all,
1654 (void *)&cmd_config_rx_mode_flag_name,
1655 (void *)&cmd_config_rx_mode_flag_value,
1660 /* *** configure rss *** */
1661 struct cmd_config_rss {
1662 cmdline_fixed_string_t port;
1663 cmdline_fixed_string_t keyword;
1664 cmdline_fixed_string_t all;
1665 cmdline_fixed_string_t name;
1666 cmdline_fixed_string_t value;
1670 cmd_config_rss_parsed(void *parsed_result,
1671 __attribute__((unused)) struct cmdline *cl,
1672 __attribute__((unused)) void *data)
1674 struct cmd_config_rss *res = parsed_result;
1675 struct rte_eth_rss_conf rss_conf;
1679 if (!strcmp(res->value, "all"))
1680 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1681 ETH_RSS_UDP | ETH_RSS_SCTP |
1683 else if (!strcmp(res->value, "ip"))
1684 rss_conf.rss_hf = ETH_RSS_IP;
1685 else if (!strcmp(res->value, "udp"))
1686 rss_conf.rss_hf = ETH_RSS_UDP;
1687 else if (!strcmp(res->value, "tcp"))
1688 rss_conf.rss_hf = ETH_RSS_TCP;
1689 else if (!strcmp(res->value, "sctp"))
1690 rss_conf.rss_hf = ETH_RSS_SCTP;
1691 else if (!strcmp(res->value, "ether"))
1692 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1693 else if (!strcmp(res->value, "port"))
1694 rss_conf.rss_hf = ETH_RSS_PORT;
1695 else if (!strcmp(res->value, "vxlan"))
1696 rss_conf.rss_hf = ETH_RSS_VXLAN;
1697 else if (!strcmp(res->value, "geneve"))
1698 rss_conf.rss_hf = ETH_RSS_GENEVE;
1699 else if (!strcmp(res->value, "nvgre"))
1700 rss_conf.rss_hf = ETH_RSS_NVGRE;
1701 else if (!strcmp(res->value, "none"))
1702 rss_conf.rss_hf = 0;
1704 printf("Unknown parameter\n");
1707 rss_conf.rss_key = NULL;
1708 for (i = 0; i < rte_eth_dev_count(); i++) {
1709 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1711 printf("Configuration of RSS hash at ethernet port %d "
1712 "failed with error (%d): %s.\n",
1713 i, -diag, strerror(-diag));
1717 cmdline_parse_token_string_t cmd_config_rss_port =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1719 cmdline_parse_token_string_t cmd_config_rss_keyword =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1721 cmdline_parse_token_string_t cmd_config_rss_all =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1723 cmdline_parse_token_string_t cmd_config_rss_name =
1724 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1725 cmdline_parse_token_string_t cmd_config_rss_value =
1726 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1727 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1729 cmdline_parse_inst_t cmd_config_rss = {
1730 .f = cmd_config_rss_parsed,
1732 .help_str = "port config all rss "
1733 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1735 (void *)&cmd_config_rss_port,
1736 (void *)&cmd_config_rss_keyword,
1737 (void *)&cmd_config_rss_all,
1738 (void *)&cmd_config_rss_name,
1739 (void *)&cmd_config_rss_value,
1744 /* *** configure rss hash key *** */
1745 struct cmd_config_rss_hash_key {
1746 cmdline_fixed_string_t port;
1747 cmdline_fixed_string_t config;
1749 cmdline_fixed_string_t rss_hash_key;
1750 cmdline_fixed_string_t rss_type;
1751 cmdline_fixed_string_t key;
1755 hexa_digit_to_value(char hexa_digit)
1757 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1758 return (uint8_t) (hexa_digit - '0');
1759 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1760 return (uint8_t) ((hexa_digit - 'a') + 10);
1761 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1762 return (uint8_t) ((hexa_digit - 'A') + 10);
1763 /* Invalid hexa digit */
1768 parse_and_check_key_hexa_digit(char *key, int idx)
1772 hexa_v = hexa_digit_to_value(key[idx]);
1774 printf("invalid key: character %c at position %d is not a "
1775 "valid hexa digit\n", key[idx], idx);
1780 cmd_config_rss_hash_key_parsed(void *parsed_result,
1781 __attribute__((unused)) struct cmdline *cl,
1782 __attribute__((unused)) void *data)
1784 struct cmd_config_rss_hash_key *res = parsed_result;
1785 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1789 struct rte_eth_dev_info dev_info;
1790 uint8_t hash_key_size;
1793 memset(&dev_info, 0, sizeof(dev_info));
1794 rte_eth_dev_info_get(res->port_id, &dev_info);
1795 if (dev_info.hash_key_size > 0 &&
1796 dev_info.hash_key_size <= sizeof(hash_key))
1797 hash_key_size = dev_info.hash_key_size;
1799 printf("dev_info did not provide a valid hash key size\n");
1802 /* Check the length of the RSS hash key */
1803 key_len = strlen(res->key);
1804 if (key_len != (hash_key_size * 2)) {
1805 printf("key length: %d invalid - key must be a string of %d"
1806 " hexa-decimal numbers\n",
1807 (int) key_len, hash_key_size * 2);
1810 /* Translate RSS hash key into binary representation */
1811 for (i = 0; i < hash_key_size; i++) {
1812 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1815 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1818 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1820 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1824 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1825 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1826 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1827 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1829 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1830 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1831 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1833 rss_hash_key, "rss-hash-key");
1834 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1836 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1837 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1838 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1839 "ipv6-tcp-ex#ipv6-udp-ex");
1840 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1843 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1844 .f = cmd_config_rss_hash_key_parsed,
1846 .help_str = "port config <port_id> rss-hash-key "
1847 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1848 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1849 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1850 "<string of hex digits (variable length, NIC dependent)>",
1852 (void *)&cmd_config_rss_hash_key_port,
1853 (void *)&cmd_config_rss_hash_key_config,
1854 (void *)&cmd_config_rss_hash_key_port_id,
1855 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1856 (void *)&cmd_config_rss_hash_key_rss_type,
1857 (void *)&cmd_config_rss_hash_key_value,
1862 /* *** configure port rxq/txq start/stop *** */
1863 struct cmd_config_rxtx_queue {
1864 cmdline_fixed_string_t port;
1866 cmdline_fixed_string_t rxtxq;
1868 cmdline_fixed_string_t opname;
1872 cmd_config_rxtx_queue_parsed(void *parsed_result,
1873 __attribute__((unused)) struct cmdline *cl,
1874 __attribute__((unused)) void *data)
1876 struct cmd_config_rxtx_queue *res = parsed_result;
1881 if (test_done == 0) {
1882 printf("Please stop forwarding first\n");
1886 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1889 if (port_is_started(res->portid) != 1) {
1890 printf("Please start port %u first\n", res->portid);
1894 if (!strcmp(res->rxtxq, "rxq"))
1896 else if (!strcmp(res->rxtxq, "txq"))
1899 printf("Unknown parameter\n");
1903 if (isrx && rx_queue_id_is_invalid(res->qid))
1905 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1908 if (!strcmp(res->opname, "start"))
1910 else if (!strcmp(res->opname, "stop"))
1913 printf("Unknown parameter\n");
1917 if (isstart && isrx)
1918 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1919 else if (!isstart && isrx)
1920 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1921 else if (isstart && !isrx)
1922 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1924 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1926 if (ret == -ENOTSUP)
1927 printf("Function not supported in PMD driver\n");
1930 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1932 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1933 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1934 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1936 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1937 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1938 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1942 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1943 .f = cmd_config_rxtx_queue_parsed,
1945 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1947 (void *)&cmd_config_speed_all_port,
1948 (void *)&cmd_config_rxtx_queue_portid,
1949 (void *)&cmd_config_rxtx_queue_rxtxq,
1950 (void *)&cmd_config_rxtx_queue_qid,
1951 (void *)&cmd_config_rxtx_queue_opname,
1956 /* *** Configure RSS RETA *** */
1957 struct cmd_config_rss_reta {
1958 cmdline_fixed_string_t port;
1959 cmdline_fixed_string_t keyword;
1961 cmdline_fixed_string_t name;
1962 cmdline_fixed_string_t list_name;
1963 cmdline_fixed_string_t list_of_items;
1967 parse_reta_config(const char *str,
1968 struct rte_eth_rss_reta_entry64 *reta_conf,
1969 uint16_t nb_entries)
1973 uint16_t hash_index, idx, shift;
1976 const char *p, *p0 = str;
1983 unsigned long int_fld[_NUM_FLD];
1984 char *str_fld[_NUM_FLD];
1986 while ((p = strchr(p0,'(')) != NULL) {
1988 if((p0 = strchr(p,')')) == NULL)
1992 if(size >= sizeof(s))
1995 snprintf(s, sizeof(s), "%.*s", size, p);
1996 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1998 for (i = 0; i < _NUM_FLD; i++) {
2000 int_fld[i] = strtoul(str_fld[i], &end, 0);
2001 if (errno != 0 || end == str_fld[i] ||
2006 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2007 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2009 if (hash_index >= nb_entries) {
2010 printf("Invalid RETA hash index=%d\n", hash_index);
2014 idx = hash_index / RTE_RETA_GROUP_SIZE;
2015 shift = hash_index % RTE_RETA_GROUP_SIZE;
2016 reta_conf[idx].mask |= (1ULL << shift);
2017 reta_conf[idx].reta[shift] = nb_queue;
2024 cmd_set_rss_reta_parsed(void *parsed_result,
2025 __attribute__((unused)) struct cmdline *cl,
2026 __attribute__((unused)) void *data)
2029 struct rte_eth_dev_info dev_info;
2030 struct rte_eth_rss_reta_entry64 reta_conf[8];
2031 struct cmd_config_rss_reta *res = parsed_result;
2033 memset(&dev_info, 0, sizeof(dev_info));
2034 rte_eth_dev_info_get(res->port_id, &dev_info);
2035 if (dev_info.reta_size == 0) {
2036 printf("Redirection table size is 0 which is "
2037 "invalid for RSS\n");
2040 printf("The reta size of port %d is %u\n",
2041 res->port_id, dev_info.reta_size);
2042 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2043 printf("Currently do not support more than %u entries of "
2044 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2048 memset(reta_conf, 0, sizeof(reta_conf));
2049 if (!strcmp(res->list_name, "reta")) {
2050 if (parse_reta_config(res->list_of_items, reta_conf,
2051 dev_info.reta_size)) {
2052 printf("Invalid RSS Redirection Table "
2053 "config entered\n");
2056 ret = rte_eth_dev_rss_reta_update(res->port_id,
2057 reta_conf, dev_info.reta_size);
2059 printf("Bad redirection table parameter, "
2060 "return code = %d \n", ret);
2064 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2066 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2068 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2069 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2070 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2071 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2072 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2074 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2075 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2077 cmdline_parse_inst_t cmd_config_rss_reta = {
2078 .f = cmd_set_rss_reta_parsed,
2080 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2082 (void *)&cmd_config_rss_reta_port,
2083 (void *)&cmd_config_rss_reta_keyword,
2084 (void *)&cmd_config_rss_reta_port_id,
2085 (void *)&cmd_config_rss_reta_name,
2086 (void *)&cmd_config_rss_reta_list_name,
2087 (void *)&cmd_config_rss_reta_list_of_items,
2092 /* *** SHOW PORT RETA INFO *** */
2093 struct cmd_showport_reta {
2094 cmdline_fixed_string_t show;
2095 cmdline_fixed_string_t port;
2097 cmdline_fixed_string_t rss;
2098 cmdline_fixed_string_t reta;
2100 cmdline_fixed_string_t list_of_items;
2104 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2105 uint16_t nb_entries,
2109 const char *p, *p0 = str;
2114 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2115 RTE_RETA_GROUP_SIZE;
2118 p = strchr(p0, '(');
2122 p0 = strchr(p, ')');
2126 if (size >= sizeof(s)) {
2127 printf("The string size exceeds the internal buffer size\n");
2130 snprintf(s, sizeof(s), "%.*s", size, p);
2131 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2132 if (ret <= 0 || ret != num) {
2133 printf("The bits of masks do not match the number of "
2134 "reta entries: %u\n", num);
2137 for (i = 0; i < ret; i++)
2138 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2144 cmd_showport_reta_parsed(void *parsed_result,
2145 __attribute__((unused)) struct cmdline *cl,
2146 __attribute__((unused)) void *data)
2148 struct cmd_showport_reta *res = parsed_result;
2149 struct rte_eth_rss_reta_entry64 reta_conf[8];
2150 struct rte_eth_dev_info dev_info;
2152 memset(&dev_info, 0, sizeof(dev_info));
2153 rte_eth_dev_info_get(res->port_id, &dev_info);
2154 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2155 res->size > ETH_RSS_RETA_SIZE_512) {
2156 printf("Invalid redirection table size: %u\n", res->size);
2160 memset(reta_conf, 0, sizeof(reta_conf));
2161 if (showport_parse_reta_config(reta_conf, res->size,
2162 res->list_of_items) < 0) {
2163 printf("Invalid string: %s for reta masks\n",
2164 res->list_of_items);
2167 port_rss_reta_info(res->port_id, reta_conf, res->size);
2170 cmdline_parse_token_string_t cmd_showport_reta_show =
2171 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2172 cmdline_parse_token_string_t cmd_showport_reta_port =
2173 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2174 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2175 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2176 cmdline_parse_token_string_t cmd_showport_reta_rss =
2177 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2178 cmdline_parse_token_string_t cmd_showport_reta_reta =
2179 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2180 cmdline_parse_token_num_t cmd_showport_reta_size =
2181 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2182 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2183 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2184 list_of_items, NULL);
2186 cmdline_parse_inst_t cmd_showport_reta = {
2187 .f = cmd_showport_reta_parsed,
2189 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2191 (void *)&cmd_showport_reta_show,
2192 (void *)&cmd_showport_reta_port,
2193 (void *)&cmd_showport_reta_port_id,
2194 (void *)&cmd_showport_reta_rss,
2195 (void *)&cmd_showport_reta_reta,
2196 (void *)&cmd_showport_reta_size,
2197 (void *)&cmd_showport_reta_list_of_items,
2202 /* *** Show RSS hash configuration *** */
2203 struct cmd_showport_rss_hash {
2204 cmdline_fixed_string_t show;
2205 cmdline_fixed_string_t port;
2207 cmdline_fixed_string_t rss_hash;
2208 cmdline_fixed_string_t rss_type;
2209 cmdline_fixed_string_t key; /* optional argument */
2212 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2213 __attribute__((unused)) struct cmdline *cl,
2216 struct cmd_showport_rss_hash *res = parsed_result;
2218 port_rss_hash_conf_show(res->port_id, res->rss_type,
2219 show_rss_key != NULL);
2222 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2223 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2224 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2225 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2226 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2227 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2228 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2229 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2231 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2232 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2233 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2234 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2235 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2236 "ipv6-tcp-ex#ipv6-udp-ex");
2237 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2238 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2240 cmdline_parse_inst_t cmd_showport_rss_hash = {
2241 .f = cmd_showport_rss_hash_parsed,
2243 .help_str = "show port <port_id> rss-hash "
2244 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2245 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2246 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2248 (void *)&cmd_showport_rss_hash_show,
2249 (void *)&cmd_showport_rss_hash_port,
2250 (void *)&cmd_showport_rss_hash_port_id,
2251 (void *)&cmd_showport_rss_hash_rss_hash,
2252 (void *)&cmd_showport_rss_hash_rss_hash_info,
2257 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2258 .f = cmd_showport_rss_hash_parsed,
2260 .help_str = "show port <port_id> rss-hash "
2261 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2262 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2263 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2265 (void *)&cmd_showport_rss_hash_show,
2266 (void *)&cmd_showport_rss_hash_port,
2267 (void *)&cmd_showport_rss_hash_port_id,
2268 (void *)&cmd_showport_rss_hash_rss_hash,
2269 (void *)&cmd_showport_rss_hash_rss_hash_info,
2270 (void *)&cmd_showport_rss_hash_rss_key,
2275 /* *** Configure DCB *** */
2276 struct cmd_config_dcb {
2277 cmdline_fixed_string_t port;
2278 cmdline_fixed_string_t config;
2280 cmdline_fixed_string_t dcb;
2281 cmdline_fixed_string_t vt;
2282 cmdline_fixed_string_t vt_en;
2284 cmdline_fixed_string_t pfc;
2285 cmdline_fixed_string_t pfc_en;
2289 cmd_config_dcb_parsed(void *parsed_result,
2290 __attribute__((unused)) struct cmdline *cl,
2291 __attribute__((unused)) void *data)
2293 struct cmd_config_dcb *res = parsed_result;
2294 portid_t port_id = res->port_id;
2295 struct rte_port *port;
2299 port = &ports[port_id];
2300 /** Check if the port is not started **/
2301 if (port->port_status != RTE_PORT_STOPPED) {
2302 printf("Please stop port %d first\n", port_id);
2306 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2307 printf("The invalid number of traffic class,"
2308 " only 4 or 8 allowed.\n");
2312 if (nb_fwd_lcores < res->num_tcs) {
2313 printf("nb_cores shouldn't be less than number of TCs.\n");
2316 if (!strncmp(res->pfc_en, "on", 2))
2321 /* DCB in VT mode */
2322 if (!strncmp(res->vt_en, "on", 2))
2323 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2324 (enum rte_eth_nb_tcs)res->num_tcs,
2327 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2328 (enum rte_eth_nb_tcs)res->num_tcs,
2333 printf("Cannot initialize network ports.\n");
2337 cmd_reconfig_device_queue(port_id, 1, 1);
2340 cmdline_parse_token_string_t cmd_config_dcb_port =
2341 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2342 cmdline_parse_token_string_t cmd_config_dcb_config =
2343 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2344 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2345 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2346 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2347 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2348 cmdline_parse_token_string_t cmd_config_dcb_vt =
2349 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2350 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2351 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2352 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2353 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2354 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2355 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2356 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2357 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2359 cmdline_parse_inst_t cmd_config_dcb = {
2360 .f = cmd_config_dcb_parsed,
2362 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2364 (void *)&cmd_config_dcb_port,
2365 (void *)&cmd_config_dcb_config,
2366 (void *)&cmd_config_dcb_port_id,
2367 (void *)&cmd_config_dcb_dcb,
2368 (void *)&cmd_config_dcb_vt,
2369 (void *)&cmd_config_dcb_vt_en,
2370 (void *)&cmd_config_dcb_num_tcs,
2371 (void *)&cmd_config_dcb_pfc,
2372 (void *)&cmd_config_dcb_pfc_en,
2377 /* *** configure number of packets per burst *** */
2378 struct cmd_config_burst {
2379 cmdline_fixed_string_t port;
2380 cmdline_fixed_string_t keyword;
2381 cmdline_fixed_string_t all;
2382 cmdline_fixed_string_t name;
2387 cmd_config_burst_parsed(void *parsed_result,
2388 __attribute__((unused)) struct cmdline *cl,
2389 __attribute__((unused)) void *data)
2391 struct cmd_config_burst *res = parsed_result;
2393 if (!all_ports_stopped()) {
2394 printf("Please stop all ports first\n");
2398 if (!strcmp(res->name, "burst")) {
2399 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2400 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2403 nb_pkt_per_burst = res->value;
2405 printf("Unknown parameter\n");
2411 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2414 cmdline_parse_token_string_t cmd_config_burst_port =
2415 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2416 cmdline_parse_token_string_t cmd_config_burst_keyword =
2417 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2418 cmdline_parse_token_string_t cmd_config_burst_all =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2420 cmdline_parse_token_string_t cmd_config_burst_name =
2421 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2422 cmdline_parse_token_num_t cmd_config_burst_value =
2423 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2425 cmdline_parse_inst_t cmd_config_burst = {
2426 .f = cmd_config_burst_parsed,
2428 .help_str = "port config all burst <value>",
2430 (void *)&cmd_config_burst_port,
2431 (void *)&cmd_config_burst_keyword,
2432 (void *)&cmd_config_burst_all,
2433 (void *)&cmd_config_burst_name,
2434 (void *)&cmd_config_burst_value,
2439 /* *** configure rx/tx queues *** */
2440 struct cmd_config_thresh {
2441 cmdline_fixed_string_t port;
2442 cmdline_fixed_string_t keyword;
2443 cmdline_fixed_string_t all;
2444 cmdline_fixed_string_t name;
2449 cmd_config_thresh_parsed(void *parsed_result,
2450 __attribute__((unused)) struct cmdline *cl,
2451 __attribute__((unused)) void *data)
2453 struct cmd_config_thresh *res = parsed_result;
2455 if (!all_ports_stopped()) {
2456 printf("Please stop all ports first\n");
2460 if (!strcmp(res->name, "txpt"))
2461 tx_pthresh = res->value;
2462 else if(!strcmp(res->name, "txht"))
2463 tx_hthresh = res->value;
2464 else if(!strcmp(res->name, "txwt"))
2465 tx_wthresh = res->value;
2466 else if(!strcmp(res->name, "rxpt"))
2467 rx_pthresh = res->value;
2468 else if(!strcmp(res->name, "rxht"))
2469 rx_hthresh = res->value;
2470 else if(!strcmp(res->name, "rxwt"))
2471 rx_wthresh = res->value;
2473 printf("Unknown parameter\n");
2479 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2482 cmdline_parse_token_string_t cmd_config_thresh_port =
2483 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2484 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2485 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2486 cmdline_parse_token_string_t cmd_config_thresh_all =
2487 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2488 cmdline_parse_token_string_t cmd_config_thresh_name =
2489 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2490 "txpt#txht#txwt#rxpt#rxht#rxwt");
2491 cmdline_parse_token_num_t cmd_config_thresh_value =
2492 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2494 cmdline_parse_inst_t cmd_config_thresh = {
2495 .f = cmd_config_thresh_parsed,
2497 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2499 (void *)&cmd_config_thresh_port,
2500 (void *)&cmd_config_thresh_keyword,
2501 (void *)&cmd_config_thresh_all,
2502 (void *)&cmd_config_thresh_name,
2503 (void *)&cmd_config_thresh_value,
2508 /* *** configure free/rs threshold *** */
2509 struct cmd_config_threshold {
2510 cmdline_fixed_string_t port;
2511 cmdline_fixed_string_t keyword;
2512 cmdline_fixed_string_t all;
2513 cmdline_fixed_string_t name;
2518 cmd_config_threshold_parsed(void *parsed_result,
2519 __attribute__((unused)) struct cmdline *cl,
2520 __attribute__((unused)) void *data)
2522 struct cmd_config_threshold *res = parsed_result;
2524 if (!all_ports_stopped()) {
2525 printf("Please stop all ports first\n");
2529 if (!strcmp(res->name, "txfreet"))
2530 tx_free_thresh = res->value;
2531 else if (!strcmp(res->name, "txrst"))
2532 tx_rs_thresh = res->value;
2533 else if (!strcmp(res->name, "rxfreet"))
2534 rx_free_thresh = res->value;
2536 printf("Unknown parameter\n");
2542 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2545 cmdline_parse_token_string_t cmd_config_threshold_port =
2546 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2547 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2548 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2550 cmdline_parse_token_string_t cmd_config_threshold_all =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2552 cmdline_parse_token_string_t cmd_config_threshold_name =
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2554 "txfreet#txrst#rxfreet");
2555 cmdline_parse_token_num_t cmd_config_threshold_value =
2556 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2558 cmdline_parse_inst_t cmd_config_threshold = {
2559 .f = cmd_config_threshold_parsed,
2561 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2563 (void *)&cmd_config_threshold_port,
2564 (void *)&cmd_config_threshold_keyword,
2565 (void *)&cmd_config_threshold_all,
2566 (void *)&cmd_config_threshold_name,
2567 (void *)&cmd_config_threshold_value,
2573 struct cmd_stop_result {
2574 cmdline_fixed_string_t stop;
2577 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2578 __attribute__((unused)) struct cmdline *cl,
2579 __attribute__((unused)) void *data)
2581 stop_packet_forwarding();
2584 cmdline_parse_token_string_t cmd_stop_stop =
2585 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2587 cmdline_parse_inst_t cmd_stop = {
2588 .f = cmd_stop_parsed,
2590 .help_str = "stop: Stop packet forwarding",
2592 (void *)&cmd_stop_stop,
2597 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2600 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2601 unsigned int *parsed_items, int check_unique_values)
2603 unsigned int nb_item;
2611 * First parse all items in the list and store their value.
2616 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2618 if ((c >= '0') && (c <= '9')) {
2619 value = (unsigned int) (value * 10 + (c - '0'));
2624 printf("character %c is not a decimal digit\n", c);
2628 printf("No valid value before comma\n");
2631 if (nb_item < max_items) {
2632 parsed_items[nb_item] = value;
2638 if (nb_item >= max_items) {
2639 printf("Number of %s = %u > %u (maximum items)\n",
2640 item_name, nb_item + 1, max_items);
2643 parsed_items[nb_item++] = value;
2644 if (! check_unique_values)
2648 * Then, check that all values in the list are differents.
2649 * No optimization here...
2651 for (i = 0; i < nb_item; i++) {
2652 for (j = i + 1; j < nb_item; j++) {
2653 if (parsed_items[j] == parsed_items[i]) {
2654 printf("duplicated %s %u at index %u and %u\n",
2655 item_name, parsed_items[i], i, j);
2663 struct cmd_set_list_result {
2664 cmdline_fixed_string_t cmd_keyword;
2665 cmdline_fixed_string_t list_name;
2666 cmdline_fixed_string_t list_of_items;
2669 static void cmd_set_list_parsed(void *parsed_result,
2670 __attribute__((unused)) struct cmdline *cl,
2671 __attribute__((unused)) void *data)
2673 struct cmd_set_list_result *res;
2675 unsigned int lcorelist[RTE_MAX_LCORE];
2676 unsigned int portlist[RTE_MAX_ETHPORTS];
2678 unsigned int nb_item;
2680 if (test_done == 0) {
2681 printf("Please stop forwarding first\n");
2685 res = parsed_result;
2686 if (!strcmp(res->list_name, "corelist")) {
2687 nb_item = parse_item_list(res->list_of_items, "core",
2689 parsed_items.lcorelist, 1);
2691 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2696 if (!strcmp(res->list_name, "portlist")) {
2697 nb_item = parse_item_list(res->list_of_items, "port",
2699 parsed_items.portlist, 1);
2701 set_fwd_ports_list(parsed_items.portlist, nb_item);
2707 cmdline_parse_token_string_t cmd_set_list_keyword =
2708 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2710 cmdline_parse_token_string_t cmd_set_list_name =
2711 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2712 "corelist#portlist");
2713 cmdline_parse_token_string_t cmd_set_list_of_items =
2714 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2717 cmdline_parse_inst_t cmd_set_fwd_list = {
2718 .f = cmd_set_list_parsed,
2720 .help_str = "set corelist|portlist <list0[,list1]*>",
2722 (void *)&cmd_set_list_keyword,
2723 (void *)&cmd_set_list_name,
2724 (void *)&cmd_set_list_of_items,
2729 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2731 struct cmd_setmask_result {
2732 cmdline_fixed_string_t set;
2733 cmdline_fixed_string_t mask;
2737 static void cmd_set_mask_parsed(void *parsed_result,
2738 __attribute__((unused)) struct cmdline *cl,
2739 __attribute__((unused)) void *data)
2741 struct cmd_setmask_result *res = parsed_result;
2743 if (test_done == 0) {
2744 printf("Please stop forwarding first\n");
2747 if (!strcmp(res->mask, "coremask")) {
2748 set_fwd_lcores_mask(res->hexavalue);
2750 } else if (!strcmp(res->mask, "portmask")) {
2751 set_fwd_ports_mask(res->hexavalue);
2756 cmdline_parse_token_string_t cmd_setmask_set =
2757 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2758 cmdline_parse_token_string_t cmd_setmask_mask =
2759 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2760 "coremask#portmask");
2761 cmdline_parse_token_num_t cmd_setmask_value =
2762 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2764 cmdline_parse_inst_t cmd_set_fwd_mask = {
2765 .f = cmd_set_mask_parsed,
2767 .help_str = "set coremask|portmask <hexadecimal value>",
2769 (void *)&cmd_setmask_set,
2770 (void *)&cmd_setmask_mask,
2771 (void *)&cmd_setmask_value,
2777 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2779 struct cmd_set_result {
2780 cmdline_fixed_string_t set;
2781 cmdline_fixed_string_t what;
2785 static void cmd_set_parsed(void *parsed_result,
2786 __attribute__((unused)) struct cmdline *cl,
2787 __attribute__((unused)) void *data)
2789 struct cmd_set_result *res = parsed_result;
2790 if (!strcmp(res->what, "nbport")) {
2791 set_fwd_ports_number(res->value);
2793 } else if (!strcmp(res->what, "nbcore")) {
2794 set_fwd_lcores_number(res->value);
2796 } else if (!strcmp(res->what, "burst"))
2797 set_nb_pkt_per_burst(res->value);
2798 else if (!strcmp(res->what, "verbose"))
2799 set_verbose_level(res->value);
2802 cmdline_parse_token_string_t cmd_set_set =
2803 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2804 cmdline_parse_token_string_t cmd_set_what =
2805 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2806 "nbport#nbcore#burst#verbose");
2807 cmdline_parse_token_num_t cmd_set_value =
2808 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2810 cmdline_parse_inst_t cmd_set_numbers = {
2811 .f = cmd_set_parsed,
2813 .help_str = "set nbport|nbcore|burst|verbose <value>",
2815 (void *)&cmd_set_set,
2816 (void *)&cmd_set_what,
2817 (void *)&cmd_set_value,
2822 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2824 struct cmd_set_txpkts_result {
2825 cmdline_fixed_string_t cmd_keyword;
2826 cmdline_fixed_string_t txpkts;
2827 cmdline_fixed_string_t seg_lengths;
2831 cmd_set_txpkts_parsed(void *parsed_result,
2832 __attribute__((unused)) struct cmdline *cl,
2833 __attribute__((unused)) void *data)
2835 struct cmd_set_txpkts_result *res;
2836 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2837 unsigned int nb_segs;
2839 res = parsed_result;
2840 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2841 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2843 set_tx_pkt_segments(seg_lengths, nb_segs);
2846 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2847 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2848 cmd_keyword, "set");
2849 cmdline_parse_token_string_t cmd_set_txpkts_name =
2850 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2852 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2853 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2856 cmdline_parse_inst_t cmd_set_txpkts = {
2857 .f = cmd_set_txpkts_parsed,
2859 .help_str = "set txpkts <len0[,len1]*>",
2861 (void *)&cmd_set_txpkts_keyword,
2862 (void *)&cmd_set_txpkts_name,
2863 (void *)&cmd_set_txpkts_lengths,
2868 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2870 struct cmd_set_txsplit_result {
2871 cmdline_fixed_string_t cmd_keyword;
2872 cmdline_fixed_string_t txsplit;
2873 cmdline_fixed_string_t mode;
2877 cmd_set_txsplit_parsed(void *parsed_result,
2878 __attribute__((unused)) struct cmdline *cl,
2879 __attribute__((unused)) void *data)
2881 struct cmd_set_txsplit_result *res;
2883 res = parsed_result;
2884 set_tx_pkt_split(res->mode);
2887 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2888 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2889 cmd_keyword, "set");
2890 cmdline_parse_token_string_t cmd_set_txsplit_name =
2891 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2892 txsplit, "txsplit");
2893 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2894 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2897 cmdline_parse_inst_t cmd_set_txsplit = {
2898 .f = cmd_set_txsplit_parsed,
2900 .help_str = "set txsplit on|off|rand",
2902 (void *)&cmd_set_txsplit_keyword,
2903 (void *)&cmd_set_txsplit_name,
2904 (void *)&cmd_set_txsplit_mode,
2909 /* *** CONFIG TX QUEUE FLAGS *** */
2911 struct cmd_config_txqflags_result {
2912 cmdline_fixed_string_t port;
2913 cmdline_fixed_string_t config;
2914 cmdline_fixed_string_t all;
2915 cmdline_fixed_string_t what;
2919 static void cmd_config_txqflags_parsed(void *parsed_result,
2920 __attribute__((unused)) struct cmdline *cl,
2921 __attribute__((unused)) void *data)
2923 struct cmd_config_txqflags_result *res = parsed_result;
2925 if (!all_ports_stopped()) {
2926 printf("Please stop all ports first\n");
2930 if (strcmp(res->what, "txqflags")) {
2931 printf("Unknown parameter\n");
2935 if (res->hexvalue >= 0) {
2936 txq_flags = res->hexvalue;
2938 printf("txqflags must be >= 0\n");
2944 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2947 cmdline_parse_token_string_t cmd_config_txqflags_port =
2948 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2950 cmdline_parse_token_string_t cmd_config_txqflags_config =
2951 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2953 cmdline_parse_token_string_t cmd_config_txqflags_all =
2954 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2956 cmdline_parse_token_string_t cmd_config_txqflags_what =
2957 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2959 cmdline_parse_token_num_t cmd_config_txqflags_value =
2960 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2963 cmdline_parse_inst_t cmd_config_txqflags = {
2964 .f = cmd_config_txqflags_parsed,
2966 .help_str = "port config all txqflags <value>",
2968 (void *)&cmd_config_txqflags_port,
2969 (void *)&cmd_config_txqflags_config,
2970 (void *)&cmd_config_txqflags_all,
2971 (void *)&cmd_config_txqflags_what,
2972 (void *)&cmd_config_txqflags_value,
2977 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2978 struct cmd_rx_vlan_filter_all_result {
2979 cmdline_fixed_string_t rx_vlan;
2980 cmdline_fixed_string_t what;
2981 cmdline_fixed_string_t all;
2986 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2987 __attribute__((unused)) struct cmdline *cl,
2988 __attribute__((unused)) void *data)
2990 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2992 if (!strcmp(res->what, "add"))
2993 rx_vlan_all_filter_set(res->port_id, 1);
2995 rx_vlan_all_filter_set(res->port_id, 0);
2998 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2999 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3000 rx_vlan, "rx_vlan");
3001 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3002 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3004 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3005 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3007 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3008 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3011 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3012 .f = cmd_rx_vlan_filter_all_parsed,
3014 .help_str = "rx_vlan add|rm all <port_id>: "
3015 "Add/Remove all identifiers to/from the set of VLAN "
3016 "identifiers filtered by a port",
3018 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3019 (void *)&cmd_rx_vlan_filter_all_what,
3020 (void *)&cmd_rx_vlan_filter_all_all,
3021 (void *)&cmd_rx_vlan_filter_all_portid,
3026 /* *** VLAN OFFLOAD SET ON A PORT *** */
3027 struct cmd_vlan_offload_result {
3028 cmdline_fixed_string_t vlan;
3029 cmdline_fixed_string_t set;
3030 cmdline_fixed_string_t vlan_type;
3031 cmdline_fixed_string_t what;
3032 cmdline_fixed_string_t on;
3033 cmdline_fixed_string_t port_id;
3037 cmd_vlan_offload_parsed(void *parsed_result,
3038 __attribute__((unused)) struct cmdline *cl,
3039 __attribute__((unused)) void *data)
3042 struct cmd_vlan_offload_result *res = parsed_result;
3045 portid_t port_id = 0;
3049 len = strnlen(str, STR_TOKEN_SIZE);
3051 /* Get port_id first */
3059 tmp = strtoul(str, NULL, 0);
3060 /* If port_id greater that what portid_t can represent, return */
3061 if(tmp >= RTE_MAX_ETHPORTS)
3063 port_id = (portid_t)tmp;
3065 if (!strcmp(res->on, "on"))
3070 if (!strcmp(res->what, "strip"))
3071 rx_vlan_strip_set(port_id, on);
3072 else if(!strcmp(res->what, "stripq")){
3073 uint16_t queue_id = 0;
3075 /* No queue_id, return */
3077 printf("must specify (port,queue_id)\n");
3080 tmp = strtoul(str + i + 1, NULL, 0);
3081 /* If queue_id greater that what 16-bits can represent, return */
3085 queue_id = (uint16_t)tmp;
3086 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3088 else if (!strcmp(res->what, "filter"))
3089 rx_vlan_filter_set(port_id, on);
3091 vlan_extend_set(port_id, on);
3096 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3097 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3099 cmdline_parse_token_string_t cmd_vlan_offload_set =
3100 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3102 cmdline_parse_token_string_t cmd_vlan_offload_what =
3103 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3104 what, "strip#filter#qinq#stripq");
3105 cmdline_parse_token_string_t cmd_vlan_offload_on =
3106 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3108 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3109 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3112 cmdline_parse_inst_t cmd_vlan_offload = {
3113 .f = cmd_vlan_offload_parsed,
3115 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3116 "<port_id[,queue_id]>: "
3117 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3119 (void *)&cmd_vlan_offload_vlan,
3120 (void *)&cmd_vlan_offload_set,
3121 (void *)&cmd_vlan_offload_what,
3122 (void *)&cmd_vlan_offload_on,
3123 (void *)&cmd_vlan_offload_portid,
3128 /* *** VLAN TPID SET ON A PORT *** */
3129 struct cmd_vlan_tpid_result {
3130 cmdline_fixed_string_t vlan;
3131 cmdline_fixed_string_t set;
3132 cmdline_fixed_string_t vlan_type;
3133 cmdline_fixed_string_t what;
3139 cmd_vlan_tpid_parsed(void *parsed_result,
3140 __attribute__((unused)) struct cmdline *cl,
3141 __attribute__((unused)) void *data)
3143 struct cmd_vlan_tpid_result *res = parsed_result;
3144 enum rte_vlan_type vlan_type;
3146 if (!strcmp(res->vlan_type, "inner"))
3147 vlan_type = ETH_VLAN_TYPE_INNER;
3148 else if (!strcmp(res->vlan_type, "outer"))
3149 vlan_type = ETH_VLAN_TYPE_OUTER;
3151 printf("Unknown vlan type\n");
3154 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3157 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3158 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3160 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3161 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3163 cmdline_parse_token_string_t cmd_vlan_type =
3164 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3165 vlan_type, "inner#outer");
3166 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3167 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3169 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3170 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3172 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3173 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3176 cmdline_parse_inst_t cmd_vlan_tpid = {
3177 .f = cmd_vlan_tpid_parsed,
3179 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3180 "Set the VLAN Ether type",
3182 (void *)&cmd_vlan_tpid_vlan,
3183 (void *)&cmd_vlan_tpid_set,
3184 (void *)&cmd_vlan_type,
3185 (void *)&cmd_vlan_tpid_what,
3186 (void *)&cmd_vlan_tpid_tpid,
3187 (void *)&cmd_vlan_tpid_portid,
3192 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3193 struct cmd_rx_vlan_filter_result {
3194 cmdline_fixed_string_t rx_vlan;
3195 cmdline_fixed_string_t what;
3201 cmd_rx_vlan_filter_parsed(void *parsed_result,
3202 __attribute__((unused)) struct cmdline *cl,
3203 __attribute__((unused)) void *data)
3205 struct cmd_rx_vlan_filter_result *res = parsed_result;
3207 if (!strcmp(res->what, "add"))
3208 rx_vft_set(res->port_id, res->vlan_id, 1);
3210 rx_vft_set(res->port_id, res->vlan_id, 0);
3213 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3214 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3215 rx_vlan, "rx_vlan");
3216 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3217 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3219 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3220 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3222 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3223 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3226 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3227 .f = cmd_rx_vlan_filter_parsed,
3229 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3230 "Add/Remove a VLAN identifier to/from the set of VLAN "
3231 "identifiers filtered by a port",
3233 (void *)&cmd_rx_vlan_filter_rx_vlan,
3234 (void *)&cmd_rx_vlan_filter_what,
3235 (void *)&cmd_rx_vlan_filter_vlanid,
3236 (void *)&cmd_rx_vlan_filter_portid,
3241 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3242 struct cmd_tx_vlan_set_result {
3243 cmdline_fixed_string_t tx_vlan;
3244 cmdline_fixed_string_t set;
3250 cmd_tx_vlan_set_parsed(void *parsed_result,
3251 __attribute__((unused)) struct cmdline *cl,
3252 __attribute__((unused)) void *data)
3254 struct cmd_tx_vlan_set_result *res = parsed_result;
3256 tx_vlan_set(res->port_id, res->vlan_id);
3259 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3260 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3261 tx_vlan, "tx_vlan");
3262 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3263 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3265 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3266 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3268 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3269 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3272 cmdline_parse_inst_t cmd_tx_vlan_set = {
3273 .f = cmd_tx_vlan_set_parsed,
3275 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3276 "Enable hardware insertion of a single VLAN header "
3277 "with a given TAG Identifier in packets sent on a port",
3279 (void *)&cmd_tx_vlan_set_tx_vlan,
3280 (void *)&cmd_tx_vlan_set_set,
3281 (void *)&cmd_tx_vlan_set_portid,
3282 (void *)&cmd_tx_vlan_set_vlanid,
3287 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3288 struct cmd_tx_vlan_set_qinq_result {
3289 cmdline_fixed_string_t tx_vlan;
3290 cmdline_fixed_string_t set;
3293 uint16_t vlan_id_outer;
3297 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3298 __attribute__((unused)) struct cmdline *cl,
3299 __attribute__((unused)) void *data)
3301 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3303 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3306 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3307 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3308 tx_vlan, "tx_vlan");
3309 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3310 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3312 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3313 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3315 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3316 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3318 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3319 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3320 vlan_id_outer, UINT16);
3322 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3323 .f = cmd_tx_vlan_set_qinq_parsed,
3325 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3326 "Enable hardware insertion of double VLAN header "
3327 "with given TAG Identifiers in packets sent on a port",
3329 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3330 (void *)&cmd_tx_vlan_set_qinq_set,
3331 (void *)&cmd_tx_vlan_set_qinq_portid,
3332 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3333 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3338 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3339 struct cmd_tx_vlan_set_pvid_result {
3340 cmdline_fixed_string_t tx_vlan;
3341 cmdline_fixed_string_t set;
3342 cmdline_fixed_string_t pvid;
3345 cmdline_fixed_string_t mode;
3349 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3350 __attribute__((unused)) struct cmdline *cl,
3351 __attribute__((unused)) void *data)
3353 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3355 if (strcmp(res->mode, "on") == 0)
3356 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3358 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3361 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3362 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3363 tx_vlan, "tx_vlan");
3364 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3365 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3367 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3368 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3370 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3371 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3373 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3374 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3376 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3377 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3380 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3381 .f = cmd_tx_vlan_set_pvid_parsed,
3383 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3385 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3386 (void *)&cmd_tx_vlan_set_pvid_set,
3387 (void *)&cmd_tx_vlan_set_pvid_pvid,
3388 (void *)&cmd_tx_vlan_set_pvid_port_id,
3389 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3390 (void *)&cmd_tx_vlan_set_pvid_mode,
3395 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3396 struct cmd_tx_vlan_reset_result {
3397 cmdline_fixed_string_t tx_vlan;
3398 cmdline_fixed_string_t reset;
3403 cmd_tx_vlan_reset_parsed(void *parsed_result,
3404 __attribute__((unused)) struct cmdline *cl,
3405 __attribute__((unused)) void *data)
3407 struct cmd_tx_vlan_reset_result *res = parsed_result;
3409 tx_vlan_reset(res->port_id);
3412 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3413 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3414 tx_vlan, "tx_vlan");
3415 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3416 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3418 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3419 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3422 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3423 .f = cmd_tx_vlan_reset_parsed,
3425 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3426 "VLAN header in packets sent on a port",
3428 (void *)&cmd_tx_vlan_reset_tx_vlan,
3429 (void *)&cmd_tx_vlan_reset_reset,
3430 (void *)&cmd_tx_vlan_reset_portid,
3436 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3437 struct cmd_csum_result {
3438 cmdline_fixed_string_t csum;
3439 cmdline_fixed_string_t mode;
3440 cmdline_fixed_string_t proto;
3441 cmdline_fixed_string_t hwsw;
3446 csum_show(int port_id)
3448 struct rte_eth_dev_info dev_info;
3451 ol_flags = ports[port_id].tx_ol_flags;
3452 printf("Parse tunnel is %s\n",
3453 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3454 printf("IP checksum offload is %s\n",
3455 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3456 printf("UDP checksum offload is %s\n",
3457 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3458 printf("TCP checksum offload is %s\n",
3459 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3460 printf("SCTP checksum offload is %s\n",
3461 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3462 printf("Outer-Ip checksum offload is %s\n",
3463 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3465 /* display warnings if configuration is not supported by the NIC */
3466 rte_eth_dev_info_get(port_id, &dev_info);
3467 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3468 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3469 printf("Warning: hardware IP checksum enabled but not "
3470 "supported by port %d\n", port_id);
3472 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3473 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3474 printf("Warning: hardware UDP checksum enabled but not "
3475 "supported by port %d\n", port_id);
3477 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3478 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3479 printf("Warning: hardware TCP checksum enabled but not "
3480 "supported by port %d\n", port_id);
3482 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3483 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3484 printf("Warning: hardware SCTP checksum enabled but not "
3485 "supported by port %d\n", port_id);
3487 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3488 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3489 printf("Warning: hardware outer IP checksum enabled but not "
3490 "supported by port %d\n", port_id);
3495 cmd_csum_parsed(void *parsed_result,
3496 __attribute__((unused)) struct cmdline *cl,
3497 __attribute__((unused)) void *data)
3499 struct cmd_csum_result *res = parsed_result;
3503 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3504 printf("invalid port %d\n", res->port_id);
3508 if (!strcmp(res->mode, "set")) {
3510 if (!strcmp(res->hwsw, "hw"))
3513 if (!strcmp(res->proto, "ip")) {
3514 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3515 } else if (!strcmp(res->proto, "udp")) {
3516 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3517 } else if (!strcmp(res->proto, "tcp")) {
3518 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3519 } else if (!strcmp(res->proto, "sctp")) {
3520 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3521 } else if (!strcmp(res->proto, "outer-ip")) {
3522 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3526 ports[res->port_id].tx_ol_flags |= mask;
3528 ports[res->port_id].tx_ol_flags &= (~mask);
3530 csum_show(res->port_id);
3533 cmdline_parse_token_string_t cmd_csum_csum =
3534 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3536 cmdline_parse_token_string_t cmd_csum_mode =
3537 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3539 cmdline_parse_token_string_t cmd_csum_proto =
3540 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3541 proto, "ip#tcp#udp#sctp#outer-ip");
3542 cmdline_parse_token_string_t cmd_csum_hwsw =
3543 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3545 cmdline_parse_token_num_t cmd_csum_portid =
3546 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3549 cmdline_parse_inst_t cmd_csum_set = {
3550 .f = cmd_csum_parsed,
3552 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3553 "Enable/Disable hardware calculation of L3/L4 checksum when "
3554 "using csum forward engine",
3556 (void *)&cmd_csum_csum,
3557 (void *)&cmd_csum_mode,
3558 (void *)&cmd_csum_proto,
3559 (void *)&cmd_csum_hwsw,
3560 (void *)&cmd_csum_portid,
3565 cmdline_parse_token_string_t cmd_csum_mode_show =
3566 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3569 cmdline_parse_inst_t cmd_csum_show = {
3570 .f = cmd_csum_parsed,
3572 .help_str = "csum show <port_id>: Show checksum offload configuration",
3574 (void *)&cmd_csum_csum,
3575 (void *)&cmd_csum_mode_show,
3576 (void *)&cmd_csum_portid,
3581 /* Enable/disable tunnel parsing */
3582 struct cmd_csum_tunnel_result {
3583 cmdline_fixed_string_t csum;
3584 cmdline_fixed_string_t parse;
3585 cmdline_fixed_string_t onoff;
3590 cmd_csum_tunnel_parsed(void *parsed_result,
3591 __attribute__((unused)) struct cmdline *cl,
3592 __attribute__((unused)) void *data)
3594 struct cmd_csum_tunnel_result *res = parsed_result;
3596 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3599 if (!strcmp(res->onoff, "on"))
3600 ports[res->port_id].tx_ol_flags |=
3601 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3603 ports[res->port_id].tx_ol_flags &=
3604 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3606 csum_show(res->port_id);
3609 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3610 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3612 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3613 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3614 parse, "parse_tunnel");
3615 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3616 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3618 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3619 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3622 cmdline_parse_inst_t cmd_csum_tunnel = {
3623 .f = cmd_csum_tunnel_parsed,
3625 .help_str = "csum parse_tunnel on|off <port_id>: "
3626 "Enable/Disable parsing of tunnels for csum engine",
3628 (void *)&cmd_csum_tunnel_csum,
3629 (void *)&cmd_csum_tunnel_parse,
3630 (void *)&cmd_csum_tunnel_onoff,
3631 (void *)&cmd_csum_tunnel_portid,
3636 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3637 struct cmd_tso_set_result {
3638 cmdline_fixed_string_t tso;
3639 cmdline_fixed_string_t mode;
3645 cmd_tso_set_parsed(void *parsed_result,
3646 __attribute__((unused)) struct cmdline *cl,
3647 __attribute__((unused)) void *data)
3649 struct cmd_tso_set_result *res = parsed_result;
3650 struct rte_eth_dev_info dev_info;
3652 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3655 if (!strcmp(res->mode, "set"))
3656 ports[res->port_id].tso_segsz = res->tso_segsz;
3658 if (ports[res->port_id].tso_segsz == 0)
3659 printf("TSO for non-tunneled packets is disabled\n");
3661 printf("TSO segment size for non-tunneled packets is %d\n",
3662 ports[res->port_id].tso_segsz);
3664 /* display warnings if configuration is not supported by the NIC */
3665 rte_eth_dev_info_get(res->port_id, &dev_info);
3666 if ((ports[res->port_id].tso_segsz != 0) &&
3667 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3668 printf("Warning: TSO enabled but not "
3669 "supported by port %d\n", res->port_id);
3673 cmdline_parse_token_string_t cmd_tso_set_tso =
3674 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3676 cmdline_parse_token_string_t cmd_tso_set_mode =
3677 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3679 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3680 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3682 cmdline_parse_token_num_t cmd_tso_set_portid =
3683 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3686 cmdline_parse_inst_t cmd_tso_set = {
3687 .f = cmd_tso_set_parsed,
3689 .help_str = "tso set <tso_segsz> <port_id>: "
3690 "Set TSO segment size of non-tunneled packets for csum engine "
3693 (void *)&cmd_tso_set_tso,
3694 (void *)&cmd_tso_set_mode,
3695 (void *)&cmd_tso_set_tso_segsz,
3696 (void *)&cmd_tso_set_portid,
3701 cmdline_parse_token_string_t cmd_tso_show_mode =
3702 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3706 cmdline_parse_inst_t cmd_tso_show = {
3707 .f = cmd_tso_set_parsed,
3709 .help_str = "tso show <port_id>: "
3710 "Show TSO segment size of non-tunneled packets for csum engine",
3712 (void *)&cmd_tso_set_tso,
3713 (void *)&cmd_tso_show_mode,
3714 (void *)&cmd_tso_set_portid,
3719 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3720 struct cmd_tunnel_tso_set_result {
3721 cmdline_fixed_string_t tso;
3722 cmdline_fixed_string_t mode;
3728 check_tunnel_tso_nic_support(uint8_t port_id)
3730 struct rte_eth_dev_info dev_info;
3732 rte_eth_dev_info_get(port_id, &dev_info);
3733 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3734 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3735 "supported by port %d\n", port_id);
3736 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3737 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3738 "supported by port %d\n", port_id);
3739 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3740 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3741 "supported by port %d\n", port_id);
3742 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3743 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3744 "supported by port %d\n", port_id);
3748 cmd_tunnel_tso_set_parsed(void *parsed_result,
3749 __attribute__((unused)) struct cmdline *cl,
3750 __attribute__((unused)) void *data)
3752 struct cmd_tunnel_tso_set_result *res = parsed_result;
3754 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3757 if (!strcmp(res->mode, "set"))
3758 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3760 if (ports[res->port_id].tunnel_tso_segsz == 0)
3761 printf("TSO for tunneled packets is disabled\n");
3763 printf("TSO segment size for tunneled packets is %d\n",
3764 ports[res->port_id].tunnel_tso_segsz);
3766 /* Below conditions are needed to make it work:
3767 * (1) tunnel TSO is supported by the NIC;
3768 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3770 * (3) for tunneled pkts with outer L3 of IPv4,
3771 * "csum set outer-ip" must be set to hw, because after tso,
3772 * total_len of outer IP header is changed, and the checksum
3773 * of outer IP header calculated by sw should be wrong; that
3774 * is not necessary for IPv6 tunneled pkts because there's no
3775 * checksum in IP header anymore.
3777 check_tunnel_tso_nic_support(res->port_id);
3779 if (!(ports[res->port_id].tx_ol_flags &
3780 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3781 printf("Warning: csum parse_tunnel must be set "
3782 "so that tunneled packets are recognized\n");
3783 if (!(ports[res->port_id].tx_ol_flags &
3784 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3785 printf("Warning: csum set outer-ip must be set to hw "
3786 "if outer L3 is IPv4; not necessary for IPv6\n");
3790 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3791 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3793 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3794 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3796 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3797 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3799 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3800 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3803 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3804 .f = cmd_tunnel_tso_set_parsed,
3806 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3807 "Set TSO segment size of tunneled packets for csum engine "
3810 (void *)&cmd_tunnel_tso_set_tso,
3811 (void *)&cmd_tunnel_tso_set_mode,
3812 (void *)&cmd_tunnel_tso_set_tso_segsz,
3813 (void *)&cmd_tunnel_tso_set_portid,
3818 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3819 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3823 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3824 .f = cmd_tunnel_tso_set_parsed,
3826 .help_str = "tunnel_tso show <port_id> "
3827 "Show TSO segment size of tunneled packets for csum engine",
3829 (void *)&cmd_tunnel_tso_set_tso,
3830 (void *)&cmd_tunnel_tso_show_mode,
3831 (void *)&cmd_tunnel_tso_set_portid,
3836 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3837 struct cmd_set_flush_rx {
3838 cmdline_fixed_string_t set;
3839 cmdline_fixed_string_t flush_rx;
3840 cmdline_fixed_string_t mode;
3844 cmd_set_flush_rx_parsed(void *parsed_result,
3845 __attribute__((unused)) struct cmdline *cl,
3846 __attribute__((unused)) void *data)
3848 struct cmd_set_flush_rx *res = parsed_result;
3849 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3852 cmdline_parse_token_string_t cmd_setflushrx_set =
3853 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3855 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3856 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3857 flush_rx, "flush_rx");
3858 cmdline_parse_token_string_t cmd_setflushrx_mode =
3859 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3863 cmdline_parse_inst_t cmd_set_flush_rx = {
3864 .f = cmd_set_flush_rx_parsed,
3865 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3868 (void *)&cmd_setflushrx_set,
3869 (void *)&cmd_setflushrx_flush_rx,
3870 (void *)&cmd_setflushrx_mode,
3875 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3876 struct cmd_set_link_check {
3877 cmdline_fixed_string_t set;
3878 cmdline_fixed_string_t link_check;
3879 cmdline_fixed_string_t mode;
3883 cmd_set_link_check_parsed(void *parsed_result,
3884 __attribute__((unused)) struct cmdline *cl,
3885 __attribute__((unused)) void *data)
3887 struct cmd_set_link_check *res = parsed_result;
3888 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3891 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3892 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3894 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3895 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3896 link_check, "link_check");
3897 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3902 cmdline_parse_inst_t cmd_set_link_check = {
3903 .f = cmd_set_link_check_parsed,
3904 .help_str = "set link_check on|off: Enable/Disable link status check "
3905 "when starting/stopping a port",
3908 (void *)&cmd_setlinkcheck_set,
3909 (void *)&cmd_setlinkcheck_link_check,
3910 (void *)&cmd_setlinkcheck_mode,
3915 /* *** SET NIC BYPASS MODE *** */
3916 struct cmd_set_bypass_mode_result {
3917 cmdline_fixed_string_t set;
3918 cmdline_fixed_string_t bypass;
3919 cmdline_fixed_string_t mode;
3920 cmdline_fixed_string_t value;
3925 cmd_set_bypass_mode_parsed(void *parsed_result,
3926 __attribute__((unused)) struct cmdline *cl,
3927 __attribute__((unused)) void *data)
3929 struct cmd_set_bypass_mode_result *res = parsed_result;
3930 portid_t port_id = res->port_id;
3931 int32_t rc = -EINVAL;
3933 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
3934 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3936 if (!strcmp(res->value, "bypass"))
3937 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
3938 else if (!strcmp(res->value, "isolate"))
3939 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
3941 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3943 /* Set the bypass mode for the relevant port. */
3944 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
3947 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3950 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3953 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3956 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3957 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3959 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3960 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3961 value, "normal#bypass#isolate");
3962 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3963 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3966 cmdline_parse_inst_t cmd_set_bypass_mode = {
3967 .f = cmd_set_bypass_mode_parsed,
3968 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3969 "Set the NIC bypass mode for port_id",
3972 (void *)&cmd_setbypass_mode_set,
3973 (void *)&cmd_setbypass_mode_bypass,
3974 (void *)&cmd_setbypass_mode_mode,
3975 (void *)&cmd_setbypass_mode_value,
3976 (void *)&cmd_setbypass_mode_port,
3981 /* *** SET NIC BYPASS EVENT *** */
3982 struct cmd_set_bypass_event_result {
3983 cmdline_fixed_string_t set;
3984 cmdline_fixed_string_t bypass;
3985 cmdline_fixed_string_t event;
3986 cmdline_fixed_string_t event_value;
3987 cmdline_fixed_string_t mode;
3988 cmdline_fixed_string_t mode_value;
3993 cmd_set_bypass_event_parsed(void *parsed_result,
3994 __attribute__((unused)) struct cmdline *cl,
3995 __attribute__((unused)) void *data)
3997 int32_t rc = -EINVAL;
3998 struct cmd_set_bypass_event_result *res = parsed_result;
3999 portid_t port_id = res->port_id;
4001 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4002 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4003 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4005 if (!strcmp(res->event_value, "timeout"))
4006 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4007 else if (!strcmp(res->event_value, "os_on"))
4008 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4009 else if (!strcmp(res->event_value, "os_off"))
4010 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4011 else if (!strcmp(res->event_value, "power_on"))
4012 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4013 else if (!strcmp(res->event_value, "power_off"))
4014 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4016 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4018 if (!strcmp(res->mode_value, "bypass"))
4019 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4020 else if (!strcmp(res->mode_value, "isolate"))
4021 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4023 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4025 /* Set the watchdog timeout. */
4026 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4029 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4030 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4034 printf("Failed to set timeout value %u "
4035 "for port %d, errto code: %d.\n",
4036 bypass_timeout, port_id, rc);
4040 /* Set the bypass event to transition to bypass mode. */
4041 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4046 printf("\t Failed to set bypass event for port = %d.\n",
4050 cmdline_parse_token_string_t cmd_setbypass_event_set =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4053 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4054 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4056 cmdline_parse_token_string_t cmd_setbypass_event_event =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4059 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4060 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4061 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4062 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4063 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4065 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4066 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4067 mode_value, "normal#bypass#isolate");
4068 cmdline_parse_token_num_t cmd_setbypass_event_port =
4069 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4072 cmdline_parse_inst_t cmd_set_bypass_event = {
4073 .f = cmd_set_bypass_event_parsed,
4074 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4075 "power_off mode normal|bypass|isolate <port_id>: "
4076 "Set the NIC bypass event mode for port_id",
4079 (void *)&cmd_setbypass_event_set,
4080 (void *)&cmd_setbypass_event_bypass,
4081 (void *)&cmd_setbypass_event_event,
4082 (void *)&cmd_setbypass_event_event_value,
4083 (void *)&cmd_setbypass_event_mode,
4084 (void *)&cmd_setbypass_event_mode_value,
4085 (void *)&cmd_setbypass_event_port,
4091 /* *** SET NIC BYPASS TIMEOUT *** */
4092 struct cmd_set_bypass_timeout_result {
4093 cmdline_fixed_string_t set;
4094 cmdline_fixed_string_t bypass;
4095 cmdline_fixed_string_t timeout;
4096 cmdline_fixed_string_t value;
4100 cmd_set_bypass_timeout_parsed(void *parsed_result,
4101 __attribute__((unused)) struct cmdline *cl,
4102 __attribute__((unused)) void *data)
4104 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4106 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4107 if (!strcmp(res->value, "1.5"))
4108 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4109 else if (!strcmp(res->value, "2"))
4110 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4111 else if (!strcmp(res->value, "3"))
4112 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4113 else if (!strcmp(res->value, "4"))
4114 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4115 else if (!strcmp(res->value, "8"))
4116 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4117 else if (!strcmp(res->value, "16"))
4118 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4119 else if (!strcmp(res->value, "32"))
4120 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4122 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4126 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4127 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4129 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4130 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4132 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4133 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4134 timeout, "timeout");
4135 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4136 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4137 value, "0#1.5#2#3#4#8#16#32");
4139 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4140 .f = cmd_set_bypass_timeout_parsed,
4141 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4142 "Set the NIC bypass watchdog timeout in seconds",
4145 (void *)&cmd_setbypass_timeout_set,
4146 (void *)&cmd_setbypass_timeout_bypass,
4147 (void *)&cmd_setbypass_timeout_timeout,
4148 (void *)&cmd_setbypass_timeout_value,
4153 /* *** SHOW NIC BYPASS MODE *** */
4154 struct cmd_show_bypass_config_result {
4155 cmdline_fixed_string_t show;
4156 cmdline_fixed_string_t bypass;
4157 cmdline_fixed_string_t config;
4162 cmd_show_bypass_config_parsed(void *parsed_result,
4163 __attribute__((unused)) struct cmdline *cl,
4164 __attribute__((unused)) void *data)
4166 struct cmd_show_bypass_config_result *res = parsed_result;
4167 portid_t port_id = res->port_id;
4169 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4170 uint32_t event_mode;
4171 uint32_t bypass_mode;
4172 uint32_t timeout = bypass_timeout;
4175 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4176 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4177 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4178 {"UNKNOWN", "normal", "bypass", "isolate"};
4179 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4186 int num_events = (sizeof events) / (sizeof events[0]);
4188 /* Display the bypass mode.*/
4189 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4190 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4194 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4195 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4197 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4200 /* Display the bypass timeout.*/
4201 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4202 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4204 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4206 /* Display the bypass events and associated modes. */
4207 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4209 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4210 printf("\tFailed to get bypass mode for event = %s\n",
4213 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4214 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4216 printf("\tbypass event: %-16s = %s\n", events[i],
4222 printf("\tFailed to get bypass configuration for port = %d\n",
4226 cmdline_parse_token_string_t cmd_showbypass_config_show =
4227 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4229 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4230 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4232 cmdline_parse_token_string_t cmd_showbypass_config_config =
4233 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4235 cmdline_parse_token_num_t cmd_showbypass_config_port =
4236 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4239 cmdline_parse_inst_t cmd_show_bypass_config = {
4240 .f = cmd_show_bypass_config_parsed,
4241 .help_str = "show bypass config <port_id>: "
4242 "Show the NIC bypass config for port_id",
4245 (void *)&cmd_showbypass_config_show,
4246 (void *)&cmd_showbypass_config_bypass,
4247 (void *)&cmd_showbypass_config_config,
4248 (void *)&cmd_showbypass_config_port,
4253 #ifdef RTE_LIBRTE_PMD_BOND
4254 /* *** SET BONDING MODE *** */
4255 struct cmd_set_bonding_mode_result {
4256 cmdline_fixed_string_t set;
4257 cmdline_fixed_string_t bonding;
4258 cmdline_fixed_string_t mode;
4263 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4264 __attribute__((unused)) struct cmdline *cl,
4265 __attribute__((unused)) void *data)
4267 struct cmd_set_bonding_mode_result *res = parsed_result;
4268 portid_t port_id = res->port_id;
4270 /* Set the bonding mode for the relevant port. */
4271 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4272 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4275 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4276 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4278 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4279 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4280 bonding, "bonding");
4281 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4282 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4284 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4285 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4287 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4288 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4291 cmdline_parse_inst_t cmd_set_bonding_mode = {
4292 .f = cmd_set_bonding_mode_parsed,
4293 .help_str = "set bonding mode <mode_value> <port_id>: "
4294 "Set the bonding mode for port_id",
4297 (void *) &cmd_setbonding_mode_set,
4298 (void *) &cmd_setbonding_mode_bonding,
4299 (void *) &cmd_setbonding_mode_mode,
4300 (void *) &cmd_setbonding_mode_value,
4301 (void *) &cmd_setbonding_mode_port,
4306 /* *** SET BALANCE XMIT POLICY *** */
4307 struct cmd_set_bonding_balance_xmit_policy_result {
4308 cmdline_fixed_string_t set;
4309 cmdline_fixed_string_t bonding;
4310 cmdline_fixed_string_t balance_xmit_policy;
4312 cmdline_fixed_string_t policy;
4315 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4316 __attribute__((unused)) struct cmdline *cl,
4317 __attribute__((unused)) void *data)
4319 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4320 portid_t port_id = res->port_id;
4323 if (!strcmp(res->policy, "l2")) {
4324 policy = BALANCE_XMIT_POLICY_LAYER2;
4325 } else if (!strcmp(res->policy, "l23")) {
4326 policy = BALANCE_XMIT_POLICY_LAYER23;
4327 } else if (!strcmp(res->policy, "l34")) {
4328 policy = BALANCE_XMIT_POLICY_LAYER34;
4330 printf("\t Invalid xmit policy selection");
4334 /* Set the bonding mode for the relevant port. */
4335 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4336 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4341 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4342 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4344 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4345 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4346 bonding, "bonding");
4347 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4348 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4349 balance_xmit_policy, "balance_xmit_policy");
4350 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4351 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4353 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4354 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4355 policy, "l2#l23#l34");
4357 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4358 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4359 .help_str = "set bonding balance_xmit_policy <port_id> "
4361 "Set the bonding balance_xmit_policy for port_id",
4364 (void *)&cmd_setbonding_balance_xmit_policy_set,
4365 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4366 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4367 (void *)&cmd_setbonding_balance_xmit_policy_port,
4368 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4373 /* *** SHOW NIC BONDING CONFIGURATION *** */
4374 struct cmd_show_bonding_config_result {
4375 cmdline_fixed_string_t show;
4376 cmdline_fixed_string_t bonding;
4377 cmdline_fixed_string_t config;
4381 static void cmd_show_bonding_config_parsed(void *parsed_result,
4382 __attribute__((unused)) struct cmdline *cl,
4383 __attribute__((unused)) void *data)
4385 struct cmd_show_bonding_config_result *res = parsed_result;
4387 uint8_t slaves[RTE_MAX_ETHPORTS];
4388 int num_slaves, num_active_slaves;
4391 portid_t port_id = res->port_id;
4393 /* Display the bonding mode.*/
4394 bonding_mode = rte_eth_bond_mode_get(port_id);
4395 if (bonding_mode < 0) {
4396 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4399 printf("\tBonding mode: %d\n", bonding_mode);
4401 if (bonding_mode == BONDING_MODE_BALANCE) {
4402 int balance_xmit_policy;
4404 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4405 if (balance_xmit_policy < 0) {
4406 printf("\tFailed to get balance xmit policy for port = %d\n",
4410 printf("\tBalance Xmit Policy: ");
4412 switch (balance_xmit_policy) {
4413 case BALANCE_XMIT_POLICY_LAYER2:
4414 printf("BALANCE_XMIT_POLICY_LAYER2");
4416 case BALANCE_XMIT_POLICY_LAYER23:
4417 printf("BALANCE_XMIT_POLICY_LAYER23");
4419 case BALANCE_XMIT_POLICY_LAYER34:
4420 printf("BALANCE_XMIT_POLICY_LAYER34");
4427 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4429 if (num_slaves < 0) {
4430 printf("\tFailed to get slave list for port = %d\n", port_id);
4433 if (num_slaves > 0) {
4434 printf("\tSlaves (%d): [", num_slaves);
4435 for (i = 0; i < num_slaves - 1; i++)
4436 printf("%d ", slaves[i]);
4438 printf("%d]\n", slaves[num_slaves - 1]);
4440 printf("\tSlaves: []\n");
4444 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4447 if (num_active_slaves < 0) {
4448 printf("\tFailed to get active slave list for port = %d\n", port_id);
4451 if (num_active_slaves > 0) {
4452 printf("\tActive Slaves (%d): [", num_active_slaves);
4453 for (i = 0; i < num_active_slaves - 1; i++)
4454 printf("%d ", slaves[i]);
4456 printf("%d]\n", slaves[num_active_slaves - 1]);
4459 printf("\tActive Slaves: []\n");
4463 primary_id = rte_eth_bond_primary_get(port_id);
4464 if (primary_id < 0) {
4465 printf("\tFailed to get primary slave for port = %d\n", port_id);
4468 printf("\tPrimary: [%d]\n", primary_id);
4472 cmdline_parse_token_string_t cmd_showbonding_config_show =
4473 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4475 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4476 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4477 bonding, "bonding");
4478 cmdline_parse_token_string_t cmd_showbonding_config_config =
4479 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4481 cmdline_parse_token_num_t cmd_showbonding_config_port =
4482 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4485 cmdline_parse_inst_t cmd_show_bonding_config = {
4486 .f = cmd_show_bonding_config_parsed,
4487 .help_str = "show bonding config <port_id>: "
4488 "Show the bonding config for port_id",
4491 (void *)&cmd_showbonding_config_show,
4492 (void *)&cmd_showbonding_config_bonding,
4493 (void *)&cmd_showbonding_config_config,
4494 (void *)&cmd_showbonding_config_port,
4499 /* *** SET BONDING PRIMARY *** */
4500 struct cmd_set_bonding_primary_result {
4501 cmdline_fixed_string_t set;
4502 cmdline_fixed_string_t bonding;
4503 cmdline_fixed_string_t primary;
4508 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4509 __attribute__((unused)) struct cmdline *cl,
4510 __attribute__((unused)) void *data)
4512 struct cmd_set_bonding_primary_result *res = parsed_result;
4513 portid_t master_port_id = res->port_id;
4514 portid_t slave_port_id = res->slave_id;
4516 /* Set the primary slave for a bonded device. */
4517 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4518 printf("\t Failed to set primary slave for port = %d.\n",
4525 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4526 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4528 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4529 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4530 bonding, "bonding");
4531 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4532 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4533 primary, "primary");
4534 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4535 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4537 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4538 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4541 cmdline_parse_inst_t cmd_set_bonding_primary = {
4542 .f = cmd_set_bonding_primary_parsed,
4543 .help_str = "set bonding primary <slave_id> <port_id>: "
4544 "Set the primary slave for port_id",
4547 (void *)&cmd_setbonding_primary_set,
4548 (void *)&cmd_setbonding_primary_bonding,
4549 (void *)&cmd_setbonding_primary_primary,
4550 (void *)&cmd_setbonding_primary_slave,
4551 (void *)&cmd_setbonding_primary_port,
4556 /* *** ADD SLAVE *** */
4557 struct cmd_add_bonding_slave_result {
4558 cmdline_fixed_string_t add;
4559 cmdline_fixed_string_t bonding;
4560 cmdline_fixed_string_t slave;
4565 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4566 __attribute__((unused)) struct cmdline *cl,
4567 __attribute__((unused)) void *data)
4569 struct cmd_add_bonding_slave_result *res = parsed_result;
4570 portid_t master_port_id = res->port_id;
4571 portid_t slave_port_id = res->slave_id;
4573 /* add the slave for a bonded device. */
4574 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4575 printf("\t Failed to add slave %d to master port = %d.\n",
4576 slave_port_id, master_port_id);
4580 set_port_slave_flag(slave_port_id);
4583 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4584 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4586 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4587 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4588 bonding, "bonding");
4589 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4590 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4592 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4593 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4595 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4596 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4599 cmdline_parse_inst_t cmd_add_bonding_slave = {
4600 .f = cmd_add_bonding_slave_parsed,
4601 .help_str = "add bonding slave <slave_id> <port_id>: "
4602 "Add a slave device to a bonded device",
4605 (void *)&cmd_addbonding_slave_add,
4606 (void *)&cmd_addbonding_slave_bonding,
4607 (void *)&cmd_addbonding_slave_slave,
4608 (void *)&cmd_addbonding_slave_slaveid,
4609 (void *)&cmd_addbonding_slave_port,
4614 /* *** REMOVE SLAVE *** */
4615 struct cmd_remove_bonding_slave_result {
4616 cmdline_fixed_string_t remove;
4617 cmdline_fixed_string_t bonding;
4618 cmdline_fixed_string_t slave;
4623 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4624 __attribute__((unused)) struct cmdline *cl,
4625 __attribute__((unused)) void *data)
4627 struct cmd_remove_bonding_slave_result *res = parsed_result;
4628 portid_t master_port_id = res->port_id;
4629 portid_t slave_port_id = res->slave_id;
4631 /* remove the slave from a bonded device. */
4632 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4633 printf("\t Failed to remove slave %d from master port = %d.\n",
4634 slave_port_id, master_port_id);
4638 clear_port_slave_flag(slave_port_id);
4641 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4642 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4644 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4645 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4646 bonding, "bonding");
4647 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4648 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4650 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4651 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4653 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4654 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4657 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4658 .f = cmd_remove_bonding_slave_parsed,
4659 .help_str = "remove bonding slave <slave_id> <port_id>: "
4660 "Remove a slave device from a bonded device",
4663 (void *)&cmd_removebonding_slave_remove,
4664 (void *)&cmd_removebonding_slave_bonding,
4665 (void *)&cmd_removebonding_slave_slave,
4666 (void *)&cmd_removebonding_slave_slaveid,
4667 (void *)&cmd_removebonding_slave_port,
4672 /* *** CREATE BONDED DEVICE *** */
4673 struct cmd_create_bonded_device_result {
4674 cmdline_fixed_string_t create;
4675 cmdline_fixed_string_t bonded;
4676 cmdline_fixed_string_t device;
4681 static int bond_dev_num = 0;
4683 static void cmd_create_bonded_device_parsed(void *parsed_result,
4684 __attribute__((unused)) struct cmdline *cl,
4685 __attribute__((unused)) void *data)
4687 struct cmd_create_bonded_device_result *res = parsed_result;
4688 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4691 if (test_done == 0) {
4692 printf("Please stop forwarding first\n");
4696 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4699 /* Create a new bonded device. */
4700 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4702 printf("\t Failed to create bonded device.\n");
4705 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4708 /* Update number of ports */
4709 nb_ports = rte_eth_dev_count();
4710 reconfig(port_id, res->socket);
4711 rte_eth_promiscuous_enable(port_id);
4716 cmdline_parse_token_string_t cmd_createbonded_device_create =
4717 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4719 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4720 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4722 cmdline_parse_token_string_t cmd_createbonded_device_device =
4723 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4725 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4726 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4728 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4729 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4732 cmdline_parse_inst_t cmd_create_bonded_device = {
4733 .f = cmd_create_bonded_device_parsed,
4734 .help_str = "create bonded device <mode> <socket>: "
4735 "Create a new bonded device with specific bonding mode and socket",
4738 (void *)&cmd_createbonded_device_create,
4739 (void *)&cmd_createbonded_device_bonded,
4740 (void *)&cmd_createbonded_device_device,
4741 (void *)&cmd_createbonded_device_mode,
4742 (void *)&cmd_createbonded_device_socket,
4747 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4748 struct cmd_set_bond_mac_addr_result {
4749 cmdline_fixed_string_t set;
4750 cmdline_fixed_string_t bonding;
4751 cmdline_fixed_string_t mac_addr;
4753 struct ether_addr address;
4756 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4757 __attribute__((unused)) struct cmdline *cl,
4758 __attribute__((unused)) void *data)
4760 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4763 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4766 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4768 /* check the return value and print it if is < 0 */
4770 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4773 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4774 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4775 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4776 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4778 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4779 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4781 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4782 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4783 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4784 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4786 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4787 .f = cmd_set_bond_mac_addr_parsed,
4789 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4791 (void *)&cmd_set_bond_mac_addr_set,
4792 (void *)&cmd_set_bond_mac_addr_bonding,
4793 (void *)&cmd_set_bond_mac_addr_mac,
4794 (void *)&cmd_set_bond_mac_addr_portnum,
4795 (void *)&cmd_set_bond_mac_addr_addr,
4801 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4802 struct cmd_set_bond_mon_period_result {
4803 cmdline_fixed_string_t set;
4804 cmdline_fixed_string_t bonding;
4805 cmdline_fixed_string_t mon_period;
4810 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4811 __attribute__((unused)) struct cmdline *cl,
4812 __attribute__((unused)) void *data)
4814 struct cmd_set_bond_mon_period_result *res = parsed_result;
4817 if (res->port_num >= nb_ports) {
4818 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4822 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4824 /* check the return value and print it if is < 0 */
4826 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4829 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4830 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4832 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4833 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4834 bonding, "bonding");
4835 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4836 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4837 mon_period, "mon_period");
4838 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4839 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4841 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4842 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4845 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4846 .f = cmd_set_bond_mon_period_parsed,
4848 .help_str = "set bonding mon_period <port_id> <period_ms>",
4850 (void *)&cmd_set_bond_mon_period_set,
4851 (void *)&cmd_set_bond_mon_period_bonding,
4852 (void *)&cmd_set_bond_mon_period_mon_period,
4853 (void *)&cmd_set_bond_mon_period_portnum,
4854 (void *)&cmd_set_bond_mon_period_period_ms,
4859 #endif /* RTE_LIBRTE_PMD_BOND */
4861 /* *** SET FORWARDING MODE *** */
4862 struct cmd_set_fwd_mode_result {
4863 cmdline_fixed_string_t set;
4864 cmdline_fixed_string_t fwd;
4865 cmdline_fixed_string_t mode;
4868 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4869 __attribute__((unused)) struct cmdline *cl,
4870 __attribute__((unused)) void *data)
4872 struct cmd_set_fwd_mode_result *res = parsed_result;
4875 set_pkt_forwarding_mode(res->mode);
4878 cmdline_parse_token_string_t cmd_setfwd_set =
4879 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4880 cmdline_parse_token_string_t cmd_setfwd_fwd =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4882 cmdline_parse_token_string_t cmd_setfwd_mode =
4883 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4884 "" /* defined at init */);
4886 cmdline_parse_inst_t cmd_set_fwd_mode = {
4887 .f = cmd_set_fwd_mode_parsed,
4889 .help_str = NULL, /* defined at init */
4891 (void *)&cmd_setfwd_set,
4892 (void *)&cmd_setfwd_fwd,
4893 (void *)&cmd_setfwd_mode,
4898 static void cmd_set_fwd_mode_init(void)
4901 static char token[128];
4902 static char help[256];
4903 cmdline_parse_token_string_t *token_struct;
4905 modes = list_pkt_forwarding_modes();
4906 snprintf(help, sizeof(help), "set fwd %s: "
4907 "Set packet forwarding mode", modes);
4908 cmd_set_fwd_mode.help_str = help;
4910 /* string token separator is # */
4911 for (c = token; *modes != '\0'; modes++)
4916 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4917 token_struct->string_data.str = token;
4920 /* *** SET RETRY FORWARDING MODE *** */
4921 struct cmd_set_fwd_retry_mode_result {
4922 cmdline_fixed_string_t set;
4923 cmdline_fixed_string_t fwd;
4924 cmdline_fixed_string_t mode;
4925 cmdline_fixed_string_t retry;
4928 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4929 __attribute__((unused)) struct cmdline *cl,
4930 __attribute__((unused)) void *data)
4932 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4935 set_pkt_forwarding_mode(res->mode);
4938 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4939 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4941 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4942 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4944 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4945 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4947 "" /* defined at init */);
4948 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4949 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4952 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4953 .f = cmd_set_fwd_retry_mode_parsed,
4955 .help_str = NULL, /* defined at init */
4957 (void *)&cmd_setfwd_retry_set,
4958 (void *)&cmd_setfwd_retry_fwd,
4959 (void *)&cmd_setfwd_retry_mode,
4960 (void *)&cmd_setfwd_retry_retry,
4965 static void cmd_set_fwd_retry_mode_init(void)
4968 static char token[128];
4969 static char help[256];
4970 cmdline_parse_token_string_t *token_struct;
4972 modes = list_pkt_forwarding_retry_modes();
4973 snprintf(help, sizeof(help), "set fwd %s retry: "
4974 "Set packet forwarding mode with retry", modes);
4975 cmd_set_fwd_retry_mode.help_str = help;
4977 /* string token separator is # */
4978 for (c = token; *modes != '\0'; modes++)
4983 token_struct = (cmdline_parse_token_string_t *)
4984 cmd_set_fwd_retry_mode.tokens[2];
4985 token_struct->string_data.str = token;
4988 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4989 struct cmd_set_burst_tx_retry_result {
4990 cmdline_fixed_string_t set;
4991 cmdline_fixed_string_t burst;
4992 cmdline_fixed_string_t tx;
4993 cmdline_fixed_string_t delay;
4995 cmdline_fixed_string_t retry;
4999 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5000 __attribute__((unused)) struct cmdline *cl,
5001 __attribute__((unused)) void *data)
5003 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5005 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5006 && !strcmp(res->tx, "tx")) {
5007 if (!strcmp(res->delay, "delay"))
5008 burst_tx_delay_time = res->time;
5009 if (!strcmp(res->retry, "retry"))
5010 burst_tx_retry_num = res->retry_num;
5015 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5016 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5017 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5018 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5020 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5021 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5022 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5023 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5024 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5025 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5026 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5027 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5028 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5029 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5031 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5032 .f = cmd_set_burst_tx_retry_parsed,
5033 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5035 (void *)&cmd_set_burst_tx_retry_set,
5036 (void *)&cmd_set_burst_tx_retry_burst,
5037 (void *)&cmd_set_burst_tx_retry_tx,
5038 (void *)&cmd_set_burst_tx_retry_delay,
5039 (void *)&cmd_set_burst_tx_retry_time,
5040 (void *)&cmd_set_burst_tx_retry_retry,
5041 (void *)&cmd_set_burst_tx_retry_retry_num,
5046 /* *** SET PROMISC MODE *** */
5047 struct cmd_set_promisc_mode_result {
5048 cmdline_fixed_string_t set;
5049 cmdline_fixed_string_t promisc;
5050 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5051 uint8_t port_num; /* valid if "allports" argument == 0 */
5052 cmdline_fixed_string_t mode;
5055 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5056 __attribute__((unused)) struct cmdline *cl,
5059 struct cmd_set_promisc_mode_result *res = parsed_result;
5063 if (!strcmp(res->mode, "on"))
5070 RTE_ETH_FOREACH_DEV(i) {
5072 rte_eth_promiscuous_enable(i);
5074 rte_eth_promiscuous_disable(i);
5079 rte_eth_promiscuous_enable(res->port_num);
5081 rte_eth_promiscuous_disable(res->port_num);
5085 cmdline_parse_token_string_t cmd_setpromisc_set =
5086 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5087 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5088 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5090 cmdline_parse_token_string_t cmd_setpromisc_portall =
5091 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5093 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5094 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5096 cmdline_parse_token_string_t cmd_setpromisc_mode =
5097 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5100 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5101 .f = cmd_set_promisc_mode_parsed,
5103 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5105 (void *)&cmd_setpromisc_set,
5106 (void *)&cmd_setpromisc_promisc,
5107 (void *)&cmd_setpromisc_portall,
5108 (void *)&cmd_setpromisc_mode,
5113 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5114 .f = cmd_set_promisc_mode_parsed,
5116 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5118 (void *)&cmd_setpromisc_set,
5119 (void *)&cmd_setpromisc_promisc,
5120 (void *)&cmd_setpromisc_portnum,
5121 (void *)&cmd_setpromisc_mode,
5126 /* *** SET ALLMULTI MODE *** */
5127 struct cmd_set_allmulti_mode_result {
5128 cmdline_fixed_string_t set;
5129 cmdline_fixed_string_t allmulti;
5130 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5131 uint8_t port_num; /* valid if "allports" argument == 0 */
5132 cmdline_fixed_string_t mode;
5135 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5136 __attribute__((unused)) struct cmdline *cl,
5139 struct cmd_set_allmulti_mode_result *res = parsed_result;
5143 if (!strcmp(res->mode, "on"))
5150 RTE_ETH_FOREACH_DEV(i) {
5152 rte_eth_allmulticast_enable(i);
5154 rte_eth_allmulticast_disable(i);
5159 rte_eth_allmulticast_enable(res->port_num);
5161 rte_eth_allmulticast_disable(res->port_num);
5165 cmdline_parse_token_string_t cmd_setallmulti_set =
5166 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5167 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5168 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5170 cmdline_parse_token_string_t cmd_setallmulti_portall =
5171 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5173 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5174 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5176 cmdline_parse_token_string_t cmd_setallmulti_mode =
5177 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5180 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5181 .f = cmd_set_allmulti_mode_parsed,
5183 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5185 (void *)&cmd_setallmulti_set,
5186 (void *)&cmd_setallmulti_allmulti,
5187 (void *)&cmd_setallmulti_portall,
5188 (void *)&cmd_setallmulti_mode,
5193 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5194 .f = cmd_set_allmulti_mode_parsed,
5196 .help_str = "set allmulti <port_id> on|off: "
5197 "Set allmulti mode on port_id",
5199 (void *)&cmd_setallmulti_set,
5200 (void *)&cmd_setallmulti_allmulti,
5201 (void *)&cmd_setallmulti_portnum,
5202 (void *)&cmd_setallmulti_mode,
5207 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5208 struct cmd_link_flow_ctrl_set_result {
5209 cmdline_fixed_string_t set;
5210 cmdline_fixed_string_t flow_ctrl;
5211 cmdline_fixed_string_t rx;
5212 cmdline_fixed_string_t rx_lfc_mode;
5213 cmdline_fixed_string_t tx;
5214 cmdline_fixed_string_t tx_lfc_mode;
5215 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5216 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5217 cmdline_fixed_string_t autoneg_str;
5218 cmdline_fixed_string_t autoneg;
5219 cmdline_fixed_string_t hw_str;
5220 uint32_t high_water;
5221 cmdline_fixed_string_t lw_str;
5223 cmdline_fixed_string_t pt_str;
5224 uint16_t pause_time;
5225 cmdline_fixed_string_t xon_str;
5230 cmdline_parse_token_string_t cmd_lfc_set_set =
5231 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5233 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5234 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5235 flow_ctrl, "flow_ctrl");
5236 cmdline_parse_token_string_t cmd_lfc_set_rx =
5237 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5239 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5240 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5241 rx_lfc_mode, "on#off");
5242 cmdline_parse_token_string_t cmd_lfc_set_tx =
5243 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5245 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5246 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5247 tx_lfc_mode, "on#off");
5248 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5249 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5250 hw_str, "high_water");
5251 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5252 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5253 high_water, UINT32);
5254 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5255 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5256 lw_str, "low_water");
5257 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5258 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5260 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5261 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5262 pt_str, "pause_time");
5263 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5264 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5265 pause_time, UINT16);
5266 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5267 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5268 xon_str, "send_xon");
5269 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5270 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5272 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5273 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5274 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5275 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5276 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5277 mac_ctrl_frame_fwd_mode, "on#off");
5278 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5279 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5280 autoneg_str, "autoneg");
5281 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5282 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5284 cmdline_parse_token_num_t cmd_lfc_set_portid =
5285 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5288 /* forward declaration */
5290 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5293 cmdline_parse_inst_t cmd_link_flow_control_set = {
5294 .f = cmd_link_flow_ctrl_set_parsed,
5296 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5297 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5298 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5300 (void *)&cmd_lfc_set_set,
5301 (void *)&cmd_lfc_set_flow_ctrl,
5302 (void *)&cmd_lfc_set_rx,
5303 (void *)&cmd_lfc_set_rx_mode,
5304 (void *)&cmd_lfc_set_tx,
5305 (void *)&cmd_lfc_set_tx_mode,
5306 (void *)&cmd_lfc_set_high_water,
5307 (void *)&cmd_lfc_set_low_water,
5308 (void *)&cmd_lfc_set_pause_time,
5309 (void *)&cmd_lfc_set_send_xon,
5310 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5311 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5312 (void *)&cmd_lfc_set_autoneg_str,
5313 (void *)&cmd_lfc_set_autoneg,
5314 (void *)&cmd_lfc_set_portid,
5319 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5320 .f = cmd_link_flow_ctrl_set_parsed,
5321 .data = (void *)&cmd_link_flow_control_set_rx,
5322 .help_str = "set flow_ctrl rx on|off <port_id>: "
5323 "Change rx flow control parameter",
5325 (void *)&cmd_lfc_set_set,
5326 (void *)&cmd_lfc_set_flow_ctrl,
5327 (void *)&cmd_lfc_set_rx,
5328 (void *)&cmd_lfc_set_rx_mode,
5329 (void *)&cmd_lfc_set_portid,
5334 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5335 .f = cmd_link_flow_ctrl_set_parsed,
5336 .data = (void *)&cmd_link_flow_control_set_tx,
5337 .help_str = "set flow_ctrl tx on|off <port_id>: "
5338 "Change tx flow control parameter",
5340 (void *)&cmd_lfc_set_set,
5341 (void *)&cmd_lfc_set_flow_ctrl,
5342 (void *)&cmd_lfc_set_tx,
5343 (void *)&cmd_lfc_set_tx_mode,
5344 (void *)&cmd_lfc_set_portid,
5349 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5350 .f = cmd_link_flow_ctrl_set_parsed,
5351 .data = (void *)&cmd_link_flow_control_set_hw,
5352 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5353 "Change high water flow control parameter",
5355 (void *)&cmd_lfc_set_set,
5356 (void *)&cmd_lfc_set_flow_ctrl,
5357 (void *)&cmd_lfc_set_high_water_str,
5358 (void *)&cmd_lfc_set_high_water,
5359 (void *)&cmd_lfc_set_portid,
5364 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5365 .f = cmd_link_flow_ctrl_set_parsed,
5366 .data = (void *)&cmd_link_flow_control_set_lw,
5367 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5368 "Change low water flow control parameter",
5370 (void *)&cmd_lfc_set_set,
5371 (void *)&cmd_lfc_set_flow_ctrl,
5372 (void *)&cmd_lfc_set_low_water_str,
5373 (void *)&cmd_lfc_set_low_water,
5374 (void *)&cmd_lfc_set_portid,
5379 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5380 .f = cmd_link_flow_ctrl_set_parsed,
5381 .data = (void *)&cmd_link_flow_control_set_pt,
5382 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5383 "Change pause time flow control parameter",
5385 (void *)&cmd_lfc_set_set,
5386 (void *)&cmd_lfc_set_flow_ctrl,
5387 (void *)&cmd_lfc_set_pause_time_str,
5388 (void *)&cmd_lfc_set_pause_time,
5389 (void *)&cmd_lfc_set_portid,
5394 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5395 .f = cmd_link_flow_ctrl_set_parsed,
5396 .data = (void *)&cmd_link_flow_control_set_xon,
5397 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5398 "Change send_xon flow control parameter",
5400 (void *)&cmd_lfc_set_set,
5401 (void *)&cmd_lfc_set_flow_ctrl,
5402 (void *)&cmd_lfc_set_send_xon_str,
5403 (void *)&cmd_lfc_set_send_xon,
5404 (void *)&cmd_lfc_set_portid,
5409 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5410 .f = cmd_link_flow_ctrl_set_parsed,
5411 .data = (void *)&cmd_link_flow_control_set_macfwd,
5412 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5413 "Change mac ctrl fwd flow control parameter",
5415 (void *)&cmd_lfc_set_set,
5416 (void *)&cmd_lfc_set_flow_ctrl,
5417 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5418 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5419 (void *)&cmd_lfc_set_portid,
5424 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5425 .f = cmd_link_flow_ctrl_set_parsed,
5426 .data = (void *)&cmd_link_flow_control_set_autoneg,
5427 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5428 "Change autoneg flow control parameter",
5430 (void *)&cmd_lfc_set_set,
5431 (void *)&cmd_lfc_set_flow_ctrl,
5432 (void *)&cmd_lfc_set_autoneg_str,
5433 (void *)&cmd_lfc_set_autoneg,
5434 (void *)&cmd_lfc_set_portid,
5440 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5441 __attribute__((unused)) struct cmdline *cl,
5444 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5445 cmdline_parse_inst_t *cmd = data;
5446 struct rte_eth_fc_conf fc_conf;
5452 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5453 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5454 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5455 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5457 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5458 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5461 /* Partial command line, retrieve current configuration */
5463 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5465 printf("cannot get current flow ctrl parameters, return"
5466 "code = %d\n", ret);
5470 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5471 (fc_conf.mode == RTE_FC_FULL))
5473 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5474 (fc_conf.mode == RTE_FC_FULL))
5478 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5479 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5481 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5482 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5484 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5486 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5487 fc_conf.high_water = res->high_water;
5489 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5490 fc_conf.low_water = res->low_water;
5492 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5493 fc_conf.pause_time = res->pause_time;
5495 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5496 fc_conf.send_xon = res->send_xon;
5498 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5499 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5500 fc_conf.mac_ctrl_frame_fwd = 1;
5502 fc_conf.mac_ctrl_frame_fwd = 0;
5505 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5506 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5508 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5510 printf("bad flow contrl parameter, return code = %d \n", ret);
5513 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5514 struct cmd_priority_flow_ctrl_set_result {
5515 cmdline_fixed_string_t set;
5516 cmdline_fixed_string_t pfc_ctrl;
5517 cmdline_fixed_string_t rx;
5518 cmdline_fixed_string_t rx_pfc_mode;
5519 cmdline_fixed_string_t tx;
5520 cmdline_fixed_string_t tx_pfc_mode;
5521 uint32_t high_water;
5523 uint16_t pause_time;
5529 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5530 __attribute__((unused)) struct cmdline *cl,
5531 __attribute__((unused)) void *data)
5533 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5534 struct rte_eth_pfc_conf pfc_conf;
5535 int rx_fc_enable, tx_fc_enable;
5539 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5540 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5541 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5542 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5544 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5545 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5548 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5549 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5550 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5551 pfc_conf.fc.high_water = res->high_water;
5552 pfc_conf.fc.low_water = res->low_water;
5553 pfc_conf.fc.pause_time = res->pause_time;
5554 pfc_conf.priority = res->priority;
5556 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5558 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5561 cmdline_parse_token_string_t cmd_pfc_set_set =
5562 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5564 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5565 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5566 pfc_ctrl, "pfc_ctrl");
5567 cmdline_parse_token_string_t cmd_pfc_set_rx =
5568 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5570 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5571 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5572 rx_pfc_mode, "on#off");
5573 cmdline_parse_token_string_t cmd_pfc_set_tx =
5574 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5576 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5577 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5578 tx_pfc_mode, "on#off");
5579 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5580 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5581 high_water, UINT32);
5582 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5583 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5585 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5586 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5587 pause_time, UINT16);
5588 cmdline_parse_token_num_t cmd_pfc_set_priority =
5589 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5591 cmdline_parse_token_num_t cmd_pfc_set_portid =
5592 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5595 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5596 .f = cmd_priority_flow_ctrl_set_parsed,
5598 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5599 "<pause_time> <priority> <port_id>: "
5600 "Configure the Ethernet priority flow control",
5602 (void *)&cmd_pfc_set_set,
5603 (void *)&cmd_pfc_set_flow_ctrl,
5604 (void *)&cmd_pfc_set_rx,
5605 (void *)&cmd_pfc_set_rx_mode,
5606 (void *)&cmd_pfc_set_tx,
5607 (void *)&cmd_pfc_set_tx_mode,
5608 (void *)&cmd_pfc_set_high_water,
5609 (void *)&cmd_pfc_set_low_water,
5610 (void *)&cmd_pfc_set_pause_time,
5611 (void *)&cmd_pfc_set_priority,
5612 (void *)&cmd_pfc_set_portid,
5617 /* *** RESET CONFIGURATION *** */
5618 struct cmd_reset_result {
5619 cmdline_fixed_string_t reset;
5620 cmdline_fixed_string_t def;
5623 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5625 __attribute__((unused)) void *data)
5627 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5628 set_def_fwd_config();
5631 cmdline_parse_token_string_t cmd_reset_set =
5632 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5633 cmdline_parse_token_string_t cmd_reset_def =
5634 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5637 cmdline_parse_inst_t cmd_reset = {
5638 .f = cmd_reset_parsed,
5640 .help_str = "set default: Reset default forwarding configuration",
5642 (void *)&cmd_reset_set,
5643 (void *)&cmd_reset_def,
5648 /* *** START FORWARDING *** */
5649 struct cmd_start_result {
5650 cmdline_fixed_string_t start;
5653 cmdline_parse_token_string_t cmd_start_start =
5654 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5656 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5657 __attribute__((unused)) struct cmdline *cl,
5658 __attribute__((unused)) void *data)
5660 start_packet_forwarding(0);
5663 cmdline_parse_inst_t cmd_start = {
5664 .f = cmd_start_parsed,
5666 .help_str = "start: Start packet forwarding",
5668 (void *)&cmd_start_start,
5673 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5674 struct cmd_start_tx_first_result {
5675 cmdline_fixed_string_t start;
5676 cmdline_fixed_string_t tx_first;
5680 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5681 __attribute__((unused)) struct cmdline *cl,
5682 __attribute__((unused)) void *data)
5684 start_packet_forwarding(1);
5687 cmdline_parse_token_string_t cmd_start_tx_first_start =
5688 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5690 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5691 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5692 tx_first, "tx_first");
5694 cmdline_parse_inst_t cmd_start_tx_first = {
5695 .f = cmd_start_tx_first_parsed,
5697 .help_str = "start tx_first: Start packet forwarding, "
5698 "after sending 1 burst of packets",
5700 (void *)&cmd_start_tx_first_start,
5701 (void *)&cmd_start_tx_first_tx_first,
5706 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5707 struct cmd_start_tx_first_n_result {
5708 cmdline_fixed_string_t start;
5709 cmdline_fixed_string_t tx_first;
5714 cmd_start_tx_first_n_parsed(void *parsed_result,
5715 __attribute__((unused)) struct cmdline *cl,
5716 __attribute__((unused)) void *data)
5718 struct cmd_start_tx_first_n_result *res = parsed_result;
5720 start_packet_forwarding(res->tx_num);
5723 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5724 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5726 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5727 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5728 tx_first, "tx_first");
5729 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5730 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5733 cmdline_parse_inst_t cmd_start_tx_first_n = {
5734 .f = cmd_start_tx_first_n_parsed,
5736 .help_str = "start tx_first <num>: "
5737 "packet forwarding, after sending <num> bursts of packets",
5739 (void *)&cmd_start_tx_first_n_start,
5740 (void *)&cmd_start_tx_first_n_tx_first,
5741 (void *)&cmd_start_tx_first_n_tx_num,
5746 /* *** SET LINK UP *** */
5747 struct cmd_set_link_up_result {
5748 cmdline_fixed_string_t set;
5749 cmdline_fixed_string_t link_up;
5750 cmdline_fixed_string_t port;
5754 cmdline_parse_token_string_t cmd_set_link_up_set =
5755 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5756 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5757 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5759 cmdline_parse_token_string_t cmd_set_link_up_port =
5760 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5761 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5762 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5764 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5765 __attribute__((unused)) struct cmdline *cl,
5766 __attribute__((unused)) void *data)
5768 struct cmd_set_link_up_result *res = parsed_result;
5769 dev_set_link_up(res->port_id);
5772 cmdline_parse_inst_t cmd_set_link_up = {
5773 .f = cmd_set_link_up_parsed,
5775 .help_str = "set link-up port <port id>",
5777 (void *)&cmd_set_link_up_set,
5778 (void *)&cmd_set_link_up_link_up,
5779 (void *)&cmd_set_link_up_port,
5780 (void *)&cmd_set_link_up_port_id,
5785 /* *** SET LINK DOWN *** */
5786 struct cmd_set_link_down_result {
5787 cmdline_fixed_string_t set;
5788 cmdline_fixed_string_t link_down;
5789 cmdline_fixed_string_t port;
5793 cmdline_parse_token_string_t cmd_set_link_down_set =
5794 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5795 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5796 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5798 cmdline_parse_token_string_t cmd_set_link_down_port =
5799 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5800 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5801 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5803 static void cmd_set_link_down_parsed(
5804 __attribute__((unused)) void *parsed_result,
5805 __attribute__((unused)) struct cmdline *cl,
5806 __attribute__((unused)) void *data)
5808 struct cmd_set_link_down_result *res = parsed_result;
5809 dev_set_link_down(res->port_id);
5812 cmdline_parse_inst_t cmd_set_link_down = {
5813 .f = cmd_set_link_down_parsed,
5815 .help_str = "set link-down port <port id>",
5817 (void *)&cmd_set_link_down_set,
5818 (void *)&cmd_set_link_down_link_down,
5819 (void *)&cmd_set_link_down_port,
5820 (void *)&cmd_set_link_down_port_id,
5825 /* *** SHOW CFG *** */
5826 struct cmd_showcfg_result {
5827 cmdline_fixed_string_t show;
5828 cmdline_fixed_string_t cfg;
5829 cmdline_fixed_string_t what;
5832 static void cmd_showcfg_parsed(void *parsed_result,
5833 __attribute__((unused)) struct cmdline *cl,
5834 __attribute__((unused)) void *data)
5836 struct cmd_showcfg_result *res = parsed_result;
5837 if (!strcmp(res->what, "rxtx"))
5838 rxtx_config_display();
5839 else if (!strcmp(res->what, "cores"))
5840 fwd_lcores_config_display();
5841 else if (!strcmp(res->what, "fwd"))
5842 pkt_fwd_config_display(&cur_fwd_config);
5843 else if (!strcmp(res->what, "txpkts"))
5844 show_tx_pkt_segments();
5847 cmdline_parse_token_string_t cmd_showcfg_show =
5848 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5849 cmdline_parse_token_string_t cmd_showcfg_port =
5850 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5851 cmdline_parse_token_string_t cmd_showcfg_what =
5852 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5853 "rxtx#cores#fwd#txpkts");
5855 cmdline_parse_inst_t cmd_showcfg = {
5856 .f = cmd_showcfg_parsed,
5858 .help_str = "show config rxtx|cores|fwd|txpkts",
5860 (void *)&cmd_showcfg_show,
5861 (void *)&cmd_showcfg_port,
5862 (void *)&cmd_showcfg_what,
5867 /* *** SHOW ALL PORT INFO *** */
5868 struct cmd_showportall_result {
5869 cmdline_fixed_string_t show;
5870 cmdline_fixed_string_t port;
5871 cmdline_fixed_string_t what;
5872 cmdline_fixed_string_t all;
5875 static void cmd_showportall_parsed(void *parsed_result,
5876 __attribute__((unused)) struct cmdline *cl,
5877 __attribute__((unused)) void *data)
5881 struct cmd_showportall_result *res = parsed_result;
5882 if (!strcmp(res->show, "clear")) {
5883 if (!strcmp(res->what, "stats"))
5884 RTE_ETH_FOREACH_DEV(i)
5886 else if (!strcmp(res->what, "xstats"))
5887 RTE_ETH_FOREACH_DEV(i)
5888 nic_xstats_clear(i);
5889 } else if (!strcmp(res->what, "info"))
5890 RTE_ETH_FOREACH_DEV(i)
5891 port_infos_display(i);
5892 else if (!strcmp(res->what, "stats"))
5893 RTE_ETH_FOREACH_DEV(i)
5894 nic_stats_display(i);
5895 else if (!strcmp(res->what, "xstats"))
5896 RTE_ETH_FOREACH_DEV(i)
5897 nic_xstats_display(i);
5898 else if (!strcmp(res->what, "fdir"))
5899 RTE_ETH_FOREACH_DEV(i)
5901 else if (!strcmp(res->what, "stat_qmap"))
5902 RTE_ETH_FOREACH_DEV(i)
5903 nic_stats_mapping_display(i);
5904 else if (!strcmp(res->what, "dcb_tc"))
5905 RTE_ETH_FOREACH_DEV(i)
5906 port_dcb_info_display(i);
5907 else if (!strcmp(res->what, "cap"))
5908 RTE_ETH_FOREACH_DEV(i)
5909 port_offload_cap_display(i);
5912 cmdline_parse_token_string_t cmd_showportall_show =
5913 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5915 cmdline_parse_token_string_t cmd_showportall_port =
5916 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5917 cmdline_parse_token_string_t cmd_showportall_what =
5918 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5919 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5920 cmdline_parse_token_string_t cmd_showportall_all =
5921 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5922 cmdline_parse_inst_t cmd_showportall = {
5923 .f = cmd_showportall_parsed,
5925 .help_str = "show|clear port "
5926 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5928 (void *)&cmd_showportall_show,
5929 (void *)&cmd_showportall_port,
5930 (void *)&cmd_showportall_what,
5931 (void *)&cmd_showportall_all,
5936 /* *** SHOW PORT INFO *** */
5937 struct cmd_showport_result {
5938 cmdline_fixed_string_t show;
5939 cmdline_fixed_string_t port;
5940 cmdline_fixed_string_t what;
5944 static void cmd_showport_parsed(void *parsed_result,
5945 __attribute__((unused)) struct cmdline *cl,
5946 __attribute__((unused)) void *data)
5948 struct cmd_showport_result *res = parsed_result;
5949 if (!strcmp(res->show, "clear")) {
5950 if (!strcmp(res->what, "stats"))
5951 nic_stats_clear(res->portnum);
5952 else if (!strcmp(res->what, "xstats"))
5953 nic_xstats_clear(res->portnum);
5954 } else if (!strcmp(res->what, "info"))
5955 port_infos_display(res->portnum);
5956 else if (!strcmp(res->what, "stats"))
5957 nic_stats_display(res->portnum);
5958 else if (!strcmp(res->what, "xstats"))
5959 nic_xstats_display(res->portnum);
5960 else if (!strcmp(res->what, "fdir"))
5961 fdir_get_infos(res->portnum);
5962 else if (!strcmp(res->what, "stat_qmap"))
5963 nic_stats_mapping_display(res->portnum);
5964 else if (!strcmp(res->what, "dcb_tc"))
5965 port_dcb_info_display(res->portnum);
5966 else if (!strcmp(res->what, "cap"))
5967 port_offload_cap_display(res->portnum);
5970 cmdline_parse_token_string_t cmd_showport_show =
5971 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5973 cmdline_parse_token_string_t cmd_showport_port =
5974 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5975 cmdline_parse_token_string_t cmd_showport_what =
5976 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5977 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5978 cmdline_parse_token_num_t cmd_showport_portnum =
5979 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5981 cmdline_parse_inst_t cmd_showport = {
5982 .f = cmd_showport_parsed,
5984 .help_str = "show|clear port "
5985 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5988 (void *)&cmd_showport_show,
5989 (void *)&cmd_showport_port,
5990 (void *)&cmd_showport_what,
5991 (void *)&cmd_showport_portnum,
5996 /* *** SHOW QUEUE INFO *** */
5997 struct cmd_showqueue_result {
5998 cmdline_fixed_string_t show;
5999 cmdline_fixed_string_t type;
6000 cmdline_fixed_string_t what;
6006 cmd_showqueue_parsed(void *parsed_result,
6007 __attribute__((unused)) struct cmdline *cl,
6008 __attribute__((unused)) void *data)
6010 struct cmd_showqueue_result *res = parsed_result;
6012 if (!strcmp(res->type, "rxq"))
6013 rx_queue_infos_display(res->portnum, res->queuenum);
6014 else if (!strcmp(res->type, "txq"))
6015 tx_queue_infos_display(res->portnum, res->queuenum);
6018 cmdline_parse_token_string_t cmd_showqueue_show =
6019 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6020 cmdline_parse_token_string_t cmd_showqueue_type =
6021 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6022 cmdline_parse_token_string_t cmd_showqueue_what =
6023 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6024 cmdline_parse_token_num_t cmd_showqueue_portnum =
6025 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6026 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6027 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6029 cmdline_parse_inst_t cmd_showqueue = {
6030 .f = cmd_showqueue_parsed,
6032 .help_str = "show rxq|txq info <port_id> <queue_id>",
6034 (void *)&cmd_showqueue_show,
6035 (void *)&cmd_showqueue_type,
6036 (void *)&cmd_showqueue_what,
6037 (void *)&cmd_showqueue_portnum,
6038 (void *)&cmd_showqueue_queuenum,
6043 /* *** READ PORT REGISTER *** */
6044 struct cmd_read_reg_result {
6045 cmdline_fixed_string_t read;
6046 cmdline_fixed_string_t reg;
6052 cmd_read_reg_parsed(void *parsed_result,
6053 __attribute__((unused)) struct cmdline *cl,
6054 __attribute__((unused)) void *data)
6056 struct cmd_read_reg_result *res = parsed_result;
6057 port_reg_display(res->port_id, res->reg_off);
6060 cmdline_parse_token_string_t cmd_read_reg_read =
6061 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6062 cmdline_parse_token_string_t cmd_read_reg_reg =
6063 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6064 cmdline_parse_token_num_t cmd_read_reg_port_id =
6065 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6066 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6067 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6069 cmdline_parse_inst_t cmd_read_reg = {
6070 .f = cmd_read_reg_parsed,
6072 .help_str = "read reg <port_id> <reg_off>",
6074 (void *)&cmd_read_reg_read,
6075 (void *)&cmd_read_reg_reg,
6076 (void *)&cmd_read_reg_port_id,
6077 (void *)&cmd_read_reg_reg_off,
6082 /* *** READ PORT REGISTER BIT FIELD *** */
6083 struct cmd_read_reg_bit_field_result {
6084 cmdline_fixed_string_t read;
6085 cmdline_fixed_string_t regfield;
6093 cmd_read_reg_bit_field_parsed(void *parsed_result,
6094 __attribute__((unused)) struct cmdline *cl,
6095 __attribute__((unused)) void *data)
6097 struct cmd_read_reg_bit_field_result *res = parsed_result;
6098 port_reg_bit_field_display(res->port_id, res->reg_off,
6099 res->bit1_pos, res->bit2_pos);
6102 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6103 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6105 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6106 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6107 regfield, "regfield");
6108 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6109 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6111 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6112 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6114 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6115 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6117 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6118 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6121 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6122 .f = cmd_read_reg_bit_field_parsed,
6124 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6125 "Read register bit field between bit_x and bit_y included",
6127 (void *)&cmd_read_reg_bit_field_read,
6128 (void *)&cmd_read_reg_bit_field_regfield,
6129 (void *)&cmd_read_reg_bit_field_port_id,
6130 (void *)&cmd_read_reg_bit_field_reg_off,
6131 (void *)&cmd_read_reg_bit_field_bit1_pos,
6132 (void *)&cmd_read_reg_bit_field_bit2_pos,
6137 /* *** READ PORT REGISTER BIT *** */
6138 struct cmd_read_reg_bit_result {
6139 cmdline_fixed_string_t read;
6140 cmdline_fixed_string_t regbit;
6147 cmd_read_reg_bit_parsed(void *parsed_result,
6148 __attribute__((unused)) struct cmdline *cl,
6149 __attribute__((unused)) void *data)
6151 struct cmd_read_reg_bit_result *res = parsed_result;
6152 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6155 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6156 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6157 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6158 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6160 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6161 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6162 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6163 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6164 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6165 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6167 cmdline_parse_inst_t cmd_read_reg_bit = {
6168 .f = cmd_read_reg_bit_parsed,
6170 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6172 (void *)&cmd_read_reg_bit_read,
6173 (void *)&cmd_read_reg_bit_regbit,
6174 (void *)&cmd_read_reg_bit_port_id,
6175 (void *)&cmd_read_reg_bit_reg_off,
6176 (void *)&cmd_read_reg_bit_bit_pos,
6181 /* *** WRITE PORT REGISTER *** */
6182 struct cmd_write_reg_result {
6183 cmdline_fixed_string_t write;
6184 cmdline_fixed_string_t reg;
6191 cmd_write_reg_parsed(void *parsed_result,
6192 __attribute__((unused)) struct cmdline *cl,
6193 __attribute__((unused)) void *data)
6195 struct cmd_write_reg_result *res = parsed_result;
6196 port_reg_set(res->port_id, res->reg_off, res->value);
6199 cmdline_parse_token_string_t cmd_write_reg_write =
6200 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6201 cmdline_parse_token_string_t cmd_write_reg_reg =
6202 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6203 cmdline_parse_token_num_t cmd_write_reg_port_id =
6204 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6205 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6206 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6207 cmdline_parse_token_num_t cmd_write_reg_value =
6208 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6210 cmdline_parse_inst_t cmd_write_reg = {
6211 .f = cmd_write_reg_parsed,
6213 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6215 (void *)&cmd_write_reg_write,
6216 (void *)&cmd_write_reg_reg,
6217 (void *)&cmd_write_reg_port_id,
6218 (void *)&cmd_write_reg_reg_off,
6219 (void *)&cmd_write_reg_value,
6224 /* *** WRITE PORT REGISTER BIT FIELD *** */
6225 struct cmd_write_reg_bit_field_result {
6226 cmdline_fixed_string_t write;
6227 cmdline_fixed_string_t regfield;
6236 cmd_write_reg_bit_field_parsed(void *parsed_result,
6237 __attribute__((unused)) struct cmdline *cl,
6238 __attribute__((unused)) void *data)
6240 struct cmd_write_reg_bit_field_result *res = parsed_result;
6241 port_reg_bit_field_set(res->port_id, res->reg_off,
6242 res->bit1_pos, res->bit2_pos, res->value);
6245 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6246 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6248 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6249 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6250 regfield, "regfield");
6251 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6252 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6254 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6255 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6257 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6258 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6260 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6261 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6263 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6264 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6267 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6268 .f = cmd_write_reg_bit_field_parsed,
6270 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6272 "Set register bit field between bit_x and bit_y included",
6274 (void *)&cmd_write_reg_bit_field_write,
6275 (void *)&cmd_write_reg_bit_field_regfield,
6276 (void *)&cmd_write_reg_bit_field_port_id,
6277 (void *)&cmd_write_reg_bit_field_reg_off,
6278 (void *)&cmd_write_reg_bit_field_bit1_pos,
6279 (void *)&cmd_write_reg_bit_field_bit2_pos,
6280 (void *)&cmd_write_reg_bit_field_value,
6285 /* *** WRITE PORT REGISTER BIT *** */
6286 struct cmd_write_reg_bit_result {
6287 cmdline_fixed_string_t write;
6288 cmdline_fixed_string_t regbit;
6296 cmd_write_reg_bit_parsed(void *parsed_result,
6297 __attribute__((unused)) struct cmdline *cl,
6298 __attribute__((unused)) void *data)
6300 struct cmd_write_reg_bit_result *res = parsed_result;
6301 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6304 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6305 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6307 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6308 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6310 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6311 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6312 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6313 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6314 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6315 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6316 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6317 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6319 cmdline_parse_inst_t cmd_write_reg_bit = {
6320 .f = cmd_write_reg_bit_parsed,
6322 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6325 (void *)&cmd_write_reg_bit_write,
6326 (void *)&cmd_write_reg_bit_regbit,
6327 (void *)&cmd_write_reg_bit_port_id,
6328 (void *)&cmd_write_reg_bit_reg_off,
6329 (void *)&cmd_write_reg_bit_bit_pos,
6330 (void *)&cmd_write_reg_bit_value,
6335 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6336 struct cmd_read_rxd_txd_result {
6337 cmdline_fixed_string_t read;
6338 cmdline_fixed_string_t rxd_txd;
6345 cmd_read_rxd_txd_parsed(void *parsed_result,
6346 __attribute__((unused)) struct cmdline *cl,
6347 __attribute__((unused)) void *data)
6349 struct cmd_read_rxd_txd_result *res = parsed_result;
6351 if (!strcmp(res->rxd_txd, "rxd"))
6352 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6353 else if (!strcmp(res->rxd_txd, "txd"))
6354 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6357 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6358 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6359 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6360 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6362 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6363 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6364 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6365 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6366 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6367 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6369 cmdline_parse_inst_t cmd_read_rxd_txd = {
6370 .f = cmd_read_rxd_txd_parsed,
6372 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6374 (void *)&cmd_read_rxd_txd_read,
6375 (void *)&cmd_read_rxd_txd_rxd_txd,
6376 (void *)&cmd_read_rxd_txd_port_id,
6377 (void *)&cmd_read_rxd_txd_queue_id,
6378 (void *)&cmd_read_rxd_txd_desc_id,
6384 struct cmd_quit_result {
6385 cmdline_fixed_string_t quit;
6388 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6390 __attribute__((unused)) void *data)
6396 cmdline_parse_token_string_t cmd_quit_quit =
6397 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6399 cmdline_parse_inst_t cmd_quit = {
6400 .f = cmd_quit_parsed,
6402 .help_str = "quit: Exit application",
6404 (void *)&cmd_quit_quit,
6409 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6410 struct cmd_mac_addr_result {
6411 cmdline_fixed_string_t mac_addr_cmd;
6412 cmdline_fixed_string_t what;
6414 struct ether_addr address;
6417 static void cmd_mac_addr_parsed(void *parsed_result,
6418 __attribute__((unused)) struct cmdline *cl,
6419 __attribute__((unused)) void *data)
6421 struct cmd_mac_addr_result *res = parsed_result;
6424 if (strcmp(res->what, "add") == 0)
6425 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6426 else if (strcmp(res->what, "set") == 0)
6427 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6430 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6432 /* check the return value and print it if is < 0 */
6434 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6438 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6439 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6441 cmdline_parse_token_string_t cmd_mac_addr_what =
6442 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6444 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6445 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6446 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6447 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6449 cmdline_parse_inst_t cmd_mac_addr = {
6450 .f = cmd_mac_addr_parsed,
6452 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6453 "Add/Remove/Set MAC address on port_id",
6455 (void *)&cmd_mac_addr_cmd,
6456 (void *)&cmd_mac_addr_what,
6457 (void *)&cmd_mac_addr_portnum,
6458 (void *)&cmd_mac_addr_addr,
6464 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6465 struct cmd_set_qmap_result {
6466 cmdline_fixed_string_t set;
6467 cmdline_fixed_string_t qmap;
6468 cmdline_fixed_string_t what;
6475 cmd_set_qmap_parsed(void *parsed_result,
6476 __attribute__((unused)) struct cmdline *cl,
6477 __attribute__((unused)) void *data)
6479 struct cmd_set_qmap_result *res = parsed_result;
6480 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6482 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6485 cmdline_parse_token_string_t cmd_setqmap_set =
6486 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6488 cmdline_parse_token_string_t cmd_setqmap_qmap =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6491 cmdline_parse_token_string_t cmd_setqmap_what =
6492 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6494 cmdline_parse_token_num_t cmd_setqmap_portid =
6495 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6497 cmdline_parse_token_num_t cmd_setqmap_queueid =
6498 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6500 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6501 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6504 cmdline_parse_inst_t cmd_set_qmap = {
6505 .f = cmd_set_qmap_parsed,
6507 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6508 "Set statistics mapping value on tx|rx queue_id of port_id",
6510 (void *)&cmd_setqmap_set,
6511 (void *)&cmd_setqmap_qmap,
6512 (void *)&cmd_setqmap_what,
6513 (void *)&cmd_setqmap_portid,
6514 (void *)&cmd_setqmap_queueid,
6515 (void *)&cmd_setqmap_mapvalue,
6520 /* *** CONFIGURE UNICAST HASH TABLE *** */
6521 struct cmd_set_uc_hash_table {
6522 cmdline_fixed_string_t set;
6523 cmdline_fixed_string_t port;
6525 cmdline_fixed_string_t what;
6526 struct ether_addr address;
6527 cmdline_fixed_string_t mode;
6531 cmd_set_uc_hash_parsed(void *parsed_result,
6532 __attribute__((unused)) struct cmdline *cl,
6533 __attribute__((unused)) void *data)
6536 struct cmd_set_uc_hash_table *res = parsed_result;
6538 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6540 if (strcmp(res->what, "uta") == 0)
6541 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6542 &res->address,(uint8_t)is_on);
6544 printf("bad unicast hash table parameter, return code = %d \n", ret);
6548 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6551 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6554 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6555 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6557 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6558 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6560 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6561 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6563 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6564 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6567 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6568 .f = cmd_set_uc_hash_parsed,
6570 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6572 (void *)&cmd_set_uc_hash_set,
6573 (void *)&cmd_set_uc_hash_port,
6574 (void *)&cmd_set_uc_hash_portid,
6575 (void *)&cmd_set_uc_hash_what,
6576 (void *)&cmd_set_uc_hash_mac,
6577 (void *)&cmd_set_uc_hash_mode,
6582 struct cmd_set_uc_all_hash_table {
6583 cmdline_fixed_string_t set;
6584 cmdline_fixed_string_t port;
6586 cmdline_fixed_string_t what;
6587 cmdline_fixed_string_t value;
6588 cmdline_fixed_string_t mode;
6592 cmd_set_uc_all_hash_parsed(void *parsed_result,
6593 __attribute__((unused)) struct cmdline *cl,
6594 __attribute__((unused)) void *data)
6597 struct cmd_set_uc_all_hash_table *res = parsed_result;
6599 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6601 if ((strcmp(res->what, "uta") == 0) &&
6602 (strcmp(res->value, "all") == 0))
6603 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6605 printf("bad unicast hash table parameter,"
6606 "return code = %d \n", ret);
6609 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6610 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6612 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6613 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6615 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6616 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6618 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6621 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6624 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6625 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6628 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6629 .f = cmd_set_uc_all_hash_parsed,
6631 .help_str = "set port <port_id> uta all on|off",
6633 (void *)&cmd_set_uc_all_hash_set,
6634 (void *)&cmd_set_uc_all_hash_port,
6635 (void *)&cmd_set_uc_all_hash_portid,
6636 (void *)&cmd_set_uc_all_hash_what,
6637 (void *)&cmd_set_uc_all_hash_value,
6638 (void *)&cmd_set_uc_all_hash_mode,
6643 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6644 struct cmd_set_vf_macvlan_filter {
6645 cmdline_fixed_string_t set;
6646 cmdline_fixed_string_t port;
6648 cmdline_fixed_string_t vf;
6650 struct ether_addr address;
6651 cmdline_fixed_string_t filter_type;
6652 cmdline_fixed_string_t mode;
6656 cmd_set_vf_macvlan_parsed(void *parsed_result,
6657 __attribute__((unused)) struct cmdline *cl,
6658 __attribute__((unused)) void *data)
6661 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6662 struct rte_eth_mac_filter filter;
6664 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6666 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6668 /* set VF MAC filter */
6672 filter.dst_id = res->vf_id;
6674 if (!strcmp(res->filter_type, "exact-mac"))
6675 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6676 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6677 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6678 else if (!strcmp(res->filter_type, "hashmac"))
6679 filter.filter_type = RTE_MAC_HASH_MATCH;
6680 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6681 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6683 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6686 ret = rte_eth_dev_filter_ctrl(res->port_id,
6687 RTE_ETH_FILTER_MACVLAN,
6691 ret = rte_eth_dev_filter_ctrl(res->port_id,
6692 RTE_ETH_FILTER_MACVLAN,
6693 RTE_ETH_FILTER_DELETE,
6697 printf("bad set MAC hash parameter, return code = %d\n", ret);
6701 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6704 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6705 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6707 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6708 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6710 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6711 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6713 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6714 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6716 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6717 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6719 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6720 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6721 filter_type, "exact-mac#exact-mac-vlan"
6722 "#hashmac#hashmac-vlan");
6723 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6724 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6727 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6728 .f = cmd_set_vf_macvlan_parsed,
6730 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6731 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6732 "Exact match rule: exact match of MAC or MAC and VLAN; "
6733 "hash match rule: hash match of MAC and exact match of VLAN",
6735 (void *)&cmd_set_vf_macvlan_set,
6736 (void *)&cmd_set_vf_macvlan_port,
6737 (void *)&cmd_set_vf_macvlan_portid,
6738 (void *)&cmd_set_vf_macvlan_vf,
6739 (void *)&cmd_set_vf_macvlan_vf_id,
6740 (void *)&cmd_set_vf_macvlan_mac,
6741 (void *)&cmd_set_vf_macvlan_filter_type,
6742 (void *)&cmd_set_vf_macvlan_mode,
6747 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6748 struct cmd_set_vf_traffic {
6749 cmdline_fixed_string_t set;
6750 cmdline_fixed_string_t port;
6752 cmdline_fixed_string_t vf;
6754 cmdline_fixed_string_t what;
6755 cmdline_fixed_string_t mode;
6759 cmd_set_vf_traffic_parsed(void *parsed_result,
6760 __attribute__((unused)) struct cmdline *cl,
6761 __attribute__((unused)) void *data)
6763 struct cmd_set_vf_traffic *res = parsed_result;
6764 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6765 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6767 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6770 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6771 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6773 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6774 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6776 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6777 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6779 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6780 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6782 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6783 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6785 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6786 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6788 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6789 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6792 cmdline_parse_inst_t cmd_set_vf_traffic = {
6793 .f = cmd_set_vf_traffic_parsed,
6795 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6797 (void *)&cmd_setvf_traffic_set,
6798 (void *)&cmd_setvf_traffic_port,
6799 (void *)&cmd_setvf_traffic_portid,
6800 (void *)&cmd_setvf_traffic_vf,
6801 (void *)&cmd_setvf_traffic_vfid,
6802 (void *)&cmd_setvf_traffic_what,
6803 (void *)&cmd_setvf_traffic_mode,
6808 /* *** CONFIGURE VF RECEIVE MODE *** */
6809 struct cmd_set_vf_rxmode {
6810 cmdline_fixed_string_t set;
6811 cmdline_fixed_string_t port;
6813 cmdline_fixed_string_t vf;
6815 cmdline_fixed_string_t what;
6816 cmdline_fixed_string_t mode;
6817 cmdline_fixed_string_t on;
6821 cmd_set_vf_rxmode_parsed(void *parsed_result,
6822 __attribute__((unused)) struct cmdline *cl,
6823 __attribute__((unused)) void *data)
6826 uint16_t rx_mode = 0;
6827 struct cmd_set_vf_rxmode *res = parsed_result;
6829 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6830 if (!strcmp(res->what,"rxmode")) {
6831 if (!strcmp(res->mode, "AUPE"))
6832 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6833 else if (!strcmp(res->mode, "ROPE"))
6834 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6835 else if (!strcmp(res->mode, "BAM"))
6836 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6837 else if (!strncmp(res->mode, "MPE",3))
6838 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6841 #ifdef RTE_LIBRTE_IXGBE_PMD
6842 if (ret == -ENOTSUP)
6843 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
6844 rx_mode, (uint8_t)is_on);
6846 #ifdef RTE_LIBRTE_BNXT_PMD
6847 if (ret == -ENOTSUP)
6848 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
6849 rx_mode, (uint8_t)is_on);
6852 printf("bad VF receive mode parameter, return code = %d \n",
6856 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6857 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6859 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6860 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6862 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6863 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6865 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6866 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6868 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6869 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6871 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6872 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6874 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6875 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6876 mode, "AUPE#ROPE#BAM#MPE");
6877 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6878 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6881 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6882 .f = cmd_set_vf_rxmode_parsed,
6884 .help_str = "set port <port_id> vf <vf_id> rxmode "
6885 "AUPE|ROPE|BAM|MPE on|off",
6887 (void *)&cmd_set_vf_rxmode_set,
6888 (void *)&cmd_set_vf_rxmode_port,
6889 (void *)&cmd_set_vf_rxmode_portid,
6890 (void *)&cmd_set_vf_rxmode_vf,
6891 (void *)&cmd_set_vf_rxmode_vfid,
6892 (void *)&cmd_set_vf_rxmode_what,
6893 (void *)&cmd_set_vf_rxmode_mode,
6894 (void *)&cmd_set_vf_rxmode_on,
6899 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6900 struct cmd_vf_mac_addr_result {
6901 cmdline_fixed_string_t mac_addr_cmd;
6902 cmdline_fixed_string_t what;
6903 cmdline_fixed_string_t port;
6905 cmdline_fixed_string_t vf;
6907 struct ether_addr address;
6910 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6911 __attribute__((unused)) struct cmdline *cl,
6912 __attribute__((unused)) void *data)
6914 struct cmd_vf_mac_addr_result *res = parsed_result;
6917 if (strcmp(res->what, "add") == 0)
6918 ret = rte_eth_dev_mac_addr_add(res->port_num,
6919 &res->address, res->vf_num);
6921 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6925 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6926 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6927 mac_addr_cmd,"mac_addr");
6928 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6929 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6931 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6932 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6934 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6935 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6937 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6938 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6940 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6941 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6943 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6944 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6947 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6948 .f = cmd_vf_mac_addr_parsed,
6950 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6951 "Add MAC address filtering for a VF on port_id",
6953 (void *)&cmd_vf_mac_addr_cmd,
6954 (void *)&cmd_vf_mac_addr_what,
6955 (void *)&cmd_vf_mac_addr_port,
6956 (void *)&cmd_vf_mac_addr_portnum,
6957 (void *)&cmd_vf_mac_addr_vf,
6958 (void *)&cmd_vf_mac_addr_vfnum,
6959 (void *)&cmd_vf_mac_addr_addr,
6964 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6965 struct cmd_vf_rx_vlan_filter {
6966 cmdline_fixed_string_t rx_vlan;
6967 cmdline_fixed_string_t what;
6969 cmdline_fixed_string_t port;
6971 cmdline_fixed_string_t vf;
6976 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6977 __attribute__((unused)) struct cmdline *cl,
6978 __attribute__((unused)) void *data)
6980 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6983 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6985 #ifdef RTE_LIBRTE_IXGBE_PMD
6986 if (ret == -ENOTSUP)
6987 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6988 res->vlan_id, res->vf_mask, is_add);
6990 #ifdef RTE_LIBRTE_I40E_PMD
6991 if (ret == -ENOTSUP)
6992 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6993 res->vlan_id, res->vf_mask, is_add);
6995 #ifdef RTE_LIBRTE_BNXT_PMD
6996 if (ret == -ENOTSUP)
6997 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
6998 res->vlan_id, res->vf_mask, is_add);
7005 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7006 res->vlan_id, res->vf_mask);
7009 printf("invalid port_id %d\n", res->port_id);
7012 printf("function not implemented or supported\n");
7015 printf("programming error: (%s)\n", strerror(-ret));
7019 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7020 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7021 rx_vlan, "rx_vlan");
7022 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7023 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7025 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7026 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7028 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7029 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7031 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7032 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7034 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7035 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7037 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7038 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7041 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7042 .f = cmd_vf_rx_vlan_filter_parsed,
7044 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7045 "(vf_mask = hexadecimal VF mask)",
7047 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7048 (void *)&cmd_vf_rx_vlan_filter_what,
7049 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7050 (void *)&cmd_vf_rx_vlan_filter_port,
7051 (void *)&cmd_vf_rx_vlan_filter_portid,
7052 (void *)&cmd_vf_rx_vlan_filter_vf,
7053 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7058 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7059 struct cmd_queue_rate_limit_result {
7060 cmdline_fixed_string_t set;
7061 cmdline_fixed_string_t port;
7063 cmdline_fixed_string_t queue;
7065 cmdline_fixed_string_t rate;
7069 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7070 __attribute__((unused)) struct cmdline *cl,
7071 __attribute__((unused)) void *data)
7073 struct cmd_queue_rate_limit_result *res = parsed_result;
7076 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7077 && (strcmp(res->queue, "queue") == 0)
7078 && (strcmp(res->rate, "rate") == 0))
7079 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7082 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7086 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7087 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7089 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7090 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7092 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7093 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7095 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7096 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7098 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7099 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7101 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7102 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7104 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7105 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7108 cmdline_parse_inst_t cmd_queue_rate_limit = {
7109 .f = cmd_queue_rate_limit_parsed,
7111 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7112 "Set rate limit for a queue on port_id",
7114 (void *)&cmd_queue_rate_limit_set,
7115 (void *)&cmd_queue_rate_limit_port,
7116 (void *)&cmd_queue_rate_limit_portnum,
7117 (void *)&cmd_queue_rate_limit_queue,
7118 (void *)&cmd_queue_rate_limit_queuenum,
7119 (void *)&cmd_queue_rate_limit_rate,
7120 (void *)&cmd_queue_rate_limit_ratenum,
7125 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7126 struct cmd_vf_rate_limit_result {
7127 cmdline_fixed_string_t set;
7128 cmdline_fixed_string_t port;
7130 cmdline_fixed_string_t vf;
7132 cmdline_fixed_string_t rate;
7134 cmdline_fixed_string_t q_msk;
7138 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7139 __attribute__((unused)) struct cmdline *cl,
7140 __attribute__((unused)) void *data)
7142 struct cmd_vf_rate_limit_result *res = parsed_result;
7145 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7146 && (strcmp(res->vf, "vf") == 0)
7147 && (strcmp(res->rate, "rate") == 0)
7148 && (strcmp(res->q_msk, "queue_mask") == 0))
7149 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7150 res->rate_num, res->q_msk_val);
7152 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7156 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7157 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7159 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7160 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7162 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7163 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7165 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7166 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7168 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7169 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7171 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7172 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7174 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7175 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7177 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7178 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7179 q_msk, "queue_mask");
7180 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7181 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7184 cmdline_parse_inst_t cmd_vf_rate_limit = {
7185 .f = cmd_vf_rate_limit_parsed,
7187 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7188 "queue_mask <queue_mask_value>: "
7189 "Set rate limit for queues of VF on port_id",
7191 (void *)&cmd_vf_rate_limit_set,
7192 (void *)&cmd_vf_rate_limit_port,
7193 (void *)&cmd_vf_rate_limit_portnum,
7194 (void *)&cmd_vf_rate_limit_vf,
7195 (void *)&cmd_vf_rate_limit_vfnum,
7196 (void *)&cmd_vf_rate_limit_rate,
7197 (void *)&cmd_vf_rate_limit_ratenum,
7198 (void *)&cmd_vf_rate_limit_q_msk,
7199 (void *)&cmd_vf_rate_limit_q_msk_val,
7204 /* *** ADD TUNNEL FILTER OF A PORT *** */
7205 struct cmd_tunnel_filter_result {
7206 cmdline_fixed_string_t cmd;
7207 cmdline_fixed_string_t what;
7209 struct ether_addr outer_mac;
7210 struct ether_addr inner_mac;
7211 cmdline_ipaddr_t ip_value;
7212 uint16_t inner_vlan;
7213 cmdline_fixed_string_t tunnel_type;
7214 cmdline_fixed_string_t filter_type;
7220 cmd_tunnel_filter_parsed(void *parsed_result,
7221 __attribute__((unused)) struct cmdline *cl,
7222 __attribute__((unused)) void *data)
7224 struct cmd_tunnel_filter_result *res = parsed_result;
7225 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7228 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7230 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7231 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7232 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7234 if (res->ip_value.family == AF_INET) {
7235 tunnel_filter_conf.ip_addr.ipv4_addr =
7236 res->ip_value.addr.ipv4.s_addr;
7237 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7239 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7240 &(res->ip_value.addr.ipv6),
7241 sizeof(struct in6_addr));
7242 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7245 if (!strcmp(res->filter_type, "imac-ivlan"))
7246 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7247 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7248 tunnel_filter_conf.filter_type =
7249 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7250 else if (!strcmp(res->filter_type, "imac-tenid"))
7251 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7252 else if (!strcmp(res->filter_type, "imac"))
7253 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7254 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7255 tunnel_filter_conf.filter_type =
7256 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7257 else if (!strcmp(res->filter_type, "oip"))
7258 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7259 else if (!strcmp(res->filter_type, "iip"))
7260 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7262 printf("The filter type is not supported");
7266 if (!strcmp(res->tunnel_type, "vxlan"))
7267 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7268 else if (!strcmp(res->tunnel_type, "nvgre"))
7269 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7270 else if (!strcmp(res->tunnel_type, "ipingre"))
7271 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7273 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7277 tunnel_filter_conf.tenant_id = res->tenant_id;
7278 tunnel_filter_conf.queue_id = res->queue_num;
7279 if (!strcmp(res->what, "add"))
7280 ret = rte_eth_dev_filter_ctrl(res->port_id,
7281 RTE_ETH_FILTER_TUNNEL,
7283 &tunnel_filter_conf);
7285 ret = rte_eth_dev_filter_ctrl(res->port_id,
7286 RTE_ETH_FILTER_TUNNEL,
7287 RTE_ETH_FILTER_DELETE,
7288 &tunnel_filter_conf);
7290 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7294 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7295 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7296 cmd, "tunnel_filter");
7297 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7298 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7300 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7301 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7303 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7304 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7306 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7307 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7309 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7310 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7311 inner_vlan, UINT16);
7312 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7313 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7315 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7316 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7317 tunnel_type, "vxlan#nvgre#ipingre");
7319 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7320 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7321 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7322 "imac#omac-imac-tenid");
7323 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7324 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7326 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7327 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7330 cmdline_parse_inst_t cmd_tunnel_filter = {
7331 .f = cmd_tunnel_filter_parsed,
7333 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7334 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7335 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7336 "<queue_id>: Add/Rm tunnel filter of a port",
7338 (void *)&cmd_tunnel_filter_cmd,
7339 (void *)&cmd_tunnel_filter_what,
7340 (void *)&cmd_tunnel_filter_port_id,
7341 (void *)&cmd_tunnel_filter_outer_mac,
7342 (void *)&cmd_tunnel_filter_inner_mac,
7343 (void *)&cmd_tunnel_filter_ip_value,
7344 (void *)&cmd_tunnel_filter_innner_vlan,
7345 (void *)&cmd_tunnel_filter_tunnel_type,
7346 (void *)&cmd_tunnel_filter_filter_type,
7347 (void *)&cmd_tunnel_filter_tenant_id,
7348 (void *)&cmd_tunnel_filter_queue_num,
7353 /* *** CONFIGURE TUNNEL UDP PORT *** */
7354 struct cmd_tunnel_udp_config {
7355 cmdline_fixed_string_t cmd;
7356 cmdline_fixed_string_t what;
7362 cmd_tunnel_udp_config_parsed(void *parsed_result,
7363 __attribute__((unused)) struct cmdline *cl,
7364 __attribute__((unused)) void *data)
7366 struct cmd_tunnel_udp_config *res = parsed_result;
7367 struct rte_eth_udp_tunnel tunnel_udp;
7370 tunnel_udp.udp_port = res->udp_port;
7372 if (!strcmp(res->cmd, "rx_vxlan_port"))
7373 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7375 if (!strcmp(res->what, "add"))
7376 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7379 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7383 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7386 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7387 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7388 cmd, "rx_vxlan_port");
7389 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7390 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7392 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7393 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7395 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7396 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7399 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7400 .f = cmd_tunnel_udp_config_parsed,
7402 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7403 "Add/Remove a tunneling UDP port filter",
7405 (void *)&cmd_tunnel_udp_config_cmd,
7406 (void *)&cmd_tunnel_udp_config_what,
7407 (void *)&cmd_tunnel_udp_config_udp_port,
7408 (void *)&cmd_tunnel_udp_config_port_id,
7413 /* *** GLOBAL CONFIG *** */
7414 struct cmd_global_config_result {
7415 cmdline_fixed_string_t cmd;
7417 cmdline_fixed_string_t cfg_type;
7422 cmd_global_config_parsed(void *parsed_result,
7423 __attribute__((unused)) struct cmdline *cl,
7424 __attribute__((unused)) void *data)
7426 struct cmd_global_config_result *res = parsed_result;
7427 struct rte_eth_global_cfg conf;
7430 memset(&conf, 0, sizeof(conf));
7431 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7432 conf.cfg.gre_key_len = res->len;
7433 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7434 RTE_ETH_FILTER_SET, &conf);
7436 printf("Global config error\n");
7439 cmdline_parse_token_string_t cmd_global_config_cmd =
7440 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7442 cmdline_parse_token_num_t cmd_global_config_port_id =
7443 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7444 cmdline_parse_token_string_t cmd_global_config_type =
7445 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7446 cfg_type, "gre-key-len");
7447 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7448 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7451 cmdline_parse_inst_t cmd_global_config = {
7452 .f = cmd_global_config_parsed,
7453 .data = (void *)NULL,
7454 .help_str = "global_config <port_id> gre-key-len <key_len>",
7456 (void *)&cmd_global_config_cmd,
7457 (void *)&cmd_global_config_port_id,
7458 (void *)&cmd_global_config_type,
7459 (void *)&cmd_global_config_gre_key_len,
7464 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7465 struct cmd_set_mirror_mask_result {
7466 cmdline_fixed_string_t set;
7467 cmdline_fixed_string_t port;
7469 cmdline_fixed_string_t mirror;
7471 cmdline_fixed_string_t what;
7472 cmdline_fixed_string_t value;
7473 cmdline_fixed_string_t dstpool;
7475 cmdline_fixed_string_t on;
7478 cmdline_parse_token_string_t cmd_mirror_mask_set =
7479 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7481 cmdline_parse_token_string_t cmd_mirror_mask_port =
7482 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7484 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7485 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7487 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7488 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7489 mirror, "mirror-rule");
7490 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7491 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7493 cmdline_parse_token_string_t cmd_mirror_mask_what =
7494 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7495 what, "pool-mirror-up#pool-mirror-down"
7497 cmdline_parse_token_string_t cmd_mirror_mask_value =
7498 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7500 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7502 dstpool, "dst-pool");
7503 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7504 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7506 cmdline_parse_token_string_t cmd_mirror_mask_on =
7507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7511 cmd_set_mirror_mask_parsed(void *parsed_result,
7512 __attribute__((unused)) struct cmdline *cl,
7513 __attribute__((unused)) void *data)
7516 struct cmd_set_mirror_mask_result *res = parsed_result;
7517 struct rte_eth_mirror_conf mr_conf;
7519 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7521 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7523 mr_conf.dst_pool = res->dstpool_id;
7525 if (!strcmp(res->what, "pool-mirror-up")) {
7526 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7527 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7528 } else if (!strcmp(res->what, "pool-mirror-down")) {
7529 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7530 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7531 } else if (!strcmp(res->what, "vlan-mirror")) {
7532 mr_conf.rule_type = ETH_MIRROR_VLAN;
7533 nb_item = parse_item_list(res->value, "vlan",
7534 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7538 for (i = 0; i < nb_item; i++) {
7539 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7540 printf("Invalid vlan_id: must be < 4096\n");
7544 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7545 mr_conf.vlan.vlan_mask |= 1ULL << i;
7549 if (!strcmp(res->on, "on"))
7550 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7553 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7556 printf("mirror rule add error: (%s)\n", strerror(-ret));
7559 cmdline_parse_inst_t cmd_set_mirror_mask = {
7560 .f = cmd_set_mirror_mask_parsed,
7562 .help_str = "set port <port_id> mirror-rule <rule_id> "
7563 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7564 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7566 (void *)&cmd_mirror_mask_set,
7567 (void *)&cmd_mirror_mask_port,
7568 (void *)&cmd_mirror_mask_portid,
7569 (void *)&cmd_mirror_mask_mirror,
7570 (void *)&cmd_mirror_mask_ruleid,
7571 (void *)&cmd_mirror_mask_what,
7572 (void *)&cmd_mirror_mask_value,
7573 (void *)&cmd_mirror_mask_dstpool,
7574 (void *)&cmd_mirror_mask_poolid,
7575 (void *)&cmd_mirror_mask_on,
7580 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7581 struct cmd_set_mirror_link_result {
7582 cmdline_fixed_string_t set;
7583 cmdline_fixed_string_t port;
7585 cmdline_fixed_string_t mirror;
7587 cmdline_fixed_string_t what;
7588 cmdline_fixed_string_t dstpool;
7590 cmdline_fixed_string_t on;
7593 cmdline_parse_token_string_t cmd_mirror_link_set =
7594 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7596 cmdline_parse_token_string_t cmd_mirror_link_port =
7597 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7599 cmdline_parse_token_num_t cmd_mirror_link_portid =
7600 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7602 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7603 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7604 mirror, "mirror-rule");
7605 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7606 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7608 cmdline_parse_token_string_t cmd_mirror_link_what =
7609 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7610 what, "uplink-mirror#downlink-mirror");
7611 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7612 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7613 dstpool, "dst-pool");
7614 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7615 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7617 cmdline_parse_token_string_t cmd_mirror_link_on =
7618 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7622 cmd_set_mirror_link_parsed(void *parsed_result,
7623 __attribute__((unused)) struct cmdline *cl,
7624 __attribute__((unused)) void *data)
7627 struct cmd_set_mirror_link_result *res = parsed_result;
7628 struct rte_eth_mirror_conf mr_conf;
7630 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7631 if (!strcmp(res->what, "uplink-mirror"))
7632 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7634 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7636 mr_conf.dst_pool = res->dstpool_id;
7638 if (!strcmp(res->on, "on"))
7639 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7642 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7645 /* check the return value and print it if is < 0 */
7647 printf("mirror rule add error: (%s)\n", strerror(-ret));
7651 cmdline_parse_inst_t cmd_set_mirror_link = {
7652 .f = cmd_set_mirror_link_parsed,
7654 .help_str = "set port <port_id> mirror-rule <rule_id> "
7655 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7657 (void *)&cmd_mirror_link_set,
7658 (void *)&cmd_mirror_link_port,
7659 (void *)&cmd_mirror_link_portid,
7660 (void *)&cmd_mirror_link_mirror,
7661 (void *)&cmd_mirror_link_ruleid,
7662 (void *)&cmd_mirror_link_what,
7663 (void *)&cmd_mirror_link_dstpool,
7664 (void *)&cmd_mirror_link_poolid,
7665 (void *)&cmd_mirror_link_on,
7670 /* *** RESET VM MIRROR RULE *** */
7671 struct cmd_rm_mirror_rule_result {
7672 cmdline_fixed_string_t reset;
7673 cmdline_fixed_string_t port;
7675 cmdline_fixed_string_t mirror;
7679 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7680 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7682 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7683 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7685 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7686 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7688 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7689 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7690 mirror, "mirror-rule");
7691 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7692 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7696 cmd_reset_mirror_rule_parsed(void *parsed_result,
7697 __attribute__((unused)) struct cmdline *cl,
7698 __attribute__((unused)) void *data)
7701 struct cmd_set_mirror_link_result *res = parsed_result;
7703 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7705 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7708 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7709 .f = cmd_reset_mirror_rule_parsed,
7711 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7713 (void *)&cmd_rm_mirror_rule_reset,
7714 (void *)&cmd_rm_mirror_rule_port,
7715 (void *)&cmd_rm_mirror_rule_portid,
7716 (void *)&cmd_rm_mirror_rule_mirror,
7717 (void *)&cmd_rm_mirror_rule_ruleid,
7722 /* ******************************************************************************** */
7724 struct cmd_dump_result {
7725 cmdline_fixed_string_t dump;
7729 dump_struct_sizes(void)
7731 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7732 DUMP_SIZE(struct rte_mbuf);
7733 DUMP_SIZE(struct rte_mempool);
7734 DUMP_SIZE(struct rte_ring);
7738 static void cmd_dump_parsed(void *parsed_result,
7739 __attribute__((unused)) struct cmdline *cl,
7740 __attribute__((unused)) void *data)
7742 struct cmd_dump_result *res = parsed_result;
7744 if (!strcmp(res->dump, "dump_physmem"))
7745 rte_dump_physmem_layout(stdout);
7746 else if (!strcmp(res->dump, "dump_memzone"))
7747 rte_memzone_dump(stdout);
7748 else if (!strcmp(res->dump, "dump_struct_sizes"))
7749 dump_struct_sizes();
7750 else if (!strcmp(res->dump, "dump_ring"))
7751 rte_ring_list_dump(stdout);
7752 else if (!strcmp(res->dump, "dump_mempool"))
7753 rte_mempool_list_dump(stdout);
7754 else if (!strcmp(res->dump, "dump_devargs"))
7755 rte_eal_devargs_dump(stdout);
7756 else if (!strcmp(res->dump, "dump_log_types"))
7757 rte_log_dump(stdout);
7760 cmdline_parse_token_string_t cmd_dump_dump =
7761 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7764 "dump_struct_sizes#"
7770 cmdline_parse_inst_t cmd_dump = {
7771 .f = cmd_dump_parsed, /* function to call */
7772 .data = NULL, /* 2nd arg of func */
7773 .help_str = "Dump status",
7774 .tokens = { /* token list, NULL terminated */
7775 (void *)&cmd_dump_dump,
7780 /* ******************************************************************************** */
7782 struct cmd_dump_one_result {
7783 cmdline_fixed_string_t dump;
7784 cmdline_fixed_string_t name;
7787 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7788 __attribute__((unused)) void *data)
7790 struct cmd_dump_one_result *res = parsed_result;
7792 if (!strcmp(res->dump, "dump_ring")) {
7794 r = rte_ring_lookup(res->name);
7796 cmdline_printf(cl, "Cannot find ring\n");
7799 rte_ring_dump(stdout, r);
7800 } else if (!strcmp(res->dump, "dump_mempool")) {
7801 struct rte_mempool *mp;
7802 mp = rte_mempool_lookup(res->name);
7804 cmdline_printf(cl, "Cannot find mempool\n");
7807 rte_mempool_dump(stdout, mp);
7811 cmdline_parse_token_string_t cmd_dump_one_dump =
7812 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7813 "dump_ring#dump_mempool");
7815 cmdline_parse_token_string_t cmd_dump_one_name =
7816 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7818 cmdline_parse_inst_t cmd_dump_one = {
7819 .f = cmd_dump_one_parsed, /* function to call */
7820 .data = NULL, /* 2nd arg of func */
7821 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7822 .tokens = { /* token list, NULL terminated */
7823 (void *)&cmd_dump_one_dump,
7824 (void *)&cmd_dump_one_name,
7829 /* *** Add/Del syn filter *** */
7830 struct cmd_syn_filter_result {
7831 cmdline_fixed_string_t filter;
7833 cmdline_fixed_string_t ops;
7834 cmdline_fixed_string_t priority;
7835 cmdline_fixed_string_t high;
7836 cmdline_fixed_string_t queue;
7841 cmd_syn_filter_parsed(void *parsed_result,
7842 __attribute__((unused)) struct cmdline *cl,
7843 __attribute__((unused)) void *data)
7845 struct cmd_syn_filter_result *res = parsed_result;
7846 struct rte_eth_syn_filter syn_filter;
7849 ret = rte_eth_dev_filter_supported(res->port_id,
7850 RTE_ETH_FILTER_SYN);
7852 printf("syn filter is not supported on port %u.\n",
7857 memset(&syn_filter, 0, sizeof(syn_filter));
7859 if (!strcmp(res->ops, "add")) {
7860 if (!strcmp(res->high, "high"))
7861 syn_filter.hig_pri = 1;
7863 syn_filter.hig_pri = 0;
7865 syn_filter.queue = res->queue_id;
7866 ret = rte_eth_dev_filter_ctrl(res->port_id,
7871 ret = rte_eth_dev_filter_ctrl(res->port_id,
7873 RTE_ETH_FILTER_DELETE,
7877 printf("syn filter programming error: (%s)\n",
7881 cmdline_parse_token_string_t cmd_syn_filter_filter =
7882 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7883 filter, "syn_filter");
7884 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7885 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7887 cmdline_parse_token_string_t cmd_syn_filter_ops =
7888 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7890 cmdline_parse_token_string_t cmd_syn_filter_priority =
7891 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7892 priority, "priority");
7893 cmdline_parse_token_string_t cmd_syn_filter_high =
7894 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7896 cmdline_parse_token_string_t cmd_syn_filter_queue =
7897 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7899 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7900 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7903 cmdline_parse_inst_t cmd_syn_filter = {
7904 .f = cmd_syn_filter_parsed,
7906 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7907 "<queue_id>: Add/Delete syn filter",
7909 (void *)&cmd_syn_filter_filter,
7910 (void *)&cmd_syn_filter_port_id,
7911 (void *)&cmd_syn_filter_ops,
7912 (void *)&cmd_syn_filter_priority,
7913 (void *)&cmd_syn_filter_high,
7914 (void *)&cmd_syn_filter_queue,
7915 (void *)&cmd_syn_filter_queue_id,
7920 /* *** ADD/REMOVE A 2tuple FILTER *** */
7921 struct cmd_2tuple_filter_result {
7922 cmdline_fixed_string_t filter;
7924 cmdline_fixed_string_t ops;
7925 cmdline_fixed_string_t dst_port;
7926 uint16_t dst_port_value;
7927 cmdline_fixed_string_t protocol;
7928 uint8_t protocol_value;
7929 cmdline_fixed_string_t mask;
7931 cmdline_fixed_string_t tcp_flags;
7932 uint8_t tcp_flags_value;
7933 cmdline_fixed_string_t priority;
7934 uint8_t priority_value;
7935 cmdline_fixed_string_t queue;
7940 cmd_2tuple_filter_parsed(void *parsed_result,
7941 __attribute__((unused)) struct cmdline *cl,
7942 __attribute__((unused)) void *data)
7944 struct rte_eth_ntuple_filter filter;
7945 struct cmd_2tuple_filter_result *res = parsed_result;
7948 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7950 printf("ntuple filter is not supported on port %u.\n",
7955 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7957 filter.flags = RTE_2TUPLE_FLAGS;
7958 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7959 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7960 filter.proto = res->protocol_value;
7961 filter.priority = res->priority_value;
7962 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7963 printf("nonzero tcp_flags is only meaningful"
7964 " when protocol is TCP.\n");
7967 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7968 printf("invalid TCP flags.\n");
7972 if (res->tcp_flags_value != 0) {
7973 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7974 filter.tcp_flags = res->tcp_flags_value;
7977 /* need convert to big endian. */
7978 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7979 filter.queue = res->queue_id;
7981 if (!strcmp(res->ops, "add"))
7982 ret = rte_eth_dev_filter_ctrl(res->port_id,
7983 RTE_ETH_FILTER_NTUPLE,
7987 ret = rte_eth_dev_filter_ctrl(res->port_id,
7988 RTE_ETH_FILTER_NTUPLE,
7989 RTE_ETH_FILTER_DELETE,
7992 printf("2tuple filter programming error: (%s)\n",
7997 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7998 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7999 filter, "2tuple_filter");
8000 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8001 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8003 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8004 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8006 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8007 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8008 dst_port, "dst_port");
8009 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8010 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8011 dst_port_value, UINT16);
8012 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8013 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8014 protocol, "protocol");
8015 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8016 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8017 protocol_value, UINT8);
8018 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8019 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8021 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8022 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8024 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8025 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8026 tcp_flags, "tcp_flags");
8027 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8028 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8029 tcp_flags_value, UINT8);
8030 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8031 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8032 priority, "priority");
8033 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8034 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8035 priority_value, UINT8);
8036 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8037 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8039 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8040 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8043 cmdline_parse_inst_t cmd_2tuple_filter = {
8044 .f = cmd_2tuple_filter_parsed,
8046 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8047 "<value> mask <value> tcp_flags <value> priority <value> queue "
8048 "<queue_id>: Add a 2tuple filter",
8050 (void *)&cmd_2tuple_filter_filter,
8051 (void *)&cmd_2tuple_filter_port_id,
8052 (void *)&cmd_2tuple_filter_ops,
8053 (void *)&cmd_2tuple_filter_dst_port,
8054 (void *)&cmd_2tuple_filter_dst_port_value,
8055 (void *)&cmd_2tuple_filter_protocol,
8056 (void *)&cmd_2tuple_filter_protocol_value,
8057 (void *)&cmd_2tuple_filter_mask,
8058 (void *)&cmd_2tuple_filter_mask_value,
8059 (void *)&cmd_2tuple_filter_tcp_flags,
8060 (void *)&cmd_2tuple_filter_tcp_flags_value,
8061 (void *)&cmd_2tuple_filter_priority,
8062 (void *)&cmd_2tuple_filter_priority_value,
8063 (void *)&cmd_2tuple_filter_queue,
8064 (void *)&cmd_2tuple_filter_queue_id,
8069 /* *** ADD/REMOVE A 5tuple FILTER *** */
8070 struct cmd_5tuple_filter_result {
8071 cmdline_fixed_string_t filter;
8073 cmdline_fixed_string_t ops;
8074 cmdline_fixed_string_t dst_ip;
8075 cmdline_ipaddr_t dst_ip_value;
8076 cmdline_fixed_string_t src_ip;
8077 cmdline_ipaddr_t src_ip_value;
8078 cmdline_fixed_string_t dst_port;
8079 uint16_t dst_port_value;
8080 cmdline_fixed_string_t src_port;
8081 uint16_t src_port_value;
8082 cmdline_fixed_string_t protocol;
8083 uint8_t protocol_value;
8084 cmdline_fixed_string_t mask;
8086 cmdline_fixed_string_t tcp_flags;
8087 uint8_t tcp_flags_value;
8088 cmdline_fixed_string_t priority;
8089 uint8_t priority_value;
8090 cmdline_fixed_string_t queue;
8095 cmd_5tuple_filter_parsed(void *parsed_result,
8096 __attribute__((unused)) struct cmdline *cl,
8097 __attribute__((unused)) void *data)
8099 struct rte_eth_ntuple_filter filter;
8100 struct cmd_5tuple_filter_result *res = parsed_result;
8103 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8105 printf("ntuple filter is not supported on port %u.\n",
8110 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8112 filter.flags = RTE_5TUPLE_FLAGS;
8113 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8114 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8115 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8116 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8117 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8118 filter.proto = res->protocol_value;
8119 filter.priority = res->priority_value;
8120 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8121 printf("nonzero tcp_flags is only meaningful"
8122 " when protocol is TCP.\n");
8125 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8126 printf("invalid TCP flags.\n");
8130 if (res->tcp_flags_value != 0) {
8131 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8132 filter.tcp_flags = res->tcp_flags_value;
8135 if (res->dst_ip_value.family == AF_INET)
8136 /* no need to convert, already big endian. */
8137 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8139 if (filter.dst_ip_mask == 0) {
8140 printf("can not support ipv6 involved compare.\n");
8146 if (res->src_ip_value.family == AF_INET)
8147 /* no need to convert, already big endian. */
8148 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8150 if (filter.src_ip_mask == 0) {
8151 printf("can not support ipv6 involved compare.\n");
8156 /* need convert to big endian. */
8157 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8158 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8159 filter.queue = res->queue_id;
8161 if (!strcmp(res->ops, "add"))
8162 ret = rte_eth_dev_filter_ctrl(res->port_id,
8163 RTE_ETH_FILTER_NTUPLE,
8167 ret = rte_eth_dev_filter_ctrl(res->port_id,
8168 RTE_ETH_FILTER_NTUPLE,
8169 RTE_ETH_FILTER_DELETE,
8172 printf("5tuple filter programming error: (%s)\n",
8176 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8177 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8178 filter, "5tuple_filter");
8179 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8180 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8182 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8183 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8185 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8186 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8188 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8189 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8191 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8192 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8194 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8195 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8197 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8198 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8199 dst_port, "dst_port");
8200 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8201 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8202 dst_port_value, UINT16);
8203 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8204 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8205 src_port, "src_port");
8206 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8207 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8208 src_port_value, UINT16);
8209 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8210 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8211 protocol, "protocol");
8212 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8213 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8214 protocol_value, UINT8);
8215 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8216 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8218 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8219 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8221 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8222 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8223 tcp_flags, "tcp_flags");
8224 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8225 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8226 tcp_flags_value, UINT8);
8227 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8228 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8229 priority, "priority");
8230 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8231 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8232 priority_value, UINT8);
8233 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8234 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8236 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8237 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8240 cmdline_parse_inst_t cmd_5tuple_filter = {
8241 .f = cmd_5tuple_filter_parsed,
8243 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8244 "src_ip <value> dst_port <value> src_port <value> "
8245 "protocol <value> mask <value> tcp_flags <value> "
8246 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8248 (void *)&cmd_5tuple_filter_filter,
8249 (void *)&cmd_5tuple_filter_port_id,
8250 (void *)&cmd_5tuple_filter_ops,
8251 (void *)&cmd_5tuple_filter_dst_ip,
8252 (void *)&cmd_5tuple_filter_dst_ip_value,
8253 (void *)&cmd_5tuple_filter_src_ip,
8254 (void *)&cmd_5tuple_filter_src_ip_value,
8255 (void *)&cmd_5tuple_filter_dst_port,
8256 (void *)&cmd_5tuple_filter_dst_port_value,
8257 (void *)&cmd_5tuple_filter_src_port,
8258 (void *)&cmd_5tuple_filter_src_port_value,
8259 (void *)&cmd_5tuple_filter_protocol,
8260 (void *)&cmd_5tuple_filter_protocol_value,
8261 (void *)&cmd_5tuple_filter_mask,
8262 (void *)&cmd_5tuple_filter_mask_value,
8263 (void *)&cmd_5tuple_filter_tcp_flags,
8264 (void *)&cmd_5tuple_filter_tcp_flags_value,
8265 (void *)&cmd_5tuple_filter_priority,
8266 (void *)&cmd_5tuple_filter_priority_value,
8267 (void *)&cmd_5tuple_filter_queue,
8268 (void *)&cmd_5tuple_filter_queue_id,
8273 /* *** ADD/REMOVE A flex FILTER *** */
8274 struct cmd_flex_filter_result {
8275 cmdline_fixed_string_t filter;
8276 cmdline_fixed_string_t ops;
8278 cmdline_fixed_string_t len;
8280 cmdline_fixed_string_t bytes;
8281 cmdline_fixed_string_t bytes_value;
8282 cmdline_fixed_string_t mask;
8283 cmdline_fixed_string_t mask_value;
8284 cmdline_fixed_string_t priority;
8285 uint8_t priority_value;
8286 cmdline_fixed_string_t queue;
8290 static int xdigit2val(unsigned char c)
8295 else if (isupper(c))
8303 cmd_flex_filter_parsed(void *parsed_result,
8304 __attribute__((unused)) struct cmdline *cl,
8305 __attribute__((unused)) void *data)
8308 struct rte_eth_flex_filter filter;
8309 struct cmd_flex_filter_result *res = parsed_result;
8310 char *bytes_ptr, *mask_ptr;
8311 uint16_t len, i, j = 0;
8316 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8317 printf("the len exceed the max length 128\n");
8320 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8321 filter.len = res->len_value;
8322 filter.priority = res->priority_value;
8323 filter.queue = res->queue_id;
8324 bytes_ptr = res->bytes_value;
8325 mask_ptr = res->mask_value;
8327 /* translate bytes string to array. */
8328 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8329 (bytes_ptr[1] == 'X')))
8331 len = strnlen(bytes_ptr, res->len_value * 2);
8332 if (len == 0 || (len % 8 != 0)) {
8333 printf("please check len and bytes input\n");
8336 for (i = 0; i < len; i++) {
8338 if (isxdigit(c) == 0) {
8339 /* invalid characters. */
8340 printf("invalid input\n");
8343 val = xdigit2val(c);
8346 filter.bytes[j] = byte;
8347 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8354 /* translate mask string to uint8_t array. */
8355 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8356 (mask_ptr[1] == 'X')))
8358 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8360 printf("invalid input\n");
8365 for (i = 0; i < len; i++) {
8367 if (isxdigit(c) == 0) {
8368 /* invalid characters. */
8369 printf("invalid input\n");
8372 val = xdigit2val(c);
8375 filter.mask[j] = byte;
8376 printf("mask[%d]:%02x ", j, filter.mask[j]);
8384 if (!strcmp(res->ops, "add"))
8385 ret = rte_eth_dev_filter_ctrl(res->port_id,
8386 RTE_ETH_FILTER_FLEXIBLE,
8390 ret = rte_eth_dev_filter_ctrl(res->port_id,
8391 RTE_ETH_FILTER_FLEXIBLE,
8392 RTE_ETH_FILTER_DELETE,
8396 printf("flex filter setting error: (%s)\n", strerror(-ret));
8399 cmdline_parse_token_string_t cmd_flex_filter_filter =
8400 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8401 filter, "flex_filter");
8402 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8403 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8405 cmdline_parse_token_string_t cmd_flex_filter_ops =
8406 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8408 cmdline_parse_token_string_t cmd_flex_filter_len =
8409 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8411 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8412 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8414 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8415 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8417 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8418 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8420 cmdline_parse_token_string_t cmd_flex_filter_mask =
8421 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8423 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8424 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8426 cmdline_parse_token_string_t cmd_flex_filter_priority =
8427 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8428 priority, "priority");
8429 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8430 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8431 priority_value, UINT8);
8432 cmdline_parse_token_string_t cmd_flex_filter_queue =
8433 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8435 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8436 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8438 cmdline_parse_inst_t cmd_flex_filter = {
8439 .f = cmd_flex_filter_parsed,
8441 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8442 "<value> mask <value> priority <value> queue <queue_id>: "
8443 "Add/Del a flex filter",
8445 (void *)&cmd_flex_filter_filter,
8446 (void *)&cmd_flex_filter_port_id,
8447 (void *)&cmd_flex_filter_ops,
8448 (void *)&cmd_flex_filter_len,
8449 (void *)&cmd_flex_filter_len_value,
8450 (void *)&cmd_flex_filter_bytes,
8451 (void *)&cmd_flex_filter_bytes_value,
8452 (void *)&cmd_flex_filter_mask,
8453 (void *)&cmd_flex_filter_mask_value,
8454 (void *)&cmd_flex_filter_priority,
8455 (void *)&cmd_flex_filter_priority_value,
8456 (void *)&cmd_flex_filter_queue,
8457 (void *)&cmd_flex_filter_queue_id,
8462 /* *** Filters Control *** */
8464 /* *** deal with ethertype filter *** */
8465 struct cmd_ethertype_filter_result {
8466 cmdline_fixed_string_t filter;
8468 cmdline_fixed_string_t ops;
8469 cmdline_fixed_string_t mac;
8470 struct ether_addr mac_addr;
8471 cmdline_fixed_string_t ethertype;
8472 uint16_t ethertype_value;
8473 cmdline_fixed_string_t drop;
8474 cmdline_fixed_string_t queue;
8478 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8479 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8480 filter, "ethertype_filter");
8481 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8482 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8484 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8485 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8487 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8488 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8489 mac, "mac_addr#mac_ignr");
8490 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8491 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8493 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8494 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8495 ethertype, "ethertype");
8496 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8497 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8498 ethertype_value, UINT16);
8499 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8500 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8502 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8503 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8505 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8506 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8510 cmd_ethertype_filter_parsed(void *parsed_result,
8511 __attribute__((unused)) struct cmdline *cl,
8512 __attribute__((unused)) void *data)
8514 struct cmd_ethertype_filter_result *res = parsed_result;
8515 struct rte_eth_ethertype_filter filter;
8518 ret = rte_eth_dev_filter_supported(res->port_id,
8519 RTE_ETH_FILTER_ETHERTYPE);
8521 printf("ethertype filter is not supported on port %u.\n",
8526 memset(&filter, 0, sizeof(filter));
8527 if (!strcmp(res->mac, "mac_addr")) {
8528 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8529 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8530 sizeof(struct ether_addr));
8532 if (!strcmp(res->drop, "drop"))
8533 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8534 filter.ether_type = res->ethertype_value;
8535 filter.queue = res->queue_id;
8537 if (!strcmp(res->ops, "add"))
8538 ret = rte_eth_dev_filter_ctrl(res->port_id,
8539 RTE_ETH_FILTER_ETHERTYPE,
8543 ret = rte_eth_dev_filter_ctrl(res->port_id,
8544 RTE_ETH_FILTER_ETHERTYPE,
8545 RTE_ETH_FILTER_DELETE,
8548 printf("ethertype filter programming error: (%s)\n",
8552 cmdline_parse_inst_t cmd_ethertype_filter = {
8553 .f = cmd_ethertype_filter_parsed,
8555 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8556 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8557 "Add or delete an ethertype filter entry",
8559 (void *)&cmd_ethertype_filter_filter,
8560 (void *)&cmd_ethertype_filter_port_id,
8561 (void *)&cmd_ethertype_filter_ops,
8562 (void *)&cmd_ethertype_filter_mac,
8563 (void *)&cmd_ethertype_filter_mac_addr,
8564 (void *)&cmd_ethertype_filter_ethertype,
8565 (void *)&cmd_ethertype_filter_ethertype_value,
8566 (void *)&cmd_ethertype_filter_drop,
8567 (void *)&cmd_ethertype_filter_queue,
8568 (void *)&cmd_ethertype_filter_queue_id,
8573 /* *** deal with flow director filter *** */
8574 struct cmd_flow_director_result {
8575 cmdline_fixed_string_t flow_director_filter;
8577 cmdline_fixed_string_t mode;
8578 cmdline_fixed_string_t mode_value;
8579 cmdline_fixed_string_t ops;
8580 cmdline_fixed_string_t flow;
8581 cmdline_fixed_string_t flow_type;
8582 cmdline_fixed_string_t ether;
8583 uint16_t ether_type;
8584 cmdline_fixed_string_t src;
8585 cmdline_ipaddr_t ip_src;
8587 cmdline_fixed_string_t dst;
8588 cmdline_ipaddr_t ip_dst;
8590 cmdline_fixed_string_t verify_tag;
8591 uint32_t verify_tag_value;
8592 cmdline_ipaddr_t tos;
8594 cmdline_ipaddr_t proto;
8595 uint8_t proto_value;
8596 cmdline_ipaddr_t ttl;
8598 cmdline_fixed_string_t vlan;
8599 uint16_t vlan_value;
8600 cmdline_fixed_string_t flexbytes;
8601 cmdline_fixed_string_t flexbytes_value;
8602 cmdline_fixed_string_t pf_vf;
8603 cmdline_fixed_string_t drop;
8604 cmdline_fixed_string_t queue;
8606 cmdline_fixed_string_t fd_id;
8607 uint32_t fd_id_value;
8608 cmdline_fixed_string_t mac;
8609 struct ether_addr mac_addr;
8610 cmdline_fixed_string_t tunnel;
8611 cmdline_fixed_string_t tunnel_type;
8612 cmdline_fixed_string_t tunnel_id;
8613 uint32_t tunnel_id_value;
8617 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8620 const char *p, *p0 = q_arg;
8622 unsigned long int_fld;
8623 char *str_fld[max_num];
8628 p = strchr(p0, '(');
8632 p0 = strchr(p, ')');
8637 if (size >= sizeof(s))
8640 snprintf(s, sizeof(s), "%.*s", size, p);
8641 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8642 if (ret < 0 || ret > max_num)
8644 for (i = 0; i < ret; i++) {
8646 int_fld = strtoul(str_fld[i], &end, 0);
8647 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8649 flexbytes[i] = (uint8_t)int_fld;
8655 str2flowtype(char *string)
8658 static const struct {
8661 } flowtype_str[] = {
8662 {"raw", RTE_ETH_FLOW_RAW},
8663 {"ipv4", RTE_ETH_FLOW_IPV4},
8664 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8665 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8666 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8667 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8668 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8669 {"ipv6", RTE_ETH_FLOW_IPV6},
8670 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8671 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8672 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8673 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8674 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8675 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8678 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8679 if (!strcmp(flowtype_str[i].str, string))
8680 return flowtype_str[i].type;
8682 return RTE_ETH_FLOW_UNKNOWN;
8685 static enum rte_eth_fdir_tunnel_type
8686 str2fdir_tunneltype(char *string)
8690 static const struct {
8692 enum rte_eth_fdir_tunnel_type type;
8693 } tunneltype_str[] = {
8694 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8695 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8698 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8699 if (!strcmp(tunneltype_str[i].str, string))
8700 return tunneltype_str[i].type;
8702 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8705 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8707 if ((ip_addr).family == AF_INET) \
8708 (ip) = (ip_addr).addr.ipv4.s_addr; \
8710 printf("invalid parameter.\n"); \
8715 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8717 if ((ip_addr).family == AF_INET6) \
8718 (void)rte_memcpy(&(ip), \
8719 &((ip_addr).addr.ipv6), \
8720 sizeof(struct in6_addr)); \
8722 printf("invalid parameter.\n"); \
8728 cmd_flow_director_filter_parsed(void *parsed_result,
8729 __attribute__((unused)) struct cmdline *cl,
8730 __attribute__((unused)) void *data)
8732 struct cmd_flow_director_result *res = parsed_result;
8733 struct rte_eth_fdir_filter entry;
8734 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8736 unsigned long vf_id;
8739 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8741 printf("flow director is not supported on port %u.\n",
8745 memset(flexbytes, 0, sizeof(flexbytes));
8746 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8748 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8749 if (strcmp(res->mode_value, "MAC-VLAN")) {
8750 printf("Please set mode to MAC-VLAN.\n");
8753 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8754 if (strcmp(res->mode_value, "Tunnel")) {
8755 printf("Please set mode to Tunnel.\n");
8759 if (strcmp(res->mode_value, "IP")) {
8760 printf("Please set mode to IP.\n");
8763 entry.input.flow_type = str2flowtype(res->flow_type);
8766 ret = parse_flexbytes(res->flexbytes_value,
8768 RTE_ETH_FDIR_MAX_FLEXLEN);
8770 printf("error: Cannot parse flexbytes input.\n");
8774 switch (entry.input.flow_type) {
8775 case RTE_ETH_FLOW_FRAG_IPV4:
8776 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8777 entry.input.flow.ip4_flow.proto = res->proto_value;
8779 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8780 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8781 IPV4_ADDR_TO_UINT(res->ip_dst,
8782 entry.input.flow.ip4_flow.dst_ip);
8783 IPV4_ADDR_TO_UINT(res->ip_src,
8784 entry.input.flow.ip4_flow.src_ip);
8785 entry.input.flow.ip4_flow.tos = res->tos_value;
8786 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8787 /* need convert to big endian. */
8788 entry.input.flow.udp4_flow.dst_port =
8789 rte_cpu_to_be_16(res->port_dst);
8790 entry.input.flow.udp4_flow.src_port =
8791 rte_cpu_to_be_16(res->port_src);
8793 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8794 IPV4_ADDR_TO_UINT(res->ip_dst,
8795 entry.input.flow.sctp4_flow.ip.dst_ip);
8796 IPV4_ADDR_TO_UINT(res->ip_src,
8797 entry.input.flow.sctp4_flow.ip.src_ip);
8798 entry.input.flow.ip4_flow.tos = res->tos_value;
8799 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8800 /* need convert to big endian. */
8801 entry.input.flow.sctp4_flow.dst_port =
8802 rte_cpu_to_be_16(res->port_dst);
8803 entry.input.flow.sctp4_flow.src_port =
8804 rte_cpu_to_be_16(res->port_src);
8805 entry.input.flow.sctp4_flow.verify_tag =
8806 rte_cpu_to_be_32(res->verify_tag_value);
8808 case RTE_ETH_FLOW_FRAG_IPV6:
8809 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8810 entry.input.flow.ipv6_flow.proto = res->proto_value;
8812 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8813 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8814 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8815 entry.input.flow.ipv6_flow.dst_ip);
8816 IPV6_ADDR_TO_ARRAY(res->ip_src,
8817 entry.input.flow.ipv6_flow.src_ip);
8818 entry.input.flow.ipv6_flow.tc = res->tos_value;
8819 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8820 /* need convert to big endian. */
8821 entry.input.flow.udp6_flow.dst_port =
8822 rte_cpu_to_be_16(res->port_dst);
8823 entry.input.flow.udp6_flow.src_port =
8824 rte_cpu_to_be_16(res->port_src);
8826 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8827 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8828 entry.input.flow.sctp6_flow.ip.dst_ip);
8829 IPV6_ADDR_TO_ARRAY(res->ip_src,
8830 entry.input.flow.sctp6_flow.ip.src_ip);
8831 entry.input.flow.ipv6_flow.tc = res->tos_value;
8832 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8833 /* need convert to big endian. */
8834 entry.input.flow.sctp6_flow.dst_port =
8835 rte_cpu_to_be_16(res->port_dst);
8836 entry.input.flow.sctp6_flow.src_port =
8837 rte_cpu_to_be_16(res->port_src);
8838 entry.input.flow.sctp6_flow.verify_tag =
8839 rte_cpu_to_be_32(res->verify_tag_value);
8841 case RTE_ETH_FLOW_L2_PAYLOAD:
8842 entry.input.flow.l2_flow.ether_type =
8843 rte_cpu_to_be_16(res->ether_type);
8849 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8850 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8852 sizeof(struct ether_addr));
8854 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8855 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8857 sizeof(struct ether_addr));
8858 entry.input.flow.tunnel_flow.tunnel_type =
8859 str2fdir_tunneltype(res->tunnel_type);
8860 entry.input.flow.tunnel_flow.tunnel_id =
8861 rte_cpu_to_be_32(res->tunnel_id_value);
8864 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8866 RTE_ETH_FDIR_MAX_FLEXLEN);
8868 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8870 entry.action.flex_off = 0; /*use 0 by default */
8871 if (!strcmp(res->drop, "drop"))
8872 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8874 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8876 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8877 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8878 if (!strcmp(res->pf_vf, "pf"))
8879 entry.input.flow_ext.is_vf = 0;
8880 else if (!strncmp(res->pf_vf, "vf", 2)) {
8881 struct rte_eth_dev_info dev_info;
8883 memset(&dev_info, 0, sizeof(dev_info));
8884 rte_eth_dev_info_get(res->port_id, &dev_info);
8886 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8887 if (errno != 0 || *end != '\0' ||
8888 vf_id >= dev_info.max_vfs) {
8889 printf("invalid parameter %s.\n", res->pf_vf);
8892 entry.input.flow_ext.is_vf = 1;
8893 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8895 printf("invalid parameter %s.\n", res->pf_vf);
8900 /* set to report FD ID by default */
8901 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8902 entry.action.rx_queue = res->queue_id;
8903 entry.soft_id = res->fd_id_value;
8904 if (!strcmp(res->ops, "add"))
8905 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8906 RTE_ETH_FILTER_ADD, &entry);
8907 else if (!strcmp(res->ops, "del"))
8908 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8909 RTE_ETH_FILTER_DELETE, &entry);
8911 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8912 RTE_ETH_FILTER_UPDATE, &entry);
8914 printf("flow director programming error: (%s)\n",
8918 cmdline_parse_token_string_t cmd_flow_director_filter =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8920 flow_director_filter, "flow_director_filter");
8921 cmdline_parse_token_num_t cmd_flow_director_port_id =
8922 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_string_t cmd_flow_director_ops =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8926 ops, "add#del#update");
8927 cmdline_parse_token_string_t cmd_flow_director_flow =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8930 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8932 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8933 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8934 cmdline_parse_token_string_t cmd_flow_director_ether =
8935 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8937 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8938 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8939 ether_type, UINT16);
8940 cmdline_parse_token_string_t cmd_flow_director_src =
8941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8943 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8944 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8946 cmdline_parse_token_num_t cmd_flow_director_port_src =
8947 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8949 cmdline_parse_token_string_t cmd_flow_director_dst =
8950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8952 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8953 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8955 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8956 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8958 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8960 verify_tag, "verify_tag");
8961 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8962 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8963 verify_tag_value, UINT32);
8964 cmdline_parse_token_string_t cmd_flow_director_tos =
8965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8967 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8968 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8970 cmdline_parse_token_string_t cmd_flow_director_proto =
8971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8973 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8974 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8975 proto_value, UINT8);
8976 cmdline_parse_token_string_t cmd_flow_director_ttl =
8977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8979 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8980 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8982 cmdline_parse_token_string_t cmd_flow_director_vlan =
8983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8985 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8986 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8987 vlan_value, UINT16);
8988 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8990 flexbytes, "flexbytes");
8991 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8992 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8993 flexbytes_value, NULL);
8994 cmdline_parse_token_string_t cmd_flow_director_drop =
8995 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8997 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9000 cmdline_parse_token_string_t cmd_flow_director_queue =
9001 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9003 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9004 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9006 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9009 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9010 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9011 fd_id_value, UINT32);
9013 cmdline_parse_token_string_t cmd_flow_director_mode =
9014 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9016 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9017 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9019 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9020 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9021 mode_value, "MAC-VLAN");
9022 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9023 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9024 mode_value, "Tunnel");
9025 cmdline_parse_token_string_t cmd_flow_director_mac =
9026 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9028 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9029 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9031 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9032 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9034 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9035 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9036 tunnel_type, "NVGRE#VxLAN");
9037 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9038 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9039 tunnel_id, "tunnel-id");
9040 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9041 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9042 tunnel_id_value, UINT32);
9044 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9045 .f = cmd_flow_director_filter_parsed,
9047 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9048 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9049 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9050 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9051 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9052 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9053 "fd_id <fd_id_value>: "
9054 "Add or delete an ip flow director entry on NIC",
9056 (void *)&cmd_flow_director_filter,
9057 (void *)&cmd_flow_director_port_id,
9058 (void *)&cmd_flow_director_mode,
9059 (void *)&cmd_flow_director_mode_ip,
9060 (void *)&cmd_flow_director_ops,
9061 (void *)&cmd_flow_director_flow,
9062 (void *)&cmd_flow_director_flow_type,
9063 (void *)&cmd_flow_director_src,
9064 (void *)&cmd_flow_director_ip_src,
9065 (void *)&cmd_flow_director_dst,
9066 (void *)&cmd_flow_director_ip_dst,
9067 (void *)&cmd_flow_director_tos,
9068 (void *)&cmd_flow_director_tos_value,
9069 (void *)&cmd_flow_director_proto,
9070 (void *)&cmd_flow_director_proto_value,
9071 (void *)&cmd_flow_director_ttl,
9072 (void *)&cmd_flow_director_ttl_value,
9073 (void *)&cmd_flow_director_vlan,
9074 (void *)&cmd_flow_director_vlan_value,
9075 (void *)&cmd_flow_director_flexbytes,
9076 (void *)&cmd_flow_director_flexbytes_value,
9077 (void *)&cmd_flow_director_drop,
9078 (void *)&cmd_flow_director_pf_vf,
9079 (void *)&cmd_flow_director_queue,
9080 (void *)&cmd_flow_director_queue_id,
9081 (void *)&cmd_flow_director_fd_id,
9082 (void *)&cmd_flow_director_fd_id_value,
9087 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9088 .f = cmd_flow_director_filter_parsed,
9090 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9091 "director entry on NIC",
9093 (void *)&cmd_flow_director_filter,
9094 (void *)&cmd_flow_director_port_id,
9095 (void *)&cmd_flow_director_mode,
9096 (void *)&cmd_flow_director_mode_ip,
9097 (void *)&cmd_flow_director_ops,
9098 (void *)&cmd_flow_director_flow,
9099 (void *)&cmd_flow_director_flow_type,
9100 (void *)&cmd_flow_director_src,
9101 (void *)&cmd_flow_director_ip_src,
9102 (void *)&cmd_flow_director_port_src,
9103 (void *)&cmd_flow_director_dst,
9104 (void *)&cmd_flow_director_ip_dst,
9105 (void *)&cmd_flow_director_port_dst,
9106 (void *)&cmd_flow_director_tos,
9107 (void *)&cmd_flow_director_tos_value,
9108 (void *)&cmd_flow_director_ttl,
9109 (void *)&cmd_flow_director_ttl_value,
9110 (void *)&cmd_flow_director_vlan,
9111 (void *)&cmd_flow_director_vlan_value,
9112 (void *)&cmd_flow_director_flexbytes,
9113 (void *)&cmd_flow_director_flexbytes_value,
9114 (void *)&cmd_flow_director_drop,
9115 (void *)&cmd_flow_director_pf_vf,
9116 (void *)&cmd_flow_director_queue,
9117 (void *)&cmd_flow_director_queue_id,
9118 (void *)&cmd_flow_director_fd_id,
9119 (void *)&cmd_flow_director_fd_id_value,
9124 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9125 .f = cmd_flow_director_filter_parsed,
9127 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9128 "director entry on NIC",
9130 (void *)&cmd_flow_director_filter,
9131 (void *)&cmd_flow_director_port_id,
9132 (void *)&cmd_flow_director_mode,
9133 (void *)&cmd_flow_director_mode_ip,
9134 (void *)&cmd_flow_director_ops,
9135 (void *)&cmd_flow_director_flow,
9136 (void *)&cmd_flow_director_flow_type,
9137 (void *)&cmd_flow_director_src,
9138 (void *)&cmd_flow_director_ip_src,
9139 (void *)&cmd_flow_director_port_dst,
9140 (void *)&cmd_flow_director_dst,
9141 (void *)&cmd_flow_director_ip_dst,
9142 (void *)&cmd_flow_director_port_dst,
9143 (void *)&cmd_flow_director_verify_tag,
9144 (void *)&cmd_flow_director_verify_tag_value,
9145 (void *)&cmd_flow_director_tos,
9146 (void *)&cmd_flow_director_tos_value,
9147 (void *)&cmd_flow_director_ttl,
9148 (void *)&cmd_flow_director_ttl_value,
9149 (void *)&cmd_flow_director_vlan,
9150 (void *)&cmd_flow_director_vlan_value,
9151 (void *)&cmd_flow_director_flexbytes,
9152 (void *)&cmd_flow_director_flexbytes_value,
9153 (void *)&cmd_flow_director_drop,
9154 (void *)&cmd_flow_director_pf_vf,
9155 (void *)&cmd_flow_director_queue,
9156 (void *)&cmd_flow_director_queue_id,
9157 (void *)&cmd_flow_director_fd_id,
9158 (void *)&cmd_flow_director_fd_id_value,
9163 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9164 .f = cmd_flow_director_filter_parsed,
9166 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9167 "director entry on NIC",
9169 (void *)&cmd_flow_director_filter,
9170 (void *)&cmd_flow_director_port_id,
9171 (void *)&cmd_flow_director_mode,
9172 (void *)&cmd_flow_director_mode_ip,
9173 (void *)&cmd_flow_director_ops,
9174 (void *)&cmd_flow_director_flow,
9175 (void *)&cmd_flow_director_flow_type,
9176 (void *)&cmd_flow_director_ether,
9177 (void *)&cmd_flow_director_ether_type,
9178 (void *)&cmd_flow_director_flexbytes,
9179 (void *)&cmd_flow_director_flexbytes_value,
9180 (void *)&cmd_flow_director_drop,
9181 (void *)&cmd_flow_director_pf_vf,
9182 (void *)&cmd_flow_director_queue,
9183 (void *)&cmd_flow_director_queue_id,
9184 (void *)&cmd_flow_director_fd_id,
9185 (void *)&cmd_flow_director_fd_id_value,
9190 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9191 .f = cmd_flow_director_filter_parsed,
9193 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9194 "director entry on NIC",
9196 (void *)&cmd_flow_director_filter,
9197 (void *)&cmd_flow_director_port_id,
9198 (void *)&cmd_flow_director_mode,
9199 (void *)&cmd_flow_director_mode_mac_vlan,
9200 (void *)&cmd_flow_director_ops,
9201 (void *)&cmd_flow_director_mac,
9202 (void *)&cmd_flow_director_mac_addr,
9203 (void *)&cmd_flow_director_vlan,
9204 (void *)&cmd_flow_director_vlan_value,
9205 (void *)&cmd_flow_director_flexbytes,
9206 (void *)&cmd_flow_director_flexbytes_value,
9207 (void *)&cmd_flow_director_drop,
9208 (void *)&cmd_flow_director_queue,
9209 (void *)&cmd_flow_director_queue_id,
9210 (void *)&cmd_flow_director_fd_id,
9211 (void *)&cmd_flow_director_fd_id_value,
9216 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9217 .f = cmd_flow_director_filter_parsed,
9219 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9220 "director entry on NIC",
9222 (void *)&cmd_flow_director_filter,
9223 (void *)&cmd_flow_director_port_id,
9224 (void *)&cmd_flow_director_mode,
9225 (void *)&cmd_flow_director_mode_tunnel,
9226 (void *)&cmd_flow_director_ops,
9227 (void *)&cmd_flow_director_mac,
9228 (void *)&cmd_flow_director_mac_addr,
9229 (void *)&cmd_flow_director_vlan,
9230 (void *)&cmd_flow_director_vlan_value,
9231 (void *)&cmd_flow_director_tunnel,
9232 (void *)&cmd_flow_director_tunnel_type,
9233 (void *)&cmd_flow_director_tunnel_id,
9234 (void *)&cmd_flow_director_tunnel_id_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_queue,
9239 (void *)&cmd_flow_director_queue_id,
9240 (void *)&cmd_flow_director_fd_id,
9241 (void *)&cmd_flow_director_fd_id_value,
9246 struct cmd_flush_flow_director_result {
9247 cmdline_fixed_string_t flush_flow_director;
9251 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9252 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9253 flush_flow_director, "flush_flow_director");
9254 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9255 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9259 cmd_flush_flow_director_parsed(void *parsed_result,
9260 __attribute__((unused)) struct cmdline *cl,
9261 __attribute__((unused)) void *data)
9263 struct cmd_flow_director_result *res = parsed_result;
9266 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9268 printf("flow director is not supported on port %u.\n",
9273 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9274 RTE_ETH_FILTER_FLUSH, NULL);
9276 printf("flow director table flushing error: (%s)\n",
9280 cmdline_parse_inst_t cmd_flush_flow_director = {
9281 .f = cmd_flush_flow_director_parsed,
9283 .help_str = "flush_flow_director <port_id>: "
9284 "Flush all flow director entries of a device on NIC",
9286 (void *)&cmd_flush_flow_director_flush,
9287 (void *)&cmd_flush_flow_director_port_id,
9292 /* *** deal with flow director mask *** */
9293 struct cmd_flow_director_mask_result {
9294 cmdline_fixed_string_t flow_director_mask;
9296 cmdline_fixed_string_t mode;
9297 cmdline_fixed_string_t mode_value;
9298 cmdline_fixed_string_t vlan;
9300 cmdline_fixed_string_t src_mask;
9301 cmdline_ipaddr_t ipv4_src;
9302 cmdline_ipaddr_t ipv6_src;
9304 cmdline_fixed_string_t dst_mask;
9305 cmdline_ipaddr_t ipv4_dst;
9306 cmdline_ipaddr_t ipv6_dst;
9308 cmdline_fixed_string_t mac;
9309 uint8_t mac_addr_byte_mask;
9310 cmdline_fixed_string_t tunnel_id;
9311 uint32_t tunnel_id_mask;
9312 cmdline_fixed_string_t tunnel_type;
9313 uint8_t tunnel_type_mask;
9317 cmd_flow_director_mask_parsed(void *parsed_result,
9318 __attribute__((unused)) struct cmdline *cl,
9319 __attribute__((unused)) void *data)
9321 struct cmd_flow_director_mask_result *res = parsed_result;
9322 struct rte_eth_fdir_masks *mask;
9323 struct rte_port *port;
9325 if (res->port_id > nb_ports) {
9326 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9330 port = &ports[res->port_id];
9331 /** Check if the port is not started **/
9332 if (port->port_status != RTE_PORT_STOPPED) {
9333 printf("Please stop port %d first\n", res->port_id);
9337 mask = &port->dev_conf.fdir_conf.mask;
9339 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9340 if (strcmp(res->mode_value, "MAC-VLAN")) {
9341 printf("Please set mode to MAC-VLAN.\n");
9345 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9346 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9347 if (strcmp(res->mode_value, "Tunnel")) {
9348 printf("Please set mode to Tunnel.\n");
9352 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9353 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9354 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9355 mask->tunnel_type_mask = res->tunnel_type_mask;
9357 if (strcmp(res->mode_value, "IP")) {
9358 printf("Please set mode to IP.\n");
9362 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9363 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9364 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9365 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9366 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9367 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9368 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9371 cmd_reconfig_device_queue(res->port_id, 1, 1);
9374 cmdline_parse_token_string_t cmd_flow_director_mask =
9375 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9376 flow_director_mask, "flow_director_mask");
9377 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9378 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9380 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9383 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9384 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9386 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9388 src_mask, "src_mask");
9389 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9390 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9392 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9393 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9395 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9396 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9398 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9400 dst_mask, "dst_mask");
9401 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9402 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9404 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9405 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9407 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9408 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9411 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9414 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9417 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9419 mode_value, "MAC-VLAN");
9420 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9422 mode_value, "Tunnel");
9423 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9426 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9427 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9428 mac_addr_byte_mask, UINT8);
9429 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9431 tunnel_type, "tunnel-type");
9432 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9433 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9434 tunnel_type_mask, UINT8);
9435 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9437 tunnel_id, "tunnel-id");
9438 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9439 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9440 tunnel_id_mask, UINT32);
9442 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9443 .f = cmd_flow_director_mask_parsed,
9445 .help_str = "flow_director_mask ... : "
9446 "Set IP mode flow director's mask on NIC",
9448 (void *)&cmd_flow_director_mask,
9449 (void *)&cmd_flow_director_mask_port_id,
9450 (void *)&cmd_flow_director_mask_mode,
9451 (void *)&cmd_flow_director_mask_mode_ip,
9452 (void *)&cmd_flow_director_mask_vlan,
9453 (void *)&cmd_flow_director_mask_vlan_value,
9454 (void *)&cmd_flow_director_mask_src,
9455 (void *)&cmd_flow_director_mask_ipv4_src,
9456 (void *)&cmd_flow_director_mask_ipv6_src,
9457 (void *)&cmd_flow_director_mask_port_src,
9458 (void *)&cmd_flow_director_mask_dst,
9459 (void *)&cmd_flow_director_mask_ipv4_dst,
9460 (void *)&cmd_flow_director_mask_ipv6_dst,
9461 (void *)&cmd_flow_director_mask_port_dst,
9466 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9467 .f = cmd_flow_director_mask_parsed,
9469 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9470 "flow director's mask on NIC",
9472 (void *)&cmd_flow_director_mask,
9473 (void *)&cmd_flow_director_mask_port_id,
9474 (void *)&cmd_flow_director_mask_mode,
9475 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9476 (void *)&cmd_flow_director_mask_vlan,
9477 (void *)&cmd_flow_director_mask_vlan_value,
9482 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9483 .f = cmd_flow_director_mask_parsed,
9485 .help_str = "flow_director_mask ... : Set tunnel mode "
9486 "flow director's mask on NIC",
9488 (void *)&cmd_flow_director_mask,
9489 (void *)&cmd_flow_director_mask_port_id,
9490 (void *)&cmd_flow_director_mask_mode,
9491 (void *)&cmd_flow_director_mask_mode_tunnel,
9492 (void *)&cmd_flow_director_mask_vlan,
9493 (void *)&cmd_flow_director_mask_vlan_value,
9494 (void *)&cmd_flow_director_mask_mac,
9495 (void *)&cmd_flow_director_mask_mac_value,
9496 (void *)&cmd_flow_director_mask_tunnel_type,
9497 (void *)&cmd_flow_director_mask_tunnel_type_value,
9498 (void *)&cmd_flow_director_mask_tunnel_id,
9499 (void *)&cmd_flow_director_mask_tunnel_id_value,
9504 /* *** deal with flow director mask on flexible payload *** */
9505 struct cmd_flow_director_flex_mask_result {
9506 cmdline_fixed_string_t flow_director_flexmask;
9508 cmdline_fixed_string_t flow;
9509 cmdline_fixed_string_t flow_type;
9510 cmdline_fixed_string_t mask;
9514 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9515 __attribute__((unused)) struct cmdline *cl,
9516 __attribute__((unused)) void *data)
9518 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9519 struct rte_eth_fdir_info fdir_info;
9520 struct rte_eth_fdir_flex_mask flex_mask;
9521 struct rte_port *port;
9522 uint32_t flow_type_mask;
9526 if (res->port_id > nb_ports) {
9527 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9531 port = &ports[res->port_id];
9532 /** Check if the port is not started **/
9533 if (port->port_status != RTE_PORT_STOPPED) {
9534 printf("Please stop port %d first\n", res->port_id);
9538 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9539 ret = parse_flexbytes(res->mask,
9541 RTE_ETH_FDIR_MAX_FLEXLEN);
9543 printf("error: Cannot parse mask input.\n");
9547 memset(&fdir_info, 0, sizeof(fdir_info));
9548 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9549 RTE_ETH_FILTER_INFO, &fdir_info);
9551 printf("Cannot get FDir filter info\n");
9555 if (!strcmp(res->flow_type, "none")) {
9556 /* means don't specify the flow type */
9557 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9558 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9559 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9560 0, sizeof(struct rte_eth_fdir_flex_mask));
9561 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9562 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9564 sizeof(struct rte_eth_fdir_flex_mask));
9565 cmd_reconfig_device_queue(res->port_id, 1, 1);
9568 flow_type_mask = fdir_info.flow_types_mask[0];
9569 if (!strcmp(res->flow_type, "all")) {
9570 if (!flow_type_mask) {
9571 printf("No flow type supported\n");
9574 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9575 if (flow_type_mask & (1 << i)) {
9576 flex_mask.flow_type = i;
9577 fdir_set_flex_mask(res->port_id, &flex_mask);
9580 cmd_reconfig_device_queue(res->port_id, 1, 1);
9583 flex_mask.flow_type = str2flowtype(res->flow_type);
9584 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9585 printf("Flow type %s not supported on port %d\n",
9586 res->flow_type, res->port_id);
9589 fdir_set_flex_mask(res->port_id, &flex_mask);
9590 cmd_reconfig_device_queue(res->port_id, 1, 1);
9593 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9595 flow_director_flexmask,
9596 "flow_director_flex_mask");
9597 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9598 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9600 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9601 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9603 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9604 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9605 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9606 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9607 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9611 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9612 .f = cmd_flow_director_flex_mask_parsed,
9614 .help_str = "flow_director_flex_mask ... : "
9615 "Set flow director's flex mask on NIC",
9617 (void *)&cmd_flow_director_flexmask,
9618 (void *)&cmd_flow_director_flexmask_port_id,
9619 (void *)&cmd_flow_director_flexmask_flow,
9620 (void *)&cmd_flow_director_flexmask_flow_type,
9621 (void *)&cmd_flow_director_flexmask_mask,
9626 /* *** deal with flow director flexible payload configuration *** */
9627 struct cmd_flow_director_flexpayload_result {
9628 cmdline_fixed_string_t flow_director_flexpayload;
9630 cmdline_fixed_string_t payload_layer;
9631 cmdline_fixed_string_t payload_cfg;
9635 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9638 const char *p, *p0 = q_arg;
9640 unsigned long int_fld;
9641 char *str_fld[max_num];
9646 p = strchr(p0, '(');
9650 p0 = strchr(p, ')');
9655 if (size >= sizeof(s))
9658 snprintf(s, sizeof(s), "%.*s", size, p);
9659 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9660 if (ret < 0 || ret > max_num)
9662 for (i = 0; i < ret; i++) {
9664 int_fld = strtoul(str_fld[i], &end, 0);
9665 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9667 offsets[i] = (uint16_t)int_fld;
9673 cmd_flow_director_flxpld_parsed(void *parsed_result,
9674 __attribute__((unused)) struct cmdline *cl,
9675 __attribute__((unused)) void *data)
9677 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9678 struct rte_eth_flex_payload_cfg flex_cfg;
9679 struct rte_port *port;
9682 if (res->port_id > nb_ports) {
9683 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9687 port = &ports[res->port_id];
9688 /** Check if the port is not started **/
9689 if (port->port_status != RTE_PORT_STOPPED) {
9690 printf("Please stop port %d first\n", res->port_id);
9694 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9696 if (!strcmp(res->payload_layer, "raw"))
9697 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9698 else if (!strcmp(res->payload_layer, "l2"))
9699 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9700 else if (!strcmp(res->payload_layer, "l3"))
9701 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9702 else if (!strcmp(res->payload_layer, "l4"))
9703 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9705 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9706 RTE_ETH_FDIR_MAX_FLEXLEN);
9708 printf("error: Cannot parse flex payload input.\n");
9712 fdir_set_flex_payload(res->port_id, &flex_cfg);
9713 cmd_reconfig_device_queue(res->port_id, 1, 1);
9716 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9718 flow_director_flexpayload,
9719 "flow_director_flex_payload");
9720 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9721 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9723 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9725 payload_layer, "raw#l2#l3#l4");
9726 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9727 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9730 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9731 .f = cmd_flow_director_flxpld_parsed,
9733 .help_str = "flow_director_flexpayload ... : "
9734 "Set flow director's flex payload on NIC",
9736 (void *)&cmd_flow_director_flexpayload,
9737 (void *)&cmd_flow_director_flexpayload_port_id,
9738 (void *)&cmd_flow_director_flexpayload_payload_layer,
9739 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9744 /* Generic flow interface command. */
9745 extern cmdline_parse_inst_t cmd_flow;
9747 /* *** Classification Filters Control *** */
9748 /* *** Get symmetric hash enable per port *** */
9749 struct cmd_get_sym_hash_ena_per_port_result {
9750 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9755 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9756 __rte_unused struct cmdline *cl,
9757 __rte_unused void *data)
9759 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9760 struct rte_eth_hash_filter_info info;
9763 if (rte_eth_dev_filter_supported(res->port_id,
9764 RTE_ETH_FILTER_HASH) < 0) {
9765 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9770 memset(&info, 0, sizeof(info));
9771 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9772 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9773 RTE_ETH_FILTER_GET, &info);
9776 printf("Cannot get symmetric hash enable per port "
9777 "on port %u\n", res->port_id);
9781 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9782 "enabled" : "disabled", res->port_id);
9785 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9786 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9787 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9788 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9789 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9792 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9793 .f = cmd_get_sym_hash_per_port_parsed,
9795 .help_str = "get_sym_hash_ena_per_port <port_id>",
9797 (void *)&cmd_get_sym_hash_ena_per_port_all,
9798 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9803 /* *** Set symmetric hash enable per port *** */
9804 struct cmd_set_sym_hash_ena_per_port_result {
9805 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9806 cmdline_fixed_string_t enable;
9811 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9812 __rte_unused struct cmdline *cl,
9813 __rte_unused void *data)
9815 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9816 struct rte_eth_hash_filter_info info;
9819 if (rte_eth_dev_filter_supported(res->port_id,
9820 RTE_ETH_FILTER_HASH) < 0) {
9821 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9826 memset(&info, 0, sizeof(info));
9827 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9828 if (!strcmp(res->enable, "enable"))
9829 info.info.enable = 1;
9830 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9831 RTE_ETH_FILTER_SET, &info);
9833 printf("Cannot set symmetric hash enable per port on "
9834 "port %u\n", res->port_id);
9837 printf("Symmetric hash has been set to %s on port %u\n",
9838 res->enable, res->port_id);
9841 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9842 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9843 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9844 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9845 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9847 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9848 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9849 enable, "enable#disable");
9851 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9852 .f = cmd_set_sym_hash_per_port_parsed,
9854 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9856 (void *)&cmd_set_sym_hash_ena_per_port_all,
9857 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9858 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9863 /* Get global config of hash function */
9864 struct cmd_get_hash_global_config_result {
9865 cmdline_fixed_string_t get_hash_global_config;
9870 flowtype_to_str(uint16_t ftype)
9877 {"ipv4", RTE_ETH_FLOW_IPV4},
9878 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9879 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9880 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9881 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9882 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9883 {"ipv6", RTE_ETH_FLOW_IPV6},
9884 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9885 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9886 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9887 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9888 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9889 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9890 {"port", RTE_ETH_FLOW_PORT},
9891 {"vxlan", RTE_ETH_FLOW_VXLAN},
9892 {"geneve", RTE_ETH_FLOW_GENEVE},
9893 {"nvgre", RTE_ETH_FLOW_NVGRE},
9896 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9897 if (ftype_table[i].ftype == ftype)
9898 return ftype_table[i].str;
9905 cmd_get_hash_global_config_parsed(void *parsed_result,
9906 __rte_unused struct cmdline *cl,
9907 __rte_unused void *data)
9909 struct cmd_get_hash_global_config_result *res = parsed_result;
9910 struct rte_eth_hash_filter_info info;
9911 uint32_t idx, offset;
9916 if (rte_eth_dev_filter_supported(res->port_id,
9917 RTE_ETH_FILTER_HASH) < 0) {
9918 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9923 memset(&info, 0, sizeof(info));
9924 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9925 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9926 RTE_ETH_FILTER_GET, &info);
9928 printf("Cannot get hash global configurations by port %d\n",
9933 switch (info.info.global_conf.hash_func) {
9934 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9935 printf("Hash function is Toeplitz\n");
9937 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9938 printf("Hash function is Simple XOR\n");
9941 printf("Unknown hash function\n");
9945 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9946 idx = i / UINT32_BIT;
9947 offset = i % UINT32_BIT;
9948 if (!(info.info.global_conf.valid_bit_mask[idx] &
9951 str = flowtype_to_str(i);
9954 printf("Symmetric hash is %s globally for flow type %s "
9956 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9957 (1UL << offset)) ? "enabled" : "disabled"), str,
9962 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9963 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9964 get_hash_global_config, "get_hash_global_config");
9965 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9966 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9969 cmdline_parse_inst_t cmd_get_hash_global_config = {
9970 .f = cmd_get_hash_global_config_parsed,
9972 .help_str = "get_hash_global_config <port_id>",
9974 (void *)&cmd_get_hash_global_config_all,
9975 (void *)&cmd_get_hash_global_config_port_id,
9980 /* Set global config of hash function */
9981 struct cmd_set_hash_global_config_result {
9982 cmdline_fixed_string_t set_hash_global_config;
9984 cmdline_fixed_string_t hash_func;
9985 cmdline_fixed_string_t flow_type;
9986 cmdline_fixed_string_t enable;
9990 cmd_set_hash_global_config_parsed(void *parsed_result,
9991 __rte_unused struct cmdline *cl,
9992 __rte_unused void *data)
9994 struct cmd_set_hash_global_config_result *res = parsed_result;
9995 struct rte_eth_hash_filter_info info;
9996 uint32_t ftype, idx, offset;
9999 if (rte_eth_dev_filter_supported(res->port_id,
10000 RTE_ETH_FILTER_HASH) < 0) {
10001 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10005 memset(&info, 0, sizeof(info));
10006 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10007 if (!strcmp(res->hash_func, "toeplitz"))
10008 info.info.global_conf.hash_func =
10009 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10010 else if (!strcmp(res->hash_func, "simple_xor"))
10011 info.info.global_conf.hash_func =
10012 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10013 else if (!strcmp(res->hash_func, "default"))
10014 info.info.global_conf.hash_func =
10015 RTE_ETH_HASH_FUNCTION_DEFAULT;
10017 ftype = str2flowtype(res->flow_type);
10018 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10019 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10020 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10021 if (!strcmp(res->enable, "enable"))
10022 info.info.global_conf.sym_hash_enable_mask[idx] |=
10024 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10025 RTE_ETH_FILTER_SET, &info);
10027 printf("Cannot set global hash configurations by port %d\n",
10030 printf("Global hash configurations have been set "
10031 "succcessfully by port %d\n", res->port_id);
10034 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10035 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10036 set_hash_global_config, "set_hash_global_config");
10037 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10038 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10040 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10041 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10042 hash_func, "toeplitz#simple_xor#default");
10043 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10044 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10046 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10047 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10048 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10049 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10050 enable, "enable#disable");
10052 cmdline_parse_inst_t cmd_set_hash_global_config = {
10053 .f = cmd_set_hash_global_config_parsed,
10055 .help_str = "set_hash_global_config <port_id> "
10056 "toeplitz|simple_xor|default "
10057 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10058 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10059 "l2_payload enable|disable",
10061 (void *)&cmd_set_hash_global_config_all,
10062 (void *)&cmd_set_hash_global_config_port_id,
10063 (void *)&cmd_set_hash_global_config_hash_func,
10064 (void *)&cmd_set_hash_global_config_flow_type,
10065 (void *)&cmd_set_hash_global_config_enable,
10070 /* Set hash input set */
10071 struct cmd_set_hash_input_set_result {
10072 cmdline_fixed_string_t set_hash_input_set;
10074 cmdline_fixed_string_t flow_type;
10075 cmdline_fixed_string_t inset_field;
10076 cmdline_fixed_string_t select;
10079 static enum rte_eth_input_set_field
10080 str2inset(char *string)
10084 static const struct {
10086 enum rte_eth_input_set_field inset;
10087 } inset_table[] = {
10088 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10089 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10090 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10091 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10092 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10093 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10094 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10095 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10096 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10097 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10098 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10099 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10100 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10101 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10102 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10103 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10104 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10105 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10106 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10107 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10108 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10109 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10110 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10111 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10112 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10113 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10114 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10115 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10116 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10117 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10118 {"none", RTE_ETH_INPUT_SET_NONE},
10121 for (i = 0; i < RTE_DIM(inset_table); i++) {
10122 if (!strcmp(string, inset_table[i].str))
10123 return inset_table[i].inset;
10126 return RTE_ETH_INPUT_SET_UNKNOWN;
10130 cmd_set_hash_input_set_parsed(void *parsed_result,
10131 __rte_unused struct cmdline *cl,
10132 __rte_unused void *data)
10134 struct cmd_set_hash_input_set_result *res = parsed_result;
10135 struct rte_eth_hash_filter_info info;
10137 memset(&info, 0, sizeof(info));
10138 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10139 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10140 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10141 info.info.input_set_conf.inset_size = 1;
10142 if (!strcmp(res->select, "select"))
10143 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10144 else if (!strcmp(res->select, "add"))
10145 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10146 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10147 RTE_ETH_FILTER_SET, &info);
10150 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10151 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10152 set_hash_input_set, "set_hash_input_set");
10153 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10154 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10156 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10157 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10159 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10160 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10161 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10162 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10164 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10165 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10166 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10167 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10168 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10170 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10171 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10172 select, "select#add");
10174 cmdline_parse_inst_t cmd_set_hash_input_set = {
10175 .f = cmd_set_hash_input_set_parsed,
10177 .help_str = "set_hash_input_set <port_id> "
10178 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10179 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10180 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10181 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10182 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10183 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10184 "fld-7th|fld-8th|none select|add",
10186 (void *)&cmd_set_hash_input_set_cmd,
10187 (void *)&cmd_set_hash_input_set_port_id,
10188 (void *)&cmd_set_hash_input_set_flow_type,
10189 (void *)&cmd_set_hash_input_set_field,
10190 (void *)&cmd_set_hash_input_set_select,
10195 /* Set flow director input set */
10196 struct cmd_set_fdir_input_set_result {
10197 cmdline_fixed_string_t set_fdir_input_set;
10199 cmdline_fixed_string_t flow_type;
10200 cmdline_fixed_string_t inset_field;
10201 cmdline_fixed_string_t select;
10205 cmd_set_fdir_input_set_parsed(void *parsed_result,
10206 __rte_unused struct cmdline *cl,
10207 __rte_unused void *data)
10209 struct cmd_set_fdir_input_set_result *res = parsed_result;
10210 struct rte_eth_fdir_filter_info info;
10212 memset(&info, 0, sizeof(info));
10213 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10214 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10215 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10216 info.info.input_set_conf.inset_size = 1;
10217 if (!strcmp(res->select, "select"))
10218 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10219 else if (!strcmp(res->select, "add"))
10220 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10221 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10222 RTE_ETH_FILTER_SET, &info);
10225 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10226 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10227 set_fdir_input_set, "set_fdir_input_set");
10228 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10229 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10231 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10232 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10234 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10235 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10236 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10237 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10239 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10240 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10241 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10242 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10243 "sctp-veri-tag#none");
10244 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10245 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10246 select, "select#add");
10248 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10249 .f = cmd_set_fdir_input_set_parsed,
10251 .help_str = "set_fdir_input_set <port_id> "
10252 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10253 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10254 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10255 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10256 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10257 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10258 "sctp-veri-tag|none select|add",
10260 (void *)&cmd_set_fdir_input_set_cmd,
10261 (void *)&cmd_set_fdir_input_set_port_id,
10262 (void *)&cmd_set_fdir_input_set_flow_type,
10263 (void *)&cmd_set_fdir_input_set_field,
10264 (void *)&cmd_set_fdir_input_set_select,
10269 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10270 struct cmd_mcast_addr_result {
10271 cmdline_fixed_string_t mcast_addr_cmd;
10272 cmdline_fixed_string_t what;
10274 struct ether_addr mc_addr;
10277 static void cmd_mcast_addr_parsed(void *parsed_result,
10278 __attribute__((unused)) struct cmdline *cl,
10279 __attribute__((unused)) void *data)
10281 struct cmd_mcast_addr_result *res = parsed_result;
10283 if (!is_multicast_ether_addr(&res->mc_addr)) {
10284 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10285 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10286 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10287 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10290 if (strcmp(res->what, "add") == 0)
10291 mcast_addr_add(res->port_num, &res->mc_addr);
10293 mcast_addr_remove(res->port_num, &res->mc_addr);
10296 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10297 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10298 mcast_addr_cmd, "mcast_addr");
10299 cmdline_parse_token_string_t cmd_mcast_addr_what =
10300 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10302 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10303 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10304 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10305 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10307 cmdline_parse_inst_t cmd_mcast_addr = {
10308 .f = cmd_mcast_addr_parsed,
10310 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10311 "Add/Remove multicast MAC address on port_id",
10313 (void *)&cmd_mcast_addr_cmd,
10314 (void *)&cmd_mcast_addr_what,
10315 (void *)&cmd_mcast_addr_portnum,
10316 (void *)&cmd_mcast_addr_addr,
10321 /* l2 tunnel config
10322 * only support E-tag now.
10325 /* Ether type config */
10326 struct cmd_config_l2_tunnel_eth_type_result {
10327 cmdline_fixed_string_t port;
10328 cmdline_fixed_string_t config;
10329 cmdline_fixed_string_t all;
10331 cmdline_fixed_string_t l2_tunnel;
10332 cmdline_fixed_string_t l2_tunnel_type;
10333 cmdline_fixed_string_t eth_type;
10334 uint16_t eth_type_val;
10337 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10338 TOKEN_STRING_INITIALIZER
10339 (struct cmd_config_l2_tunnel_eth_type_result,
10341 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10342 TOKEN_STRING_INITIALIZER
10343 (struct cmd_config_l2_tunnel_eth_type_result,
10345 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10346 TOKEN_STRING_INITIALIZER
10347 (struct cmd_config_l2_tunnel_eth_type_result,
10349 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10350 TOKEN_NUM_INITIALIZER
10351 (struct cmd_config_l2_tunnel_eth_type_result,
10353 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10354 TOKEN_STRING_INITIALIZER
10355 (struct cmd_config_l2_tunnel_eth_type_result,
10356 l2_tunnel, "l2-tunnel");
10357 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10358 TOKEN_STRING_INITIALIZER
10359 (struct cmd_config_l2_tunnel_eth_type_result,
10360 l2_tunnel_type, "E-tag");
10361 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10362 TOKEN_STRING_INITIALIZER
10363 (struct cmd_config_l2_tunnel_eth_type_result,
10364 eth_type, "ether-type");
10365 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10366 TOKEN_NUM_INITIALIZER
10367 (struct cmd_config_l2_tunnel_eth_type_result,
10368 eth_type_val, UINT16);
10370 static enum rte_eth_tunnel_type
10371 str2fdir_l2_tunnel_type(char *string)
10375 static const struct {
10377 enum rte_eth_tunnel_type type;
10378 } l2_tunnel_type_str[] = {
10379 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10382 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10383 if (!strcmp(l2_tunnel_type_str[i].str, string))
10384 return l2_tunnel_type_str[i].type;
10386 return RTE_TUNNEL_TYPE_NONE;
10389 /* ether type config for all ports */
10391 cmd_config_l2_tunnel_eth_type_all_parsed
10392 (void *parsed_result,
10393 __attribute__((unused)) struct cmdline *cl,
10394 __attribute__((unused)) void *data)
10396 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10397 struct rte_eth_l2_tunnel_conf entry;
10400 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10401 entry.ether_type = res->eth_type_val;
10403 RTE_ETH_FOREACH_DEV(pid) {
10404 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10408 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10409 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10411 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10413 (void *)&cmd_config_l2_tunnel_eth_type_port,
10414 (void *)&cmd_config_l2_tunnel_eth_type_config,
10415 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10416 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10417 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10418 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10419 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10424 /* ether type config for a specific port */
10426 cmd_config_l2_tunnel_eth_type_specific_parsed(
10427 void *parsed_result,
10428 __attribute__((unused)) struct cmdline *cl,
10429 __attribute__((unused)) void *data)
10431 struct cmd_config_l2_tunnel_eth_type_result *res =
10433 struct rte_eth_l2_tunnel_conf entry;
10435 if (port_id_is_invalid(res->id, ENABLED_WARN))
10438 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10439 entry.ether_type = res->eth_type_val;
10441 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10444 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10445 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10447 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10449 (void *)&cmd_config_l2_tunnel_eth_type_port,
10450 (void *)&cmd_config_l2_tunnel_eth_type_config,
10451 (void *)&cmd_config_l2_tunnel_eth_type_id,
10452 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10453 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10454 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10455 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10460 /* Enable/disable l2 tunnel */
10461 struct cmd_config_l2_tunnel_en_dis_result {
10462 cmdline_fixed_string_t port;
10463 cmdline_fixed_string_t config;
10464 cmdline_fixed_string_t all;
10466 cmdline_fixed_string_t l2_tunnel;
10467 cmdline_fixed_string_t l2_tunnel_type;
10468 cmdline_fixed_string_t en_dis;
10471 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10472 TOKEN_STRING_INITIALIZER
10473 (struct cmd_config_l2_tunnel_en_dis_result,
10475 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10476 TOKEN_STRING_INITIALIZER
10477 (struct cmd_config_l2_tunnel_en_dis_result,
10479 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10480 TOKEN_STRING_INITIALIZER
10481 (struct cmd_config_l2_tunnel_en_dis_result,
10483 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10484 TOKEN_NUM_INITIALIZER
10485 (struct cmd_config_l2_tunnel_en_dis_result,
10487 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10488 TOKEN_STRING_INITIALIZER
10489 (struct cmd_config_l2_tunnel_en_dis_result,
10490 l2_tunnel, "l2-tunnel");
10491 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10492 TOKEN_STRING_INITIALIZER
10493 (struct cmd_config_l2_tunnel_en_dis_result,
10494 l2_tunnel_type, "E-tag");
10495 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10496 TOKEN_STRING_INITIALIZER
10497 (struct cmd_config_l2_tunnel_en_dis_result,
10498 en_dis, "enable#disable");
10500 /* enable/disable l2 tunnel for all ports */
10502 cmd_config_l2_tunnel_en_dis_all_parsed(
10503 void *parsed_result,
10504 __attribute__((unused)) struct cmdline *cl,
10505 __attribute__((unused)) void *data)
10507 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10508 struct rte_eth_l2_tunnel_conf entry;
10512 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10514 if (!strcmp("enable", res->en_dis))
10519 RTE_ETH_FOREACH_DEV(pid) {
10520 rte_eth_dev_l2_tunnel_offload_set(pid,
10522 ETH_L2_TUNNEL_ENABLE_MASK,
10527 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10528 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10530 .help_str = "port config all l2-tunnel E-tag enable|disable",
10532 (void *)&cmd_config_l2_tunnel_en_dis_port,
10533 (void *)&cmd_config_l2_tunnel_en_dis_config,
10534 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10535 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10536 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10537 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10542 /* enable/disable l2 tunnel for a port */
10544 cmd_config_l2_tunnel_en_dis_specific_parsed(
10545 void *parsed_result,
10546 __attribute__((unused)) struct cmdline *cl,
10547 __attribute__((unused)) void *data)
10549 struct cmd_config_l2_tunnel_en_dis_result *res =
10551 struct rte_eth_l2_tunnel_conf entry;
10553 if (port_id_is_invalid(res->id, ENABLED_WARN))
10556 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10558 if (!strcmp("enable", res->en_dis))
10559 rte_eth_dev_l2_tunnel_offload_set(res->id,
10561 ETH_L2_TUNNEL_ENABLE_MASK,
10564 rte_eth_dev_l2_tunnel_offload_set(res->id,
10566 ETH_L2_TUNNEL_ENABLE_MASK,
10570 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10571 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10573 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10575 (void *)&cmd_config_l2_tunnel_en_dis_port,
10576 (void *)&cmd_config_l2_tunnel_en_dis_config,
10577 (void *)&cmd_config_l2_tunnel_en_dis_id,
10578 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10579 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10580 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10585 /* E-tag configuration */
10587 /* Common result structure for all E-tag configuration */
10588 struct cmd_config_e_tag_result {
10589 cmdline_fixed_string_t e_tag;
10590 cmdline_fixed_string_t set;
10591 cmdline_fixed_string_t insertion;
10592 cmdline_fixed_string_t stripping;
10593 cmdline_fixed_string_t forwarding;
10594 cmdline_fixed_string_t filter;
10595 cmdline_fixed_string_t add;
10596 cmdline_fixed_string_t del;
10597 cmdline_fixed_string_t on;
10598 cmdline_fixed_string_t off;
10599 cmdline_fixed_string_t on_off;
10600 cmdline_fixed_string_t port_tag_id;
10601 uint32_t port_tag_id_val;
10602 cmdline_fixed_string_t e_tag_id;
10603 uint16_t e_tag_id_val;
10604 cmdline_fixed_string_t dst_pool;
10605 uint8_t dst_pool_val;
10606 cmdline_fixed_string_t port;
10608 cmdline_fixed_string_t vf;
10612 /* Common CLI fields for all E-tag configuration */
10613 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10614 TOKEN_STRING_INITIALIZER
10615 (struct cmd_config_e_tag_result,
10617 cmdline_parse_token_string_t cmd_config_e_tag_set =
10618 TOKEN_STRING_INITIALIZER
10619 (struct cmd_config_e_tag_result,
10621 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10622 TOKEN_STRING_INITIALIZER
10623 (struct cmd_config_e_tag_result,
10624 insertion, "insertion");
10625 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10626 TOKEN_STRING_INITIALIZER
10627 (struct cmd_config_e_tag_result,
10628 stripping, "stripping");
10629 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10630 TOKEN_STRING_INITIALIZER
10631 (struct cmd_config_e_tag_result,
10632 forwarding, "forwarding");
10633 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10634 TOKEN_STRING_INITIALIZER
10635 (struct cmd_config_e_tag_result,
10637 cmdline_parse_token_string_t cmd_config_e_tag_add =
10638 TOKEN_STRING_INITIALIZER
10639 (struct cmd_config_e_tag_result,
10641 cmdline_parse_token_string_t cmd_config_e_tag_del =
10642 TOKEN_STRING_INITIALIZER
10643 (struct cmd_config_e_tag_result,
10645 cmdline_parse_token_string_t cmd_config_e_tag_on =
10646 TOKEN_STRING_INITIALIZER
10647 (struct cmd_config_e_tag_result,
10649 cmdline_parse_token_string_t cmd_config_e_tag_off =
10650 TOKEN_STRING_INITIALIZER
10651 (struct cmd_config_e_tag_result,
10653 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10654 TOKEN_STRING_INITIALIZER
10655 (struct cmd_config_e_tag_result,
10657 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10658 TOKEN_STRING_INITIALIZER
10659 (struct cmd_config_e_tag_result,
10660 port_tag_id, "port-tag-id");
10661 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10662 TOKEN_NUM_INITIALIZER
10663 (struct cmd_config_e_tag_result,
10664 port_tag_id_val, UINT32);
10665 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10666 TOKEN_STRING_INITIALIZER
10667 (struct cmd_config_e_tag_result,
10668 e_tag_id, "e-tag-id");
10669 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10670 TOKEN_NUM_INITIALIZER
10671 (struct cmd_config_e_tag_result,
10672 e_tag_id_val, UINT16);
10673 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10674 TOKEN_STRING_INITIALIZER
10675 (struct cmd_config_e_tag_result,
10676 dst_pool, "dst-pool");
10677 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10678 TOKEN_NUM_INITIALIZER
10679 (struct cmd_config_e_tag_result,
10680 dst_pool_val, UINT8);
10681 cmdline_parse_token_string_t cmd_config_e_tag_port =
10682 TOKEN_STRING_INITIALIZER
10683 (struct cmd_config_e_tag_result,
10685 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10686 TOKEN_NUM_INITIALIZER
10687 (struct cmd_config_e_tag_result,
10689 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10690 TOKEN_STRING_INITIALIZER
10691 (struct cmd_config_e_tag_result,
10693 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10694 TOKEN_NUM_INITIALIZER
10695 (struct cmd_config_e_tag_result,
10698 /* E-tag insertion configuration */
10700 cmd_config_e_tag_insertion_en_parsed(
10701 void *parsed_result,
10702 __attribute__((unused)) struct cmdline *cl,
10703 __attribute__((unused)) void *data)
10705 struct cmd_config_e_tag_result *res =
10707 struct rte_eth_l2_tunnel_conf entry;
10709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10712 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10713 entry.tunnel_id = res->port_tag_id_val;
10714 entry.vf_id = res->vf_id;
10715 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10717 ETH_L2_TUNNEL_INSERTION_MASK,
10722 cmd_config_e_tag_insertion_dis_parsed(
10723 void *parsed_result,
10724 __attribute__((unused)) struct cmdline *cl,
10725 __attribute__((unused)) void *data)
10727 struct cmd_config_e_tag_result *res =
10729 struct rte_eth_l2_tunnel_conf entry;
10731 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10734 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10735 entry.vf_id = res->vf_id;
10737 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10739 ETH_L2_TUNNEL_INSERTION_MASK,
10743 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10744 .f = cmd_config_e_tag_insertion_en_parsed,
10746 .help_str = "E-tag ... : E-tag insertion enable",
10748 (void *)&cmd_config_e_tag_e_tag,
10749 (void *)&cmd_config_e_tag_set,
10750 (void *)&cmd_config_e_tag_insertion,
10751 (void *)&cmd_config_e_tag_on,
10752 (void *)&cmd_config_e_tag_port_tag_id,
10753 (void *)&cmd_config_e_tag_port_tag_id_val,
10754 (void *)&cmd_config_e_tag_port,
10755 (void *)&cmd_config_e_tag_port_id,
10756 (void *)&cmd_config_e_tag_vf,
10757 (void *)&cmd_config_e_tag_vf_id,
10762 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10763 .f = cmd_config_e_tag_insertion_dis_parsed,
10765 .help_str = "E-tag ... : E-tag insertion disable",
10767 (void *)&cmd_config_e_tag_e_tag,
10768 (void *)&cmd_config_e_tag_set,
10769 (void *)&cmd_config_e_tag_insertion,
10770 (void *)&cmd_config_e_tag_off,
10771 (void *)&cmd_config_e_tag_port,
10772 (void *)&cmd_config_e_tag_port_id,
10773 (void *)&cmd_config_e_tag_vf,
10774 (void *)&cmd_config_e_tag_vf_id,
10779 /* E-tag stripping configuration */
10781 cmd_config_e_tag_stripping_parsed(
10782 void *parsed_result,
10783 __attribute__((unused)) struct cmdline *cl,
10784 __attribute__((unused)) void *data)
10786 struct cmd_config_e_tag_result *res =
10788 struct rte_eth_l2_tunnel_conf entry;
10790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10793 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10795 if (!strcmp(res->on_off, "on"))
10796 rte_eth_dev_l2_tunnel_offload_set
10799 ETH_L2_TUNNEL_STRIPPING_MASK,
10802 rte_eth_dev_l2_tunnel_offload_set
10805 ETH_L2_TUNNEL_STRIPPING_MASK,
10809 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10810 .f = cmd_config_e_tag_stripping_parsed,
10812 .help_str = "E-tag ... : E-tag stripping enable/disable",
10814 (void *)&cmd_config_e_tag_e_tag,
10815 (void *)&cmd_config_e_tag_set,
10816 (void *)&cmd_config_e_tag_stripping,
10817 (void *)&cmd_config_e_tag_on_off,
10818 (void *)&cmd_config_e_tag_port,
10819 (void *)&cmd_config_e_tag_port_id,
10824 /* E-tag forwarding configuration */
10826 cmd_config_e_tag_forwarding_parsed(
10827 void *parsed_result,
10828 __attribute__((unused)) struct cmdline *cl,
10829 __attribute__((unused)) void *data)
10831 struct cmd_config_e_tag_result *res = parsed_result;
10832 struct rte_eth_l2_tunnel_conf entry;
10834 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10837 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10839 if (!strcmp(res->on_off, "on"))
10840 rte_eth_dev_l2_tunnel_offload_set
10843 ETH_L2_TUNNEL_FORWARDING_MASK,
10846 rte_eth_dev_l2_tunnel_offload_set
10849 ETH_L2_TUNNEL_FORWARDING_MASK,
10853 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10854 .f = cmd_config_e_tag_forwarding_parsed,
10856 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10858 (void *)&cmd_config_e_tag_e_tag,
10859 (void *)&cmd_config_e_tag_set,
10860 (void *)&cmd_config_e_tag_forwarding,
10861 (void *)&cmd_config_e_tag_on_off,
10862 (void *)&cmd_config_e_tag_port,
10863 (void *)&cmd_config_e_tag_port_id,
10868 /* E-tag filter configuration */
10870 cmd_config_e_tag_filter_add_parsed(
10871 void *parsed_result,
10872 __attribute__((unused)) struct cmdline *cl,
10873 __attribute__((unused)) void *data)
10875 struct cmd_config_e_tag_result *res = parsed_result;
10876 struct rte_eth_l2_tunnel_conf entry;
10879 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10882 if (res->e_tag_id_val > 0x3fff) {
10883 printf("e-tag-id must be equal or less than 0x3fff.\n");
10887 ret = rte_eth_dev_filter_supported(res->port_id,
10888 RTE_ETH_FILTER_L2_TUNNEL);
10890 printf("E-tag filter is not supported on port %u.\n",
10895 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10896 entry.tunnel_id = res->e_tag_id_val;
10897 entry.pool = res->dst_pool_val;
10899 ret = rte_eth_dev_filter_ctrl(res->port_id,
10900 RTE_ETH_FILTER_L2_TUNNEL,
10901 RTE_ETH_FILTER_ADD,
10904 printf("E-tag filter programming error: (%s)\n",
10908 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10909 .f = cmd_config_e_tag_filter_add_parsed,
10911 .help_str = "E-tag ... : E-tag filter add",
10913 (void *)&cmd_config_e_tag_e_tag,
10914 (void *)&cmd_config_e_tag_set,
10915 (void *)&cmd_config_e_tag_filter,
10916 (void *)&cmd_config_e_tag_add,
10917 (void *)&cmd_config_e_tag_e_tag_id,
10918 (void *)&cmd_config_e_tag_e_tag_id_val,
10919 (void *)&cmd_config_e_tag_dst_pool,
10920 (void *)&cmd_config_e_tag_dst_pool_val,
10921 (void *)&cmd_config_e_tag_port,
10922 (void *)&cmd_config_e_tag_port_id,
10928 cmd_config_e_tag_filter_del_parsed(
10929 void *parsed_result,
10930 __attribute__((unused)) struct cmdline *cl,
10931 __attribute__((unused)) void *data)
10933 struct cmd_config_e_tag_result *res = parsed_result;
10934 struct rte_eth_l2_tunnel_conf entry;
10937 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10940 if (res->e_tag_id_val > 0x3fff) {
10941 printf("e-tag-id must be less than 0x3fff.\n");
10945 ret = rte_eth_dev_filter_supported(res->port_id,
10946 RTE_ETH_FILTER_L2_TUNNEL);
10948 printf("E-tag filter is not supported on port %u.\n",
10953 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10954 entry.tunnel_id = res->e_tag_id_val;
10956 ret = rte_eth_dev_filter_ctrl(res->port_id,
10957 RTE_ETH_FILTER_L2_TUNNEL,
10958 RTE_ETH_FILTER_DELETE,
10961 printf("E-tag filter programming error: (%s)\n",
10965 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10966 .f = cmd_config_e_tag_filter_del_parsed,
10968 .help_str = "E-tag ... : E-tag filter delete",
10970 (void *)&cmd_config_e_tag_e_tag,
10971 (void *)&cmd_config_e_tag_set,
10972 (void *)&cmd_config_e_tag_filter,
10973 (void *)&cmd_config_e_tag_del,
10974 (void *)&cmd_config_e_tag_e_tag_id,
10975 (void *)&cmd_config_e_tag_e_tag_id_val,
10976 (void *)&cmd_config_e_tag_port,
10977 (void *)&cmd_config_e_tag_port_id,
10982 /* vf vlan anti spoof configuration */
10984 /* Common result structure for vf vlan anti spoof */
10985 struct cmd_vf_vlan_anti_spoof_result {
10986 cmdline_fixed_string_t set;
10987 cmdline_fixed_string_t vf;
10988 cmdline_fixed_string_t vlan;
10989 cmdline_fixed_string_t antispoof;
10992 cmdline_fixed_string_t on_off;
10995 /* Common CLI fields for vf vlan anti spoof enable disable */
10996 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10997 TOKEN_STRING_INITIALIZER
10998 (struct cmd_vf_vlan_anti_spoof_result,
11000 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11001 TOKEN_STRING_INITIALIZER
11002 (struct cmd_vf_vlan_anti_spoof_result,
11004 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11005 TOKEN_STRING_INITIALIZER
11006 (struct cmd_vf_vlan_anti_spoof_result,
11008 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11009 TOKEN_STRING_INITIALIZER
11010 (struct cmd_vf_vlan_anti_spoof_result,
11011 antispoof, "antispoof");
11012 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11013 TOKEN_NUM_INITIALIZER
11014 (struct cmd_vf_vlan_anti_spoof_result,
11016 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11017 TOKEN_NUM_INITIALIZER
11018 (struct cmd_vf_vlan_anti_spoof_result,
11020 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11021 TOKEN_STRING_INITIALIZER
11022 (struct cmd_vf_vlan_anti_spoof_result,
11026 cmd_set_vf_vlan_anti_spoof_parsed(
11027 void *parsed_result,
11028 __attribute__((unused)) struct cmdline *cl,
11029 __attribute__((unused)) void *data)
11031 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11032 int ret = -ENOTSUP;
11034 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11036 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11039 #ifdef RTE_LIBRTE_IXGBE_PMD
11040 if (ret == -ENOTSUP)
11041 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11042 res->vf_id, is_on);
11044 #ifdef RTE_LIBRTE_I40E_PMD
11045 if (ret == -ENOTSUP)
11046 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11047 res->vf_id, is_on);
11049 #ifdef RTE_LIBRTE_BNXT_PMD
11050 if (ret == -ENOTSUP)
11051 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11052 res->vf_id, is_on);
11059 printf("invalid vf_id %d\n", res->vf_id);
11062 printf("invalid port_id %d\n", res->port_id);
11065 printf("function not implemented\n");
11068 printf("programming error: (%s)\n", strerror(-ret));
11072 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11073 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11075 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11077 (void *)&cmd_vf_vlan_anti_spoof_set,
11078 (void *)&cmd_vf_vlan_anti_spoof_vf,
11079 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11080 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11081 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11082 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11083 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11088 /* vf mac anti spoof configuration */
11090 /* Common result structure for vf mac anti spoof */
11091 struct cmd_vf_mac_anti_spoof_result {
11092 cmdline_fixed_string_t set;
11093 cmdline_fixed_string_t vf;
11094 cmdline_fixed_string_t mac;
11095 cmdline_fixed_string_t antispoof;
11098 cmdline_fixed_string_t on_off;
11101 /* Common CLI fields for vf mac anti spoof enable disable */
11102 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11103 TOKEN_STRING_INITIALIZER
11104 (struct cmd_vf_mac_anti_spoof_result,
11106 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11107 TOKEN_STRING_INITIALIZER
11108 (struct cmd_vf_mac_anti_spoof_result,
11110 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11111 TOKEN_STRING_INITIALIZER
11112 (struct cmd_vf_mac_anti_spoof_result,
11114 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11115 TOKEN_STRING_INITIALIZER
11116 (struct cmd_vf_mac_anti_spoof_result,
11117 antispoof, "antispoof");
11118 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11119 TOKEN_NUM_INITIALIZER
11120 (struct cmd_vf_mac_anti_spoof_result,
11122 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11123 TOKEN_NUM_INITIALIZER
11124 (struct cmd_vf_mac_anti_spoof_result,
11126 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11127 TOKEN_STRING_INITIALIZER
11128 (struct cmd_vf_mac_anti_spoof_result,
11132 cmd_set_vf_mac_anti_spoof_parsed(
11133 void *parsed_result,
11134 __attribute__((unused)) struct cmdline *cl,
11135 __attribute__((unused)) void *data)
11137 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11138 int ret = -ENOTSUP;
11140 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11145 #ifdef RTE_LIBRTE_IXGBE_PMD
11146 if (ret == -ENOTSUP)
11147 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11148 res->vf_id, is_on);
11150 #ifdef RTE_LIBRTE_I40E_PMD
11151 if (ret == -ENOTSUP)
11152 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11153 res->vf_id, is_on);
11155 #ifdef RTE_LIBRTE_BNXT_PMD
11156 if (ret == -ENOTSUP)
11157 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11158 res->vf_id, is_on);
11165 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11168 printf("invalid port_id %d\n", res->port_id);
11171 printf("function not implemented\n");
11174 printf("programming error: (%s)\n", strerror(-ret));
11178 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11179 .f = cmd_set_vf_mac_anti_spoof_parsed,
11181 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11183 (void *)&cmd_vf_mac_anti_spoof_set,
11184 (void *)&cmd_vf_mac_anti_spoof_vf,
11185 (void *)&cmd_vf_mac_anti_spoof_mac,
11186 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11187 (void *)&cmd_vf_mac_anti_spoof_port_id,
11188 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11189 (void *)&cmd_vf_mac_anti_spoof_on_off,
11194 /* vf vlan strip queue configuration */
11196 /* Common result structure for vf mac anti spoof */
11197 struct cmd_vf_vlan_stripq_result {
11198 cmdline_fixed_string_t set;
11199 cmdline_fixed_string_t vf;
11200 cmdline_fixed_string_t vlan;
11201 cmdline_fixed_string_t stripq;
11204 cmdline_fixed_string_t on_off;
11207 /* Common CLI fields for vf vlan strip enable disable */
11208 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11209 TOKEN_STRING_INITIALIZER
11210 (struct cmd_vf_vlan_stripq_result,
11212 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11213 TOKEN_STRING_INITIALIZER
11214 (struct cmd_vf_vlan_stripq_result,
11216 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11217 TOKEN_STRING_INITIALIZER
11218 (struct cmd_vf_vlan_stripq_result,
11220 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11221 TOKEN_STRING_INITIALIZER
11222 (struct cmd_vf_vlan_stripq_result,
11224 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11225 TOKEN_NUM_INITIALIZER
11226 (struct cmd_vf_vlan_stripq_result,
11228 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11229 TOKEN_NUM_INITIALIZER
11230 (struct cmd_vf_vlan_stripq_result,
11232 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11233 TOKEN_STRING_INITIALIZER
11234 (struct cmd_vf_vlan_stripq_result,
11238 cmd_set_vf_vlan_stripq_parsed(
11239 void *parsed_result,
11240 __attribute__((unused)) struct cmdline *cl,
11241 __attribute__((unused)) void *data)
11243 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11244 int ret = -ENOTSUP;
11246 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11248 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11251 #ifdef RTE_LIBRTE_IXGBE_PMD
11252 if (ret == -ENOTSUP)
11253 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11254 res->vf_id, is_on);
11256 #ifdef RTE_LIBRTE_I40E_PMD
11257 if (ret == -ENOTSUP)
11258 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11259 res->vf_id, is_on);
11261 #ifdef RTE_LIBRTE_BNXT_PMD
11262 if (ret == -ENOTSUP)
11263 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11264 res->vf_id, is_on);
11271 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11274 printf("invalid port_id %d\n", res->port_id);
11277 printf("function not implemented\n");
11280 printf("programming error: (%s)\n", strerror(-ret));
11284 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11285 .f = cmd_set_vf_vlan_stripq_parsed,
11287 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11289 (void *)&cmd_vf_vlan_stripq_set,
11290 (void *)&cmd_vf_vlan_stripq_vf,
11291 (void *)&cmd_vf_vlan_stripq_vlan,
11292 (void *)&cmd_vf_vlan_stripq_stripq,
11293 (void *)&cmd_vf_vlan_stripq_port_id,
11294 (void *)&cmd_vf_vlan_stripq_vf_id,
11295 (void *)&cmd_vf_vlan_stripq_on_off,
11300 /* vf vlan insert configuration */
11302 /* Common result structure for vf vlan insert */
11303 struct cmd_vf_vlan_insert_result {
11304 cmdline_fixed_string_t set;
11305 cmdline_fixed_string_t vf;
11306 cmdline_fixed_string_t vlan;
11307 cmdline_fixed_string_t insert;
11313 /* Common CLI fields for vf vlan insert enable disable */
11314 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11315 TOKEN_STRING_INITIALIZER
11316 (struct cmd_vf_vlan_insert_result,
11318 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11319 TOKEN_STRING_INITIALIZER
11320 (struct cmd_vf_vlan_insert_result,
11322 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11323 TOKEN_STRING_INITIALIZER
11324 (struct cmd_vf_vlan_insert_result,
11326 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11327 TOKEN_STRING_INITIALIZER
11328 (struct cmd_vf_vlan_insert_result,
11330 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11331 TOKEN_NUM_INITIALIZER
11332 (struct cmd_vf_vlan_insert_result,
11334 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11335 TOKEN_NUM_INITIALIZER
11336 (struct cmd_vf_vlan_insert_result,
11338 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11339 TOKEN_NUM_INITIALIZER
11340 (struct cmd_vf_vlan_insert_result,
11344 cmd_set_vf_vlan_insert_parsed(
11345 void *parsed_result,
11346 __attribute__((unused)) struct cmdline *cl,
11347 __attribute__((unused)) void *data)
11349 struct cmd_vf_vlan_insert_result *res = parsed_result;
11350 int ret = -ENOTSUP;
11352 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11355 #ifdef RTE_LIBRTE_IXGBE_PMD
11356 if (ret == -ENOTSUP)
11357 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11360 #ifdef RTE_LIBRTE_I40E_PMD
11361 if (ret == -ENOTSUP)
11362 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11365 #ifdef RTE_LIBRTE_BNXT_PMD
11366 if (ret == -ENOTSUP)
11367 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11375 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11378 printf("invalid port_id %d\n", res->port_id);
11381 printf("function not implemented\n");
11384 printf("programming error: (%s)\n", strerror(-ret));
11388 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11389 .f = cmd_set_vf_vlan_insert_parsed,
11391 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11393 (void *)&cmd_vf_vlan_insert_set,
11394 (void *)&cmd_vf_vlan_insert_vf,
11395 (void *)&cmd_vf_vlan_insert_vlan,
11396 (void *)&cmd_vf_vlan_insert_insert,
11397 (void *)&cmd_vf_vlan_insert_port_id,
11398 (void *)&cmd_vf_vlan_insert_vf_id,
11399 (void *)&cmd_vf_vlan_insert_vlan_id,
11404 /* tx loopback configuration */
11406 /* Common result structure for tx loopback */
11407 struct cmd_tx_loopback_result {
11408 cmdline_fixed_string_t set;
11409 cmdline_fixed_string_t tx;
11410 cmdline_fixed_string_t loopback;
11412 cmdline_fixed_string_t on_off;
11415 /* Common CLI fields for tx loopback enable disable */
11416 cmdline_parse_token_string_t cmd_tx_loopback_set =
11417 TOKEN_STRING_INITIALIZER
11418 (struct cmd_tx_loopback_result,
11420 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11421 TOKEN_STRING_INITIALIZER
11422 (struct cmd_tx_loopback_result,
11424 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11425 TOKEN_STRING_INITIALIZER
11426 (struct cmd_tx_loopback_result,
11427 loopback, "loopback");
11428 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11429 TOKEN_NUM_INITIALIZER
11430 (struct cmd_tx_loopback_result,
11432 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11433 TOKEN_STRING_INITIALIZER
11434 (struct cmd_tx_loopback_result,
11438 cmd_set_tx_loopback_parsed(
11439 void *parsed_result,
11440 __attribute__((unused)) struct cmdline *cl,
11441 __attribute__((unused)) void *data)
11443 struct cmd_tx_loopback_result *res = parsed_result;
11444 int ret = -ENOTSUP;
11446 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11448 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11451 #ifdef RTE_LIBRTE_IXGBE_PMD
11452 if (ret == -ENOTSUP)
11453 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11455 #ifdef RTE_LIBRTE_I40E_PMD
11456 if (ret == -ENOTSUP)
11457 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11459 #ifdef RTE_LIBRTE_BNXT_PMD
11460 if (ret == -ENOTSUP)
11461 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11468 printf("invalid is_on %d\n", is_on);
11471 printf("invalid port_id %d\n", res->port_id);
11474 printf("function not implemented\n");
11477 printf("programming error: (%s)\n", strerror(-ret));
11481 cmdline_parse_inst_t cmd_set_tx_loopback = {
11482 .f = cmd_set_tx_loopback_parsed,
11484 .help_str = "set tx loopback <port_id> on|off",
11486 (void *)&cmd_tx_loopback_set,
11487 (void *)&cmd_tx_loopback_tx,
11488 (void *)&cmd_tx_loopback_loopback,
11489 (void *)&cmd_tx_loopback_port_id,
11490 (void *)&cmd_tx_loopback_on_off,
11495 /* all queues drop enable configuration */
11497 /* Common result structure for all queues drop enable */
11498 struct cmd_all_queues_drop_en_result {
11499 cmdline_fixed_string_t set;
11500 cmdline_fixed_string_t all;
11501 cmdline_fixed_string_t queues;
11502 cmdline_fixed_string_t drop;
11504 cmdline_fixed_string_t on_off;
11507 /* Common CLI fields for tx loopback enable disable */
11508 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11509 TOKEN_STRING_INITIALIZER
11510 (struct cmd_all_queues_drop_en_result,
11512 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11513 TOKEN_STRING_INITIALIZER
11514 (struct cmd_all_queues_drop_en_result,
11516 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11517 TOKEN_STRING_INITIALIZER
11518 (struct cmd_all_queues_drop_en_result,
11520 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11521 TOKEN_STRING_INITIALIZER
11522 (struct cmd_all_queues_drop_en_result,
11524 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11525 TOKEN_NUM_INITIALIZER
11526 (struct cmd_all_queues_drop_en_result,
11528 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11529 TOKEN_STRING_INITIALIZER
11530 (struct cmd_all_queues_drop_en_result,
11534 cmd_set_all_queues_drop_en_parsed(
11535 void *parsed_result,
11536 __attribute__((unused)) struct cmdline *cl,
11537 __attribute__((unused)) void *data)
11539 struct cmd_all_queues_drop_en_result *res = parsed_result;
11540 int ret = -ENOTSUP;
11541 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11543 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11546 #ifdef RTE_LIBRTE_IXGBE_PMD
11547 if (ret == -ENOTSUP)
11548 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11550 #ifdef RTE_LIBRTE_BNXT_PMD
11551 if (ret == -ENOTSUP)
11552 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11558 printf("invalid is_on %d\n", is_on);
11561 printf("invalid port_id %d\n", res->port_id);
11564 printf("function not implemented\n");
11567 printf("programming error: (%s)\n", strerror(-ret));
11571 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11572 .f = cmd_set_all_queues_drop_en_parsed,
11574 .help_str = "set all queues drop <port_id> on|off",
11576 (void *)&cmd_all_queues_drop_en_set,
11577 (void *)&cmd_all_queues_drop_en_all,
11578 (void *)&cmd_all_queues_drop_en_queues,
11579 (void *)&cmd_all_queues_drop_en_drop,
11580 (void *)&cmd_all_queues_drop_en_port_id,
11581 (void *)&cmd_all_queues_drop_en_on_off,
11586 /* vf split drop enable configuration */
11588 /* Common result structure for vf split drop enable */
11589 struct cmd_vf_split_drop_en_result {
11590 cmdline_fixed_string_t set;
11591 cmdline_fixed_string_t vf;
11592 cmdline_fixed_string_t split;
11593 cmdline_fixed_string_t drop;
11596 cmdline_fixed_string_t on_off;
11599 /* Common CLI fields for vf split drop enable disable */
11600 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11601 TOKEN_STRING_INITIALIZER
11602 (struct cmd_vf_split_drop_en_result,
11604 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11605 TOKEN_STRING_INITIALIZER
11606 (struct cmd_vf_split_drop_en_result,
11608 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11609 TOKEN_STRING_INITIALIZER
11610 (struct cmd_vf_split_drop_en_result,
11612 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11613 TOKEN_STRING_INITIALIZER
11614 (struct cmd_vf_split_drop_en_result,
11616 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11617 TOKEN_NUM_INITIALIZER
11618 (struct cmd_vf_split_drop_en_result,
11620 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11621 TOKEN_NUM_INITIALIZER
11622 (struct cmd_vf_split_drop_en_result,
11624 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11625 TOKEN_STRING_INITIALIZER
11626 (struct cmd_vf_split_drop_en_result,
11630 cmd_set_vf_split_drop_en_parsed(
11631 void *parsed_result,
11632 __attribute__((unused)) struct cmdline *cl,
11633 __attribute__((unused)) void *data)
11635 struct cmd_vf_split_drop_en_result *res = parsed_result;
11636 int ret = -ENOTSUP;
11637 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11639 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11642 #ifdef RTE_LIBRTE_IXGBE_PMD
11643 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11650 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11653 printf("invalid port_id %d\n", res->port_id);
11656 printf("not supported on port %d\n", res->port_id);
11659 printf("programming error: (%s)\n", strerror(-ret));
11663 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11664 .f = cmd_set_vf_split_drop_en_parsed,
11666 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11668 (void *)&cmd_vf_split_drop_en_set,
11669 (void *)&cmd_vf_split_drop_en_vf,
11670 (void *)&cmd_vf_split_drop_en_split,
11671 (void *)&cmd_vf_split_drop_en_drop,
11672 (void *)&cmd_vf_split_drop_en_port_id,
11673 (void *)&cmd_vf_split_drop_en_vf_id,
11674 (void *)&cmd_vf_split_drop_en_on_off,
11679 /* vf mac address configuration */
11681 /* Common result structure for vf mac address */
11682 struct cmd_set_vf_mac_addr_result {
11683 cmdline_fixed_string_t set;
11684 cmdline_fixed_string_t vf;
11685 cmdline_fixed_string_t mac;
11686 cmdline_fixed_string_t addr;
11689 struct ether_addr mac_addr;
11693 /* Common CLI fields for vf split drop enable disable */
11694 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11695 TOKEN_STRING_INITIALIZER
11696 (struct cmd_set_vf_mac_addr_result,
11698 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11699 TOKEN_STRING_INITIALIZER
11700 (struct cmd_set_vf_mac_addr_result,
11702 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11703 TOKEN_STRING_INITIALIZER
11704 (struct cmd_set_vf_mac_addr_result,
11706 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11707 TOKEN_STRING_INITIALIZER
11708 (struct cmd_set_vf_mac_addr_result,
11710 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11711 TOKEN_NUM_INITIALIZER
11712 (struct cmd_set_vf_mac_addr_result,
11714 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11715 TOKEN_NUM_INITIALIZER
11716 (struct cmd_set_vf_mac_addr_result,
11718 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11719 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11723 cmd_set_vf_mac_addr_parsed(
11724 void *parsed_result,
11725 __attribute__((unused)) struct cmdline *cl,
11726 __attribute__((unused)) void *data)
11728 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11729 int ret = -ENOTSUP;
11731 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11734 #ifdef RTE_LIBRTE_IXGBE_PMD
11735 if (ret == -ENOTSUP)
11736 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11739 #ifdef RTE_LIBRTE_I40E_PMD
11740 if (ret == -ENOTSUP)
11741 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11744 #ifdef RTE_LIBRTE_BNXT_PMD
11745 if (ret == -ENOTSUP)
11746 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11754 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11757 printf("invalid port_id %d\n", res->port_id);
11760 printf("function not implemented\n");
11763 printf("programming error: (%s)\n", strerror(-ret));
11767 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11768 .f = cmd_set_vf_mac_addr_parsed,
11770 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11772 (void *)&cmd_set_vf_mac_addr_set,
11773 (void *)&cmd_set_vf_mac_addr_vf,
11774 (void *)&cmd_set_vf_mac_addr_mac,
11775 (void *)&cmd_set_vf_mac_addr_addr,
11776 (void *)&cmd_set_vf_mac_addr_port_id,
11777 (void *)&cmd_set_vf_mac_addr_vf_id,
11778 (void *)&cmd_set_vf_mac_addr_mac_addr,
11783 /* MACsec configuration */
11785 /* Common result structure for MACsec offload enable */
11786 struct cmd_macsec_offload_on_result {
11787 cmdline_fixed_string_t set;
11788 cmdline_fixed_string_t macsec;
11789 cmdline_fixed_string_t offload;
11791 cmdline_fixed_string_t on;
11792 cmdline_fixed_string_t encrypt;
11793 cmdline_fixed_string_t en_on_off;
11794 cmdline_fixed_string_t replay_protect;
11795 cmdline_fixed_string_t rp_on_off;
11798 /* Common CLI fields for MACsec offload disable */
11799 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11800 TOKEN_STRING_INITIALIZER
11801 (struct cmd_macsec_offload_on_result,
11803 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11804 TOKEN_STRING_INITIALIZER
11805 (struct cmd_macsec_offload_on_result,
11807 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11808 TOKEN_STRING_INITIALIZER
11809 (struct cmd_macsec_offload_on_result,
11810 offload, "offload");
11811 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11812 TOKEN_NUM_INITIALIZER
11813 (struct cmd_macsec_offload_on_result,
11815 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11816 TOKEN_STRING_INITIALIZER
11817 (struct cmd_macsec_offload_on_result,
11819 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11820 TOKEN_STRING_INITIALIZER
11821 (struct cmd_macsec_offload_on_result,
11822 encrypt, "encrypt");
11823 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11824 TOKEN_STRING_INITIALIZER
11825 (struct cmd_macsec_offload_on_result,
11826 en_on_off, "on#off");
11827 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11828 TOKEN_STRING_INITIALIZER
11829 (struct cmd_macsec_offload_on_result,
11830 replay_protect, "replay-protect");
11831 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11832 TOKEN_STRING_INITIALIZER
11833 (struct cmd_macsec_offload_on_result,
11834 rp_on_off, "on#off");
11837 cmd_set_macsec_offload_on_parsed(
11838 void *parsed_result,
11839 __attribute__((unused)) struct cmdline *cl,
11840 __attribute__((unused)) void *data)
11842 struct cmd_macsec_offload_on_result *res = parsed_result;
11843 int ret = -ENOTSUP;
11844 portid_t port_id = res->port_id;
11845 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11846 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11848 if (port_id_is_invalid(port_id, ENABLED_WARN))
11851 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11852 #ifdef RTE_LIBRTE_IXGBE_PMD
11853 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11862 printf("invalid port_id %d\n", port_id);
11865 printf("not supported on port %d\n", port_id);
11868 printf("programming error: (%s)\n", strerror(-ret));
11872 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11873 .f = cmd_set_macsec_offload_on_parsed,
11875 .help_str = "set macsec offload <port_id> on "
11876 "encrypt on|off replay-protect on|off",
11878 (void *)&cmd_macsec_offload_on_set,
11879 (void *)&cmd_macsec_offload_on_macsec,
11880 (void *)&cmd_macsec_offload_on_offload,
11881 (void *)&cmd_macsec_offload_on_port_id,
11882 (void *)&cmd_macsec_offload_on_on,
11883 (void *)&cmd_macsec_offload_on_encrypt,
11884 (void *)&cmd_macsec_offload_on_en_on_off,
11885 (void *)&cmd_macsec_offload_on_replay_protect,
11886 (void *)&cmd_macsec_offload_on_rp_on_off,
11891 /* Common result structure for MACsec offload disable */
11892 struct cmd_macsec_offload_off_result {
11893 cmdline_fixed_string_t set;
11894 cmdline_fixed_string_t macsec;
11895 cmdline_fixed_string_t offload;
11897 cmdline_fixed_string_t off;
11900 /* Common CLI fields for MACsec offload disable */
11901 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11902 TOKEN_STRING_INITIALIZER
11903 (struct cmd_macsec_offload_off_result,
11905 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11906 TOKEN_STRING_INITIALIZER
11907 (struct cmd_macsec_offload_off_result,
11909 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11910 TOKEN_STRING_INITIALIZER
11911 (struct cmd_macsec_offload_off_result,
11912 offload, "offload");
11913 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11914 TOKEN_NUM_INITIALIZER
11915 (struct cmd_macsec_offload_off_result,
11917 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11918 TOKEN_STRING_INITIALIZER
11919 (struct cmd_macsec_offload_off_result,
11923 cmd_set_macsec_offload_off_parsed(
11924 void *parsed_result,
11925 __attribute__((unused)) struct cmdline *cl,
11926 __attribute__((unused)) void *data)
11928 struct cmd_macsec_offload_off_result *res = parsed_result;
11929 int ret = -ENOTSUP;
11930 portid_t port_id = res->port_id;
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_disable(port_id);
11944 printf("invalid port_id %d\n", port_id);
11947 printf("not supported on port %d\n", port_id);
11950 printf("programming error: (%s)\n", strerror(-ret));
11954 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11955 .f = cmd_set_macsec_offload_off_parsed,
11957 .help_str = "set macsec offload <port_id> off",
11959 (void *)&cmd_macsec_offload_off_set,
11960 (void *)&cmd_macsec_offload_off_macsec,
11961 (void *)&cmd_macsec_offload_off_offload,
11962 (void *)&cmd_macsec_offload_off_port_id,
11963 (void *)&cmd_macsec_offload_off_off,
11968 /* Common result structure for MACsec secure connection configure */
11969 struct cmd_macsec_sc_result {
11970 cmdline_fixed_string_t set;
11971 cmdline_fixed_string_t macsec;
11972 cmdline_fixed_string_t sc;
11973 cmdline_fixed_string_t tx_rx;
11975 struct ether_addr mac;
11979 /* Common CLI fields for MACsec secure connection configure */
11980 cmdline_parse_token_string_t cmd_macsec_sc_set =
11981 TOKEN_STRING_INITIALIZER
11982 (struct cmd_macsec_sc_result,
11984 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11985 TOKEN_STRING_INITIALIZER
11986 (struct cmd_macsec_sc_result,
11988 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11989 TOKEN_STRING_INITIALIZER
11990 (struct cmd_macsec_sc_result,
11992 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11993 TOKEN_STRING_INITIALIZER
11994 (struct cmd_macsec_sc_result,
11996 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11997 TOKEN_NUM_INITIALIZER
11998 (struct cmd_macsec_sc_result,
12000 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12001 TOKEN_ETHERADDR_INITIALIZER
12002 (struct cmd_macsec_sc_result,
12004 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12005 TOKEN_NUM_INITIALIZER
12006 (struct cmd_macsec_sc_result,
12010 cmd_set_macsec_sc_parsed(
12011 void *parsed_result,
12012 __attribute__((unused)) struct cmdline *cl,
12013 __attribute__((unused)) void *data)
12015 struct cmd_macsec_sc_result *res = parsed_result;
12016 int ret = -ENOTSUP;
12017 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12019 #ifdef RTE_LIBRTE_IXGBE_PMD
12021 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12022 res->mac.addr_bytes) :
12023 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12024 res->mac.addr_bytes, res->pi);
12026 RTE_SET_USED(is_tx);
12032 printf("invalid port_id %d\n", res->port_id);
12035 printf("not supported on port %d\n", res->port_id);
12038 printf("programming error: (%s)\n", strerror(-ret));
12042 cmdline_parse_inst_t cmd_set_macsec_sc = {
12043 .f = cmd_set_macsec_sc_parsed,
12045 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12047 (void *)&cmd_macsec_sc_set,
12048 (void *)&cmd_macsec_sc_macsec,
12049 (void *)&cmd_macsec_sc_sc,
12050 (void *)&cmd_macsec_sc_tx_rx,
12051 (void *)&cmd_macsec_sc_port_id,
12052 (void *)&cmd_macsec_sc_mac,
12053 (void *)&cmd_macsec_sc_pi,
12058 /* Common result structure for MACsec secure connection configure */
12059 struct cmd_macsec_sa_result {
12060 cmdline_fixed_string_t set;
12061 cmdline_fixed_string_t macsec;
12062 cmdline_fixed_string_t sa;
12063 cmdline_fixed_string_t tx_rx;
12068 cmdline_fixed_string_t key;
12071 /* Common CLI fields for MACsec secure connection configure */
12072 cmdline_parse_token_string_t cmd_macsec_sa_set =
12073 TOKEN_STRING_INITIALIZER
12074 (struct cmd_macsec_sa_result,
12076 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12077 TOKEN_STRING_INITIALIZER
12078 (struct cmd_macsec_sa_result,
12080 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12081 TOKEN_STRING_INITIALIZER
12082 (struct cmd_macsec_sa_result,
12084 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12085 TOKEN_STRING_INITIALIZER
12086 (struct cmd_macsec_sa_result,
12088 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12089 TOKEN_NUM_INITIALIZER
12090 (struct cmd_macsec_sa_result,
12092 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12093 TOKEN_NUM_INITIALIZER
12094 (struct cmd_macsec_sa_result,
12096 cmdline_parse_token_num_t cmd_macsec_sa_an =
12097 TOKEN_NUM_INITIALIZER
12098 (struct cmd_macsec_sa_result,
12100 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12101 TOKEN_NUM_INITIALIZER
12102 (struct cmd_macsec_sa_result,
12104 cmdline_parse_token_string_t cmd_macsec_sa_key =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_macsec_sa_result,
12110 cmd_set_macsec_sa_parsed(
12111 void *parsed_result,
12112 __attribute__((unused)) struct cmdline *cl,
12113 __attribute__((unused)) void *data)
12115 struct cmd_macsec_sa_result *res = parsed_result;
12116 int ret = -ENOTSUP;
12117 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12118 uint8_t key[16] = { 0 };
12124 key_len = strlen(res->key) / 2;
12128 for (i = 0; i < key_len; i++) {
12129 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12132 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12135 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12138 #ifdef RTE_LIBRTE_IXGBE_PMD
12140 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12141 res->idx, res->an, res->pn, key) :
12142 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12143 res->idx, res->an, res->pn, key);
12145 RTE_SET_USED(is_tx);
12152 printf("invalid idx %d or an %d\n", res->idx, res->an);
12155 printf("invalid port_id %d\n", res->port_id);
12158 printf("not supported on port %d\n", res->port_id);
12161 printf("programming error: (%s)\n", strerror(-ret));
12165 cmdline_parse_inst_t cmd_set_macsec_sa = {
12166 .f = cmd_set_macsec_sa_parsed,
12168 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12170 (void *)&cmd_macsec_sa_set,
12171 (void *)&cmd_macsec_sa_macsec,
12172 (void *)&cmd_macsec_sa_sa,
12173 (void *)&cmd_macsec_sa_tx_rx,
12174 (void *)&cmd_macsec_sa_port_id,
12175 (void *)&cmd_macsec_sa_idx,
12176 (void *)&cmd_macsec_sa_an,
12177 (void *)&cmd_macsec_sa_pn,
12178 (void *)&cmd_macsec_sa_key,
12183 /* VF unicast promiscuous mode configuration */
12185 /* Common result structure for VF unicast promiscuous mode */
12186 struct cmd_vf_promisc_result {
12187 cmdline_fixed_string_t set;
12188 cmdline_fixed_string_t vf;
12189 cmdline_fixed_string_t promisc;
12192 cmdline_fixed_string_t on_off;
12195 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12196 cmdline_parse_token_string_t cmd_vf_promisc_set =
12197 TOKEN_STRING_INITIALIZER
12198 (struct cmd_vf_promisc_result,
12200 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12201 TOKEN_STRING_INITIALIZER
12202 (struct cmd_vf_promisc_result,
12204 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12205 TOKEN_STRING_INITIALIZER
12206 (struct cmd_vf_promisc_result,
12207 promisc, "promisc");
12208 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12209 TOKEN_NUM_INITIALIZER
12210 (struct cmd_vf_promisc_result,
12212 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12213 TOKEN_NUM_INITIALIZER
12214 (struct cmd_vf_promisc_result,
12216 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12217 TOKEN_STRING_INITIALIZER
12218 (struct cmd_vf_promisc_result,
12222 cmd_set_vf_promisc_parsed(
12223 void *parsed_result,
12224 __attribute__((unused)) struct cmdline *cl,
12225 __attribute__((unused)) void *data)
12227 struct cmd_vf_promisc_result *res = parsed_result;
12228 int ret = -ENOTSUP;
12230 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12232 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12235 #ifdef RTE_LIBRTE_I40E_PMD
12236 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12237 res->vf_id, is_on);
12244 printf("invalid vf_id %d\n", res->vf_id);
12247 printf("invalid port_id %d\n", res->port_id);
12250 printf("function not implemented\n");
12253 printf("programming error: (%s)\n", strerror(-ret));
12257 cmdline_parse_inst_t cmd_set_vf_promisc = {
12258 .f = cmd_set_vf_promisc_parsed,
12260 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12261 "Set unicast promiscuous mode for a VF from the PF",
12263 (void *)&cmd_vf_promisc_set,
12264 (void *)&cmd_vf_promisc_vf,
12265 (void *)&cmd_vf_promisc_promisc,
12266 (void *)&cmd_vf_promisc_port_id,
12267 (void *)&cmd_vf_promisc_vf_id,
12268 (void *)&cmd_vf_promisc_on_off,
12273 /* VF multicast promiscuous mode configuration */
12275 /* Common result structure for VF multicast promiscuous mode */
12276 struct cmd_vf_allmulti_result {
12277 cmdline_fixed_string_t set;
12278 cmdline_fixed_string_t vf;
12279 cmdline_fixed_string_t allmulti;
12282 cmdline_fixed_string_t on_off;
12285 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12286 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12287 TOKEN_STRING_INITIALIZER
12288 (struct cmd_vf_allmulti_result,
12290 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12291 TOKEN_STRING_INITIALIZER
12292 (struct cmd_vf_allmulti_result,
12294 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12295 TOKEN_STRING_INITIALIZER
12296 (struct cmd_vf_allmulti_result,
12297 allmulti, "allmulti");
12298 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12299 TOKEN_NUM_INITIALIZER
12300 (struct cmd_vf_allmulti_result,
12302 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12303 TOKEN_NUM_INITIALIZER
12304 (struct cmd_vf_allmulti_result,
12306 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12307 TOKEN_STRING_INITIALIZER
12308 (struct cmd_vf_allmulti_result,
12312 cmd_set_vf_allmulti_parsed(
12313 void *parsed_result,
12314 __attribute__((unused)) struct cmdline *cl,
12315 __attribute__((unused)) void *data)
12317 struct cmd_vf_allmulti_result *res = parsed_result;
12318 int ret = -ENOTSUP;
12320 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12322 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12325 #ifdef RTE_LIBRTE_I40E_PMD
12326 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12327 res->vf_id, is_on);
12334 printf("invalid vf_id %d\n", res->vf_id);
12337 printf("invalid port_id %d\n", res->port_id);
12340 printf("function not implemented\n");
12343 printf("programming error: (%s)\n", strerror(-ret));
12347 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12348 .f = cmd_set_vf_allmulti_parsed,
12350 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12351 "Set multicast promiscuous mode for a VF from the PF",
12353 (void *)&cmd_vf_allmulti_set,
12354 (void *)&cmd_vf_allmulti_vf,
12355 (void *)&cmd_vf_allmulti_allmulti,
12356 (void *)&cmd_vf_allmulti_port_id,
12357 (void *)&cmd_vf_allmulti_vf_id,
12358 (void *)&cmd_vf_allmulti_on_off,
12363 /* vf broadcast mode configuration */
12365 /* Common result structure for vf broadcast */
12366 struct cmd_set_vf_broadcast_result {
12367 cmdline_fixed_string_t set;
12368 cmdline_fixed_string_t vf;
12369 cmdline_fixed_string_t broadcast;
12372 cmdline_fixed_string_t on_off;
12375 /* Common CLI fields for vf broadcast enable disable */
12376 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_set_vf_broadcast_result,
12380 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12381 TOKEN_STRING_INITIALIZER
12382 (struct cmd_set_vf_broadcast_result,
12384 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12385 TOKEN_STRING_INITIALIZER
12386 (struct cmd_set_vf_broadcast_result,
12387 broadcast, "broadcast");
12388 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12389 TOKEN_NUM_INITIALIZER
12390 (struct cmd_set_vf_broadcast_result,
12392 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12393 TOKEN_NUM_INITIALIZER
12394 (struct cmd_set_vf_broadcast_result,
12396 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12397 TOKEN_STRING_INITIALIZER
12398 (struct cmd_set_vf_broadcast_result,
12402 cmd_set_vf_broadcast_parsed(
12403 void *parsed_result,
12404 __attribute__((unused)) struct cmdline *cl,
12405 __attribute__((unused)) void *data)
12407 struct cmd_set_vf_broadcast_result *res = parsed_result;
12408 int ret = -ENOTSUP;
12410 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12412 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12415 #ifdef RTE_LIBRTE_I40E_PMD
12416 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12417 res->vf_id, is_on);
12424 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12427 printf("invalid port_id %d\n", res->port_id);
12430 printf("function not implemented\n");
12433 printf("programming error: (%s)\n", strerror(-ret));
12437 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12438 .f = cmd_set_vf_broadcast_parsed,
12440 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12442 (void *)&cmd_set_vf_broadcast_set,
12443 (void *)&cmd_set_vf_broadcast_vf,
12444 (void *)&cmd_set_vf_broadcast_broadcast,
12445 (void *)&cmd_set_vf_broadcast_port_id,
12446 (void *)&cmd_set_vf_broadcast_vf_id,
12447 (void *)&cmd_set_vf_broadcast_on_off,
12452 /* vf vlan tag configuration */
12454 /* Common result structure for vf vlan tag */
12455 struct cmd_set_vf_vlan_tag_result {
12456 cmdline_fixed_string_t set;
12457 cmdline_fixed_string_t vf;
12458 cmdline_fixed_string_t vlan;
12459 cmdline_fixed_string_t tag;
12462 cmdline_fixed_string_t on_off;
12465 /* Common CLI fields for vf vlan tag enable disable */
12466 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12467 TOKEN_STRING_INITIALIZER
12468 (struct cmd_set_vf_vlan_tag_result,
12470 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12471 TOKEN_STRING_INITIALIZER
12472 (struct cmd_set_vf_vlan_tag_result,
12474 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12475 TOKEN_STRING_INITIALIZER
12476 (struct cmd_set_vf_vlan_tag_result,
12478 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12479 TOKEN_STRING_INITIALIZER
12480 (struct cmd_set_vf_vlan_tag_result,
12482 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12483 TOKEN_NUM_INITIALIZER
12484 (struct cmd_set_vf_vlan_tag_result,
12486 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12487 TOKEN_NUM_INITIALIZER
12488 (struct cmd_set_vf_vlan_tag_result,
12490 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12491 TOKEN_STRING_INITIALIZER
12492 (struct cmd_set_vf_vlan_tag_result,
12496 cmd_set_vf_vlan_tag_parsed(
12497 void *parsed_result,
12498 __attribute__((unused)) struct cmdline *cl,
12499 __attribute__((unused)) void *data)
12501 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12502 int ret = -ENOTSUP;
12504 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12506 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12509 #ifdef RTE_LIBRTE_I40E_PMD
12510 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12511 res->vf_id, is_on);
12518 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12521 printf("invalid port_id %d\n", res->port_id);
12524 printf("function not implemented\n");
12527 printf("programming error: (%s)\n", strerror(-ret));
12531 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12532 .f = cmd_set_vf_vlan_tag_parsed,
12534 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12536 (void *)&cmd_set_vf_vlan_tag_set,
12537 (void *)&cmd_set_vf_vlan_tag_vf,
12538 (void *)&cmd_set_vf_vlan_tag_vlan,
12539 (void *)&cmd_set_vf_vlan_tag_tag,
12540 (void *)&cmd_set_vf_vlan_tag_port_id,
12541 (void *)&cmd_set_vf_vlan_tag_vf_id,
12542 (void *)&cmd_set_vf_vlan_tag_on_off,
12547 /* Common definition of VF and TC TX bandwidth configuration */
12548 struct cmd_vf_tc_bw_result {
12549 cmdline_fixed_string_t set;
12550 cmdline_fixed_string_t vf;
12551 cmdline_fixed_string_t tc;
12552 cmdline_fixed_string_t tx;
12553 cmdline_fixed_string_t min_bw;
12554 cmdline_fixed_string_t max_bw;
12555 cmdline_fixed_string_t strict_link_prio;
12560 cmdline_fixed_string_t bw_list;
12564 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12565 TOKEN_STRING_INITIALIZER
12566 (struct cmd_vf_tc_bw_result,
12568 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12569 TOKEN_STRING_INITIALIZER
12570 (struct cmd_vf_tc_bw_result,
12572 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12573 TOKEN_STRING_INITIALIZER
12574 (struct cmd_vf_tc_bw_result,
12576 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12577 TOKEN_STRING_INITIALIZER
12578 (struct cmd_vf_tc_bw_result,
12580 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12581 TOKEN_STRING_INITIALIZER
12582 (struct cmd_vf_tc_bw_result,
12583 strict_link_prio, "strict-link-priority");
12584 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12585 TOKEN_STRING_INITIALIZER
12586 (struct cmd_vf_tc_bw_result,
12587 min_bw, "min-bandwidth");
12588 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12589 TOKEN_STRING_INITIALIZER
12590 (struct cmd_vf_tc_bw_result,
12591 max_bw, "max-bandwidth");
12592 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12593 TOKEN_NUM_INITIALIZER
12594 (struct cmd_vf_tc_bw_result,
12596 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12597 TOKEN_NUM_INITIALIZER
12598 (struct cmd_vf_tc_bw_result,
12600 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12601 TOKEN_NUM_INITIALIZER
12602 (struct cmd_vf_tc_bw_result,
12604 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12605 TOKEN_NUM_INITIALIZER
12606 (struct cmd_vf_tc_bw_result,
12608 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12609 TOKEN_STRING_INITIALIZER
12610 (struct cmd_vf_tc_bw_result,
12612 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12613 TOKEN_NUM_INITIALIZER
12614 (struct cmd_vf_tc_bw_result,
12617 /* VF max bandwidth setting */
12619 cmd_vf_max_bw_parsed(
12620 void *parsed_result,
12621 __attribute__((unused)) struct cmdline *cl,
12622 __attribute__((unused)) void *data)
12624 struct cmd_vf_tc_bw_result *res = parsed_result;
12625 int ret = -ENOTSUP;
12627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12630 #ifdef RTE_LIBRTE_I40E_PMD
12631 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12632 res->vf_id, res->bw);
12639 printf("invalid vf_id %d or bandwidth %d\n",
12640 res->vf_id, res->bw);
12643 printf("invalid port_id %d\n", res->port_id);
12646 printf("function not implemented\n");
12649 printf("programming error: (%s)\n", strerror(-ret));
12653 cmdline_parse_inst_t cmd_vf_max_bw = {
12654 .f = cmd_vf_max_bw_parsed,
12656 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12658 (void *)&cmd_vf_tc_bw_set,
12659 (void *)&cmd_vf_tc_bw_vf,
12660 (void *)&cmd_vf_tc_bw_tx,
12661 (void *)&cmd_vf_tc_bw_max_bw,
12662 (void *)&cmd_vf_tc_bw_port_id,
12663 (void *)&cmd_vf_tc_bw_vf_id,
12664 (void *)&cmd_vf_tc_bw_bw,
12670 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12675 const char *p, *p0 = str;
12682 p = strchr(p0, '(');
12684 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12688 p0 = strchr(p, ')');
12690 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12694 if (size >= sizeof(s)) {
12695 printf("The string size exceeds the internal buffer size\n");
12698 snprintf(s, sizeof(s), "%.*s", size, p);
12699 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12701 printf("Failed to get the bandwidth list. ");
12705 for (i = 0; i < ret; i++)
12706 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12711 /* TC min bandwidth setting */
12713 cmd_vf_tc_min_bw_parsed(
12714 void *parsed_result,
12715 __attribute__((unused)) struct cmdline *cl,
12716 __attribute__((unused)) void *data)
12718 struct cmd_vf_tc_bw_result *res = parsed_result;
12721 int ret = -ENOTSUP;
12723 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12726 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12730 #ifdef RTE_LIBRTE_I40E_PMD
12731 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12739 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12742 printf("invalid port_id %d\n", res->port_id);
12745 printf("function not implemented\n");
12748 printf("programming error: (%s)\n", strerror(-ret));
12752 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12753 .f = cmd_vf_tc_min_bw_parsed,
12755 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12756 " <bw1, bw2, ...>",
12758 (void *)&cmd_vf_tc_bw_set,
12759 (void *)&cmd_vf_tc_bw_vf,
12760 (void *)&cmd_vf_tc_bw_tc,
12761 (void *)&cmd_vf_tc_bw_tx,
12762 (void *)&cmd_vf_tc_bw_min_bw,
12763 (void *)&cmd_vf_tc_bw_port_id,
12764 (void *)&cmd_vf_tc_bw_vf_id,
12765 (void *)&cmd_vf_tc_bw_bw_list,
12771 cmd_tc_min_bw_parsed(
12772 void *parsed_result,
12773 __attribute__((unused)) struct cmdline *cl,
12774 __attribute__((unused)) void *data)
12776 struct cmd_vf_tc_bw_result *res = parsed_result;
12777 struct rte_port *port;
12780 int ret = -ENOTSUP;
12782 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12785 port = &ports[res->port_id];
12786 /** Check if the port is not started **/
12787 if (port->port_status != RTE_PORT_STOPPED) {
12788 printf("Please stop port %d first\n", res->port_id);
12792 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12796 #ifdef RTE_LIBRTE_IXGBE_PMD
12797 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12804 printf("invalid bandwidth\n");
12807 printf("invalid port_id %d\n", res->port_id);
12810 printf("function not implemented\n");
12813 printf("programming error: (%s)\n", strerror(-ret));
12817 cmdline_parse_inst_t cmd_tc_min_bw = {
12818 .f = cmd_tc_min_bw_parsed,
12820 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12822 (void *)&cmd_vf_tc_bw_set,
12823 (void *)&cmd_vf_tc_bw_tc,
12824 (void *)&cmd_vf_tc_bw_tx,
12825 (void *)&cmd_vf_tc_bw_min_bw,
12826 (void *)&cmd_vf_tc_bw_port_id,
12827 (void *)&cmd_vf_tc_bw_bw_list,
12832 /* TC max bandwidth setting */
12834 cmd_vf_tc_max_bw_parsed(
12835 void *parsed_result,
12836 __attribute__((unused)) struct cmdline *cl,
12837 __attribute__((unused)) void *data)
12839 struct cmd_vf_tc_bw_result *res = parsed_result;
12840 int ret = -ENOTSUP;
12842 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12845 #ifdef RTE_LIBRTE_I40E_PMD
12846 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12847 res->tc_no, res->bw);
12854 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12855 res->vf_id, res->tc_no, res->bw);
12858 printf("invalid port_id %d\n", res->port_id);
12861 printf("function not implemented\n");
12864 printf("programming error: (%s)\n", strerror(-ret));
12868 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12869 .f = cmd_vf_tc_max_bw_parsed,
12871 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12874 (void *)&cmd_vf_tc_bw_set,
12875 (void *)&cmd_vf_tc_bw_vf,
12876 (void *)&cmd_vf_tc_bw_tc,
12877 (void *)&cmd_vf_tc_bw_tx,
12878 (void *)&cmd_vf_tc_bw_max_bw,
12879 (void *)&cmd_vf_tc_bw_port_id,
12880 (void *)&cmd_vf_tc_bw_vf_id,
12881 (void *)&cmd_vf_tc_bw_tc_no,
12882 (void *)&cmd_vf_tc_bw_bw,
12887 /* Strict link priority scheduling mode setting */
12889 cmd_strict_link_prio_parsed(
12890 void *parsed_result,
12891 __attribute__((unused)) struct cmdline *cl,
12892 __attribute__((unused)) void *data)
12894 struct cmd_vf_tc_bw_result *res = parsed_result;
12895 int ret = -ENOTSUP;
12897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12900 #ifdef RTE_LIBRTE_I40E_PMD
12901 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12908 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12911 printf("invalid port_id %d\n", res->port_id);
12914 printf("function not implemented\n");
12917 printf("programming error: (%s)\n", strerror(-ret));
12921 cmdline_parse_inst_t cmd_strict_link_prio = {
12922 .f = cmd_strict_link_prio_parsed,
12924 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12926 (void *)&cmd_vf_tc_bw_set,
12927 (void *)&cmd_vf_tc_bw_tx,
12928 (void *)&cmd_vf_tc_bw_strict_link_prio,
12929 (void *)&cmd_vf_tc_bw_port_id,
12930 (void *)&cmd_vf_tc_bw_tc_map,
12935 /* Load dynamic device personalization*/
12936 struct cmd_ddp_add_result {
12937 cmdline_fixed_string_t ddp;
12938 cmdline_fixed_string_t add;
12943 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12944 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12945 cmdline_parse_token_string_t cmd_ddp_add_add =
12946 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12947 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12948 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12949 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12950 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12953 cmd_ddp_add_parsed(
12954 void *parsed_result,
12955 __attribute__((unused)) struct cmdline *cl,
12956 __attribute__((unused)) void *data)
12958 struct cmd_ddp_add_result *res = parsed_result;
12964 int ret = -ENOTSUP;
12966 if (res->port_id > nb_ports) {
12967 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12971 if (!all_ports_stopped()) {
12972 printf("Please stop all ports first\n");
12976 filepath = strdup(res->filepath);
12977 if (filepath == NULL) {
12978 printf("Failed to allocate memory\n");
12981 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
12983 buff = open_ddp_package_file(file_fld[0], &size);
12985 free((void *)filepath);
12989 #ifdef RTE_LIBRTE_I40E_PMD
12990 if (ret == -ENOTSUP)
12991 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12993 RTE_PMD_I40E_PKG_OP_WR_ADD);
12996 if (ret == -EEXIST)
12997 printf("Profile has already existed.\n");
12999 printf("Failed to load profile.\n");
13000 else if (file_num == 2)
13001 save_ddp_package_file(file_fld[1], buff, size);
13003 close_ddp_package_file(buff);
13004 free((void *)filepath);
13007 cmdline_parse_inst_t cmd_ddp_add = {
13008 .f = cmd_ddp_add_parsed,
13010 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13012 (void *)&cmd_ddp_add_ddp,
13013 (void *)&cmd_ddp_add_add,
13014 (void *)&cmd_ddp_add_port_id,
13015 (void *)&cmd_ddp_add_filepath,
13020 /* Delete dynamic device personalization*/
13021 struct cmd_ddp_del_result {
13022 cmdline_fixed_string_t ddp;
13023 cmdline_fixed_string_t del;
13028 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13029 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13030 cmdline_parse_token_string_t cmd_ddp_del_del =
13031 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13032 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13033 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13034 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13035 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13038 cmd_ddp_del_parsed(
13039 void *parsed_result,
13040 __attribute__((unused)) struct cmdline *cl,
13041 __attribute__((unused)) void *data)
13043 struct cmd_ddp_del_result *res = parsed_result;
13046 int ret = -ENOTSUP;
13048 if (res->port_id > nb_ports) {
13049 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13053 if (!all_ports_stopped()) {
13054 printf("Please stop all ports first\n");
13058 buff = open_ddp_package_file(res->filepath, &size);
13062 #ifdef RTE_LIBRTE_I40E_PMD
13063 if (ret == -ENOTSUP)
13064 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13066 RTE_PMD_I40E_PKG_OP_WR_DEL);
13069 if (ret == -EACCES)
13070 printf("Profile does not exist.\n");
13072 printf("Failed to delete profile.\n");
13074 close_ddp_package_file(buff);
13077 cmdline_parse_inst_t cmd_ddp_del = {
13078 .f = cmd_ddp_del_parsed,
13080 .help_str = "ddp del <port_id> <profile_path>",
13082 (void *)&cmd_ddp_del_ddp,
13083 (void *)&cmd_ddp_del_del,
13084 (void *)&cmd_ddp_del_port_id,
13085 (void *)&cmd_ddp_del_filepath,
13090 /* Get dynamic device personalization profile info */
13091 struct cmd_ddp_info_result {
13092 cmdline_fixed_string_t ddp;
13093 cmdline_fixed_string_t get;
13094 cmdline_fixed_string_t info;
13098 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13099 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13100 cmdline_parse_token_string_t cmd_ddp_info_get =
13101 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13102 cmdline_parse_token_string_t cmd_ddp_info_info =
13103 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13104 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13105 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13108 cmd_ddp_info_parsed(
13109 void *parsed_result,
13110 __attribute__((unused)) struct cmdline *cl,
13111 __attribute__((unused)) void *data)
13113 struct cmd_ddp_info_result *res = parsed_result;
13116 int ret = -ENOTSUP;
13117 #ifdef RTE_LIBRTE_I40E_PMD
13120 uint32_t buff_size;
13121 struct rte_pmd_i40e_profile_info info;
13123 struct rte_pmd_i40e_ddp_device_id *devs;
13126 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13130 #ifdef RTE_LIBRTE_I40E_PMD
13131 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13132 (uint8_t *)&info, sizeof(info),
13133 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13135 printf("Global Track id: 0x%x\n", info.track_id);
13136 printf("Global Version: %d.%d.%d.%d\n",
13137 info.version.major,
13138 info.version.minor,
13139 info.version.update,
13140 info.version.draft);
13141 printf("Global Package name: %s\n\n", info.name);
13144 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13145 (uint8_t *)&info, sizeof(info),
13146 RTE_PMD_I40E_PKG_INFO_HEADER);
13148 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13149 printf("i40e Profile Version: %d.%d.%d.%d\n",
13150 info.version.major,
13151 info.version.minor,
13152 info.version.update,
13153 info.version.draft);
13154 printf("i40e Profile name: %s\n\n", info.name);
13157 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13158 (uint8_t *)&buff_size, sizeof(buff_size),
13159 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13160 if (!ret && buff_size) {
13161 buff = (uint8_t *)malloc(buff_size);
13163 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13165 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13167 printf("Package Notes:\n%s\n\n", buff);
13172 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13173 (uint8_t *)&dev_num, sizeof(dev_num),
13174 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13175 if (!ret && dev_num) {
13176 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
13177 sizeof(struct rte_pmd_i40e_ddp_device_id));
13179 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13180 (uint8_t *)devs, dev_num *
13181 sizeof(struct rte_pmd_i40e_ddp_device_id),
13182 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13184 printf("List of supported devices:\n");
13185 for (i = 0; i < dev_num; i++) {
13186 printf(" %04X:%04X %04X:%04X\n",
13187 devs[i].vendor_dev_id >> 16,
13188 devs[i].vendor_dev_id & 0xFFFF,
13189 devs[i].sub_vendor_dev_id >> 16,
13190 devs[i].sub_vendor_dev_id & 0xFFFF);
13199 if (ret == -ENOTSUP)
13200 printf("Function not supported in PMD driver\n");
13201 close_ddp_package_file(pkg);
13204 cmdline_parse_inst_t cmd_ddp_get_info = {
13205 .f = cmd_ddp_info_parsed,
13207 .help_str = "ddp get info <profile_path>",
13209 (void *)&cmd_ddp_info_ddp,
13210 (void *)&cmd_ddp_info_get,
13211 (void *)&cmd_ddp_info_info,
13212 (void *)&cmd_ddp_info_filepath,
13217 /* Get dynamic device personalization profile info list*/
13218 #define PROFILE_INFO_SIZE 48
13219 #define MAX_PROFILE_NUM 16
13221 struct cmd_ddp_get_list_result {
13222 cmdline_fixed_string_t ddp;
13223 cmdline_fixed_string_t get;
13224 cmdline_fixed_string_t list;
13228 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13229 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13230 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13231 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13232 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13233 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13234 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13235 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13238 cmd_ddp_get_list_parsed(
13239 void *parsed_result,
13240 __attribute__((unused)) struct cmdline *cl,
13241 __attribute__((unused)) void *data)
13243 struct cmd_ddp_get_list_result *res = parsed_result;
13244 #ifdef RTE_LIBRTE_I40E_PMD
13245 struct rte_pmd_i40e_profile_list *p_list;
13246 struct rte_pmd_i40e_profile_info *p_info;
13251 int ret = -ENOTSUP;
13253 if (res->port_id > nb_ports) {
13254 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13258 #ifdef RTE_LIBRTE_I40E_PMD
13259 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13260 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13262 printf("%s: Failed to malloc buffer\n", __func__);
13264 if (ret == -ENOTSUP)
13265 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13266 (uint8_t *)p_list, size);
13269 p_num = p_list->p_count;
13270 printf("Profile number is: %d\n\n", p_num);
13272 for (i = 0; i < p_num; i++) {
13273 p_info = &p_list->p_info[i];
13274 printf("Profile %d:\n", i);
13275 printf("Track id: 0x%x\n", p_info->track_id);
13276 printf("Version: %d.%d.%d.%d\n",
13277 p_info->version.major,
13278 p_info->version.minor,
13279 p_info->version.update,
13280 p_info->version.draft);
13281 printf("Profile name: %s\n\n", p_info->name);
13289 printf("Failed to get ddp list\n");
13292 cmdline_parse_inst_t cmd_ddp_get_list = {
13293 .f = cmd_ddp_get_list_parsed,
13295 .help_str = "ddp get list <port_id>",
13297 (void *)&cmd_ddp_get_list_ddp,
13298 (void *)&cmd_ddp_get_list_get,
13299 (void *)&cmd_ddp_get_list_list,
13300 (void *)&cmd_ddp_get_list_port_id,
13305 /* show vf stats */
13307 /* Common result structure for show vf stats */
13308 struct cmd_show_vf_stats_result {
13309 cmdline_fixed_string_t show;
13310 cmdline_fixed_string_t vf;
13311 cmdline_fixed_string_t stats;
13316 /* Common CLI fields show vf stats*/
13317 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13318 TOKEN_STRING_INITIALIZER
13319 (struct cmd_show_vf_stats_result,
13321 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13322 TOKEN_STRING_INITIALIZER
13323 (struct cmd_show_vf_stats_result,
13325 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13326 TOKEN_STRING_INITIALIZER
13327 (struct cmd_show_vf_stats_result,
13329 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13330 TOKEN_NUM_INITIALIZER
13331 (struct cmd_show_vf_stats_result,
13333 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13334 TOKEN_NUM_INITIALIZER
13335 (struct cmd_show_vf_stats_result,
13339 cmd_show_vf_stats_parsed(
13340 void *parsed_result,
13341 __attribute__((unused)) struct cmdline *cl,
13342 __attribute__((unused)) void *data)
13344 struct cmd_show_vf_stats_result *res = parsed_result;
13345 struct rte_eth_stats stats;
13346 int ret = -ENOTSUP;
13347 static const char *nic_stats_border = "########################";
13349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13352 memset(&stats, 0, sizeof(stats));
13354 #ifdef RTE_LIBRTE_I40E_PMD
13355 if (ret == -ENOTSUP)
13356 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13360 #ifdef RTE_LIBRTE_BNXT_PMD
13361 if (ret == -ENOTSUP)
13362 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13371 printf("invalid vf_id %d\n", res->vf_id);
13374 printf("invalid port_id %d\n", res->port_id);
13377 printf("function not implemented\n");
13380 printf("programming error: (%s)\n", strerror(-ret));
13383 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13384 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13386 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13388 stats.ipackets, stats.imissed, stats.ibytes);
13389 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13390 printf(" RX-nombuf: %-10"PRIu64"\n",
13392 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13394 stats.opackets, stats.oerrors, stats.obytes);
13396 printf(" %s############################%s\n",
13397 nic_stats_border, nic_stats_border);
13400 cmdline_parse_inst_t cmd_show_vf_stats = {
13401 .f = cmd_show_vf_stats_parsed,
13403 .help_str = "show vf stats <port_id> <vf_id>",
13405 (void *)&cmd_show_vf_stats_show,
13406 (void *)&cmd_show_vf_stats_vf,
13407 (void *)&cmd_show_vf_stats_stats,
13408 (void *)&cmd_show_vf_stats_port_id,
13409 (void *)&cmd_show_vf_stats_vf_id,
13414 /* clear vf stats */
13416 /* Common result structure for clear vf stats */
13417 struct cmd_clear_vf_stats_result {
13418 cmdline_fixed_string_t clear;
13419 cmdline_fixed_string_t vf;
13420 cmdline_fixed_string_t stats;
13425 /* Common CLI fields clear vf stats*/
13426 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13427 TOKEN_STRING_INITIALIZER
13428 (struct cmd_clear_vf_stats_result,
13430 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13431 TOKEN_STRING_INITIALIZER
13432 (struct cmd_clear_vf_stats_result,
13434 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13435 TOKEN_STRING_INITIALIZER
13436 (struct cmd_clear_vf_stats_result,
13438 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13439 TOKEN_NUM_INITIALIZER
13440 (struct cmd_clear_vf_stats_result,
13442 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13443 TOKEN_NUM_INITIALIZER
13444 (struct cmd_clear_vf_stats_result,
13448 cmd_clear_vf_stats_parsed(
13449 void *parsed_result,
13450 __attribute__((unused)) struct cmdline *cl,
13451 __attribute__((unused)) void *data)
13453 struct cmd_clear_vf_stats_result *res = parsed_result;
13454 int ret = -ENOTSUP;
13456 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13459 #ifdef RTE_LIBRTE_I40E_PMD
13460 if (ret == -ENOTSUP)
13461 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13464 #ifdef RTE_LIBRTE_BNXT_PMD
13465 if (ret == -ENOTSUP)
13466 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13474 printf("invalid vf_id %d\n", res->vf_id);
13477 printf("invalid port_id %d\n", res->port_id);
13480 printf("function not implemented\n");
13483 printf("programming error: (%s)\n", strerror(-ret));
13487 cmdline_parse_inst_t cmd_clear_vf_stats = {
13488 .f = cmd_clear_vf_stats_parsed,
13490 .help_str = "clear vf stats <port_id> <vf_id>",
13492 (void *)&cmd_clear_vf_stats_clear,
13493 (void *)&cmd_clear_vf_stats_vf,
13494 (void *)&cmd_clear_vf_stats_stats,
13495 (void *)&cmd_clear_vf_stats_port_id,
13496 (void *)&cmd_clear_vf_stats_vf_id,
13501 /* ptype mapping get */
13503 /* Common result structure for ptype mapping get */
13504 struct cmd_ptype_mapping_get_result {
13505 cmdline_fixed_string_t ptype;
13506 cmdline_fixed_string_t mapping;
13507 cmdline_fixed_string_t get;
13509 uint8_t valid_only;
13512 /* Common CLI fields for ptype mapping get */
13513 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13514 TOKEN_STRING_INITIALIZER
13515 (struct cmd_ptype_mapping_get_result,
13517 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13518 TOKEN_STRING_INITIALIZER
13519 (struct cmd_ptype_mapping_get_result,
13520 mapping, "mapping");
13521 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13522 TOKEN_STRING_INITIALIZER
13523 (struct cmd_ptype_mapping_get_result,
13525 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13526 TOKEN_NUM_INITIALIZER
13527 (struct cmd_ptype_mapping_get_result,
13529 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13530 TOKEN_NUM_INITIALIZER
13531 (struct cmd_ptype_mapping_get_result,
13532 valid_only, UINT8);
13535 cmd_ptype_mapping_get_parsed(
13536 void *parsed_result,
13537 __attribute__((unused)) struct cmdline *cl,
13538 __attribute__((unused)) void *data)
13540 struct cmd_ptype_mapping_get_result *res = parsed_result;
13541 int ret = -ENOTSUP;
13542 #ifdef RTE_LIBRTE_I40E_PMD
13543 int max_ptype_num = 256;
13544 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13549 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13552 #ifdef RTE_LIBRTE_I40E_PMD
13553 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13564 printf("invalid port_id %d\n", res->port_id);
13567 printf("function not implemented\n");
13570 printf("programming error: (%s)\n", strerror(-ret));
13573 #ifdef RTE_LIBRTE_I40E_PMD
13575 for (i = 0; i < count; i++)
13576 printf("%3d\t0x%08x\n",
13577 mapping[i].hw_ptype, mapping[i].sw_ptype);
13582 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13583 .f = cmd_ptype_mapping_get_parsed,
13585 .help_str = "ptype mapping get <port_id> <valid_only>",
13587 (void *)&cmd_ptype_mapping_get_ptype,
13588 (void *)&cmd_ptype_mapping_get_mapping,
13589 (void *)&cmd_ptype_mapping_get_get,
13590 (void *)&cmd_ptype_mapping_get_port_id,
13591 (void *)&cmd_ptype_mapping_get_valid_only,
13596 /* ptype mapping replace */
13598 /* Common result structure for ptype mapping replace */
13599 struct cmd_ptype_mapping_replace_result {
13600 cmdline_fixed_string_t ptype;
13601 cmdline_fixed_string_t mapping;
13602 cmdline_fixed_string_t replace;
13609 /* Common CLI fields for ptype mapping replace */
13610 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13611 TOKEN_STRING_INITIALIZER
13612 (struct cmd_ptype_mapping_replace_result,
13614 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13615 TOKEN_STRING_INITIALIZER
13616 (struct cmd_ptype_mapping_replace_result,
13617 mapping, "mapping");
13618 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13619 TOKEN_STRING_INITIALIZER
13620 (struct cmd_ptype_mapping_replace_result,
13621 replace, "replace");
13622 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13623 TOKEN_NUM_INITIALIZER
13624 (struct cmd_ptype_mapping_replace_result,
13626 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13627 TOKEN_NUM_INITIALIZER
13628 (struct cmd_ptype_mapping_replace_result,
13630 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13631 TOKEN_NUM_INITIALIZER
13632 (struct cmd_ptype_mapping_replace_result,
13634 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13635 TOKEN_NUM_INITIALIZER
13636 (struct cmd_ptype_mapping_replace_result,
13640 cmd_ptype_mapping_replace_parsed(
13641 void *parsed_result,
13642 __attribute__((unused)) struct cmdline *cl,
13643 __attribute__((unused)) void *data)
13645 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13646 int ret = -ENOTSUP;
13648 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13651 #ifdef RTE_LIBRTE_I40E_PMD
13652 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13662 printf("invalid ptype 0x%8x or 0x%8x\n",
13663 res->target, res->pkt_type);
13666 printf("invalid port_id %d\n", res->port_id);
13669 printf("function not implemented\n");
13672 printf("programming error: (%s)\n", strerror(-ret));
13676 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13677 .f = cmd_ptype_mapping_replace_parsed,
13680 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13682 (void *)&cmd_ptype_mapping_replace_ptype,
13683 (void *)&cmd_ptype_mapping_replace_mapping,
13684 (void *)&cmd_ptype_mapping_replace_replace,
13685 (void *)&cmd_ptype_mapping_replace_port_id,
13686 (void *)&cmd_ptype_mapping_replace_target,
13687 (void *)&cmd_ptype_mapping_replace_mask,
13688 (void *)&cmd_ptype_mapping_replace_pkt_type,
13693 /* ptype mapping reset */
13695 /* Common result structure for ptype mapping reset */
13696 struct cmd_ptype_mapping_reset_result {
13697 cmdline_fixed_string_t ptype;
13698 cmdline_fixed_string_t mapping;
13699 cmdline_fixed_string_t reset;
13703 /* Common CLI fields for ptype mapping reset*/
13704 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
13705 TOKEN_STRING_INITIALIZER
13706 (struct cmd_ptype_mapping_reset_result,
13708 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
13709 TOKEN_STRING_INITIALIZER
13710 (struct cmd_ptype_mapping_reset_result,
13711 mapping, "mapping");
13712 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
13713 TOKEN_STRING_INITIALIZER
13714 (struct cmd_ptype_mapping_reset_result,
13716 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
13717 TOKEN_NUM_INITIALIZER
13718 (struct cmd_ptype_mapping_reset_result,
13722 cmd_ptype_mapping_reset_parsed(
13723 void *parsed_result,
13724 __attribute__((unused)) struct cmdline *cl,
13725 __attribute__((unused)) void *data)
13727 struct cmd_ptype_mapping_reset_result *res = parsed_result;
13728 int ret = -ENOTSUP;
13730 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13733 #ifdef RTE_LIBRTE_I40E_PMD
13734 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
13741 printf("invalid port_id %d\n", res->port_id);
13744 printf("function not implemented\n");
13747 printf("programming error: (%s)\n", strerror(-ret));
13751 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
13752 .f = cmd_ptype_mapping_reset_parsed,
13754 .help_str = "ptype mapping reset <port_id>",
13756 (void *)&cmd_ptype_mapping_reset_ptype,
13757 (void *)&cmd_ptype_mapping_reset_mapping,
13758 (void *)&cmd_ptype_mapping_reset_reset,
13759 (void *)&cmd_ptype_mapping_reset_port_id,
13764 /* ptype mapping update */
13766 /* Common result structure for ptype mapping update */
13767 struct cmd_ptype_mapping_update_result {
13768 cmdline_fixed_string_t ptype;
13769 cmdline_fixed_string_t mapping;
13770 cmdline_fixed_string_t reset;
13776 /* Common CLI fields for ptype mapping update*/
13777 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
13778 TOKEN_STRING_INITIALIZER
13779 (struct cmd_ptype_mapping_update_result,
13781 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
13782 TOKEN_STRING_INITIALIZER
13783 (struct cmd_ptype_mapping_update_result,
13784 mapping, "mapping");
13785 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
13786 TOKEN_STRING_INITIALIZER
13787 (struct cmd_ptype_mapping_update_result,
13789 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
13790 TOKEN_NUM_INITIALIZER
13791 (struct cmd_ptype_mapping_update_result,
13793 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
13794 TOKEN_NUM_INITIALIZER
13795 (struct cmd_ptype_mapping_update_result,
13797 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
13798 TOKEN_NUM_INITIALIZER
13799 (struct cmd_ptype_mapping_update_result,
13803 cmd_ptype_mapping_update_parsed(
13804 void *parsed_result,
13805 __attribute__((unused)) struct cmdline *cl,
13806 __attribute__((unused)) void *data)
13808 struct cmd_ptype_mapping_update_result *res = parsed_result;
13809 int ret = -ENOTSUP;
13810 #ifdef RTE_LIBRTE_I40E_PMD
13811 struct rte_pmd_i40e_ptype_mapping mapping;
13813 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13816 #ifdef RTE_LIBRTE_I40E_PMD
13817 mapping.hw_ptype = res->hw_ptype;
13818 mapping.sw_ptype = res->sw_ptype;
13819 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
13829 printf("invalid ptype 0x%8x\n", res->sw_ptype);
13832 printf("invalid port_id %d\n", res->port_id);
13835 printf("function not implemented\n");
13838 printf("programming error: (%s)\n", strerror(-ret));
13842 cmdline_parse_inst_t cmd_ptype_mapping_update = {
13843 .f = cmd_ptype_mapping_update_parsed,
13845 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
13847 (void *)&cmd_ptype_mapping_update_ptype,
13848 (void *)&cmd_ptype_mapping_update_mapping,
13849 (void *)&cmd_ptype_mapping_update_update,
13850 (void *)&cmd_ptype_mapping_update_port_id,
13851 (void *)&cmd_ptype_mapping_update_hw_ptype,
13852 (void *)&cmd_ptype_mapping_update_sw_ptype,
13857 /* Common result structure for file commands */
13858 struct cmd_cmdfile_result {
13859 cmdline_fixed_string_t load;
13860 cmdline_fixed_string_t filename;
13863 /* Common CLI fields for file commands */
13864 cmdline_parse_token_string_t cmd_load_cmdfile =
13865 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
13866 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
13867 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
13870 cmd_load_from_file_parsed(
13871 void *parsed_result,
13872 __attribute__((unused)) struct cmdline *cl,
13873 __attribute__((unused)) void *data)
13875 struct cmd_cmdfile_result *res = parsed_result;
13877 cmdline_read_from_file(res->filename);
13880 cmdline_parse_inst_t cmd_load_from_file = {
13881 .f = cmd_load_from_file_parsed,
13883 .help_str = "load <filename>",
13885 (void *)&cmd_load_cmdfile,
13886 (void *)&cmd_load_cmdfile_filename,
13891 /* ******************************************************************************** */
13893 /* list of instructions */
13894 cmdline_parse_ctx_t main_ctx[] = {
13895 (cmdline_parse_inst_t *)&cmd_help_brief,
13896 (cmdline_parse_inst_t *)&cmd_help_long,
13897 (cmdline_parse_inst_t *)&cmd_quit,
13898 (cmdline_parse_inst_t *)&cmd_load_from_file,
13899 (cmdline_parse_inst_t *)&cmd_showport,
13900 (cmdline_parse_inst_t *)&cmd_showqueue,
13901 (cmdline_parse_inst_t *)&cmd_showportall,
13902 (cmdline_parse_inst_t *)&cmd_showcfg,
13903 (cmdline_parse_inst_t *)&cmd_start,
13904 (cmdline_parse_inst_t *)&cmd_start_tx_first,
13905 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13906 (cmdline_parse_inst_t *)&cmd_set_link_up,
13907 (cmdline_parse_inst_t *)&cmd_set_link_down,
13908 (cmdline_parse_inst_t *)&cmd_reset,
13909 (cmdline_parse_inst_t *)&cmd_set_numbers,
13910 (cmdline_parse_inst_t *)&cmd_set_txpkts,
13911 (cmdline_parse_inst_t *)&cmd_set_txsplit,
13912 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13913 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13914 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13915 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13916 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13917 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13918 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13919 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13920 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13921 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13922 (cmdline_parse_inst_t *)&cmd_set_link_check,
13923 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13924 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13925 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13926 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13927 #ifdef RTE_LIBRTE_PMD_BOND
13928 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13929 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13930 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13931 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13932 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13933 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13934 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13935 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13936 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13938 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13939 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13940 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13941 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13942 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13943 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13944 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13945 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13946 (cmdline_parse_inst_t *)&cmd_csum_set,
13947 (cmdline_parse_inst_t *)&cmd_csum_show,
13948 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13949 (cmdline_parse_inst_t *)&cmd_tso_set,
13950 (cmdline_parse_inst_t *)&cmd_tso_show,
13951 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13952 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13953 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13954 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13955 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13956 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13957 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13958 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13959 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13960 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13961 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13962 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13963 (cmdline_parse_inst_t *)&cmd_config_dcb,
13964 (cmdline_parse_inst_t *)&cmd_read_reg,
13965 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13966 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13967 (cmdline_parse_inst_t *)&cmd_write_reg,
13968 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13969 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13970 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13971 (cmdline_parse_inst_t *)&cmd_stop,
13972 (cmdline_parse_inst_t *)&cmd_mac_addr,
13973 (cmdline_parse_inst_t *)&cmd_set_qmap,
13974 (cmdline_parse_inst_t *)&cmd_operate_port,
13975 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13976 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13977 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13978 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13979 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13980 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13981 (cmdline_parse_inst_t *)&cmd_config_mtu,
13982 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13983 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13984 (cmdline_parse_inst_t *)&cmd_config_rss,
13985 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13986 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13987 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13988 (cmdline_parse_inst_t *)&cmd_showport_reta,
13989 (cmdline_parse_inst_t *)&cmd_config_burst,
13990 (cmdline_parse_inst_t *)&cmd_config_thresh,
13991 (cmdline_parse_inst_t *)&cmd_config_threshold,
13992 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13993 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13994 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13995 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13996 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13997 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13998 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13999 (cmdline_parse_inst_t *)&cmd_global_config,
14000 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
14001 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
14002 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
14003 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
14004 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
14005 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
14006 (cmdline_parse_inst_t *)&cmd_dump,
14007 (cmdline_parse_inst_t *)&cmd_dump_one,
14008 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
14009 (cmdline_parse_inst_t *)&cmd_syn_filter,
14010 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
14011 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
14012 (cmdline_parse_inst_t *)&cmd_flex_filter,
14013 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
14014 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
14015 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
14016 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
14017 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
14018 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
14019 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
14020 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
14021 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
14022 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
14023 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
14024 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
14025 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
14026 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
14027 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
14028 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
14029 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
14030 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
14031 (cmdline_parse_inst_t *)&cmd_flow,
14032 (cmdline_parse_inst_t *)&cmd_mcast_addr,
14033 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
14034 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
14035 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
14036 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
14037 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
14038 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
14039 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
14040 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
14041 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
14042 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
14043 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
14044 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
14045 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
14046 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
14047 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
14048 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
14049 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
14050 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
14051 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
14052 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
14053 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
14054 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
14055 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
14056 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
14057 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
14058 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
14059 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
14060 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
14061 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
14062 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
14063 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
14064 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
14065 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
14066 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
14067 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
14068 (cmdline_parse_inst_t *)&cmd_ddp_add,
14069 (cmdline_parse_inst_t *)&cmd_ddp_del,
14070 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
14071 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
14072 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
14073 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
14074 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
14075 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
14076 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
14077 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
14081 /* read cmdline commands from file */
14083 cmdline_read_from_file(const char *filename)
14085 struct cmdline *cl;
14087 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14089 printf("Failed to create file based cmdline context: %s\n",
14094 cmdline_interact(cl);
14099 printf("Read CLI commands from %s\n", filename);
14102 /* prompt function, called from main on MASTER lcore */
14106 /* initialize non-constant commands */
14107 cmd_set_fwd_mode_init();
14108 cmd_set_fwd_retry_mode_init();
14110 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14111 if (testpmd_cl == NULL)
14113 cmdline_interact(testpmd_cl);
14114 cmdline_stdin_exit(testpmd_cl);
14120 if (testpmd_cl != NULL)
14121 cmdline_quit(testpmd_cl);
14125 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14127 if (id == (portid_t)RTE_PORT_ALL) {
14130 RTE_ETH_FOREACH_DEV(pid) {
14131 /* check if need_reconfig has been set to 1 */
14132 if (ports[pid].need_reconfig == 0)
14133 ports[pid].need_reconfig = dev;
14134 /* check if need_reconfig_queues has been set to 1 */
14135 if (ports[pid].need_reconfig_queues == 0)
14136 ports[pid].need_reconfig_queues = queue;
14138 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14139 /* check if need_reconfig has been set to 1 */
14140 if (ports[id].need_reconfig == 0)
14141 ports[id].need_reconfig = dev;
14142 /* check if need_reconfig_queues has been set to 1 */
14143 if (ports[id].need_reconfig_queues == 0)
14144 ports[id].need_reconfig_queues = queue;