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 "show vf stats (port_id) (vf_id)\n"
225 " Display a VF's statistics.\n\n"
227 "clear vf stats (port_id) (vf_id)\n"
228 " Reset a VF's statistics.\n\n"
232 if (show_all || !strcmp(res->section, "config")) {
238 "Configuration changes only become active when"
239 " forwarding is started/restarted.\n\n"
242 " Reset forwarding to the default configuration.\n\n"
244 "set verbose (level)\n"
245 " Set the debug verbosity level X.\n\n"
248 " Set number of ports.\n\n"
251 " Set number of cores.\n\n"
253 "set coremask (mask)\n"
254 " Set the forwarding cores hexadecimal mask.\n\n"
256 "set portmask (mask)\n"
257 " Set the forwarding ports hexadecimal mask.\n\n"
260 " Set number of packets per burst.\n\n"
262 "set burst tx delay (microseconds) retry (num)\n"
263 " Set the transmit delay time and number of retries,"
264 " effective when retry is enabled.\n\n"
266 "set txpkts (x[,y]*)\n"
267 " Set the length of each segment of TXONLY"
268 " and optionally CSUM packets.\n\n"
270 "set txsplit (off|on|rand)\n"
271 " Set the split policy for the TX packets."
272 " Right now only applicable for CSUM and TXONLY"
275 "set corelist (x[,y]*)\n"
276 " Set the list of forwarding cores.\n\n"
278 "set portlist (x[,y]*)\n"
279 " Set the list of forwarding ports.\n\n"
281 "set tx loopback (port_id) (on|off)\n"
282 " Enable or disable tx loopback.\n\n"
284 "set all queues drop (port_id) (on|off)\n"
285 " Set drop enable bit for all queues.\n\n"
287 "set vf split drop (port_id) (vf_id) (on|off)\n"
288 " Set split drop enable bit for a VF from the PF.\n\n"
290 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
291 " Set MAC antispoof for a VF from the PF.\n\n"
293 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
294 " Enable MACsec offload.\n\n"
296 "set macsec offload (port_id) off\n"
297 " Disable MACsec offload.\n\n"
299 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
300 " Configure MACsec secure connection (SC).\n\n"
302 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
303 " Configure MACsec secure association (SA).\n\n"
305 "set vf broadcast (port_id) (vf_id) (on|off)\n"
306 " Set VF broadcast for a VF from the PF.\n\n"
308 "vlan set strip (on|off) (port_id)\n"
309 " Set the VLAN strip on a port.\n\n"
311 "vlan set stripq (on|off) (port_id,queue_id)\n"
312 " Set the VLAN strip for a queue on a port.\n\n"
314 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
315 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
317 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
318 " Set VLAN insert for a VF from the PF.\n\n"
320 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
321 " Set VLAN antispoof for a VF from the PF.\n\n"
323 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
324 " Set VLAN tag for a VF from the PF.\n\n"
326 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
327 " Set a VF's max bandwidth(Mbps).\n\n"
329 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
330 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
332 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
333 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
335 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
336 " Set some TCs' strict link priority mode on a physical port.\n\n"
338 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
339 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
341 "vlan set filter (on|off) (port_id)\n"
342 " Set the VLAN filter on a port.\n\n"
344 "vlan set qinq (on|off) (port_id)\n"
345 " Set the VLAN QinQ (extended queue in queue)"
348 "vlan set (inner|outer) tpid (value) (port_id)\n"
349 " Set the VLAN TPID for Packet Filtering on"
352 "rx_vlan add (vlan_id|all) (port_id)\n"
353 " Add a vlan_id, or all identifiers, to the set"
354 " of VLAN identifiers filtered by port_id.\n\n"
356 "rx_vlan rm (vlan_id|all) (port_id)\n"
357 " Remove a vlan_id, or all identifiers, from the set"
358 " of VLAN identifiers filtered by port_id.\n\n"
360 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
361 " Add a vlan_id, to the set of VLAN identifiers"
362 "filtered for VF(s) from port_id.\n\n"
364 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
365 " Remove a vlan_id, to the set of VLAN identifiers"
366 "filtered for VF(s) from port_id.\n\n"
368 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
369 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
370 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
371 " add a tunnel filter of a port.\n\n"
373 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
374 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
375 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
376 " remove a tunnel filter of a port.\n\n"
378 "rx_vxlan_port add (udp_port) (port_id)\n"
379 " Add an UDP port for VXLAN packet filter on a port\n\n"
381 "rx_vxlan_port rm (udp_port) (port_id)\n"
382 " Remove an UDP port for VXLAN packet filter on a port\n\n"
384 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
385 " Set hardware insertion of VLAN IDs (single or double VLAN "
386 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
388 "tx_vlan set pvid port_id vlan_id (on|off)\n"
389 " Set port based TX VLAN insertion.\n\n"
391 "tx_vlan reset (port_id)\n"
392 " Disable hardware insertion of a VLAN header in"
393 " packets sent on a port.\n\n"
395 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
396 " Select hardware or software calculation of the"
397 " checksum when transmitting a packet using the"
398 " csum forward engine.\n"
399 " ip|udp|tcp|sctp always concern the inner layer.\n"
400 " outer-ip concerns the outer IP layer in"
401 " case the packet is recognized as a tunnel packet by"
402 " the forward engine (vxlan, gre and ipip are supported)\n"
403 " Please check the NIC datasheet for HW limits.\n\n"
405 "csum parse-tunnel (on|off) (tx_port_id)\n"
406 " If disabled, treat tunnel packets as non-tunneled"
407 " packets (treat inner headers as payload). The port\n"
408 " argument is the port used for TX in csum forward"
411 "csum show (port_id)\n"
412 " Display tx checksum offload configuration\n\n"
414 "tso set (segsize) (portid)\n"
415 " Enable TCP Segmentation Offload in csum forward"
417 " Please check the NIC datasheet for HW limits.\n\n"
420 " Display the status of TCP Segmentation Offload.\n\n"
423 " Set packet forwarding mode.\n\n"
425 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
426 " Add a MAC address on port_id.\n\n"
428 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
429 " Remove a MAC address from port_id.\n\n"
431 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
432 " Set the default MAC address for port_id.\n\n"
434 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
435 " Add a MAC address for a VF on the port.\n\n"
437 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
438 " Set the MAC address for a VF from the PF.\n\n"
440 "set port (port_id) uta (mac_address|all) (on|off)\n"
441 " Add/Remove a or all unicast hash filter(s)"
444 "set promisc (port_id|all) (on|off)\n"
445 " Set the promiscuous mode on port_id, or all.\n\n"
447 "set allmulti (port_id|all) (on|off)\n"
448 " Set the allmulti mode on port_id, or all.\n\n"
450 "set vf promisc (port_id) (vf_id) (on|off)\n"
451 " Set unicast promiscuous mode for a VF from the PF.\n\n"
453 "set vf allmulti (port_id) (vf_id) (on|off)\n"
454 " Set multicast promiscuous mode for a VF from the PF.\n\n"
456 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
457 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
458 " (on|off) autoneg (on|off) (port_id)\n"
459 "set flow_ctrl rx (on|off) (portid)\n"
460 "set flow_ctrl tx (on|off) (portid)\n"
461 "set flow_ctrl high_water (high_water) (portid)\n"
462 "set flow_ctrl low_water (low_water) (portid)\n"
463 "set flow_ctrl pause_time (pause_time) (portid)\n"
464 "set flow_ctrl send_xon (send_xon) (portid)\n"
465 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
466 "set flow_ctrl autoneg (on|off) (port_id)\n"
467 " Set the link flow control parameter on a port.\n\n"
469 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
470 " (low_water) (pause_time) (priority) (port_id)\n"
471 " Set the priority flow control parameter on a"
474 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
475 " Set statistics mapping (qmapping 0..15) for RX/TX"
477 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
478 " on port 0 to mapping 5.\n\n"
480 "set port (port_id) vf (vf_id) rx|tx on|off\n"
481 " Enable/Disable a VF receive/tranmit from a port\n\n"
483 "set port (port_id) vf (vf_id) (mac_addr)"
484 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
485 " Add/Remove unicast or multicast MAC addr filter"
488 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
490 " AUPE:accepts untagged VLAN;"
491 "ROPE:accept unicast hash\n\n"
492 " BAM:accepts broadcast packets;"
493 "MPE:accepts all multicast packets\n\n"
494 " Enable/Disable a VF receive mode of a port\n\n"
496 "set port (port_id) queue (queue_id) rate (rate_num)\n"
497 " Set rate limit for a queue of a port\n\n"
499 "set port (port_id) vf (vf_id) rate (rate_num) "
500 "queue_mask (queue_mask_value)\n"
501 " Set rate limit for queues in VF of a port\n\n"
503 "set port (port_id) mirror-rule (rule_id)"
504 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
505 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
506 " Set pool or vlan type mirror rule on a port.\n"
507 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
508 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
511 "set port (port_id) mirror-rule (rule_id)"
512 " (uplink-mirror|downlink-mirror) dst-pool"
513 " (pool_id) (on|off)\n"
514 " Set uplink or downlink type mirror rule on a port.\n"
515 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
516 " 0 on' enable mirror income traffic to pool 0.\n\n"
518 "reset port (port_id) mirror-rule (rule_id)\n"
519 " Reset a mirror rule.\n\n"
521 "set flush_rx (on|off)\n"
522 " Flush (default) or don't flush RX streams before"
523 " forwarding. Mainly used with PCAP drivers.\n\n"
525 "set bypass mode (normal|bypass|isolate) (port_id)\n"
526 " Set the bypass mode for the lowest port on bypass enabled"
529 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
530 "mode (normal|bypass|isolate) (port_id)\n"
531 " Set the event required to initiate specified bypass mode for"
532 " the lowest port on a bypass enabled NIC where:\n"
533 " timeout = enable bypass after watchdog timeout.\n"
534 " os_on = enable bypass when OS/board is powered on.\n"
535 " os_off = enable bypass when OS/board is powered off.\n"
536 " power_on = enable bypass when power supply is turned on.\n"
537 " power_off = enable bypass when power supply is turned off."
540 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
541 " Set the bypass watchdog timeout to 'n' seconds"
542 " where 0 = instant.\n\n"
544 "show bypass config (port_id)\n"
545 " Show the bypass configuration for a bypass enabled NIC"
546 " using the lowest port on the NIC.\n\n"
548 #ifdef RTE_LIBRTE_PMD_BOND
549 "create bonded device (mode) (socket)\n"
550 " Create a new bonded device with specific bonding mode and socket.\n\n"
552 "add bonding slave (slave_id) (port_id)\n"
553 " Add a slave device to a bonded device.\n\n"
555 "remove bonding slave (slave_id) (port_id)\n"
556 " Remove a slave device from a bonded device.\n\n"
558 "set bonding mode (value) (port_id)\n"
559 " Set the bonding mode on a bonded device.\n\n"
561 "set bonding primary (slave_id) (port_id)\n"
562 " Set the primary slave for a bonded device.\n\n"
564 "show bonding config (port_id)\n"
565 " Show the bonding config for port_id.\n\n"
567 "set bonding mac_addr (port_id) (address)\n"
568 " Set the MAC address of a bonded device.\n\n"
570 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
571 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
573 "set bonding mon_period (port_id) (value)\n"
574 " Set the bonding link status monitoring polling period in ms.\n\n"
576 "set link-up port (port_id)\n"
577 " Set link up for a port.\n\n"
579 "set link-down port (port_id)\n"
580 " Set link down for a port.\n\n"
582 "E-tag set insertion on port-tag-id (value)"
583 " port (port_id) vf (vf_id)\n"
584 " Enable E-tag insertion for a VF on a port\n\n"
586 "E-tag set insertion off port (port_id) vf (vf_id)\n"
587 " Disable E-tag insertion for a VF on a port\n\n"
589 "E-tag set stripping (on|off) port (port_id)\n"
590 " Enable/disable E-tag stripping on a port\n\n"
592 "E-tag set forwarding (on|off) port (port_id)\n"
593 " Enable/disable E-tag based forwarding"
596 "E-tag set filter add e-tag-id (value) dst-pool"
597 " (pool_id) port (port_id)\n"
598 " Add an E-tag forwarding filter on a port\n\n"
600 "E-tag set filter del e-tag-id (value) port (port_id)\n"
601 " Delete an E-tag forwarding filter on a port\n\n"
603 "ddp add (port_id) (profile_path)\n"
604 " Load a profile package on a port\n\n"
606 "ptype mapping get (port_id) (valid_only)\n"
607 " Get ptype mapping on a port\n\n"
609 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
610 " Replace target with the pkt_type in ptype mapping\n\n"
612 "ptype mapping reset (port_id)\n"
613 " Reset ptype mapping on a port\n\n"
615 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
616 " Update a ptype mapping item on a port\n\n"
618 , list_pkt_forwarding_modes()
622 if (show_all || !strcmp(res->section, "ports")) {
628 "----------------\n\n"
630 "port start (port_id|all)\n"
631 " Start all ports or port_id.\n\n"
633 "port stop (port_id|all)\n"
634 " Stop all ports or port_id.\n\n"
636 "port close (port_id|all)\n"
637 " Close all ports or port_id.\n\n"
639 "port attach (ident)\n"
640 " Attach physical or virtual dev by pci address or virtual device name\n\n"
642 "port detach (port_id)\n"
643 " Detach physical or virtual dev by port_id\n\n"
645 "port config (port_id|all)"
646 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
647 " duplex (half|full|auto)\n"
648 " Set speed and duplex for all ports or port_id\n\n"
650 "port config all (rxq|txq|rxd|txd) (value)\n"
651 " Set number for rxq/txq/rxd/txd.\n\n"
653 "port config all max-pkt-len (value)\n"
654 " Set the max packet length.\n\n"
656 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
657 "hw-vlan-strip|hw-vlan-extend|drop-en)"
659 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
662 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
663 " Set the RSS mode.\n\n"
665 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
666 " Set the RSS redirection table.\n\n"
668 "port config (port_id) dcb vt (on|off) (traffic_class)"
670 " Set the DCB mode.\n\n"
672 "port config all burst (value)\n"
673 " Set the number of packets per burst.\n\n"
675 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
677 " Set the ring prefetch/host/writeback threshold"
678 " for tx/rx queue.\n\n"
680 "port config all (txfreet|txrst|rxfreet) (value)\n"
681 " Set free threshold for rx/tx, or set"
682 " tx rs bit threshold.\n\n"
683 "port config mtu X value\n"
684 " Set the MTU of port X to a given value\n\n"
686 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
687 " Start/stop a rx/tx queue of port X. Only take effect"
688 " when port X is started\n\n"
690 "port config (port_id|all) l2-tunnel E-tag ether-type"
692 " Set the value of E-tag ether-type.\n\n"
694 "port config (port_id|all) l2-tunnel E-tag"
695 " (enable|disable)\n"
696 " Enable/disable the E-tag support.\n\n"
700 if (show_all || !strcmp(res->section, "registers")) {
708 "read reg (port_id) (address)\n"
709 " Display value of a port register.\n\n"
711 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
712 " Display a port register bit field.\n\n"
714 "read regbit (port_id) (address) (bit_x)\n"
715 " Display a single port register bit.\n\n"
717 "write reg (port_id) (address) (value)\n"
718 " Set value of a port register.\n\n"
720 "write regfield (port_id) (address) (bit_x) (bit_y)"
722 " Set bit field of a port register.\n\n"
724 "write regbit (port_id) (address) (bit_x) (value)\n"
725 " Set single bit value of a port register.\n\n"
728 if (show_all || !strcmp(res->section, "filters")) {
736 "ethertype_filter (port_id) (add|del)"
737 " (mac_addr|mac_ignr) (mac_address) ethertype"
738 " (ether_type) (drop|fwd) queue (queue_id)\n"
739 " Add/Del an ethertype filter.\n\n"
741 "2tuple_filter (port_id) (add|del)"
742 " dst_port (dst_port_value) protocol (protocol_value)"
743 " mask (mask_value) tcp_flags (tcp_flags_value)"
744 " priority (prio_value) queue (queue_id)\n"
745 " Add/Del a 2tuple filter.\n\n"
747 "5tuple_filter (port_id) (add|del)"
748 " dst_ip (dst_address) src_ip (src_address)"
749 " dst_port (dst_port_value) src_port (src_port_value)"
750 " protocol (protocol_value)"
751 " mask (mask_value) tcp_flags (tcp_flags_value)"
752 " priority (prio_value) queue (queue_id)\n"
753 " Add/Del a 5tuple filter.\n\n"
755 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
756 " Add/Del syn filter.\n\n"
758 "flex_filter (port_id) (add|del) len (len_value)"
759 " bytes (bytes_value) mask (mask_value)"
760 " priority (prio_value) queue (queue_id)\n"
761 " Add/Del a flex filter.\n\n"
763 "flow_director_filter (port_id) mode IP (add|del|update)"
764 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
765 " src (src_ip_address) dst (dst_ip_address)"
766 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
767 " vlan (vlan_value) flexbytes (flexbytes_value)"
768 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
769 " fd_id (fd_id_value)\n"
770 " Add/Del an IP type flow director filter.\n\n"
772 "flow_director_filter (port_id) mode IP (add|del|update)"
773 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
774 " src (src_ip_address) (src_port)"
775 " dst (dst_ip_address) (dst_port)"
776 " tos (tos_value) ttl (ttl_value)"
777 " vlan (vlan_value) flexbytes (flexbytes_value)"
778 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
779 " fd_id (fd_id_value)\n"
780 " Add/Del an UDP/TCP type flow director filter.\n\n"
782 "flow_director_filter (port_id) mode IP (add|del|update)"
783 " flow (ipv4-sctp|ipv6-sctp)"
784 " src (src_ip_address) (src_port)"
785 " dst (dst_ip_address) (dst_port)"
786 " tag (verification_tag) "
787 " tos (tos_value) ttl (ttl_value)"
789 " flexbytes (flexbytes_value) (drop|fwd)"
790 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
791 " Add/Del a SCTP type flow director filter.\n\n"
793 "flow_director_filter (port_id) mode IP (add|del|update)"
794 " flow l2_payload ether (ethertype)"
795 " flexbytes (flexbytes_value) (drop|fwd)"
796 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
797 " Add/Del a l2 payload type flow director filter.\n\n"
799 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
800 " mac (mac_address) vlan (vlan_value)"
801 " flexbytes (flexbytes_value) (drop|fwd)"
802 " queue (queue_id) fd_id (fd_id_value)\n"
803 " Add/Del a MAC-VLAN flow director filter.\n\n"
805 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
806 " mac (mac_address) vlan (vlan_value)"
807 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
808 " flexbytes (flexbytes_value) (drop|fwd)"
809 " queue (queue_id) fd_id (fd_id_value)\n"
810 " Add/Del a Tunnel flow director filter.\n\n"
812 "flush_flow_director (port_id)\n"
813 " Flush all flow director entries of a device.\n\n"
815 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
816 " src_mask (ipv4_src) (ipv6_src) (src_port)"
817 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
818 " Set flow director IP mask.\n\n"
820 "flow_director_mask (port_id) mode MAC-VLAN"
821 " vlan (vlan_value)\n"
822 " Set flow director MAC-VLAN mask.\n\n"
824 "flow_director_mask (port_id) mode Tunnel"
825 " vlan (vlan_value) mac (mac_value)"
826 " tunnel-type (tunnel_type_value)"
827 " tunnel-id (tunnel_id_value)\n"
828 " Set flow director Tunnel mask.\n\n"
830 "flow_director_flex_mask (port_id)"
831 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
832 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
834 " Configure mask of flex payload.\n\n"
836 "flow_director_flex_payload (port_id)"
837 " (raw|l2|l3|l4) (config)\n"
838 " Configure flex payload selection.\n\n"
840 "get_sym_hash_ena_per_port (port_id)\n"
841 " get symmetric hash enable configuration per port.\n\n"
843 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
844 " set symmetric hash enable configuration per port"
845 " to enable or disable.\n\n"
847 "get_hash_global_config (port_id)\n"
848 " Get the global configurations of hash filters.\n\n"
850 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
851 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
852 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
853 " (enable|disable)\n"
854 " Set the global configurations of hash filters.\n\n"
856 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
857 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
858 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
859 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
860 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
861 "ipv6-next-header|udp-src-port|udp-dst-port|"
862 "tcp-src-port|tcp-dst-port|sctp-src-port|"
863 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
864 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
865 "fld-8th|none) (select|add)\n"
866 " Set the input set for hash.\n\n"
868 "set_fdir_input_set (port_id) "
869 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
870 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
871 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
872 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
873 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
874 "udp-dst-port|tcp-src-port|tcp-dst-port|"
875 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
877 " Set the input set for FDir.\n\n"
879 "flow validate {port_id}"
880 " [group {group_id}] [priority {level}]"
881 " [ingress] [egress]"
882 " pattern {item} [/ {item} [...]] / end"
883 " actions {action} [/ {action} [...]] / end\n"
884 " Check whether a flow rule can be created.\n\n"
886 "flow create {port_id}"
887 " [group {group_id}] [priority {level}]"
888 " [ingress] [egress]"
889 " pattern {item} [/ {item} [...]] / end"
890 " actions {action} [/ {action} [...]] / end\n"
891 " Create a flow rule.\n\n"
893 "flow destroy {port_id} rule {rule_id} [...]\n"
894 " Destroy specific flow rules.\n\n"
896 "flow flush {port_id}\n"
897 " Destroy all flow rules.\n\n"
899 "flow query {port_id} {rule_id} {action}\n"
900 " Query an existing flow rule.\n\n"
902 "flow list {port_id} [group {group_id}] [...]\n"
903 " List existing flow rules sorted by priority,"
904 " filtered by group identifiers.\n\n"
906 "flow isolate {port_id} {boolean}\n"
907 " Restrict ingress traffic to the defined"
913 cmdline_parse_token_string_t cmd_help_long_help =
914 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
916 cmdline_parse_token_string_t cmd_help_long_section =
917 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
918 "all#control#display#config#"
919 "ports#registers#filters");
921 cmdline_parse_inst_t cmd_help_long = {
922 .f = cmd_help_long_parsed,
924 .help_str = "help all|control|display|config|ports|register|filters: "
927 (void *)&cmd_help_long_help,
928 (void *)&cmd_help_long_section,
934 /* *** start/stop/close all ports *** */
935 struct cmd_operate_port_result {
936 cmdline_fixed_string_t keyword;
937 cmdline_fixed_string_t name;
938 cmdline_fixed_string_t value;
941 static void cmd_operate_port_parsed(void *parsed_result,
942 __attribute__((unused)) struct cmdline *cl,
943 __attribute__((unused)) void *data)
945 struct cmd_operate_port_result *res = parsed_result;
947 if (!strcmp(res->name, "start"))
948 start_port(RTE_PORT_ALL);
949 else if (!strcmp(res->name, "stop"))
950 stop_port(RTE_PORT_ALL);
951 else if (!strcmp(res->name, "close"))
952 close_port(RTE_PORT_ALL);
954 printf("Unknown parameter\n");
957 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
958 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
960 cmdline_parse_token_string_t cmd_operate_port_all_port =
961 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
963 cmdline_parse_token_string_t cmd_operate_port_all_all =
964 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
966 cmdline_parse_inst_t cmd_operate_port = {
967 .f = cmd_operate_port_parsed,
969 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
971 (void *)&cmd_operate_port_all_cmd,
972 (void *)&cmd_operate_port_all_port,
973 (void *)&cmd_operate_port_all_all,
978 /* *** start/stop/close specific port *** */
979 struct cmd_operate_specific_port_result {
980 cmdline_fixed_string_t keyword;
981 cmdline_fixed_string_t name;
985 static void cmd_operate_specific_port_parsed(void *parsed_result,
986 __attribute__((unused)) struct cmdline *cl,
987 __attribute__((unused)) void *data)
989 struct cmd_operate_specific_port_result *res = parsed_result;
991 if (!strcmp(res->name, "start"))
992 start_port(res->value);
993 else if (!strcmp(res->name, "stop"))
994 stop_port(res->value);
995 else if (!strcmp(res->name, "close"))
996 close_port(res->value);
998 printf("Unknown parameter\n");
1001 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1002 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1004 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1005 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1006 name, "start#stop#close");
1007 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1008 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1011 cmdline_parse_inst_t cmd_operate_specific_port = {
1012 .f = cmd_operate_specific_port_parsed,
1014 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1016 (void *)&cmd_operate_specific_port_cmd,
1017 (void *)&cmd_operate_specific_port_port,
1018 (void *)&cmd_operate_specific_port_id,
1023 /* *** attach a specified port *** */
1024 struct cmd_operate_attach_port_result {
1025 cmdline_fixed_string_t port;
1026 cmdline_fixed_string_t keyword;
1027 cmdline_fixed_string_t identifier;
1030 static void cmd_operate_attach_port_parsed(void *parsed_result,
1031 __attribute__((unused)) struct cmdline *cl,
1032 __attribute__((unused)) void *data)
1034 struct cmd_operate_attach_port_result *res = parsed_result;
1036 if (!strcmp(res->keyword, "attach"))
1037 attach_port(res->identifier);
1039 printf("Unknown parameter\n");
1042 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1043 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1045 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1046 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1048 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1049 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1052 cmdline_parse_inst_t cmd_operate_attach_port = {
1053 .f = cmd_operate_attach_port_parsed,
1055 .help_str = "port attach <identifier>: "
1056 "(identifier: pci address or virtual dev name)",
1058 (void *)&cmd_operate_attach_port_port,
1059 (void *)&cmd_operate_attach_port_keyword,
1060 (void *)&cmd_operate_attach_port_identifier,
1065 /* *** detach a specified port *** */
1066 struct cmd_operate_detach_port_result {
1067 cmdline_fixed_string_t port;
1068 cmdline_fixed_string_t keyword;
1072 static void cmd_operate_detach_port_parsed(void *parsed_result,
1073 __attribute__((unused)) struct cmdline *cl,
1074 __attribute__((unused)) void *data)
1076 struct cmd_operate_detach_port_result *res = parsed_result;
1078 if (!strcmp(res->keyword, "detach"))
1079 detach_port(res->port_id);
1081 printf("Unknown parameter\n");
1084 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1085 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1087 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1088 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1090 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1091 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1094 cmdline_parse_inst_t cmd_operate_detach_port = {
1095 .f = cmd_operate_detach_port_parsed,
1097 .help_str = "port detach <port_id>",
1099 (void *)&cmd_operate_detach_port_port,
1100 (void *)&cmd_operate_detach_port_keyword,
1101 (void *)&cmd_operate_detach_port_port_id,
1106 /* *** configure speed for all ports *** */
1107 struct cmd_config_speed_all {
1108 cmdline_fixed_string_t port;
1109 cmdline_fixed_string_t keyword;
1110 cmdline_fixed_string_t all;
1111 cmdline_fixed_string_t item1;
1112 cmdline_fixed_string_t item2;
1113 cmdline_fixed_string_t value1;
1114 cmdline_fixed_string_t value2;
1118 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1123 if (!strcmp(duplexstr, "half")) {
1124 duplex = ETH_LINK_HALF_DUPLEX;
1125 } else if (!strcmp(duplexstr, "full")) {
1126 duplex = ETH_LINK_FULL_DUPLEX;
1127 } else if (!strcmp(duplexstr, "auto")) {
1128 duplex = ETH_LINK_FULL_DUPLEX;
1130 printf("Unknown duplex parameter\n");
1134 if (!strcmp(speedstr, "10")) {
1135 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1136 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1137 } else if (!strcmp(speedstr, "100")) {
1138 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1139 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1141 if (duplex != ETH_LINK_FULL_DUPLEX) {
1142 printf("Invalid speed/duplex parameters\n");
1145 if (!strcmp(speedstr, "1000")) {
1146 *speed = ETH_LINK_SPEED_1G;
1147 } else if (!strcmp(speedstr, "10000")) {
1148 *speed = ETH_LINK_SPEED_10G;
1149 } else if (!strcmp(speedstr, "25000")) {
1150 *speed = ETH_LINK_SPEED_25G;
1151 } else if (!strcmp(speedstr, "40000")) {
1152 *speed = ETH_LINK_SPEED_40G;
1153 } else if (!strcmp(speedstr, "50000")) {
1154 *speed = ETH_LINK_SPEED_50G;
1155 } else if (!strcmp(speedstr, "100000")) {
1156 *speed = ETH_LINK_SPEED_100G;
1157 } else if (!strcmp(speedstr, "auto")) {
1158 *speed = ETH_LINK_SPEED_AUTONEG;
1160 printf("Unknown speed parameter\n");
1169 cmd_config_speed_all_parsed(void *parsed_result,
1170 __attribute__((unused)) struct cmdline *cl,
1171 __attribute__((unused)) void *data)
1173 struct cmd_config_speed_all *res = parsed_result;
1174 uint32_t link_speed;
1177 if (!all_ports_stopped()) {
1178 printf("Please stop all ports first\n");
1182 if (parse_and_check_speed_duplex(res->value1, res->value2,
1186 RTE_ETH_FOREACH_DEV(pid) {
1187 ports[pid].dev_conf.link_speeds = link_speed;
1190 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1193 cmdline_parse_token_string_t cmd_config_speed_all_port =
1194 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1195 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1196 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1198 cmdline_parse_token_string_t cmd_config_speed_all_all =
1199 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1200 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1201 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1202 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1203 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1204 "10#100#1000#10000#25000#40000#50000#100000#auto");
1205 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1206 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1207 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1208 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1211 cmdline_parse_inst_t cmd_config_speed_all = {
1212 .f = cmd_config_speed_all_parsed,
1214 .help_str = "port config all speed "
1215 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1218 (void *)&cmd_config_speed_all_port,
1219 (void *)&cmd_config_speed_all_keyword,
1220 (void *)&cmd_config_speed_all_all,
1221 (void *)&cmd_config_speed_all_item1,
1222 (void *)&cmd_config_speed_all_value1,
1223 (void *)&cmd_config_speed_all_item2,
1224 (void *)&cmd_config_speed_all_value2,
1229 /* *** configure speed for specific port *** */
1230 struct cmd_config_speed_specific {
1231 cmdline_fixed_string_t port;
1232 cmdline_fixed_string_t keyword;
1234 cmdline_fixed_string_t item1;
1235 cmdline_fixed_string_t item2;
1236 cmdline_fixed_string_t value1;
1237 cmdline_fixed_string_t value2;
1241 cmd_config_speed_specific_parsed(void *parsed_result,
1242 __attribute__((unused)) struct cmdline *cl,
1243 __attribute__((unused)) void *data)
1245 struct cmd_config_speed_specific *res = parsed_result;
1246 uint32_t link_speed;
1248 if (!all_ports_stopped()) {
1249 printf("Please stop all ports first\n");
1253 if (port_id_is_invalid(res->id, ENABLED_WARN))
1256 if (parse_and_check_speed_duplex(res->value1, res->value2,
1260 ports[res->id].dev_conf.link_speeds = link_speed;
1262 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1266 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1267 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1269 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1270 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1272 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1273 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1274 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1275 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1277 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1278 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1279 "10#100#1000#10000#25000#40000#50000#100000#auto");
1280 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1283 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1284 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1287 cmdline_parse_inst_t cmd_config_speed_specific = {
1288 .f = cmd_config_speed_specific_parsed,
1290 .help_str = "port config <port_id> speed "
1291 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1294 (void *)&cmd_config_speed_specific_port,
1295 (void *)&cmd_config_speed_specific_keyword,
1296 (void *)&cmd_config_speed_specific_id,
1297 (void *)&cmd_config_speed_specific_item1,
1298 (void *)&cmd_config_speed_specific_value1,
1299 (void *)&cmd_config_speed_specific_item2,
1300 (void *)&cmd_config_speed_specific_value2,
1305 /* *** configure txq/rxq, txd/rxd *** */
1306 struct cmd_config_rx_tx {
1307 cmdline_fixed_string_t port;
1308 cmdline_fixed_string_t keyword;
1309 cmdline_fixed_string_t all;
1310 cmdline_fixed_string_t name;
1315 cmd_config_rx_tx_parsed(void *parsed_result,
1316 __attribute__((unused)) struct cmdline *cl,
1317 __attribute__((unused)) void *data)
1319 struct cmd_config_rx_tx *res = parsed_result;
1321 if (!all_ports_stopped()) {
1322 printf("Please stop all ports first\n");
1325 if (!strcmp(res->name, "rxq")) {
1326 if (!res->value && !nb_txq) {
1327 printf("Warning: Either rx or tx queues should be non zero\n");
1330 nb_rxq = res->value;
1332 else if (!strcmp(res->name, "txq")) {
1333 if (!res->value && !nb_rxq) {
1334 printf("Warning: Either rx or tx queues should be non zero\n");
1337 nb_txq = res->value;
1339 else if (!strcmp(res->name, "rxd")) {
1340 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1341 printf("rxd %d invalid - must be > 0 && <= %d\n",
1342 res->value, RTE_TEST_RX_DESC_MAX);
1345 nb_rxd = res->value;
1346 } else if (!strcmp(res->name, "txd")) {
1347 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1348 printf("txd %d invalid - must be > 0 && <= %d\n",
1349 res->value, RTE_TEST_TX_DESC_MAX);
1352 nb_txd = res->value;
1354 printf("Unknown parameter\n");
1362 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1365 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1366 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1367 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1368 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1369 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1370 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1371 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1372 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1374 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1375 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1377 cmdline_parse_inst_t cmd_config_rx_tx = {
1378 .f = cmd_config_rx_tx_parsed,
1380 .help_str = "port config all rxq|txq|rxd|txd <value>",
1382 (void *)&cmd_config_rx_tx_port,
1383 (void *)&cmd_config_rx_tx_keyword,
1384 (void *)&cmd_config_rx_tx_all,
1385 (void *)&cmd_config_rx_tx_name,
1386 (void *)&cmd_config_rx_tx_value,
1391 /* *** config max packet length *** */
1392 struct cmd_config_max_pkt_len_result {
1393 cmdline_fixed_string_t port;
1394 cmdline_fixed_string_t keyword;
1395 cmdline_fixed_string_t all;
1396 cmdline_fixed_string_t name;
1401 cmd_config_max_pkt_len_parsed(void *parsed_result,
1402 __attribute__((unused)) struct cmdline *cl,
1403 __attribute__((unused)) void *data)
1405 struct cmd_config_max_pkt_len_result *res = parsed_result;
1407 if (!all_ports_stopped()) {
1408 printf("Please stop all ports first\n");
1412 if (!strcmp(res->name, "max-pkt-len")) {
1413 if (res->value < ETHER_MIN_LEN) {
1414 printf("max-pkt-len can not be less than %d\n",
1418 if (res->value == rx_mode.max_rx_pkt_len)
1421 rx_mode.max_rx_pkt_len = res->value;
1422 if (res->value > ETHER_MAX_LEN)
1423 rx_mode.jumbo_frame = 1;
1425 rx_mode.jumbo_frame = 0;
1427 printf("Unknown parameter\n");
1433 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1436 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1437 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1439 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1440 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1442 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1443 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1445 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1446 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1448 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1449 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1452 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1453 .f = cmd_config_max_pkt_len_parsed,
1455 .help_str = "port config all max-pkt-len <value>",
1457 (void *)&cmd_config_max_pkt_len_port,
1458 (void *)&cmd_config_max_pkt_len_keyword,
1459 (void *)&cmd_config_max_pkt_len_all,
1460 (void *)&cmd_config_max_pkt_len_name,
1461 (void *)&cmd_config_max_pkt_len_value,
1466 /* *** configure port MTU *** */
1467 struct cmd_config_mtu_result {
1468 cmdline_fixed_string_t port;
1469 cmdline_fixed_string_t keyword;
1470 cmdline_fixed_string_t mtu;
1476 cmd_config_mtu_parsed(void *parsed_result,
1477 __attribute__((unused)) struct cmdline *cl,
1478 __attribute__((unused)) void *data)
1480 struct cmd_config_mtu_result *res = parsed_result;
1482 if (res->value < ETHER_MIN_LEN) {
1483 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1486 port_mtu_set(res->port_id, res->value);
1489 cmdline_parse_token_string_t cmd_config_mtu_port =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1492 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1495 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1496 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1498 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1499 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1500 cmdline_parse_token_num_t cmd_config_mtu_value =
1501 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1503 cmdline_parse_inst_t cmd_config_mtu = {
1504 .f = cmd_config_mtu_parsed,
1506 .help_str = "port config mtu <port_id> <value>",
1508 (void *)&cmd_config_mtu_port,
1509 (void *)&cmd_config_mtu_keyword,
1510 (void *)&cmd_config_mtu_mtu,
1511 (void *)&cmd_config_mtu_port_id,
1512 (void *)&cmd_config_mtu_value,
1517 /* *** configure rx mode *** */
1518 struct cmd_config_rx_mode_flag {
1519 cmdline_fixed_string_t port;
1520 cmdline_fixed_string_t keyword;
1521 cmdline_fixed_string_t all;
1522 cmdline_fixed_string_t name;
1523 cmdline_fixed_string_t value;
1527 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1528 __attribute__((unused)) struct cmdline *cl,
1529 __attribute__((unused)) void *data)
1531 struct cmd_config_rx_mode_flag *res = parsed_result;
1533 if (!all_ports_stopped()) {
1534 printf("Please stop all ports first\n");
1538 if (!strcmp(res->name, "crc-strip")) {
1539 if (!strcmp(res->value, "on"))
1540 rx_mode.hw_strip_crc = 1;
1541 else if (!strcmp(res->value, "off"))
1542 rx_mode.hw_strip_crc = 0;
1544 printf("Unknown parameter\n");
1547 } else if (!strcmp(res->name, "scatter")) {
1548 if (!strcmp(res->value, "on"))
1549 rx_mode.enable_scatter = 1;
1550 else if (!strcmp(res->value, "off"))
1551 rx_mode.enable_scatter = 0;
1553 printf("Unknown parameter\n");
1556 } else if (!strcmp(res->name, "rx-cksum")) {
1557 if (!strcmp(res->value, "on"))
1558 rx_mode.hw_ip_checksum = 1;
1559 else if (!strcmp(res->value, "off"))
1560 rx_mode.hw_ip_checksum = 0;
1562 printf("Unknown parameter\n");
1565 } else if (!strcmp(res->name, "hw-vlan")) {
1566 if (!strcmp(res->value, "on")) {
1567 rx_mode.hw_vlan_filter = 1;
1568 rx_mode.hw_vlan_strip = 1;
1570 else if (!strcmp(res->value, "off")) {
1571 rx_mode.hw_vlan_filter = 0;
1572 rx_mode.hw_vlan_strip = 0;
1575 printf("Unknown parameter\n");
1578 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1579 if (!strcmp(res->value, "on"))
1580 rx_mode.hw_vlan_filter = 1;
1581 else if (!strcmp(res->value, "off"))
1582 rx_mode.hw_vlan_filter = 0;
1584 printf("Unknown parameter\n");
1587 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1588 if (!strcmp(res->value, "on"))
1589 rx_mode.hw_vlan_strip = 1;
1590 else if (!strcmp(res->value, "off"))
1591 rx_mode.hw_vlan_strip = 0;
1593 printf("Unknown parameter\n");
1596 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1597 if (!strcmp(res->value, "on"))
1598 rx_mode.hw_vlan_extend = 1;
1599 else if (!strcmp(res->value, "off"))
1600 rx_mode.hw_vlan_extend = 0;
1602 printf("Unknown parameter\n");
1605 } else if (!strcmp(res->name, "drop-en")) {
1606 if (!strcmp(res->value, "on"))
1608 else if (!strcmp(res->value, "off"))
1611 printf("Unknown parameter\n");
1615 printf("Unknown parameter\n");
1621 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1624 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1625 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1626 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1627 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1629 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1630 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1631 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1632 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1633 "crc-strip#scatter#rx-cksum#hw-vlan#"
1634 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1635 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1636 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1639 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1640 .f = cmd_config_rx_mode_flag_parsed,
1642 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1643 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1645 (void *)&cmd_config_rx_mode_flag_port,
1646 (void *)&cmd_config_rx_mode_flag_keyword,
1647 (void *)&cmd_config_rx_mode_flag_all,
1648 (void *)&cmd_config_rx_mode_flag_name,
1649 (void *)&cmd_config_rx_mode_flag_value,
1654 /* *** configure rss *** */
1655 struct cmd_config_rss {
1656 cmdline_fixed_string_t port;
1657 cmdline_fixed_string_t keyword;
1658 cmdline_fixed_string_t all;
1659 cmdline_fixed_string_t name;
1660 cmdline_fixed_string_t value;
1664 cmd_config_rss_parsed(void *parsed_result,
1665 __attribute__((unused)) struct cmdline *cl,
1666 __attribute__((unused)) void *data)
1668 struct cmd_config_rss *res = parsed_result;
1669 struct rte_eth_rss_conf rss_conf;
1673 if (!strcmp(res->value, "all"))
1674 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1675 ETH_RSS_UDP | ETH_RSS_SCTP |
1677 else if (!strcmp(res->value, "ip"))
1678 rss_conf.rss_hf = ETH_RSS_IP;
1679 else if (!strcmp(res->value, "udp"))
1680 rss_conf.rss_hf = ETH_RSS_UDP;
1681 else if (!strcmp(res->value, "tcp"))
1682 rss_conf.rss_hf = ETH_RSS_TCP;
1683 else if (!strcmp(res->value, "sctp"))
1684 rss_conf.rss_hf = ETH_RSS_SCTP;
1685 else if (!strcmp(res->value, "ether"))
1686 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1687 else if (!strcmp(res->value, "port"))
1688 rss_conf.rss_hf = ETH_RSS_PORT;
1689 else if (!strcmp(res->value, "vxlan"))
1690 rss_conf.rss_hf = ETH_RSS_VXLAN;
1691 else if (!strcmp(res->value, "geneve"))
1692 rss_conf.rss_hf = ETH_RSS_GENEVE;
1693 else if (!strcmp(res->value, "nvgre"))
1694 rss_conf.rss_hf = ETH_RSS_NVGRE;
1695 else if (!strcmp(res->value, "none"))
1696 rss_conf.rss_hf = 0;
1698 printf("Unknown parameter\n");
1701 rss_conf.rss_key = NULL;
1702 for (i = 0; i < rte_eth_dev_count(); i++) {
1703 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1705 printf("Configuration of RSS hash at ethernet port %d "
1706 "failed with error (%d): %s.\n",
1707 i, -diag, strerror(-diag));
1711 cmdline_parse_token_string_t cmd_config_rss_port =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1713 cmdline_parse_token_string_t cmd_config_rss_keyword =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1715 cmdline_parse_token_string_t cmd_config_rss_all =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1717 cmdline_parse_token_string_t cmd_config_rss_name =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1719 cmdline_parse_token_string_t cmd_config_rss_value =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1721 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1723 cmdline_parse_inst_t cmd_config_rss = {
1724 .f = cmd_config_rss_parsed,
1726 .help_str = "port config all rss "
1727 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1729 (void *)&cmd_config_rss_port,
1730 (void *)&cmd_config_rss_keyword,
1731 (void *)&cmd_config_rss_all,
1732 (void *)&cmd_config_rss_name,
1733 (void *)&cmd_config_rss_value,
1738 /* *** configure rss hash key *** */
1739 struct cmd_config_rss_hash_key {
1740 cmdline_fixed_string_t port;
1741 cmdline_fixed_string_t config;
1743 cmdline_fixed_string_t rss_hash_key;
1744 cmdline_fixed_string_t rss_type;
1745 cmdline_fixed_string_t key;
1749 hexa_digit_to_value(char hexa_digit)
1751 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1752 return (uint8_t) (hexa_digit - '0');
1753 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1754 return (uint8_t) ((hexa_digit - 'a') + 10);
1755 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1756 return (uint8_t) ((hexa_digit - 'A') + 10);
1757 /* Invalid hexa digit */
1762 parse_and_check_key_hexa_digit(char *key, int idx)
1766 hexa_v = hexa_digit_to_value(key[idx]);
1768 printf("invalid key: character %c at position %d is not a "
1769 "valid hexa digit\n", key[idx], idx);
1774 cmd_config_rss_hash_key_parsed(void *parsed_result,
1775 __attribute__((unused)) struct cmdline *cl,
1776 __attribute__((unused)) void *data)
1778 struct cmd_config_rss_hash_key *res = parsed_result;
1779 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1783 struct rte_eth_dev_info dev_info;
1784 uint8_t hash_key_size;
1787 memset(&dev_info, 0, sizeof(dev_info));
1788 rte_eth_dev_info_get(res->port_id, &dev_info);
1789 if (dev_info.hash_key_size > 0 &&
1790 dev_info.hash_key_size <= sizeof(hash_key))
1791 hash_key_size = dev_info.hash_key_size;
1793 printf("dev_info did not provide a valid hash key size\n");
1796 /* Check the length of the RSS hash key */
1797 key_len = strlen(res->key);
1798 if (key_len != (hash_key_size * 2)) {
1799 printf("key length: %d invalid - key must be a string of %d"
1800 " hexa-decimal numbers\n",
1801 (int) key_len, hash_key_size * 2);
1804 /* Translate RSS hash key into binary representation */
1805 for (i = 0; i < hash_key_size; i++) {
1806 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1809 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1812 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1814 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1818 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1819 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1820 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1821 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1823 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1824 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1825 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1826 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1827 rss_hash_key, "rss-hash-key");
1828 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1829 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1830 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1831 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1832 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1833 "ipv6-tcp-ex#ipv6-udp-ex");
1834 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1837 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1838 .f = cmd_config_rss_hash_key_parsed,
1840 .help_str = "port config <port_id> rss-hash-key "
1841 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1842 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1843 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1844 "<string of hex digits (variable length, NIC dependent)>",
1846 (void *)&cmd_config_rss_hash_key_port,
1847 (void *)&cmd_config_rss_hash_key_config,
1848 (void *)&cmd_config_rss_hash_key_port_id,
1849 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1850 (void *)&cmd_config_rss_hash_key_rss_type,
1851 (void *)&cmd_config_rss_hash_key_value,
1856 /* *** configure port rxq/txq start/stop *** */
1857 struct cmd_config_rxtx_queue {
1858 cmdline_fixed_string_t port;
1860 cmdline_fixed_string_t rxtxq;
1862 cmdline_fixed_string_t opname;
1866 cmd_config_rxtx_queue_parsed(void *parsed_result,
1867 __attribute__((unused)) struct cmdline *cl,
1868 __attribute__((unused)) void *data)
1870 struct cmd_config_rxtx_queue *res = parsed_result;
1875 if (test_done == 0) {
1876 printf("Please stop forwarding first\n");
1880 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1883 if (port_is_started(res->portid) != 1) {
1884 printf("Please start port %u first\n", res->portid);
1888 if (!strcmp(res->rxtxq, "rxq"))
1890 else if (!strcmp(res->rxtxq, "txq"))
1893 printf("Unknown parameter\n");
1897 if (isrx && rx_queue_id_is_invalid(res->qid))
1899 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1902 if (!strcmp(res->opname, "start"))
1904 else if (!strcmp(res->opname, "stop"))
1907 printf("Unknown parameter\n");
1911 if (isstart && isrx)
1912 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1913 else if (!isstart && isrx)
1914 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1915 else if (isstart && !isrx)
1916 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1918 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1920 if (ret == -ENOTSUP)
1921 printf("Function not supported in PMD driver\n");
1924 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1925 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1926 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1927 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1928 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1930 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1931 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1932 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1936 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1937 .f = cmd_config_rxtx_queue_parsed,
1939 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1941 (void *)&cmd_config_speed_all_port,
1942 (void *)&cmd_config_rxtx_queue_portid,
1943 (void *)&cmd_config_rxtx_queue_rxtxq,
1944 (void *)&cmd_config_rxtx_queue_qid,
1945 (void *)&cmd_config_rxtx_queue_opname,
1950 /* *** Configure RSS RETA *** */
1951 struct cmd_config_rss_reta {
1952 cmdline_fixed_string_t port;
1953 cmdline_fixed_string_t keyword;
1955 cmdline_fixed_string_t name;
1956 cmdline_fixed_string_t list_name;
1957 cmdline_fixed_string_t list_of_items;
1961 parse_reta_config(const char *str,
1962 struct rte_eth_rss_reta_entry64 *reta_conf,
1963 uint16_t nb_entries)
1967 uint16_t hash_index, idx, shift;
1970 const char *p, *p0 = str;
1977 unsigned long int_fld[_NUM_FLD];
1978 char *str_fld[_NUM_FLD];
1980 while ((p = strchr(p0,'(')) != NULL) {
1982 if((p0 = strchr(p,')')) == NULL)
1986 if(size >= sizeof(s))
1989 snprintf(s, sizeof(s), "%.*s", size, p);
1990 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1992 for (i = 0; i < _NUM_FLD; i++) {
1994 int_fld[i] = strtoul(str_fld[i], &end, 0);
1995 if (errno != 0 || end == str_fld[i] ||
2000 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2001 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2003 if (hash_index >= nb_entries) {
2004 printf("Invalid RETA hash index=%d\n", hash_index);
2008 idx = hash_index / RTE_RETA_GROUP_SIZE;
2009 shift = hash_index % RTE_RETA_GROUP_SIZE;
2010 reta_conf[idx].mask |= (1ULL << shift);
2011 reta_conf[idx].reta[shift] = nb_queue;
2018 cmd_set_rss_reta_parsed(void *parsed_result,
2019 __attribute__((unused)) struct cmdline *cl,
2020 __attribute__((unused)) void *data)
2023 struct rte_eth_dev_info dev_info;
2024 struct rte_eth_rss_reta_entry64 reta_conf[8];
2025 struct cmd_config_rss_reta *res = parsed_result;
2027 memset(&dev_info, 0, sizeof(dev_info));
2028 rte_eth_dev_info_get(res->port_id, &dev_info);
2029 if (dev_info.reta_size == 0) {
2030 printf("Redirection table size is 0 which is "
2031 "invalid for RSS\n");
2034 printf("The reta size of port %d is %u\n",
2035 res->port_id, dev_info.reta_size);
2036 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2037 printf("Currently do not support more than %u entries of "
2038 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2042 memset(reta_conf, 0, sizeof(reta_conf));
2043 if (!strcmp(res->list_name, "reta")) {
2044 if (parse_reta_config(res->list_of_items, reta_conf,
2045 dev_info.reta_size)) {
2046 printf("Invalid RSS Redirection Table "
2047 "config entered\n");
2050 ret = rte_eth_dev_rss_reta_update(res->port_id,
2051 reta_conf, dev_info.reta_size);
2053 printf("Bad redirection table parameter, "
2054 "return code = %d \n", ret);
2058 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2060 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2062 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2063 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2064 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2066 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2068 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2071 cmdline_parse_inst_t cmd_config_rss_reta = {
2072 .f = cmd_set_rss_reta_parsed,
2074 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2076 (void *)&cmd_config_rss_reta_port,
2077 (void *)&cmd_config_rss_reta_keyword,
2078 (void *)&cmd_config_rss_reta_port_id,
2079 (void *)&cmd_config_rss_reta_name,
2080 (void *)&cmd_config_rss_reta_list_name,
2081 (void *)&cmd_config_rss_reta_list_of_items,
2086 /* *** SHOW PORT RETA INFO *** */
2087 struct cmd_showport_reta {
2088 cmdline_fixed_string_t show;
2089 cmdline_fixed_string_t port;
2091 cmdline_fixed_string_t rss;
2092 cmdline_fixed_string_t reta;
2094 cmdline_fixed_string_t list_of_items;
2098 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2099 uint16_t nb_entries,
2103 const char *p, *p0 = str;
2108 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2109 RTE_RETA_GROUP_SIZE;
2112 p = strchr(p0, '(');
2116 p0 = strchr(p, ')');
2120 if (size >= sizeof(s)) {
2121 printf("The string size exceeds the internal buffer size\n");
2124 snprintf(s, sizeof(s), "%.*s", size, p);
2125 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2126 if (ret <= 0 || ret != num) {
2127 printf("The bits of masks do not match the number of "
2128 "reta entries: %u\n", num);
2131 for (i = 0; i < ret; i++)
2132 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2138 cmd_showport_reta_parsed(void *parsed_result,
2139 __attribute__((unused)) struct cmdline *cl,
2140 __attribute__((unused)) void *data)
2142 struct cmd_showport_reta *res = parsed_result;
2143 struct rte_eth_rss_reta_entry64 reta_conf[8];
2144 struct rte_eth_dev_info dev_info;
2146 memset(&dev_info, 0, sizeof(dev_info));
2147 rte_eth_dev_info_get(res->port_id, &dev_info);
2148 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2149 res->size > ETH_RSS_RETA_SIZE_512) {
2150 printf("Invalid redirection table size: %u\n", res->size);
2154 memset(reta_conf, 0, sizeof(reta_conf));
2155 if (showport_parse_reta_config(reta_conf, res->size,
2156 res->list_of_items) < 0) {
2157 printf("Invalid string: %s for reta masks\n",
2158 res->list_of_items);
2161 port_rss_reta_info(res->port_id, reta_conf, res->size);
2164 cmdline_parse_token_string_t cmd_showport_reta_show =
2165 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2166 cmdline_parse_token_string_t cmd_showport_reta_port =
2167 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2168 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2169 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2170 cmdline_parse_token_string_t cmd_showport_reta_rss =
2171 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2172 cmdline_parse_token_string_t cmd_showport_reta_reta =
2173 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2174 cmdline_parse_token_num_t cmd_showport_reta_size =
2175 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2176 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2177 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2178 list_of_items, NULL);
2180 cmdline_parse_inst_t cmd_showport_reta = {
2181 .f = cmd_showport_reta_parsed,
2183 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2185 (void *)&cmd_showport_reta_show,
2186 (void *)&cmd_showport_reta_port,
2187 (void *)&cmd_showport_reta_port_id,
2188 (void *)&cmd_showport_reta_rss,
2189 (void *)&cmd_showport_reta_reta,
2190 (void *)&cmd_showport_reta_size,
2191 (void *)&cmd_showport_reta_list_of_items,
2196 /* *** Show RSS hash configuration *** */
2197 struct cmd_showport_rss_hash {
2198 cmdline_fixed_string_t show;
2199 cmdline_fixed_string_t port;
2201 cmdline_fixed_string_t rss_hash;
2202 cmdline_fixed_string_t rss_type;
2203 cmdline_fixed_string_t key; /* optional argument */
2206 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2207 __attribute__((unused)) struct cmdline *cl,
2210 struct cmd_showport_rss_hash *res = parsed_result;
2212 port_rss_hash_conf_show(res->port_id, res->rss_type,
2213 show_rss_key != NULL);
2216 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2217 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2218 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2219 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2220 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2221 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2222 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2223 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2225 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2226 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2227 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2228 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2229 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2230 "ipv6-tcp-ex#ipv6-udp-ex");
2231 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2232 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2234 cmdline_parse_inst_t cmd_showport_rss_hash = {
2235 .f = cmd_showport_rss_hash_parsed,
2237 .help_str = "show port <port_id> rss-hash "
2238 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2239 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2240 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2242 (void *)&cmd_showport_rss_hash_show,
2243 (void *)&cmd_showport_rss_hash_port,
2244 (void *)&cmd_showport_rss_hash_port_id,
2245 (void *)&cmd_showport_rss_hash_rss_hash,
2246 (void *)&cmd_showport_rss_hash_rss_hash_info,
2251 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2252 .f = cmd_showport_rss_hash_parsed,
2254 .help_str = "show port <port_id> rss-hash "
2255 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2256 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2257 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2259 (void *)&cmd_showport_rss_hash_show,
2260 (void *)&cmd_showport_rss_hash_port,
2261 (void *)&cmd_showport_rss_hash_port_id,
2262 (void *)&cmd_showport_rss_hash_rss_hash,
2263 (void *)&cmd_showport_rss_hash_rss_hash_info,
2264 (void *)&cmd_showport_rss_hash_rss_key,
2269 /* *** Configure DCB *** */
2270 struct cmd_config_dcb {
2271 cmdline_fixed_string_t port;
2272 cmdline_fixed_string_t config;
2274 cmdline_fixed_string_t dcb;
2275 cmdline_fixed_string_t vt;
2276 cmdline_fixed_string_t vt_en;
2278 cmdline_fixed_string_t pfc;
2279 cmdline_fixed_string_t pfc_en;
2283 cmd_config_dcb_parsed(void *parsed_result,
2284 __attribute__((unused)) struct cmdline *cl,
2285 __attribute__((unused)) void *data)
2287 struct cmd_config_dcb *res = parsed_result;
2288 portid_t port_id = res->port_id;
2289 struct rte_port *port;
2293 port = &ports[port_id];
2294 /** Check if the port is not started **/
2295 if (port->port_status != RTE_PORT_STOPPED) {
2296 printf("Please stop port %d first\n", port_id);
2300 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2301 printf("The invalid number of traffic class,"
2302 " only 4 or 8 allowed.\n");
2306 if (nb_fwd_lcores < res->num_tcs) {
2307 printf("nb_cores shouldn't be less than number of TCs.\n");
2310 if (!strncmp(res->pfc_en, "on", 2))
2315 /* DCB in VT mode */
2316 if (!strncmp(res->vt_en, "on", 2))
2317 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2318 (enum rte_eth_nb_tcs)res->num_tcs,
2321 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2322 (enum rte_eth_nb_tcs)res->num_tcs,
2327 printf("Cannot initialize network ports.\n");
2331 cmd_reconfig_device_queue(port_id, 1, 1);
2334 cmdline_parse_token_string_t cmd_config_dcb_port =
2335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2336 cmdline_parse_token_string_t cmd_config_dcb_config =
2337 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2338 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2339 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2340 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2341 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2342 cmdline_parse_token_string_t cmd_config_dcb_vt =
2343 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2344 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2345 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2346 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2347 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2348 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2349 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2350 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2351 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2353 cmdline_parse_inst_t cmd_config_dcb = {
2354 .f = cmd_config_dcb_parsed,
2356 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2358 (void *)&cmd_config_dcb_port,
2359 (void *)&cmd_config_dcb_config,
2360 (void *)&cmd_config_dcb_port_id,
2361 (void *)&cmd_config_dcb_dcb,
2362 (void *)&cmd_config_dcb_vt,
2363 (void *)&cmd_config_dcb_vt_en,
2364 (void *)&cmd_config_dcb_num_tcs,
2365 (void *)&cmd_config_dcb_pfc,
2366 (void *)&cmd_config_dcb_pfc_en,
2371 /* *** configure number of packets per burst *** */
2372 struct cmd_config_burst {
2373 cmdline_fixed_string_t port;
2374 cmdline_fixed_string_t keyword;
2375 cmdline_fixed_string_t all;
2376 cmdline_fixed_string_t name;
2381 cmd_config_burst_parsed(void *parsed_result,
2382 __attribute__((unused)) struct cmdline *cl,
2383 __attribute__((unused)) void *data)
2385 struct cmd_config_burst *res = parsed_result;
2387 if (!all_ports_stopped()) {
2388 printf("Please stop all ports first\n");
2392 if (!strcmp(res->name, "burst")) {
2393 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2394 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2397 nb_pkt_per_burst = res->value;
2399 printf("Unknown parameter\n");
2405 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2408 cmdline_parse_token_string_t cmd_config_burst_port =
2409 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2410 cmdline_parse_token_string_t cmd_config_burst_keyword =
2411 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2412 cmdline_parse_token_string_t cmd_config_burst_all =
2413 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2414 cmdline_parse_token_string_t cmd_config_burst_name =
2415 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2416 cmdline_parse_token_num_t cmd_config_burst_value =
2417 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2419 cmdline_parse_inst_t cmd_config_burst = {
2420 .f = cmd_config_burst_parsed,
2422 .help_str = "port config all burst <value>",
2424 (void *)&cmd_config_burst_port,
2425 (void *)&cmd_config_burst_keyword,
2426 (void *)&cmd_config_burst_all,
2427 (void *)&cmd_config_burst_name,
2428 (void *)&cmd_config_burst_value,
2433 /* *** configure rx/tx queues *** */
2434 struct cmd_config_thresh {
2435 cmdline_fixed_string_t port;
2436 cmdline_fixed_string_t keyword;
2437 cmdline_fixed_string_t all;
2438 cmdline_fixed_string_t name;
2443 cmd_config_thresh_parsed(void *parsed_result,
2444 __attribute__((unused)) struct cmdline *cl,
2445 __attribute__((unused)) void *data)
2447 struct cmd_config_thresh *res = parsed_result;
2449 if (!all_ports_stopped()) {
2450 printf("Please stop all ports first\n");
2454 if (!strcmp(res->name, "txpt"))
2455 tx_pthresh = res->value;
2456 else if(!strcmp(res->name, "txht"))
2457 tx_hthresh = res->value;
2458 else if(!strcmp(res->name, "txwt"))
2459 tx_wthresh = res->value;
2460 else if(!strcmp(res->name, "rxpt"))
2461 rx_pthresh = res->value;
2462 else if(!strcmp(res->name, "rxht"))
2463 rx_hthresh = res->value;
2464 else if(!strcmp(res->name, "rxwt"))
2465 rx_wthresh = res->value;
2467 printf("Unknown parameter\n");
2473 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2476 cmdline_parse_token_string_t cmd_config_thresh_port =
2477 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2478 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2479 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2480 cmdline_parse_token_string_t cmd_config_thresh_all =
2481 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2482 cmdline_parse_token_string_t cmd_config_thresh_name =
2483 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2484 "txpt#txht#txwt#rxpt#rxht#rxwt");
2485 cmdline_parse_token_num_t cmd_config_thresh_value =
2486 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2488 cmdline_parse_inst_t cmd_config_thresh = {
2489 .f = cmd_config_thresh_parsed,
2491 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2493 (void *)&cmd_config_thresh_port,
2494 (void *)&cmd_config_thresh_keyword,
2495 (void *)&cmd_config_thresh_all,
2496 (void *)&cmd_config_thresh_name,
2497 (void *)&cmd_config_thresh_value,
2502 /* *** configure free/rs threshold *** */
2503 struct cmd_config_threshold {
2504 cmdline_fixed_string_t port;
2505 cmdline_fixed_string_t keyword;
2506 cmdline_fixed_string_t all;
2507 cmdline_fixed_string_t name;
2512 cmd_config_threshold_parsed(void *parsed_result,
2513 __attribute__((unused)) struct cmdline *cl,
2514 __attribute__((unused)) void *data)
2516 struct cmd_config_threshold *res = parsed_result;
2518 if (!all_ports_stopped()) {
2519 printf("Please stop all ports first\n");
2523 if (!strcmp(res->name, "txfreet"))
2524 tx_free_thresh = res->value;
2525 else if (!strcmp(res->name, "txrst"))
2526 tx_rs_thresh = res->value;
2527 else if (!strcmp(res->name, "rxfreet"))
2528 rx_free_thresh = res->value;
2530 printf("Unknown parameter\n");
2536 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2539 cmdline_parse_token_string_t cmd_config_threshold_port =
2540 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2541 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2542 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2544 cmdline_parse_token_string_t cmd_config_threshold_all =
2545 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2546 cmdline_parse_token_string_t cmd_config_threshold_name =
2547 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2548 "txfreet#txrst#rxfreet");
2549 cmdline_parse_token_num_t cmd_config_threshold_value =
2550 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2552 cmdline_parse_inst_t cmd_config_threshold = {
2553 .f = cmd_config_threshold_parsed,
2555 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2557 (void *)&cmd_config_threshold_port,
2558 (void *)&cmd_config_threshold_keyword,
2559 (void *)&cmd_config_threshold_all,
2560 (void *)&cmd_config_threshold_name,
2561 (void *)&cmd_config_threshold_value,
2567 struct cmd_stop_result {
2568 cmdline_fixed_string_t stop;
2571 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2572 __attribute__((unused)) struct cmdline *cl,
2573 __attribute__((unused)) void *data)
2575 stop_packet_forwarding();
2578 cmdline_parse_token_string_t cmd_stop_stop =
2579 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2581 cmdline_parse_inst_t cmd_stop = {
2582 .f = cmd_stop_parsed,
2584 .help_str = "stop: Stop packet forwarding",
2586 (void *)&cmd_stop_stop,
2591 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2594 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2595 unsigned int *parsed_items, int check_unique_values)
2597 unsigned int nb_item;
2605 * First parse all items in the list and store their value.
2610 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2612 if ((c >= '0') && (c <= '9')) {
2613 value = (unsigned int) (value * 10 + (c - '0'));
2618 printf("character %c is not a decimal digit\n", c);
2622 printf("No valid value before comma\n");
2625 if (nb_item < max_items) {
2626 parsed_items[nb_item] = value;
2632 if (nb_item >= max_items) {
2633 printf("Number of %s = %u > %u (maximum items)\n",
2634 item_name, nb_item + 1, max_items);
2637 parsed_items[nb_item++] = value;
2638 if (! check_unique_values)
2642 * Then, check that all values in the list are differents.
2643 * No optimization here...
2645 for (i = 0; i < nb_item; i++) {
2646 for (j = i + 1; j < nb_item; j++) {
2647 if (parsed_items[j] == parsed_items[i]) {
2648 printf("duplicated %s %u at index %u and %u\n",
2649 item_name, parsed_items[i], i, j);
2657 struct cmd_set_list_result {
2658 cmdline_fixed_string_t cmd_keyword;
2659 cmdline_fixed_string_t list_name;
2660 cmdline_fixed_string_t list_of_items;
2663 static void cmd_set_list_parsed(void *parsed_result,
2664 __attribute__((unused)) struct cmdline *cl,
2665 __attribute__((unused)) void *data)
2667 struct cmd_set_list_result *res;
2669 unsigned int lcorelist[RTE_MAX_LCORE];
2670 unsigned int portlist[RTE_MAX_ETHPORTS];
2672 unsigned int nb_item;
2674 if (test_done == 0) {
2675 printf("Please stop forwarding first\n");
2679 res = parsed_result;
2680 if (!strcmp(res->list_name, "corelist")) {
2681 nb_item = parse_item_list(res->list_of_items, "core",
2683 parsed_items.lcorelist, 1);
2685 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2690 if (!strcmp(res->list_name, "portlist")) {
2691 nb_item = parse_item_list(res->list_of_items, "port",
2693 parsed_items.portlist, 1);
2695 set_fwd_ports_list(parsed_items.portlist, nb_item);
2701 cmdline_parse_token_string_t cmd_set_list_keyword =
2702 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2704 cmdline_parse_token_string_t cmd_set_list_name =
2705 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2706 "corelist#portlist");
2707 cmdline_parse_token_string_t cmd_set_list_of_items =
2708 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2711 cmdline_parse_inst_t cmd_set_fwd_list = {
2712 .f = cmd_set_list_parsed,
2714 .help_str = "set corelist|portlist <list0[,list1]*>",
2716 (void *)&cmd_set_list_keyword,
2717 (void *)&cmd_set_list_name,
2718 (void *)&cmd_set_list_of_items,
2723 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2725 struct cmd_setmask_result {
2726 cmdline_fixed_string_t set;
2727 cmdline_fixed_string_t mask;
2731 static void cmd_set_mask_parsed(void *parsed_result,
2732 __attribute__((unused)) struct cmdline *cl,
2733 __attribute__((unused)) void *data)
2735 struct cmd_setmask_result *res = parsed_result;
2737 if (test_done == 0) {
2738 printf("Please stop forwarding first\n");
2741 if (!strcmp(res->mask, "coremask")) {
2742 set_fwd_lcores_mask(res->hexavalue);
2744 } else if (!strcmp(res->mask, "portmask")) {
2745 set_fwd_ports_mask(res->hexavalue);
2750 cmdline_parse_token_string_t cmd_setmask_set =
2751 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2752 cmdline_parse_token_string_t cmd_setmask_mask =
2753 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2754 "coremask#portmask");
2755 cmdline_parse_token_num_t cmd_setmask_value =
2756 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2758 cmdline_parse_inst_t cmd_set_fwd_mask = {
2759 .f = cmd_set_mask_parsed,
2761 .help_str = "set coremask|portmask <hexadecimal value>",
2763 (void *)&cmd_setmask_set,
2764 (void *)&cmd_setmask_mask,
2765 (void *)&cmd_setmask_value,
2771 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2773 struct cmd_set_result {
2774 cmdline_fixed_string_t set;
2775 cmdline_fixed_string_t what;
2779 static void cmd_set_parsed(void *parsed_result,
2780 __attribute__((unused)) struct cmdline *cl,
2781 __attribute__((unused)) void *data)
2783 struct cmd_set_result *res = parsed_result;
2784 if (!strcmp(res->what, "nbport")) {
2785 set_fwd_ports_number(res->value);
2787 } else if (!strcmp(res->what, "nbcore")) {
2788 set_fwd_lcores_number(res->value);
2790 } else if (!strcmp(res->what, "burst"))
2791 set_nb_pkt_per_burst(res->value);
2792 else if (!strcmp(res->what, "verbose"))
2793 set_verbose_level(res->value);
2796 cmdline_parse_token_string_t cmd_set_set =
2797 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2798 cmdline_parse_token_string_t cmd_set_what =
2799 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2800 "nbport#nbcore#burst#verbose");
2801 cmdline_parse_token_num_t cmd_set_value =
2802 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2804 cmdline_parse_inst_t cmd_set_numbers = {
2805 .f = cmd_set_parsed,
2807 .help_str = "set nbport|nbcore|burst|verbose <value>",
2809 (void *)&cmd_set_set,
2810 (void *)&cmd_set_what,
2811 (void *)&cmd_set_value,
2816 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2818 struct cmd_set_txpkts_result {
2819 cmdline_fixed_string_t cmd_keyword;
2820 cmdline_fixed_string_t txpkts;
2821 cmdline_fixed_string_t seg_lengths;
2825 cmd_set_txpkts_parsed(void *parsed_result,
2826 __attribute__((unused)) struct cmdline *cl,
2827 __attribute__((unused)) void *data)
2829 struct cmd_set_txpkts_result *res;
2830 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2831 unsigned int nb_segs;
2833 res = parsed_result;
2834 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2835 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2837 set_tx_pkt_segments(seg_lengths, nb_segs);
2840 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2841 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2842 cmd_keyword, "set");
2843 cmdline_parse_token_string_t cmd_set_txpkts_name =
2844 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2846 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2847 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2850 cmdline_parse_inst_t cmd_set_txpkts = {
2851 .f = cmd_set_txpkts_parsed,
2853 .help_str = "set txpkts <len0[,len1]*>",
2855 (void *)&cmd_set_txpkts_keyword,
2856 (void *)&cmd_set_txpkts_name,
2857 (void *)&cmd_set_txpkts_lengths,
2862 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2864 struct cmd_set_txsplit_result {
2865 cmdline_fixed_string_t cmd_keyword;
2866 cmdline_fixed_string_t txsplit;
2867 cmdline_fixed_string_t mode;
2871 cmd_set_txsplit_parsed(void *parsed_result,
2872 __attribute__((unused)) struct cmdline *cl,
2873 __attribute__((unused)) void *data)
2875 struct cmd_set_txsplit_result *res;
2877 res = parsed_result;
2878 set_tx_pkt_split(res->mode);
2881 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2882 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2883 cmd_keyword, "set");
2884 cmdline_parse_token_string_t cmd_set_txsplit_name =
2885 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2886 txsplit, "txsplit");
2887 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2888 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2891 cmdline_parse_inst_t cmd_set_txsplit = {
2892 .f = cmd_set_txsplit_parsed,
2894 .help_str = "set txsplit on|off|rand",
2896 (void *)&cmd_set_txsplit_keyword,
2897 (void *)&cmd_set_txsplit_name,
2898 (void *)&cmd_set_txsplit_mode,
2903 /* *** CONFIG TX QUEUE FLAGS *** */
2905 struct cmd_config_txqflags_result {
2906 cmdline_fixed_string_t port;
2907 cmdline_fixed_string_t config;
2908 cmdline_fixed_string_t all;
2909 cmdline_fixed_string_t what;
2913 static void cmd_config_txqflags_parsed(void *parsed_result,
2914 __attribute__((unused)) struct cmdline *cl,
2915 __attribute__((unused)) void *data)
2917 struct cmd_config_txqflags_result *res = parsed_result;
2919 if (!all_ports_stopped()) {
2920 printf("Please stop all ports first\n");
2924 if (strcmp(res->what, "txqflags")) {
2925 printf("Unknown parameter\n");
2929 if (res->hexvalue >= 0) {
2930 txq_flags = res->hexvalue;
2932 printf("txqflags must be >= 0\n");
2938 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2941 cmdline_parse_token_string_t cmd_config_txqflags_port =
2942 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2944 cmdline_parse_token_string_t cmd_config_txqflags_config =
2945 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2947 cmdline_parse_token_string_t cmd_config_txqflags_all =
2948 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2950 cmdline_parse_token_string_t cmd_config_txqflags_what =
2951 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2953 cmdline_parse_token_num_t cmd_config_txqflags_value =
2954 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2957 cmdline_parse_inst_t cmd_config_txqflags = {
2958 .f = cmd_config_txqflags_parsed,
2960 .help_str = "port config all txqflags <value>",
2962 (void *)&cmd_config_txqflags_port,
2963 (void *)&cmd_config_txqflags_config,
2964 (void *)&cmd_config_txqflags_all,
2965 (void *)&cmd_config_txqflags_what,
2966 (void *)&cmd_config_txqflags_value,
2971 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2972 struct cmd_rx_vlan_filter_all_result {
2973 cmdline_fixed_string_t rx_vlan;
2974 cmdline_fixed_string_t what;
2975 cmdline_fixed_string_t all;
2980 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2981 __attribute__((unused)) struct cmdline *cl,
2982 __attribute__((unused)) void *data)
2984 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2986 if (!strcmp(res->what, "add"))
2987 rx_vlan_all_filter_set(res->port_id, 1);
2989 rx_vlan_all_filter_set(res->port_id, 0);
2992 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2993 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2994 rx_vlan, "rx_vlan");
2995 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2996 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2998 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2999 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3001 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3002 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3005 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3006 .f = cmd_rx_vlan_filter_all_parsed,
3008 .help_str = "rx_vlan add|rm all <port_id>: "
3009 "Add/Remove all identifiers to/from the set of VLAN "
3010 "identifiers filtered by a port",
3012 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3013 (void *)&cmd_rx_vlan_filter_all_what,
3014 (void *)&cmd_rx_vlan_filter_all_all,
3015 (void *)&cmd_rx_vlan_filter_all_portid,
3020 /* *** VLAN OFFLOAD SET ON A PORT *** */
3021 struct cmd_vlan_offload_result {
3022 cmdline_fixed_string_t vlan;
3023 cmdline_fixed_string_t set;
3024 cmdline_fixed_string_t vlan_type;
3025 cmdline_fixed_string_t what;
3026 cmdline_fixed_string_t on;
3027 cmdline_fixed_string_t port_id;
3031 cmd_vlan_offload_parsed(void *parsed_result,
3032 __attribute__((unused)) struct cmdline *cl,
3033 __attribute__((unused)) void *data)
3036 struct cmd_vlan_offload_result *res = parsed_result;
3039 portid_t port_id = 0;
3043 len = strnlen(str, STR_TOKEN_SIZE);
3045 /* Get port_id first */
3053 tmp = strtoul(str, NULL, 0);
3054 /* If port_id greater that what portid_t can represent, return */
3055 if(tmp >= RTE_MAX_ETHPORTS)
3057 port_id = (portid_t)tmp;
3059 if (!strcmp(res->on, "on"))
3064 if (!strcmp(res->what, "strip"))
3065 rx_vlan_strip_set(port_id, on);
3066 else if(!strcmp(res->what, "stripq")){
3067 uint16_t queue_id = 0;
3069 /* No queue_id, return */
3071 printf("must specify (port,queue_id)\n");
3074 tmp = strtoul(str + i + 1, NULL, 0);
3075 /* If queue_id greater that what 16-bits can represent, return */
3079 queue_id = (uint16_t)tmp;
3080 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3082 else if (!strcmp(res->what, "filter"))
3083 rx_vlan_filter_set(port_id, on);
3085 vlan_extend_set(port_id, on);
3090 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3091 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3093 cmdline_parse_token_string_t cmd_vlan_offload_set =
3094 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3096 cmdline_parse_token_string_t cmd_vlan_offload_what =
3097 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3098 what, "strip#filter#qinq#stripq");
3099 cmdline_parse_token_string_t cmd_vlan_offload_on =
3100 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3102 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3103 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3106 cmdline_parse_inst_t cmd_vlan_offload = {
3107 .f = cmd_vlan_offload_parsed,
3109 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3110 "<port_id[,queue_id]>: "
3111 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3113 (void *)&cmd_vlan_offload_vlan,
3114 (void *)&cmd_vlan_offload_set,
3115 (void *)&cmd_vlan_offload_what,
3116 (void *)&cmd_vlan_offload_on,
3117 (void *)&cmd_vlan_offload_portid,
3122 /* *** VLAN TPID SET ON A PORT *** */
3123 struct cmd_vlan_tpid_result {
3124 cmdline_fixed_string_t vlan;
3125 cmdline_fixed_string_t set;
3126 cmdline_fixed_string_t vlan_type;
3127 cmdline_fixed_string_t what;
3133 cmd_vlan_tpid_parsed(void *parsed_result,
3134 __attribute__((unused)) struct cmdline *cl,
3135 __attribute__((unused)) void *data)
3137 struct cmd_vlan_tpid_result *res = parsed_result;
3138 enum rte_vlan_type vlan_type;
3140 if (!strcmp(res->vlan_type, "inner"))
3141 vlan_type = ETH_VLAN_TYPE_INNER;
3142 else if (!strcmp(res->vlan_type, "outer"))
3143 vlan_type = ETH_VLAN_TYPE_OUTER;
3145 printf("Unknown vlan type\n");
3148 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3151 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3152 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3154 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3155 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3157 cmdline_parse_token_string_t cmd_vlan_type =
3158 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3159 vlan_type, "inner#outer");
3160 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3161 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3163 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3164 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3166 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3167 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3170 cmdline_parse_inst_t cmd_vlan_tpid = {
3171 .f = cmd_vlan_tpid_parsed,
3173 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3174 "Set the VLAN Ether type",
3176 (void *)&cmd_vlan_tpid_vlan,
3177 (void *)&cmd_vlan_tpid_set,
3178 (void *)&cmd_vlan_type,
3179 (void *)&cmd_vlan_tpid_what,
3180 (void *)&cmd_vlan_tpid_tpid,
3181 (void *)&cmd_vlan_tpid_portid,
3186 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3187 struct cmd_rx_vlan_filter_result {
3188 cmdline_fixed_string_t rx_vlan;
3189 cmdline_fixed_string_t what;
3195 cmd_rx_vlan_filter_parsed(void *parsed_result,
3196 __attribute__((unused)) struct cmdline *cl,
3197 __attribute__((unused)) void *data)
3199 struct cmd_rx_vlan_filter_result *res = parsed_result;
3201 if (!strcmp(res->what, "add"))
3202 rx_vft_set(res->port_id, res->vlan_id, 1);
3204 rx_vft_set(res->port_id, res->vlan_id, 0);
3207 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3208 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3209 rx_vlan, "rx_vlan");
3210 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3211 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3213 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3214 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3216 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3217 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3220 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3221 .f = cmd_rx_vlan_filter_parsed,
3223 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3224 "Add/Remove a VLAN identifier to/from the set of VLAN "
3225 "identifiers filtered by a port",
3227 (void *)&cmd_rx_vlan_filter_rx_vlan,
3228 (void *)&cmd_rx_vlan_filter_what,
3229 (void *)&cmd_rx_vlan_filter_vlanid,
3230 (void *)&cmd_rx_vlan_filter_portid,
3235 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3236 struct cmd_tx_vlan_set_result {
3237 cmdline_fixed_string_t tx_vlan;
3238 cmdline_fixed_string_t set;
3244 cmd_tx_vlan_set_parsed(void *parsed_result,
3245 __attribute__((unused)) struct cmdline *cl,
3246 __attribute__((unused)) void *data)
3248 struct cmd_tx_vlan_set_result *res = parsed_result;
3250 tx_vlan_set(res->port_id, res->vlan_id);
3253 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3254 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3255 tx_vlan, "tx_vlan");
3256 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3257 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3259 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3260 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3262 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3263 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3266 cmdline_parse_inst_t cmd_tx_vlan_set = {
3267 .f = cmd_tx_vlan_set_parsed,
3269 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3270 "Enable hardware insertion of a single VLAN header "
3271 "with a given TAG Identifier in packets sent on a port",
3273 (void *)&cmd_tx_vlan_set_tx_vlan,
3274 (void *)&cmd_tx_vlan_set_set,
3275 (void *)&cmd_tx_vlan_set_portid,
3276 (void *)&cmd_tx_vlan_set_vlanid,
3281 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3282 struct cmd_tx_vlan_set_qinq_result {
3283 cmdline_fixed_string_t tx_vlan;
3284 cmdline_fixed_string_t set;
3287 uint16_t vlan_id_outer;
3291 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3292 __attribute__((unused)) struct cmdline *cl,
3293 __attribute__((unused)) void *data)
3295 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3297 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3300 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3301 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3302 tx_vlan, "tx_vlan");
3303 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3304 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3306 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3307 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3309 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3310 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3312 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3313 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3314 vlan_id_outer, UINT16);
3316 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3317 .f = cmd_tx_vlan_set_qinq_parsed,
3319 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3320 "Enable hardware insertion of double VLAN header "
3321 "with given TAG Identifiers in packets sent on a port",
3323 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3324 (void *)&cmd_tx_vlan_set_qinq_set,
3325 (void *)&cmd_tx_vlan_set_qinq_portid,
3326 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3327 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3332 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3333 struct cmd_tx_vlan_set_pvid_result {
3334 cmdline_fixed_string_t tx_vlan;
3335 cmdline_fixed_string_t set;
3336 cmdline_fixed_string_t pvid;
3339 cmdline_fixed_string_t mode;
3343 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3344 __attribute__((unused)) struct cmdline *cl,
3345 __attribute__((unused)) void *data)
3347 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3349 if (strcmp(res->mode, "on") == 0)
3350 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3352 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3355 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3356 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3357 tx_vlan, "tx_vlan");
3358 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3359 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3361 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3362 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3364 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3365 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3367 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3368 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3370 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3371 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3374 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3375 .f = cmd_tx_vlan_set_pvid_parsed,
3377 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3379 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3380 (void *)&cmd_tx_vlan_set_pvid_set,
3381 (void *)&cmd_tx_vlan_set_pvid_pvid,
3382 (void *)&cmd_tx_vlan_set_pvid_port_id,
3383 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3384 (void *)&cmd_tx_vlan_set_pvid_mode,
3389 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3390 struct cmd_tx_vlan_reset_result {
3391 cmdline_fixed_string_t tx_vlan;
3392 cmdline_fixed_string_t reset;
3397 cmd_tx_vlan_reset_parsed(void *parsed_result,
3398 __attribute__((unused)) struct cmdline *cl,
3399 __attribute__((unused)) void *data)
3401 struct cmd_tx_vlan_reset_result *res = parsed_result;
3403 tx_vlan_reset(res->port_id);
3406 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3407 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3408 tx_vlan, "tx_vlan");
3409 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3410 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3412 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3413 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3416 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3417 .f = cmd_tx_vlan_reset_parsed,
3419 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3420 "VLAN header in packets sent on a port",
3422 (void *)&cmd_tx_vlan_reset_tx_vlan,
3423 (void *)&cmd_tx_vlan_reset_reset,
3424 (void *)&cmd_tx_vlan_reset_portid,
3430 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3431 struct cmd_csum_result {
3432 cmdline_fixed_string_t csum;
3433 cmdline_fixed_string_t mode;
3434 cmdline_fixed_string_t proto;
3435 cmdline_fixed_string_t hwsw;
3440 csum_show(int port_id)
3442 struct rte_eth_dev_info dev_info;
3445 ol_flags = ports[port_id].tx_ol_flags;
3446 printf("Parse tunnel is %s\n",
3447 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3448 printf("IP checksum offload is %s\n",
3449 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3450 printf("UDP checksum offload is %s\n",
3451 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3452 printf("TCP checksum offload is %s\n",
3453 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3454 printf("SCTP checksum offload is %s\n",
3455 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3456 printf("Outer-Ip checksum offload is %s\n",
3457 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3459 /* display warnings if configuration is not supported by the NIC */
3460 rte_eth_dev_info_get(port_id, &dev_info);
3461 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3462 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3463 printf("Warning: hardware IP checksum enabled but not "
3464 "supported by port %d\n", port_id);
3466 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3467 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3468 printf("Warning: hardware UDP checksum enabled but not "
3469 "supported by port %d\n", port_id);
3471 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3472 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3473 printf("Warning: hardware TCP checksum enabled but not "
3474 "supported by port %d\n", port_id);
3476 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3477 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3478 printf("Warning: hardware SCTP checksum enabled but not "
3479 "supported by port %d\n", port_id);
3481 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3482 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3483 printf("Warning: hardware outer IP checksum enabled but not "
3484 "supported by port %d\n", port_id);
3489 cmd_csum_parsed(void *parsed_result,
3490 __attribute__((unused)) struct cmdline *cl,
3491 __attribute__((unused)) void *data)
3493 struct cmd_csum_result *res = parsed_result;
3497 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3498 printf("invalid port %d\n", res->port_id);
3502 if (!strcmp(res->mode, "set")) {
3504 if (!strcmp(res->hwsw, "hw"))
3507 if (!strcmp(res->proto, "ip")) {
3508 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3509 } else if (!strcmp(res->proto, "udp")) {
3510 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3511 } else if (!strcmp(res->proto, "tcp")) {
3512 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3513 } else if (!strcmp(res->proto, "sctp")) {
3514 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3515 } else if (!strcmp(res->proto, "outer-ip")) {
3516 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3520 ports[res->port_id].tx_ol_flags |= mask;
3522 ports[res->port_id].tx_ol_flags &= (~mask);
3524 csum_show(res->port_id);
3527 cmdline_parse_token_string_t cmd_csum_csum =
3528 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3530 cmdline_parse_token_string_t cmd_csum_mode =
3531 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3533 cmdline_parse_token_string_t cmd_csum_proto =
3534 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3535 proto, "ip#tcp#udp#sctp#outer-ip");
3536 cmdline_parse_token_string_t cmd_csum_hwsw =
3537 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3539 cmdline_parse_token_num_t cmd_csum_portid =
3540 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3543 cmdline_parse_inst_t cmd_csum_set = {
3544 .f = cmd_csum_parsed,
3546 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3547 "Enable/Disable hardware calculation of L3/L4 checksum when "
3548 "using csum forward engine",
3550 (void *)&cmd_csum_csum,
3551 (void *)&cmd_csum_mode,
3552 (void *)&cmd_csum_proto,
3553 (void *)&cmd_csum_hwsw,
3554 (void *)&cmd_csum_portid,
3559 cmdline_parse_token_string_t cmd_csum_mode_show =
3560 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3563 cmdline_parse_inst_t cmd_csum_show = {
3564 .f = cmd_csum_parsed,
3566 .help_str = "csum show <port_id>: Show checksum offload configuration",
3568 (void *)&cmd_csum_csum,
3569 (void *)&cmd_csum_mode_show,
3570 (void *)&cmd_csum_portid,
3575 /* Enable/disable tunnel parsing */
3576 struct cmd_csum_tunnel_result {
3577 cmdline_fixed_string_t csum;
3578 cmdline_fixed_string_t parse;
3579 cmdline_fixed_string_t onoff;
3584 cmd_csum_tunnel_parsed(void *parsed_result,
3585 __attribute__((unused)) struct cmdline *cl,
3586 __attribute__((unused)) void *data)
3588 struct cmd_csum_tunnel_result *res = parsed_result;
3590 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3593 if (!strcmp(res->onoff, "on"))
3594 ports[res->port_id].tx_ol_flags |=
3595 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3597 ports[res->port_id].tx_ol_flags &=
3598 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3600 csum_show(res->port_id);
3603 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3604 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3606 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3607 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3608 parse, "parse_tunnel");
3609 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3610 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3612 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3613 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3616 cmdline_parse_inst_t cmd_csum_tunnel = {
3617 .f = cmd_csum_tunnel_parsed,
3619 .help_str = "csum parse_tunnel on|off <port_id>: "
3620 "Enable/Disable parsing of tunnels for csum engine",
3622 (void *)&cmd_csum_tunnel_csum,
3623 (void *)&cmd_csum_tunnel_parse,
3624 (void *)&cmd_csum_tunnel_onoff,
3625 (void *)&cmd_csum_tunnel_portid,
3630 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3631 struct cmd_tso_set_result {
3632 cmdline_fixed_string_t tso;
3633 cmdline_fixed_string_t mode;
3639 cmd_tso_set_parsed(void *parsed_result,
3640 __attribute__((unused)) struct cmdline *cl,
3641 __attribute__((unused)) void *data)
3643 struct cmd_tso_set_result *res = parsed_result;
3644 struct rte_eth_dev_info dev_info;
3646 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3649 if (!strcmp(res->mode, "set"))
3650 ports[res->port_id].tso_segsz = res->tso_segsz;
3652 if (ports[res->port_id].tso_segsz == 0)
3653 printf("TSO for non-tunneled packets is disabled\n");
3655 printf("TSO segment size for non-tunneled packets is %d\n",
3656 ports[res->port_id].tso_segsz);
3658 /* display warnings if configuration is not supported by the NIC */
3659 rte_eth_dev_info_get(res->port_id, &dev_info);
3660 if ((ports[res->port_id].tso_segsz != 0) &&
3661 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3662 printf("Warning: TSO enabled but not "
3663 "supported by port %d\n", res->port_id);
3667 cmdline_parse_token_string_t cmd_tso_set_tso =
3668 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3670 cmdline_parse_token_string_t cmd_tso_set_mode =
3671 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3673 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3674 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3676 cmdline_parse_token_num_t cmd_tso_set_portid =
3677 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3680 cmdline_parse_inst_t cmd_tso_set = {
3681 .f = cmd_tso_set_parsed,
3683 .help_str = "tso set <tso_segsz> <port_id>: "
3684 "Set TSO segment size of non-tunneled packets for csum engine "
3687 (void *)&cmd_tso_set_tso,
3688 (void *)&cmd_tso_set_mode,
3689 (void *)&cmd_tso_set_tso_segsz,
3690 (void *)&cmd_tso_set_portid,
3695 cmdline_parse_token_string_t cmd_tso_show_mode =
3696 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3700 cmdline_parse_inst_t cmd_tso_show = {
3701 .f = cmd_tso_set_parsed,
3703 .help_str = "tso show <port_id>: "
3704 "Show TSO segment size of non-tunneled packets for csum engine",
3706 (void *)&cmd_tso_set_tso,
3707 (void *)&cmd_tso_show_mode,
3708 (void *)&cmd_tso_set_portid,
3713 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3714 struct cmd_tunnel_tso_set_result {
3715 cmdline_fixed_string_t tso;
3716 cmdline_fixed_string_t mode;
3722 check_tunnel_tso_nic_support(uint8_t port_id)
3724 struct rte_eth_dev_info dev_info;
3726 rte_eth_dev_info_get(port_id, &dev_info);
3727 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3728 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3729 "supported by port %d\n", port_id);
3730 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3731 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3732 "supported by port %d\n", port_id);
3733 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3734 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3735 "supported by port %d\n", port_id);
3736 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3737 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3738 "supported by port %d\n", port_id);
3742 cmd_tunnel_tso_set_parsed(void *parsed_result,
3743 __attribute__((unused)) struct cmdline *cl,
3744 __attribute__((unused)) void *data)
3746 struct cmd_tunnel_tso_set_result *res = parsed_result;
3748 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3751 if (!strcmp(res->mode, "set"))
3752 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3754 if (ports[res->port_id].tunnel_tso_segsz == 0)
3755 printf("TSO for tunneled packets is disabled\n");
3757 printf("TSO segment size for tunneled packets is %d\n",
3758 ports[res->port_id].tunnel_tso_segsz);
3760 /* Below conditions are needed to make it work:
3761 * (1) tunnel TSO is supported by the NIC;
3762 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3764 * (3) for tunneled pkts with outer L3 of IPv4,
3765 * "csum set outer-ip" must be set to hw, because after tso,
3766 * total_len of outer IP header is changed, and the checksum
3767 * of outer IP header calculated by sw should be wrong; that
3768 * is not necessary for IPv6 tunneled pkts because there's no
3769 * checksum in IP header anymore.
3771 check_tunnel_tso_nic_support(res->port_id);
3773 if (!(ports[res->port_id].tx_ol_flags &
3774 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3775 printf("Warning: csum parse_tunnel must be set "
3776 "so that tunneled packets are recognized\n");
3777 if (!(ports[res->port_id].tx_ol_flags &
3778 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3779 printf("Warning: csum set outer-ip must be set to hw "
3780 "if outer L3 is IPv4; not necessary for IPv6\n");
3784 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3785 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3787 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3788 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3790 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3791 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3793 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3794 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3797 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3798 .f = cmd_tunnel_tso_set_parsed,
3800 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3801 "Set TSO segment size of tunneled packets for csum engine "
3804 (void *)&cmd_tunnel_tso_set_tso,
3805 (void *)&cmd_tunnel_tso_set_mode,
3806 (void *)&cmd_tunnel_tso_set_tso_segsz,
3807 (void *)&cmd_tunnel_tso_set_portid,
3812 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3813 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3817 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3818 .f = cmd_tunnel_tso_set_parsed,
3820 .help_str = "tunnel_tso show <port_id> "
3821 "Show TSO segment size of tunneled packets for csum engine",
3823 (void *)&cmd_tunnel_tso_set_tso,
3824 (void *)&cmd_tunnel_tso_show_mode,
3825 (void *)&cmd_tunnel_tso_set_portid,
3830 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3831 struct cmd_set_flush_rx {
3832 cmdline_fixed_string_t set;
3833 cmdline_fixed_string_t flush_rx;
3834 cmdline_fixed_string_t mode;
3838 cmd_set_flush_rx_parsed(void *parsed_result,
3839 __attribute__((unused)) struct cmdline *cl,
3840 __attribute__((unused)) void *data)
3842 struct cmd_set_flush_rx *res = parsed_result;
3843 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3846 cmdline_parse_token_string_t cmd_setflushrx_set =
3847 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3849 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3850 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3851 flush_rx, "flush_rx");
3852 cmdline_parse_token_string_t cmd_setflushrx_mode =
3853 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3857 cmdline_parse_inst_t cmd_set_flush_rx = {
3858 .f = cmd_set_flush_rx_parsed,
3859 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3862 (void *)&cmd_setflushrx_set,
3863 (void *)&cmd_setflushrx_flush_rx,
3864 (void *)&cmd_setflushrx_mode,
3869 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3870 struct cmd_set_link_check {
3871 cmdline_fixed_string_t set;
3872 cmdline_fixed_string_t link_check;
3873 cmdline_fixed_string_t mode;
3877 cmd_set_link_check_parsed(void *parsed_result,
3878 __attribute__((unused)) struct cmdline *cl,
3879 __attribute__((unused)) void *data)
3881 struct cmd_set_link_check *res = parsed_result;
3882 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3885 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3886 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3888 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3890 link_check, "link_check");
3891 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3892 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3896 cmdline_parse_inst_t cmd_set_link_check = {
3897 .f = cmd_set_link_check_parsed,
3898 .help_str = "set link_check on|off: Enable/Disable link status check "
3899 "when starting/stopping a port",
3902 (void *)&cmd_setlinkcheck_set,
3903 (void *)&cmd_setlinkcheck_link_check,
3904 (void *)&cmd_setlinkcheck_mode,
3909 /* *** SET NIC BYPASS MODE *** */
3910 struct cmd_set_bypass_mode_result {
3911 cmdline_fixed_string_t set;
3912 cmdline_fixed_string_t bypass;
3913 cmdline_fixed_string_t mode;
3914 cmdline_fixed_string_t value;
3919 cmd_set_bypass_mode_parsed(void *parsed_result,
3920 __attribute__((unused)) struct cmdline *cl,
3921 __attribute__((unused)) void *data)
3923 struct cmd_set_bypass_mode_result *res = parsed_result;
3924 portid_t port_id = res->port_id;
3925 int32_t rc = -EINVAL;
3927 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
3928 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3930 if (!strcmp(res->value, "bypass"))
3931 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
3932 else if (!strcmp(res->value, "isolate"))
3933 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
3935 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3937 /* Set the bypass mode for the relevant port. */
3938 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
3941 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3944 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3945 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3947 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3950 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3953 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3955 value, "normal#bypass#isolate");
3956 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3957 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3960 cmdline_parse_inst_t cmd_set_bypass_mode = {
3961 .f = cmd_set_bypass_mode_parsed,
3962 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3963 "Set the NIC bypass mode for port_id",
3966 (void *)&cmd_setbypass_mode_set,
3967 (void *)&cmd_setbypass_mode_bypass,
3968 (void *)&cmd_setbypass_mode_mode,
3969 (void *)&cmd_setbypass_mode_value,
3970 (void *)&cmd_setbypass_mode_port,
3975 /* *** SET NIC BYPASS EVENT *** */
3976 struct cmd_set_bypass_event_result {
3977 cmdline_fixed_string_t set;
3978 cmdline_fixed_string_t bypass;
3979 cmdline_fixed_string_t event;
3980 cmdline_fixed_string_t event_value;
3981 cmdline_fixed_string_t mode;
3982 cmdline_fixed_string_t mode_value;
3987 cmd_set_bypass_event_parsed(void *parsed_result,
3988 __attribute__((unused)) struct cmdline *cl,
3989 __attribute__((unused)) void *data)
3991 int32_t rc = -EINVAL;
3992 struct cmd_set_bypass_event_result *res = parsed_result;
3993 portid_t port_id = res->port_id;
3995 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
3996 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
3997 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
3999 if (!strcmp(res->event_value, "timeout"))
4000 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4001 else if (!strcmp(res->event_value, "os_on"))
4002 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4003 else if (!strcmp(res->event_value, "os_off"))
4004 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4005 else if (!strcmp(res->event_value, "power_on"))
4006 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4007 else if (!strcmp(res->event_value, "power_off"))
4008 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4010 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4012 if (!strcmp(res->mode_value, "bypass"))
4013 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4014 else if (!strcmp(res->mode_value, "isolate"))
4015 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4017 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4019 /* Set the watchdog timeout. */
4020 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4023 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4024 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4028 printf("Failed to set timeout value %u "
4029 "for port %d, errto code: %d.\n",
4030 bypass_timeout, port_id, rc);
4034 /* Set the bypass event to transition to bypass mode. */
4035 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4040 printf("\t Failed to set bypass event for port = %d.\n",
4044 cmdline_parse_token_string_t cmd_setbypass_event_set =
4045 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4047 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4048 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4050 cmdline_parse_token_string_t cmd_setbypass_event_event =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4053 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4054 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4055 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4056 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4059 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4060 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4061 mode_value, "normal#bypass#isolate");
4062 cmdline_parse_token_num_t cmd_setbypass_event_port =
4063 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4066 cmdline_parse_inst_t cmd_set_bypass_event = {
4067 .f = cmd_set_bypass_event_parsed,
4068 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4069 "power_off mode normal|bypass|isolate <port_id>: "
4070 "Set the NIC bypass event mode for port_id",
4073 (void *)&cmd_setbypass_event_set,
4074 (void *)&cmd_setbypass_event_bypass,
4075 (void *)&cmd_setbypass_event_event,
4076 (void *)&cmd_setbypass_event_event_value,
4077 (void *)&cmd_setbypass_event_mode,
4078 (void *)&cmd_setbypass_event_mode_value,
4079 (void *)&cmd_setbypass_event_port,
4085 /* *** SET NIC BYPASS TIMEOUT *** */
4086 struct cmd_set_bypass_timeout_result {
4087 cmdline_fixed_string_t set;
4088 cmdline_fixed_string_t bypass;
4089 cmdline_fixed_string_t timeout;
4090 cmdline_fixed_string_t value;
4094 cmd_set_bypass_timeout_parsed(void *parsed_result,
4095 __attribute__((unused)) struct cmdline *cl,
4096 __attribute__((unused)) void *data)
4098 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4100 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4101 if (!strcmp(res->value, "1.5"))
4102 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4103 else if (!strcmp(res->value, "2"))
4104 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4105 else if (!strcmp(res->value, "3"))
4106 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4107 else if (!strcmp(res->value, "4"))
4108 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4109 else if (!strcmp(res->value, "8"))
4110 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4111 else if (!strcmp(res->value, "16"))
4112 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4113 else if (!strcmp(res->value, "32"))
4114 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4116 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4120 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4121 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4123 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4124 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4126 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4127 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4128 timeout, "timeout");
4129 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4130 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4131 value, "0#1.5#2#3#4#8#16#32");
4133 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4134 .f = cmd_set_bypass_timeout_parsed,
4135 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4136 "Set the NIC bypass watchdog timeout in seconds",
4139 (void *)&cmd_setbypass_timeout_set,
4140 (void *)&cmd_setbypass_timeout_bypass,
4141 (void *)&cmd_setbypass_timeout_timeout,
4142 (void *)&cmd_setbypass_timeout_value,
4147 /* *** SHOW NIC BYPASS MODE *** */
4148 struct cmd_show_bypass_config_result {
4149 cmdline_fixed_string_t show;
4150 cmdline_fixed_string_t bypass;
4151 cmdline_fixed_string_t config;
4156 cmd_show_bypass_config_parsed(void *parsed_result,
4157 __attribute__((unused)) struct cmdline *cl,
4158 __attribute__((unused)) void *data)
4160 struct cmd_show_bypass_config_result *res = parsed_result;
4161 portid_t port_id = res->port_id;
4163 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4164 uint32_t event_mode;
4165 uint32_t bypass_mode;
4166 uint32_t timeout = bypass_timeout;
4169 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4170 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4171 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4172 {"UNKNOWN", "normal", "bypass", "isolate"};
4173 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4180 int num_events = (sizeof events) / (sizeof events[0]);
4182 /* Display the bypass mode.*/
4183 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4184 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4188 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4189 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4191 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4194 /* Display the bypass timeout.*/
4195 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4196 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4198 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4200 /* Display the bypass events and associated modes. */
4201 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4203 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4204 printf("\tFailed to get bypass mode for event = %s\n",
4207 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4208 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4210 printf("\tbypass event: %-16s = %s\n", events[i],
4216 printf("\tFailed to get bypass configuration for port = %d\n",
4220 cmdline_parse_token_string_t cmd_showbypass_config_show =
4221 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4223 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4224 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4226 cmdline_parse_token_string_t cmd_showbypass_config_config =
4227 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4229 cmdline_parse_token_num_t cmd_showbypass_config_port =
4230 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4233 cmdline_parse_inst_t cmd_show_bypass_config = {
4234 .f = cmd_show_bypass_config_parsed,
4235 .help_str = "show bypass config <port_id>: "
4236 "Show the NIC bypass config for port_id",
4239 (void *)&cmd_showbypass_config_show,
4240 (void *)&cmd_showbypass_config_bypass,
4241 (void *)&cmd_showbypass_config_config,
4242 (void *)&cmd_showbypass_config_port,
4247 #ifdef RTE_LIBRTE_PMD_BOND
4248 /* *** SET BONDING MODE *** */
4249 struct cmd_set_bonding_mode_result {
4250 cmdline_fixed_string_t set;
4251 cmdline_fixed_string_t bonding;
4252 cmdline_fixed_string_t mode;
4257 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4258 __attribute__((unused)) struct cmdline *cl,
4259 __attribute__((unused)) void *data)
4261 struct cmd_set_bonding_mode_result *res = parsed_result;
4262 portid_t port_id = res->port_id;
4264 /* Set the bonding mode for the relevant port. */
4265 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4266 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4269 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4270 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4272 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4273 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4274 bonding, "bonding");
4275 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4276 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4278 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4279 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4281 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4282 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4285 cmdline_parse_inst_t cmd_set_bonding_mode = {
4286 .f = cmd_set_bonding_mode_parsed,
4287 .help_str = "set bonding mode <mode_value> <port_id>: "
4288 "Set the bonding mode for port_id",
4291 (void *) &cmd_setbonding_mode_set,
4292 (void *) &cmd_setbonding_mode_bonding,
4293 (void *) &cmd_setbonding_mode_mode,
4294 (void *) &cmd_setbonding_mode_value,
4295 (void *) &cmd_setbonding_mode_port,
4300 /* *** SET BALANCE XMIT POLICY *** */
4301 struct cmd_set_bonding_balance_xmit_policy_result {
4302 cmdline_fixed_string_t set;
4303 cmdline_fixed_string_t bonding;
4304 cmdline_fixed_string_t balance_xmit_policy;
4306 cmdline_fixed_string_t policy;
4309 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4310 __attribute__((unused)) struct cmdline *cl,
4311 __attribute__((unused)) void *data)
4313 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4314 portid_t port_id = res->port_id;
4317 if (!strcmp(res->policy, "l2")) {
4318 policy = BALANCE_XMIT_POLICY_LAYER2;
4319 } else if (!strcmp(res->policy, "l23")) {
4320 policy = BALANCE_XMIT_POLICY_LAYER23;
4321 } else if (!strcmp(res->policy, "l34")) {
4322 policy = BALANCE_XMIT_POLICY_LAYER34;
4324 printf("\t Invalid xmit policy selection");
4328 /* Set the bonding mode for the relevant port. */
4329 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4330 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4335 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4336 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4338 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4339 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4340 bonding, "bonding");
4341 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4342 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4343 balance_xmit_policy, "balance_xmit_policy");
4344 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4345 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4347 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4348 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4349 policy, "l2#l23#l34");
4351 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4352 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4353 .help_str = "set bonding balance_xmit_policy <port_id> "
4355 "Set the bonding balance_xmit_policy for port_id",
4358 (void *)&cmd_setbonding_balance_xmit_policy_set,
4359 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4360 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4361 (void *)&cmd_setbonding_balance_xmit_policy_port,
4362 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4367 /* *** SHOW NIC BONDING CONFIGURATION *** */
4368 struct cmd_show_bonding_config_result {
4369 cmdline_fixed_string_t show;
4370 cmdline_fixed_string_t bonding;
4371 cmdline_fixed_string_t config;
4375 static void cmd_show_bonding_config_parsed(void *parsed_result,
4376 __attribute__((unused)) struct cmdline *cl,
4377 __attribute__((unused)) void *data)
4379 struct cmd_show_bonding_config_result *res = parsed_result;
4381 uint8_t slaves[RTE_MAX_ETHPORTS];
4382 int num_slaves, num_active_slaves;
4385 portid_t port_id = res->port_id;
4387 /* Display the bonding mode.*/
4388 bonding_mode = rte_eth_bond_mode_get(port_id);
4389 if (bonding_mode < 0) {
4390 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4393 printf("\tBonding mode: %d\n", bonding_mode);
4395 if (bonding_mode == BONDING_MODE_BALANCE) {
4396 int balance_xmit_policy;
4398 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4399 if (balance_xmit_policy < 0) {
4400 printf("\tFailed to get balance xmit policy for port = %d\n",
4404 printf("\tBalance Xmit Policy: ");
4406 switch (balance_xmit_policy) {
4407 case BALANCE_XMIT_POLICY_LAYER2:
4408 printf("BALANCE_XMIT_POLICY_LAYER2");
4410 case BALANCE_XMIT_POLICY_LAYER23:
4411 printf("BALANCE_XMIT_POLICY_LAYER23");
4413 case BALANCE_XMIT_POLICY_LAYER34:
4414 printf("BALANCE_XMIT_POLICY_LAYER34");
4421 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4423 if (num_slaves < 0) {
4424 printf("\tFailed to get slave list for port = %d\n", port_id);
4427 if (num_slaves > 0) {
4428 printf("\tSlaves (%d): [", num_slaves);
4429 for (i = 0; i < num_slaves - 1; i++)
4430 printf("%d ", slaves[i]);
4432 printf("%d]\n", slaves[num_slaves - 1]);
4434 printf("\tSlaves: []\n");
4438 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4441 if (num_active_slaves < 0) {
4442 printf("\tFailed to get active slave list for port = %d\n", port_id);
4445 if (num_active_slaves > 0) {
4446 printf("\tActive Slaves (%d): [", num_active_slaves);
4447 for (i = 0; i < num_active_slaves - 1; i++)
4448 printf("%d ", slaves[i]);
4450 printf("%d]\n", slaves[num_active_slaves - 1]);
4453 printf("\tActive Slaves: []\n");
4457 primary_id = rte_eth_bond_primary_get(port_id);
4458 if (primary_id < 0) {
4459 printf("\tFailed to get primary slave for port = %d\n", port_id);
4462 printf("\tPrimary: [%d]\n", primary_id);
4466 cmdline_parse_token_string_t cmd_showbonding_config_show =
4467 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4469 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4470 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4471 bonding, "bonding");
4472 cmdline_parse_token_string_t cmd_showbonding_config_config =
4473 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4475 cmdline_parse_token_num_t cmd_showbonding_config_port =
4476 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4479 cmdline_parse_inst_t cmd_show_bonding_config = {
4480 .f = cmd_show_bonding_config_parsed,
4481 .help_str = "show bonding config <port_id>: "
4482 "Show the bonding config for port_id",
4485 (void *)&cmd_showbonding_config_show,
4486 (void *)&cmd_showbonding_config_bonding,
4487 (void *)&cmd_showbonding_config_config,
4488 (void *)&cmd_showbonding_config_port,
4493 /* *** SET BONDING PRIMARY *** */
4494 struct cmd_set_bonding_primary_result {
4495 cmdline_fixed_string_t set;
4496 cmdline_fixed_string_t bonding;
4497 cmdline_fixed_string_t primary;
4502 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4503 __attribute__((unused)) struct cmdline *cl,
4504 __attribute__((unused)) void *data)
4506 struct cmd_set_bonding_primary_result *res = parsed_result;
4507 portid_t master_port_id = res->port_id;
4508 portid_t slave_port_id = res->slave_id;
4510 /* Set the primary slave for a bonded device. */
4511 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4512 printf("\t Failed to set primary slave for port = %d.\n",
4519 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4520 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4522 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4523 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4524 bonding, "bonding");
4525 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4526 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4527 primary, "primary");
4528 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4529 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4531 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4532 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4535 cmdline_parse_inst_t cmd_set_bonding_primary = {
4536 .f = cmd_set_bonding_primary_parsed,
4537 .help_str = "set bonding primary <slave_id> <port_id>: "
4538 "Set the primary slave for port_id",
4541 (void *)&cmd_setbonding_primary_set,
4542 (void *)&cmd_setbonding_primary_bonding,
4543 (void *)&cmd_setbonding_primary_primary,
4544 (void *)&cmd_setbonding_primary_slave,
4545 (void *)&cmd_setbonding_primary_port,
4550 /* *** ADD SLAVE *** */
4551 struct cmd_add_bonding_slave_result {
4552 cmdline_fixed_string_t add;
4553 cmdline_fixed_string_t bonding;
4554 cmdline_fixed_string_t slave;
4559 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4560 __attribute__((unused)) struct cmdline *cl,
4561 __attribute__((unused)) void *data)
4563 struct cmd_add_bonding_slave_result *res = parsed_result;
4564 portid_t master_port_id = res->port_id;
4565 portid_t slave_port_id = res->slave_id;
4567 /* Set the primary slave for a bonded device. */
4568 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4569 printf("\t Failed to add slave %d to master port = %d.\n",
4570 slave_port_id, master_port_id);
4574 set_port_slave_flag(slave_port_id);
4577 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4578 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4580 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4581 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4582 bonding, "bonding");
4583 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4584 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4586 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4587 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4589 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4590 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4593 cmdline_parse_inst_t cmd_add_bonding_slave = {
4594 .f = cmd_add_bonding_slave_parsed,
4595 .help_str = "add bonding slave <slave_id> <port_id>: "
4596 "Add a slave device to a bonded device",
4599 (void *)&cmd_addbonding_slave_add,
4600 (void *)&cmd_addbonding_slave_bonding,
4601 (void *)&cmd_addbonding_slave_slave,
4602 (void *)&cmd_addbonding_slave_slaveid,
4603 (void *)&cmd_addbonding_slave_port,
4608 /* *** REMOVE SLAVE *** */
4609 struct cmd_remove_bonding_slave_result {
4610 cmdline_fixed_string_t remove;
4611 cmdline_fixed_string_t bonding;
4612 cmdline_fixed_string_t slave;
4617 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4618 __attribute__((unused)) struct cmdline *cl,
4619 __attribute__((unused)) void *data)
4621 struct cmd_remove_bonding_slave_result *res = parsed_result;
4622 portid_t master_port_id = res->port_id;
4623 portid_t slave_port_id = res->slave_id;
4625 /* Set the primary slave for a bonded device. */
4626 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4627 printf("\t Failed to remove slave %d from master port = %d.\n",
4628 slave_port_id, master_port_id);
4632 clear_port_slave_flag(slave_port_id);
4635 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4636 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4638 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4639 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4640 bonding, "bonding");
4641 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4642 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4644 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4645 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4647 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4648 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4651 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4652 .f = cmd_remove_bonding_slave_parsed,
4653 .help_str = "remove bonding slave <slave_id> <port_id>: "
4654 "Remove a slave device from a bonded device",
4657 (void *)&cmd_removebonding_slave_remove,
4658 (void *)&cmd_removebonding_slave_bonding,
4659 (void *)&cmd_removebonding_slave_slave,
4660 (void *)&cmd_removebonding_slave_slaveid,
4661 (void *)&cmd_removebonding_slave_port,
4666 /* *** CREATE BONDED DEVICE *** */
4667 struct cmd_create_bonded_device_result {
4668 cmdline_fixed_string_t create;
4669 cmdline_fixed_string_t bonded;
4670 cmdline_fixed_string_t device;
4675 static int bond_dev_num = 0;
4677 static void cmd_create_bonded_device_parsed(void *parsed_result,
4678 __attribute__((unused)) struct cmdline *cl,
4679 __attribute__((unused)) void *data)
4681 struct cmd_create_bonded_device_result *res = parsed_result;
4682 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4685 if (test_done == 0) {
4686 printf("Please stop forwarding first\n");
4690 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4693 /* Create a new bonded device. */
4694 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4696 printf("\t Failed to create bonded device.\n");
4699 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4702 /* Update number of ports */
4703 nb_ports = rte_eth_dev_count();
4704 reconfig(port_id, res->socket);
4705 rte_eth_promiscuous_enable(port_id);
4710 cmdline_parse_token_string_t cmd_createbonded_device_create =
4711 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4713 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4714 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4716 cmdline_parse_token_string_t cmd_createbonded_device_device =
4717 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4719 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4720 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4722 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4723 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4726 cmdline_parse_inst_t cmd_create_bonded_device = {
4727 .f = cmd_create_bonded_device_parsed,
4728 .help_str = "create bonded device <mode> <socket>: "
4729 "Create a new bonded device with specific bonding mode and socket",
4732 (void *)&cmd_createbonded_device_create,
4733 (void *)&cmd_createbonded_device_bonded,
4734 (void *)&cmd_createbonded_device_device,
4735 (void *)&cmd_createbonded_device_mode,
4736 (void *)&cmd_createbonded_device_socket,
4741 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4742 struct cmd_set_bond_mac_addr_result {
4743 cmdline_fixed_string_t set;
4744 cmdline_fixed_string_t bonding;
4745 cmdline_fixed_string_t mac_addr;
4747 struct ether_addr address;
4750 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4751 __attribute__((unused)) struct cmdline *cl,
4752 __attribute__((unused)) void *data)
4754 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4757 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4760 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4762 /* check the return value and print it if is < 0 */
4764 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4767 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4768 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4769 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4770 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4772 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4773 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4775 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4776 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4777 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4778 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4780 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4781 .f = cmd_set_bond_mac_addr_parsed,
4783 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4785 (void *)&cmd_set_bond_mac_addr_set,
4786 (void *)&cmd_set_bond_mac_addr_bonding,
4787 (void *)&cmd_set_bond_mac_addr_mac,
4788 (void *)&cmd_set_bond_mac_addr_portnum,
4789 (void *)&cmd_set_bond_mac_addr_addr,
4795 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4796 struct cmd_set_bond_mon_period_result {
4797 cmdline_fixed_string_t set;
4798 cmdline_fixed_string_t bonding;
4799 cmdline_fixed_string_t mon_period;
4804 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4805 __attribute__((unused)) struct cmdline *cl,
4806 __attribute__((unused)) void *data)
4808 struct cmd_set_bond_mon_period_result *res = parsed_result;
4811 if (res->port_num >= nb_ports) {
4812 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4816 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4818 /* check the return value and print it if is < 0 */
4820 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4823 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4824 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4826 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4827 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4828 bonding, "bonding");
4829 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4830 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4831 mon_period, "mon_period");
4832 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4833 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4835 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4836 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4839 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4840 .f = cmd_set_bond_mon_period_parsed,
4842 .help_str = "set bonding mon_period <port_id> <period_ms>",
4844 (void *)&cmd_set_bond_mon_period_set,
4845 (void *)&cmd_set_bond_mon_period_bonding,
4846 (void *)&cmd_set_bond_mon_period_mon_period,
4847 (void *)&cmd_set_bond_mon_period_portnum,
4848 (void *)&cmd_set_bond_mon_period_period_ms,
4853 #endif /* RTE_LIBRTE_PMD_BOND */
4855 /* *** SET FORWARDING MODE *** */
4856 struct cmd_set_fwd_mode_result {
4857 cmdline_fixed_string_t set;
4858 cmdline_fixed_string_t fwd;
4859 cmdline_fixed_string_t mode;
4862 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4863 __attribute__((unused)) struct cmdline *cl,
4864 __attribute__((unused)) void *data)
4866 struct cmd_set_fwd_mode_result *res = parsed_result;
4869 set_pkt_forwarding_mode(res->mode);
4872 cmdline_parse_token_string_t cmd_setfwd_set =
4873 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4874 cmdline_parse_token_string_t cmd_setfwd_fwd =
4875 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4876 cmdline_parse_token_string_t cmd_setfwd_mode =
4877 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4878 "" /* defined at init */);
4880 cmdline_parse_inst_t cmd_set_fwd_mode = {
4881 .f = cmd_set_fwd_mode_parsed,
4883 .help_str = NULL, /* defined at init */
4885 (void *)&cmd_setfwd_set,
4886 (void *)&cmd_setfwd_fwd,
4887 (void *)&cmd_setfwd_mode,
4892 static void cmd_set_fwd_mode_init(void)
4895 static char token[128];
4896 static char help[256];
4897 cmdline_parse_token_string_t *token_struct;
4899 modes = list_pkt_forwarding_modes();
4900 snprintf(help, sizeof(help), "set fwd %s: "
4901 "Set packet forwarding mode", modes);
4902 cmd_set_fwd_mode.help_str = help;
4904 /* string token separator is # */
4905 for (c = token; *modes != '\0'; modes++)
4910 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4911 token_struct->string_data.str = token;
4914 /* *** SET RETRY FORWARDING MODE *** */
4915 struct cmd_set_fwd_retry_mode_result {
4916 cmdline_fixed_string_t set;
4917 cmdline_fixed_string_t fwd;
4918 cmdline_fixed_string_t mode;
4919 cmdline_fixed_string_t retry;
4922 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4923 __attribute__((unused)) struct cmdline *cl,
4924 __attribute__((unused)) void *data)
4926 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4929 set_pkt_forwarding_mode(res->mode);
4932 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4933 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4935 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4936 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4938 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4939 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4941 "" /* defined at init */);
4942 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4943 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4946 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4947 .f = cmd_set_fwd_retry_mode_parsed,
4949 .help_str = NULL, /* defined at init */
4951 (void *)&cmd_setfwd_retry_set,
4952 (void *)&cmd_setfwd_retry_fwd,
4953 (void *)&cmd_setfwd_retry_mode,
4954 (void *)&cmd_setfwd_retry_retry,
4959 static void cmd_set_fwd_retry_mode_init(void)
4962 static char token[128];
4963 static char help[256];
4964 cmdline_parse_token_string_t *token_struct;
4966 modes = list_pkt_forwarding_retry_modes();
4967 snprintf(help, sizeof(help), "set fwd %s retry: "
4968 "Set packet forwarding mode with retry", modes);
4969 cmd_set_fwd_retry_mode.help_str = help;
4971 /* string token separator is # */
4972 for (c = token; *modes != '\0'; modes++)
4977 token_struct = (cmdline_parse_token_string_t *)
4978 cmd_set_fwd_retry_mode.tokens[2];
4979 token_struct->string_data.str = token;
4982 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4983 struct cmd_set_burst_tx_retry_result {
4984 cmdline_fixed_string_t set;
4985 cmdline_fixed_string_t burst;
4986 cmdline_fixed_string_t tx;
4987 cmdline_fixed_string_t delay;
4989 cmdline_fixed_string_t retry;
4993 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4994 __attribute__((unused)) struct cmdline *cl,
4995 __attribute__((unused)) void *data)
4997 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4999 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5000 && !strcmp(res->tx, "tx")) {
5001 if (!strcmp(res->delay, "delay"))
5002 burst_tx_delay_time = res->time;
5003 if (!strcmp(res->retry, "retry"))
5004 burst_tx_retry_num = res->retry_num;
5009 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5010 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5011 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5012 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5014 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5015 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5016 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5017 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5018 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5019 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5020 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5021 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5022 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5023 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5025 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5026 .f = cmd_set_burst_tx_retry_parsed,
5027 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5029 (void *)&cmd_set_burst_tx_retry_set,
5030 (void *)&cmd_set_burst_tx_retry_burst,
5031 (void *)&cmd_set_burst_tx_retry_tx,
5032 (void *)&cmd_set_burst_tx_retry_delay,
5033 (void *)&cmd_set_burst_tx_retry_time,
5034 (void *)&cmd_set_burst_tx_retry_retry,
5035 (void *)&cmd_set_burst_tx_retry_retry_num,
5040 /* *** SET PROMISC MODE *** */
5041 struct cmd_set_promisc_mode_result {
5042 cmdline_fixed_string_t set;
5043 cmdline_fixed_string_t promisc;
5044 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5045 uint8_t port_num; /* valid if "allports" argument == 0 */
5046 cmdline_fixed_string_t mode;
5049 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5050 __attribute__((unused)) struct cmdline *cl,
5053 struct cmd_set_promisc_mode_result *res = parsed_result;
5057 if (!strcmp(res->mode, "on"))
5064 RTE_ETH_FOREACH_DEV(i) {
5066 rte_eth_promiscuous_enable(i);
5068 rte_eth_promiscuous_disable(i);
5073 rte_eth_promiscuous_enable(res->port_num);
5075 rte_eth_promiscuous_disable(res->port_num);
5079 cmdline_parse_token_string_t cmd_setpromisc_set =
5080 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5081 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5082 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5084 cmdline_parse_token_string_t cmd_setpromisc_portall =
5085 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5087 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5088 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5090 cmdline_parse_token_string_t cmd_setpromisc_mode =
5091 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5094 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5095 .f = cmd_set_promisc_mode_parsed,
5097 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5099 (void *)&cmd_setpromisc_set,
5100 (void *)&cmd_setpromisc_promisc,
5101 (void *)&cmd_setpromisc_portall,
5102 (void *)&cmd_setpromisc_mode,
5107 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5108 .f = cmd_set_promisc_mode_parsed,
5110 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5112 (void *)&cmd_setpromisc_set,
5113 (void *)&cmd_setpromisc_promisc,
5114 (void *)&cmd_setpromisc_portnum,
5115 (void *)&cmd_setpromisc_mode,
5120 /* *** SET ALLMULTI MODE *** */
5121 struct cmd_set_allmulti_mode_result {
5122 cmdline_fixed_string_t set;
5123 cmdline_fixed_string_t allmulti;
5124 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5125 uint8_t port_num; /* valid if "allports" argument == 0 */
5126 cmdline_fixed_string_t mode;
5129 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5130 __attribute__((unused)) struct cmdline *cl,
5133 struct cmd_set_allmulti_mode_result *res = parsed_result;
5137 if (!strcmp(res->mode, "on"))
5144 RTE_ETH_FOREACH_DEV(i) {
5146 rte_eth_allmulticast_enable(i);
5148 rte_eth_allmulticast_disable(i);
5153 rte_eth_allmulticast_enable(res->port_num);
5155 rte_eth_allmulticast_disable(res->port_num);
5159 cmdline_parse_token_string_t cmd_setallmulti_set =
5160 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5161 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5162 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5164 cmdline_parse_token_string_t cmd_setallmulti_portall =
5165 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5167 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5168 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5170 cmdline_parse_token_string_t cmd_setallmulti_mode =
5171 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5174 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5175 .f = cmd_set_allmulti_mode_parsed,
5177 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5179 (void *)&cmd_setallmulti_set,
5180 (void *)&cmd_setallmulti_allmulti,
5181 (void *)&cmd_setallmulti_portall,
5182 (void *)&cmd_setallmulti_mode,
5187 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5188 .f = cmd_set_allmulti_mode_parsed,
5190 .help_str = "set allmulti <port_id> on|off: "
5191 "Set allmulti mode on port_id",
5193 (void *)&cmd_setallmulti_set,
5194 (void *)&cmd_setallmulti_allmulti,
5195 (void *)&cmd_setallmulti_portnum,
5196 (void *)&cmd_setallmulti_mode,
5201 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5202 struct cmd_link_flow_ctrl_set_result {
5203 cmdline_fixed_string_t set;
5204 cmdline_fixed_string_t flow_ctrl;
5205 cmdline_fixed_string_t rx;
5206 cmdline_fixed_string_t rx_lfc_mode;
5207 cmdline_fixed_string_t tx;
5208 cmdline_fixed_string_t tx_lfc_mode;
5209 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5210 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5211 cmdline_fixed_string_t autoneg_str;
5212 cmdline_fixed_string_t autoneg;
5213 cmdline_fixed_string_t hw_str;
5214 uint32_t high_water;
5215 cmdline_fixed_string_t lw_str;
5217 cmdline_fixed_string_t pt_str;
5218 uint16_t pause_time;
5219 cmdline_fixed_string_t xon_str;
5224 cmdline_parse_token_string_t cmd_lfc_set_set =
5225 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5227 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5228 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5229 flow_ctrl, "flow_ctrl");
5230 cmdline_parse_token_string_t cmd_lfc_set_rx =
5231 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5233 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5234 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5235 rx_lfc_mode, "on#off");
5236 cmdline_parse_token_string_t cmd_lfc_set_tx =
5237 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5239 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5240 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5241 tx_lfc_mode, "on#off");
5242 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5243 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5244 hw_str, "high_water");
5245 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5246 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5247 high_water, UINT32);
5248 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5249 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5250 lw_str, "low_water");
5251 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5252 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5254 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5255 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5256 pt_str, "pause_time");
5257 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5258 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5259 pause_time, UINT16);
5260 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5261 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5262 xon_str, "send_xon");
5263 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5264 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5266 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5267 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5268 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5269 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5270 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5271 mac_ctrl_frame_fwd_mode, "on#off");
5272 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5273 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5274 autoneg_str, "autoneg");
5275 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5276 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5278 cmdline_parse_token_num_t cmd_lfc_set_portid =
5279 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5282 /* forward declaration */
5284 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5287 cmdline_parse_inst_t cmd_link_flow_control_set = {
5288 .f = cmd_link_flow_ctrl_set_parsed,
5290 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5291 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5292 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5294 (void *)&cmd_lfc_set_set,
5295 (void *)&cmd_lfc_set_flow_ctrl,
5296 (void *)&cmd_lfc_set_rx,
5297 (void *)&cmd_lfc_set_rx_mode,
5298 (void *)&cmd_lfc_set_tx,
5299 (void *)&cmd_lfc_set_tx_mode,
5300 (void *)&cmd_lfc_set_high_water,
5301 (void *)&cmd_lfc_set_low_water,
5302 (void *)&cmd_lfc_set_pause_time,
5303 (void *)&cmd_lfc_set_send_xon,
5304 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5305 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5306 (void *)&cmd_lfc_set_autoneg_str,
5307 (void *)&cmd_lfc_set_autoneg,
5308 (void *)&cmd_lfc_set_portid,
5313 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5314 .f = cmd_link_flow_ctrl_set_parsed,
5315 .data = (void *)&cmd_link_flow_control_set_rx,
5316 .help_str = "set flow_ctrl rx on|off <port_id>: "
5317 "Change rx flow control parameter",
5319 (void *)&cmd_lfc_set_set,
5320 (void *)&cmd_lfc_set_flow_ctrl,
5321 (void *)&cmd_lfc_set_rx,
5322 (void *)&cmd_lfc_set_rx_mode,
5323 (void *)&cmd_lfc_set_portid,
5328 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5329 .f = cmd_link_flow_ctrl_set_parsed,
5330 .data = (void *)&cmd_link_flow_control_set_tx,
5331 .help_str = "set flow_ctrl tx on|off <port_id>: "
5332 "Change tx flow control parameter",
5334 (void *)&cmd_lfc_set_set,
5335 (void *)&cmd_lfc_set_flow_ctrl,
5336 (void *)&cmd_lfc_set_tx,
5337 (void *)&cmd_lfc_set_tx_mode,
5338 (void *)&cmd_lfc_set_portid,
5343 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5344 .f = cmd_link_flow_ctrl_set_parsed,
5345 .data = (void *)&cmd_link_flow_control_set_hw,
5346 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5347 "Change high water flow control parameter",
5349 (void *)&cmd_lfc_set_set,
5350 (void *)&cmd_lfc_set_flow_ctrl,
5351 (void *)&cmd_lfc_set_high_water_str,
5352 (void *)&cmd_lfc_set_high_water,
5353 (void *)&cmd_lfc_set_portid,
5358 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5359 .f = cmd_link_flow_ctrl_set_parsed,
5360 .data = (void *)&cmd_link_flow_control_set_lw,
5361 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5362 "Change low water flow control parameter",
5364 (void *)&cmd_lfc_set_set,
5365 (void *)&cmd_lfc_set_flow_ctrl,
5366 (void *)&cmd_lfc_set_low_water_str,
5367 (void *)&cmd_lfc_set_low_water,
5368 (void *)&cmd_lfc_set_portid,
5373 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5374 .f = cmd_link_flow_ctrl_set_parsed,
5375 .data = (void *)&cmd_link_flow_control_set_pt,
5376 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5377 "Change pause time flow control parameter",
5379 (void *)&cmd_lfc_set_set,
5380 (void *)&cmd_lfc_set_flow_ctrl,
5381 (void *)&cmd_lfc_set_pause_time_str,
5382 (void *)&cmd_lfc_set_pause_time,
5383 (void *)&cmd_lfc_set_portid,
5388 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5389 .f = cmd_link_flow_ctrl_set_parsed,
5390 .data = (void *)&cmd_link_flow_control_set_xon,
5391 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5392 "Change send_xon flow control parameter",
5394 (void *)&cmd_lfc_set_set,
5395 (void *)&cmd_lfc_set_flow_ctrl,
5396 (void *)&cmd_lfc_set_send_xon_str,
5397 (void *)&cmd_lfc_set_send_xon,
5398 (void *)&cmd_lfc_set_portid,
5403 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5404 .f = cmd_link_flow_ctrl_set_parsed,
5405 .data = (void *)&cmd_link_flow_control_set_macfwd,
5406 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5407 "Change mac ctrl fwd flow control parameter",
5409 (void *)&cmd_lfc_set_set,
5410 (void *)&cmd_lfc_set_flow_ctrl,
5411 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5412 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5413 (void *)&cmd_lfc_set_portid,
5418 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5419 .f = cmd_link_flow_ctrl_set_parsed,
5420 .data = (void *)&cmd_link_flow_control_set_autoneg,
5421 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5422 "Change autoneg flow control parameter",
5424 (void *)&cmd_lfc_set_set,
5425 (void *)&cmd_lfc_set_flow_ctrl,
5426 (void *)&cmd_lfc_set_autoneg_str,
5427 (void *)&cmd_lfc_set_autoneg,
5428 (void *)&cmd_lfc_set_portid,
5434 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5435 __attribute__((unused)) struct cmdline *cl,
5438 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5439 cmdline_parse_inst_t *cmd = data;
5440 struct rte_eth_fc_conf fc_conf;
5446 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5447 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5448 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5449 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5451 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5452 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5455 /* Partial command line, retrieve current configuration */
5457 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5459 printf("cannot get current flow ctrl parameters, return"
5460 "code = %d\n", ret);
5464 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5465 (fc_conf.mode == RTE_FC_FULL))
5467 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5468 (fc_conf.mode == RTE_FC_FULL))
5472 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5473 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5475 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5476 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5478 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5480 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5481 fc_conf.high_water = res->high_water;
5483 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5484 fc_conf.low_water = res->low_water;
5486 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5487 fc_conf.pause_time = res->pause_time;
5489 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5490 fc_conf.send_xon = res->send_xon;
5492 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5493 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5494 fc_conf.mac_ctrl_frame_fwd = 1;
5496 fc_conf.mac_ctrl_frame_fwd = 0;
5499 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5500 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5502 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5504 printf("bad flow contrl parameter, return code = %d \n", ret);
5507 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5508 struct cmd_priority_flow_ctrl_set_result {
5509 cmdline_fixed_string_t set;
5510 cmdline_fixed_string_t pfc_ctrl;
5511 cmdline_fixed_string_t rx;
5512 cmdline_fixed_string_t rx_pfc_mode;
5513 cmdline_fixed_string_t tx;
5514 cmdline_fixed_string_t tx_pfc_mode;
5515 uint32_t high_water;
5517 uint16_t pause_time;
5523 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5524 __attribute__((unused)) struct cmdline *cl,
5525 __attribute__((unused)) void *data)
5527 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5528 struct rte_eth_pfc_conf pfc_conf;
5529 int rx_fc_enable, tx_fc_enable;
5533 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5534 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5535 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5536 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5538 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5539 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5542 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5543 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5544 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5545 pfc_conf.fc.high_water = res->high_water;
5546 pfc_conf.fc.low_water = res->low_water;
5547 pfc_conf.fc.pause_time = res->pause_time;
5548 pfc_conf.priority = res->priority;
5550 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5552 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5555 cmdline_parse_token_string_t cmd_pfc_set_set =
5556 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5558 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5559 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5560 pfc_ctrl, "pfc_ctrl");
5561 cmdline_parse_token_string_t cmd_pfc_set_rx =
5562 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5564 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5565 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5566 rx_pfc_mode, "on#off");
5567 cmdline_parse_token_string_t cmd_pfc_set_tx =
5568 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5570 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5571 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5572 tx_pfc_mode, "on#off");
5573 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5574 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5575 high_water, UINT32);
5576 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5577 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5579 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5580 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5581 pause_time, UINT16);
5582 cmdline_parse_token_num_t cmd_pfc_set_priority =
5583 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5585 cmdline_parse_token_num_t cmd_pfc_set_portid =
5586 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5589 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5590 .f = cmd_priority_flow_ctrl_set_parsed,
5592 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5593 "<pause_time> <priority> <port_id>: "
5594 "Configure the Ethernet priority flow control",
5596 (void *)&cmd_pfc_set_set,
5597 (void *)&cmd_pfc_set_flow_ctrl,
5598 (void *)&cmd_pfc_set_rx,
5599 (void *)&cmd_pfc_set_rx_mode,
5600 (void *)&cmd_pfc_set_tx,
5601 (void *)&cmd_pfc_set_tx_mode,
5602 (void *)&cmd_pfc_set_high_water,
5603 (void *)&cmd_pfc_set_low_water,
5604 (void *)&cmd_pfc_set_pause_time,
5605 (void *)&cmd_pfc_set_priority,
5606 (void *)&cmd_pfc_set_portid,
5611 /* *** RESET CONFIGURATION *** */
5612 struct cmd_reset_result {
5613 cmdline_fixed_string_t reset;
5614 cmdline_fixed_string_t def;
5617 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5619 __attribute__((unused)) void *data)
5621 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5622 set_def_fwd_config();
5625 cmdline_parse_token_string_t cmd_reset_set =
5626 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5627 cmdline_parse_token_string_t cmd_reset_def =
5628 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5631 cmdline_parse_inst_t cmd_reset = {
5632 .f = cmd_reset_parsed,
5634 .help_str = "set default: Reset default forwarding configuration",
5636 (void *)&cmd_reset_set,
5637 (void *)&cmd_reset_def,
5642 /* *** START FORWARDING *** */
5643 struct cmd_start_result {
5644 cmdline_fixed_string_t start;
5647 cmdline_parse_token_string_t cmd_start_start =
5648 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5650 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5651 __attribute__((unused)) struct cmdline *cl,
5652 __attribute__((unused)) void *data)
5654 start_packet_forwarding(0);
5657 cmdline_parse_inst_t cmd_start = {
5658 .f = cmd_start_parsed,
5660 .help_str = "start: Start packet forwarding",
5662 (void *)&cmd_start_start,
5667 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5668 struct cmd_start_tx_first_result {
5669 cmdline_fixed_string_t start;
5670 cmdline_fixed_string_t tx_first;
5674 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5675 __attribute__((unused)) struct cmdline *cl,
5676 __attribute__((unused)) void *data)
5678 start_packet_forwarding(1);
5681 cmdline_parse_token_string_t cmd_start_tx_first_start =
5682 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5684 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5685 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5686 tx_first, "tx_first");
5688 cmdline_parse_inst_t cmd_start_tx_first = {
5689 .f = cmd_start_tx_first_parsed,
5691 .help_str = "start tx_first: Start packet forwarding, "
5692 "after sending 1 burst of packets",
5694 (void *)&cmd_start_tx_first_start,
5695 (void *)&cmd_start_tx_first_tx_first,
5700 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5701 struct cmd_start_tx_first_n_result {
5702 cmdline_fixed_string_t start;
5703 cmdline_fixed_string_t tx_first;
5708 cmd_start_tx_first_n_parsed(void *parsed_result,
5709 __attribute__((unused)) struct cmdline *cl,
5710 __attribute__((unused)) void *data)
5712 struct cmd_start_tx_first_n_result *res = parsed_result;
5714 start_packet_forwarding(res->tx_num);
5717 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5718 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5720 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5721 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5722 tx_first, "tx_first");
5723 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5724 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5727 cmdline_parse_inst_t cmd_start_tx_first_n = {
5728 .f = cmd_start_tx_first_n_parsed,
5730 .help_str = "start tx_first <num>: "
5731 "packet forwarding, after sending <num> bursts of packets",
5733 (void *)&cmd_start_tx_first_n_start,
5734 (void *)&cmd_start_tx_first_n_tx_first,
5735 (void *)&cmd_start_tx_first_n_tx_num,
5740 /* *** SET LINK UP *** */
5741 struct cmd_set_link_up_result {
5742 cmdline_fixed_string_t set;
5743 cmdline_fixed_string_t link_up;
5744 cmdline_fixed_string_t port;
5748 cmdline_parse_token_string_t cmd_set_link_up_set =
5749 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5750 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5753 cmdline_parse_token_string_t cmd_set_link_up_port =
5754 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5755 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5756 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5758 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5759 __attribute__((unused)) struct cmdline *cl,
5760 __attribute__((unused)) void *data)
5762 struct cmd_set_link_up_result *res = parsed_result;
5763 dev_set_link_up(res->port_id);
5766 cmdline_parse_inst_t cmd_set_link_up = {
5767 .f = cmd_set_link_up_parsed,
5769 .help_str = "set link-up port <port id>",
5771 (void *)&cmd_set_link_up_set,
5772 (void *)&cmd_set_link_up_link_up,
5773 (void *)&cmd_set_link_up_port,
5774 (void *)&cmd_set_link_up_port_id,
5779 /* *** SET LINK DOWN *** */
5780 struct cmd_set_link_down_result {
5781 cmdline_fixed_string_t set;
5782 cmdline_fixed_string_t link_down;
5783 cmdline_fixed_string_t port;
5787 cmdline_parse_token_string_t cmd_set_link_down_set =
5788 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5789 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5790 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5792 cmdline_parse_token_string_t cmd_set_link_down_port =
5793 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5794 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5795 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5797 static void cmd_set_link_down_parsed(
5798 __attribute__((unused)) void *parsed_result,
5799 __attribute__((unused)) struct cmdline *cl,
5800 __attribute__((unused)) void *data)
5802 struct cmd_set_link_down_result *res = parsed_result;
5803 dev_set_link_down(res->port_id);
5806 cmdline_parse_inst_t cmd_set_link_down = {
5807 .f = cmd_set_link_down_parsed,
5809 .help_str = "set link-down port <port id>",
5811 (void *)&cmd_set_link_down_set,
5812 (void *)&cmd_set_link_down_link_down,
5813 (void *)&cmd_set_link_down_port,
5814 (void *)&cmd_set_link_down_port_id,
5819 /* *** SHOW CFG *** */
5820 struct cmd_showcfg_result {
5821 cmdline_fixed_string_t show;
5822 cmdline_fixed_string_t cfg;
5823 cmdline_fixed_string_t what;
5826 static void cmd_showcfg_parsed(void *parsed_result,
5827 __attribute__((unused)) struct cmdline *cl,
5828 __attribute__((unused)) void *data)
5830 struct cmd_showcfg_result *res = parsed_result;
5831 if (!strcmp(res->what, "rxtx"))
5832 rxtx_config_display();
5833 else if (!strcmp(res->what, "cores"))
5834 fwd_lcores_config_display();
5835 else if (!strcmp(res->what, "fwd"))
5836 pkt_fwd_config_display(&cur_fwd_config);
5837 else if (!strcmp(res->what, "txpkts"))
5838 show_tx_pkt_segments();
5841 cmdline_parse_token_string_t cmd_showcfg_show =
5842 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5843 cmdline_parse_token_string_t cmd_showcfg_port =
5844 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5845 cmdline_parse_token_string_t cmd_showcfg_what =
5846 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5847 "rxtx#cores#fwd#txpkts");
5849 cmdline_parse_inst_t cmd_showcfg = {
5850 .f = cmd_showcfg_parsed,
5852 .help_str = "show config rxtx|cores|fwd|txpkts",
5854 (void *)&cmd_showcfg_show,
5855 (void *)&cmd_showcfg_port,
5856 (void *)&cmd_showcfg_what,
5861 /* *** SHOW ALL PORT INFO *** */
5862 struct cmd_showportall_result {
5863 cmdline_fixed_string_t show;
5864 cmdline_fixed_string_t port;
5865 cmdline_fixed_string_t what;
5866 cmdline_fixed_string_t all;
5869 static void cmd_showportall_parsed(void *parsed_result,
5870 __attribute__((unused)) struct cmdline *cl,
5871 __attribute__((unused)) void *data)
5875 struct cmd_showportall_result *res = parsed_result;
5876 if (!strcmp(res->show, "clear")) {
5877 if (!strcmp(res->what, "stats"))
5878 RTE_ETH_FOREACH_DEV(i)
5880 else if (!strcmp(res->what, "xstats"))
5881 RTE_ETH_FOREACH_DEV(i)
5882 nic_xstats_clear(i);
5883 } else if (!strcmp(res->what, "info"))
5884 RTE_ETH_FOREACH_DEV(i)
5885 port_infos_display(i);
5886 else if (!strcmp(res->what, "stats"))
5887 RTE_ETH_FOREACH_DEV(i)
5888 nic_stats_display(i);
5889 else if (!strcmp(res->what, "xstats"))
5890 RTE_ETH_FOREACH_DEV(i)
5891 nic_xstats_display(i);
5892 else if (!strcmp(res->what, "fdir"))
5893 RTE_ETH_FOREACH_DEV(i)
5895 else if (!strcmp(res->what, "stat_qmap"))
5896 RTE_ETH_FOREACH_DEV(i)
5897 nic_stats_mapping_display(i);
5898 else if (!strcmp(res->what, "dcb_tc"))
5899 RTE_ETH_FOREACH_DEV(i)
5900 port_dcb_info_display(i);
5901 else if (!strcmp(res->what, "cap"))
5902 RTE_ETH_FOREACH_DEV(i)
5903 port_offload_cap_display(i);
5906 cmdline_parse_token_string_t cmd_showportall_show =
5907 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5909 cmdline_parse_token_string_t cmd_showportall_port =
5910 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5911 cmdline_parse_token_string_t cmd_showportall_what =
5912 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5913 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5914 cmdline_parse_token_string_t cmd_showportall_all =
5915 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5916 cmdline_parse_inst_t cmd_showportall = {
5917 .f = cmd_showportall_parsed,
5919 .help_str = "show|clear port "
5920 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5922 (void *)&cmd_showportall_show,
5923 (void *)&cmd_showportall_port,
5924 (void *)&cmd_showportall_what,
5925 (void *)&cmd_showportall_all,
5930 /* *** SHOW PORT INFO *** */
5931 struct cmd_showport_result {
5932 cmdline_fixed_string_t show;
5933 cmdline_fixed_string_t port;
5934 cmdline_fixed_string_t what;
5938 static void cmd_showport_parsed(void *parsed_result,
5939 __attribute__((unused)) struct cmdline *cl,
5940 __attribute__((unused)) void *data)
5942 struct cmd_showport_result *res = parsed_result;
5943 if (!strcmp(res->show, "clear")) {
5944 if (!strcmp(res->what, "stats"))
5945 nic_stats_clear(res->portnum);
5946 else if (!strcmp(res->what, "xstats"))
5947 nic_xstats_clear(res->portnum);
5948 } else if (!strcmp(res->what, "info"))
5949 port_infos_display(res->portnum);
5950 else if (!strcmp(res->what, "stats"))
5951 nic_stats_display(res->portnum);
5952 else if (!strcmp(res->what, "xstats"))
5953 nic_xstats_display(res->portnum);
5954 else if (!strcmp(res->what, "fdir"))
5955 fdir_get_infos(res->portnum);
5956 else if (!strcmp(res->what, "stat_qmap"))
5957 nic_stats_mapping_display(res->portnum);
5958 else if (!strcmp(res->what, "dcb_tc"))
5959 port_dcb_info_display(res->portnum);
5960 else if (!strcmp(res->what, "cap"))
5961 port_offload_cap_display(res->portnum);
5964 cmdline_parse_token_string_t cmd_showport_show =
5965 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5967 cmdline_parse_token_string_t cmd_showport_port =
5968 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5969 cmdline_parse_token_string_t cmd_showport_what =
5970 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5971 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5972 cmdline_parse_token_num_t cmd_showport_portnum =
5973 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5975 cmdline_parse_inst_t cmd_showport = {
5976 .f = cmd_showport_parsed,
5978 .help_str = "show|clear port "
5979 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5982 (void *)&cmd_showport_show,
5983 (void *)&cmd_showport_port,
5984 (void *)&cmd_showport_what,
5985 (void *)&cmd_showport_portnum,
5990 /* *** SHOW QUEUE INFO *** */
5991 struct cmd_showqueue_result {
5992 cmdline_fixed_string_t show;
5993 cmdline_fixed_string_t type;
5994 cmdline_fixed_string_t what;
6000 cmd_showqueue_parsed(void *parsed_result,
6001 __attribute__((unused)) struct cmdline *cl,
6002 __attribute__((unused)) void *data)
6004 struct cmd_showqueue_result *res = parsed_result;
6006 if (!strcmp(res->type, "rxq"))
6007 rx_queue_infos_display(res->portnum, res->queuenum);
6008 else if (!strcmp(res->type, "txq"))
6009 tx_queue_infos_display(res->portnum, res->queuenum);
6012 cmdline_parse_token_string_t cmd_showqueue_show =
6013 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6014 cmdline_parse_token_string_t cmd_showqueue_type =
6015 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6016 cmdline_parse_token_string_t cmd_showqueue_what =
6017 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6018 cmdline_parse_token_num_t cmd_showqueue_portnum =
6019 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6020 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6021 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6023 cmdline_parse_inst_t cmd_showqueue = {
6024 .f = cmd_showqueue_parsed,
6026 .help_str = "show rxq|txq info <port_id> <queue_id>",
6028 (void *)&cmd_showqueue_show,
6029 (void *)&cmd_showqueue_type,
6030 (void *)&cmd_showqueue_what,
6031 (void *)&cmd_showqueue_portnum,
6032 (void *)&cmd_showqueue_queuenum,
6037 /* *** READ PORT REGISTER *** */
6038 struct cmd_read_reg_result {
6039 cmdline_fixed_string_t read;
6040 cmdline_fixed_string_t reg;
6046 cmd_read_reg_parsed(void *parsed_result,
6047 __attribute__((unused)) struct cmdline *cl,
6048 __attribute__((unused)) void *data)
6050 struct cmd_read_reg_result *res = parsed_result;
6051 port_reg_display(res->port_id, res->reg_off);
6054 cmdline_parse_token_string_t cmd_read_reg_read =
6055 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6056 cmdline_parse_token_string_t cmd_read_reg_reg =
6057 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6058 cmdline_parse_token_num_t cmd_read_reg_port_id =
6059 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6060 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6061 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6063 cmdline_parse_inst_t cmd_read_reg = {
6064 .f = cmd_read_reg_parsed,
6066 .help_str = "read reg <port_id> <reg_off>",
6068 (void *)&cmd_read_reg_read,
6069 (void *)&cmd_read_reg_reg,
6070 (void *)&cmd_read_reg_port_id,
6071 (void *)&cmd_read_reg_reg_off,
6076 /* *** READ PORT REGISTER BIT FIELD *** */
6077 struct cmd_read_reg_bit_field_result {
6078 cmdline_fixed_string_t read;
6079 cmdline_fixed_string_t regfield;
6087 cmd_read_reg_bit_field_parsed(void *parsed_result,
6088 __attribute__((unused)) struct cmdline *cl,
6089 __attribute__((unused)) void *data)
6091 struct cmd_read_reg_bit_field_result *res = parsed_result;
6092 port_reg_bit_field_display(res->port_id, res->reg_off,
6093 res->bit1_pos, res->bit2_pos);
6096 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6097 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6099 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6100 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6101 regfield, "regfield");
6102 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6103 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6105 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6106 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6108 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6109 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6111 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6112 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6115 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6116 .f = cmd_read_reg_bit_field_parsed,
6118 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6119 "Read register bit field between bit_x and bit_y included",
6121 (void *)&cmd_read_reg_bit_field_read,
6122 (void *)&cmd_read_reg_bit_field_regfield,
6123 (void *)&cmd_read_reg_bit_field_port_id,
6124 (void *)&cmd_read_reg_bit_field_reg_off,
6125 (void *)&cmd_read_reg_bit_field_bit1_pos,
6126 (void *)&cmd_read_reg_bit_field_bit2_pos,
6131 /* *** READ PORT REGISTER BIT *** */
6132 struct cmd_read_reg_bit_result {
6133 cmdline_fixed_string_t read;
6134 cmdline_fixed_string_t regbit;
6141 cmd_read_reg_bit_parsed(void *parsed_result,
6142 __attribute__((unused)) struct cmdline *cl,
6143 __attribute__((unused)) void *data)
6145 struct cmd_read_reg_bit_result *res = parsed_result;
6146 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6149 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6150 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6151 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6152 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6154 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6155 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6156 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6157 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6158 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6159 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6161 cmdline_parse_inst_t cmd_read_reg_bit = {
6162 .f = cmd_read_reg_bit_parsed,
6164 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6166 (void *)&cmd_read_reg_bit_read,
6167 (void *)&cmd_read_reg_bit_regbit,
6168 (void *)&cmd_read_reg_bit_port_id,
6169 (void *)&cmd_read_reg_bit_reg_off,
6170 (void *)&cmd_read_reg_bit_bit_pos,
6175 /* *** WRITE PORT REGISTER *** */
6176 struct cmd_write_reg_result {
6177 cmdline_fixed_string_t write;
6178 cmdline_fixed_string_t reg;
6185 cmd_write_reg_parsed(void *parsed_result,
6186 __attribute__((unused)) struct cmdline *cl,
6187 __attribute__((unused)) void *data)
6189 struct cmd_write_reg_result *res = parsed_result;
6190 port_reg_set(res->port_id, res->reg_off, res->value);
6193 cmdline_parse_token_string_t cmd_write_reg_write =
6194 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6195 cmdline_parse_token_string_t cmd_write_reg_reg =
6196 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6197 cmdline_parse_token_num_t cmd_write_reg_port_id =
6198 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6199 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6200 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6201 cmdline_parse_token_num_t cmd_write_reg_value =
6202 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6204 cmdline_parse_inst_t cmd_write_reg = {
6205 .f = cmd_write_reg_parsed,
6207 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6209 (void *)&cmd_write_reg_write,
6210 (void *)&cmd_write_reg_reg,
6211 (void *)&cmd_write_reg_port_id,
6212 (void *)&cmd_write_reg_reg_off,
6213 (void *)&cmd_write_reg_value,
6218 /* *** WRITE PORT REGISTER BIT FIELD *** */
6219 struct cmd_write_reg_bit_field_result {
6220 cmdline_fixed_string_t write;
6221 cmdline_fixed_string_t regfield;
6230 cmd_write_reg_bit_field_parsed(void *parsed_result,
6231 __attribute__((unused)) struct cmdline *cl,
6232 __attribute__((unused)) void *data)
6234 struct cmd_write_reg_bit_field_result *res = parsed_result;
6235 port_reg_bit_field_set(res->port_id, res->reg_off,
6236 res->bit1_pos, res->bit2_pos, res->value);
6239 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6240 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6242 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6243 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6244 regfield, "regfield");
6245 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6246 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6248 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6249 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6251 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6252 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6254 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6255 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6257 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6258 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6261 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6262 .f = cmd_write_reg_bit_field_parsed,
6264 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6266 "Set register bit field between bit_x and bit_y included",
6268 (void *)&cmd_write_reg_bit_field_write,
6269 (void *)&cmd_write_reg_bit_field_regfield,
6270 (void *)&cmd_write_reg_bit_field_port_id,
6271 (void *)&cmd_write_reg_bit_field_reg_off,
6272 (void *)&cmd_write_reg_bit_field_bit1_pos,
6273 (void *)&cmd_write_reg_bit_field_bit2_pos,
6274 (void *)&cmd_write_reg_bit_field_value,
6279 /* *** WRITE PORT REGISTER BIT *** */
6280 struct cmd_write_reg_bit_result {
6281 cmdline_fixed_string_t write;
6282 cmdline_fixed_string_t regbit;
6290 cmd_write_reg_bit_parsed(void *parsed_result,
6291 __attribute__((unused)) struct cmdline *cl,
6292 __attribute__((unused)) void *data)
6294 struct cmd_write_reg_bit_result *res = parsed_result;
6295 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6298 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6299 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6301 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6302 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6304 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6305 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6306 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6307 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6308 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6309 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6310 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6311 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6313 cmdline_parse_inst_t cmd_write_reg_bit = {
6314 .f = cmd_write_reg_bit_parsed,
6316 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6319 (void *)&cmd_write_reg_bit_write,
6320 (void *)&cmd_write_reg_bit_regbit,
6321 (void *)&cmd_write_reg_bit_port_id,
6322 (void *)&cmd_write_reg_bit_reg_off,
6323 (void *)&cmd_write_reg_bit_bit_pos,
6324 (void *)&cmd_write_reg_bit_value,
6329 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6330 struct cmd_read_rxd_txd_result {
6331 cmdline_fixed_string_t read;
6332 cmdline_fixed_string_t rxd_txd;
6339 cmd_read_rxd_txd_parsed(void *parsed_result,
6340 __attribute__((unused)) struct cmdline *cl,
6341 __attribute__((unused)) void *data)
6343 struct cmd_read_rxd_txd_result *res = parsed_result;
6345 if (!strcmp(res->rxd_txd, "rxd"))
6346 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6347 else if (!strcmp(res->rxd_txd, "txd"))
6348 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6351 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6352 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6353 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6354 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6356 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6357 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6358 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6359 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6360 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6361 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6363 cmdline_parse_inst_t cmd_read_rxd_txd = {
6364 .f = cmd_read_rxd_txd_parsed,
6366 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6368 (void *)&cmd_read_rxd_txd_read,
6369 (void *)&cmd_read_rxd_txd_rxd_txd,
6370 (void *)&cmd_read_rxd_txd_port_id,
6371 (void *)&cmd_read_rxd_txd_queue_id,
6372 (void *)&cmd_read_rxd_txd_desc_id,
6378 struct cmd_quit_result {
6379 cmdline_fixed_string_t quit;
6382 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6384 __attribute__((unused)) void *data)
6390 cmdline_parse_token_string_t cmd_quit_quit =
6391 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6393 cmdline_parse_inst_t cmd_quit = {
6394 .f = cmd_quit_parsed,
6396 .help_str = "quit: Exit application",
6398 (void *)&cmd_quit_quit,
6403 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6404 struct cmd_mac_addr_result {
6405 cmdline_fixed_string_t mac_addr_cmd;
6406 cmdline_fixed_string_t what;
6408 struct ether_addr address;
6411 static void cmd_mac_addr_parsed(void *parsed_result,
6412 __attribute__((unused)) struct cmdline *cl,
6413 __attribute__((unused)) void *data)
6415 struct cmd_mac_addr_result *res = parsed_result;
6418 if (strcmp(res->what, "add") == 0)
6419 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6420 else if (strcmp(res->what, "set") == 0)
6421 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6424 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6426 /* check the return value and print it if is < 0 */
6428 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6432 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6433 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6435 cmdline_parse_token_string_t cmd_mac_addr_what =
6436 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6438 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6439 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6440 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6441 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6443 cmdline_parse_inst_t cmd_mac_addr = {
6444 .f = cmd_mac_addr_parsed,
6446 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6447 "Add/Remove/Set MAC address on port_id",
6449 (void *)&cmd_mac_addr_cmd,
6450 (void *)&cmd_mac_addr_what,
6451 (void *)&cmd_mac_addr_portnum,
6452 (void *)&cmd_mac_addr_addr,
6458 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6459 struct cmd_set_qmap_result {
6460 cmdline_fixed_string_t set;
6461 cmdline_fixed_string_t qmap;
6462 cmdline_fixed_string_t what;
6469 cmd_set_qmap_parsed(void *parsed_result,
6470 __attribute__((unused)) struct cmdline *cl,
6471 __attribute__((unused)) void *data)
6473 struct cmd_set_qmap_result *res = parsed_result;
6474 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6476 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6479 cmdline_parse_token_string_t cmd_setqmap_set =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6482 cmdline_parse_token_string_t cmd_setqmap_qmap =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6485 cmdline_parse_token_string_t cmd_setqmap_what =
6486 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6488 cmdline_parse_token_num_t cmd_setqmap_portid =
6489 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6491 cmdline_parse_token_num_t cmd_setqmap_queueid =
6492 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6494 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6495 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6498 cmdline_parse_inst_t cmd_set_qmap = {
6499 .f = cmd_set_qmap_parsed,
6501 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6502 "Set statistics mapping value on tx|rx queue_id of port_id",
6504 (void *)&cmd_setqmap_set,
6505 (void *)&cmd_setqmap_qmap,
6506 (void *)&cmd_setqmap_what,
6507 (void *)&cmd_setqmap_portid,
6508 (void *)&cmd_setqmap_queueid,
6509 (void *)&cmd_setqmap_mapvalue,
6514 /* *** CONFIGURE UNICAST HASH TABLE *** */
6515 struct cmd_set_uc_hash_table {
6516 cmdline_fixed_string_t set;
6517 cmdline_fixed_string_t port;
6519 cmdline_fixed_string_t what;
6520 struct ether_addr address;
6521 cmdline_fixed_string_t mode;
6525 cmd_set_uc_hash_parsed(void *parsed_result,
6526 __attribute__((unused)) struct cmdline *cl,
6527 __attribute__((unused)) void *data)
6530 struct cmd_set_uc_hash_table *res = parsed_result;
6532 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6534 if (strcmp(res->what, "uta") == 0)
6535 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6536 &res->address,(uint8_t)is_on);
6538 printf("bad unicast hash table parameter, return code = %d \n", ret);
6542 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6543 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6545 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6546 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6548 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6549 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6551 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6554 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6555 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6557 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6558 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6561 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6562 .f = cmd_set_uc_hash_parsed,
6564 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6566 (void *)&cmd_set_uc_hash_set,
6567 (void *)&cmd_set_uc_hash_port,
6568 (void *)&cmd_set_uc_hash_portid,
6569 (void *)&cmd_set_uc_hash_what,
6570 (void *)&cmd_set_uc_hash_mac,
6571 (void *)&cmd_set_uc_hash_mode,
6576 struct cmd_set_uc_all_hash_table {
6577 cmdline_fixed_string_t set;
6578 cmdline_fixed_string_t port;
6580 cmdline_fixed_string_t what;
6581 cmdline_fixed_string_t value;
6582 cmdline_fixed_string_t mode;
6586 cmd_set_uc_all_hash_parsed(void *parsed_result,
6587 __attribute__((unused)) struct cmdline *cl,
6588 __attribute__((unused)) void *data)
6591 struct cmd_set_uc_all_hash_table *res = parsed_result;
6593 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6595 if ((strcmp(res->what, "uta") == 0) &&
6596 (strcmp(res->value, "all") == 0))
6597 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6599 printf("bad unicast hash table parameter,"
6600 "return code = %d \n", ret);
6603 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6604 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6606 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6607 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6609 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6610 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6612 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6613 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6615 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6616 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6618 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6622 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6623 .f = cmd_set_uc_all_hash_parsed,
6625 .help_str = "set port <port_id> uta all on|off",
6627 (void *)&cmd_set_uc_all_hash_set,
6628 (void *)&cmd_set_uc_all_hash_port,
6629 (void *)&cmd_set_uc_all_hash_portid,
6630 (void *)&cmd_set_uc_all_hash_what,
6631 (void *)&cmd_set_uc_all_hash_value,
6632 (void *)&cmd_set_uc_all_hash_mode,
6637 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6638 struct cmd_set_vf_macvlan_filter {
6639 cmdline_fixed_string_t set;
6640 cmdline_fixed_string_t port;
6642 cmdline_fixed_string_t vf;
6644 struct ether_addr address;
6645 cmdline_fixed_string_t filter_type;
6646 cmdline_fixed_string_t mode;
6650 cmd_set_vf_macvlan_parsed(void *parsed_result,
6651 __attribute__((unused)) struct cmdline *cl,
6652 __attribute__((unused)) void *data)
6655 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6656 struct rte_eth_mac_filter filter;
6658 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6660 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6662 /* set VF MAC filter */
6666 filter.dst_id = res->vf_id;
6668 if (!strcmp(res->filter_type, "exact-mac"))
6669 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6670 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6671 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6672 else if (!strcmp(res->filter_type, "hashmac"))
6673 filter.filter_type = RTE_MAC_HASH_MATCH;
6674 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6675 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6677 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6680 ret = rte_eth_dev_filter_ctrl(res->port_id,
6681 RTE_ETH_FILTER_MACVLAN,
6685 ret = rte_eth_dev_filter_ctrl(res->port_id,
6686 RTE_ETH_FILTER_MACVLAN,
6687 RTE_ETH_FILTER_DELETE,
6691 printf("bad set MAC hash parameter, return code = %d\n", ret);
6695 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6696 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6698 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6699 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6701 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6702 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6704 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6705 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6707 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6708 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6710 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6711 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6713 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6714 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6715 filter_type, "exact-mac#exact-mac-vlan"
6716 "#hashmac#hashmac-vlan");
6717 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6718 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6721 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6722 .f = cmd_set_vf_macvlan_parsed,
6724 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6725 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6726 "Exact match rule: exact match of MAC or MAC and VLAN; "
6727 "hash match rule: hash match of MAC and exact match of VLAN",
6729 (void *)&cmd_set_vf_macvlan_set,
6730 (void *)&cmd_set_vf_macvlan_port,
6731 (void *)&cmd_set_vf_macvlan_portid,
6732 (void *)&cmd_set_vf_macvlan_vf,
6733 (void *)&cmd_set_vf_macvlan_vf_id,
6734 (void *)&cmd_set_vf_macvlan_mac,
6735 (void *)&cmd_set_vf_macvlan_filter_type,
6736 (void *)&cmd_set_vf_macvlan_mode,
6741 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6742 struct cmd_set_vf_traffic {
6743 cmdline_fixed_string_t set;
6744 cmdline_fixed_string_t port;
6746 cmdline_fixed_string_t vf;
6748 cmdline_fixed_string_t what;
6749 cmdline_fixed_string_t mode;
6753 cmd_set_vf_traffic_parsed(void *parsed_result,
6754 __attribute__((unused)) struct cmdline *cl,
6755 __attribute__((unused)) void *data)
6757 struct cmd_set_vf_traffic *res = parsed_result;
6758 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6759 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6761 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6764 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6765 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6767 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6768 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6770 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6771 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6773 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6774 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6776 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6777 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6779 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6780 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6782 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6783 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6786 cmdline_parse_inst_t cmd_set_vf_traffic = {
6787 .f = cmd_set_vf_traffic_parsed,
6789 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6791 (void *)&cmd_setvf_traffic_set,
6792 (void *)&cmd_setvf_traffic_port,
6793 (void *)&cmd_setvf_traffic_portid,
6794 (void *)&cmd_setvf_traffic_vf,
6795 (void *)&cmd_setvf_traffic_vfid,
6796 (void *)&cmd_setvf_traffic_what,
6797 (void *)&cmd_setvf_traffic_mode,
6802 /* *** CONFIGURE VF RECEIVE MODE *** */
6803 struct cmd_set_vf_rxmode {
6804 cmdline_fixed_string_t set;
6805 cmdline_fixed_string_t port;
6807 cmdline_fixed_string_t vf;
6809 cmdline_fixed_string_t what;
6810 cmdline_fixed_string_t mode;
6811 cmdline_fixed_string_t on;
6815 cmd_set_vf_rxmode_parsed(void *parsed_result,
6816 __attribute__((unused)) struct cmdline *cl,
6817 __attribute__((unused)) void *data)
6820 uint16_t rx_mode = 0;
6821 struct cmd_set_vf_rxmode *res = parsed_result;
6823 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6824 if (!strcmp(res->what,"rxmode")) {
6825 if (!strcmp(res->mode, "AUPE"))
6826 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6827 else if (!strcmp(res->mode, "ROPE"))
6828 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6829 else if (!strcmp(res->mode, "BAM"))
6830 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6831 else if (!strncmp(res->mode, "MPE",3))
6832 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6835 #ifdef RTE_LIBRTE_IXGBE_PMD
6836 if (ret == -ENOTSUP)
6837 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
6838 rx_mode, (uint8_t)is_on);
6840 #ifdef RTE_LIBRTE_BNXT_PMD
6841 if (ret == -ENOTSUP)
6842 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
6843 rx_mode, (uint8_t)is_on);
6846 printf("bad VF receive mode parameter, return code = %d \n",
6850 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6851 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6853 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6854 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6856 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6857 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6859 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6860 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6862 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6863 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6865 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6866 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6868 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6869 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6870 mode, "AUPE#ROPE#BAM#MPE");
6871 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6872 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6875 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6876 .f = cmd_set_vf_rxmode_parsed,
6878 .help_str = "set port <port_id> vf <vf_id> rxmode "
6879 "AUPE|ROPE|BAM|MPE on|off",
6881 (void *)&cmd_set_vf_rxmode_set,
6882 (void *)&cmd_set_vf_rxmode_port,
6883 (void *)&cmd_set_vf_rxmode_portid,
6884 (void *)&cmd_set_vf_rxmode_vf,
6885 (void *)&cmd_set_vf_rxmode_vfid,
6886 (void *)&cmd_set_vf_rxmode_what,
6887 (void *)&cmd_set_vf_rxmode_mode,
6888 (void *)&cmd_set_vf_rxmode_on,
6893 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6894 struct cmd_vf_mac_addr_result {
6895 cmdline_fixed_string_t mac_addr_cmd;
6896 cmdline_fixed_string_t what;
6897 cmdline_fixed_string_t port;
6899 cmdline_fixed_string_t vf;
6901 struct ether_addr address;
6904 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6905 __attribute__((unused)) struct cmdline *cl,
6906 __attribute__((unused)) void *data)
6908 struct cmd_vf_mac_addr_result *res = parsed_result;
6911 if (strcmp(res->what, "add") == 0)
6912 ret = rte_eth_dev_mac_addr_add(res->port_num,
6913 &res->address, res->vf_num);
6915 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6919 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6920 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6921 mac_addr_cmd,"mac_addr");
6922 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6923 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6925 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6926 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6928 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6929 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6931 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6932 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6934 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6935 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6937 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6938 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6941 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6942 .f = cmd_vf_mac_addr_parsed,
6944 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6945 "Add MAC address filtering for a VF on port_id",
6947 (void *)&cmd_vf_mac_addr_cmd,
6948 (void *)&cmd_vf_mac_addr_what,
6949 (void *)&cmd_vf_mac_addr_port,
6950 (void *)&cmd_vf_mac_addr_portnum,
6951 (void *)&cmd_vf_mac_addr_vf,
6952 (void *)&cmd_vf_mac_addr_vfnum,
6953 (void *)&cmd_vf_mac_addr_addr,
6958 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6959 struct cmd_vf_rx_vlan_filter {
6960 cmdline_fixed_string_t rx_vlan;
6961 cmdline_fixed_string_t what;
6963 cmdline_fixed_string_t port;
6965 cmdline_fixed_string_t vf;
6970 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6971 __attribute__((unused)) struct cmdline *cl,
6972 __attribute__((unused)) void *data)
6974 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6977 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6979 #ifdef RTE_LIBRTE_IXGBE_PMD
6980 if (ret == -ENOTSUP)
6981 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6982 res->vlan_id, res->vf_mask, is_add);
6984 #ifdef RTE_LIBRTE_I40E_PMD
6985 if (ret == -ENOTSUP)
6986 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6987 res->vlan_id, res->vf_mask, is_add);
6989 #ifdef RTE_LIBRTE_BNXT_PMD
6990 if (ret == -ENOTSUP)
6991 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
6992 res->vlan_id, res->vf_mask, is_add);
6999 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7000 res->vlan_id, res->vf_mask);
7003 printf("invalid port_id %d\n", res->port_id);
7006 printf("function not implemented or supported\n");
7009 printf("programming error: (%s)\n", strerror(-ret));
7013 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7014 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7015 rx_vlan, "rx_vlan");
7016 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7017 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7019 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7020 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7022 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7023 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7025 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7026 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7028 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7029 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7031 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7032 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7035 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7036 .f = cmd_vf_rx_vlan_filter_parsed,
7038 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7039 "(vf_mask = hexadecimal VF mask)",
7041 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7042 (void *)&cmd_vf_rx_vlan_filter_what,
7043 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7044 (void *)&cmd_vf_rx_vlan_filter_port,
7045 (void *)&cmd_vf_rx_vlan_filter_portid,
7046 (void *)&cmd_vf_rx_vlan_filter_vf,
7047 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7052 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7053 struct cmd_queue_rate_limit_result {
7054 cmdline_fixed_string_t set;
7055 cmdline_fixed_string_t port;
7057 cmdline_fixed_string_t queue;
7059 cmdline_fixed_string_t rate;
7063 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7064 __attribute__((unused)) struct cmdline *cl,
7065 __attribute__((unused)) void *data)
7067 struct cmd_queue_rate_limit_result *res = parsed_result;
7070 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7071 && (strcmp(res->queue, "queue") == 0)
7072 && (strcmp(res->rate, "rate") == 0))
7073 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7076 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7080 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7081 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7083 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7084 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7086 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7087 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7089 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7090 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7092 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7093 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7095 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7096 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7098 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7099 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7102 cmdline_parse_inst_t cmd_queue_rate_limit = {
7103 .f = cmd_queue_rate_limit_parsed,
7105 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7106 "Set rate limit for a queue on port_id",
7108 (void *)&cmd_queue_rate_limit_set,
7109 (void *)&cmd_queue_rate_limit_port,
7110 (void *)&cmd_queue_rate_limit_portnum,
7111 (void *)&cmd_queue_rate_limit_queue,
7112 (void *)&cmd_queue_rate_limit_queuenum,
7113 (void *)&cmd_queue_rate_limit_rate,
7114 (void *)&cmd_queue_rate_limit_ratenum,
7119 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7120 struct cmd_vf_rate_limit_result {
7121 cmdline_fixed_string_t set;
7122 cmdline_fixed_string_t port;
7124 cmdline_fixed_string_t vf;
7126 cmdline_fixed_string_t rate;
7128 cmdline_fixed_string_t q_msk;
7132 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7133 __attribute__((unused)) struct cmdline *cl,
7134 __attribute__((unused)) void *data)
7136 struct cmd_vf_rate_limit_result *res = parsed_result;
7139 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7140 && (strcmp(res->vf, "vf") == 0)
7141 && (strcmp(res->rate, "rate") == 0)
7142 && (strcmp(res->q_msk, "queue_mask") == 0))
7143 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7144 res->rate_num, res->q_msk_val);
7146 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7150 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7151 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7153 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7154 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7156 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7157 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7159 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7160 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7162 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7163 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7165 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7166 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7168 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7169 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7171 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7172 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7173 q_msk, "queue_mask");
7174 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7175 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7178 cmdline_parse_inst_t cmd_vf_rate_limit = {
7179 .f = cmd_vf_rate_limit_parsed,
7181 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7182 "queue_mask <queue_mask_value>: "
7183 "Set rate limit for queues of VF on port_id",
7185 (void *)&cmd_vf_rate_limit_set,
7186 (void *)&cmd_vf_rate_limit_port,
7187 (void *)&cmd_vf_rate_limit_portnum,
7188 (void *)&cmd_vf_rate_limit_vf,
7189 (void *)&cmd_vf_rate_limit_vfnum,
7190 (void *)&cmd_vf_rate_limit_rate,
7191 (void *)&cmd_vf_rate_limit_ratenum,
7192 (void *)&cmd_vf_rate_limit_q_msk,
7193 (void *)&cmd_vf_rate_limit_q_msk_val,
7198 /* *** ADD TUNNEL FILTER OF A PORT *** */
7199 struct cmd_tunnel_filter_result {
7200 cmdline_fixed_string_t cmd;
7201 cmdline_fixed_string_t what;
7203 struct ether_addr outer_mac;
7204 struct ether_addr inner_mac;
7205 cmdline_ipaddr_t ip_value;
7206 uint16_t inner_vlan;
7207 cmdline_fixed_string_t tunnel_type;
7208 cmdline_fixed_string_t filter_type;
7214 cmd_tunnel_filter_parsed(void *parsed_result,
7215 __attribute__((unused)) struct cmdline *cl,
7216 __attribute__((unused)) void *data)
7218 struct cmd_tunnel_filter_result *res = parsed_result;
7219 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7222 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7224 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7225 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7226 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7228 if (res->ip_value.family == AF_INET) {
7229 tunnel_filter_conf.ip_addr.ipv4_addr =
7230 res->ip_value.addr.ipv4.s_addr;
7231 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7233 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7234 &(res->ip_value.addr.ipv6),
7235 sizeof(struct in6_addr));
7236 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7239 if (!strcmp(res->filter_type, "imac-ivlan"))
7240 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7241 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7242 tunnel_filter_conf.filter_type =
7243 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7244 else if (!strcmp(res->filter_type, "imac-tenid"))
7245 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7246 else if (!strcmp(res->filter_type, "imac"))
7247 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7248 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7249 tunnel_filter_conf.filter_type =
7250 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7251 else if (!strcmp(res->filter_type, "oip"))
7252 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7253 else if (!strcmp(res->filter_type, "iip"))
7254 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7256 printf("The filter type is not supported");
7260 if (!strcmp(res->tunnel_type, "vxlan"))
7261 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7262 else if (!strcmp(res->tunnel_type, "nvgre"))
7263 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7264 else if (!strcmp(res->tunnel_type, "ipingre"))
7265 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7267 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7271 tunnel_filter_conf.tenant_id = res->tenant_id;
7272 tunnel_filter_conf.queue_id = res->queue_num;
7273 if (!strcmp(res->what, "add"))
7274 ret = rte_eth_dev_filter_ctrl(res->port_id,
7275 RTE_ETH_FILTER_TUNNEL,
7277 &tunnel_filter_conf);
7279 ret = rte_eth_dev_filter_ctrl(res->port_id,
7280 RTE_ETH_FILTER_TUNNEL,
7281 RTE_ETH_FILTER_DELETE,
7282 &tunnel_filter_conf);
7284 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7288 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7289 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7290 cmd, "tunnel_filter");
7291 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7292 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7294 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7295 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7297 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7298 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7300 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7301 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7303 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7304 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7305 inner_vlan, UINT16);
7306 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7307 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7309 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7310 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7311 tunnel_type, "vxlan#nvgre#ipingre");
7313 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7314 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7315 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7316 "imac#omac-imac-tenid");
7317 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7318 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7320 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7321 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7324 cmdline_parse_inst_t cmd_tunnel_filter = {
7325 .f = cmd_tunnel_filter_parsed,
7327 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7328 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7329 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7330 "<queue_id>: Add/Rm tunnel filter of a port",
7332 (void *)&cmd_tunnel_filter_cmd,
7333 (void *)&cmd_tunnel_filter_what,
7334 (void *)&cmd_tunnel_filter_port_id,
7335 (void *)&cmd_tunnel_filter_outer_mac,
7336 (void *)&cmd_tunnel_filter_inner_mac,
7337 (void *)&cmd_tunnel_filter_ip_value,
7338 (void *)&cmd_tunnel_filter_innner_vlan,
7339 (void *)&cmd_tunnel_filter_tunnel_type,
7340 (void *)&cmd_tunnel_filter_filter_type,
7341 (void *)&cmd_tunnel_filter_tenant_id,
7342 (void *)&cmd_tunnel_filter_queue_num,
7347 /* *** CONFIGURE TUNNEL UDP PORT *** */
7348 struct cmd_tunnel_udp_config {
7349 cmdline_fixed_string_t cmd;
7350 cmdline_fixed_string_t what;
7356 cmd_tunnel_udp_config_parsed(void *parsed_result,
7357 __attribute__((unused)) struct cmdline *cl,
7358 __attribute__((unused)) void *data)
7360 struct cmd_tunnel_udp_config *res = parsed_result;
7361 struct rte_eth_udp_tunnel tunnel_udp;
7364 tunnel_udp.udp_port = res->udp_port;
7366 if (!strcmp(res->cmd, "rx_vxlan_port"))
7367 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7369 if (!strcmp(res->what, "add"))
7370 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7373 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7377 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7380 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7381 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7382 cmd, "rx_vxlan_port");
7383 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7384 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7386 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7387 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7389 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7390 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7393 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7394 .f = cmd_tunnel_udp_config_parsed,
7396 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7397 "Add/Remove a tunneling UDP port filter",
7399 (void *)&cmd_tunnel_udp_config_cmd,
7400 (void *)&cmd_tunnel_udp_config_what,
7401 (void *)&cmd_tunnel_udp_config_udp_port,
7402 (void *)&cmd_tunnel_udp_config_port_id,
7407 /* *** GLOBAL CONFIG *** */
7408 struct cmd_global_config_result {
7409 cmdline_fixed_string_t cmd;
7411 cmdline_fixed_string_t cfg_type;
7416 cmd_global_config_parsed(void *parsed_result,
7417 __attribute__((unused)) struct cmdline *cl,
7418 __attribute__((unused)) void *data)
7420 struct cmd_global_config_result *res = parsed_result;
7421 struct rte_eth_global_cfg conf;
7424 memset(&conf, 0, sizeof(conf));
7425 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7426 conf.cfg.gre_key_len = res->len;
7427 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7428 RTE_ETH_FILTER_SET, &conf);
7430 printf("Global config error\n");
7433 cmdline_parse_token_string_t cmd_global_config_cmd =
7434 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7436 cmdline_parse_token_num_t cmd_global_config_port_id =
7437 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7438 cmdline_parse_token_string_t cmd_global_config_type =
7439 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7440 cfg_type, "gre-key-len");
7441 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7442 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7445 cmdline_parse_inst_t cmd_global_config = {
7446 .f = cmd_global_config_parsed,
7447 .data = (void *)NULL,
7448 .help_str = "global_config <port_id> gre-key-len <key_len>",
7450 (void *)&cmd_global_config_cmd,
7451 (void *)&cmd_global_config_port_id,
7452 (void *)&cmd_global_config_type,
7453 (void *)&cmd_global_config_gre_key_len,
7458 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7459 struct cmd_set_mirror_mask_result {
7460 cmdline_fixed_string_t set;
7461 cmdline_fixed_string_t port;
7463 cmdline_fixed_string_t mirror;
7465 cmdline_fixed_string_t what;
7466 cmdline_fixed_string_t value;
7467 cmdline_fixed_string_t dstpool;
7469 cmdline_fixed_string_t on;
7472 cmdline_parse_token_string_t cmd_mirror_mask_set =
7473 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7475 cmdline_parse_token_string_t cmd_mirror_mask_port =
7476 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7478 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7479 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7481 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7482 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7483 mirror, "mirror-rule");
7484 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7485 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7487 cmdline_parse_token_string_t cmd_mirror_mask_what =
7488 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7489 what, "pool-mirror-up#pool-mirror-down"
7491 cmdline_parse_token_string_t cmd_mirror_mask_value =
7492 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7494 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7495 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7496 dstpool, "dst-pool");
7497 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7498 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7500 cmdline_parse_token_string_t cmd_mirror_mask_on =
7501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7505 cmd_set_mirror_mask_parsed(void *parsed_result,
7506 __attribute__((unused)) struct cmdline *cl,
7507 __attribute__((unused)) void *data)
7510 struct cmd_set_mirror_mask_result *res = parsed_result;
7511 struct rte_eth_mirror_conf mr_conf;
7513 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7515 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7517 mr_conf.dst_pool = res->dstpool_id;
7519 if (!strcmp(res->what, "pool-mirror-up")) {
7520 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7521 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7522 } else if (!strcmp(res->what, "pool-mirror-down")) {
7523 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7524 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7525 } else if (!strcmp(res->what, "vlan-mirror")) {
7526 mr_conf.rule_type = ETH_MIRROR_VLAN;
7527 nb_item = parse_item_list(res->value, "vlan",
7528 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7532 for (i = 0; i < nb_item; i++) {
7533 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7534 printf("Invalid vlan_id: must be < 4096\n");
7538 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7539 mr_conf.vlan.vlan_mask |= 1ULL << i;
7543 if (!strcmp(res->on, "on"))
7544 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7547 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7550 printf("mirror rule add error: (%s)\n", strerror(-ret));
7553 cmdline_parse_inst_t cmd_set_mirror_mask = {
7554 .f = cmd_set_mirror_mask_parsed,
7556 .help_str = "set port <port_id> mirror-rule <rule_id> "
7557 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7558 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7560 (void *)&cmd_mirror_mask_set,
7561 (void *)&cmd_mirror_mask_port,
7562 (void *)&cmd_mirror_mask_portid,
7563 (void *)&cmd_mirror_mask_mirror,
7564 (void *)&cmd_mirror_mask_ruleid,
7565 (void *)&cmd_mirror_mask_what,
7566 (void *)&cmd_mirror_mask_value,
7567 (void *)&cmd_mirror_mask_dstpool,
7568 (void *)&cmd_mirror_mask_poolid,
7569 (void *)&cmd_mirror_mask_on,
7574 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7575 struct cmd_set_mirror_link_result {
7576 cmdline_fixed_string_t set;
7577 cmdline_fixed_string_t port;
7579 cmdline_fixed_string_t mirror;
7581 cmdline_fixed_string_t what;
7582 cmdline_fixed_string_t dstpool;
7584 cmdline_fixed_string_t on;
7587 cmdline_parse_token_string_t cmd_mirror_link_set =
7588 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7590 cmdline_parse_token_string_t cmd_mirror_link_port =
7591 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7593 cmdline_parse_token_num_t cmd_mirror_link_portid =
7594 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7596 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7597 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7598 mirror, "mirror-rule");
7599 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7600 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7602 cmdline_parse_token_string_t cmd_mirror_link_what =
7603 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7604 what, "uplink-mirror#downlink-mirror");
7605 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7606 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7607 dstpool, "dst-pool");
7608 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7609 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7611 cmdline_parse_token_string_t cmd_mirror_link_on =
7612 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7616 cmd_set_mirror_link_parsed(void *parsed_result,
7617 __attribute__((unused)) struct cmdline *cl,
7618 __attribute__((unused)) void *data)
7621 struct cmd_set_mirror_link_result *res = parsed_result;
7622 struct rte_eth_mirror_conf mr_conf;
7624 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7625 if (!strcmp(res->what, "uplink-mirror"))
7626 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7628 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7630 mr_conf.dst_pool = res->dstpool_id;
7632 if (!strcmp(res->on, "on"))
7633 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7636 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7639 /* check the return value and print it if is < 0 */
7641 printf("mirror rule add error: (%s)\n", strerror(-ret));
7645 cmdline_parse_inst_t cmd_set_mirror_link = {
7646 .f = cmd_set_mirror_link_parsed,
7648 .help_str = "set port <port_id> mirror-rule <rule_id> "
7649 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7651 (void *)&cmd_mirror_link_set,
7652 (void *)&cmd_mirror_link_port,
7653 (void *)&cmd_mirror_link_portid,
7654 (void *)&cmd_mirror_link_mirror,
7655 (void *)&cmd_mirror_link_ruleid,
7656 (void *)&cmd_mirror_link_what,
7657 (void *)&cmd_mirror_link_dstpool,
7658 (void *)&cmd_mirror_link_poolid,
7659 (void *)&cmd_mirror_link_on,
7664 /* *** RESET VM MIRROR RULE *** */
7665 struct cmd_rm_mirror_rule_result {
7666 cmdline_fixed_string_t reset;
7667 cmdline_fixed_string_t port;
7669 cmdline_fixed_string_t mirror;
7673 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7674 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7676 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7677 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7679 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7680 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7682 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7683 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7684 mirror, "mirror-rule");
7685 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7686 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7690 cmd_reset_mirror_rule_parsed(void *parsed_result,
7691 __attribute__((unused)) struct cmdline *cl,
7692 __attribute__((unused)) void *data)
7695 struct cmd_set_mirror_link_result *res = parsed_result;
7697 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7699 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7702 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7703 .f = cmd_reset_mirror_rule_parsed,
7705 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7707 (void *)&cmd_rm_mirror_rule_reset,
7708 (void *)&cmd_rm_mirror_rule_port,
7709 (void *)&cmd_rm_mirror_rule_portid,
7710 (void *)&cmd_rm_mirror_rule_mirror,
7711 (void *)&cmd_rm_mirror_rule_ruleid,
7716 /* ******************************************************************************** */
7718 struct cmd_dump_result {
7719 cmdline_fixed_string_t dump;
7723 dump_struct_sizes(void)
7725 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7726 DUMP_SIZE(struct rte_mbuf);
7727 DUMP_SIZE(struct rte_mempool);
7728 DUMP_SIZE(struct rte_ring);
7732 static void cmd_dump_parsed(void *parsed_result,
7733 __attribute__((unused)) struct cmdline *cl,
7734 __attribute__((unused)) void *data)
7736 struct cmd_dump_result *res = parsed_result;
7738 if (!strcmp(res->dump, "dump_physmem"))
7739 rte_dump_physmem_layout(stdout);
7740 else if (!strcmp(res->dump, "dump_memzone"))
7741 rte_memzone_dump(stdout);
7742 else if (!strcmp(res->dump, "dump_struct_sizes"))
7743 dump_struct_sizes();
7744 else if (!strcmp(res->dump, "dump_ring"))
7745 rte_ring_list_dump(stdout);
7746 else if (!strcmp(res->dump, "dump_mempool"))
7747 rte_mempool_list_dump(stdout);
7748 else if (!strcmp(res->dump, "dump_devargs"))
7749 rte_eal_devargs_dump(stdout);
7750 else if (!strcmp(res->dump, "dump_log_types"))
7751 rte_log_dump(stdout);
7754 cmdline_parse_token_string_t cmd_dump_dump =
7755 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7758 "dump_struct_sizes#"
7764 cmdline_parse_inst_t cmd_dump = {
7765 .f = cmd_dump_parsed, /* function to call */
7766 .data = NULL, /* 2nd arg of func */
7767 .help_str = "Dump status",
7768 .tokens = { /* token list, NULL terminated */
7769 (void *)&cmd_dump_dump,
7774 /* ******************************************************************************** */
7776 struct cmd_dump_one_result {
7777 cmdline_fixed_string_t dump;
7778 cmdline_fixed_string_t name;
7781 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7782 __attribute__((unused)) void *data)
7784 struct cmd_dump_one_result *res = parsed_result;
7786 if (!strcmp(res->dump, "dump_ring")) {
7788 r = rte_ring_lookup(res->name);
7790 cmdline_printf(cl, "Cannot find ring\n");
7793 rte_ring_dump(stdout, r);
7794 } else if (!strcmp(res->dump, "dump_mempool")) {
7795 struct rte_mempool *mp;
7796 mp = rte_mempool_lookup(res->name);
7798 cmdline_printf(cl, "Cannot find mempool\n");
7801 rte_mempool_dump(stdout, mp);
7805 cmdline_parse_token_string_t cmd_dump_one_dump =
7806 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7807 "dump_ring#dump_mempool");
7809 cmdline_parse_token_string_t cmd_dump_one_name =
7810 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7812 cmdline_parse_inst_t cmd_dump_one = {
7813 .f = cmd_dump_one_parsed, /* function to call */
7814 .data = NULL, /* 2nd arg of func */
7815 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7816 .tokens = { /* token list, NULL terminated */
7817 (void *)&cmd_dump_one_dump,
7818 (void *)&cmd_dump_one_name,
7823 /* *** Add/Del syn filter *** */
7824 struct cmd_syn_filter_result {
7825 cmdline_fixed_string_t filter;
7827 cmdline_fixed_string_t ops;
7828 cmdline_fixed_string_t priority;
7829 cmdline_fixed_string_t high;
7830 cmdline_fixed_string_t queue;
7835 cmd_syn_filter_parsed(void *parsed_result,
7836 __attribute__((unused)) struct cmdline *cl,
7837 __attribute__((unused)) void *data)
7839 struct cmd_syn_filter_result *res = parsed_result;
7840 struct rte_eth_syn_filter syn_filter;
7843 ret = rte_eth_dev_filter_supported(res->port_id,
7844 RTE_ETH_FILTER_SYN);
7846 printf("syn filter is not supported on port %u.\n",
7851 memset(&syn_filter, 0, sizeof(syn_filter));
7853 if (!strcmp(res->ops, "add")) {
7854 if (!strcmp(res->high, "high"))
7855 syn_filter.hig_pri = 1;
7857 syn_filter.hig_pri = 0;
7859 syn_filter.queue = res->queue_id;
7860 ret = rte_eth_dev_filter_ctrl(res->port_id,
7865 ret = rte_eth_dev_filter_ctrl(res->port_id,
7867 RTE_ETH_FILTER_DELETE,
7871 printf("syn filter programming error: (%s)\n",
7875 cmdline_parse_token_string_t cmd_syn_filter_filter =
7876 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7877 filter, "syn_filter");
7878 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7879 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7881 cmdline_parse_token_string_t cmd_syn_filter_ops =
7882 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7884 cmdline_parse_token_string_t cmd_syn_filter_priority =
7885 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7886 priority, "priority");
7887 cmdline_parse_token_string_t cmd_syn_filter_high =
7888 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7890 cmdline_parse_token_string_t cmd_syn_filter_queue =
7891 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7893 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7894 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7897 cmdline_parse_inst_t cmd_syn_filter = {
7898 .f = cmd_syn_filter_parsed,
7900 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7901 "<queue_id>: Add/Delete syn filter",
7903 (void *)&cmd_syn_filter_filter,
7904 (void *)&cmd_syn_filter_port_id,
7905 (void *)&cmd_syn_filter_ops,
7906 (void *)&cmd_syn_filter_priority,
7907 (void *)&cmd_syn_filter_high,
7908 (void *)&cmd_syn_filter_queue,
7909 (void *)&cmd_syn_filter_queue_id,
7914 /* *** ADD/REMOVE A 2tuple FILTER *** */
7915 struct cmd_2tuple_filter_result {
7916 cmdline_fixed_string_t filter;
7918 cmdline_fixed_string_t ops;
7919 cmdline_fixed_string_t dst_port;
7920 uint16_t dst_port_value;
7921 cmdline_fixed_string_t protocol;
7922 uint8_t protocol_value;
7923 cmdline_fixed_string_t mask;
7925 cmdline_fixed_string_t tcp_flags;
7926 uint8_t tcp_flags_value;
7927 cmdline_fixed_string_t priority;
7928 uint8_t priority_value;
7929 cmdline_fixed_string_t queue;
7934 cmd_2tuple_filter_parsed(void *parsed_result,
7935 __attribute__((unused)) struct cmdline *cl,
7936 __attribute__((unused)) void *data)
7938 struct rte_eth_ntuple_filter filter;
7939 struct cmd_2tuple_filter_result *res = parsed_result;
7942 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7944 printf("ntuple filter is not supported on port %u.\n",
7949 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7951 filter.flags = RTE_2TUPLE_FLAGS;
7952 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7953 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7954 filter.proto = res->protocol_value;
7955 filter.priority = res->priority_value;
7956 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7957 printf("nonzero tcp_flags is only meaningful"
7958 " when protocol is TCP.\n");
7961 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7962 printf("invalid TCP flags.\n");
7966 if (res->tcp_flags_value != 0) {
7967 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7968 filter.tcp_flags = res->tcp_flags_value;
7971 /* need convert to big endian. */
7972 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7973 filter.queue = res->queue_id;
7975 if (!strcmp(res->ops, "add"))
7976 ret = rte_eth_dev_filter_ctrl(res->port_id,
7977 RTE_ETH_FILTER_NTUPLE,
7981 ret = rte_eth_dev_filter_ctrl(res->port_id,
7982 RTE_ETH_FILTER_NTUPLE,
7983 RTE_ETH_FILTER_DELETE,
7986 printf("2tuple filter programming error: (%s)\n",
7991 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7992 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7993 filter, "2tuple_filter");
7994 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7995 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7997 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7998 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8000 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8001 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8002 dst_port, "dst_port");
8003 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8004 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8005 dst_port_value, UINT16);
8006 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8007 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8008 protocol, "protocol");
8009 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8010 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8011 protocol_value, UINT8);
8012 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8013 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8015 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8016 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8018 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8019 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8020 tcp_flags, "tcp_flags");
8021 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8022 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8023 tcp_flags_value, UINT8);
8024 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8025 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8026 priority, "priority");
8027 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8028 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8029 priority_value, UINT8);
8030 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8031 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8033 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8034 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8037 cmdline_parse_inst_t cmd_2tuple_filter = {
8038 .f = cmd_2tuple_filter_parsed,
8040 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8041 "<value> mask <value> tcp_flags <value> priority <value> queue "
8042 "<queue_id>: Add a 2tuple filter",
8044 (void *)&cmd_2tuple_filter_filter,
8045 (void *)&cmd_2tuple_filter_port_id,
8046 (void *)&cmd_2tuple_filter_ops,
8047 (void *)&cmd_2tuple_filter_dst_port,
8048 (void *)&cmd_2tuple_filter_dst_port_value,
8049 (void *)&cmd_2tuple_filter_protocol,
8050 (void *)&cmd_2tuple_filter_protocol_value,
8051 (void *)&cmd_2tuple_filter_mask,
8052 (void *)&cmd_2tuple_filter_mask_value,
8053 (void *)&cmd_2tuple_filter_tcp_flags,
8054 (void *)&cmd_2tuple_filter_tcp_flags_value,
8055 (void *)&cmd_2tuple_filter_priority,
8056 (void *)&cmd_2tuple_filter_priority_value,
8057 (void *)&cmd_2tuple_filter_queue,
8058 (void *)&cmd_2tuple_filter_queue_id,
8063 /* *** ADD/REMOVE A 5tuple FILTER *** */
8064 struct cmd_5tuple_filter_result {
8065 cmdline_fixed_string_t filter;
8067 cmdline_fixed_string_t ops;
8068 cmdline_fixed_string_t dst_ip;
8069 cmdline_ipaddr_t dst_ip_value;
8070 cmdline_fixed_string_t src_ip;
8071 cmdline_ipaddr_t src_ip_value;
8072 cmdline_fixed_string_t dst_port;
8073 uint16_t dst_port_value;
8074 cmdline_fixed_string_t src_port;
8075 uint16_t src_port_value;
8076 cmdline_fixed_string_t protocol;
8077 uint8_t protocol_value;
8078 cmdline_fixed_string_t mask;
8080 cmdline_fixed_string_t tcp_flags;
8081 uint8_t tcp_flags_value;
8082 cmdline_fixed_string_t priority;
8083 uint8_t priority_value;
8084 cmdline_fixed_string_t queue;
8089 cmd_5tuple_filter_parsed(void *parsed_result,
8090 __attribute__((unused)) struct cmdline *cl,
8091 __attribute__((unused)) void *data)
8093 struct rte_eth_ntuple_filter filter;
8094 struct cmd_5tuple_filter_result *res = parsed_result;
8097 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8099 printf("ntuple filter is not supported on port %u.\n",
8104 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8106 filter.flags = RTE_5TUPLE_FLAGS;
8107 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8108 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8109 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8110 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8111 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8112 filter.proto = res->protocol_value;
8113 filter.priority = res->priority_value;
8114 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8115 printf("nonzero tcp_flags is only meaningful"
8116 " when protocol is TCP.\n");
8119 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8120 printf("invalid TCP flags.\n");
8124 if (res->tcp_flags_value != 0) {
8125 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8126 filter.tcp_flags = res->tcp_flags_value;
8129 if (res->dst_ip_value.family == AF_INET)
8130 /* no need to convert, already big endian. */
8131 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8133 if (filter.dst_ip_mask == 0) {
8134 printf("can not support ipv6 involved compare.\n");
8140 if (res->src_ip_value.family == AF_INET)
8141 /* no need to convert, already big endian. */
8142 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8144 if (filter.src_ip_mask == 0) {
8145 printf("can not support ipv6 involved compare.\n");
8150 /* need convert to big endian. */
8151 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8152 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8153 filter.queue = res->queue_id;
8155 if (!strcmp(res->ops, "add"))
8156 ret = rte_eth_dev_filter_ctrl(res->port_id,
8157 RTE_ETH_FILTER_NTUPLE,
8161 ret = rte_eth_dev_filter_ctrl(res->port_id,
8162 RTE_ETH_FILTER_NTUPLE,
8163 RTE_ETH_FILTER_DELETE,
8166 printf("5tuple filter programming error: (%s)\n",
8170 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8171 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8172 filter, "5tuple_filter");
8173 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8174 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8176 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8177 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8179 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8180 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8182 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8183 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8185 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8186 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8188 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8189 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8191 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8192 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8193 dst_port, "dst_port");
8194 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8195 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8196 dst_port_value, UINT16);
8197 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8198 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8199 src_port, "src_port");
8200 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8201 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8202 src_port_value, UINT16);
8203 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8204 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8205 protocol, "protocol");
8206 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8207 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8208 protocol_value, UINT8);
8209 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8210 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8212 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8213 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8215 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8216 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8217 tcp_flags, "tcp_flags");
8218 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8219 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8220 tcp_flags_value, UINT8);
8221 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8222 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8223 priority, "priority");
8224 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8225 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8226 priority_value, UINT8);
8227 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8228 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8230 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8231 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8234 cmdline_parse_inst_t cmd_5tuple_filter = {
8235 .f = cmd_5tuple_filter_parsed,
8237 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8238 "src_ip <value> dst_port <value> src_port <value> "
8239 "protocol <value> mask <value> tcp_flags <value> "
8240 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8242 (void *)&cmd_5tuple_filter_filter,
8243 (void *)&cmd_5tuple_filter_port_id,
8244 (void *)&cmd_5tuple_filter_ops,
8245 (void *)&cmd_5tuple_filter_dst_ip,
8246 (void *)&cmd_5tuple_filter_dst_ip_value,
8247 (void *)&cmd_5tuple_filter_src_ip,
8248 (void *)&cmd_5tuple_filter_src_ip_value,
8249 (void *)&cmd_5tuple_filter_dst_port,
8250 (void *)&cmd_5tuple_filter_dst_port_value,
8251 (void *)&cmd_5tuple_filter_src_port,
8252 (void *)&cmd_5tuple_filter_src_port_value,
8253 (void *)&cmd_5tuple_filter_protocol,
8254 (void *)&cmd_5tuple_filter_protocol_value,
8255 (void *)&cmd_5tuple_filter_mask,
8256 (void *)&cmd_5tuple_filter_mask_value,
8257 (void *)&cmd_5tuple_filter_tcp_flags,
8258 (void *)&cmd_5tuple_filter_tcp_flags_value,
8259 (void *)&cmd_5tuple_filter_priority,
8260 (void *)&cmd_5tuple_filter_priority_value,
8261 (void *)&cmd_5tuple_filter_queue,
8262 (void *)&cmd_5tuple_filter_queue_id,
8267 /* *** ADD/REMOVE A flex FILTER *** */
8268 struct cmd_flex_filter_result {
8269 cmdline_fixed_string_t filter;
8270 cmdline_fixed_string_t ops;
8272 cmdline_fixed_string_t len;
8274 cmdline_fixed_string_t bytes;
8275 cmdline_fixed_string_t bytes_value;
8276 cmdline_fixed_string_t mask;
8277 cmdline_fixed_string_t mask_value;
8278 cmdline_fixed_string_t priority;
8279 uint8_t priority_value;
8280 cmdline_fixed_string_t queue;
8284 static int xdigit2val(unsigned char c)
8289 else if (isupper(c))
8297 cmd_flex_filter_parsed(void *parsed_result,
8298 __attribute__((unused)) struct cmdline *cl,
8299 __attribute__((unused)) void *data)
8302 struct rte_eth_flex_filter filter;
8303 struct cmd_flex_filter_result *res = parsed_result;
8304 char *bytes_ptr, *mask_ptr;
8305 uint16_t len, i, j = 0;
8310 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8311 printf("the len exceed the max length 128\n");
8314 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8315 filter.len = res->len_value;
8316 filter.priority = res->priority_value;
8317 filter.queue = res->queue_id;
8318 bytes_ptr = res->bytes_value;
8319 mask_ptr = res->mask_value;
8321 /* translate bytes string to array. */
8322 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8323 (bytes_ptr[1] == 'X')))
8325 len = strnlen(bytes_ptr, res->len_value * 2);
8326 if (len == 0 || (len % 8 != 0)) {
8327 printf("please check len and bytes input\n");
8330 for (i = 0; i < len; i++) {
8332 if (isxdigit(c) == 0) {
8333 /* invalid characters. */
8334 printf("invalid input\n");
8337 val = xdigit2val(c);
8340 filter.bytes[j] = byte;
8341 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8348 /* translate mask string to uint8_t array. */
8349 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8350 (mask_ptr[1] == 'X')))
8352 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8354 printf("invalid input\n");
8359 for (i = 0; i < len; i++) {
8361 if (isxdigit(c) == 0) {
8362 /* invalid characters. */
8363 printf("invalid input\n");
8366 val = xdigit2val(c);
8369 filter.mask[j] = byte;
8370 printf("mask[%d]:%02x ", j, filter.mask[j]);
8378 if (!strcmp(res->ops, "add"))
8379 ret = rte_eth_dev_filter_ctrl(res->port_id,
8380 RTE_ETH_FILTER_FLEXIBLE,
8384 ret = rte_eth_dev_filter_ctrl(res->port_id,
8385 RTE_ETH_FILTER_FLEXIBLE,
8386 RTE_ETH_FILTER_DELETE,
8390 printf("flex filter setting error: (%s)\n", strerror(-ret));
8393 cmdline_parse_token_string_t cmd_flex_filter_filter =
8394 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8395 filter, "flex_filter");
8396 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8397 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8399 cmdline_parse_token_string_t cmd_flex_filter_ops =
8400 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8402 cmdline_parse_token_string_t cmd_flex_filter_len =
8403 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8405 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8406 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8408 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8409 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8411 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8412 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8414 cmdline_parse_token_string_t cmd_flex_filter_mask =
8415 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8417 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8418 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8420 cmdline_parse_token_string_t cmd_flex_filter_priority =
8421 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8422 priority, "priority");
8423 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8424 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8425 priority_value, UINT8);
8426 cmdline_parse_token_string_t cmd_flex_filter_queue =
8427 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8429 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8430 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8432 cmdline_parse_inst_t cmd_flex_filter = {
8433 .f = cmd_flex_filter_parsed,
8435 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8436 "<value> mask <value> priority <value> queue <queue_id>: "
8437 "Add/Del a flex filter",
8439 (void *)&cmd_flex_filter_filter,
8440 (void *)&cmd_flex_filter_port_id,
8441 (void *)&cmd_flex_filter_ops,
8442 (void *)&cmd_flex_filter_len,
8443 (void *)&cmd_flex_filter_len_value,
8444 (void *)&cmd_flex_filter_bytes,
8445 (void *)&cmd_flex_filter_bytes_value,
8446 (void *)&cmd_flex_filter_mask,
8447 (void *)&cmd_flex_filter_mask_value,
8448 (void *)&cmd_flex_filter_priority,
8449 (void *)&cmd_flex_filter_priority_value,
8450 (void *)&cmd_flex_filter_queue,
8451 (void *)&cmd_flex_filter_queue_id,
8456 /* *** Filters Control *** */
8458 /* *** deal with ethertype filter *** */
8459 struct cmd_ethertype_filter_result {
8460 cmdline_fixed_string_t filter;
8462 cmdline_fixed_string_t ops;
8463 cmdline_fixed_string_t mac;
8464 struct ether_addr mac_addr;
8465 cmdline_fixed_string_t ethertype;
8466 uint16_t ethertype_value;
8467 cmdline_fixed_string_t drop;
8468 cmdline_fixed_string_t queue;
8472 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8473 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8474 filter, "ethertype_filter");
8475 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8476 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8478 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8479 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8481 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8482 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8483 mac, "mac_addr#mac_ignr");
8484 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8485 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8487 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8488 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8489 ethertype, "ethertype");
8490 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8491 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8492 ethertype_value, UINT16);
8493 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8494 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8496 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8497 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8499 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8500 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8504 cmd_ethertype_filter_parsed(void *parsed_result,
8505 __attribute__((unused)) struct cmdline *cl,
8506 __attribute__((unused)) void *data)
8508 struct cmd_ethertype_filter_result *res = parsed_result;
8509 struct rte_eth_ethertype_filter filter;
8512 ret = rte_eth_dev_filter_supported(res->port_id,
8513 RTE_ETH_FILTER_ETHERTYPE);
8515 printf("ethertype filter is not supported on port %u.\n",
8520 memset(&filter, 0, sizeof(filter));
8521 if (!strcmp(res->mac, "mac_addr")) {
8522 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8523 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8524 sizeof(struct ether_addr));
8526 if (!strcmp(res->drop, "drop"))
8527 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8528 filter.ether_type = res->ethertype_value;
8529 filter.queue = res->queue_id;
8531 if (!strcmp(res->ops, "add"))
8532 ret = rte_eth_dev_filter_ctrl(res->port_id,
8533 RTE_ETH_FILTER_ETHERTYPE,
8537 ret = rte_eth_dev_filter_ctrl(res->port_id,
8538 RTE_ETH_FILTER_ETHERTYPE,
8539 RTE_ETH_FILTER_DELETE,
8542 printf("ethertype filter programming error: (%s)\n",
8546 cmdline_parse_inst_t cmd_ethertype_filter = {
8547 .f = cmd_ethertype_filter_parsed,
8549 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8550 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8551 "Add or delete an ethertype filter entry",
8553 (void *)&cmd_ethertype_filter_filter,
8554 (void *)&cmd_ethertype_filter_port_id,
8555 (void *)&cmd_ethertype_filter_ops,
8556 (void *)&cmd_ethertype_filter_mac,
8557 (void *)&cmd_ethertype_filter_mac_addr,
8558 (void *)&cmd_ethertype_filter_ethertype,
8559 (void *)&cmd_ethertype_filter_ethertype_value,
8560 (void *)&cmd_ethertype_filter_drop,
8561 (void *)&cmd_ethertype_filter_queue,
8562 (void *)&cmd_ethertype_filter_queue_id,
8567 /* *** deal with flow director filter *** */
8568 struct cmd_flow_director_result {
8569 cmdline_fixed_string_t flow_director_filter;
8571 cmdline_fixed_string_t mode;
8572 cmdline_fixed_string_t mode_value;
8573 cmdline_fixed_string_t ops;
8574 cmdline_fixed_string_t flow;
8575 cmdline_fixed_string_t flow_type;
8576 cmdline_fixed_string_t ether;
8577 uint16_t ether_type;
8578 cmdline_fixed_string_t src;
8579 cmdline_ipaddr_t ip_src;
8581 cmdline_fixed_string_t dst;
8582 cmdline_ipaddr_t ip_dst;
8584 cmdline_fixed_string_t verify_tag;
8585 uint32_t verify_tag_value;
8586 cmdline_ipaddr_t tos;
8588 cmdline_ipaddr_t proto;
8589 uint8_t proto_value;
8590 cmdline_ipaddr_t ttl;
8592 cmdline_fixed_string_t vlan;
8593 uint16_t vlan_value;
8594 cmdline_fixed_string_t flexbytes;
8595 cmdline_fixed_string_t flexbytes_value;
8596 cmdline_fixed_string_t pf_vf;
8597 cmdline_fixed_string_t drop;
8598 cmdline_fixed_string_t queue;
8600 cmdline_fixed_string_t fd_id;
8601 uint32_t fd_id_value;
8602 cmdline_fixed_string_t mac;
8603 struct ether_addr mac_addr;
8604 cmdline_fixed_string_t tunnel;
8605 cmdline_fixed_string_t tunnel_type;
8606 cmdline_fixed_string_t tunnel_id;
8607 uint32_t tunnel_id_value;
8611 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8614 const char *p, *p0 = q_arg;
8616 unsigned long int_fld;
8617 char *str_fld[max_num];
8622 p = strchr(p0, '(');
8626 p0 = strchr(p, ')');
8631 if (size >= sizeof(s))
8634 snprintf(s, sizeof(s), "%.*s", size, p);
8635 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8636 if (ret < 0 || ret > max_num)
8638 for (i = 0; i < ret; i++) {
8640 int_fld = strtoul(str_fld[i], &end, 0);
8641 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8643 flexbytes[i] = (uint8_t)int_fld;
8649 str2flowtype(char *string)
8652 static const struct {
8655 } flowtype_str[] = {
8656 {"raw", RTE_ETH_FLOW_RAW},
8657 {"ipv4", RTE_ETH_FLOW_IPV4},
8658 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8659 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8660 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8661 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8662 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8663 {"ipv6", RTE_ETH_FLOW_IPV6},
8664 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8665 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8666 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8667 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8668 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8669 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8672 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8673 if (!strcmp(flowtype_str[i].str, string))
8674 return flowtype_str[i].type;
8676 return RTE_ETH_FLOW_UNKNOWN;
8679 static enum rte_eth_fdir_tunnel_type
8680 str2fdir_tunneltype(char *string)
8684 static const struct {
8686 enum rte_eth_fdir_tunnel_type type;
8687 } tunneltype_str[] = {
8688 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8689 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8692 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8693 if (!strcmp(tunneltype_str[i].str, string))
8694 return tunneltype_str[i].type;
8696 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8699 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8701 if ((ip_addr).family == AF_INET) \
8702 (ip) = (ip_addr).addr.ipv4.s_addr; \
8704 printf("invalid parameter.\n"); \
8709 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8711 if ((ip_addr).family == AF_INET6) \
8712 (void)rte_memcpy(&(ip), \
8713 &((ip_addr).addr.ipv6), \
8714 sizeof(struct in6_addr)); \
8716 printf("invalid parameter.\n"); \
8722 cmd_flow_director_filter_parsed(void *parsed_result,
8723 __attribute__((unused)) struct cmdline *cl,
8724 __attribute__((unused)) void *data)
8726 struct cmd_flow_director_result *res = parsed_result;
8727 struct rte_eth_fdir_filter entry;
8728 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8730 unsigned long vf_id;
8733 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8735 printf("flow director is not supported on port %u.\n",
8739 memset(flexbytes, 0, sizeof(flexbytes));
8740 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8742 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8743 if (strcmp(res->mode_value, "MAC-VLAN")) {
8744 printf("Please set mode to MAC-VLAN.\n");
8747 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8748 if (strcmp(res->mode_value, "Tunnel")) {
8749 printf("Please set mode to Tunnel.\n");
8753 if (strcmp(res->mode_value, "IP")) {
8754 printf("Please set mode to IP.\n");
8757 entry.input.flow_type = str2flowtype(res->flow_type);
8760 ret = parse_flexbytes(res->flexbytes_value,
8762 RTE_ETH_FDIR_MAX_FLEXLEN);
8764 printf("error: Cannot parse flexbytes input.\n");
8768 switch (entry.input.flow_type) {
8769 case RTE_ETH_FLOW_FRAG_IPV4:
8770 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8771 entry.input.flow.ip4_flow.proto = res->proto_value;
8773 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8774 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8775 IPV4_ADDR_TO_UINT(res->ip_dst,
8776 entry.input.flow.ip4_flow.dst_ip);
8777 IPV4_ADDR_TO_UINT(res->ip_src,
8778 entry.input.flow.ip4_flow.src_ip);
8779 entry.input.flow.ip4_flow.tos = res->tos_value;
8780 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8781 /* need convert to big endian. */
8782 entry.input.flow.udp4_flow.dst_port =
8783 rte_cpu_to_be_16(res->port_dst);
8784 entry.input.flow.udp4_flow.src_port =
8785 rte_cpu_to_be_16(res->port_src);
8787 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8788 IPV4_ADDR_TO_UINT(res->ip_dst,
8789 entry.input.flow.sctp4_flow.ip.dst_ip);
8790 IPV4_ADDR_TO_UINT(res->ip_src,
8791 entry.input.flow.sctp4_flow.ip.src_ip);
8792 entry.input.flow.ip4_flow.tos = res->tos_value;
8793 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8794 /* need convert to big endian. */
8795 entry.input.flow.sctp4_flow.dst_port =
8796 rte_cpu_to_be_16(res->port_dst);
8797 entry.input.flow.sctp4_flow.src_port =
8798 rte_cpu_to_be_16(res->port_src);
8799 entry.input.flow.sctp4_flow.verify_tag =
8800 rte_cpu_to_be_32(res->verify_tag_value);
8802 case RTE_ETH_FLOW_FRAG_IPV6:
8803 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8804 entry.input.flow.ipv6_flow.proto = res->proto_value;
8806 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8807 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8808 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8809 entry.input.flow.ipv6_flow.dst_ip);
8810 IPV6_ADDR_TO_ARRAY(res->ip_src,
8811 entry.input.flow.ipv6_flow.src_ip);
8812 entry.input.flow.ipv6_flow.tc = res->tos_value;
8813 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8814 /* need convert to big endian. */
8815 entry.input.flow.udp6_flow.dst_port =
8816 rte_cpu_to_be_16(res->port_dst);
8817 entry.input.flow.udp6_flow.src_port =
8818 rte_cpu_to_be_16(res->port_src);
8820 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8821 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8822 entry.input.flow.sctp6_flow.ip.dst_ip);
8823 IPV6_ADDR_TO_ARRAY(res->ip_src,
8824 entry.input.flow.sctp6_flow.ip.src_ip);
8825 entry.input.flow.ipv6_flow.tc = res->tos_value;
8826 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8827 /* need convert to big endian. */
8828 entry.input.flow.sctp6_flow.dst_port =
8829 rte_cpu_to_be_16(res->port_dst);
8830 entry.input.flow.sctp6_flow.src_port =
8831 rte_cpu_to_be_16(res->port_src);
8832 entry.input.flow.sctp6_flow.verify_tag =
8833 rte_cpu_to_be_32(res->verify_tag_value);
8835 case RTE_ETH_FLOW_L2_PAYLOAD:
8836 entry.input.flow.l2_flow.ether_type =
8837 rte_cpu_to_be_16(res->ether_type);
8843 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8844 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8846 sizeof(struct ether_addr));
8848 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8849 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8851 sizeof(struct ether_addr));
8852 entry.input.flow.tunnel_flow.tunnel_type =
8853 str2fdir_tunneltype(res->tunnel_type);
8854 entry.input.flow.tunnel_flow.tunnel_id =
8855 rte_cpu_to_be_32(res->tunnel_id_value);
8858 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8860 RTE_ETH_FDIR_MAX_FLEXLEN);
8862 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8864 entry.action.flex_off = 0; /*use 0 by default */
8865 if (!strcmp(res->drop, "drop"))
8866 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8868 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8870 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8871 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8872 if (!strcmp(res->pf_vf, "pf"))
8873 entry.input.flow_ext.is_vf = 0;
8874 else if (!strncmp(res->pf_vf, "vf", 2)) {
8875 struct rte_eth_dev_info dev_info;
8877 memset(&dev_info, 0, sizeof(dev_info));
8878 rte_eth_dev_info_get(res->port_id, &dev_info);
8880 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8881 if (errno != 0 || *end != '\0' ||
8882 vf_id >= dev_info.max_vfs) {
8883 printf("invalid parameter %s.\n", res->pf_vf);
8886 entry.input.flow_ext.is_vf = 1;
8887 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8889 printf("invalid parameter %s.\n", res->pf_vf);
8894 /* set to report FD ID by default */
8895 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8896 entry.action.rx_queue = res->queue_id;
8897 entry.soft_id = res->fd_id_value;
8898 if (!strcmp(res->ops, "add"))
8899 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8900 RTE_ETH_FILTER_ADD, &entry);
8901 else if (!strcmp(res->ops, "del"))
8902 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8903 RTE_ETH_FILTER_DELETE, &entry);
8905 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8906 RTE_ETH_FILTER_UPDATE, &entry);
8908 printf("flow director programming error: (%s)\n",
8912 cmdline_parse_token_string_t cmd_flow_director_filter =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8914 flow_director_filter, "flow_director_filter");
8915 cmdline_parse_token_num_t cmd_flow_director_port_id =
8916 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8918 cmdline_parse_token_string_t cmd_flow_director_ops =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8920 ops, "add#del#update");
8921 cmdline_parse_token_string_t cmd_flow_director_flow =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8926 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8927 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8928 cmdline_parse_token_string_t cmd_flow_director_ether =
8929 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8931 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8932 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8933 ether_type, UINT16);
8934 cmdline_parse_token_string_t cmd_flow_director_src =
8935 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8937 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8938 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8940 cmdline_parse_token_num_t cmd_flow_director_port_src =
8941 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8943 cmdline_parse_token_string_t cmd_flow_director_dst =
8944 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8946 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8947 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8949 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8950 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8952 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8954 verify_tag, "verify_tag");
8955 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8956 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8957 verify_tag_value, UINT32);
8958 cmdline_parse_token_string_t cmd_flow_director_tos =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8961 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8962 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8964 cmdline_parse_token_string_t cmd_flow_director_proto =
8965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8967 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8968 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8969 proto_value, UINT8);
8970 cmdline_parse_token_string_t cmd_flow_director_ttl =
8971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8973 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8974 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8976 cmdline_parse_token_string_t cmd_flow_director_vlan =
8977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8979 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8980 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8981 vlan_value, UINT16);
8982 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8984 flexbytes, "flexbytes");
8985 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8986 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8987 flexbytes_value, NULL);
8988 cmdline_parse_token_string_t cmd_flow_director_drop =
8989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8991 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8992 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8994 cmdline_parse_token_string_t cmd_flow_director_queue =
8995 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8997 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8998 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9000 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9001 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9003 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9004 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9005 fd_id_value, UINT32);
9007 cmdline_parse_token_string_t cmd_flow_director_mode =
9008 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9010 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9011 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9013 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9014 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9015 mode_value, "MAC-VLAN");
9016 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9017 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9018 mode_value, "Tunnel");
9019 cmdline_parse_token_string_t cmd_flow_director_mac =
9020 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9022 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9023 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9025 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9026 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9028 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9029 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9030 tunnel_type, "NVGRE#VxLAN");
9031 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9032 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9033 tunnel_id, "tunnel-id");
9034 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9035 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9036 tunnel_id_value, UINT32);
9038 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9039 .f = cmd_flow_director_filter_parsed,
9041 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9042 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9043 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9044 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9045 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9046 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9047 "fd_id <fd_id_value>: "
9048 "Add or delete an ip flow director entry on NIC",
9050 (void *)&cmd_flow_director_filter,
9051 (void *)&cmd_flow_director_port_id,
9052 (void *)&cmd_flow_director_mode,
9053 (void *)&cmd_flow_director_mode_ip,
9054 (void *)&cmd_flow_director_ops,
9055 (void *)&cmd_flow_director_flow,
9056 (void *)&cmd_flow_director_flow_type,
9057 (void *)&cmd_flow_director_src,
9058 (void *)&cmd_flow_director_ip_src,
9059 (void *)&cmd_flow_director_dst,
9060 (void *)&cmd_flow_director_ip_dst,
9061 (void *)&cmd_flow_director_tos,
9062 (void *)&cmd_flow_director_tos_value,
9063 (void *)&cmd_flow_director_proto,
9064 (void *)&cmd_flow_director_proto_value,
9065 (void *)&cmd_flow_director_ttl,
9066 (void *)&cmd_flow_director_ttl_value,
9067 (void *)&cmd_flow_director_vlan,
9068 (void *)&cmd_flow_director_vlan_value,
9069 (void *)&cmd_flow_director_flexbytes,
9070 (void *)&cmd_flow_director_flexbytes_value,
9071 (void *)&cmd_flow_director_drop,
9072 (void *)&cmd_flow_director_pf_vf,
9073 (void *)&cmd_flow_director_queue,
9074 (void *)&cmd_flow_director_queue_id,
9075 (void *)&cmd_flow_director_fd_id,
9076 (void *)&cmd_flow_director_fd_id_value,
9081 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9082 .f = cmd_flow_director_filter_parsed,
9084 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9085 "director entry on NIC",
9087 (void *)&cmd_flow_director_filter,
9088 (void *)&cmd_flow_director_port_id,
9089 (void *)&cmd_flow_director_mode,
9090 (void *)&cmd_flow_director_mode_ip,
9091 (void *)&cmd_flow_director_ops,
9092 (void *)&cmd_flow_director_flow,
9093 (void *)&cmd_flow_director_flow_type,
9094 (void *)&cmd_flow_director_src,
9095 (void *)&cmd_flow_director_ip_src,
9096 (void *)&cmd_flow_director_port_src,
9097 (void *)&cmd_flow_director_dst,
9098 (void *)&cmd_flow_director_ip_dst,
9099 (void *)&cmd_flow_director_port_dst,
9100 (void *)&cmd_flow_director_tos,
9101 (void *)&cmd_flow_director_tos_value,
9102 (void *)&cmd_flow_director_ttl,
9103 (void *)&cmd_flow_director_ttl_value,
9104 (void *)&cmd_flow_director_vlan,
9105 (void *)&cmd_flow_director_vlan_value,
9106 (void *)&cmd_flow_director_flexbytes,
9107 (void *)&cmd_flow_director_flexbytes_value,
9108 (void *)&cmd_flow_director_drop,
9109 (void *)&cmd_flow_director_pf_vf,
9110 (void *)&cmd_flow_director_queue,
9111 (void *)&cmd_flow_director_queue_id,
9112 (void *)&cmd_flow_director_fd_id,
9113 (void *)&cmd_flow_director_fd_id_value,
9118 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9119 .f = cmd_flow_director_filter_parsed,
9121 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9122 "director entry on NIC",
9124 (void *)&cmd_flow_director_filter,
9125 (void *)&cmd_flow_director_port_id,
9126 (void *)&cmd_flow_director_mode,
9127 (void *)&cmd_flow_director_mode_ip,
9128 (void *)&cmd_flow_director_ops,
9129 (void *)&cmd_flow_director_flow,
9130 (void *)&cmd_flow_director_flow_type,
9131 (void *)&cmd_flow_director_src,
9132 (void *)&cmd_flow_director_ip_src,
9133 (void *)&cmd_flow_director_port_dst,
9134 (void *)&cmd_flow_director_dst,
9135 (void *)&cmd_flow_director_ip_dst,
9136 (void *)&cmd_flow_director_port_dst,
9137 (void *)&cmd_flow_director_verify_tag,
9138 (void *)&cmd_flow_director_verify_tag_value,
9139 (void *)&cmd_flow_director_tos,
9140 (void *)&cmd_flow_director_tos_value,
9141 (void *)&cmd_flow_director_ttl,
9142 (void *)&cmd_flow_director_ttl_value,
9143 (void *)&cmd_flow_director_vlan,
9144 (void *)&cmd_flow_director_vlan_value,
9145 (void *)&cmd_flow_director_flexbytes,
9146 (void *)&cmd_flow_director_flexbytes_value,
9147 (void *)&cmd_flow_director_drop,
9148 (void *)&cmd_flow_director_pf_vf,
9149 (void *)&cmd_flow_director_queue,
9150 (void *)&cmd_flow_director_queue_id,
9151 (void *)&cmd_flow_director_fd_id,
9152 (void *)&cmd_flow_director_fd_id_value,
9157 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9158 .f = cmd_flow_director_filter_parsed,
9160 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9161 "director entry on NIC",
9163 (void *)&cmd_flow_director_filter,
9164 (void *)&cmd_flow_director_port_id,
9165 (void *)&cmd_flow_director_mode,
9166 (void *)&cmd_flow_director_mode_ip,
9167 (void *)&cmd_flow_director_ops,
9168 (void *)&cmd_flow_director_flow,
9169 (void *)&cmd_flow_director_flow_type,
9170 (void *)&cmd_flow_director_ether,
9171 (void *)&cmd_flow_director_ether_type,
9172 (void *)&cmd_flow_director_flexbytes,
9173 (void *)&cmd_flow_director_flexbytes_value,
9174 (void *)&cmd_flow_director_drop,
9175 (void *)&cmd_flow_director_pf_vf,
9176 (void *)&cmd_flow_director_queue,
9177 (void *)&cmd_flow_director_queue_id,
9178 (void *)&cmd_flow_director_fd_id,
9179 (void *)&cmd_flow_director_fd_id_value,
9184 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9185 .f = cmd_flow_director_filter_parsed,
9187 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9188 "director entry on NIC",
9190 (void *)&cmd_flow_director_filter,
9191 (void *)&cmd_flow_director_port_id,
9192 (void *)&cmd_flow_director_mode,
9193 (void *)&cmd_flow_director_mode_mac_vlan,
9194 (void *)&cmd_flow_director_ops,
9195 (void *)&cmd_flow_director_mac,
9196 (void *)&cmd_flow_director_mac_addr,
9197 (void *)&cmd_flow_director_vlan,
9198 (void *)&cmd_flow_director_vlan_value,
9199 (void *)&cmd_flow_director_flexbytes,
9200 (void *)&cmd_flow_director_flexbytes_value,
9201 (void *)&cmd_flow_director_drop,
9202 (void *)&cmd_flow_director_queue,
9203 (void *)&cmd_flow_director_queue_id,
9204 (void *)&cmd_flow_director_fd_id,
9205 (void *)&cmd_flow_director_fd_id_value,
9210 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9211 .f = cmd_flow_director_filter_parsed,
9213 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9214 "director entry on NIC",
9216 (void *)&cmd_flow_director_filter,
9217 (void *)&cmd_flow_director_port_id,
9218 (void *)&cmd_flow_director_mode,
9219 (void *)&cmd_flow_director_mode_tunnel,
9220 (void *)&cmd_flow_director_ops,
9221 (void *)&cmd_flow_director_mac,
9222 (void *)&cmd_flow_director_mac_addr,
9223 (void *)&cmd_flow_director_vlan,
9224 (void *)&cmd_flow_director_vlan_value,
9225 (void *)&cmd_flow_director_tunnel,
9226 (void *)&cmd_flow_director_tunnel_type,
9227 (void *)&cmd_flow_director_tunnel_id,
9228 (void *)&cmd_flow_director_tunnel_id_value,
9229 (void *)&cmd_flow_director_flexbytes,
9230 (void *)&cmd_flow_director_flexbytes_value,
9231 (void *)&cmd_flow_director_drop,
9232 (void *)&cmd_flow_director_queue,
9233 (void *)&cmd_flow_director_queue_id,
9234 (void *)&cmd_flow_director_fd_id,
9235 (void *)&cmd_flow_director_fd_id_value,
9240 struct cmd_flush_flow_director_result {
9241 cmdline_fixed_string_t flush_flow_director;
9245 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9246 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9247 flush_flow_director, "flush_flow_director");
9248 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9249 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9253 cmd_flush_flow_director_parsed(void *parsed_result,
9254 __attribute__((unused)) struct cmdline *cl,
9255 __attribute__((unused)) void *data)
9257 struct cmd_flow_director_result *res = parsed_result;
9260 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9262 printf("flow director is not supported on port %u.\n",
9267 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9268 RTE_ETH_FILTER_FLUSH, NULL);
9270 printf("flow director table flushing error: (%s)\n",
9274 cmdline_parse_inst_t cmd_flush_flow_director = {
9275 .f = cmd_flush_flow_director_parsed,
9277 .help_str = "flush_flow_director <port_id>: "
9278 "Flush all flow director entries of a device on NIC",
9280 (void *)&cmd_flush_flow_director_flush,
9281 (void *)&cmd_flush_flow_director_port_id,
9286 /* *** deal with flow director mask *** */
9287 struct cmd_flow_director_mask_result {
9288 cmdline_fixed_string_t flow_director_mask;
9290 cmdline_fixed_string_t mode;
9291 cmdline_fixed_string_t mode_value;
9292 cmdline_fixed_string_t vlan;
9294 cmdline_fixed_string_t src_mask;
9295 cmdline_ipaddr_t ipv4_src;
9296 cmdline_ipaddr_t ipv6_src;
9298 cmdline_fixed_string_t dst_mask;
9299 cmdline_ipaddr_t ipv4_dst;
9300 cmdline_ipaddr_t ipv6_dst;
9302 cmdline_fixed_string_t mac;
9303 uint8_t mac_addr_byte_mask;
9304 cmdline_fixed_string_t tunnel_id;
9305 uint32_t tunnel_id_mask;
9306 cmdline_fixed_string_t tunnel_type;
9307 uint8_t tunnel_type_mask;
9311 cmd_flow_director_mask_parsed(void *parsed_result,
9312 __attribute__((unused)) struct cmdline *cl,
9313 __attribute__((unused)) void *data)
9315 struct cmd_flow_director_mask_result *res = parsed_result;
9316 struct rte_eth_fdir_masks *mask;
9317 struct rte_port *port;
9319 if (res->port_id > nb_ports) {
9320 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9324 port = &ports[res->port_id];
9325 /** Check if the port is not started **/
9326 if (port->port_status != RTE_PORT_STOPPED) {
9327 printf("Please stop port %d first\n", res->port_id);
9331 mask = &port->dev_conf.fdir_conf.mask;
9333 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9334 if (strcmp(res->mode_value, "MAC-VLAN")) {
9335 printf("Please set mode to MAC-VLAN.\n");
9339 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9340 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9341 if (strcmp(res->mode_value, "Tunnel")) {
9342 printf("Please set mode to Tunnel.\n");
9346 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9347 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9348 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9349 mask->tunnel_type_mask = res->tunnel_type_mask;
9351 if (strcmp(res->mode_value, "IP")) {
9352 printf("Please set mode to IP.\n");
9356 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9357 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9358 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9359 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9360 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9361 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9362 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9365 cmd_reconfig_device_queue(res->port_id, 1, 1);
9368 cmdline_parse_token_string_t cmd_flow_director_mask =
9369 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9370 flow_director_mask, "flow_director_mask");
9371 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9372 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9374 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9375 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9377 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9378 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9380 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9382 src_mask, "src_mask");
9383 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9384 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9386 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9387 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9389 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9390 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9392 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9394 dst_mask, "dst_mask");
9395 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9396 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9398 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9399 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9401 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9402 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9405 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9408 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9409 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9411 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9413 mode_value, "MAC-VLAN");
9414 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9416 mode_value, "Tunnel");
9417 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9420 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9421 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9422 mac_addr_byte_mask, UINT8);
9423 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9425 tunnel_type, "tunnel-type");
9426 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9427 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9428 tunnel_type_mask, UINT8);
9429 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9431 tunnel_id, "tunnel-id");
9432 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9433 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9434 tunnel_id_mask, UINT32);
9436 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9437 .f = cmd_flow_director_mask_parsed,
9439 .help_str = "flow_director_mask ... : "
9440 "Set IP mode flow director's mask on NIC",
9442 (void *)&cmd_flow_director_mask,
9443 (void *)&cmd_flow_director_mask_port_id,
9444 (void *)&cmd_flow_director_mask_mode,
9445 (void *)&cmd_flow_director_mask_mode_ip,
9446 (void *)&cmd_flow_director_mask_vlan,
9447 (void *)&cmd_flow_director_mask_vlan_value,
9448 (void *)&cmd_flow_director_mask_src,
9449 (void *)&cmd_flow_director_mask_ipv4_src,
9450 (void *)&cmd_flow_director_mask_ipv6_src,
9451 (void *)&cmd_flow_director_mask_port_src,
9452 (void *)&cmd_flow_director_mask_dst,
9453 (void *)&cmd_flow_director_mask_ipv4_dst,
9454 (void *)&cmd_flow_director_mask_ipv6_dst,
9455 (void *)&cmd_flow_director_mask_port_dst,
9460 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9461 .f = cmd_flow_director_mask_parsed,
9463 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9464 "flow director's mask on NIC",
9466 (void *)&cmd_flow_director_mask,
9467 (void *)&cmd_flow_director_mask_port_id,
9468 (void *)&cmd_flow_director_mask_mode,
9469 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9470 (void *)&cmd_flow_director_mask_vlan,
9471 (void *)&cmd_flow_director_mask_vlan_value,
9476 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9477 .f = cmd_flow_director_mask_parsed,
9479 .help_str = "flow_director_mask ... : Set tunnel mode "
9480 "flow director's mask on NIC",
9482 (void *)&cmd_flow_director_mask,
9483 (void *)&cmd_flow_director_mask_port_id,
9484 (void *)&cmd_flow_director_mask_mode,
9485 (void *)&cmd_flow_director_mask_mode_tunnel,
9486 (void *)&cmd_flow_director_mask_vlan,
9487 (void *)&cmd_flow_director_mask_vlan_value,
9488 (void *)&cmd_flow_director_mask_mac,
9489 (void *)&cmd_flow_director_mask_mac_value,
9490 (void *)&cmd_flow_director_mask_tunnel_type,
9491 (void *)&cmd_flow_director_mask_tunnel_type_value,
9492 (void *)&cmd_flow_director_mask_tunnel_id,
9493 (void *)&cmd_flow_director_mask_tunnel_id_value,
9498 /* *** deal with flow director mask on flexible payload *** */
9499 struct cmd_flow_director_flex_mask_result {
9500 cmdline_fixed_string_t flow_director_flexmask;
9502 cmdline_fixed_string_t flow;
9503 cmdline_fixed_string_t flow_type;
9504 cmdline_fixed_string_t mask;
9508 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9509 __attribute__((unused)) struct cmdline *cl,
9510 __attribute__((unused)) void *data)
9512 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9513 struct rte_eth_fdir_info fdir_info;
9514 struct rte_eth_fdir_flex_mask flex_mask;
9515 struct rte_port *port;
9516 uint32_t flow_type_mask;
9520 if (res->port_id > nb_ports) {
9521 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9525 port = &ports[res->port_id];
9526 /** Check if the port is not started **/
9527 if (port->port_status != RTE_PORT_STOPPED) {
9528 printf("Please stop port %d first\n", res->port_id);
9532 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9533 ret = parse_flexbytes(res->mask,
9535 RTE_ETH_FDIR_MAX_FLEXLEN);
9537 printf("error: Cannot parse mask input.\n");
9541 memset(&fdir_info, 0, sizeof(fdir_info));
9542 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9543 RTE_ETH_FILTER_INFO, &fdir_info);
9545 printf("Cannot get FDir filter info\n");
9549 if (!strcmp(res->flow_type, "none")) {
9550 /* means don't specify the flow type */
9551 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9552 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9553 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9554 0, sizeof(struct rte_eth_fdir_flex_mask));
9555 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9556 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9558 sizeof(struct rte_eth_fdir_flex_mask));
9559 cmd_reconfig_device_queue(res->port_id, 1, 1);
9562 flow_type_mask = fdir_info.flow_types_mask[0];
9563 if (!strcmp(res->flow_type, "all")) {
9564 if (!flow_type_mask) {
9565 printf("No flow type supported\n");
9568 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9569 if (flow_type_mask & (1 << i)) {
9570 flex_mask.flow_type = i;
9571 fdir_set_flex_mask(res->port_id, &flex_mask);
9574 cmd_reconfig_device_queue(res->port_id, 1, 1);
9577 flex_mask.flow_type = str2flowtype(res->flow_type);
9578 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9579 printf("Flow type %s not supported on port %d\n",
9580 res->flow_type, res->port_id);
9583 fdir_set_flex_mask(res->port_id, &flex_mask);
9584 cmd_reconfig_device_queue(res->port_id, 1, 1);
9587 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9589 flow_director_flexmask,
9590 "flow_director_flex_mask");
9591 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9592 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9594 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9595 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9597 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9598 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9599 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9600 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9601 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9605 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9606 .f = cmd_flow_director_flex_mask_parsed,
9608 .help_str = "flow_director_flex_mask ... : "
9609 "Set flow director's flex mask on NIC",
9611 (void *)&cmd_flow_director_flexmask,
9612 (void *)&cmd_flow_director_flexmask_port_id,
9613 (void *)&cmd_flow_director_flexmask_flow,
9614 (void *)&cmd_flow_director_flexmask_flow_type,
9615 (void *)&cmd_flow_director_flexmask_mask,
9620 /* *** deal with flow director flexible payload configuration *** */
9621 struct cmd_flow_director_flexpayload_result {
9622 cmdline_fixed_string_t flow_director_flexpayload;
9624 cmdline_fixed_string_t payload_layer;
9625 cmdline_fixed_string_t payload_cfg;
9629 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9632 const char *p, *p0 = q_arg;
9634 unsigned long int_fld;
9635 char *str_fld[max_num];
9640 p = strchr(p0, '(');
9644 p0 = strchr(p, ')');
9649 if (size >= sizeof(s))
9652 snprintf(s, sizeof(s), "%.*s", size, p);
9653 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9654 if (ret < 0 || ret > max_num)
9656 for (i = 0; i < ret; i++) {
9658 int_fld = strtoul(str_fld[i], &end, 0);
9659 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9661 offsets[i] = (uint16_t)int_fld;
9667 cmd_flow_director_flxpld_parsed(void *parsed_result,
9668 __attribute__((unused)) struct cmdline *cl,
9669 __attribute__((unused)) void *data)
9671 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9672 struct rte_eth_flex_payload_cfg flex_cfg;
9673 struct rte_port *port;
9676 if (res->port_id > nb_ports) {
9677 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9681 port = &ports[res->port_id];
9682 /** Check if the port is not started **/
9683 if (port->port_status != RTE_PORT_STOPPED) {
9684 printf("Please stop port %d first\n", res->port_id);
9688 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9690 if (!strcmp(res->payload_layer, "raw"))
9691 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9692 else if (!strcmp(res->payload_layer, "l2"))
9693 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9694 else if (!strcmp(res->payload_layer, "l3"))
9695 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9696 else if (!strcmp(res->payload_layer, "l4"))
9697 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9699 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9700 RTE_ETH_FDIR_MAX_FLEXLEN);
9702 printf("error: Cannot parse flex payload input.\n");
9706 fdir_set_flex_payload(res->port_id, &flex_cfg);
9707 cmd_reconfig_device_queue(res->port_id, 1, 1);
9710 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9712 flow_director_flexpayload,
9713 "flow_director_flex_payload");
9714 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9715 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9717 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9718 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9719 payload_layer, "raw#l2#l3#l4");
9720 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9721 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9724 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9725 .f = cmd_flow_director_flxpld_parsed,
9727 .help_str = "flow_director_flexpayload ... : "
9728 "Set flow director's flex payload on NIC",
9730 (void *)&cmd_flow_director_flexpayload,
9731 (void *)&cmd_flow_director_flexpayload_port_id,
9732 (void *)&cmd_flow_director_flexpayload_payload_layer,
9733 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9738 /* Generic flow interface command. */
9739 extern cmdline_parse_inst_t cmd_flow;
9741 /* *** Classification Filters Control *** */
9742 /* *** Get symmetric hash enable per port *** */
9743 struct cmd_get_sym_hash_ena_per_port_result {
9744 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9749 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9750 __rte_unused struct cmdline *cl,
9751 __rte_unused void *data)
9753 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9754 struct rte_eth_hash_filter_info info;
9757 if (rte_eth_dev_filter_supported(res->port_id,
9758 RTE_ETH_FILTER_HASH) < 0) {
9759 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9764 memset(&info, 0, sizeof(info));
9765 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9766 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9767 RTE_ETH_FILTER_GET, &info);
9770 printf("Cannot get symmetric hash enable per port "
9771 "on port %u\n", res->port_id);
9775 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9776 "enabled" : "disabled", res->port_id);
9779 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9780 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9781 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9782 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9783 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9786 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9787 .f = cmd_get_sym_hash_per_port_parsed,
9789 .help_str = "get_sym_hash_ena_per_port <port_id>",
9791 (void *)&cmd_get_sym_hash_ena_per_port_all,
9792 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9797 /* *** Set symmetric hash enable per port *** */
9798 struct cmd_set_sym_hash_ena_per_port_result {
9799 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9800 cmdline_fixed_string_t enable;
9805 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9806 __rte_unused struct cmdline *cl,
9807 __rte_unused void *data)
9809 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9810 struct rte_eth_hash_filter_info info;
9813 if (rte_eth_dev_filter_supported(res->port_id,
9814 RTE_ETH_FILTER_HASH) < 0) {
9815 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9820 memset(&info, 0, sizeof(info));
9821 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9822 if (!strcmp(res->enable, "enable"))
9823 info.info.enable = 1;
9824 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9825 RTE_ETH_FILTER_SET, &info);
9827 printf("Cannot set symmetric hash enable per port on "
9828 "port %u\n", res->port_id);
9831 printf("Symmetric hash has been set to %s on port %u\n",
9832 res->enable, res->port_id);
9835 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9836 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9837 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9838 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9839 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9841 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9842 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9843 enable, "enable#disable");
9845 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9846 .f = cmd_set_sym_hash_per_port_parsed,
9848 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9850 (void *)&cmd_set_sym_hash_ena_per_port_all,
9851 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9852 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9857 /* Get global config of hash function */
9858 struct cmd_get_hash_global_config_result {
9859 cmdline_fixed_string_t get_hash_global_config;
9864 flowtype_to_str(uint16_t ftype)
9871 {"ipv4", RTE_ETH_FLOW_IPV4},
9872 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9873 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9874 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9875 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9876 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9877 {"ipv6", RTE_ETH_FLOW_IPV6},
9878 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9879 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9880 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9881 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9882 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9883 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9884 {"port", RTE_ETH_FLOW_PORT},
9885 {"vxlan", RTE_ETH_FLOW_VXLAN},
9886 {"geneve", RTE_ETH_FLOW_GENEVE},
9887 {"nvgre", RTE_ETH_FLOW_NVGRE},
9890 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9891 if (ftype_table[i].ftype == ftype)
9892 return ftype_table[i].str;
9899 cmd_get_hash_global_config_parsed(void *parsed_result,
9900 __rte_unused struct cmdline *cl,
9901 __rte_unused void *data)
9903 struct cmd_get_hash_global_config_result *res = parsed_result;
9904 struct rte_eth_hash_filter_info info;
9905 uint32_t idx, offset;
9910 if (rte_eth_dev_filter_supported(res->port_id,
9911 RTE_ETH_FILTER_HASH) < 0) {
9912 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9917 memset(&info, 0, sizeof(info));
9918 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9919 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9920 RTE_ETH_FILTER_GET, &info);
9922 printf("Cannot get hash global configurations by port %d\n",
9927 switch (info.info.global_conf.hash_func) {
9928 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9929 printf("Hash function is Toeplitz\n");
9931 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9932 printf("Hash function is Simple XOR\n");
9935 printf("Unknown hash function\n");
9939 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9940 idx = i / UINT32_BIT;
9941 offset = i % UINT32_BIT;
9942 if (!(info.info.global_conf.valid_bit_mask[idx] &
9945 str = flowtype_to_str(i);
9948 printf("Symmetric hash is %s globally for flow type %s "
9950 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9951 (1UL << offset)) ? "enabled" : "disabled"), str,
9956 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9957 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9958 get_hash_global_config, "get_hash_global_config");
9959 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9960 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9963 cmdline_parse_inst_t cmd_get_hash_global_config = {
9964 .f = cmd_get_hash_global_config_parsed,
9966 .help_str = "get_hash_global_config <port_id>",
9968 (void *)&cmd_get_hash_global_config_all,
9969 (void *)&cmd_get_hash_global_config_port_id,
9974 /* Set global config of hash function */
9975 struct cmd_set_hash_global_config_result {
9976 cmdline_fixed_string_t set_hash_global_config;
9978 cmdline_fixed_string_t hash_func;
9979 cmdline_fixed_string_t flow_type;
9980 cmdline_fixed_string_t enable;
9984 cmd_set_hash_global_config_parsed(void *parsed_result,
9985 __rte_unused struct cmdline *cl,
9986 __rte_unused void *data)
9988 struct cmd_set_hash_global_config_result *res = parsed_result;
9989 struct rte_eth_hash_filter_info info;
9990 uint32_t ftype, idx, offset;
9993 if (rte_eth_dev_filter_supported(res->port_id,
9994 RTE_ETH_FILTER_HASH) < 0) {
9995 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9999 memset(&info, 0, sizeof(info));
10000 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10001 if (!strcmp(res->hash_func, "toeplitz"))
10002 info.info.global_conf.hash_func =
10003 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10004 else if (!strcmp(res->hash_func, "simple_xor"))
10005 info.info.global_conf.hash_func =
10006 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10007 else if (!strcmp(res->hash_func, "default"))
10008 info.info.global_conf.hash_func =
10009 RTE_ETH_HASH_FUNCTION_DEFAULT;
10011 ftype = str2flowtype(res->flow_type);
10012 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10013 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10014 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10015 if (!strcmp(res->enable, "enable"))
10016 info.info.global_conf.sym_hash_enable_mask[idx] |=
10018 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10019 RTE_ETH_FILTER_SET, &info);
10021 printf("Cannot set global hash configurations by port %d\n",
10024 printf("Global hash configurations have been set "
10025 "succcessfully by port %d\n", res->port_id);
10028 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10029 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10030 set_hash_global_config, "set_hash_global_config");
10031 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10032 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10034 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10035 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10036 hash_func, "toeplitz#simple_xor#default");
10037 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10038 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10040 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10041 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10042 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10043 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10044 enable, "enable#disable");
10046 cmdline_parse_inst_t cmd_set_hash_global_config = {
10047 .f = cmd_set_hash_global_config_parsed,
10049 .help_str = "set_hash_global_config <port_id> "
10050 "toeplitz|simple_xor|default "
10051 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10052 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10053 "l2_payload enable|disable",
10055 (void *)&cmd_set_hash_global_config_all,
10056 (void *)&cmd_set_hash_global_config_port_id,
10057 (void *)&cmd_set_hash_global_config_hash_func,
10058 (void *)&cmd_set_hash_global_config_flow_type,
10059 (void *)&cmd_set_hash_global_config_enable,
10064 /* Set hash input set */
10065 struct cmd_set_hash_input_set_result {
10066 cmdline_fixed_string_t set_hash_input_set;
10068 cmdline_fixed_string_t flow_type;
10069 cmdline_fixed_string_t inset_field;
10070 cmdline_fixed_string_t select;
10073 static enum rte_eth_input_set_field
10074 str2inset(char *string)
10078 static const struct {
10080 enum rte_eth_input_set_field inset;
10081 } inset_table[] = {
10082 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10083 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10084 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10085 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10086 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10087 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10088 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10089 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10090 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10091 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10092 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10093 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10094 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10095 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10096 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10097 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10098 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10099 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10100 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10101 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10102 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10103 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10104 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10105 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10106 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10107 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10108 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10109 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10110 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10111 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10112 {"none", RTE_ETH_INPUT_SET_NONE},
10115 for (i = 0; i < RTE_DIM(inset_table); i++) {
10116 if (!strcmp(string, inset_table[i].str))
10117 return inset_table[i].inset;
10120 return RTE_ETH_INPUT_SET_UNKNOWN;
10124 cmd_set_hash_input_set_parsed(void *parsed_result,
10125 __rte_unused struct cmdline *cl,
10126 __rte_unused void *data)
10128 struct cmd_set_hash_input_set_result *res = parsed_result;
10129 struct rte_eth_hash_filter_info info;
10131 memset(&info, 0, sizeof(info));
10132 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10133 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10134 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10135 info.info.input_set_conf.inset_size = 1;
10136 if (!strcmp(res->select, "select"))
10137 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10138 else if (!strcmp(res->select, "add"))
10139 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10140 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10141 RTE_ETH_FILTER_SET, &info);
10144 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10145 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10146 set_hash_input_set, "set_hash_input_set");
10147 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10148 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10150 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10151 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10153 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10154 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10155 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10156 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10158 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10159 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10160 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10161 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10162 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10164 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10165 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10166 select, "select#add");
10168 cmdline_parse_inst_t cmd_set_hash_input_set = {
10169 .f = cmd_set_hash_input_set_parsed,
10171 .help_str = "set_hash_input_set <port_id> "
10172 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10173 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10174 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10175 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10176 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10177 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10178 "fld-7th|fld-8th|none select|add",
10180 (void *)&cmd_set_hash_input_set_cmd,
10181 (void *)&cmd_set_hash_input_set_port_id,
10182 (void *)&cmd_set_hash_input_set_flow_type,
10183 (void *)&cmd_set_hash_input_set_field,
10184 (void *)&cmd_set_hash_input_set_select,
10189 /* Set flow director input set */
10190 struct cmd_set_fdir_input_set_result {
10191 cmdline_fixed_string_t set_fdir_input_set;
10193 cmdline_fixed_string_t flow_type;
10194 cmdline_fixed_string_t inset_field;
10195 cmdline_fixed_string_t select;
10199 cmd_set_fdir_input_set_parsed(void *parsed_result,
10200 __rte_unused struct cmdline *cl,
10201 __rte_unused void *data)
10203 struct cmd_set_fdir_input_set_result *res = parsed_result;
10204 struct rte_eth_fdir_filter_info info;
10206 memset(&info, 0, sizeof(info));
10207 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10208 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10209 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10210 info.info.input_set_conf.inset_size = 1;
10211 if (!strcmp(res->select, "select"))
10212 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10213 else if (!strcmp(res->select, "add"))
10214 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10215 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10216 RTE_ETH_FILTER_SET, &info);
10219 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10220 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10221 set_fdir_input_set, "set_fdir_input_set");
10222 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10223 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10225 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10226 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10228 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10229 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10230 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10231 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10233 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10234 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10235 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10236 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10237 "sctp-veri-tag#none");
10238 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10239 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10240 select, "select#add");
10242 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10243 .f = cmd_set_fdir_input_set_parsed,
10245 .help_str = "set_fdir_input_set <port_id> "
10246 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10247 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10248 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10249 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10250 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10251 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10252 "sctp-veri-tag|none select|add",
10254 (void *)&cmd_set_fdir_input_set_cmd,
10255 (void *)&cmd_set_fdir_input_set_port_id,
10256 (void *)&cmd_set_fdir_input_set_flow_type,
10257 (void *)&cmd_set_fdir_input_set_field,
10258 (void *)&cmd_set_fdir_input_set_select,
10263 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10264 struct cmd_mcast_addr_result {
10265 cmdline_fixed_string_t mcast_addr_cmd;
10266 cmdline_fixed_string_t what;
10268 struct ether_addr mc_addr;
10271 static void cmd_mcast_addr_parsed(void *parsed_result,
10272 __attribute__((unused)) struct cmdline *cl,
10273 __attribute__((unused)) void *data)
10275 struct cmd_mcast_addr_result *res = parsed_result;
10277 if (!is_multicast_ether_addr(&res->mc_addr)) {
10278 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10279 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10280 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10281 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10284 if (strcmp(res->what, "add") == 0)
10285 mcast_addr_add(res->port_num, &res->mc_addr);
10287 mcast_addr_remove(res->port_num, &res->mc_addr);
10290 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10291 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10292 mcast_addr_cmd, "mcast_addr");
10293 cmdline_parse_token_string_t cmd_mcast_addr_what =
10294 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10296 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10297 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10298 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10299 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10301 cmdline_parse_inst_t cmd_mcast_addr = {
10302 .f = cmd_mcast_addr_parsed,
10304 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10305 "Add/Remove multicast MAC address on port_id",
10307 (void *)&cmd_mcast_addr_cmd,
10308 (void *)&cmd_mcast_addr_what,
10309 (void *)&cmd_mcast_addr_portnum,
10310 (void *)&cmd_mcast_addr_addr,
10315 /* l2 tunnel config
10316 * only support E-tag now.
10319 /* Ether type config */
10320 struct cmd_config_l2_tunnel_eth_type_result {
10321 cmdline_fixed_string_t port;
10322 cmdline_fixed_string_t config;
10323 cmdline_fixed_string_t all;
10325 cmdline_fixed_string_t l2_tunnel;
10326 cmdline_fixed_string_t l2_tunnel_type;
10327 cmdline_fixed_string_t eth_type;
10328 uint16_t eth_type_val;
10331 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10332 TOKEN_STRING_INITIALIZER
10333 (struct cmd_config_l2_tunnel_eth_type_result,
10335 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10336 TOKEN_STRING_INITIALIZER
10337 (struct cmd_config_l2_tunnel_eth_type_result,
10339 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10340 TOKEN_STRING_INITIALIZER
10341 (struct cmd_config_l2_tunnel_eth_type_result,
10343 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10344 TOKEN_NUM_INITIALIZER
10345 (struct cmd_config_l2_tunnel_eth_type_result,
10347 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10348 TOKEN_STRING_INITIALIZER
10349 (struct cmd_config_l2_tunnel_eth_type_result,
10350 l2_tunnel, "l2-tunnel");
10351 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10352 TOKEN_STRING_INITIALIZER
10353 (struct cmd_config_l2_tunnel_eth_type_result,
10354 l2_tunnel_type, "E-tag");
10355 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10356 TOKEN_STRING_INITIALIZER
10357 (struct cmd_config_l2_tunnel_eth_type_result,
10358 eth_type, "ether-type");
10359 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10360 TOKEN_NUM_INITIALIZER
10361 (struct cmd_config_l2_tunnel_eth_type_result,
10362 eth_type_val, UINT16);
10364 static enum rte_eth_tunnel_type
10365 str2fdir_l2_tunnel_type(char *string)
10369 static const struct {
10371 enum rte_eth_tunnel_type type;
10372 } l2_tunnel_type_str[] = {
10373 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10376 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10377 if (!strcmp(l2_tunnel_type_str[i].str, string))
10378 return l2_tunnel_type_str[i].type;
10380 return RTE_TUNNEL_TYPE_NONE;
10383 /* ether type config for all ports */
10385 cmd_config_l2_tunnel_eth_type_all_parsed
10386 (void *parsed_result,
10387 __attribute__((unused)) struct cmdline *cl,
10388 __attribute__((unused)) void *data)
10390 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10391 struct rte_eth_l2_tunnel_conf entry;
10394 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10395 entry.ether_type = res->eth_type_val;
10397 RTE_ETH_FOREACH_DEV(pid) {
10398 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10402 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10403 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10405 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10407 (void *)&cmd_config_l2_tunnel_eth_type_port,
10408 (void *)&cmd_config_l2_tunnel_eth_type_config,
10409 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10410 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10411 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10412 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10413 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10418 /* ether type config for a specific port */
10420 cmd_config_l2_tunnel_eth_type_specific_parsed(
10421 void *parsed_result,
10422 __attribute__((unused)) struct cmdline *cl,
10423 __attribute__((unused)) void *data)
10425 struct cmd_config_l2_tunnel_eth_type_result *res =
10427 struct rte_eth_l2_tunnel_conf entry;
10429 if (port_id_is_invalid(res->id, ENABLED_WARN))
10432 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10433 entry.ether_type = res->eth_type_val;
10435 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10438 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10439 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10441 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10443 (void *)&cmd_config_l2_tunnel_eth_type_port,
10444 (void *)&cmd_config_l2_tunnel_eth_type_config,
10445 (void *)&cmd_config_l2_tunnel_eth_type_id,
10446 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10447 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10448 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10449 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10454 /* Enable/disable l2 tunnel */
10455 struct cmd_config_l2_tunnel_en_dis_result {
10456 cmdline_fixed_string_t port;
10457 cmdline_fixed_string_t config;
10458 cmdline_fixed_string_t all;
10460 cmdline_fixed_string_t l2_tunnel;
10461 cmdline_fixed_string_t l2_tunnel_type;
10462 cmdline_fixed_string_t en_dis;
10465 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10466 TOKEN_STRING_INITIALIZER
10467 (struct cmd_config_l2_tunnel_en_dis_result,
10469 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10470 TOKEN_STRING_INITIALIZER
10471 (struct cmd_config_l2_tunnel_en_dis_result,
10473 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10474 TOKEN_STRING_INITIALIZER
10475 (struct cmd_config_l2_tunnel_en_dis_result,
10477 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10478 TOKEN_NUM_INITIALIZER
10479 (struct cmd_config_l2_tunnel_en_dis_result,
10481 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10482 TOKEN_STRING_INITIALIZER
10483 (struct cmd_config_l2_tunnel_en_dis_result,
10484 l2_tunnel, "l2-tunnel");
10485 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10486 TOKEN_STRING_INITIALIZER
10487 (struct cmd_config_l2_tunnel_en_dis_result,
10488 l2_tunnel_type, "E-tag");
10489 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10490 TOKEN_STRING_INITIALIZER
10491 (struct cmd_config_l2_tunnel_en_dis_result,
10492 en_dis, "enable#disable");
10494 /* enable/disable l2 tunnel for all ports */
10496 cmd_config_l2_tunnel_en_dis_all_parsed(
10497 void *parsed_result,
10498 __attribute__((unused)) struct cmdline *cl,
10499 __attribute__((unused)) void *data)
10501 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10502 struct rte_eth_l2_tunnel_conf entry;
10506 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10508 if (!strcmp("enable", res->en_dis))
10513 RTE_ETH_FOREACH_DEV(pid) {
10514 rte_eth_dev_l2_tunnel_offload_set(pid,
10516 ETH_L2_TUNNEL_ENABLE_MASK,
10521 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10522 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10524 .help_str = "port config all l2-tunnel E-tag enable|disable",
10526 (void *)&cmd_config_l2_tunnel_en_dis_port,
10527 (void *)&cmd_config_l2_tunnel_en_dis_config,
10528 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10529 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10530 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10531 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10536 /* enable/disable l2 tunnel for a port */
10538 cmd_config_l2_tunnel_en_dis_specific_parsed(
10539 void *parsed_result,
10540 __attribute__((unused)) struct cmdline *cl,
10541 __attribute__((unused)) void *data)
10543 struct cmd_config_l2_tunnel_en_dis_result *res =
10545 struct rte_eth_l2_tunnel_conf entry;
10547 if (port_id_is_invalid(res->id, ENABLED_WARN))
10550 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10552 if (!strcmp("enable", res->en_dis))
10553 rte_eth_dev_l2_tunnel_offload_set(res->id,
10555 ETH_L2_TUNNEL_ENABLE_MASK,
10558 rte_eth_dev_l2_tunnel_offload_set(res->id,
10560 ETH_L2_TUNNEL_ENABLE_MASK,
10564 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10565 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10567 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10569 (void *)&cmd_config_l2_tunnel_en_dis_port,
10570 (void *)&cmd_config_l2_tunnel_en_dis_config,
10571 (void *)&cmd_config_l2_tunnel_en_dis_id,
10572 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10573 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10574 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10579 /* E-tag configuration */
10581 /* Common result structure for all E-tag configuration */
10582 struct cmd_config_e_tag_result {
10583 cmdline_fixed_string_t e_tag;
10584 cmdline_fixed_string_t set;
10585 cmdline_fixed_string_t insertion;
10586 cmdline_fixed_string_t stripping;
10587 cmdline_fixed_string_t forwarding;
10588 cmdline_fixed_string_t filter;
10589 cmdline_fixed_string_t add;
10590 cmdline_fixed_string_t del;
10591 cmdline_fixed_string_t on;
10592 cmdline_fixed_string_t off;
10593 cmdline_fixed_string_t on_off;
10594 cmdline_fixed_string_t port_tag_id;
10595 uint32_t port_tag_id_val;
10596 cmdline_fixed_string_t e_tag_id;
10597 uint16_t e_tag_id_val;
10598 cmdline_fixed_string_t dst_pool;
10599 uint8_t dst_pool_val;
10600 cmdline_fixed_string_t port;
10602 cmdline_fixed_string_t vf;
10606 /* Common CLI fields for all E-tag configuration */
10607 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10608 TOKEN_STRING_INITIALIZER
10609 (struct cmd_config_e_tag_result,
10611 cmdline_parse_token_string_t cmd_config_e_tag_set =
10612 TOKEN_STRING_INITIALIZER
10613 (struct cmd_config_e_tag_result,
10615 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10616 TOKEN_STRING_INITIALIZER
10617 (struct cmd_config_e_tag_result,
10618 insertion, "insertion");
10619 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10620 TOKEN_STRING_INITIALIZER
10621 (struct cmd_config_e_tag_result,
10622 stripping, "stripping");
10623 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10624 TOKEN_STRING_INITIALIZER
10625 (struct cmd_config_e_tag_result,
10626 forwarding, "forwarding");
10627 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10628 TOKEN_STRING_INITIALIZER
10629 (struct cmd_config_e_tag_result,
10631 cmdline_parse_token_string_t cmd_config_e_tag_add =
10632 TOKEN_STRING_INITIALIZER
10633 (struct cmd_config_e_tag_result,
10635 cmdline_parse_token_string_t cmd_config_e_tag_del =
10636 TOKEN_STRING_INITIALIZER
10637 (struct cmd_config_e_tag_result,
10639 cmdline_parse_token_string_t cmd_config_e_tag_on =
10640 TOKEN_STRING_INITIALIZER
10641 (struct cmd_config_e_tag_result,
10643 cmdline_parse_token_string_t cmd_config_e_tag_off =
10644 TOKEN_STRING_INITIALIZER
10645 (struct cmd_config_e_tag_result,
10647 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10648 TOKEN_STRING_INITIALIZER
10649 (struct cmd_config_e_tag_result,
10651 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10652 TOKEN_STRING_INITIALIZER
10653 (struct cmd_config_e_tag_result,
10654 port_tag_id, "port-tag-id");
10655 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10656 TOKEN_NUM_INITIALIZER
10657 (struct cmd_config_e_tag_result,
10658 port_tag_id_val, UINT32);
10659 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10660 TOKEN_STRING_INITIALIZER
10661 (struct cmd_config_e_tag_result,
10662 e_tag_id, "e-tag-id");
10663 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10664 TOKEN_NUM_INITIALIZER
10665 (struct cmd_config_e_tag_result,
10666 e_tag_id_val, UINT16);
10667 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10668 TOKEN_STRING_INITIALIZER
10669 (struct cmd_config_e_tag_result,
10670 dst_pool, "dst-pool");
10671 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10672 TOKEN_NUM_INITIALIZER
10673 (struct cmd_config_e_tag_result,
10674 dst_pool_val, UINT8);
10675 cmdline_parse_token_string_t cmd_config_e_tag_port =
10676 TOKEN_STRING_INITIALIZER
10677 (struct cmd_config_e_tag_result,
10679 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10680 TOKEN_NUM_INITIALIZER
10681 (struct cmd_config_e_tag_result,
10683 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10684 TOKEN_STRING_INITIALIZER
10685 (struct cmd_config_e_tag_result,
10687 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10688 TOKEN_NUM_INITIALIZER
10689 (struct cmd_config_e_tag_result,
10692 /* E-tag insertion configuration */
10694 cmd_config_e_tag_insertion_en_parsed(
10695 void *parsed_result,
10696 __attribute__((unused)) struct cmdline *cl,
10697 __attribute__((unused)) void *data)
10699 struct cmd_config_e_tag_result *res =
10701 struct rte_eth_l2_tunnel_conf entry;
10703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10706 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10707 entry.tunnel_id = res->port_tag_id_val;
10708 entry.vf_id = res->vf_id;
10709 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10711 ETH_L2_TUNNEL_INSERTION_MASK,
10716 cmd_config_e_tag_insertion_dis_parsed(
10717 void *parsed_result,
10718 __attribute__((unused)) struct cmdline *cl,
10719 __attribute__((unused)) void *data)
10721 struct cmd_config_e_tag_result *res =
10723 struct rte_eth_l2_tunnel_conf entry;
10725 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10728 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10729 entry.vf_id = res->vf_id;
10731 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10733 ETH_L2_TUNNEL_INSERTION_MASK,
10737 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10738 .f = cmd_config_e_tag_insertion_en_parsed,
10740 .help_str = "E-tag ... : E-tag insertion enable",
10742 (void *)&cmd_config_e_tag_e_tag,
10743 (void *)&cmd_config_e_tag_set,
10744 (void *)&cmd_config_e_tag_insertion,
10745 (void *)&cmd_config_e_tag_on,
10746 (void *)&cmd_config_e_tag_port_tag_id,
10747 (void *)&cmd_config_e_tag_port_tag_id_val,
10748 (void *)&cmd_config_e_tag_port,
10749 (void *)&cmd_config_e_tag_port_id,
10750 (void *)&cmd_config_e_tag_vf,
10751 (void *)&cmd_config_e_tag_vf_id,
10756 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10757 .f = cmd_config_e_tag_insertion_dis_parsed,
10759 .help_str = "E-tag ... : E-tag insertion disable",
10761 (void *)&cmd_config_e_tag_e_tag,
10762 (void *)&cmd_config_e_tag_set,
10763 (void *)&cmd_config_e_tag_insertion,
10764 (void *)&cmd_config_e_tag_off,
10765 (void *)&cmd_config_e_tag_port,
10766 (void *)&cmd_config_e_tag_port_id,
10767 (void *)&cmd_config_e_tag_vf,
10768 (void *)&cmd_config_e_tag_vf_id,
10773 /* E-tag stripping configuration */
10775 cmd_config_e_tag_stripping_parsed(
10776 void *parsed_result,
10777 __attribute__((unused)) struct cmdline *cl,
10778 __attribute__((unused)) void *data)
10780 struct cmd_config_e_tag_result *res =
10782 struct rte_eth_l2_tunnel_conf entry;
10784 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10787 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10789 if (!strcmp(res->on_off, "on"))
10790 rte_eth_dev_l2_tunnel_offload_set
10793 ETH_L2_TUNNEL_STRIPPING_MASK,
10796 rte_eth_dev_l2_tunnel_offload_set
10799 ETH_L2_TUNNEL_STRIPPING_MASK,
10803 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10804 .f = cmd_config_e_tag_stripping_parsed,
10806 .help_str = "E-tag ... : E-tag stripping enable/disable",
10808 (void *)&cmd_config_e_tag_e_tag,
10809 (void *)&cmd_config_e_tag_set,
10810 (void *)&cmd_config_e_tag_stripping,
10811 (void *)&cmd_config_e_tag_on_off,
10812 (void *)&cmd_config_e_tag_port,
10813 (void *)&cmd_config_e_tag_port_id,
10818 /* E-tag forwarding configuration */
10820 cmd_config_e_tag_forwarding_parsed(
10821 void *parsed_result,
10822 __attribute__((unused)) struct cmdline *cl,
10823 __attribute__((unused)) void *data)
10825 struct cmd_config_e_tag_result *res = parsed_result;
10826 struct rte_eth_l2_tunnel_conf entry;
10828 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10831 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10833 if (!strcmp(res->on_off, "on"))
10834 rte_eth_dev_l2_tunnel_offload_set
10837 ETH_L2_TUNNEL_FORWARDING_MASK,
10840 rte_eth_dev_l2_tunnel_offload_set
10843 ETH_L2_TUNNEL_FORWARDING_MASK,
10847 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10848 .f = cmd_config_e_tag_forwarding_parsed,
10850 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10852 (void *)&cmd_config_e_tag_e_tag,
10853 (void *)&cmd_config_e_tag_set,
10854 (void *)&cmd_config_e_tag_forwarding,
10855 (void *)&cmd_config_e_tag_on_off,
10856 (void *)&cmd_config_e_tag_port,
10857 (void *)&cmd_config_e_tag_port_id,
10862 /* E-tag filter configuration */
10864 cmd_config_e_tag_filter_add_parsed(
10865 void *parsed_result,
10866 __attribute__((unused)) struct cmdline *cl,
10867 __attribute__((unused)) void *data)
10869 struct cmd_config_e_tag_result *res = parsed_result;
10870 struct rte_eth_l2_tunnel_conf entry;
10873 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10876 if (res->e_tag_id_val > 0x3fff) {
10877 printf("e-tag-id must be equal or less than 0x3fff.\n");
10881 ret = rte_eth_dev_filter_supported(res->port_id,
10882 RTE_ETH_FILTER_L2_TUNNEL);
10884 printf("E-tag filter is not supported on port %u.\n",
10889 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10890 entry.tunnel_id = res->e_tag_id_val;
10891 entry.pool = res->dst_pool_val;
10893 ret = rte_eth_dev_filter_ctrl(res->port_id,
10894 RTE_ETH_FILTER_L2_TUNNEL,
10895 RTE_ETH_FILTER_ADD,
10898 printf("E-tag filter programming error: (%s)\n",
10902 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10903 .f = cmd_config_e_tag_filter_add_parsed,
10905 .help_str = "E-tag ... : E-tag filter add",
10907 (void *)&cmd_config_e_tag_e_tag,
10908 (void *)&cmd_config_e_tag_set,
10909 (void *)&cmd_config_e_tag_filter,
10910 (void *)&cmd_config_e_tag_add,
10911 (void *)&cmd_config_e_tag_e_tag_id,
10912 (void *)&cmd_config_e_tag_e_tag_id_val,
10913 (void *)&cmd_config_e_tag_dst_pool,
10914 (void *)&cmd_config_e_tag_dst_pool_val,
10915 (void *)&cmd_config_e_tag_port,
10916 (void *)&cmd_config_e_tag_port_id,
10922 cmd_config_e_tag_filter_del_parsed(
10923 void *parsed_result,
10924 __attribute__((unused)) struct cmdline *cl,
10925 __attribute__((unused)) void *data)
10927 struct cmd_config_e_tag_result *res = parsed_result;
10928 struct rte_eth_l2_tunnel_conf entry;
10931 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10934 if (res->e_tag_id_val > 0x3fff) {
10935 printf("e-tag-id must be less than 0x3fff.\n");
10939 ret = rte_eth_dev_filter_supported(res->port_id,
10940 RTE_ETH_FILTER_L2_TUNNEL);
10942 printf("E-tag filter is not supported on port %u.\n",
10947 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10948 entry.tunnel_id = res->e_tag_id_val;
10950 ret = rte_eth_dev_filter_ctrl(res->port_id,
10951 RTE_ETH_FILTER_L2_TUNNEL,
10952 RTE_ETH_FILTER_DELETE,
10955 printf("E-tag filter programming error: (%s)\n",
10959 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10960 .f = cmd_config_e_tag_filter_del_parsed,
10962 .help_str = "E-tag ... : E-tag filter delete",
10964 (void *)&cmd_config_e_tag_e_tag,
10965 (void *)&cmd_config_e_tag_set,
10966 (void *)&cmd_config_e_tag_filter,
10967 (void *)&cmd_config_e_tag_del,
10968 (void *)&cmd_config_e_tag_e_tag_id,
10969 (void *)&cmd_config_e_tag_e_tag_id_val,
10970 (void *)&cmd_config_e_tag_port,
10971 (void *)&cmd_config_e_tag_port_id,
10976 /* vf vlan anti spoof configuration */
10978 /* Common result structure for vf vlan anti spoof */
10979 struct cmd_vf_vlan_anti_spoof_result {
10980 cmdline_fixed_string_t set;
10981 cmdline_fixed_string_t vf;
10982 cmdline_fixed_string_t vlan;
10983 cmdline_fixed_string_t antispoof;
10986 cmdline_fixed_string_t on_off;
10989 /* Common CLI fields for vf vlan anti spoof enable disable */
10990 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10991 TOKEN_STRING_INITIALIZER
10992 (struct cmd_vf_vlan_anti_spoof_result,
10994 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10995 TOKEN_STRING_INITIALIZER
10996 (struct cmd_vf_vlan_anti_spoof_result,
10998 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10999 TOKEN_STRING_INITIALIZER
11000 (struct cmd_vf_vlan_anti_spoof_result,
11002 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11003 TOKEN_STRING_INITIALIZER
11004 (struct cmd_vf_vlan_anti_spoof_result,
11005 antispoof, "antispoof");
11006 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11007 TOKEN_NUM_INITIALIZER
11008 (struct cmd_vf_vlan_anti_spoof_result,
11010 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11011 TOKEN_NUM_INITIALIZER
11012 (struct cmd_vf_vlan_anti_spoof_result,
11014 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11015 TOKEN_STRING_INITIALIZER
11016 (struct cmd_vf_vlan_anti_spoof_result,
11020 cmd_set_vf_vlan_anti_spoof_parsed(
11021 void *parsed_result,
11022 __attribute__((unused)) struct cmdline *cl,
11023 __attribute__((unused)) void *data)
11025 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11026 int ret = -ENOTSUP;
11028 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11030 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11033 #ifdef RTE_LIBRTE_IXGBE_PMD
11034 if (ret == -ENOTSUP)
11035 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11036 res->vf_id, is_on);
11038 #ifdef RTE_LIBRTE_I40E_PMD
11039 if (ret == -ENOTSUP)
11040 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11041 res->vf_id, is_on);
11043 #ifdef RTE_LIBRTE_BNXT_PMD
11044 if (ret == -ENOTSUP)
11045 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11046 res->vf_id, is_on);
11053 printf("invalid vf_id %d\n", res->vf_id);
11056 printf("invalid port_id %d\n", res->port_id);
11059 printf("function not implemented\n");
11062 printf("programming error: (%s)\n", strerror(-ret));
11066 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11067 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11069 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11071 (void *)&cmd_vf_vlan_anti_spoof_set,
11072 (void *)&cmd_vf_vlan_anti_spoof_vf,
11073 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11074 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11075 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11076 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11077 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11082 /* vf mac anti spoof configuration */
11084 /* Common result structure for vf mac anti spoof */
11085 struct cmd_vf_mac_anti_spoof_result {
11086 cmdline_fixed_string_t set;
11087 cmdline_fixed_string_t vf;
11088 cmdline_fixed_string_t mac;
11089 cmdline_fixed_string_t antispoof;
11092 cmdline_fixed_string_t on_off;
11095 /* Common CLI fields for vf mac anti spoof enable disable */
11096 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11097 TOKEN_STRING_INITIALIZER
11098 (struct cmd_vf_mac_anti_spoof_result,
11100 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11101 TOKEN_STRING_INITIALIZER
11102 (struct cmd_vf_mac_anti_spoof_result,
11104 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11105 TOKEN_STRING_INITIALIZER
11106 (struct cmd_vf_mac_anti_spoof_result,
11108 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11109 TOKEN_STRING_INITIALIZER
11110 (struct cmd_vf_mac_anti_spoof_result,
11111 antispoof, "antispoof");
11112 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11113 TOKEN_NUM_INITIALIZER
11114 (struct cmd_vf_mac_anti_spoof_result,
11116 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11117 TOKEN_NUM_INITIALIZER
11118 (struct cmd_vf_mac_anti_spoof_result,
11120 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11121 TOKEN_STRING_INITIALIZER
11122 (struct cmd_vf_mac_anti_spoof_result,
11126 cmd_set_vf_mac_anti_spoof_parsed(
11127 void *parsed_result,
11128 __attribute__((unused)) struct cmdline *cl,
11129 __attribute__((unused)) void *data)
11131 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11132 int ret = -ENOTSUP;
11134 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11136 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11139 #ifdef RTE_LIBRTE_IXGBE_PMD
11140 if (ret == -ENOTSUP)
11141 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11142 res->vf_id, is_on);
11144 #ifdef RTE_LIBRTE_I40E_PMD
11145 if (ret == -ENOTSUP)
11146 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11147 res->vf_id, is_on);
11149 #ifdef RTE_LIBRTE_BNXT_PMD
11150 if (ret == -ENOTSUP)
11151 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11152 res->vf_id, is_on);
11159 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11162 printf("invalid port_id %d\n", res->port_id);
11165 printf("function not implemented\n");
11168 printf("programming error: (%s)\n", strerror(-ret));
11172 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11173 .f = cmd_set_vf_mac_anti_spoof_parsed,
11175 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11177 (void *)&cmd_vf_mac_anti_spoof_set,
11178 (void *)&cmd_vf_mac_anti_spoof_vf,
11179 (void *)&cmd_vf_mac_anti_spoof_mac,
11180 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11181 (void *)&cmd_vf_mac_anti_spoof_port_id,
11182 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11183 (void *)&cmd_vf_mac_anti_spoof_on_off,
11188 /* vf vlan strip queue configuration */
11190 /* Common result structure for vf mac anti spoof */
11191 struct cmd_vf_vlan_stripq_result {
11192 cmdline_fixed_string_t set;
11193 cmdline_fixed_string_t vf;
11194 cmdline_fixed_string_t vlan;
11195 cmdline_fixed_string_t stripq;
11198 cmdline_fixed_string_t on_off;
11201 /* Common CLI fields for vf vlan strip enable disable */
11202 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11203 TOKEN_STRING_INITIALIZER
11204 (struct cmd_vf_vlan_stripq_result,
11206 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11207 TOKEN_STRING_INITIALIZER
11208 (struct cmd_vf_vlan_stripq_result,
11210 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11211 TOKEN_STRING_INITIALIZER
11212 (struct cmd_vf_vlan_stripq_result,
11214 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11215 TOKEN_STRING_INITIALIZER
11216 (struct cmd_vf_vlan_stripq_result,
11218 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11219 TOKEN_NUM_INITIALIZER
11220 (struct cmd_vf_vlan_stripq_result,
11222 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11223 TOKEN_NUM_INITIALIZER
11224 (struct cmd_vf_vlan_stripq_result,
11226 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11227 TOKEN_STRING_INITIALIZER
11228 (struct cmd_vf_vlan_stripq_result,
11232 cmd_set_vf_vlan_stripq_parsed(
11233 void *parsed_result,
11234 __attribute__((unused)) struct cmdline *cl,
11235 __attribute__((unused)) void *data)
11237 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11238 int ret = -ENOTSUP;
11240 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11242 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11245 #ifdef RTE_LIBRTE_IXGBE_PMD
11246 if (ret == -ENOTSUP)
11247 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11248 res->vf_id, is_on);
11250 #ifdef RTE_LIBRTE_I40E_PMD
11251 if (ret == -ENOTSUP)
11252 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11253 res->vf_id, is_on);
11255 #ifdef RTE_LIBRTE_BNXT_PMD
11256 if (ret == -ENOTSUP)
11257 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11258 res->vf_id, is_on);
11265 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11268 printf("invalid port_id %d\n", res->port_id);
11271 printf("function not implemented\n");
11274 printf("programming error: (%s)\n", strerror(-ret));
11278 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11279 .f = cmd_set_vf_vlan_stripq_parsed,
11281 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11283 (void *)&cmd_vf_vlan_stripq_set,
11284 (void *)&cmd_vf_vlan_stripq_vf,
11285 (void *)&cmd_vf_vlan_stripq_vlan,
11286 (void *)&cmd_vf_vlan_stripq_stripq,
11287 (void *)&cmd_vf_vlan_stripq_port_id,
11288 (void *)&cmd_vf_vlan_stripq_vf_id,
11289 (void *)&cmd_vf_vlan_stripq_on_off,
11294 /* vf vlan insert configuration */
11296 /* Common result structure for vf vlan insert */
11297 struct cmd_vf_vlan_insert_result {
11298 cmdline_fixed_string_t set;
11299 cmdline_fixed_string_t vf;
11300 cmdline_fixed_string_t vlan;
11301 cmdline_fixed_string_t insert;
11307 /* Common CLI fields for vf vlan insert enable disable */
11308 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11309 TOKEN_STRING_INITIALIZER
11310 (struct cmd_vf_vlan_insert_result,
11312 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11313 TOKEN_STRING_INITIALIZER
11314 (struct cmd_vf_vlan_insert_result,
11316 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11317 TOKEN_STRING_INITIALIZER
11318 (struct cmd_vf_vlan_insert_result,
11320 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11321 TOKEN_STRING_INITIALIZER
11322 (struct cmd_vf_vlan_insert_result,
11324 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11325 TOKEN_NUM_INITIALIZER
11326 (struct cmd_vf_vlan_insert_result,
11328 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11329 TOKEN_NUM_INITIALIZER
11330 (struct cmd_vf_vlan_insert_result,
11332 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11333 TOKEN_NUM_INITIALIZER
11334 (struct cmd_vf_vlan_insert_result,
11338 cmd_set_vf_vlan_insert_parsed(
11339 void *parsed_result,
11340 __attribute__((unused)) struct cmdline *cl,
11341 __attribute__((unused)) void *data)
11343 struct cmd_vf_vlan_insert_result *res = parsed_result;
11344 int ret = -ENOTSUP;
11346 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11349 #ifdef RTE_LIBRTE_IXGBE_PMD
11350 if (ret == -ENOTSUP)
11351 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11354 #ifdef RTE_LIBRTE_I40E_PMD
11355 if (ret == -ENOTSUP)
11356 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11359 #ifdef RTE_LIBRTE_BNXT_PMD
11360 if (ret == -ENOTSUP)
11361 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11369 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11372 printf("invalid port_id %d\n", res->port_id);
11375 printf("function not implemented\n");
11378 printf("programming error: (%s)\n", strerror(-ret));
11382 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11383 .f = cmd_set_vf_vlan_insert_parsed,
11385 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11387 (void *)&cmd_vf_vlan_insert_set,
11388 (void *)&cmd_vf_vlan_insert_vf,
11389 (void *)&cmd_vf_vlan_insert_vlan,
11390 (void *)&cmd_vf_vlan_insert_insert,
11391 (void *)&cmd_vf_vlan_insert_port_id,
11392 (void *)&cmd_vf_vlan_insert_vf_id,
11393 (void *)&cmd_vf_vlan_insert_vlan_id,
11398 /* tx loopback configuration */
11400 /* Common result structure for tx loopback */
11401 struct cmd_tx_loopback_result {
11402 cmdline_fixed_string_t set;
11403 cmdline_fixed_string_t tx;
11404 cmdline_fixed_string_t loopback;
11406 cmdline_fixed_string_t on_off;
11409 /* Common CLI fields for tx loopback enable disable */
11410 cmdline_parse_token_string_t cmd_tx_loopback_set =
11411 TOKEN_STRING_INITIALIZER
11412 (struct cmd_tx_loopback_result,
11414 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11415 TOKEN_STRING_INITIALIZER
11416 (struct cmd_tx_loopback_result,
11418 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11419 TOKEN_STRING_INITIALIZER
11420 (struct cmd_tx_loopback_result,
11421 loopback, "loopback");
11422 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11423 TOKEN_NUM_INITIALIZER
11424 (struct cmd_tx_loopback_result,
11426 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11427 TOKEN_STRING_INITIALIZER
11428 (struct cmd_tx_loopback_result,
11432 cmd_set_tx_loopback_parsed(
11433 void *parsed_result,
11434 __attribute__((unused)) struct cmdline *cl,
11435 __attribute__((unused)) void *data)
11437 struct cmd_tx_loopback_result *res = parsed_result;
11438 int ret = -ENOTSUP;
11440 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11442 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11445 #ifdef RTE_LIBRTE_IXGBE_PMD
11446 if (ret == -ENOTSUP)
11447 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11449 #ifdef RTE_LIBRTE_I40E_PMD
11450 if (ret == -ENOTSUP)
11451 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11453 #ifdef RTE_LIBRTE_BNXT_PMD
11454 if (ret == -ENOTSUP)
11455 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11462 printf("invalid is_on %d\n", is_on);
11465 printf("invalid port_id %d\n", res->port_id);
11468 printf("function not implemented\n");
11471 printf("programming error: (%s)\n", strerror(-ret));
11475 cmdline_parse_inst_t cmd_set_tx_loopback = {
11476 .f = cmd_set_tx_loopback_parsed,
11478 .help_str = "set tx loopback <port_id> on|off",
11480 (void *)&cmd_tx_loopback_set,
11481 (void *)&cmd_tx_loopback_tx,
11482 (void *)&cmd_tx_loopback_loopback,
11483 (void *)&cmd_tx_loopback_port_id,
11484 (void *)&cmd_tx_loopback_on_off,
11489 /* all queues drop enable configuration */
11491 /* Common result structure for all queues drop enable */
11492 struct cmd_all_queues_drop_en_result {
11493 cmdline_fixed_string_t set;
11494 cmdline_fixed_string_t all;
11495 cmdline_fixed_string_t queues;
11496 cmdline_fixed_string_t drop;
11498 cmdline_fixed_string_t on_off;
11501 /* Common CLI fields for tx loopback enable disable */
11502 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11503 TOKEN_STRING_INITIALIZER
11504 (struct cmd_all_queues_drop_en_result,
11506 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11507 TOKEN_STRING_INITIALIZER
11508 (struct cmd_all_queues_drop_en_result,
11510 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11511 TOKEN_STRING_INITIALIZER
11512 (struct cmd_all_queues_drop_en_result,
11514 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11515 TOKEN_STRING_INITIALIZER
11516 (struct cmd_all_queues_drop_en_result,
11518 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11519 TOKEN_NUM_INITIALIZER
11520 (struct cmd_all_queues_drop_en_result,
11522 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11523 TOKEN_STRING_INITIALIZER
11524 (struct cmd_all_queues_drop_en_result,
11528 cmd_set_all_queues_drop_en_parsed(
11529 void *parsed_result,
11530 __attribute__((unused)) struct cmdline *cl,
11531 __attribute__((unused)) void *data)
11533 struct cmd_all_queues_drop_en_result *res = parsed_result;
11534 int ret = -ENOTSUP;
11535 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11537 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11540 #ifdef RTE_LIBRTE_IXGBE_PMD
11541 if (ret == -ENOTSUP)
11542 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11544 #ifdef RTE_LIBRTE_BNXT_PMD
11545 if (ret == -ENOTSUP)
11546 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11552 printf("invalid is_on %d\n", is_on);
11555 printf("invalid port_id %d\n", res->port_id);
11558 printf("function not implemented\n");
11561 printf("programming error: (%s)\n", strerror(-ret));
11565 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11566 .f = cmd_set_all_queues_drop_en_parsed,
11568 .help_str = "set all queues drop <port_id> on|off",
11570 (void *)&cmd_all_queues_drop_en_set,
11571 (void *)&cmd_all_queues_drop_en_all,
11572 (void *)&cmd_all_queues_drop_en_queues,
11573 (void *)&cmd_all_queues_drop_en_drop,
11574 (void *)&cmd_all_queues_drop_en_port_id,
11575 (void *)&cmd_all_queues_drop_en_on_off,
11580 /* vf split drop enable configuration */
11582 /* Common result structure for vf split drop enable */
11583 struct cmd_vf_split_drop_en_result {
11584 cmdline_fixed_string_t set;
11585 cmdline_fixed_string_t vf;
11586 cmdline_fixed_string_t split;
11587 cmdline_fixed_string_t drop;
11590 cmdline_fixed_string_t on_off;
11593 /* Common CLI fields for vf split drop enable disable */
11594 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11595 TOKEN_STRING_INITIALIZER
11596 (struct cmd_vf_split_drop_en_result,
11598 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11599 TOKEN_STRING_INITIALIZER
11600 (struct cmd_vf_split_drop_en_result,
11602 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11603 TOKEN_STRING_INITIALIZER
11604 (struct cmd_vf_split_drop_en_result,
11606 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11607 TOKEN_STRING_INITIALIZER
11608 (struct cmd_vf_split_drop_en_result,
11610 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11611 TOKEN_NUM_INITIALIZER
11612 (struct cmd_vf_split_drop_en_result,
11614 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11615 TOKEN_NUM_INITIALIZER
11616 (struct cmd_vf_split_drop_en_result,
11618 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11619 TOKEN_STRING_INITIALIZER
11620 (struct cmd_vf_split_drop_en_result,
11624 cmd_set_vf_split_drop_en_parsed(
11625 void *parsed_result,
11626 __attribute__((unused)) struct cmdline *cl,
11627 __attribute__((unused)) void *data)
11629 struct cmd_vf_split_drop_en_result *res = parsed_result;
11630 int ret = -ENOTSUP;
11631 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11633 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11636 #ifdef RTE_LIBRTE_IXGBE_PMD
11637 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11644 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11647 printf("invalid port_id %d\n", res->port_id);
11650 printf("not supported on port %d\n", res->port_id);
11653 printf("programming error: (%s)\n", strerror(-ret));
11657 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11658 .f = cmd_set_vf_split_drop_en_parsed,
11660 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11662 (void *)&cmd_vf_split_drop_en_set,
11663 (void *)&cmd_vf_split_drop_en_vf,
11664 (void *)&cmd_vf_split_drop_en_split,
11665 (void *)&cmd_vf_split_drop_en_drop,
11666 (void *)&cmd_vf_split_drop_en_port_id,
11667 (void *)&cmd_vf_split_drop_en_vf_id,
11668 (void *)&cmd_vf_split_drop_en_on_off,
11673 /* vf mac address configuration */
11675 /* Common result structure for vf mac address */
11676 struct cmd_set_vf_mac_addr_result {
11677 cmdline_fixed_string_t set;
11678 cmdline_fixed_string_t vf;
11679 cmdline_fixed_string_t mac;
11680 cmdline_fixed_string_t addr;
11683 struct ether_addr mac_addr;
11687 /* Common CLI fields for vf split drop enable disable */
11688 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11689 TOKEN_STRING_INITIALIZER
11690 (struct cmd_set_vf_mac_addr_result,
11692 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11693 TOKEN_STRING_INITIALIZER
11694 (struct cmd_set_vf_mac_addr_result,
11696 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11697 TOKEN_STRING_INITIALIZER
11698 (struct cmd_set_vf_mac_addr_result,
11700 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11701 TOKEN_STRING_INITIALIZER
11702 (struct cmd_set_vf_mac_addr_result,
11704 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11705 TOKEN_NUM_INITIALIZER
11706 (struct cmd_set_vf_mac_addr_result,
11708 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11709 TOKEN_NUM_INITIALIZER
11710 (struct cmd_set_vf_mac_addr_result,
11712 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11713 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11717 cmd_set_vf_mac_addr_parsed(
11718 void *parsed_result,
11719 __attribute__((unused)) struct cmdline *cl,
11720 __attribute__((unused)) void *data)
11722 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11723 int ret = -ENOTSUP;
11725 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11728 #ifdef RTE_LIBRTE_IXGBE_PMD
11729 if (ret == -ENOTSUP)
11730 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11733 #ifdef RTE_LIBRTE_I40E_PMD
11734 if (ret == -ENOTSUP)
11735 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11738 #ifdef RTE_LIBRTE_BNXT_PMD
11739 if (ret == -ENOTSUP)
11740 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11748 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11751 printf("invalid port_id %d\n", res->port_id);
11754 printf("function not implemented\n");
11757 printf("programming error: (%s)\n", strerror(-ret));
11761 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11762 .f = cmd_set_vf_mac_addr_parsed,
11764 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11766 (void *)&cmd_set_vf_mac_addr_set,
11767 (void *)&cmd_set_vf_mac_addr_vf,
11768 (void *)&cmd_set_vf_mac_addr_mac,
11769 (void *)&cmd_set_vf_mac_addr_addr,
11770 (void *)&cmd_set_vf_mac_addr_port_id,
11771 (void *)&cmd_set_vf_mac_addr_vf_id,
11772 (void *)&cmd_set_vf_mac_addr_mac_addr,
11777 /* MACsec configuration */
11779 /* Common result structure for MACsec offload enable */
11780 struct cmd_macsec_offload_on_result {
11781 cmdline_fixed_string_t set;
11782 cmdline_fixed_string_t macsec;
11783 cmdline_fixed_string_t offload;
11785 cmdline_fixed_string_t on;
11786 cmdline_fixed_string_t encrypt;
11787 cmdline_fixed_string_t en_on_off;
11788 cmdline_fixed_string_t replay_protect;
11789 cmdline_fixed_string_t rp_on_off;
11792 /* Common CLI fields for MACsec offload disable */
11793 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_macsec_offload_on_result,
11797 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11798 TOKEN_STRING_INITIALIZER
11799 (struct cmd_macsec_offload_on_result,
11801 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11802 TOKEN_STRING_INITIALIZER
11803 (struct cmd_macsec_offload_on_result,
11804 offload, "offload");
11805 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11806 TOKEN_NUM_INITIALIZER
11807 (struct cmd_macsec_offload_on_result,
11809 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_macsec_offload_on_result,
11813 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_macsec_offload_on_result,
11816 encrypt, "encrypt");
11817 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_macsec_offload_on_result,
11820 en_on_off, "on#off");
11821 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11822 TOKEN_STRING_INITIALIZER
11823 (struct cmd_macsec_offload_on_result,
11824 replay_protect, "replay-protect");
11825 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11826 TOKEN_STRING_INITIALIZER
11827 (struct cmd_macsec_offload_on_result,
11828 rp_on_off, "on#off");
11831 cmd_set_macsec_offload_on_parsed(
11832 void *parsed_result,
11833 __attribute__((unused)) struct cmdline *cl,
11834 __attribute__((unused)) void *data)
11836 struct cmd_macsec_offload_on_result *res = parsed_result;
11837 int ret = -ENOTSUP;
11838 portid_t port_id = res->port_id;
11839 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11840 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11842 if (port_id_is_invalid(port_id, ENABLED_WARN))
11845 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11846 #ifdef RTE_LIBRTE_IXGBE_PMD
11847 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11856 printf("invalid port_id %d\n", port_id);
11859 printf("not supported on port %d\n", port_id);
11862 printf("programming error: (%s)\n", strerror(-ret));
11866 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11867 .f = cmd_set_macsec_offload_on_parsed,
11869 .help_str = "set macsec offload <port_id> on "
11870 "encrypt on|off replay-protect on|off",
11872 (void *)&cmd_macsec_offload_on_set,
11873 (void *)&cmd_macsec_offload_on_macsec,
11874 (void *)&cmd_macsec_offload_on_offload,
11875 (void *)&cmd_macsec_offload_on_port_id,
11876 (void *)&cmd_macsec_offload_on_on,
11877 (void *)&cmd_macsec_offload_on_encrypt,
11878 (void *)&cmd_macsec_offload_on_en_on_off,
11879 (void *)&cmd_macsec_offload_on_replay_protect,
11880 (void *)&cmd_macsec_offload_on_rp_on_off,
11885 /* Common result structure for MACsec offload disable */
11886 struct cmd_macsec_offload_off_result {
11887 cmdline_fixed_string_t set;
11888 cmdline_fixed_string_t macsec;
11889 cmdline_fixed_string_t offload;
11891 cmdline_fixed_string_t off;
11894 /* Common CLI fields for MACsec offload disable */
11895 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11896 TOKEN_STRING_INITIALIZER
11897 (struct cmd_macsec_offload_off_result,
11899 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11900 TOKEN_STRING_INITIALIZER
11901 (struct cmd_macsec_offload_off_result,
11903 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11904 TOKEN_STRING_INITIALIZER
11905 (struct cmd_macsec_offload_off_result,
11906 offload, "offload");
11907 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11908 TOKEN_NUM_INITIALIZER
11909 (struct cmd_macsec_offload_off_result,
11911 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11912 TOKEN_STRING_INITIALIZER
11913 (struct cmd_macsec_offload_off_result,
11917 cmd_set_macsec_offload_off_parsed(
11918 void *parsed_result,
11919 __attribute__((unused)) struct cmdline *cl,
11920 __attribute__((unused)) void *data)
11922 struct cmd_macsec_offload_off_result *res = parsed_result;
11923 int ret = -ENOTSUP;
11924 portid_t port_id = res->port_id;
11926 if (port_id_is_invalid(port_id, ENABLED_WARN))
11929 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11930 #ifdef RTE_LIBRTE_IXGBE_PMD
11931 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11938 printf("invalid port_id %d\n", port_id);
11941 printf("not supported on port %d\n", port_id);
11944 printf("programming error: (%s)\n", strerror(-ret));
11948 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11949 .f = cmd_set_macsec_offload_off_parsed,
11951 .help_str = "set macsec offload <port_id> off",
11953 (void *)&cmd_macsec_offload_off_set,
11954 (void *)&cmd_macsec_offload_off_macsec,
11955 (void *)&cmd_macsec_offload_off_offload,
11956 (void *)&cmd_macsec_offload_off_port_id,
11957 (void *)&cmd_macsec_offload_off_off,
11962 /* Common result structure for MACsec secure connection configure */
11963 struct cmd_macsec_sc_result {
11964 cmdline_fixed_string_t set;
11965 cmdline_fixed_string_t macsec;
11966 cmdline_fixed_string_t sc;
11967 cmdline_fixed_string_t tx_rx;
11969 struct ether_addr mac;
11973 /* Common CLI fields for MACsec secure connection configure */
11974 cmdline_parse_token_string_t cmd_macsec_sc_set =
11975 TOKEN_STRING_INITIALIZER
11976 (struct cmd_macsec_sc_result,
11978 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11979 TOKEN_STRING_INITIALIZER
11980 (struct cmd_macsec_sc_result,
11982 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11983 TOKEN_STRING_INITIALIZER
11984 (struct cmd_macsec_sc_result,
11986 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11987 TOKEN_STRING_INITIALIZER
11988 (struct cmd_macsec_sc_result,
11990 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11991 TOKEN_NUM_INITIALIZER
11992 (struct cmd_macsec_sc_result,
11994 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11995 TOKEN_ETHERADDR_INITIALIZER
11996 (struct cmd_macsec_sc_result,
11998 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11999 TOKEN_NUM_INITIALIZER
12000 (struct cmd_macsec_sc_result,
12004 cmd_set_macsec_sc_parsed(
12005 void *parsed_result,
12006 __attribute__((unused)) struct cmdline *cl,
12007 __attribute__((unused)) void *data)
12009 struct cmd_macsec_sc_result *res = parsed_result;
12010 int ret = -ENOTSUP;
12011 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12013 #ifdef RTE_LIBRTE_IXGBE_PMD
12015 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12016 res->mac.addr_bytes) :
12017 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12018 res->mac.addr_bytes, res->pi);
12020 RTE_SET_USED(is_tx);
12026 printf("invalid port_id %d\n", res->port_id);
12029 printf("not supported on port %d\n", res->port_id);
12032 printf("programming error: (%s)\n", strerror(-ret));
12036 cmdline_parse_inst_t cmd_set_macsec_sc = {
12037 .f = cmd_set_macsec_sc_parsed,
12039 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12041 (void *)&cmd_macsec_sc_set,
12042 (void *)&cmd_macsec_sc_macsec,
12043 (void *)&cmd_macsec_sc_sc,
12044 (void *)&cmd_macsec_sc_tx_rx,
12045 (void *)&cmd_macsec_sc_port_id,
12046 (void *)&cmd_macsec_sc_mac,
12047 (void *)&cmd_macsec_sc_pi,
12052 /* Common result structure for MACsec secure connection configure */
12053 struct cmd_macsec_sa_result {
12054 cmdline_fixed_string_t set;
12055 cmdline_fixed_string_t macsec;
12056 cmdline_fixed_string_t sa;
12057 cmdline_fixed_string_t tx_rx;
12062 cmdline_fixed_string_t key;
12065 /* Common CLI fields for MACsec secure connection configure */
12066 cmdline_parse_token_string_t cmd_macsec_sa_set =
12067 TOKEN_STRING_INITIALIZER
12068 (struct cmd_macsec_sa_result,
12070 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12071 TOKEN_STRING_INITIALIZER
12072 (struct cmd_macsec_sa_result,
12074 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12075 TOKEN_STRING_INITIALIZER
12076 (struct cmd_macsec_sa_result,
12078 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12079 TOKEN_STRING_INITIALIZER
12080 (struct cmd_macsec_sa_result,
12082 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12083 TOKEN_NUM_INITIALIZER
12084 (struct cmd_macsec_sa_result,
12086 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12087 TOKEN_NUM_INITIALIZER
12088 (struct cmd_macsec_sa_result,
12090 cmdline_parse_token_num_t cmd_macsec_sa_an =
12091 TOKEN_NUM_INITIALIZER
12092 (struct cmd_macsec_sa_result,
12094 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12095 TOKEN_NUM_INITIALIZER
12096 (struct cmd_macsec_sa_result,
12098 cmdline_parse_token_string_t cmd_macsec_sa_key =
12099 TOKEN_STRING_INITIALIZER
12100 (struct cmd_macsec_sa_result,
12104 cmd_set_macsec_sa_parsed(
12105 void *parsed_result,
12106 __attribute__((unused)) struct cmdline *cl,
12107 __attribute__((unused)) void *data)
12109 struct cmd_macsec_sa_result *res = parsed_result;
12110 int ret = -ENOTSUP;
12111 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12112 uint8_t key[16] = { 0 };
12118 key_len = strlen(res->key) / 2;
12122 for (i = 0; i < key_len; i++) {
12123 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12126 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12129 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12132 #ifdef RTE_LIBRTE_IXGBE_PMD
12134 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12135 res->idx, res->an, res->pn, key) :
12136 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12137 res->idx, res->an, res->pn, key);
12139 RTE_SET_USED(is_tx);
12146 printf("invalid idx %d or an %d\n", res->idx, res->an);
12149 printf("invalid port_id %d\n", res->port_id);
12152 printf("not supported on port %d\n", res->port_id);
12155 printf("programming error: (%s)\n", strerror(-ret));
12159 cmdline_parse_inst_t cmd_set_macsec_sa = {
12160 .f = cmd_set_macsec_sa_parsed,
12162 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12164 (void *)&cmd_macsec_sa_set,
12165 (void *)&cmd_macsec_sa_macsec,
12166 (void *)&cmd_macsec_sa_sa,
12167 (void *)&cmd_macsec_sa_tx_rx,
12168 (void *)&cmd_macsec_sa_port_id,
12169 (void *)&cmd_macsec_sa_idx,
12170 (void *)&cmd_macsec_sa_an,
12171 (void *)&cmd_macsec_sa_pn,
12172 (void *)&cmd_macsec_sa_key,
12177 /* VF unicast promiscuous mode configuration */
12179 /* Common result structure for VF unicast promiscuous mode */
12180 struct cmd_vf_promisc_result {
12181 cmdline_fixed_string_t set;
12182 cmdline_fixed_string_t vf;
12183 cmdline_fixed_string_t promisc;
12186 cmdline_fixed_string_t on_off;
12189 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12190 cmdline_parse_token_string_t cmd_vf_promisc_set =
12191 TOKEN_STRING_INITIALIZER
12192 (struct cmd_vf_promisc_result,
12194 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12195 TOKEN_STRING_INITIALIZER
12196 (struct cmd_vf_promisc_result,
12198 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12199 TOKEN_STRING_INITIALIZER
12200 (struct cmd_vf_promisc_result,
12201 promisc, "promisc");
12202 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12203 TOKEN_NUM_INITIALIZER
12204 (struct cmd_vf_promisc_result,
12206 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12207 TOKEN_NUM_INITIALIZER
12208 (struct cmd_vf_promisc_result,
12210 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12211 TOKEN_STRING_INITIALIZER
12212 (struct cmd_vf_promisc_result,
12216 cmd_set_vf_promisc_parsed(
12217 void *parsed_result,
12218 __attribute__((unused)) struct cmdline *cl,
12219 __attribute__((unused)) void *data)
12221 struct cmd_vf_promisc_result *res = parsed_result;
12222 int ret = -ENOTSUP;
12224 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12229 #ifdef RTE_LIBRTE_I40E_PMD
12230 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12231 res->vf_id, is_on);
12238 printf("invalid vf_id %d\n", res->vf_id);
12241 printf("invalid port_id %d\n", res->port_id);
12244 printf("function not implemented\n");
12247 printf("programming error: (%s)\n", strerror(-ret));
12251 cmdline_parse_inst_t cmd_set_vf_promisc = {
12252 .f = cmd_set_vf_promisc_parsed,
12254 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12255 "Set unicast promiscuous mode for a VF from the PF",
12257 (void *)&cmd_vf_promisc_set,
12258 (void *)&cmd_vf_promisc_vf,
12259 (void *)&cmd_vf_promisc_promisc,
12260 (void *)&cmd_vf_promisc_port_id,
12261 (void *)&cmd_vf_promisc_vf_id,
12262 (void *)&cmd_vf_promisc_on_off,
12267 /* VF multicast promiscuous mode configuration */
12269 /* Common result structure for VF multicast promiscuous mode */
12270 struct cmd_vf_allmulti_result {
12271 cmdline_fixed_string_t set;
12272 cmdline_fixed_string_t vf;
12273 cmdline_fixed_string_t allmulti;
12276 cmdline_fixed_string_t on_off;
12279 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12280 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12281 TOKEN_STRING_INITIALIZER
12282 (struct cmd_vf_allmulti_result,
12284 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12285 TOKEN_STRING_INITIALIZER
12286 (struct cmd_vf_allmulti_result,
12288 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12289 TOKEN_STRING_INITIALIZER
12290 (struct cmd_vf_allmulti_result,
12291 allmulti, "allmulti");
12292 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12293 TOKEN_NUM_INITIALIZER
12294 (struct cmd_vf_allmulti_result,
12296 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12297 TOKEN_NUM_INITIALIZER
12298 (struct cmd_vf_allmulti_result,
12300 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12301 TOKEN_STRING_INITIALIZER
12302 (struct cmd_vf_allmulti_result,
12306 cmd_set_vf_allmulti_parsed(
12307 void *parsed_result,
12308 __attribute__((unused)) struct cmdline *cl,
12309 __attribute__((unused)) void *data)
12311 struct cmd_vf_allmulti_result *res = parsed_result;
12312 int ret = -ENOTSUP;
12314 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12316 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12319 #ifdef RTE_LIBRTE_I40E_PMD
12320 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12321 res->vf_id, is_on);
12328 printf("invalid vf_id %d\n", res->vf_id);
12331 printf("invalid port_id %d\n", res->port_id);
12334 printf("function not implemented\n");
12337 printf("programming error: (%s)\n", strerror(-ret));
12341 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12342 .f = cmd_set_vf_allmulti_parsed,
12344 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12345 "Set multicast promiscuous mode for a VF from the PF",
12347 (void *)&cmd_vf_allmulti_set,
12348 (void *)&cmd_vf_allmulti_vf,
12349 (void *)&cmd_vf_allmulti_allmulti,
12350 (void *)&cmd_vf_allmulti_port_id,
12351 (void *)&cmd_vf_allmulti_vf_id,
12352 (void *)&cmd_vf_allmulti_on_off,
12357 /* vf broadcast mode configuration */
12359 /* Common result structure for vf broadcast */
12360 struct cmd_set_vf_broadcast_result {
12361 cmdline_fixed_string_t set;
12362 cmdline_fixed_string_t vf;
12363 cmdline_fixed_string_t broadcast;
12366 cmdline_fixed_string_t on_off;
12369 /* Common CLI fields for vf broadcast enable disable */
12370 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12371 TOKEN_STRING_INITIALIZER
12372 (struct cmd_set_vf_broadcast_result,
12374 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12375 TOKEN_STRING_INITIALIZER
12376 (struct cmd_set_vf_broadcast_result,
12378 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_set_vf_broadcast_result,
12381 broadcast, "broadcast");
12382 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12383 TOKEN_NUM_INITIALIZER
12384 (struct cmd_set_vf_broadcast_result,
12386 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12387 TOKEN_NUM_INITIALIZER
12388 (struct cmd_set_vf_broadcast_result,
12390 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12391 TOKEN_STRING_INITIALIZER
12392 (struct cmd_set_vf_broadcast_result,
12396 cmd_set_vf_broadcast_parsed(
12397 void *parsed_result,
12398 __attribute__((unused)) struct cmdline *cl,
12399 __attribute__((unused)) void *data)
12401 struct cmd_set_vf_broadcast_result *res = parsed_result;
12402 int ret = -ENOTSUP;
12404 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12406 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12409 #ifdef RTE_LIBRTE_I40E_PMD
12410 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12411 res->vf_id, is_on);
12418 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12421 printf("invalid port_id %d\n", res->port_id);
12424 printf("function not implemented\n");
12427 printf("programming error: (%s)\n", strerror(-ret));
12431 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12432 .f = cmd_set_vf_broadcast_parsed,
12434 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12436 (void *)&cmd_set_vf_broadcast_set,
12437 (void *)&cmd_set_vf_broadcast_vf,
12438 (void *)&cmd_set_vf_broadcast_broadcast,
12439 (void *)&cmd_set_vf_broadcast_port_id,
12440 (void *)&cmd_set_vf_broadcast_vf_id,
12441 (void *)&cmd_set_vf_broadcast_on_off,
12446 /* vf vlan tag configuration */
12448 /* Common result structure for vf vlan tag */
12449 struct cmd_set_vf_vlan_tag_result {
12450 cmdline_fixed_string_t set;
12451 cmdline_fixed_string_t vf;
12452 cmdline_fixed_string_t vlan;
12453 cmdline_fixed_string_t tag;
12456 cmdline_fixed_string_t on_off;
12459 /* Common CLI fields for vf vlan tag enable disable */
12460 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12461 TOKEN_STRING_INITIALIZER
12462 (struct cmd_set_vf_vlan_tag_result,
12464 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_set_vf_vlan_tag_result,
12468 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_set_vf_vlan_tag_result,
12472 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_set_vf_vlan_tag_result,
12476 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12477 TOKEN_NUM_INITIALIZER
12478 (struct cmd_set_vf_vlan_tag_result,
12480 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12481 TOKEN_NUM_INITIALIZER
12482 (struct cmd_set_vf_vlan_tag_result,
12484 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12485 TOKEN_STRING_INITIALIZER
12486 (struct cmd_set_vf_vlan_tag_result,
12490 cmd_set_vf_vlan_tag_parsed(
12491 void *parsed_result,
12492 __attribute__((unused)) struct cmdline *cl,
12493 __attribute__((unused)) void *data)
12495 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12496 int ret = -ENOTSUP;
12498 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12500 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12503 #ifdef RTE_LIBRTE_I40E_PMD
12504 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12505 res->vf_id, is_on);
12512 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12515 printf("invalid port_id %d\n", res->port_id);
12518 printf("function not implemented\n");
12521 printf("programming error: (%s)\n", strerror(-ret));
12525 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12526 .f = cmd_set_vf_vlan_tag_parsed,
12528 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12530 (void *)&cmd_set_vf_vlan_tag_set,
12531 (void *)&cmd_set_vf_vlan_tag_vf,
12532 (void *)&cmd_set_vf_vlan_tag_vlan,
12533 (void *)&cmd_set_vf_vlan_tag_tag,
12534 (void *)&cmd_set_vf_vlan_tag_port_id,
12535 (void *)&cmd_set_vf_vlan_tag_vf_id,
12536 (void *)&cmd_set_vf_vlan_tag_on_off,
12541 /* Common definition of VF and TC TX bandwidth configuration */
12542 struct cmd_vf_tc_bw_result {
12543 cmdline_fixed_string_t set;
12544 cmdline_fixed_string_t vf;
12545 cmdline_fixed_string_t tc;
12546 cmdline_fixed_string_t tx;
12547 cmdline_fixed_string_t min_bw;
12548 cmdline_fixed_string_t max_bw;
12549 cmdline_fixed_string_t strict_link_prio;
12554 cmdline_fixed_string_t bw_list;
12558 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12559 TOKEN_STRING_INITIALIZER
12560 (struct cmd_vf_tc_bw_result,
12562 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12563 TOKEN_STRING_INITIALIZER
12564 (struct cmd_vf_tc_bw_result,
12566 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12567 TOKEN_STRING_INITIALIZER
12568 (struct cmd_vf_tc_bw_result,
12570 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12571 TOKEN_STRING_INITIALIZER
12572 (struct cmd_vf_tc_bw_result,
12574 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12575 TOKEN_STRING_INITIALIZER
12576 (struct cmd_vf_tc_bw_result,
12577 strict_link_prio, "strict-link-priority");
12578 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12579 TOKEN_STRING_INITIALIZER
12580 (struct cmd_vf_tc_bw_result,
12581 min_bw, "min-bandwidth");
12582 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12583 TOKEN_STRING_INITIALIZER
12584 (struct cmd_vf_tc_bw_result,
12585 max_bw, "max-bandwidth");
12586 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12587 TOKEN_NUM_INITIALIZER
12588 (struct cmd_vf_tc_bw_result,
12590 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12591 TOKEN_NUM_INITIALIZER
12592 (struct cmd_vf_tc_bw_result,
12594 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12595 TOKEN_NUM_INITIALIZER
12596 (struct cmd_vf_tc_bw_result,
12598 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12599 TOKEN_NUM_INITIALIZER
12600 (struct cmd_vf_tc_bw_result,
12602 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12603 TOKEN_STRING_INITIALIZER
12604 (struct cmd_vf_tc_bw_result,
12606 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12607 TOKEN_NUM_INITIALIZER
12608 (struct cmd_vf_tc_bw_result,
12611 /* VF max bandwidth setting */
12613 cmd_vf_max_bw_parsed(
12614 void *parsed_result,
12615 __attribute__((unused)) struct cmdline *cl,
12616 __attribute__((unused)) void *data)
12618 struct cmd_vf_tc_bw_result *res = parsed_result;
12619 int ret = -ENOTSUP;
12621 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12624 #ifdef RTE_LIBRTE_I40E_PMD
12625 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12626 res->vf_id, res->bw);
12633 printf("invalid vf_id %d or bandwidth %d\n",
12634 res->vf_id, res->bw);
12637 printf("invalid port_id %d\n", res->port_id);
12640 printf("function not implemented\n");
12643 printf("programming error: (%s)\n", strerror(-ret));
12647 cmdline_parse_inst_t cmd_vf_max_bw = {
12648 .f = cmd_vf_max_bw_parsed,
12650 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12652 (void *)&cmd_vf_tc_bw_set,
12653 (void *)&cmd_vf_tc_bw_vf,
12654 (void *)&cmd_vf_tc_bw_tx,
12655 (void *)&cmd_vf_tc_bw_max_bw,
12656 (void *)&cmd_vf_tc_bw_port_id,
12657 (void *)&cmd_vf_tc_bw_vf_id,
12658 (void *)&cmd_vf_tc_bw_bw,
12664 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12669 const char *p, *p0 = str;
12676 p = strchr(p0, '(');
12678 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12682 p0 = strchr(p, ')');
12684 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12688 if (size >= sizeof(s)) {
12689 printf("The string size exceeds the internal buffer size\n");
12692 snprintf(s, sizeof(s), "%.*s", size, p);
12693 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12695 printf("Failed to get the bandwidth list. ");
12699 for (i = 0; i < ret; i++)
12700 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12705 /* TC min bandwidth setting */
12707 cmd_vf_tc_min_bw_parsed(
12708 void *parsed_result,
12709 __attribute__((unused)) struct cmdline *cl,
12710 __attribute__((unused)) void *data)
12712 struct cmd_vf_tc_bw_result *res = parsed_result;
12715 int ret = -ENOTSUP;
12717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12720 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12724 #ifdef RTE_LIBRTE_I40E_PMD
12725 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12733 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12736 printf("invalid port_id %d\n", res->port_id);
12739 printf("function not implemented\n");
12742 printf("programming error: (%s)\n", strerror(-ret));
12746 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12747 .f = cmd_vf_tc_min_bw_parsed,
12749 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12750 " <bw1, bw2, ...>",
12752 (void *)&cmd_vf_tc_bw_set,
12753 (void *)&cmd_vf_tc_bw_vf,
12754 (void *)&cmd_vf_tc_bw_tc,
12755 (void *)&cmd_vf_tc_bw_tx,
12756 (void *)&cmd_vf_tc_bw_min_bw,
12757 (void *)&cmd_vf_tc_bw_port_id,
12758 (void *)&cmd_vf_tc_bw_vf_id,
12759 (void *)&cmd_vf_tc_bw_bw_list,
12765 cmd_tc_min_bw_parsed(
12766 void *parsed_result,
12767 __attribute__((unused)) struct cmdline *cl,
12768 __attribute__((unused)) void *data)
12770 struct cmd_vf_tc_bw_result *res = parsed_result;
12771 struct rte_port *port;
12774 int ret = -ENOTSUP;
12776 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12779 port = &ports[res->port_id];
12780 /** Check if the port is not started **/
12781 if (port->port_status != RTE_PORT_STOPPED) {
12782 printf("Please stop port %d first\n", res->port_id);
12786 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12790 #ifdef RTE_LIBRTE_IXGBE_PMD
12791 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12798 printf("invalid bandwidth\n");
12801 printf("invalid port_id %d\n", res->port_id);
12804 printf("function not implemented\n");
12807 printf("programming error: (%s)\n", strerror(-ret));
12811 cmdline_parse_inst_t cmd_tc_min_bw = {
12812 .f = cmd_tc_min_bw_parsed,
12814 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12816 (void *)&cmd_vf_tc_bw_set,
12817 (void *)&cmd_vf_tc_bw_tc,
12818 (void *)&cmd_vf_tc_bw_tx,
12819 (void *)&cmd_vf_tc_bw_min_bw,
12820 (void *)&cmd_vf_tc_bw_port_id,
12821 (void *)&cmd_vf_tc_bw_bw_list,
12826 /* TC max bandwidth setting */
12828 cmd_vf_tc_max_bw_parsed(
12829 void *parsed_result,
12830 __attribute__((unused)) struct cmdline *cl,
12831 __attribute__((unused)) void *data)
12833 struct cmd_vf_tc_bw_result *res = parsed_result;
12834 int ret = -ENOTSUP;
12836 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12839 #ifdef RTE_LIBRTE_I40E_PMD
12840 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12841 res->tc_no, res->bw);
12848 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12849 res->vf_id, res->tc_no, res->bw);
12852 printf("invalid port_id %d\n", res->port_id);
12855 printf("function not implemented\n");
12858 printf("programming error: (%s)\n", strerror(-ret));
12862 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12863 .f = cmd_vf_tc_max_bw_parsed,
12865 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12868 (void *)&cmd_vf_tc_bw_set,
12869 (void *)&cmd_vf_tc_bw_vf,
12870 (void *)&cmd_vf_tc_bw_tc,
12871 (void *)&cmd_vf_tc_bw_tx,
12872 (void *)&cmd_vf_tc_bw_max_bw,
12873 (void *)&cmd_vf_tc_bw_port_id,
12874 (void *)&cmd_vf_tc_bw_vf_id,
12875 (void *)&cmd_vf_tc_bw_tc_no,
12876 (void *)&cmd_vf_tc_bw_bw,
12881 /* Strict link priority scheduling mode setting */
12883 cmd_strict_link_prio_parsed(
12884 void *parsed_result,
12885 __attribute__((unused)) struct cmdline *cl,
12886 __attribute__((unused)) void *data)
12888 struct cmd_vf_tc_bw_result *res = parsed_result;
12889 int ret = -ENOTSUP;
12891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12894 #ifdef RTE_LIBRTE_I40E_PMD
12895 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12902 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12905 printf("invalid port_id %d\n", res->port_id);
12908 printf("function not implemented\n");
12911 printf("programming error: (%s)\n", strerror(-ret));
12915 cmdline_parse_inst_t cmd_strict_link_prio = {
12916 .f = cmd_strict_link_prio_parsed,
12918 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12920 (void *)&cmd_vf_tc_bw_set,
12921 (void *)&cmd_vf_tc_bw_tx,
12922 (void *)&cmd_vf_tc_bw_strict_link_prio,
12923 (void *)&cmd_vf_tc_bw_port_id,
12924 (void *)&cmd_vf_tc_bw_tc_map,
12929 /* Load dynamic device personalization*/
12930 struct cmd_ddp_add_result {
12931 cmdline_fixed_string_t ddp;
12932 cmdline_fixed_string_t add;
12937 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12938 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12939 cmdline_parse_token_string_t cmd_ddp_add_add =
12940 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12941 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12942 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12943 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12944 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12947 cmd_ddp_add_parsed(
12948 void *parsed_result,
12949 __attribute__((unused)) struct cmdline *cl,
12950 __attribute__((unused)) void *data)
12952 struct cmd_ddp_add_result *res = parsed_result;
12955 int ret = -ENOTSUP;
12957 if (res->port_id > nb_ports) {
12958 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12962 if (!all_ports_stopped()) {
12963 printf("Please stop all ports first\n");
12967 buff = open_ddp_package_file(res->filepath, &size);
12971 #ifdef RTE_LIBRTE_I40E_PMD
12972 if (ret == -ENOTSUP)
12973 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12975 RTE_PMD_I40E_PKG_OP_WR_ADD);
12979 printf("Failed to load profile.\n");
12981 printf("Profile has already existed.\n");
12983 close_ddp_package_file(buff);
12986 cmdline_parse_inst_t cmd_ddp_add = {
12987 .f = cmd_ddp_add_parsed,
12989 .help_str = "ddp add <port_id> <profile_path>",
12991 (void *)&cmd_ddp_add_ddp,
12992 (void *)&cmd_ddp_add_add,
12993 (void *)&cmd_ddp_add_port_id,
12994 (void *)&cmd_ddp_add_filepath,
12999 /* Get dynamic device personalization profile info list*/
13000 #define PROFILE_INFO_SIZE 48
13001 #define MAX_PROFILE_NUM 16
13003 struct cmd_ddp_get_list_result {
13004 cmdline_fixed_string_t ddp;
13005 cmdline_fixed_string_t get;
13006 cmdline_fixed_string_t list;
13010 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13011 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13012 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13013 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13014 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13015 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13016 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13017 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13020 cmd_ddp_get_list_parsed(
13021 void *parsed_result,
13022 __attribute__((unused)) struct cmdline *cl,
13023 __attribute__((unused)) void *data)
13025 struct cmd_ddp_get_list_result *res = parsed_result;
13026 #ifdef RTE_LIBRTE_I40E_PMD
13027 struct rte_pmd_i40e_profile_list *p_list;
13028 struct rte_pmd_i40e_profile_info *p_info;
13033 int ret = -ENOTSUP;
13035 if (res->port_id > nb_ports) {
13036 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13040 #ifdef RTE_LIBRTE_I40E_PMD
13041 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13042 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13044 printf("%s: Failed to malloc buffer\n", __func__);
13046 if (ret == -ENOTSUP)
13047 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13048 (uint8_t *)p_list, size);
13051 p_num = p_list->p_count;
13052 printf("Profile number is: %d\n\n", p_num);
13054 for (i = 0; i < p_num; i++) {
13055 p_info = &p_list->p_info[i];
13056 printf("Profile %d:\n", i);
13057 printf("Track id: 0x%x\n", p_info->track_id);
13058 printf("Version: %d.%d.%d.%d\n",
13059 p_info->version.major,
13060 p_info->version.minor,
13061 p_info->version.update,
13062 p_info->version.draft);
13063 printf("Profile name: %s\n\n", p_info->name);
13071 printf("Failed to get ddp list\n");
13074 cmdline_parse_inst_t cmd_ddp_get_list = {
13075 .f = cmd_ddp_get_list_parsed,
13077 .help_str = "ddp get list <port_id>",
13079 (void *)&cmd_ddp_get_list_ddp,
13080 (void *)&cmd_ddp_get_list_get,
13081 (void *)&cmd_ddp_get_list_list,
13082 (void *)&cmd_ddp_get_list_port_id,
13087 /* show vf stats */
13089 /* Common result structure for show vf stats */
13090 struct cmd_show_vf_stats_result {
13091 cmdline_fixed_string_t show;
13092 cmdline_fixed_string_t vf;
13093 cmdline_fixed_string_t stats;
13098 /* Common CLI fields show vf stats*/
13099 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13100 TOKEN_STRING_INITIALIZER
13101 (struct cmd_show_vf_stats_result,
13103 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13104 TOKEN_STRING_INITIALIZER
13105 (struct cmd_show_vf_stats_result,
13107 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13108 TOKEN_STRING_INITIALIZER
13109 (struct cmd_show_vf_stats_result,
13111 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13112 TOKEN_NUM_INITIALIZER
13113 (struct cmd_show_vf_stats_result,
13115 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13116 TOKEN_NUM_INITIALIZER
13117 (struct cmd_show_vf_stats_result,
13121 cmd_show_vf_stats_parsed(
13122 void *parsed_result,
13123 __attribute__((unused)) struct cmdline *cl,
13124 __attribute__((unused)) void *data)
13126 struct cmd_show_vf_stats_result *res = parsed_result;
13127 struct rte_eth_stats stats;
13128 int ret = -ENOTSUP;
13129 static const char *nic_stats_border = "########################";
13131 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13134 memset(&stats, 0, sizeof(stats));
13136 #ifdef RTE_LIBRTE_I40E_PMD
13137 if (ret == -ENOTSUP)
13138 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13142 #ifdef RTE_LIBRTE_BNXT_PMD
13143 if (ret == -ENOTSUP)
13144 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13153 printf("invalid vf_id %d\n", res->vf_id);
13156 printf("invalid port_id %d\n", res->port_id);
13159 printf("function not implemented\n");
13162 printf("programming error: (%s)\n", strerror(-ret));
13165 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13166 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13168 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13170 stats.ipackets, stats.imissed, stats.ibytes);
13171 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13172 printf(" RX-nombuf: %-10"PRIu64"\n",
13174 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13176 stats.opackets, stats.oerrors, stats.obytes);
13178 printf(" %s############################%s\n",
13179 nic_stats_border, nic_stats_border);
13182 cmdline_parse_inst_t cmd_show_vf_stats = {
13183 .f = cmd_show_vf_stats_parsed,
13185 .help_str = "show vf stats <port_id> <vf_id>",
13187 (void *)&cmd_show_vf_stats_show,
13188 (void *)&cmd_show_vf_stats_vf,
13189 (void *)&cmd_show_vf_stats_stats,
13190 (void *)&cmd_show_vf_stats_port_id,
13191 (void *)&cmd_show_vf_stats_vf_id,
13196 /* clear vf stats */
13198 /* Common result structure for clear vf stats */
13199 struct cmd_clear_vf_stats_result {
13200 cmdline_fixed_string_t clear;
13201 cmdline_fixed_string_t vf;
13202 cmdline_fixed_string_t stats;
13207 /* Common CLI fields clear vf stats*/
13208 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13209 TOKEN_STRING_INITIALIZER
13210 (struct cmd_clear_vf_stats_result,
13212 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13213 TOKEN_STRING_INITIALIZER
13214 (struct cmd_clear_vf_stats_result,
13216 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13217 TOKEN_STRING_INITIALIZER
13218 (struct cmd_clear_vf_stats_result,
13220 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13221 TOKEN_NUM_INITIALIZER
13222 (struct cmd_clear_vf_stats_result,
13224 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13225 TOKEN_NUM_INITIALIZER
13226 (struct cmd_clear_vf_stats_result,
13230 cmd_clear_vf_stats_parsed(
13231 void *parsed_result,
13232 __attribute__((unused)) struct cmdline *cl,
13233 __attribute__((unused)) void *data)
13235 struct cmd_clear_vf_stats_result *res = parsed_result;
13236 int ret = -ENOTSUP;
13238 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13241 #ifdef RTE_LIBRTE_I40E_PMD
13242 if (ret == -ENOTSUP)
13243 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13246 #ifdef RTE_LIBRTE_BNXT_PMD
13247 if (ret == -ENOTSUP)
13248 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13256 printf("invalid vf_id %d\n", res->vf_id);
13259 printf("invalid port_id %d\n", res->port_id);
13262 printf("function not implemented\n");
13265 printf("programming error: (%s)\n", strerror(-ret));
13269 cmdline_parse_inst_t cmd_clear_vf_stats = {
13270 .f = cmd_clear_vf_stats_parsed,
13272 .help_str = "clear vf stats <port_id> <vf_id>",
13274 (void *)&cmd_clear_vf_stats_clear,
13275 (void *)&cmd_clear_vf_stats_vf,
13276 (void *)&cmd_clear_vf_stats_stats,
13277 (void *)&cmd_clear_vf_stats_port_id,
13278 (void *)&cmd_clear_vf_stats_vf_id,
13283 /* ptype mapping get */
13285 /* Common result structure for ptype mapping get */
13286 struct cmd_ptype_mapping_get_result {
13287 cmdline_fixed_string_t ptype;
13288 cmdline_fixed_string_t mapping;
13289 cmdline_fixed_string_t get;
13291 uint8_t valid_only;
13294 /* Common CLI fields for ptype mapping get */
13295 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13296 TOKEN_STRING_INITIALIZER
13297 (struct cmd_ptype_mapping_get_result,
13299 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13300 TOKEN_STRING_INITIALIZER
13301 (struct cmd_ptype_mapping_get_result,
13302 mapping, "mapping");
13303 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13304 TOKEN_STRING_INITIALIZER
13305 (struct cmd_ptype_mapping_get_result,
13307 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13308 TOKEN_NUM_INITIALIZER
13309 (struct cmd_ptype_mapping_get_result,
13311 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13312 TOKEN_NUM_INITIALIZER
13313 (struct cmd_ptype_mapping_get_result,
13314 valid_only, UINT8);
13317 cmd_ptype_mapping_get_parsed(
13318 void *parsed_result,
13319 __attribute__((unused)) struct cmdline *cl,
13320 __attribute__((unused)) void *data)
13322 struct cmd_ptype_mapping_get_result *res = parsed_result;
13323 int ret = -ENOTSUP;
13324 #ifdef RTE_LIBRTE_I40E_PMD
13325 int max_ptype_num = 256;
13326 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13331 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13334 #ifdef RTE_LIBRTE_I40E_PMD
13335 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13346 printf("invalid port_id %d\n", res->port_id);
13349 printf("function not implemented\n");
13352 printf("programming error: (%s)\n", strerror(-ret));
13355 #ifdef RTE_LIBRTE_I40E_PMD
13357 for (i = 0; i < count; i++)
13358 printf("%3d\t0x%08x\n",
13359 mapping[i].hw_ptype, mapping[i].sw_ptype);
13364 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13365 .f = cmd_ptype_mapping_get_parsed,
13367 .help_str = "ptype mapping get <port_id> <valid_only>",
13369 (void *)&cmd_ptype_mapping_get_ptype,
13370 (void *)&cmd_ptype_mapping_get_mapping,
13371 (void *)&cmd_ptype_mapping_get_get,
13372 (void *)&cmd_ptype_mapping_get_port_id,
13373 (void *)&cmd_ptype_mapping_get_valid_only,
13378 /* ptype mapping replace */
13380 /* Common result structure for ptype mapping replace */
13381 struct cmd_ptype_mapping_replace_result {
13382 cmdline_fixed_string_t ptype;
13383 cmdline_fixed_string_t mapping;
13384 cmdline_fixed_string_t replace;
13391 /* Common CLI fields for ptype mapping replace */
13392 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13393 TOKEN_STRING_INITIALIZER
13394 (struct cmd_ptype_mapping_replace_result,
13396 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13397 TOKEN_STRING_INITIALIZER
13398 (struct cmd_ptype_mapping_replace_result,
13399 mapping, "mapping");
13400 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13401 TOKEN_STRING_INITIALIZER
13402 (struct cmd_ptype_mapping_replace_result,
13403 replace, "replace");
13404 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13405 TOKEN_NUM_INITIALIZER
13406 (struct cmd_ptype_mapping_replace_result,
13408 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13409 TOKEN_NUM_INITIALIZER
13410 (struct cmd_ptype_mapping_replace_result,
13412 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13413 TOKEN_NUM_INITIALIZER
13414 (struct cmd_ptype_mapping_replace_result,
13416 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13417 TOKEN_NUM_INITIALIZER
13418 (struct cmd_ptype_mapping_replace_result,
13422 cmd_ptype_mapping_replace_parsed(
13423 void *parsed_result,
13424 __attribute__((unused)) struct cmdline *cl,
13425 __attribute__((unused)) void *data)
13427 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13428 int ret = -ENOTSUP;
13430 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13433 #ifdef RTE_LIBRTE_I40E_PMD
13434 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13444 printf("invalid ptype 0x%8x or 0x%8x\n",
13445 res->target, res->pkt_type);
13448 printf("invalid port_id %d\n", res->port_id);
13451 printf("function not implemented\n");
13454 printf("programming error: (%s)\n", strerror(-ret));
13458 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13459 .f = cmd_ptype_mapping_replace_parsed,
13462 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13464 (void *)&cmd_ptype_mapping_replace_ptype,
13465 (void *)&cmd_ptype_mapping_replace_mapping,
13466 (void *)&cmd_ptype_mapping_replace_replace,
13467 (void *)&cmd_ptype_mapping_replace_port_id,
13468 (void *)&cmd_ptype_mapping_replace_target,
13469 (void *)&cmd_ptype_mapping_replace_mask,
13470 (void *)&cmd_ptype_mapping_replace_pkt_type,
13475 /* ptype mapping reset */
13477 /* Common result structure for ptype mapping reset */
13478 struct cmd_ptype_mapping_reset_result {
13479 cmdline_fixed_string_t ptype;
13480 cmdline_fixed_string_t mapping;
13481 cmdline_fixed_string_t reset;
13485 /* Common CLI fields for ptype mapping reset*/
13486 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
13487 TOKEN_STRING_INITIALIZER
13488 (struct cmd_ptype_mapping_reset_result,
13490 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
13491 TOKEN_STRING_INITIALIZER
13492 (struct cmd_ptype_mapping_reset_result,
13493 mapping, "mapping");
13494 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
13495 TOKEN_STRING_INITIALIZER
13496 (struct cmd_ptype_mapping_reset_result,
13498 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
13499 TOKEN_NUM_INITIALIZER
13500 (struct cmd_ptype_mapping_reset_result,
13504 cmd_ptype_mapping_reset_parsed(
13505 void *parsed_result,
13506 __attribute__((unused)) struct cmdline *cl,
13507 __attribute__((unused)) void *data)
13509 struct cmd_ptype_mapping_reset_result *res = parsed_result;
13510 int ret = -ENOTSUP;
13512 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13515 #ifdef RTE_LIBRTE_I40E_PMD
13516 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
13523 printf("invalid port_id %d\n", res->port_id);
13526 printf("function not implemented\n");
13529 printf("programming error: (%s)\n", strerror(-ret));
13533 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
13534 .f = cmd_ptype_mapping_reset_parsed,
13536 .help_str = "ptype mapping reset <port_id>",
13538 (void *)&cmd_ptype_mapping_reset_ptype,
13539 (void *)&cmd_ptype_mapping_reset_mapping,
13540 (void *)&cmd_ptype_mapping_reset_reset,
13541 (void *)&cmd_ptype_mapping_reset_port_id,
13546 /* ptype mapping update */
13548 /* Common result structure for ptype mapping update */
13549 struct cmd_ptype_mapping_update_result {
13550 cmdline_fixed_string_t ptype;
13551 cmdline_fixed_string_t mapping;
13552 cmdline_fixed_string_t reset;
13558 /* Common CLI fields for ptype mapping update*/
13559 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
13560 TOKEN_STRING_INITIALIZER
13561 (struct cmd_ptype_mapping_update_result,
13563 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
13564 TOKEN_STRING_INITIALIZER
13565 (struct cmd_ptype_mapping_update_result,
13566 mapping, "mapping");
13567 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
13568 TOKEN_STRING_INITIALIZER
13569 (struct cmd_ptype_mapping_update_result,
13571 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
13572 TOKEN_NUM_INITIALIZER
13573 (struct cmd_ptype_mapping_update_result,
13575 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
13576 TOKEN_NUM_INITIALIZER
13577 (struct cmd_ptype_mapping_update_result,
13579 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
13580 TOKEN_NUM_INITIALIZER
13581 (struct cmd_ptype_mapping_update_result,
13585 cmd_ptype_mapping_update_parsed(
13586 void *parsed_result,
13587 __attribute__((unused)) struct cmdline *cl,
13588 __attribute__((unused)) void *data)
13590 struct cmd_ptype_mapping_update_result *res = parsed_result;
13591 int ret = -ENOTSUP;
13592 #ifdef RTE_LIBRTE_I40E_PMD
13593 struct rte_pmd_i40e_ptype_mapping mapping;
13595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13598 #ifdef RTE_LIBRTE_I40E_PMD
13599 mapping.hw_ptype = res->hw_ptype;
13600 mapping.sw_ptype = res->sw_ptype;
13601 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
13611 printf("invalid ptype 0x%8x\n", res->sw_ptype);
13614 printf("invalid port_id %d\n", res->port_id);
13617 printf("function not implemented\n");
13620 printf("programming error: (%s)\n", strerror(-ret));
13624 cmdline_parse_inst_t cmd_ptype_mapping_update = {
13625 .f = cmd_ptype_mapping_update_parsed,
13627 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
13629 (void *)&cmd_ptype_mapping_update_ptype,
13630 (void *)&cmd_ptype_mapping_update_mapping,
13631 (void *)&cmd_ptype_mapping_update_update,
13632 (void *)&cmd_ptype_mapping_update_port_id,
13633 (void *)&cmd_ptype_mapping_update_hw_ptype,
13634 (void *)&cmd_ptype_mapping_update_sw_ptype,
13639 /* Common result structure for file commands */
13640 struct cmd_cmdfile_result {
13641 cmdline_fixed_string_t load;
13642 cmdline_fixed_string_t filename;
13645 /* Common CLI fields for file commands */
13646 cmdline_parse_token_string_t cmd_load_cmdfile =
13647 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
13648 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
13649 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
13652 cmd_load_from_file_parsed(
13653 void *parsed_result,
13654 __attribute__((unused)) struct cmdline *cl,
13655 __attribute__((unused)) void *data)
13657 struct cmd_cmdfile_result *res = parsed_result;
13659 cmdline_read_from_file(res->filename);
13662 cmdline_parse_inst_t cmd_load_from_file = {
13663 .f = cmd_load_from_file_parsed,
13665 .help_str = "load <filename>",
13667 (void *)&cmd_load_cmdfile,
13668 (void *)&cmd_load_cmdfile_filename,
13673 /* ******************************************************************************** */
13675 /* list of instructions */
13676 cmdline_parse_ctx_t main_ctx[] = {
13677 (cmdline_parse_inst_t *)&cmd_help_brief,
13678 (cmdline_parse_inst_t *)&cmd_help_long,
13679 (cmdline_parse_inst_t *)&cmd_quit,
13680 (cmdline_parse_inst_t *)&cmd_load_from_file,
13681 (cmdline_parse_inst_t *)&cmd_showport,
13682 (cmdline_parse_inst_t *)&cmd_showqueue,
13683 (cmdline_parse_inst_t *)&cmd_showportall,
13684 (cmdline_parse_inst_t *)&cmd_showcfg,
13685 (cmdline_parse_inst_t *)&cmd_start,
13686 (cmdline_parse_inst_t *)&cmd_start_tx_first,
13687 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13688 (cmdline_parse_inst_t *)&cmd_set_link_up,
13689 (cmdline_parse_inst_t *)&cmd_set_link_down,
13690 (cmdline_parse_inst_t *)&cmd_reset,
13691 (cmdline_parse_inst_t *)&cmd_set_numbers,
13692 (cmdline_parse_inst_t *)&cmd_set_txpkts,
13693 (cmdline_parse_inst_t *)&cmd_set_txsplit,
13694 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13695 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13696 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13697 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13698 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13699 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13700 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13701 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13702 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13703 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13704 (cmdline_parse_inst_t *)&cmd_set_link_check,
13705 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13706 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13707 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13708 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13709 #ifdef RTE_LIBRTE_PMD_BOND
13710 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13711 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13712 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13713 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13714 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13715 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13716 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13717 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13718 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13720 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13721 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13722 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13723 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13724 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13725 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13726 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13727 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13728 (cmdline_parse_inst_t *)&cmd_csum_set,
13729 (cmdline_parse_inst_t *)&cmd_csum_show,
13730 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13731 (cmdline_parse_inst_t *)&cmd_tso_set,
13732 (cmdline_parse_inst_t *)&cmd_tso_show,
13733 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13734 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13735 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13736 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13737 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13738 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13739 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13740 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13741 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13742 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13743 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13744 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13745 (cmdline_parse_inst_t *)&cmd_config_dcb,
13746 (cmdline_parse_inst_t *)&cmd_read_reg,
13747 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13748 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13749 (cmdline_parse_inst_t *)&cmd_write_reg,
13750 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13751 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13752 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13753 (cmdline_parse_inst_t *)&cmd_stop,
13754 (cmdline_parse_inst_t *)&cmd_mac_addr,
13755 (cmdline_parse_inst_t *)&cmd_set_qmap,
13756 (cmdline_parse_inst_t *)&cmd_operate_port,
13757 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13758 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13759 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13760 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13761 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13762 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13763 (cmdline_parse_inst_t *)&cmd_config_mtu,
13764 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13765 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13766 (cmdline_parse_inst_t *)&cmd_config_rss,
13767 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13768 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13769 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13770 (cmdline_parse_inst_t *)&cmd_showport_reta,
13771 (cmdline_parse_inst_t *)&cmd_config_burst,
13772 (cmdline_parse_inst_t *)&cmd_config_thresh,
13773 (cmdline_parse_inst_t *)&cmd_config_threshold,
13774 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13775 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13776 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13777 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13778 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13779 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13780 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13781 (cmdline_parse_inst_t *)&cmd_global_config,
13782 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13783 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13784 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13785 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13786 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13787 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13788 (cmdline_parse_inst_t *)&cmd_dump,
13789 (cmdline_parse_inst_t *)&cmd_dump_one,
13790 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13791 (cmdline_parse_inst_t *)&cmd_syn_filter,
13792 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13793 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13794 (cmdline_parse_inst_t *)&cmd_flex_filter,
13795 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13796 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13797 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13798 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13799 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13800 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13801 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13802 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13803 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13804 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13805 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13806 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13807 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13808 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13809 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13810 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13811 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13812 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13813 (cmdline_parse_inst_t *)&cmd_flow,
13814 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13815 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13816 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13817 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13818 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13819 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13820 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13821 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13822 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13823 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13824 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13825 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13826 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13827 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13828 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13829 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13830 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13831 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13832 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13833 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13834 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13835 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13836 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13837 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13838 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13839 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13840 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13841 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13842 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13843 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13844 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13845 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13846 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13847 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13848 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13849 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
13850 (cmdline_parse_inst_t *)&cmd_ddp_add,
13851 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13852 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13853 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13854 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
13855 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
13856 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
13857 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
13861 /* read cmdline commands from file */
13863 cmdline_read_from_file(const char *filename)
13865 struct cmdline *cl;
13867 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
13869 printf("Failed to create file based cmdline context: %s\n",
13874 cmdline_interact(cl);
13879 printf("Read CLI commands from %s\n", filename);
13882 /* prompt function, called from main on MASTER lcore */
13886 /* initialize non-constant commands */
13887 cmd_set_fwd_mode_init();
13888 cmd_set_fwd_retry_mode_init();
13890 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13891 if (testpmd_cl == NULL)
13893 cmdline_interact(testpmd_cl);
13894 cmdline_stdin_exit(testpmd_cl);
13900 if (testpmd_cl != NULL)
13901 cmdline_quit(testpmd_cl);
13905 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13907 if (id == (portid_t)RTE_PORT_ALL) {
13910 RTE_ETH_FOREACH_DEV(pid) {
13911 /* check if need_reconfig has been set to 1 */
13912 if (ports[pid].need_reconfig == 0)
13913 ports[pid].need_reconfig = dev;
13914 /* check if need_reconfig_queues has been set to 1 */
13915 if (ports[pid].need_reconfig_queues == 0)
13916 ports[pid].need_reconfig_queues = queue;
13918 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13919 /* check if need_reconfig has been set to 1 */
13920 if (ports[id].need_reconfig == 0)
13921 ports[id].need_reconfig = dev;
13922 /* check if need_reconfig_queues has been set to 1 */
13923 if (ports[id].need_reconfig_queues == 0)
13924 ports[id].need_reconfig_queues = queue;